示例#1
0
文件: MdiMp.cs 项目: cpuriwat/8mp
 private void MdiMp_Load(object sender, EventArgs e)
 {
     _objMp = new MpModuleController(_objFlex, _objWs, _objC, _objMsg, _objOperatrion, new MpTransaction(_objFlex, _objWs, _objMsg))
     {
         FormObject = this, DockPanelMain = dockPanel
     };
     IsMdiContainer            = true;
     StatusStrip.Items[0].Text = _objMsg.GetSystemMsg(EnumMessage.SL_StatusOnline).ReturnMsg;
     StatusStrip.Items.Add(new ToolStripStatusLabel()
     {
         Text = _objMsg.GetSystemMsg(EnumMessage.DisplayUserName, Username).ReturnMsg, BorderStyle = Border3DStyle.Etched, BorderSides = ToolStripStatusLabelBorderSides.Right
     });
     Text             = _objMsg.GetSystemMsg(EnumMessage.SL_FomMainTitle).ReturnMsg;
     _objMp.LoginInfo = LoginInfo;
     _objMp.LoadMain();
 }
示例#2
0
 public string ValidateFillComplete(Control objC)
 {
     foreach (var cCont in objC.Controls)
     {
         if (!(cCont is TextBox c))
         {
             continue;
         }
         if (c.Name.Substring(0, 1).ToLower() == "r" && c.Text == "")
         {
             return(_objErr.GetSystemMsg(EnumMessage.ElementIsEmpty, c.Name).ReturnMsg);
         }
     }
     return("OK");
 }
示例#3
0
        private void AddMsg(object objApi, object ui)
        {
            var ump    = (IMpUserControl)ui;
            var a      = (IMpCommonApi)objApi;
            var msgApi = "";

            if (a == null | ump == null)
            {
                _objCb.DisplayMsgToolbox(_messageToolbox, _objMsg.GetSystemMsg(EnumMessage.SystemObjectIsNothing).ReturnMsg);
            }
            if (a.ReturnMsg != null && a.ReturnMsg.ReturnMsg != "")
            {
                _objCb.DisplayMsgToolbox(_messageToolbox, a.ReturnMsg.ReturnMsg); msgApi = a.ReturnMsg.ReturnMsg;
            }
            if (ump.ReturnMsgVm == null || ump.ReturnMsgVm.ReturnMsg == "")
            {
                return;
            }
            if (msgApi != ump.ReturnMsgVm.ReturnMsg)
            {
                _objCb.DisplayMsgToolbox(_messageToolbox, ump.ReturnMsgVm.ReturnMsg);                                      // prevent duplicate msg
            }
        }
示例#4
0
        public bool GetHttpPost(string postData, string Path)
        {
            WebRequest request = WebRequest.Create(Path);

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            request.Method        = "POST";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;
            try
            {
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                WebResponse response = request.GetResponse();
                dataStream = response.GetResponseStream();
                StreamReader reader             = new StreamReader(dataStream);
                string       responseFromServer = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();
                var    jss     = new JavaScriptSerializer();
                object data    = jss.DeserializeObject(responseFromServer);
                var    handler = new JwtSecurityTokenHandler();
                foreach (var item in (IEnumerable <KeyValuePair <string, object> >)data)
                {
                    if (item.Key.ToLower() == "refresh")
                    {
                        _tokenRefresh = (string)item.Value;
                    }
                    if (item.Key.ToLower() == "access")
                    {
                        _tokenAccess   = (string)item.Value;
                        TokenAccessKey = _tokenAccess;
                        JwtSecurityToken jsonToken = (JwtSecurityToken)handler.ReadToken(_tokenRefresh);
                        foreach (KeyValuePair <string, object> i in jsonToken.Payload)
                        {
                            if (i.Key.ToLower() == "user_id")
                            {
                                UserId = Convert.ToInt32(i.Value);
                            }
                        }
                    }
                }
                ReturnMsg = _objMsg.GetSystemMsg(EnumMessage.LoginSuccess);
                return(true);
            }
            catch (WebException e)
            {
                using (WebResponse r = e.Response)
                {
                    var httpResponse = (HttpWebResponse)r;
                    if (httpResponse != null)
                    {
                        Debug.Print(httpResponse.StatusDescription);
                        ValidateResponseErrorCode((int)httpResponse.StatusCode);
                    }
                    else
                    {
                        ValidateResponseErrorCode(0);
                    }
                }
                return(false);
            }
        }