コード例 #1
0
        public HttpResponseMessage GettrueName()
        {
            ResponseMessage     responseMessage = new ResponseMessage(0);
            HttpResponseMessage result          = new HttpResponseMessage();

            try
            {
                bool            flag    = false;
                HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context
                HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
                Dictionary <string, object> dcParams = new Dictionary <string, object>();
                dcParams = DictionaryPro.RequestToDic(context);
                string          UserID  = DictionaryPro.GetDicValue(dcParams, "UserID");//用户名
                DataTable       account = new DataTable();
                ProjectInfo_DAL dal     = new ProjectInfo_DAL();
                account = dal.Getaccount(UserID);

                responseMessage.message = new { rows = account };
                result.Content          = new StringContent(JsonHelper.Object2Json(responseMessage), Encoding.GetEncoding("utf-8"), "application/json");
            }

            catch (Exception ex)
            {
                //返回错误信息
                //返回错误信息
                responseMessage.status  = -1;
                responseMessage.message = ex.Message;
            }
            return(result);
        }
コード例 #2
0
        public HttpResponseMessage UpdateProjectInfo()
        {
            ResponseMessage     responseMessage = new ResponseMessage(0);
            HttpResponseMessage result          = new HttpResponseMessage();

            try
            {
                bool            flag    = false;
                HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context
                HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
                Dictionary <string, object> dcParams = new Dictionary <string, object>();
                dcParams = DictionaryPro.RequestToDic(context);
                string UserID          = DictionaryPro.GetDicValue(dcParams, "UserID");          //用户名
                string OldUserPassword = DictionaryPro.GetDicValue(dcParams, "OldUserPassword"); //密码
                string newUserPassword = DictionaryPro.GetDicValue(dcParams, "newUserPassword"); //密码

                DataTable       account = new DataTable();
                ProjectInfo_DAL dal     = new ProjectInfo_DAL();
                //验证密码
                account = dal.Getaccount(UserID);
                if (account != null)
                {
                    //验证通过标志

                    //用户名
                    string username = "";

                    if (account.Rows[0][7].Equals(OldUserPassword))
                    {
                        flag = dal.UpdateProjectInfo(UserID, newUserPassword);
                    }
                }

                responseMessage.message = new { rows = flag };
                result.Content          = new StringContent(JsonHelper.Object2Json(responseMessage), Encoding.GetEncoding("utf-8"), "application/json");
            }

            catch (Exception ex)
            {
                //返回错误信息
                //返回错误信息
                responseMessage.status  = -1;
                responseMessage.message = ex.Message;
            }
            return(result);
        }