コード例 #1
0
 public void PropertiesTest()
 {
     m_PA = new PersonAttribute();
     m_PA.PersonID = 12;
     Assert.AreEqual(12, m_PA.PersonID);
     m_PA.InsertionDate = new DateTime(2007, 03, 12);
     Assert.AreEqual(new DateTime(2007, 03, 12), m_PA.InsertionDate);
     m_PA.KeyWord = "Phone";
     Assert.AreEqual("Phone", m_PA.KeyWord);
     m_PA.ValueType = typeof(string).AssemblyQualifiedName;
     Assert.AreEqual(typeof(string).AssemblyQualifiedName, m_PA.ValueType);
     m_PA.StringField = "Hello";
     Assert.AreEqual("Hello", m_PA.StringField);
     m_PA.IntegerField = 34;
     Assert.AreEqual(34, m_PA.IntegerField);
     m_PA.DoubleField = 23.4;
     Assert.AreEqual(23.4, m_PA.DoubleField);
     m_PA.BooleanField = true;
     Assert.IsTrue(m_PA.BooleanField.Value);
     m_PA.DateTimeField = new DateTime(2005, 11, 07);
     Assert.AreEqual(new DateTime(2005, 11, 07), m_PA.DateTimeField);
     m_PA.BinaryField = new byte[1];
     Assert.IsNotNull(m_PA.BinaryField);
     Assert.AreEqual(1, m_PA.BinaryField.Length);
 }
コード例 #2
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(); }
        }
コード例 #3
0
        public void SetUp()
        {
            pAttrib = new PersonAttribute();
            pAttrib.BinaryField = new byte[] { 1, 2, 3 };
            pAttrib.BooleanField = true;
            pAttrib.DateTimeField = DateTime.Today;
            pAttrib.DoubleField = 1.233;
            pAttrib.InsertionDate = DateTime.Today;
            pAttrib.IntegerField = 44;
            pAttrib.PersonID = 123;
            pAttrib.StringField = "Test";
            pAttrib.ValueType = typeof( string ).AssemblyQualifiedName;
            pAttrib.Save();

            loaded = new PersonAttribute();
            loaded.Load( pAttrib.ID.Value );
        }
コード例 #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 Value_BinaryData()
 {
     byte[] arr = new byte[1];
     arr[0] = 23;
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(byte[]).AssemblyQualifiedName;
     m_PA.BinaryField = arr;
     Assert.IsNotNull(m_PA.Value);
     Assert.IsInstanceOfType(typeof(byte[]), m_PA.Value);
     byte[] retArr = (byte[])m_PA.Value;
     Assert.AreEqual(1, retArr.Length);
     Assert.AreEqual(23, retArr[0]);
 }
コード例 #6
0
 public void Value_StringData()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(string).AssemblyQualifiedName;
     m_PA.StringField = "Hello";
     Assert.AreEqual("Hello", m_PA.Value);
 }
コード例 #7
0
ファイル: Person.cs プロジェクト: Confirmit/Portal
        /// <summary>
        /// Adds standard string attribute.
        /// </summary>
        /// <param name="type">Type of attribute.</param>
        /// <param name="value">Value of attribute.</param>
        /// <returns>Created attribute.</returns>
        public PersonAttribute AddStandardStringAttribute(PersonAttributeType type, string value)
        {
            if (ID == null || string.IsNullOrEmpty(value))
                return null;

            try
            {
                var pa = new PersonAttribute
                         	{
                         		PersonID = ID.Value,
                         		InsertionDate = DateTime.Now,
                         		AttributeID = type.ID.Value,
                         		ValueType = typeof (string).AssemblyQualifiedName,
                         		StringField = value
                         	};
                pa.Save();
                return pa;
            }
            catch( Exception ex )
            {
                Logger.Log.Error( ex.Message, ex );
                return null;
            }
        }
コード例 #8
0
ファイル: UserInfoView.ascx.cs プロジェクト: Confirmit/Portal
    // Удаляем строку
    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();
    }
コード例 #9
0
 public void Value_Null_IncorrectValueType()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = "This is incorrect type.";
     Assert.IsNull(m_PA.Value);
 }
コード例 #10
0
 public void Value_IntData()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(int).AssemblyQualifiedName;
     m_PA.IntegerField = 12;
     Assert.IsInstanceOfType(typeof(Nullable<int>), m_PA.Value);
     Nullable<int> nv = (Nullable<int>)m_PA.Value;
     Assert.AreEqual(12, nv.Value);
 }
コード例 #11
0
 public void Value_DoubleData()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(double).AssemblyQualifiedName;
     m_PA.DoubleField = 23.4;
     Assert.IsInstanceOfType(typeof(Nullable<double>), m_PA.Value);
     Nullable<double> nv = (Nullable<double>)m_PA.Value;
     Assert.AreEqual(23.4, nv.Value);
 }
