Sunday 25 February 2018

sql function, procedure, trigger

table

procedure

procedure


procedure cursor

cursor

cursor

function

function

function

function procedure

trigger

trigger

table

trigger

trigger

xml


Saturday 24 February 2018

kijiji sell - Dual Band 2.4G / 5G Hz WiFi Adapter



dual band wifi adapter, fully working, 433Mbps Wireless Speed at 5.8GHz band or 150Mbps Speed at 2.4GHz band. Transmission Rate: 600Mbps (150Mbps+433Mbps) Frequency range: 2.412-2.4835GHz, 5.12-5.825GHz Standards: IEEE 802.11a/b/g/n, 802.11ac RF Power: 20dbm (MAX) Support Operating System: windows XP / Vista / Win7 / Win8 / Win10 / Mac / Linux

Wednesday 21 February 2018

职业在美国年薪

最近,美国公布了一些常见工作的中位工资,中位数不同于平均数,美国的平均工资早就被那1%的富人给拉高了,中间数是以一个点为准,工资在这个点以上的人数与工资在这个点以下的人数是相等的,这样更能表现出美国大众的工资水平。



  具体到每个工种来看,在所有工种中,平均工资最高的是外科医生,年薪219770美元,全美共有近4.5万名外科医生;其次是麻醉医师,年薪211750美元,共有3.7万名麻醉医师;平均工资最低的是食品制备及快餐店服务人员,年薪18120美元,从业人员约有269万人。



  下面就来看看吧:



  1、行政助理:中位数工资每小时14美金,一小时在10.58到20.41美元之间。年薪范围在23421到48187美元之间。



  2、销售/销售经理:中位数工资54657美金,年薪从31121到106383美元不等。



  3、收银员:中位数工资8美元一小时,一个小时在7.34到11.01美元之间。年薪在15268到24229美金之间。但是可能会根据最低保障工资调整。



  4、质量检测员:工资中位数16美元每小时,一小时工资在11.06到27.19美元之间。年薪在25111到71333之间。



  5、注册护士:工资中位数为26美元每小时,一小时工资在20.51到38.95美元之间。年薪在42727到82093美金之间



  6、警察:年薪中位数为47938美元,年薪在30757到81485之间。



  7、办公室经理:中位数工资为42491美元,年薪在26128到59189美元之间。



  8、制造工程师:工资中位数为63745美元,年薪在47379到86473美元之间。



  9、信息技术经理:年薪范围在46052美元到127625美元之间,中位数工资为79584美元。



  10、会计及审计师:年薪67430美元,从业人员110万人;



  11、个人理财顾问:94180美元,从业人员15万人;



  12、贷款员:63210美元,从业人员近30万人;



  13、电脑程序员:74690美元,从业人员近37万人;



  14、电脑应用软件工程师:90170美元,从业人员近50万人;



  15、电脑系统软件工程师:96620美元,从业人员近39万人;



  16、网络和计算机系统管理员:70930美元,从业人员近34万人;



  17、统计师:75220美元,从业人员2.1万人;



  18、航空工程师:96270美元,从业人员近7万人;



  19、化学工程师:91670美元,从业人员近3万人;



  20、电脑硬件工程师:101410美元,从业人员6.5万人;



  21、律师:129020美元,从业人员近56万人;



  22、法官:103990美元,从业人员近2.7万人;



  23、小学教师:53150美元,从业人员近155万人;



  24、初中教师:53550美元,从业人员近67万人;



  25、大学数学教师:70550美元,从业人员近4.8万人;



  26、大学物理教师:83320美元,从业人员近1.3万人;



  27、大学政治学教师:76990美元,从业人员1.5万人;



  28、普通牙医:156850美元,从业人员近8.7万人;



  29、口腔颌面外科牙医:210710美元,从业人员5390人;



  30、消防人员:47270美元,从业人员30万人;



  31、大厨:44240美元,从业人员近9.5万人;



  32、理发师:27650美元,从业人员1万人;



  33、导游:25990美元,从业人员近3.2万人。看过了所有人的工资,我们再来看看美国的物价。



  一、餐厅:



  普通——12美元



  中等,两个人,三道菜——50美元



  麦当劳——7美元



  二、菜市场:



  牛奶(一公升)——0.93美元



  一条白面包(500g)——2.56美元



  大米(1kg)——3.57美元



  鸡蛋(12个)——2.75美元



  土鸡(1kg)——10.66美元



  苹果(1kg)——4.24美元



  香蕉(1kg)——1.63美元



  一包万宝路香烟——6.5美元



  三、交通:



  出租车起步价——3美元



  每千米价格——1.6美元



  一公升汽油——0.62美元



  四、房租:



  市中心的套一公寓——1192.61美元



  周边地区套一公寓——895.80美元



  市中心的套三公寓——1976.36美元



  周边地区套三公寓——1490.38美元



  五、买房:



  市中心公寓每平米价格——2355.62美元



  周边地区每平方米价格——1541.06美元



  以上价格是2016年最新的平均价格。

