예제 #1
0
        /// <summary>
        /// 导入客户数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public JsonResult ImportCusData(string data)
        {
            string jsonStr = string.Empty;
            bool   result  = false;
            string retmsg  = string.Empty;

            LogicBiz biz = new LogicBiz();

            RetMsg msg = biz.DataImport(customerUrl, data, SessionId);

            if (!msg.IsSysError)
            {
                ImportResponse <CustomerErrorDetail> response = DataJsonSerializer <ImportResponse <CustomerErrorDetail> > .JsonToEntity(msg.Message);

                if (response.Data.FalseCount == 0)
                {
                    result = true; //导入成功
                }
                else
                {
                    jsonStr = JsonConvert.SerializeObject(response.Data);
                }
            }
            else
            {
                retmsg = msg.Message;
            }

            return(Json(new { Result = result, Msg = retmsg, Data = jsonStr }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public JsonResult Login(FormCollection formCol)
        {
            string loginUrl = string.Empty;

            try
            {
                string domain = ConfigurationManager.AppSettings["domain"].ToString();
                loginUrl = string.Format(ConfigurationManager.AppSettings["loginUrl"].ToString(), domain);

                string userName = formCol["userName"];
                string Password = formCol["Password"];

                bool   result = false;
                string retmsg = string.Empty;

                userName = userName.Trim();
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(Password))
                {
                    UserRequestEntity user = new UserRequestEntity();

                    user.userCode = userName;
                    user.passWord = Password;
                    user.sysInfo  = "web";

                    LogicBiz biz = new LogicBiz();

                    UserResponseEntity response = new UserResponseEntity();

                    RetMsg msg = biz.GetUserInfo(loginUrl, user);

                    if (!msg.IsSysError)
                    {
                        response = DataJsonSerializer <UserResponseEntity> .JsonToEntity(msg.Message);

                        if (response.StatusCode == 200)
                        {
                            Session["userCode"]  = response.Data.UserCode;
                            Session["userName"]  = response.Data.UserName;
                            Session["SessionId"] = response.Data.SessionId;

                            result = true; //sessionId不为空,用户登录成功
                        }
                        else
                        {
                            retmsg = response.ErrorMsg;
                        }
                    }
                    else
                    {
                        retmsg = msg.Message;
                    }
                }
                else
                {
                    retmsg = "用户名和密码不能为空";
                }

                return(Json(new { Result = result, Msg = retmsg }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Msg = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }