Exemple #1
0
        internal static PersonDto GetByLogin(Rbr_Db pDb, string pLogin)
        {
            PersonRow _personRow = pDb.PersonCollection.GetByLogin(pLogin);

            if (_personRow == null)
            {
                return(null);
            }

            ContactInfoDto          _contactInfo          = null;
            CustomerSupportGroupDto _customerSupportGroup = null;
            VirtualSwitchDto        _virtualSwitch        = null;

            if (!_personRow.IsContact_info_idNull)
            {
                _contactInfo = ContactInfoManager.Get(pDb, _personRow.Contact_info_id);
            }
            if (!_personRow.IsGroup_idNull)
            {
                _customerSupportGroup = CustomerSupportManager.GetCustomerSupportGroup(pDb, _personRow.Group_id);
            }
            if (!_personRow.IsVirtual_switch_idNull)
            {
                _virtualSwitch = VirtualSwitchManager.Get(pDb, _personRow.Virtual_switch_id);
            }
            return(mapToPerson(_personRow, _contactInfo, _customerSupportGroup, _virtualSwitch));
        }
Exemple #2
0
        public void CanUpdateReferencedEntityThroughReadWriteContext()
        {
            const string newName = "RenamedSusan";

            using (var connection = new TestTablesDbConnection()) {
                using (var cp = new TestTablesDbContextsProvider(connection)) {
                    var dbc = cp.DbContext;
                    this.TryAddingPeople(dbc);

                    PersonRow person = dbc.People
                                       .Where(p => p.Id == Id2).First();
                    person.Name = newName;

                    Assert.True(
                        dbc.People.Where(p => p.Id == Id2)
                        .Select(p => p.Name).First() == Name2);

                    dbc.SaveChanges();
                }

                using (var cp = new TestTablesDbContextsProvider(connection))
                    Assert.True(
                        cp.DbContext.People.Where(p => p.Id == Id2)
                        .Select(p => p.Name).First() == newName);
            }
        }
Exemple #3
0
        internal static void Save(Rbr_Db pDb, string pSalt, PersonDto pPerson)
        {
            bool _isNew = pPerson.PersonId == 0;

            try {
                PersonRow      _personRow;
                ContactInfoRow _contactInfoRow;
                mapToPersonRow(pPerson, out _personRow, out _contactInfoRow);

                if (_personRow != null)
                {
                    PersonRow _existingPersonRow = pDb.PersonCollection.GetByPrimaryKey(_personRow.Person_id);
                    if (_existingPersonRow != null)
                    {
                        if (_existingPersonRow.Password != _personRow.Password)
                        {
                            //-- At this point the PWD should be in a clear form, rewrite it with Hashed value
                            SaltHashedPwd _sh = SaltHashedPwd.FromClearPwd(_personRow.Password, _personRow.Salt);
                            _personRow.Password = _sh.Value;
                            pPerson.Password    = _personRow.Password;
                        }
                        if (_contactInfoRow != null)
                        {
                            if (_contactInfoRow.Contact_info_id == 0)
                            {
                                pDb.ContactInfoCollection.Insert(_contactInfoRow);
                                _personRow.Contact_info_id = _contactInfoRow.Contact_info_id;
                            }
                            else
                            {
                                pDb.ContactInfoCollection.Update(_contactInfoRow);
                            }
                        }
                        pDb.PersonCollection.Update(_personRow);
                    }
                    else
                    {
                        pDb.ContactInfoCollection.Insert(_contactInfoRow);
                        _personRow.Contact_info_id = _contactInfoRow.Contact_info_id;

                        _personRow.Salt = pSalt;
                        SaltHashedPwd _sh = SaltHashedPwd.FromClearPwd(_personRow.Password, _personRow.Salt);
                        _personRow.Password = _sh.Value;
                        pPerson.Password    = _personRow.Password;
                        pDb.PersonCollection.Insert(_personRow);
                        pPerson.PersonId = _personRow.Person_id;
                    }
                }
            }
            catch (AlternateKeyException) {
                if (_isNew)
                {
                    pPerson.PersonId = 0;                     //reset it in case of err
                }
                throw new LoginNameAlreadyInUseException();
            }
        }
