Exemple #1
0
        protected override void HandleCollectDataToOptions()
        {
            //ViewBag.NewsKind_Option = MakeDropDownOption(ac.GetGroupCodeValue("NewsKind"));
            a_Users ac_User = new a_Users()
            {
                Connection = getSQLConnection()
            };
            LogicAddress address = new LogicAddress()
            {
                Connection = this.getSQLConnection()
            };

            ViewBag.Unit_Option    = MakeCollectDataToOptions(ac_User.MakeOption_Unit(), false);
            ViewBag.City_Option    = MakeCollectDataToOptions(address.GetCity(), false);
            ViewBag.Country_Option = MakeCollectDataToOptions(address.GetCountry(""), false);
        }
Exemple #2
0
        protected m_ProgData GetSystemInfo()
        {
            a_WebInfo  ac = new a_WebInfo();
            m_ProgData md = new m_ProgData();

            ac.Connection = getSQLConnection();

            md = ac.GetSystemInfo(this.GetArea, this.GetController, "");

            //設定權限
            //先取得User Info 代入單位
            m_Users md_User;
            a_Users ac_User = new a_Users();

            ac_User.Connection = ac.Connection;
            md_User            = ac_User.GetDataMaster(LoginUserId, LoginUserId).SearchData;

            powerHave            = new PowerHave();
            powerHave.Connection = ac.Connection;
            powerHave.SetPower(LoginUserId, md.id);

            return(md);
        }
