Esempio n. 1
0
 public bool CheckOperator(string badge)
 {
     try
     {
         IServerObjFactory obj = CallRemotingService.GetRemoteObject();
         DataSet           ds  = obj.CreateIUserEngine().CheckOperator(badge);
         if (ds != null && ds.ExtendedProperties.ContainsKey(PARAMETERS.OUTPUT_MESSAGE))
         {
             _errorMsg = ds.ExtendedProperties[PARAMETERS.OUTPUT_MESSAGE].ToString();
         }
         if (_errorMsg.Length == 0)
         {
             return(true);
         }
         else
         {
             MessageService.ShowError("验证员工号出错!" + _errorMsg);
         }
     }
     catch (Exception ex)
     {
         MessageService.ShowError(ex.Message);
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
     return(false);
 }
Esempio n. 2
0
        public bool CheckLastPackageOperator()
        {
            bool   blBack = false;
            string badge  = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);

            if (!string.IsNullOrEmpty(badge))
            {
                try
                {
                    IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                    DataSet           dsReturn      = serverFactory.CreateIUserEngine().CheckLastPackageOperator(badge);
                    if (dsReturn.Tables.Contains(RBAC_USER_FIELDS.DATABASE_TABLE_NAME))
                    {
                        DataTable dtUser = dsReturn.Tables[RBAC_USER_FIELDS.DATABASE_TABLE_NAME];
                        if (dtUser.Rows.Count > 0)
                        {
                            blBack = true;
                        }
                    }
                }
                catch
                {
                    //TODO: Ignore Generant Exception.
                }
                finally
                {
                    CallRemotingService.UnregisterChannel();
                }
            }
            return(blBack);
        }
Esempio n. 3
0
        public DataSet GetUserInfo()
        {
            DataSet   dsReturn  = new DataSet();
            DataSet   ds        = new DataSet();
            DataTable dataTable = new DataTable();
            Hashtable hashTable = new Hashtable();

            hashTable.Add(RBAC_USER_FIELDS.FIELD_USER_KEY, _userKey);
            dataTable           = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
            dataTable.TableName = RBAC_USER_FIELDS.DATABASE_TABLE_NAME;
            ds.Tables.Add(dataTable);
            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    dsReturn  = serverFactory.CreateIUserEngine().GetUserInfo(ds);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(dsReturn);
        }
Esempio n. 4
0
 public bool ChangePassword(DataTable table)
 {
     try
     {
         IServerObjFactory obj      = CallRemotingService.GetRemoteObject();
         DataSet           dsReturn = obj.CreateIUserEngine().ChangePassword(table);
         _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
         if (_errorMsg.Length < 1)
         {
             return(true);
         }
         else
         {
             MessageService.ShowMessage(_errorMsg);
         }
     }
     catch (Exception ex)
     {
         MessageService.ShowMessage(ex.Message);
     }
     finally
     {
         CallRemotingService.UnregisterChannel();
     }
     return(false);
 }
Esempio n. 5
0
        /// <summary>
        /// Load Users Data
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        /// Owner:Andy Gao 2011-08-05 10:56:49
        public DataTable LoadUsersData(out string msg)
        {
            #region Call Remoting Interface

            DataSet reqDS = new DataSet();
            DataSet resDS = new DataSet();

            DataTable dataTable = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(new Hashtable());
            dataTable.TableName = RBAC_USER_FIELDS.DATABASE_TABLE_NAME;

            reqDS.Tables.Add(dataTable);

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();

                resDS = serverFactory.CreateIUserEngine().GetUserInfo(reqDS);
            }
            catch (Exception ex)
            {
                msg = ex.Message;

                return(null);
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }

            msg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(resDS);

            return(resDS.Tables[0]);

            #endregion
        }