Exemple #4
0
        //----------------------------------- Privates ----------------------------------------------------------
        static void mapToPersonRow(PersonDto pPerson, out PersonRow pPersonRow, out ContactInfoRow pContactInfoRow)
        {
            pPersonRow      = null;
            pContactInfoRow = null;
            if (pPerson == null)
            {
                return;
            }

            pPersonRow = new PersonRow
            {
                Person_id          = pPerson.PersonId,
                Name               = pPerson.Name,
                Login              = pPerson.Login,
                Password           = pPerson.Password,
                AccessScope        = pPerson.AccessScope,
                PermissionType     = pPerson.PermissionType,
                RegistrationStatus = pPerson.RegistrationStatus,
                PersonStatus       = pPerson.Status,
                Salt               = pPerson.Salt
            };

            if (pPerson.VirtualSwitch != null)
            {
                pPersonRow.Virtual_switch_id = pPerson.VirtualSwitchId;
            }

            if (pPerson.PartnerId != 0)
            {
                pPersonRow.Partner_id = pPerson.PartnerId;
            }
            if (pPerson.RetailAcctId != 0)
            {
                pPersonRow.Retail_acct_id = pPerson.RetailAcctId;
            }
            if (pPerson.GroupId != 0)
            {
                pPersonRow.Group_id = pPerson.GroupId;
            }
            if (pPerson.ContactInfo != null)
            {
                pPersonRow.Contact_info_id        = pPerson.ContactInfoId;
                pContactInfoRow                   = new ContactInfoRow();
                pContactInfoRow.Contact_info_id   = pPerson.ContactInfo.ContactInfoId;
                pContactInfoRow.Address1          = pPerson.ContactInfo.Address1;
                pContactInfoRow.Address2          = pPerson.ContactInfo.Address2;
                pContactInfoRow.City              = pPerson.ContactInfo.City;
                pContactInfoRow.State             = pPerson.ContactInfo.State;
                pContactInfoRow.Zip_code          = pPerson.ContactInfo.Zip;
                pContactInfoRow.Email             = pPerson.ContactInfo.Email;
                pContactInfoRow.Work_phone_number = pPerson.ContactInfo.WorkPhone;
                pContactInfoRow.Home_phone_number = pPerson.ContactInfo.HomePhone;
                pContactInfoRow.Cell_phone_number = pPerson.ContactInfo.CellPhone;
            }
        }
Exemple #5
0
 public void AddContent(IEnumerable <IPerson> persons)
 {
     foreach (IPerson _item in persons)
     {
         PersonRow _newPersonROw = Person.AddPersonRow(_item.FirstName, _item.LastName, _item.Age);
         foreach (ICDCatalog _cdEntity in _item.CDs)
         {
             this.CDCatalogEntity.AddCDCatalogEntityRow(_cdEntity.Title, _newPersonROw, _cdEntity.Country, _cdEntity.Price, _cdEntity.Year);
         }
     }
 }
        private Person convertRowToPerson(PersonRow row)
        {
            Person person = new Person();

            person.Emails = new List <Email>();

            person.FirstName = row.FirstName;
            person.LastName  = row.LastName;
            person.Emails.Add(new Email(row.Outlook));
            person.Emails.Add(new Email(row.StMartin));

            return(person);
        }
Exemple #7
0
        public PersonRow AddPersonRow(string Name, string Street, string City, string State)
        {
            PersonRow rowPersonRow = ((PersonRow)(this.NewRow()));

            object[] columnValuesArray = new object[] {
                Name,
                Street,
                City,
                State
            };
            rowPersonRow.ItemArray = columnValuesArray;
            this.Rows.Add(rowPersonRow);
            return(rowPersonRow);
        }