Monday 19 February 2018

IIS basic authentication

in features -> iis -> wwws -> security -> basic authentication

open iis -> select app -> authentication ->enable basic -> disable anonymous

edit basic authentication -> leave settings blank

when open the website, authentication is required,
user name, password same as windows login


in settings, add user to pc/server as standard user -> verify new user by email

authentication verified, webpage accessed

reference:





Saturday 17 February 2018

css 3D


Cube with transparent faces

1
2
4
5



<style>
#box1 {
    -webkit-perspective: 800px;
    -webkit-perspective-origin: 50% 150px;
}

#cube {
    position: relative;
    margin: 80px auto;
    height: 300px;
    width: 300px;
    -webkit-transition: -webkit-transform 2s linear;
    -webkit-transform-style: preserve-3d;
    animation-name: spin3D;
    animation-duration: 8s;
    animation-iteration-count: infinite;
}

@keyframes spin3D {
    0% {
        -webkit-transform: rotateX(0deg) rotateY(0deg);
        -moz-transform: rotateX(0deg) rotateY(0deg);
    }

    15% {
        -webkit-transform: rotateX(0deg) rotateY(-90deg);
        -moz-transform: rotateX(0deg) rotateY(-90deg);
    }

    30% {
        -webkit-transform: rotateX(0deg) rotateY(-180deg);
        -moz-transform: rotateX(0deg) rotateY(-180deg);
    }

    45% {
        -webkit-transform: rotateX(0deg) rotateY(-270deg);
        -moz-transform: rotateX(0deg) rotateY(-270deg);
    }

    65% {
        -webkit-transform: rotateX(-90deg) rotateY(0deg);
        -moz-transform: rotateX(-90deg) rotateY(0deg);
    }

    85% {
        -webkit-transform: rotateX(90deg) rotateY(0deg);
        -moz-transform: rotateX(90deg) rotateY(0deg);
    }

    100% {
        -webkit-transform: rotateX(0deg) rotateY(0deg);
        -moz-transform: rotateX(0deg) rotateY(0deg);
    }
}

#cube > div {
    position: absolute;
    font-size: 150px;
    text-align: center;
    height: 300px;
    width: 300px;
}

    #cube > div:nth-child(n) {
        height: 100%;
        width: 100%;
    }

    #cube > div:first-child {
        -webkit-transform: translateZ(150px);
        -moz-transform: translateZ(150px);
        background-color: rgba(0, 255, 0, 0.7);
    }

    #cube > div:nth-child(2) {
        -webkit-transform: rotateY(90deg) translateZ(150px);
        -moz-transform: rotateY(90deg) translateZ(150px);
        background-color: rgba(0, 0, 0, 0.7);
    }

    #cube > div:nth-child(3) {
        -webkit-transform: rotateY(180deg) translateZ(150px);
        -moz-transform: rotateY(180deg) translateZ(150px);
        background-color: rgba(196, 0, 0, 0.7);
    }   

    #cube > div:nth-child(4) {
        -webkit-transform: rotateY(-90deg) translateZ(150px);
        -moz-transform: rotateY(-90deg) translateZ(150px);
        background-color: rgba(0, 0, 196, 0.7);
    }

    #cube > div:nth-child(5) {
        -webkit-transform: rotateX(90deg) translateZ(150px);
        -moz-transform: rotateX(90deg) translateZ(150px);
        background-color: rgba(196, 196, 0, 0.7);
    }

    #cube > div:nth-child(6) {
        -webkit-transform: rotateX(-90deg) translateZ(150px);
        -moz-transform: rotateX(-90deg) translateZ(150px);
        background-color: rgba(196, 0, 196, 0.7);
    }

    .radio_alignment{
        margin:auto;
        text-align:center;
    }
</style>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">

    var enlarged = false;

    function rotate_3D(x_Angle, y_Angle, z_Angle) {
        $("#cube").css({ "animation": "none" });
        $("#cube").css({ "-webkit-transform": "rotateX(" + x_Angle + "deg) rotateY(" + y_Angle + "deg) rotateZ(" + z_Angle + "deg)" });
    }

    function animate1() {
        setTimeout(function () {
            $("#cube").css({ "animation": "" });
        }, 10);
    }

    function stop_anime() {
        $("#cube").css({ "animation": "none" });
    }

</script>

<div id="box">
    <div id="cube">
        <div >1</div>
        <div >2</div>
        <div onclick="window.open('https://www.google.com/maps')"><iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d321303.3268281848!2d-114.35433369398585!3d51.01278199569303!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x537170039f843fd5%3A0x266d3bb1b652b63a!2sCalgary%2C+AB!5e0!3m2!1sfr!2sca!4v1519065821007" width="300" height="225" frameborder="0" style="border:0" allowfullscreen></iframe></div>
        <div >4</div>
        <div >5</div>
        <div onclick="window.open('https://www.youtube.com/embed/0I27JCFMIQM')"><iframe width="280" height="160" src="https://www.youtube.com/embed/0I27JCFMIQM" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>
    </div>
</div>

<div class="radio_alignment">
    <input type="radio" name="select_face" onclick="rotate_3D(0,0,0)" checked="checked" />
    <input type="radio" name="select_face" onclick="rotate_3D(0,-90,0)" />
    <input type="radio" name="select_face" onclick="rotate_3D(0,180,0)" />
    <input type="radio" name="select_face" onclick="rotate_3D(0,90,0)" />
    <input type="radio" name="select_face" onclick="rotate_3D(-90,0,0)" />
    <input type="radio" name="select_face" onclick="rotate_3D(90,0,0)" /><br />
    <button type="button" onclick="animate1()">animate</button>
    <button type="button" onclick="stop_anime()">stop</button>
</div>

reference:
https://www.creativebloq.com/css3/20-stunning-examples-css-3d-transforms-11112759
https://paulrhayes.com/animated-css3-cube-interface-using-3d-transforms/
https://developer.mozilla.org/fr/docs/Web/CSS/perspective
http://jsfiddle.net/leaverou/xK6sa/2/

Saturday 10 February 2018

asp-action asp-route

delete link in index view
--<a asp-action="DeleteTop5" asp-route-num_to_delete="5">Delete top 5</a>--
action specify controller, route specify controller argument

num_to_delete="5" returns 5 record


num_to_delete="3" returns 3 record

num_to_delete="10" returns 10 record


history controller function

//delete few items from top
public async Task<IActionResult> DeleteTop5(int num_to_delete)
        {
            var items = await _context.History.Take(num_to_delete).ToListAsync();
            return View(items);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> DeleteTop5(IFormCollection collection)
        {
            var id_delete = collection["id_num"].ToString().Split(',');

            for (int i = 0; i < id_delete.Length - 1; i++)
            {
                var history = await _context.History.SingleOrDefaultAsync(m => m.Id == Convert.ToInt32(id_delete[i]));
                _context.History.Remove(history);
                await _context.SaveChangesAsync();
            }

            return RedirectToAction(nameof(Index));
        }

-------------------------------------------------------------------------------------------

view index.cshtml

 <a asp-action="DeleteTop5" asp-route-num_to_delete="5">Delete top 5</a>

----------------------------------------------------------------------------------------------

view delete_top_5.cshtml

@model IEnumerable<ebay_track.Models.History>

@{
    ViewData["Title"] = "Delete";
}

<script src="~/lib/jquery/dist/jquery.js"></script>
<script type="text/javascript">

    var num_array='';

    $(document).ready(function () {
        @foreach(var item in Model)
        {
        <text>
        num_array = num_array + '@item.Id' + ',';
        </text>
        }

        $("#id_num").val(num_array);
    });

</script>

<h2>Delete</h2>

<h3>Are you sure you want to delete these?</h3>
<div>
    <h4>History</h4>
    <hr />

    <table class="table">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.Id)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ActionDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ActionType)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Item)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Tracking)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Qty)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShippingDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.DeliveryDate)
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ActionDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ActionType)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Item)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Tracking)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Qty)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShippingDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.DeliveryDate)
                    </td>
                </tr>
            }
        </tbody>
    </table>

    <form method="post">
        <input type="hidden" id="id_num" name="id_num"/>
        <input type="submit" value="Delete" class="btn btn-default" /> |
        <a asp-action="Index">Back to List</a>
    </form>
