Esempio n. 1
0
        public void UpdateObjectTest()
        {
            IObjectService service  = new DefaultObjectService();
            ServiceObject  svObject = service.GetAllSerivceObjects(service.GetAllObjectDefinitions()[0].ObjectDefinitionID, null, null)[0];

            svObject.OnlyUpdateProperties = true;

            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person Name",
                Value   = new PrimeObjectField()
                {
                    PrimeDataType = PrimeFieldDataType.String,
                    Value         = "Peter, Robert - Updated"
                }
            });

            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person Image",
                Value   = new ObjectFileField()
                {
                    FileCRC       = "10001001",
                    FileExtension = ".docx",
                    FileFullPath  = "c:\\location-update.docx",
                    FileName      = "location-update.docx",
                    FileUrl       = "http://www.url.com",
                    FileSize      = 10,
                    Created       = DateTime.Now,
                    Updated       = DateTime.Now
                }
            });

            int objectId      = service.CreateORUpdateGeneralObject(svObject);
            var serviceobject = service.GetServiceObjectById(objectId, new string[]
            {
                "Person Name",
                "Person Image"
            }, null);

            Assert.Equal(serviceobject.GetPropertyValue <PrimeObjectField>("Person Name").GetStrongTypeValue <string>(), "Peter, Robert - Updated");
            Assert.Equal(serviceobject.GetPropertyValue <ObjectFileField>("Person Image").FileName, "location-update.docx");
        }
Esempio n. 2
0
        public void CreateObjectTest()
        {
            IObjectService service  = new DefaultObjectService();
            ServiceObject  svObject = new ServiceObject();

            svObject.ObjectName           = "Peter";
            svObject.ObjectOwner          = "Admin";
            svObject.OnlyUpdateProperties = false;
            svObject.UpdatedBy            = "Admin";
            svObject.CreatedBy            = "Admin";

            var objDef = service.GetAllObjectDefinitions()
                         .Where(od => od.ObjectDefinitionName.Equals("Person"))
                         .FirstOrDefault();

            if (objDef != null)
            {
                svObject.ObjectDefinitionId = objDef.ObjectDefinitionID;
            }


            Console.WriteLine("ObjectDefintionID = " + svObject.ObjectDefinitionId);
            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person Name",
                Value   = new PrimeObjectField()
                {
                    PrimeDataType = PrimeFieldDataType.String,
                    Value         = "Peter, Robert"
                }
            });
            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person Sex",
                Value   = new SingleSelectionField()
                {
                    SelectedItemID = 5
                }
            });
            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person AGE",
                Value   = new PrimeObjectField()
                {
                    PrimeDataType = PrimeFieldDataType.Integer,
                    Value         = 30
                }
            });
            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person Image",
                Value   = new ObjectFileField()
                {
                    FileCRC       = "10001001",
                    FileExtension = ".docx",
                    FileFullPath  = "c:\\location.docx",
                    FileName      = "location.docx",
                    FileUrl       = "http://www.url.com",
                    FileSize      = 10,
                    Created       = DateTime.Now,
                    Updated       = DateTime.Now
                }
            });

            svObject.Properties.Add(new ObjectKeyValuePair()
            {
                KeyName = "Person Manager",
                Value   = new ObjectReferenceField()
                {
                    ReferedGeneralObjectID = 1
                }
            });


            var objects = service.GetAllSerivceObjects(service.GetAllObjectDefinitions()[0].ObjectDefinitionID, new string[] {
                "Person Name",
                "Person Sex",
                "Person AGE",
                "Person Image",
                "Person Manager"
            }, null);

            var currObj = objects != null?objects.Where(o => o.ObjectName.Equals("Peter")).FirstOrDefault()
                              :  null;

            if (currObj == null)
            {
                int objId = service.CreateORUpdateGeneralObject(svObject);
            }

            Assert.True(service.GetGeneralObjectCount(service.GetAllObjectDefinitions()[0].ObjectDefinitionID, null) >= 1);
        }