Example #1
0
        /// <summary>
        /// UserLogin
        /// </summary>
        /// <param name="usercode"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static UserObject UserLogin(string usercode, string pwd)
        {
            UserObject userObj        = null;
            string     responseResult = "";
            HttpResponseResultObject <object> responseObj = null;

            try
            {
                IRMSApiReqParam apiParam = CreateIRMSApiReqParam.CreateUserLoginParam(usercode, pwd);
                if (apiParam != null)
                {
                    responseResult = HttpService.Post(apiParam.JsonData, apiParam.Path, 6000);
                    responseObj    = JsonConvert.DeserializeObject <HttpResponseResultObject <object> >(responseResult);
                    if (responseObj != null && responseObj.Code == SuccessCode)
                    {
                        Newtonsoft.Json.Linq.JObject jObj = responseObj.Data as Newtonsoft.Json.Linq.JObject;
                        if (jObj != null)
                        {
                            userObj = jObj.ToObject <UserObject>();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                userObj = null;
                WindowUI.NlogHelper.LogToFile(ex.ToString());
            }
            //
            return(userObj);
        }
Example #2
0
        /// <summary>
        /// CreateUserLoginParam
        /// </summary>
        /// <param name="usercode"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static IRMSApiReqParam CreateUserLoginParam(string usercode, string pwd)
        {
            IRMSApiReqParam param = null;

            try
            {
                var obj = new { UserCode = usercode, Password = pwd };
                //
                param          = new IRMSApiReqParam();
                param.Path     = string.Format("{0}/irmsapi/login/", Global.IRMSApiUrl);
                param.JsonData = JsonConvert.SerializeObject(obj);
            }
            catch (Exception ex)
            {
                WindowUI.NlogHelper.LogToFile(ex.ToString());
            }
            //
            return(param);
        }
Example #3
0
        /// <summary>
        /// CreateGetAccessShopParam
        /// </summary>
        /// <param name="iPAddress"></param>
        /// <param name="shopNature"></param>
        /// <param name="languageCode"></param>
        /// <returns></returns>
        public static IRMSApiReqParam CreateGetAccessShopParam(string iPAddress, string shopNature, string languageCode)
        {
            IRMSApiReqParam param = null;

            try
            {
                var obj = new { IPAddress = iPAddress, ShopNature = shopNature, LanguageCode = languageCode };
                //
                param          = new IRMSApiReqParam();
                param.Path     = string.Format("{0}/irmsapi/getaccessshop/", Global.IRMSApiUrl);
                param.JsonData = JsonConvert.SerializeObject(obj);
            }
            catch (Exception ex)
            {
                WindowUI.NlogHelper.LogToFile(ex.ToString());
            }

            return(param);
        }
Example #4
0
        /// <summary>
        /// GetAccessShop
        /// </summary>
        /// <param name="loginIPAddress"></param>
        /// <param name="loginShopNature"></param>
        /// <param name="languageCode"></param>
        /// <returns></returns>
        public static List <UserAccessObject> GetAccessShop(string loginIPAddress, string loginShopNature, string languageCode)
        {
            List <UserAccessObject> result  = null;
            string           responseResult = "";
            UserAccessObject userAccessObj  = null;
            HttpResponseResultObject <object> responseObj = null;

            try
            {
                result = new List <UserAccessObject>();

                IRMSApiReqParam apiParam = CreateIRMSApiReqParam.CreateGetAccessShopParam(loginIPAddress, loginShopNature, languageCode);
                if (apiParam != null)
                {
                    responseResult = HttpService.Post(apiParam.JsonData, apiParam.Path, 6000);
                    responseObj    = JsonConvert.DeserializeObject <HttpResponseResultObject <object> >(responseResult);
                    if (responseObj != null && responseObj.Code == SuccessCode)
                    {
                        Newtonsoft.Json.Linq.JArray arrData = responseObj.Data  as Newtonsoft.Json.Linq.JArray;
                        if (arrData != null && arrData.Count > 0)
                        {
                            foreach (Newtonsoft.Json.Linq.JObject jobj in arrData)
                            {
                                userAccessObj = jobj.ToObject <UserAccessObject>();
                                if (userAccessObj != null)
                                {
                                    result.Add(userAccessObj);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = null;
                WindowUI.NlogHelper.LogToFile(ex.ToString());
            }
            return(result);
        }