예제 #1
0
        /// <summary>
        /// AD驗證
        /// </summary>
        protected void verifyAccount()
        {
            var ad_service = new ADVerifyService.ADVerifyClient();
            var addaccount = txt_Account.Text = txt_Account.Text.Trim();

            //清空重新查詢
            Set_txt_Account(false, "", "");
            var result = ad_service.Verify("OBdesign.com.tw", addaccount, null);

            if (result.VertifyState == ADVerifyService.State.NoAccount)
            {
                lbl_Message.Text = "無此AD帳號";
                txt_Account.Text = string.Empty;
                return;
            }
            else if (result.VertifyState == ADVerifyService.State.Error)
            {
                lbl_Message.Text = "Server錯誤";
                txt_Account.Text = string.Empty;
                return;
            }
            else if (result.VertifyState == ADVerifyService.State.NoPass)
            {
                var mappings = wmsauth.GetUser(addaccount, area, AccountType);
                if (mappings.Count > 0)
                {
                    lbl_Message.Text = "AD帳號已存在";
                    txt_Account.Text = string.Empty;
                    return;
                }

                ADVerifyClient ADVC = new ADVerifyClient();
                var            ADI  = ADVC.Verify("OBDesign.com.tw", addaccount, "");

                lbl_Message.Text  = ADI.Fullname;
                lbl_Message.Text += ", 帳號正常,請選擇此帳號之權限!";
                //設定
                Set_txt_Account(true, addaccount, ADI.Fullname);
            }
        }
예제 #2
0
        /// <summary>
        /// 新增AD帳號
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_AddAD_Click(object sender, EventArgs e)
        {
            var ad_service = new ADVerifyService.ADVerifyClient();
            var addaccount = txb_ADaccount.Text.Trim();

            var result = ad_service.Verify("OBdesign.com.tw", addaccount, null);

            if (result.VertifyState == ADVerifyService.State.NoAccount)
            {
                lbl_Message.Text   = "無此AD帳號";
                txb_ADaccount.Text = string.Empty;
                return;
            }
            //2013-1009新增
            else if (result.VertifyState == ADVerifyService.State.Error)
            {
                lbl_Message.Text   = "Server錯誤";
                txb_ADaccount.Text = string.Empty;
                return;
            }
            else if (result.VertifyState == ADVerifyService.State.NoPass)
            {
                var authService = new AuthClient();
                var mappings    = (List <AuthMapping>)ViewState["mappings"];
                if (mappings.Count > 0 && mappings.FirstOrDefault(x => x.Account == addaccount) != null)
                {
                    lbl_Message.Text   = "AD帳號已存在";
                    txb_ADaccount.Text = string.Empty;
                    return;
                }

                var mapping = new AuthMapping();
                mapping.Authoritys = new List <Authority>();
                mapping.Account    = txb_ADaccount.Text.Trim().ToLower();
                mappings.Add(mapping);
                ViewState["mappings"] = mappings;

                if (!CB_顯示姓名.Checked)
                {
                    ltbMapping.DataSource = ViewState["mappings"];
                    ltbMapping.DataBind();
                }
                else
                {
                    //增加顯示姓名(2013-1104新增)-----------------------
                    ltbMapping.Items.Clear();

                    foreach (var i in mappings)
                    {
                        var ADI = ADVC.Verify("OBDesign.com.tw", i.Account, "");

                        ListItem aa = new ListItem();
                        aa.Value = i.Account;
                        aa.Text  = i.Account + " (" + ADI.Fullname + ")";
                        ltbMapping.Items.Add(aa);
                    }
                    //----------------------------------------------
                }

                lbl_Message.Text  = ADVC.Verify("OBDesign.com.tw", addaccount, "").Fullname;
                lbl_Message.Text += ", 加入清單成功,請選擇此帳號之權限!";

                txb_ADaccount.Text = string.Empty;
            }
        }
예제 #3
0
        /// <summary>
        /// 登入
        /// </summary>
        protected void Login()
        {
            try
            {
                if (txt_ID.Text.Trim() == "guest")
                {
                    String ID = txt_ID.Text = txt_ID.Text.Trim().ToLower();
                    Session["Account"] = "Guest";
                    Session["Name"]    = "Guest";
                    //取client ip
                    Session["ip"] = Request.Cookies["myip"].Value;
                    Cookie(ID);

                    //加入onlineList帳號(2013-1106新增)-----
                    AddOnlineList(ID);
                    Response.Redirect("~/index.aspx");
                }
                //帳密登入
                else if (txt_ID.Text.Trim() != "" && txt_PW.Text.Trim() != "")
                {
                    //0b389280842de54c
                    String ID = txt_ID.Text = txt_ID.Text.Trim().ToLower();
                    String PW = txt_PW.Text.Trim();
                    EntranceService.Result Lg = new Result();

                    ADVerifyService.ADVerifyClient ADVC = new ADVerifyService.ADVerifyClient();
                    ADVerifyService.Identity       ADI  = ADVC.Verify("OBDesign.com.tw", txt_ID.Text, txt_PW.Text);

                    try
                    {
                        Lg = EC.LogIn(ID, PW);
                    }
                    catch (Exception ex)
                    {
                        Response.Write("系統發生錯誤 " + ex.Message);
                    }

                    if (Lg.ResultStatus == ResultType.Success)
                    {
                        String account = Lg.Account;
                        Session["ID"]      = ID;
                        Session["PW"]      = PW;
                        Session["Account"] = account;
                        //取得中文名(如果AD有)
                        Session["Name"]        = string.IsNullOrEmpty(Lg.Fullname) ? Lg.Account : Lg.Fullname;
                        Session["Zone"]        = "1";
                        Session["ShipOutType"] = (Utility.Area)_areaId;
                        Session["EID"]         = ADI.EmployeeID;

                        //取client ip
                        //正式cookieIP(2012-1205新增)
                        Session["ip"] = Request.Cookies["myip"].Value;
                        //正式
                        //Session["ip"] = HttpContext.Current.Request.UserHostAddress;
                        //測試
                        //Session["ip"] = Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString();

                        //權限設定(2012-0110 舊權限確認方式)
                        //auth.check(account);

                        //(2012-0110 新權限確認方式)
                        auth.setAuthority(Lg.Authoritys);

                        //(2014-0509 新新權限確認方式)
                        auth.setAuthorityPro(ID, 1);
                        var test = auth.checkAuthorityPro("4");

                        Cookie(ID);

                        //加入onlineList帳號(2013-1106新增)-----
                        AddOnlineList(ID);

                        if (urlx != null && urlx != "")
                        {
                            Response.Redirect("~/" + urlx);
                        }
                        else
                        {
                            Response.Redirect("~/index.aspx");
                        }
                    }
                    else
                    {
                        lbl_Message.Text = "登入失敗";
                    }
                }
                //密碼為空則使用物流BarCode登入
                else if (txt_ID.Text.Trim() != "" && txt_PW.Text.Trim() == "")
                {
                    //List<EntranceService.StructLogin> Lg = new List<StructLogin>();
                    String ID = txt_ID.Text = txt_ID.Text.Trim();

                    #region ●service登入(舊)

                    //EntranceService.Result Lg = new Result();

                    //try
                    //{
                    //    Lg = EC.EmployeeCode(ID);
                    //}
                    //catch (Exception ex)
                    //{
                    //    Response.Write("系統發生錯誤 " + ex.Message);
                    //}

                    //if (Lg.ResultStatus == ResultType.Success && Lg.Zone == "1")
                    //{
                    //    String account = Lg.Account;
                    //    String zone = Lg.Zone;
                    //    Session["Account"] = account;
                    //    //取得中文名(如果AD有)
                    //    Session["Name"] = string.IsNullOrEmpty(Lg.Fullname) ? Lg.Account : Lg.Fullname;
                    //    Session["logisticAccount"] = true;
                    //    Session["Zone"] = zone;
                    //    Session["ShipOutType"] = "橘熊";

                    //    //取client ip
                    //    //正式cookieIP(2012-1205新增)
                    //    Session["ip"] = Request.Cookies["myip"].Value;
                    //    //正式
                    //    //Session["ip"] = HttpContext.Current.Request.UserHostAddress;
                    //    //測試
                    //    //Session["ip"] = Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString();

                    //    //權限設定(2012-0110 舊權限確認方式)
                    //    //auth.check(account);

                    //    //若有權限則設定(2012-0110 新權限確認方式)
                    //    if (Lg.Authoritys != null)
                    //        auth.setAuthority(Lg.Authoritys);

                    //    //(2014-0509 新新權限確認方式)
                    //    auth.setAuthorityPro(ID, 0);
                    //    var test = auth.checkAuthorityPro("4");

                    //    Cookie(ID);

                    //    //加入onlineList帳號(2013-1106新增)-----
                    //    AddOnlineList(ID);

                    //    if (urlx != null && urlx != "")
                    //        Response.Redirect("~/" + urlx);
                    //    else
                    //        Response.Redirect("~/index.aspx");
                    //}
                    //else
                    //{
                    //    lbl_Message.Text = "登入失敗";
                    //}

                    #endregion

                    #region ●門市client server DB登入

                    POS_Library.ShopPos.LogisticsAccount LG = new POS_Library.ShopPos.LogisticsAccount();

                    var ResultStatus = LG.GetLogisticsDetailByBarcode(ID);

                    if (ResultStatus.Count == 1)
                    {
                        String account = ResultStatus[0].Account;
                        String zone    = ResultStatus[0].Zone.ToString();
                        Session["Account"] = account;
                        Session["ClerkID"] = ResultStatus[0].Id;
                        //取得中文名(如果AD有)
                        Session["Name"]            = account;
                        Session["logisticAccount"] = true;
                        Session["Zone"]            = zone;
                        Session["ShipOutType"]     = (Utility.Area) int.Parse(zone);

                        //取client ip
                        //正式cookieIP(2012-1205新增)
                        Session["ip"] = Request.Cookies["myip"].Value;
                        //正式
                        //Session["ip"] = HttpContext.Current.Request.UserHostAddress;
                        //測試
                        //Session["ip"] = Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString();

                        //權限設定(2012-0110 舊權限確認方式)
                        //auth.check(account);

                        //若有權限則設定(2012-0110 新權限確認方式)
                        //if (Lg.Authoritys != null)
                        //    auth.setAuthority(Lg.Authoritys);

                        //(2014-0509 新新權限確認方式)
                        auth.setAuthorityPro(ID, 0);
                        var test = auth.checkAuthorityPro("4");

                        Cookie(ID);

                        //加入onlineList帳號(2013-1106新增)-----
                        AddOnlineList(ID);

                        //if (urlx != null && urlx != "")
                        //    Response.Redirect("~/" + urlx);
                        //else
                        //    Response.Redirect("~/index.aspx");

                        Response.Redirect("~/pos_check_out.aspx");
                    }
                    else
                    {
                        lbl_Message.Text = "登入失敗";
                    }

                    #endregion
                }
                else
                {
                    lbl_Message.Text = "帳號為空白";
                }
            }
            catch (Exception ex)
            {
                Response.Write("系統發生錯誤 " + ex.Message);
            }
        }