Exemple #8
0
 internal static PersonDto GetByRetailAcctId(Rbr_Db pDb, int pRetailAcctId)
 {
     PersonRow[] _personRows = pDb.PersonCollection.GetByRetail_acct_id(pRetailAcctId);
     if (_personRows != null && _personRows.Length > 0)
     {
         PersonRow      _personRow   = _personRows[0];
         ContactInfoDto _contactInfo = null;
         if (!_personRow.IsContact_info_idNull)
         {
             _contactInfo = ContactInfoManager.Get(pDb, _personRow.Contact_info_id);
         }
         return(mapToPerson(_personRows[0], _contactInfo, null, null));
     }
     return(null);
 }
Exemple #9
0
        static PersonDto mapToPerson(PersonRow pPersonRow, ContactInfoDto pContactInfo, CustomerSupportGroupDto pCustomerSupportGroup, VirtualSwitchDto pVirtualSwitch)
        {
            if (pPersonRow == null)
            {
                return(null);
            }
            var _person = new PersonDto();

            _person.PersonId           = pPersonRow.Person_id;
            _person.Name               = pPersonRow.Name;
            _person.Login              = pPersonRow.Login;
            _person.Password           = pPersonRow.Password;
            _person.AccessScope        = pPersonRow.AccessScope;
            _person.PermissionType     = pPersonRow.PermissionType;
            _person.RegistrationStatus = pPersonRow.RegistrationStatus;
            _person.Status             = pPersonRow.PersonStatus;
            _person.Salt               = pPersonRow.Salt;

            if (!pPersonRow.IsPartner_idNull)
            {
                _person.PartnerId = pPersonRow.Partner_id;
            }
            if (!pPersonRow.IsRetail_acct_idNull)
            {
                _person.RetailAcctId = pPersonRow.Retail_acct_id;
            }
            if (pCustomerSupportGroup != null)
            {
                _person.CustomerSupportGroup = pCustomerSupportGroup;
            }
            if (pVirtualSwitch != null)
            {
                _person.VirtualSwitch = pVirtualSwitch;
            }
            if (pContactInfo != null)
            {
                _person.ContactInfo = pContactInfo;
            }

            return(_person);
        }
Exemple #10
0
        /// <summary>
        /// Builds the Contactstring for each language in meta.LanguageCodes.
        /// </summary>
        public PXSqlContact(PXSqlMeta_24 meta, string mMainTableId)
        {
            foreach (string language in meta.LanguageCodes)
            {
                mBigFatContactStringsByLanguage.Add(language, "");
            }

            try
            {
                Dictionary <string, MainTablePersonRow> personIDs = new Dictionary <string, MainTablePersonRow>();
                try
                {
                    foreach (KeyValuePair <string, MainTablePersonRow> RoleMain in meta.MetaQuery.GetMainTablePersonRows(mMainTableId, meta.Config.Codes.RoleMain, false))
                    {
                        if (!personIDs.ContainsKey(RoleMain.Key))
                        {
                            personIDs.Add(RoleMain.Key, RoleMain.Value);
                        }
                    }
                } catch (Exceptions.PCAxisSqlException e)
                {
                    log.Error("Cant add RoleMain", e);
                }

                try
                {
                    foreach (KeyValuePair <string, MainTablePersonRow> RoleContact in meta.MetaQuery.GetMainTablePersonRows(mMainTableId, meta.Config.Codes.RoleContact, true))
                    {
                        if (!personIDs.ContainsKey(RoleContact.Key))
                        {
                            personIDs.Add(RoleContact.Key, RoleContact.Value);
                        }
                    }
                } catch (Exceptions.PCAxisSqlException e)
                {
                    log.Error("Cant add RoleContact", e);
                }



                bool firstPerson = true;
                foreach (string personId in personIDs.Keys)
                {
                    PersonRow person = meta.MetaQuery.GetPersonRow(personId);

                    if (!orgs.ContainsKey(person.OrganizationCode))
                    {
                        orgs.Add(person.OrganizationCode, meta.MetaQuery.GetOrganizationRow(person.OrganizationCode));
                    }
                    OrganizationRow org = orgs[person.OrganizationCode];

                    foreach (string language in meta.LanguageCodes)
                    {
                        if (!firstPerson)
                        {
                            //mBigFatContactStringsByLanguage[language] += "#";
                            // mBigFatContactStringsByLanguage[language] += "||";
                        }



                        //mBigFatContactStringsByLanguage[language] += person.Forename + " " + person.Surname + ", " + org.texts[language].OrganizationName +
                        //    "# " + PCAxis.Paxiom.Localization.PxResourceManager.GetResourceManager().GetString("PxcContactPhone", language) + ": " + person.PhonePrefix + " " + person.PhoneNo +
                        //    "#" + PCAxis.Paxiom.Localization.PxResourceManager.GetResourceManager().GetString("PxcContactFax", language) + ": " + person.PhonePrefix + " " + person.FaxNo +
                        //    "#" + PCAxis.Paxiom.Localization.PxResourceManager.GetResourceManager().GetString("PxcContactEMail", language) + ": " + person.Email;

                        mBigFatContactStringsByLanguage[language] +=
                            person.Forename +
                            "#" + person.Surname +
                            "# " + person.PhonePrefix +
                            "#" + person.PhoneNo +
                            "#" + person.Email +
                            "#" + org.texts[language].OrganizationName +
                            "#" + org.texts[language].Department +
                            "#" + org.texts[language].Unit +
                            "||";
                    }

                    firstPerson = false;
                }
            } catch (Exceptions.PCAxisSqlException e)
            {
                log.Error("Cant find contact info", e);
            }
        }