Esempio n. 6
0
        /// <summary>
        /// 记录用户登录信息。
        /// </summary>
        /// <param name="userKey">用户主键。</param>
        /// <param name="site">站点。</param>
        /// <param name="language">语言。</param>
        /// <param name="version">系统版本号。</param>
        public void LogUserLoginInfo(string userKey, string site, string language, string version)
        {
            string preLoginLogKey = PropertyService.Get(PROPERTY_FIELDS.LOGIN_LOG_KEY);

            DataTable loginLogDataTable = RBAC_LOGIN_LOG_FIELDS.CreateDataTable();

            DataRow dataRow = loginLogDataTable.NewRow();

            string loginLogKey = CommonUtils.GenerateNewKey(0);

            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_LOGIN_LOG_KEY] = loginLogKey;
            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_USER_KEY]      = userKey;
            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_SITE]          = site;
            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_LANGUAGE]      = language;
            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_COMPUTER_NAME] = Environment.MachineName.ToString();
            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_COMPUTER_IP]   = FanHai.Hemera.Utils.Common.Utils.GetLocationIPAddress();
            dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_VERSION]       = version;

            loginLogDataTable.Rows.Add(dataRow);

            loginLogDataTable.AcceptChanges();

            DataSet reqDS = new DataSet();

            reqDS.Tables.Add(loginLogDataTable);

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                IUserEngine       userEngine    = null;
                if (serverFactory != null)
                {
                    userEngine = serverFactory.CreateIUserEngine();
                }
                if (userEngine != null && !string.IsNullOrEmpty(preLoginLogKey))
                {
                    userEngine.LogUserLogoutInfo(preLoginLogKey);
                }

                if (userEngine != null && userEngine.LogUserLoginInfo(reqDS))
                {
                    PropertyService.Set(PROPERTY_FIELDS.LOGIN_LOG_KEY, loginLogKey);
                }
            }
            catch
            {
                //TODO: Ignore Generant Exception.
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }
Esempio n. 7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //对登陆界面的帐号密码进行判断并对XML 进行重新配置
            if (CheckData(this.txtUserName.Text.Trim(), this.txtPassword.Text.Trim()))
            {
                try
                {
                    CallRemotingService.SelectServerSite(site);
                    DataSet   ds        = new DataSet();
                    DataTable dataTable = CreateUserTable();//创建一张自定义结构的表
                    Dictionary <string, string> rowData = new Dictionary <string, string>()
                    {
                        { RBAC_USER_FIELDS.FIELD_USERNAME, txtUserName.Text.Trim() }
                    };
                    FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref dataTable, rowData); //把rowData中的数据添加在表dataTable中
                    ds.Tables.Add(dataTable);                                                       //把表dataTable添加到表集ds中
                    DataSet dataUser = new DataSet();

                    IServerObjFactory isof       = CallRemotingService.GetRemoteObject();//创建工厂接口对象
                    IUserEngine       userEngine = isof.CreateIUserEngine();

                    dataUser = userEngine.CheckUser(ds); //通过传入的帐号查询返回该帐号对应的信息

                    if (CheckUser(dataUser))             //数据库信息和用户信息进行对比返回bool类型
                    {
                        UpdateLanguageInfo();
                        UpdateServerSitList();
                        //对登录用户的信息进行登记
                        UpdateLoginUserInfo();

                        DialogResult = DialogResult.OK;
                        this.Close();
                        StatusBarService.SetCaretPosition(30, 70, 0);
                    }
                }
                catch (Exception ex)
                {
                    MessageService.ShowMessage(ex.Message);
                }
                finally
                {
                    CallRemotingService.UnregisterChannel();
                }
            }
            Xmlproper();
        }