</div>

Friday 9 February 2018

阿省10大行业的工作与收入

经济变化的信息,我们一般通过加拿大统计局公布的劳动力调查(Labor Force Survey)数据了解,比如:失业率。

加拿大统计局还有一种较为传统的调查,叫做就业、薪酬和工时调查( Survey of Employment, Payroll and Hours)。这种调查能够更全面地反应就业情况,但有一些不足,比如,误差较大、按工作而不是按人进行统计。如果一个人白天做保险代理,晚上去酒吧做服务员,那他一个人所做的就要算成两份工作。

许多专家认为,加拿大统计局对于雇员薪酬(payroll)的调查,是较可靠的数据。卡尔加里大学的经济学教授Trevor Tombe说:“这方面的数据质量较高。”他说,薪酬数据的一个好处是,它能告诉我们人们实际收入有多少,包括加班收入。其缺点是,这项调查并不包括自雇者的收入。

2017年11月份的雇员薪酬数据显示,阿省约有230万份工作。以下是阿省10大行业的雇员在去年11月份的收入状况。

1.零售业:包括商场、加油站、车行等销售商品或提供售后服务的雇员。该行业阿省共有241,077份工作,雇员周收入为$629.56。

2.保健与社会服务:包括医院、老人院、托儿中心等提供保健和社会支持机构的雇员。该行业阿省共有201,240份工作,雇员周收入为$981.39。

3.建筑:阿省的建筑行业在2011年到2014年间很兴旺,但受最近这次经济衰退的冲击较大,工作数量从第二降到了第三。该行业阿省共有188,087份工作,雇员周收入为$1,446.05。

4. 餐饮住宿服务:包括饭店、餐馆、酒吧的雇员。该行业阿省共有163,787份工作,雇员周收入为$435.52。

5.教育服务:包括大、中、小学的雇员、软件、滑雪等培训机构的雇员。该行业阿省共有145,967份工作,雇员周收入为$1,093.28。

6. 制造业:该行业阿省共有122,231份工作,雇员周收入为$1,243.62。

7.专业、科学和技术服务:加拿大统计局的定义是指“几乎全靠工人技能”提供的服务,涉及面较宽,包括法律、会计、设计、工程咨询、科研、广告、公关等。该行业阿省共有114,035份工作,雇员周收入为$1,461.52。

8.公共管理:包括联邦政府、省政府、市政府机构的雇员,如当选的议员、警察、消防队员、士兵、皇家公诉人等。该行业阿省共有109,955份工作,雇员周收入为$1,399.96。

9.采矿、采油、采气和采石业:尽管人们很容易把阿省与石油和天然气开采联系起来,但工作数量仅排在第九。该行业阿省共有106,380份工作,雇员周收入为$2,219.00。

10:运输与仓储业:该行业阿省共有105,263份工作,雇员周收入为$1,214.71。

Sunday 4 February 2018

Host ASP.NET Core on Windows with IIS


Install the .NET Core Windows Server Hosting bundle
https://aka.ms/dotnetcore-2-windowshosting



create new application pool

ebay_track app with sql access is published

change application pool for app in iis

add iis application pool to sql user

give iis read and write permision


test app working on iis on local machine

test app working on intranet



reference:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?tabs=aspnetcore2x

Negin Mirsalehi


https://www.youtube.com/channel/UCec6MLamEsKx8W1U8p0LgQg

Saturday 3 February 2018