Exemple #11
0
 public PersonRowChangeEvent(PersonRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
Exemple #12
0
 public void AddPersonRow(PersonRow row)
 {
     this.Rows.Add(row);
 }
//        public TableAdjustment UpdateRow(LatticeData<Person, PersonRow> latticeData)
//        {
//            return latticeData.Adjust(x => x.Build());
//        }

        public TableAdjustment EditPerson(LatticeData <Person, PersonRow> latticeData, PersonRow personRow)
        {
            Person currentPerson = null;

            if (personRow.Id == 0)
            {
                currentPerson = new Person();
                _context.Persons.Add(currentPerson);
            }
            else
            {
                currentPerson = _context.Persons.FirstOrDefault(x => x.Id == personRow.Id);
            }

            currentPerson.Age        = personRow.Age;
            currentPerson.Gender     = personRow.Gender;
            currentPerson.Name       = personRow.Name;
            currentPerson.Surname    = personRow.Surname;
            currentPerson.Middlename = personRow.Middlename;
            _context.SaveChanges();

            personRow.Id = currentPerson.Id;

            return(latticeData.Adjust(x => x
                                      .Update(personRow)
//                .Message(LatticeMessage.AtsUser("success", "Editing", "Person saved!"))
                                      ));
        }
Exemple #14
0
 public PersonRowChangeEvent(PersonRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
Exemple #15
0
 public void RemovePersonRow(PersonRow row)
 {
     this.Rows.Remove(row);
 }
Exemple #16
0
 public void AddPersonRow(PersonRow row)
 {
     this.Rows.Add(row);
 }
 public AppUserRow AddAppUserRow(PersonRow parentPersonRowByFK_AppUser_Person, int PersonID, string ModuleUsage) {
     AppUserRow rowAppUserRow = ((AppUserRow)(this.NewRow()));
     object[] columnValuesArray = new object[] {
             null,
             PersonID,
             ModuleUsage};
     if ((parentPersonRowByFK_AppUser_Person != null)) {
         columnValuesArray[0] = parentPersonRowByFK_AppUser_Person[0];
     }
     rowAppUserRow.ItemArray = columnValuesArray;
     this.Rows.Add(rowAppUserRow);
     return rowAppUserRow;
 }
Exemple #18
0
 public void RemovePersonRow(PersonRow row)
 {
     this.Rows.Remove(row);
 }