Esempio n. 8
0
        /// <summary>
        /// 获取用户拥有权限的线上仓信息。
        /// </summary>
        /// <param name="userKey">用户主键。</param>
        /// <param name="roomName">车间名称。</param>
        /// <returns>
        /// 使用,分割的线上仓名称字符串。
        /// </returns>
        public string GetStoreOfUser(string userKey, string roomName)
        {
            string stores = "";

            try
            {
                IServerObjFactory serverObjFactory = CallRemotingService.GetRemoteObject();
                if (null != serverObjFactory)
                {
                    DataSet dsStore = new DataSet();
                    dsStore = serverObjFactory.CreateIUserEngine().GetStoreOfUser(userKey, roomName);
                    if (dsStore.Tables.Count > 0)
                    {
                        if (dsStore.Tables.Contains(RBAC_ROLE_OWN_STORE_FIELDS.DATABASE_TABLE_NAME))
                        {
                            DataTable dataTable = dsStore.Tables[RBAC_ROLE_OWN_STORE_FIELDS.DATABASE_TABLE_NAME];
                            for (int i = 0; i < dataTable.Rows.Count; i++)
                            {
                                if (i == 0)
                                {
                                    stores = dataTable.Rows[i][RBAC_ROLE_OWN_STORE_FIELDS.FIELD_STORE_NAME].ToString();
                                }
                                else
                                {
                                    stores = stores + "," + dataTable.Rows[i][RBAC_ROLE_OWN_STORE_FIELDS.FIELD_STORE_NAME].ToString();
                                }
                            }
                        }
                    }
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsStore);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(stores);
        }
Esempio n. 9
0
        public void DeleteUser()
        {
            DataSet dsReturn = new DataSet();

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    dsReturn  = serverFactory.CreateIUserEngine().DeleteUser(_userKey);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }
Esempio n. 10
0
        public string GetPrivilegeOfUser()
        {
            string privileges = "";

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    DataSet dsReturn = new DataSet();
                    dsReturn = serverFactory.CreateIUserEngine().GetPrivilegeOfUser(_userKey);
                    if (dsReturn.Tables.Count > 0)
                    {
                        for (int i = 0; i < dsReturn.Tables[0].Rows.Count; i++)
                        {
                            if (i == 0)
                            {
                                privileges = dsReturn.Tables[0].Rows[i]["PRIVILEGE_CODE"].ToString();
                            }
                            else
                            {
                                privileges = privileges + "," + dsReturn.Tables[0].Rows[i]["PRIVILEGE_CODE"].ToString();
                            }
                        }
                    }
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
            return(privileges);
        }
Esempio n. 11
0
        /// <summary>
        /// 记录用户登出信息。
        /// </summary>
        public void LogUserLogoutInfo()
        {
            string loginLogKey = PropertyService.Get(PROPERTY_FIELDS.LOGIN_LOG_KEY);

            if (!string.IsNullOrEmpty(loginLogKey))
            {
                try
                {
                    IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                    if (serverFactory != null)
                    {
                        serverFactory.CreateIUserEngine().LogUserLogoutInfo(loginLogKey);
                    }
                }
                catch
                {
                    //TODO: Ignore Generant Exception.
                }
                finally
                {
                    CallRemotingService.UnregisterChannel();
                }
            }
        }
Esempio n. 12
0
        public void SaveUser(bool isNew)
        {
            DataSet   dsReturn  = new DataSet();
            DataSet   ds        = new DataSet();
            Hashtable hashTable = new Hashtable();
            DataTable dataTable = new DataTable();

            if (isNew)
            {
                hashTable.Add(RBAC_USER_FIELDS.FIELD_USER_KEY, _userKey);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_USERNAME, _userName);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_PASSWORD, _password);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_BADGE, _badge);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_OFFICE_PHONE, _officePhone);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_MOBILE_PHONE, _mobilePhone);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_REMARK, _remark);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_EMAIL, _email);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_CREATOR, Creator);
                hashTable.Add(RBAC_USER_FIELDS.FIELD_CREATE_TIMEZONE, CreateTimeZone);
                dataTable           = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                dataTable.TableName = RBAC_USER_FIELDS.DATABASE_TABLE_NAME;
                ds.Tables.Add(dataTable);
            }
            else
            {
                //update
                if (IsDirty)
                {
                    if (DirtyList.Count > 0)
                    {
                        foreach (string key in DirtyList.Keys)
                        {
                            hashTable.Add(key, DirtyList[key].FieldNewValue);
                        }
                        hashTable.Add(RBAC_USER_FIELDS.FIELD_USER_KEY, _userKey);
                        dataTable           = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                        dataTable.TableName = RBAC_USER_FIELDS.DATABASE_TABLE_NAME;
                        ds.Tables.Add(dataTable);
                    }
                }
            }

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    if (isNew)
                    {
                        dsReturn = serverFactory.CreateIUserEngine().AddUser(ds);
                    }
                    else
                    {
                        dsReturn = serverFactory.CreateIUserEngine().UpdateUser(ds);
                    }
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }