Example #1
0
        private string AutoLogin(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "AutoLogin";

            try
            {
                do
                {
                    string           email  = context.Request["mailAddress"];
                    BigAttachManager dll    = new BigAttachManager(ClientIP);
                    Guid             userid = Guid.Empty;
                    bool             result = dll.GetUserIDByEmail(transactionid, email, out userid, out strJsonResult);
                    if (result == true)
                    {
                        HttpCookie myCookie = new HttpCookie("BGQTUserToken");
                        myCookie["Token"]   = userid.ToString();
                        myCookie["Account"] = email;
                        myCookie.Expires    = DateTime.Now.AddHours(1);
                        context.Response.Cookies.Add(myCookie);
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                error.Code = ErrorCode.Exception;
                LoggerHelper.Error("Setting.ashx调用接口AutoLogin异常", context.Request.RawUrl, ex.ToString(), transactionid);
                LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
            }

            return(strJsonResult);
        }