send email asp.net




firs time use external app to access gmail, google will email security alert

turn less secure app on




home controller

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using email.Models;
using Microsoft.AspNetCore.Http;
using System.Net.Mail;
using System.Text.RegularExpressions;

namespace email.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public IActionResult Index(IFormCollection collection)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress(collection["fromAddress"].ToString() + "@gmail.com");
                mail.Subject = collection["toSubject"].ToString();
                mail.Body = collection["toMessage"].ToString();

                //add sent addresses---------------------------------------------------
                string[] addresses = collection["toAddress"].ToString().Split(';');

                for (int i = 0; i < addresses.Length; i++)
                {
                    var address = addresses[i].Replace(" ", "").Replace("\r\n","");

                    bool valid_address = false;

                    try
                    {
                        valid_address = Regex.IsMatch(address,
                              @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                              @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
                              RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
                    }
                    catch (RegexMatchTimeoutException)
                    {
                        valid_address = false;
                    }

                    if (valid_address)
                    {
                        mail.To.Add(address);
                        var address_added = address + "; ";
                        ViewBag.status += address_added;
                    }
                }
                //-------------------------------------------------------------

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential(collection["fromUser"].ToString(), collection["fromPassword"].ToString());
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);

                ViewBag.status += "email sucessfully sent";

                return View();
            }
            catch (Exception ex)
            {
                ViewBag.status = ex.ToString();
                return View();
            }
        }

        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}

---------------------------------------------------------------------------

home view

@{
    ViewData["Title"] = "Home Page";
}

<script src="~/lib/jquery/dist/jquery.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#status").html('@ViewBag.status');

        $("#toMessage").css("resize", "none");
    });

    function fromAddress_change() {
        $("#fromUser").val($("#fromAddress").val());
    }

    function onsubmit_check() {

        if ($("#toSubject").val() == "") {

            var sentNoSubject = confirm("send without subject");

            if (sentNoSubject == true) { return true; }
            else { return false; }
        }

        return true;
    }

    $(function () { $("[data-toggle='popover']").popover(); });
</script>

<div class="text-danger" id="status"></div>

<form method="post" onsubmit="return onsubmit_check()">
    <div class="row">
        <h6>
            <label class="col-xs-2">from gmail address </label>
            <input type="text" class="col-xs-8" name="fromAddress" id="fromAddress" onchange="fromAddress_change()" required="required" />
            <label class="col-xs-2">@@gmail.com</label>
        </h6>
    </div>
    <div class="row">
        <h6>
            <label class="col-xs-2">gmail user name </label>
            <input type="text" class="col-xs-8" name="fromUser" id="fromUser" required="required" />
        </h6>
    </div>
    <div class="row">
        <h6>
            <label class="col-xs-2">gmail password </label>
            <input type="password" class="col-xs-8" name="fromPassword" required="required" />
        </h6>
    </div>
    <div class="row">
        <h6>
            <label class="col-xs-2">to email address </label>
            <textarea rows="5" class="col-xs-8" name="toAddress" required="required" placeholder="a@xyz.com; b@xyz.com; c@xyz.com"></textarea>
        </h6>
        <h3><span class="col-xs-2 glyphicon glyphicon-question-sign" title="enter multiple address" data-container="body" data-toggle="popover" data-placement="top" data-content="enter email addresses seperated by semicolon"></span></h3>
    </div>
    <div class="row">
        <h6>
            <label class="col-xs-2">email subject </label>
            <input type="text" class="col-xs-8" name="toSubject" id="toSubject" />
        </h6>
    </div>
    <div class="row">
        <h6>
            <label class="col-xs-2">message </label>
            <textarea rows="10" class="col-xs-8" name="toMessage" id="toMessage"></textarea>
        </h6>
    </div>
    <div class="row">
        <h6>
            <input type="submit" class="col-xs-8 col-xs-offset-2 btn btn-primary btn-xs" value="submit" />
        </h6>
    </div>
</form>

---------------------------------------------------------------------------------


reference:
http://csharp.net-informations.com/communications/csharp-smtp-mail.htm

bootstrap icon
https://www.w3schools.com/bootstrap/bootstrap_ref_comp_glyphs.asp

email regular expression
https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format