예제 #1
0
 // 读取表格定义
 public static string GetTableDef(string tableid)
 {
     if (AppServer.wcfClient.State == System.ServiceModel.CommunicationState.Opened)
     {
         // 已经打开则不再关闭
         return(AppServer.wcfClient.GetTableDef(tableid));
     }
     else
     {
         // 否则先打开后关闭
         try
         {
             if (!AppServer.WcfService_Open())
             {
                 return("");
             }
             //
             return(AppServer.wcfClient.GetTableDef(tableid));
         }
         catch (Exception ex)
         {
             AppServer.ShowMsg_ExceptError(ex.Message);
             return("");
         }
         finally
         {
             AppServer.WcfService_Close();
         }
     }
 }
예제 #2
0
        private void TfmMan_Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = false;
            if (!FLoginSuccess)
            {
                return;
            }
            //退出提示
#if !DEBUG
            if (AppServer.DialogMsg("感谢您的使用,确认要退出系统吗?", "退出提示"))
            {
                //开始验证登录
                base.Cursor = Cursors.WaitCursor;
                try
                {
                    if (!AppServer.WcfService_Open())
                    {
                        return;
                    }
                    //
                    var model = new Ref_WS_STK.DataType_User();
                    model.LoginID = AppServer.LoginID;
                    AppServer.wcfClient.SYS_Logout(model);
                    if (model.ExResult != 0)
                    {
                        AppServer.ShowMsg_Error(model.ErrorMsg, "退出登录注册失败了!");
                        return;
                    }
                }
                catch
                {
                    return;
                }
                finally
                {
                    AppServer.WcfService_Close();
                    base.Cursor = Cursors.Arrow;
                }
            }
            else
            {
                e.Cancel = true;
            }
#endif
        }
예제 #3
0
        public static bool UsingWcf(Action action)
        {
            try
            {
                if (!AppServer.WcfService_Open())
                {
                    return(false);
                }

                action();

                return(true);
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_ExceptError(ex.Message);
                return(false);
            }
            finally
            {
                AppServer.WcfService_Close();
            }
        }
예제 #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.None;

            if (this.txtLoginName.Text.Trim().Length == 0)
            {
                AppServer.ShowMsg("请输入要登录的用户账号!");
                this.txtLoginName.Focus();
                this.DialogResult = DialogResult.None;
                return;
            }
            //开始验证登录
            base.Cursor = Cursors.WaitCursor;
            try
            {
                if (!AppServer.WcfService_Open())
                {
                    return;
                }
                //
                var model = new Ref_WS_STK.DataType_User();
                model.LoginName = this.txtLoginName.Text;
                model.LoginPswd = this.txtLoginPswd.Text;
                model.LoginDate = this.dtpLoginDate.Value;
                model.LoginAddr = TY.Common.NetWork.GetLocalIP();
                model.LoginID   = AppServer.LoginID; //重新登录时会用于注册退出使用

                AppServer.wcfClient.SYS_Login(ref model);

                if (model.ExResult != 0)
                {
                    AppServer.ShowMsg_Error(model.ErrorMsg, "登录失败了!");
                    switch (model.ExResult)
                    {
                    case 1: this.txtLoginName.Focus(); break;

                    case 2: this.txtLoginPswd.Focus(); break;

                    case 3: this.dtpLoginDate.Focus(); break;
                    }
                    return;
                }
                AppServer.LoginUserCode = model.UserCode;
                AppServer.LoginUserName = model.UserName;
                AppServer.LoginWorkDate = this.dtpLoginDate.Value;
                AppServer.LoginID       = model.LoginID;
                //获取用户菜单列表
                DataSet tdb = AppServer.wcfClient.SYS_Login_Menu(ref model);
                if (model.ExResult != 0)
                {
                    AppServer.ShowMsg_Error(model.ErrorMsg, "登录失败了!");
                    return;
                }
                if (AppServer.UserQxMenuList != null)
                {
                    AppServer.UserQxMenuList.Dispose();
                }
                AppServer.UserQxMenuList            = tdb.Tables[0].Copy();
                AppServer.UserQxMenuList.PrimaryKey = new DataColumn[1] {
                    AppServer.UserQxMenuList.Columns["MenuCode"]
                };
                //获取系统参数
                AppServer.wcfClient.SYS_Param_Get(ref AppServer.Sys_Param);
            }
            catch (Exception ex)
            {
                AppServer.ShowMsg_Error("系统登录时出现异常,请确认您的网络连接是否有问题!\n错误信息:" + ex.Message, "登录失败了!");
                return;
            }
            finally
            {
                AppServer.WcfService_Close();
                base.Cursor = Cursors.Arrow;
            }

            //登录成功了
            if (this.chkRemember.Checked)
            {
                Properties.Settings.Default.LoginName = this.txtLoginName.Text;
                Properties.Settings.Default.LoginPswd = Cmn_DataProtection.ProtectData(txtLoginPswd.Text, "GLG_STK_Password");
                Properties.Settings.Default.LoginRemb = this.chkRemember.Checked;
            }
            else
            {
                Properties.Settings.Default.LoginName = string.Empty;
                Properties.Settings.Default.LoginPswd = string.Empty;
                Properties.Settings.Default.LoginRemb = this.chkRemember.Checked;
            }
            Properties.Settings.Default.Save();

            this.DialogResult = DialogResult.OK;
        }