Beispiel #1
0
        public User(decimal ID, bool AsProxy)
        {
            if (AsProxy == false)
            {
                FI.DataAccess.Users        dacObj = DataAccessFactory.Instance.GetUsersDA();
                FI.Common.Data.FIDataTable table  = dacObj.ReadUser(ID);
                if (table == null || table.Rows.Count == 0)
                {
                    throw new Exception("Cannot authenticate by id:" + ID.ToString());
                }

                LoadData(table);

                this._isProxy = false;
            }

            this._id = ID;

            if (this.IsNew == false)
            {
                _contactSystem      = new ContactSystem(this);
                _reportSystem       = new ReportSystem(this);
                _distributionSystem = new DistributionSystem(this);               // after Contacts and Reports
            }
        }
        private void TestLoadRemotingSocketsMethod()
        {
            try
            {
                FI.DataAccess.Users dac = FI.BusinessObjects.DataAccessFactory.Instance.GetUsersDA();
                dac.ReadUser((decimal)1);

                FI.Common.LogWriter.Instance.WriteEventLogEntry("TestLoadRemotingSocketsMethod completed");
            }
            catch (Exception exc)
            {
                FI.Common.LogWriter.Instance.WriteEventLogEntry(exc);
            }
        }
Beispiel #3
0
        public void SaveUser(User user)
        {
            if (this.IsNew || this.IsProxy)
            {
                throw new Exception("Cannot use new or proxy to save");
            }
            if (user.IsNew == false && user.IsProxy)
            {
                throw new Exception("Cannot save proxy");
            }
            if (this.IsAdmin == false && this.ID != user.ID)
            {
                throw new Exception("Permission denied");
            }

            if (this.ID == user.ID)
            {
                //saving itself , must not assign itself as admin if wasn't admin
                if (this._isAdminAudit == false && user.IsAdmin)
                {
                    throw new Exception("Premission denied : IsAdmin property");
                }
            }

            FI.DataAccess.Users dacObj = DataAccessFactory.Instance.GetUsersDA();
            if (user.IsNew)
            {
                user._id = dacObj.InsertUser(user._companyId, user.Logon, user.Password, user._passwordTimestamp, user.Name, user.Email, user.IsAdmin, user.CssStyle);
            }
            else
            {
                dacObj.UpdateUser(user.ID, user.Logon, user.Password, user._passwordTimestamp, user.Name, user.Email, user.IsAdmin, user.CssStyle);
            }

            user._isProxy      = false;
            user._isAdminAudit = user._isAdmin;
            if (this.ID == user.ID)
            {
                //update itself
                FI.Common.Data.FIDataTable table = dacObj.ReadUser(this.ID);
                this.LoadData(table);
            }
        }
Beispiel #4
0
        public User(string CompanyNameShort, string Logon, string Password)
        {
            FI.DataAccess.Users dacObj = DataAccessFactory.Instance.GetUsersDA();

            // read
            FI.Common.Data.FIDataTable table = dacObj.ReadUser(CompanyNameShort, Logon, Password);
            if (table.Rows.Count == 0)
            {
                throw new Exception("Incorrect login information");
            }

            System.Data.DataRow row = table.Rows[0];
            this._id = (decimal)row["id"];
            LoadData(table);


            this._isProxy = false;

            _contactSystem      = new ContactSystem(this);
            _reportSystem       = new ReportSystem(this);
            _distributionSystem = new DistributionSystem(this);           // after Contacts and Reports
        }