Exemple #3
0
        public String ajax_Login(String account, String password, String img_vildate)
        {
            JavaScriptSerializer js = new JavaScriptSerializer()
            {
                MaxJsonLength = 65536
            };                                                                              //64K
            LoginResult getLoginResult = new LoginResult();
            a_Users     ac             = new a_Users()
            {
                Connection = getSQLConnection(), logPlamInfo = new Log.LogPlamInfo()
                {
                    UserId = 0, IP = System.Web.HttpContext.Current.Request.UserHostAddress, BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version
                }
            };

            try
            {
                getLoginResult.vildate = Session["CheckCode"].ToString() != img_vildate ? false : true;
#if DEBUG
                getLoginResult.vildate = true;
#endif
                if (!getLoginResult.vildate)
                {
                    throw new Exception(Resources.Res.Log_Err_ImgValideNotEquel);
                }

                LoginSate CheckLoginState = ac.SystemLogin(account, password);

                if (CheckLoginState.Result)
                {
                    getLoginResult.result = true;
                    getLoginResult.url    = Url.Content(CommWebSetup.ManageDefCTR);

                    Session.Timeout   = 720;
                    Session["Id"]     = CheckLoginState.Id;
                    Session["UnitId"] = CheckLoginState.Unit;

                    ViewData["WebAppPath"] = System.Web.HttpContext.Current.Request.ApplicationPath == "/" ? System.Web.HttpContext.Current.Request.ApplicationPath : System.Web.HttpContext.Current.Request.ApplicationPath + "/";
                    ViewData["user"]       = CheckLoginState.Acccount;

                    //登錄記錄

                    a__UserLoginLog ac_UserLoginLog = new a__UserLoginLog()
                    {
                        Connection = getSQLConnection(), logPlamInfo = new Log.LogPlamInfo()
                        {
                            UserId = 0, IP = System.Web.HttpContext.Current.Request.UserHostAddress, BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version
                        }
                    };
                    var r1 = ac_UserLoginLog.SearchMaster(new q__UserLoginLog()
                    {
                        s_account = CheckLoginState.Acccount, MaxRecord = 1, sord = "desc", sidx = "logintime"
                    }, CheckLoginState.Id).SearchData;
                    if (r1.Count() > 0)
                    {
                        ViewData["lastlogin"] = r1.FirstOrDefault().logintime;
                    }
                    else
                    {
                        ViewData["lastlogin"] = DateTime.Now;
                    }

                    m__UserLoginLog md = new m__UserLoginLog()
                    {
                        ip        = System.Web.HttpContext.Current.Request.UserHostAddress,
                        account   = CheckLoginState.Acccount,
                        logintime = DateTime.Now,
                        browers   = System.Web.HttpContext.Current.Request.Headers.ToString()
                    };
                    var r3 = ac_UserLoginLog.InsertMaster(md, CheckLoginState.Id);

                    //語系使用
                    HttpCookie WebLang = Request.Cookies[CommWebSetup.WebCookiesId + ".Lang"];
                    a__Lang    ac_Lang = new a__Lang()
                    {
                        Connection = getSQLConnection(), logPlamInfo = new Log.LogPlamInfo()
                        {
                            UserId = CheckLoginState.Id, IP = System.Web.HttpContext.Current.Request.UserHostAddress, BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version
                        }
                    };
                    var r2 = ac_Lang.SearchMaster(new q__Lang()
                    {
                        s_lang = WebLang.Value
                    }, CheckLoginState.Id).SearchData.FirstOrDefault();
                    ViewData["lang"] = r2.area;

                    ViewResult resultView = View("Manage/vucMenu");

                    StringResult sr = new StringResult();
                    sr.ViewName   = resultView.ViewName;
                    sr.MasterName = resultView.MasterName;
                    sr.ViewData   = resultView.ViewData;
                    sr.TempData   = resultView.TempData;
                    sr.ExecuteResult(this.ControllerContext);
                    Session["MenuHtmlString"] = sr.ToHtmlString;
                    Log.Write("ajax_Login Login OK!:" + Session["Id"].ToString());
                }
                else
                {
                    getLoginResult.title   = Resources.Res.Log_Err_Title;
                    getLoginResult.result  = false;
                    getLoginResult.message = GetRecMessage(CheckLoginState.Message);

                    Log.Write("ajax_Login Login Fail!:" + getLoginResult.message);

                    Session.Remove("Id");
                    Session.Remove("UnitId");
                    Session.Remove("MenuHtmlString");
                }
            }
            catch (Exception ex)
            {
                getLoginResult.title   = Resources.Res.Log_Err_Title;
                getLoginResult.result  = false;
                getLoginResult.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(getLoginResult, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
        public String ajax_Login(String account, String password, String img_vildate)
        {
            JavaScriptSerializer js = new JavaScriptSerializer() { MaxJsonLength = 65536 }; //64K
            LoginResult getLoginResult = new LoginResult();
            a_Users ac = new a_Users() { Connection = getSQLConnection(), logPlamInfo = new Log.LogPlamInfo() { UserId = 0, IP = System.Web.HttpContext.Current.Request.UserHostAddress, BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version } };
            try
            {
                getLoginResult.vildate = Session["CheckCode"].ToString() != img_vildate ? false : true;
            #if DEBUG
                getLoginResult.vildate = true;
            #endif
                if (!getLoginResult.vildate)
                    throw new Exception(Resources.Res.Log_Err_ImgValideNotEquel);

                LoginSate CheckLoginState = ac.SystemLogin(account, password);

                if (CheckLoginState.Result)
                {
                    getLoginResult.result = true;
                    getLoginResult.url = Url.Content(CommWebSetup.ManageDefCTR);

                    Session.Timeout = 720;
                    Session["Id"] = CheckLoginState.Id;
                    Session["UnitId"] = CheckLoginState.Unit;

                    ViewData["WebAppPath"] = System.Web.HttpContext.Current.Request.ApplicationPath == "/" ? System.Web.HttpContext.Current.Request.ApplicationPath : System.Web.HttpContext.Current.Request.ApplicationPath + "/";
                    ViewData["user"] = CheckLoginState.Acccount;

                    //登錄記錄

                    a__UserLoginLog ac_UserLoginLog = new a__UserLoginLog() { Connection = getSQLConnection(), logPlamInfo = new Log.LogPlamInfo() { UserId = 0, IP = System.Web.HttpContext.Current.Request.UserHostAddress, BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version } };
                    var r1 = ac_UserLoginLog.SearchMaster(new q__UserLoginLog() { s_account = CheckLoginState.Acccount,MaxRecord=1,sord="desc",sidx="logintime"}, CheckLoginState.Id).SearchData;
                    if (r1.Count() > 0)
                    {
                        ViewData["lastlogin"] = r1.FirstOrDefault().logintime;
                    }
                    else {
                        ViewData["lastlogin"] = DateTime.Now;
                    }

                    m__UserLoginLog md = new m__UserLoginLog() {
                        ip = System.Web.HttpContext.Current.Request.UserHostAddress ,
                        account = CheckLoginState.Acccount,
                        logintime = DateTime.Now,
                        browers = System.Web.HttpContext.Current.Request.Headers.ToString()
                    };
                    var r3 = ac_UserLoginLog.InsertMaster(md, CheckLoginState.Id);

                    //語系使用
                    HttpCookie WebLang = Request.Cookies[CommWebSetup.WebCookiesId + ".Lang"];
                    a__Lang ac_Lang = new a__Lang() { Connection = getSQLConnection(), logPlamInfo = new Log.LogPlamInfo() { UserId = CheckLoginState.Id, IP = System.Web.HttpContext.Current.Request.UserHostAddress, BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version } };
                    var r2 = ac_Lang.SearchMaster(new q__Lang() { s_lang = WebLang.Value }, CheckLoginState.Id).SearchData.FirstOrDefault();
                    ViewData["lang"] = r2.area;

                    ViewResult resultView = View("Manage/vucMenu");

                    StringResult sr = new StringResult();
                    sr.ViewName = resultView.ViewName;
                    sr.MasterName = resultView.MasterName;
                    sr.ViewData = resultView.ViewData;
                    sr.TempData = resultView.TempData;
                    sr.ExecuteResult(this.ControllerContext);
                    Session["MenuHtmlString"] = sr.ToHtmlString;
                    Log.Write("ajax_Login Login OK!:" + Session["Id"].ToString());
                }
                else
                {
                    getLoginResult.title = Resources.Res.Log_Err_Title;
                    getLoginResult.result = false;
                    getLoginResult.message = GetRecMessage(CheckLoginState.Message);

                    Log.Write("ajax_Login Login Fail!:" + getLoginResult.message);

                    Session.Remove("Id");
                    Session.Remove("UnitId");
                    Session.Remove("MenuHtmlString");
                }
            }
            catch (Exception ex)
            {
                getLoginResult.title = Resources.Res.Log_Err_Title;
                getLoginResult.result = false;
                getLoginResult.message = ex.Message;
            }
            return JsonConvert.SerializeObject(getLoginResult, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
        }