Пример #1
0
        public void GetPersonAttributesByKeyword()
        {
            Guid g = Guid.NewGuid();

            PersonAttribute pa = new PersonAttribute();
            pa.PersonID = -10;
            pa.InsertionDate = DateTime.Now;
            pa.KeyWord = g.ToString();
            pa.ValueType = typeof(string).AssemblyQualifiedName;
            pa.StringField = "123456";
            pa.Save();
            Assert.IsNotNull(pa.ID);

            try
            {
                PersonAttribute[] coll = PersonAttributes.GetPersonAttributesByKeyword(g.ToString());
                Assert.IsNotNull(coll);
                Assert.AreEqual(1, coll.Length);

                Assert.AreEqual(pa.PersonID, coll[0].PersonID);
                Assert.AreEqual(pa.InsertionDate.Date, coll[0].InsertionDate.Date);
                Assert.AreEqual(pa.KeyWord, coll[0].KeyWord);
                Assert.AreEqual(pa.ValueType, coll[0].ValueType);
                Assert.AreEqual(pa.StringField, coll[0].StringField);
                Assert.AreEqual(pa.Value, coll[0].Value);
            }
            finally
            { pa.Delete(); }
        }
Пример #2
0
    /// <summary>
    /// Generates domain names for current user.
    /// </summary>
    /// <param name="personID">ID of person to which domain names belong to.</param>
    public void GenerateDomainNames(int personID)
    {
        try
        {
            Person person = Person.GetPersonByID(personID);
            if (person == null || person.ID == null)
                return;

            foreach (ListItem item in lbDomainNames.Items)
            {
                if (item.Value != absentDomainNameID)
                    continue;

                PersonAttribute dnAttrib = person.AddStandardStringAttribute(PersonAttributeTypes.DomainName, item.Text);
                Debug.Assert(dnAttrib.ID != null);
                item.Value = dnAttrib.ID.Value.ToString();
            }

            // Remove deleted domain names from database.
            foreach (int attribID in RemovedDomainNames)
            {
                PersonAttribute attrib = new PersonAttribute();
                if (attrib.Load(attribID))
                    attrib.Delete();
            }
        }
        catch (Exception ex)
        {
            Logger.Log.Error(ex.Message, ex);
        }
    }
Пример #3
0
    // Удаляем строку
    protected void gvContact_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int id = (int)gvContact.DataKeys[e.RowIndex].Value;
        PersonAttribute attr = new PersonAttribute();
        if (!attr.Load(id) || !attr.IsSaved)
            return;

        attr.Delete();
    }
Пример #4
0
        public void Save()
        {
            DateTime now = DateTime.Now;
            byte[] arr = new byte[1];
            arr[0] = 2;

            m_PA = new PersonAttribute();
            m_PA.PersonID = 12;
            m_PA.InsertionDate = now;
            m_PA.KeyWord = "Phone";
            m_PA.ValueType = typeof(string).AssemblyQualifiedName;
            m_PA.StringField = "123456";
            m_PA.IntegerField = 1;
            m_PA.DoubleField = 1.4;
            m_PA.BooleanField = true;
            m_PA.DateTimeField = new DateTime(1934, 12, 1);
            m_PA.BinaryField = arr;
            m_PA.Save();
            Assert.IsNotNull(m_PA.ID);

            PersonAttribute pa = new PersonAttribute();
            Assert.IsTrue(pa.Load(m_PA.ID.Value));

            Assert.AreEqual(m_PA.PersonID, pa.PersonID);
            TimeSpan diff = m_PA.InsertionDate - pa.InsertionDate;
            Assert.IsTrue(Math.Abs(diff.TotalSeconds) < 1.0);
            Assert.AreEqual(m_PA.KeyWord, pa.KeyWord);
            Assert.AreEqual(m_PA.ValueType, pa.ValueType);
            Assert.AreEqual(m_PA.StringField, pa.StringField);
            Assert.AreEqual(m_PA.IntegerField, pa.IntegerField);
            Assert.AreEqual(m_PA.DoubleField, pa.DoubleField);
            Assert.AreEqual(m_PA.BooleanField, pa.BooleanField);
            Assert.AreEqual(m_PA.DateTimeField, pa.DateTimeField);
            Assert.AreEqual(m_PA.BinaryField.Length, pa.BinaryField.Length);
            Assert.AreEqual(m_PA.BinaryField[0], pa.BinaryField[0]);
            Assert.AreEqual(m_PA.Value, pa.Value);

            m_PA.Delete();
        }
Пример #5
0
        public void LoadByDomainName_False()
        {
            Person p = new Person();
            Assert.IsFalse(p.LoadByDomainName(@"ultersysyar\yim"));

            m_Person = new Person();
            m_Person.LastName = new MLText("en", "Yakimov");
            m_Person.PersonGender = Person.Gender.Male;
            Assert.IsFalse(m_Person.ID.HasValue);
            m_Person.Save();
            Assert.IsTrue(m_Person.ID.HasValue);

            try
            {
                Assert.IsFalse(p.LoadByDomainName(@"ultersysyar\yim"));

                PersonAttribute pa = new PersonAttribute();
                pa.PersonID = m_Person.ID.Value;
                pa.InsertionDate = DateTime.Now;
                pa.KeyWord = PersonAttributeTypes.DomainName.ToString();
                pa.ValueType = typeof(string).AssemblyQualifiedName;
                pa.StringField = @"ultersysyar\yim1";
                pa.Save();
                Assert.IsNotNull(pa.ID);

                try
                {
                    Assert.IsFalse(p.LoadByDomainName(@"ultersysyar\yim"));
                }
                finally
                { pa.Delete(); }
            }
            finally
            { m_Person.Delete(); }
        }
Пример #6
0
        public void GetPersonAttributesByKeyword_Empty()
        {
            PersonAttribute[] coll = PersonAttributes.GetPersonAttributesByKeyword(-10, null);
            Assert.IsNotNull(coll);
            Assert.AreEqual(0, coll.Length);

            coll = PersonAttributes.GetPersonAttributesByKeyword(-10, string.Empty);
            Assert.IsNotNull(coll);
            Assert.AreEqual(0, coll.Length);

            coll = PersonAttributes.GetPersonAttributesByKeyword(-10, "Phone");
            Assert.IsNotNull(coll);
            Assert.AreEqual(0, coll.Length);

            PersonAttribute pa = new PersonAttribute();
            pa.PersonID = -10;
            pa.InsertionDate = DateTime.Now;
            pa.KeyWord = "Phone";
            pa.ValueType = typeof(string).AssemblyQualifiedName;
            pa.StringField = "123456";
            pa.Save();
            Assert.IsNotNull(pa.ID);

            try
            {
                coll = PersonAttributes.GetPersonAttributesByKeyword(-10, "TelePhone");
                Assert.IsNotNull(coll);
                Assert.AreEqual(0, coll.Length);
            }
            finally
            { pa.Delete(); }
        }