コード例 #12
0
 public void Value_DateTimeData()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(DateTime).AssemblyQualifiedName;
     m_PA.DateTimeField = new DateTime(1999, 10, 1);
     Assert.IsInstanceOfType(typeof(Nullable<DateTime>), m_PA.Value);
     Nullable<DateTime> nv = (Nullable<DateTime>)m_PA.Value;
     Assert.AreEqual(new DateTime(1999, 10, 1), nv.Value);
 }
コード例 #13
0
 public void Value_BoolData()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(bool).AssemblyQualifiedName;
     m_PA.BooleanField = true;
     Assert.IsInstanceOfType(typeof(Nullable<bool>), m_PA.Value);
     Nullable<bool> nv = (Nullable<bool>)m_PA.Value;
     Assert.AreEqual(true, nv.Value);
 }
コード例 #14
0
ファイル: PersonTest.cs プロジェクト: Confirmit/Portal
        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(); }
        }
コード例 #15
0
ファイル: PersonTest.cs プロジェクト: Confirmit/Portal
        public void SetUp()
        {
            person = new Person();
            person.Birthday = DateTime.Now;
            person.EmployeesUlterSYSMoscow = true;
            person.FirstName = new MLText( "en", "Tester", "ru", "Тест" );
            person.LastName = new MLText( "en", "Tester", "ru", "Тестов" );
            person.LongServiceEmployees = true;
            person.MiddleName = new MLText( "en", "T.", "ru", "Тестович" );
            person.PersonnelReserve = true;
            person.PrimaryEMail = "*****@*****.**";
            person.PrimaryIP = "127.0.0.1";
            person.Project = "Project";
            person.Room = "Room";
            person.Sex = Person.UserSex.Female;
            person.Save();

            domainNameAttr = new PersonAttribute();
            domainNameAttr.StringField = domainName;
            domainNameAttr.ValueType = typeof( string ).AssemblyQualifiedName;
            domainNameAttr.PersonID = person.ID.Value;
            domainNameAttr.Save();

            loaded = new Person();
            loaded.Load( person.ID.Value );

            /*group = new Group();
            group.GroupType = Group.GroupsEnum.Employee;
            group.Name = new MLText( "en", "Employees" );
            group.Description = new MLText( "en", "Employees" );
            group.Save();*/
        }
コード例 #16
0
 public void Value_Null_NoData()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(string).AssemblyQualifiedName;
     Assert.IsNull(m_PA.Value);
     m_PA.ValueType = typeof(int).AssemblyQualifiedName;
     Assert.IsNull(m_PA.Value);
     m_PA.ValueType = typeof(float).AssemblyQualifiedName;
     Assert.IsNull(m_PA.Value);
     m_PA.ValueType = typeof(bool).AssemblyQualifiedName;
     Assert.IsNull(m_PA.Value);
     m_PA.ValueType = typeof(DateTime).AssemblyQualifiedName;
     Assert.IsNull(m_PA.Value);
     m_PA.ValueType = typeof(byte[]).AssemblyQualifiedName;
     Assert.IsNull(m_PA.Value);
 }
コード例 #17
0
 public PersonalSettingEntity(SettingAttribute setting_attr, PersonAttribute person_attr)
 {
     m_PersonAttribute = person_attr;
     if (!setPersonSettingAttributeField(setting_attr))
         throw new Exception("Invalid setting type of personal setting.");
 }
コード例 #18
0
 public void Value_Null_NoValueType()
 {
     m_PA = new PersonAttribute();
     Assert.IsNull(m_PA.Value);
     m_PA.ValueType = string.Empty;
     Assert.IsNull(m_PA.Value);
 }
コード例 #19
0
ファイル: UserInfoView.ascx.cs プロジェクト: Confirmit/Portal
    // Сохраняем строку, которую отредактировали
    protected void gvContact_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int id = (int)gvContact.DataKeys[e.RowIndex].Value;
        PersonAttribute attr = new PersonAttribute();

        if(!attr.Load(id) || !attr.IsSaved)
            return;

        TextBox tbText = (TextBox)gvContact.Rows[e.RowIndex].FindControl("dataPanelEdit").FindControl("tbUserData");
        attr.StringField = tbText.Text;
        attr.Save();
        gvContact.EditIndex = -1;
    }
コード例 #20
0
 public void Value_Null_UnknownType()
 {
     m_PA = new PersonAttribute();
     m_PA.ValueType = typeof(TimeSpan).AssemblyQualifiedName;
     m_PA.StringField = "Hello";
     m_PA.DateTimeField = DateTime.Now;
     Assert.IsNull(m_PA.Value);
 }
コード例 #21
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);
        }
    }
コード例 #22
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(); }
        }