コード例 #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
        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 );
        }
コード例 #3
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();
        }
コード例 #4
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;
            }
        }
コード例 #5
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;
    }
コード例 #6
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();*/
        }
コード例 #7
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(); }
        }
コード例 #8
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(); }
        }