public override Response PreMassOperation()
        {
            ConsoleEventHandlerComment console = new ConsoleEventHandlerComment();

            kCura.EventHandler.Response retVal = new kCura.EventHandler.Response();
            retVal.Success = true;
            retVal.Message = "Successful Pre Execute Operation method";
            IDBContext dbContext = this.Helper.GetDBContext(this.Helper.GetActiveCaseID());
            string     sqlText   = $" SELECT * FROM [Comment] WHERE ArtifactID IN (SELECT ARTIFACTID from[RESOURCE].[{ this.MassActionTableName}]) ";

            System.Data.DataRowCollection results = dbContext.ExecuteSqlStatementAsDataTable(sqlText).Rows;
            foreach (System.Data.DataRow row in results)
            {
                DTOs.RDO comme = new DTOs.RDO((int)row.ItemArray[0]);
                comme.ArtifactTypeGuids.Add(new Guid(ARTIFACT_TYPE));

                comme.Fields.Add(new DTOs.FieldValue(new Guid(COMMENT_FIELD_GUID.ToString()), row.ItemArray[1]));
                console.insertJob(dbContext, this.Helper.GetAuthenticationManager().UserInfo.FullName, comme);


                DTOs.Choice choice = new DTOs.Choice(ERROR_TYPE_FIELD_GUID);
                comme.Fields.Add(new DTOs.FieldValue(TYPE_FIELD_GUID, choice));

                using (kCura.Relativity.Client.IRSAPIClient client =
                           this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(Relativity.API.ExecutionIdentity.System))
                {
                    client.APIOptions.WorkspaceID = this.Helper.GetActiveCaseID();
                    client.Repositories.RDO.UpdateSingle(comme);
                }
            }
            return(retVal);
        }
 private List <Guid> ConvertChoiceArtifactIdsToGuids(int workspaceArtifactId, List <int> choiceArtifactIds)
 {
     try
     {
         List <Guid> choiceGuids = new List <Guid>();
         foreach (int choiceArtifactId in choiceArtifactIds)
         {
             Choice choice     = _rsapiHelper.RetrieveMetricChoice(workspaceArtifactId, choiceArtifactId);
             Guid   choiceGuid = choice.Guids.FirstOrDefault();
             choiceGuids.Add(choiceGuid);
         }
         return(choiceGuids);
     }
     catch (Exception ex)
     {
         throw new Exception(Constants.ErrorMessages.CHOICE_ARTIFACT_ID_TO_GUID_CONVERSION_ERROR, ex);
     }
 }
Esempio n. 3
0
        public RDO ToRdo()
        {
            RelativityObjectAttribute objectTypeAttribute = this.GetType().GetCustomAttribute <RelativityObjectAttribute>(false);
            RDO rdo = new RDO(objectTypeAttribute.ObjectTypeGuid, ArtifactId);

            var parentProperty = this.GetParentArtifactIdProperty();

            if (parentProperty != null)
            {
                var parentId = parentProperty.GetValue(this, null);
                if (parentId != null)
                {
                    rdo.ParentArtifact = new kCura.Relativity.Client.DTOs.Artifact((int)parentId);
                }
            }

            foreach (PropertyInfo property in this.GetType().GetPublicProperties())
            {
                object theFieldValue = null;

                RelativityObjectFieldAttribute fieldAttribute = property.GetCustomAttribute <RelativityObjectFieldAttribute>();

                if (fieldAttribute != null)
                {
                    object propertyValue = property.GetValue(this);
                    if (propertyValue != null && fieldAttribute.FieldType != (int)RdoFieldType.File)
                    {
                        switch (fieldAttribute.FieldType)
                        {
                        case (int)RdoFieldType.Currency:
                        case (int)RdoFieldType.Date:
                        case (int)RdoFieldType.Decimal:
                        case (int)RdoFieldType.Empty:
                        case (int)RdoFieldType.LongText:
                        case (int)RdoFieldType.WholeNumber:
                        case (int)RdoFieldType.YesNo:
                        case (int)RdoFieldType.User:
                            theFieldValue = propertyValue;
                            break;

                        case (int)RdoFieldType.FixedLengthText:
                            int stringLenght;
                            stringLenght = property.GetCustomAttribute <RelativityObjectFieldAttribute>().Length != null?
                                           property.GetCustomAttribute <RelativityObjectFieldAttribute>().Length.Value:
                                           3000;

                            string theString = propertyValue as string;
                            if (string.IsNullOrEmpty(theString) == false && theString.Length > stringLenght)
                            {
                                theString  = theString.Substring(0, (stringLenght - 3));
                                theString += "...";
                            }

                            theFieldValue = theString;
                            break;

                        case (int)RdoFieldType.MultipleChoice:
                            // We have IList<Enum> values here
                            var multiChoiceFieldValueList = new MultiChoiceFieldValueList();

                            IEnumerable enumEnumerable = propertyValue as IEnumerable;
                            Type        entryType      = enumEnumerable.AsQueryable().ElementType;

                            var enumValues = Enum.GetValues(entryType);
                            foreach (var enumValueObject in enumEnumerable)
                            {
                                var memberInfo = entryType.GetMember(enumValueObject.ToString());
                                var relativityObjectAttribute = memberInfo[0].GetCustomAttribute <RelativityObjectAttribute>();
                                multiChoiceFieldValueList.Add(new kCura.Relativity.Client.DTOs.Choice(relativityObjectAttribute.ObjectTypeGuid));
                            }

                            theFieldValue = multiChoiceFieldValueList;
                            break;

                        case (int)RdoFieldType.MultipleObject:
                            var listOfObjects = new FieldValueList <kCura.Relativity.Client.DTOs.Artifact>();

                            foreach (int artifactId in (IList <int>)propertyValue)
                            {
                                listOfObjects.Add(new kCura.Relativity.Client.DTOs.Artifact(artifactId));
                            }

                            theFieldValue = listOfObjects;
                            break;

                        case (int)RdoFieldType.SingleChoice:

                            bool isEnumDefined = Enum.IsDefined(propertyValue.GetType(), propertyValue);

                            if (isEnumDefined == true)
                            {
                                var choiceGuid = propertyValue.GetType().GetMember(propertyValue.ToString())[0].GetCustomAttribute <RelativityObjectAttribute>().ObjectTypeGuid;
                                theFieldValue = new kCura.Relativity.Client.DTOs.Choice(choiceGuid);
                            }
                            break;

                        case (int)RdoFieldType.SingleObject:
                            if ((int)propertyValue > 0)
                            {
                                theFieldValue = new kCura.Relativity.Client.DTOs.Artifact((int)propertyValue);
                            }
                            break;

                        case SharedConstants.FieldTypeCustomListInt:
                            theFieldValue = ((IList <int>)propertyValue).ToSeparatedString(SharedConstants.ListIntSeparatorChar);
                            break;

                        case SharedConstants.FieldTypeByteArray:
                            theFieldValue = Convert.ToBase64String((byte[])propertyValue);
                            break;
                        }

                        rdo.Fields.Add(new FieldValue(fieldAttribute.FieldGuid, theFieldValue));
                    }
                }
            }

            foreach (PropertyInfo property in this.GetType().GetPublicProperties())
            {
                object theFieldValue = null;
                RelativitySingleObjectAttribute   singleObjectAttribute   = property.GetCustomAttribute <RelativitySingleObjectAttribute>();
                RelativityMultipleObjectAttribute multipleObjectAttribute = property.GetCustomAttribute <RelativityMultipleObjectAttribute>();

                if (singleObjectAttribute != null)
                {
                    int fieldsWithSameGuid = rdo.Fields.Where(c => c.Guids.Contains(singleObjectAttribute.FieldGuid)).Count();

                    if (fieldsWithSameGuid == 0)
                    {
                        object propertyValue = property.GetValue(this);
                        if (propertyValue != null)
                        {
                            int artifactId = (int)propertyValue.GetType().GetProperty("ArtifactId").GetValue(propertyValue, null);
                            if (artifactId != 0)
                            {
                                theFieldValue = new kCura.Relativity.Client.DTOs.Artifact(artifactId);
                                rdo.Fields.Add(new FieldValue(singleObjectAttribute.FieldGuid, theFieldValue));
                            }
                            else
                            {
                                theFieldValue = null;
                                rdo.Fields.Add(new FieldValue(singleObjectAttribute.FieldGuid, theFieldValue));
                            }
                        }
                    }
                }

                if (multipleObjectAttribute != null)
                {
                    int fieldsWithSameGuid = rdo.Fields.Where(c => c.Guids.Contains(multipleObjectAttribute.FieldGuid)).Count();

                    if (fieldsWithSameGuid == 0)
                    {
                        object propertyValue = property.GetValue(this);
                        if (propertyValue != null)
                        {
                            var listOfObjects = new FieldValueList <kCura.Relativity.Client.DTOs.Artifact>();

                            foreach (var objectValue in propertyValue as IList)
                            {
                                int artifactId = (int)objectValue.GetType().GetProperty("ArtifactId").GetValue(objectValue, null);

                                listOfObjects.Add(new kCura.Relativity.Client.DTOs.Artifact(artifactId));
                            }

                            theFieldValue = listOfObjects;
                            rdo.Fields.Add(new FieldValue(multipleObjectAttribute.FieldGuid, theFieldValue));
                        }
                    }
                }
            }

            return(rdo);
        }
Esempio n. 4
0
        // TODO: Scope a US to replace the usage of kCura.Relativity.Client.FieldType with our own enum for only our usages
        public static T ToHydratedDto <T>(this RDO rdo)
            where T : BaseDto, new()
        {
            T returnDto = new T();

            returnDto.ArtifactId = rdo.ArtifactID;

            foreach (PropertyInfo property in typeof(T).GetPublicProperties())
            {
                RelativityObjectFieldAttribute fieldAttribute = property.GetCustomAttribute <RelativityObjectFieldAttribute>();
                object newValueObject = null;
                if (fieldAttribute != null)
                {
                    FieldValue theFieldValue = rdo[fieldAttribute.FieldGuid];

                    switch ((int)fieldAttribute.FieldType)
                    {
                    case (int)RdoFieldType.Currency:
                        newValueObject = theFieldValue.ValueAsCurrency;
                        break;

                    case (int)RdoFieldType.Date:
                        newValueObject = theFieldValue.ValueAsDate;
                        break;

                    case (int)RdoFieldType.Decimal:
                        newValueObject = theFieldValue.ValueAsDecimal;
                        break;

                    case (int)RdoFieldType.Empty:
                        newValueObject = null;
                        break;

                    case (int)RdoFieldType.File:
                        if (theFieldValue.Value != null)
                        {
                            RelativityFile fileData = new RelativityFile(theFieldValue.ArtifactID);
                            newValueObject = fileData;
                        }
                        break;

                    case (int)RdoFieldType.FixedLengthText:
                        newValueObject = theFieldValue.ValueAsFixedLengthText;
                        break;

                    case (int)RdoFieldType.LongText:
                        newValueObject = theFieldValue.ValueAsLongText;
                        break;

                    case (int)RdoFieldType.MultipleChoice:
                        // Means we have IList<some_enum> here, in fieldAttribute.ObjectDTOType
                        var valueAsMultipleChoice = theFieldValue.ValueAsMultipleChoice;
                        if (valueAsMultipleChoice != null)
                        {
                            var listOfEnumValuesDoNotUse = typeof(List <>).MakeGenericType(fieldAttribute.ObjectFieldDTOType);
                            var listOfEnumValuesInstance = (IList)Activator.CreateInstance(listOfEnumValuesDoNotUse);
                            foreach (var choice in valueAsMultipleChoice)
                            {
                                string       choiceNameTrimmed = choice.Name.Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
                                System.Array enumValues        = System.Enum.GetValues(fieldAttribute.ObjectFieldDTOType);
                                for (int i = 0; i < enumValues.Length; i++)
                                {
                                    object theValueObject = enumValues.GetValue(i);
                                    if (theValueObject.ToString().Equals(choiceNameTrimmed, StringComparison.OrdinalIgnoreCase) == true)
                                    {
                                        listOfEnumValuesInstance.Add(theValueObject);
                                    }
                                }
                            }

                            // Now we have a List<object> and we need it to be List<fieldAttribute.ObjectFieldDTOType>
                            newValueObject = listOfEnumValuesInstance;
                        }
                        break;

                    case (int)RdoFieldType.MultipleObject:
                        newValueObject = theFieldValue.GetValueAsMultipleObject <kCura.Relativity.Client.DTOs.Artifact>()
                                         .Select <kCura.Relativity.Client.DTOs.Artifact, int>(artifact => artifact.ArtifactID).ToList();
                        break;

                    case (int)RdoFieldType.SingleChoice:
                        kCura.Relativity.Client.DTOs.Choice theChoice = theFieldValue.ValueAsSingleChoice;
                        if (theChoice != null)
                        {
                            string       choiceNameTrimmed = theChoice.Name.Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
                            System.Array enumValues        = System.Enum.GetValues(fieldAttribute.ObjectFieldDTOType);
                            for (int i = 0; i < enumValues.Length; i++)
                            {
                                object theValueObject = enumValues.GetValue(i);
                                if (theValueObject.ToString().Equals(choiceNameTrimmed, StringComparison.OrdinalIgnoreCase) == true)
                                {
                                    newValueObject = theValueObject;
                                    break;
                                }
                            }
                        }
                        break;

                    case (int)RdoFieldType.SingleObject:
                        if (theFieldValue != null && theFieldValue.ValueAsSingleObject != null && theFieldValue.ValueAsSingleObject.ArtifactID > 0)
                        {
                            newValueObject = theFieldValue.ValueAsSingleObject.ArtifactID;
                        }
                        break;

                    case (int)RdoFieldType.User:
                        if (theFieldValue.Value != null)
                        {
                            if (property.PropertyType == typeof(User))
                            {
                                newValueObject = theFieldValue.Value as User;
                            }
                        }
                        break;

                    case (int)RdoFieldType.WholeNumber:
                        newValueObject = theFieldValue.ValueAsWholeNumber;
                        break;

                    case (int)RdoFieldType.YesNo:
                        newValueObject = theFieldValue.ValueAsYesNo;
                        break;

                    case SharedConstants.FieldTypeCustomListInt:
                        newValueObject = theFieldValue.ValueAsLongText.ToListInt(SharedConstants.ListIntSeparatorChar);
                        break;

                    case SharedConstants.FieldTypeByteArray:
                        if (theFieldValue.ValueAsLongText != null)
                        {
                            newValueObject = Convert.FromBase64String(theFieldValue.ValueAsLongText);
                        }
                        break;
                    }

                    property.SetValue(returnDto, newValueObject);
                }
            }

            return(returnDto);
        }
Esempio n. 5
0
        public void UpdateField <T>(int rdoID, Guid fieldGuid, object value)
            where T : BaseDto, new()
        {
            RDO theRdo = new RDO(rdoID);

            theRdo.ArtifactTypeGuids.Add(BaseDto.GetObjectTypeGuid <T>());

            Type fieldType = typeof(T).GetProperties().Where(p => p.GetFieldGuidValueFromAttribute() == fieldGuid).FirstOrDefault().PropertyType;

            if (fieldType.IsGenericType)
            {
                if (fieldType.GetGenericTypeDefinition() == typeof(IList <>))
                {
                    if ((value as IList).HeuristicallyDetermineType().IsEnum)
                    {
                        MultiChoiceFieldValueList choices = new MultiChoiceFieldValueList();
                        List <Guid> choiceValues          = new List <Guid>();
                        foreach (var enumValue in (value as IList))
                        {
                            choices.Add(new kCura.Relativity.Client.DTOs.Choice(((Enum)enumValue).GetRelativityObjectAttributeGuidValue()));
                        }

                        theRdo.Fields.Add(new FieldValue(fieldGuid, choices));
                    }

                    if (value.GetType().GetGenericArguments() != null && value.GetType().GetGenericArguments().Length != 0)
                    {
                        if (value.GetType().GetGenericArguments()[0].IsSubclassOf(typeof(BaseDto)))
                        {
                            var listOfObjects = new FieldValueList <kCura.Relativity.Client.DTOs.Artifact>();

                            foreach (var objectValue in value as IList)
                            {
                                listOfObjects.Add(new kCura.Relativity.Client.DTOs.Artifact((int)objectValue.GetType().GetProperty("ArtifactId").GetValue(objectValue, null)));
                            }

                            theRdo.Fields.Add(new FieldValue(fieldGuid, listOfObjects));
                        }

                        if (value.GetType().GetGenericArguments()[0].IsEquivalentTo(typeof(int)))
                        {
                            var listOfObjects = new FieldValueList <kCura.Relativity.Client.DTOs.Artifact>();

                            foreach (var objectValue in value as IList)
                            {
                                listOfObjects.Add(new kCura.Relativity.Client.DTOs.Artifact((int)objectValue));
                            }

                            theRdo.Fields.Add(new FieldValue(fieldGuid, listOfObjects));
                        }
                    }
                }
                else if (value == null)
                {
                    theRdo.Fields.Add(new FieldValue(fieldGuid, value));
                }
                else if (value.GetType() == typeof(string) ||
                         value.GetType() == typeof(int) ||
                         value.GetType() == typeof(bool) ||
                         value.GetType() == typeof(decimal) ||
                         value.GetType() == typeof(DateTime))
                {
                    theRdo.Fields.Add(new FieldValue(fieldGuid, value));
                }

                UpdateRdo(theRdo);
            }
            else
            {
                RelativityObjectFieldAttribute fieldAttributeValue = typeof(T).GetProperties().Where(p => p.GetFieldGuidValueFromAttribute() == fieldGuid).FirstOrDefault().GetCustomAttribute <RelativityObjectFieldAttribute>();

                if (fieldAttributeValue != null)
                {
                    if (fieldAttributeValue.FieldType == (int)RdoFieldType.File)
                    {
                        if (value.GetType().BaseType != null)
                        {
                            if (value.GetType().BaseType.IsAssignableFrom(typeof(RelativityFile)))
                            {
                                InsertUpdateFileField(value as RelativityFile, rdoID);
                            }
                        }
                    }

                    if (fieldAttributeValue.FieldType == (int)RdoFieldType.User)
                    {
                        if (value.GetType() == typeof(User))
                        {
                            theRdo.Fields.Add(new FieldValue(fieldGuid, value));
                            UpdateRdo(theRdo);
                        }
                    }

                    if (value.GetType().IsEnum)
                    {
                        var choice = new kCura.Relativity.Client.DTOs.Choice(((Enum)value).GetRelativityObjectAttributeGuidValue());

                        theRdo.Fields.Add(new FieldValue(fieldGuid, choice));
                        UpdateRdo(theRdo);
                    }

                    if (value.GetType() == typeof(string) ||
                        value.GetType() == typeof(int) ||
                        value.GetType() == typeof(bool) ||
                        value.GetType() == typeof(decimal) ||
                        value.GetType() == typeof(DateTime))
                    {
                        theRdo.Fields.Add(new FieldValue(fieldGuid, value));
                        UpdateRdo(theRdo);
                    }
                }
            }
        }
        public void Valid_Gravity_RelativityObject_Read_Field_Type <T>(string objectPropertyName, T sampleData)
        {
            void Inner()
            {
                //Arrange
                LogStart($"Arrangement for property {objectPropertyName}");

                GravityLevelOne testObject = new GravityLevelOne()
                {
                    Name = $"TestObjectRead_{objectPropertyName}{Guid.NewGuid()}"
                };

                Guid         testObjectTypeGuid = testObject.GetObjectLevelCustomAttribute <RelativityObjectAttribute>().ObjectTypeGuid;
                Guid         nameFieldGuid      = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>("Name").FieldGuid;
                var          testFieldAttribute = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>(objectPropertyName);
                Guid         testFieldGuid      = testFieldAttribute.FieldGuid;
                RdoFieldType fieldType          = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>(objectPropertyName).FieldType;

                _client.APIOptions.WorkspaceID = _workspaceId;

                object expectedData = sampleData;

                var dto = new RDO()
                {
                    ArtifactTypeGuids = new List <Guid> {
                        testObjectTypeGuid
                    }
                };
                int newArtifactId = -1;

                dto.Fields.Add(new FieldValue(nameFieldGuid, testObject.Name));

                int objectToAttachID;

                //need this mess because when passing in tests for decimal and currency System wants to use double and causes problems
                switch (fieldType)
                {
                case RdoFieldType.SingleChoice:
                    Enum   singleChoice      = (Enum)Enum.ToObject(sampleData.GetType(), sampleData);
                    Guid   singleChoiceGuid  = singleChoice.GetRelativityObjectAttributeGuidValue();
                    Choice singleChoiceToAdd = new Choice(singleChoiceGuid);
                    dto.Fields.Add(new FieldValue(testFieldGuid, singleChoiceToAdd));
                    break;

                case RdoFieldType.SingleObject:
                    int objectToAttach =
                        _testObjectHelper.CreateTestObjectWithGravity <GravityLevel2>(sampleData as GravityLevel2);
                    dto.Fields.Add(new FieldValue(testFieldGuid, objectToAttach));
                    expectedData = (sampleData as GravityLevel2).Name;
                    break;

                case RdoFieldType.MultipleObject:
                    IList <GravityLevel2>     gravityLevel2s = (IList <GravityLevel2>)sampleData;
                    FieldValueList <Artifact> objects        = new FieldValueList <Artifact>();
                    expectedData = new Dictionary <int, string>();
                    foreach (GravityLevel2 child in gravityLevel2s)
                    {
                        objectToAttachID =
                            _testObjectHelper.CreateTestObjectWithGravity <GravityLevel2>(child);
                        objects.Add(new Artifact(objectToAttachID));
                        (expectedData as Dictionary <int, string>).Add(objectToAttachID, child.Name);
                    }
                    dto.Fields.Add(new FieldValue(testFieldGuid, objects));
                    break;

                default:
                    dto.Fields.Add(new FieldValue(testFieldGuid, sampleData));
                    break;
                }

                WriteResultSet <RDO> writeResults = _client.Repositories.RDO.Create(dto);

                if (writeResults.Success)
                {
                    newArtifactId = writeResults.Results[0].Artifact.ArtifactID;
                    Console.WriteLine($"Object was created with Artifact ID {newArtifactId}.");
                }
                else
                {
                    Console.WriteLine($"An error occurred creating object: {writeResults.Message}");
                    foreach (var result in
                             writeResults.Results
                             .Select((item, index) => new { rdoResult = item, itemNumber = index })
                             .Where(x => x.rdoResult.Success == false))
                    {
                        Console.WriteLine($"An error occurred in create request {result.itemNumber}: {result.rdoResult.Message}");
                    }
                }

                LogEnd("Arrangement");

                //Act
                LogStart("Act");

                object gravityFieldValue = null;

                if (newArtifactId > 0)
                {
                    GravityLevelOne testGravityObject = _testObjectHelper.ReturnTestObjectWithGravity <GravityLevelOne>(newArtifactId);
                    gravityFieldValue = testGravityObject.GetPropertyValue(objectPropertyName);
                    if (gravityFieldValue != null)
                    {
                        switch (fieldType)
                        {
                        case RdoFieldType.SingleObject:
                            gravityFieldValue = ((GravityLevel2)gravityFieldValue).Name;
                            break;

                        case RdoFieldType.MultipleObject:
                            gravityFieldValue = ((List <GravityLevel2>)gravityFieldValue).ToDictionary(x => x.ArtifactId, x => x.Name);
                            break;
                        }
                    }
                }

                LogEnd("Act");

                //Assert
                LogStart("Assertion");

                if (newArtifactId > 0)
                {
                    Assert.AreEqual(expectedData, gravityFieldValue);
                }
                else
                {
                    Assert.Fail("Could not create object to test with through RSAPI. This is not a Gravity failure.");
                }

                LogEnd("Assertion");
            }

            TestWrapper(Inner);
        }
        //need object fields, could get a little more difficult
        public void Valid_Gravity_RelativityObject_Create_Field_Type <T>(string objectPropertyName, T sampleData)
        {
            void Inner()
            {
                //Arrange
                LogStart($"for property{objectPropertyName}");

                GravityLevelOne testObject = new GravityLevelOne()
                {
                    Name = $"TestObjectCreate_{objectPropertyName}{Guid.NewGuid()}"
                };

                var          testFieldAttribute = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>(objectPropertyName);
                Guid         testFieldGuid      = testFieldAttribute.FieldGuid;
                RdoFieldType fieldType          = testFieldAttribute.FieldType;


                //need this mess because when passing in tests for decimal and currency System wants to use double and causes problems
                switch (fieldType)
                {
                case RdoFieldType.Currency:
                case RdoFieldType.Decimal:
                    testObject.SetValueByPropertyName(objectPropertyName, Convert.ToDecimal(sampleData));
                    break;

                default:
                    testObject.SetValueByPropertyName(objectPropertyName, sampleData);
                    break;
                }

                _client.APIOptions.WorkspaceID = _workspaceId;

                LogEnd("Arrangement");

                //Act
                LogStart("Act");

                var newRdoArtifactId = _testObjectHelper.CreateTestObjectWithGravity <GravityLevelOne>(testObject);

                //read artifactID from RSAPI
                RDO newObject = _client.Repositories.RDO.ReadSingle(newRdoArtifactId);

                FieldValue field = newObject.Fields.Get(testFieldGuid);

                object newObjectValue = null;
                object expectedData   = sampleData;

                switch (fieldType)
                {
                case RdoFieldType.LongText:
                    newObjectValue = field.ValueAsLongText;
                    break;

                case RdoFieldType.FixedLengthText:
                    newObjectValue = field.ValueAsFixedLengthText;
                    break;

                case RdoFieldType.WholeNumber:
                    newObjectValue = field.ValueAsWholeNumber;
                    break;

                case RdoFieldType.YesNo:
                    newObjectValue = field.ValueAsYesNo;
                    break;

                case RdoFieldType.Currency:
                    newObjectValue = field.ValueAsCurrency;
                    break;

                case RdoFieldType.Decimal:
                    newObjectValue = field.ValueAsDecimal;
                    break;

                case RdoFieldType.SingleChoice:
                    int choiceArtifactId = field.ValueAsSingleChoice.ArtifactID;
                    if (choiceArtifactId > 0)
                    {
                        Choice choice           = _client.Repositories.Choice.ReadSingle(choiceArtifactId);
                        Enum   singleChoice     = (Enum)Enum.ToObject(sampleData.GetType(), sampleData);
                        Guid   singleChoiceGuid = singleChoice.GetRelativityObjectAttributeGuidValue();
                        newObjectValue = choice.Guids.SingleOrDefault(x => x == singleChoiceGuid);
                        expectedData   = singleChoiceGuid;
                    }
                    break;

                case RdoFieldType.SingleObject:
                    newObjectValue = field.ValueAsSingleObject.ArtifactID;
                    expectedData   = testObject.GravityLevel2Obj.ArtifactId > 0
                                                        ? (object)testObject.GravityLevel2Obj.ArtifactId
                                                        : null;
                    break;

                case RdoFieldType.MultipleObject:
                    var  rawNewObjectValue  = field.GetValueAsMultipleObject <Artifact>();
                    var  resultData         = new List <GravityLevel2>();
                    Guid childFieldNameGuid = new GravityLevel2().GetCustomAttribute <RelativityObjectFieldAttribute>("Name").FieldGuid;

                    foreach (Artifact child in rawNewObjectValue)
                    {
                        //'Read' - need to get name.
                        RDO childRdo = new RDO()
                        {
                            Fields = new List <FieldValue>()
                            {
                                new FieldValue(childFieldNameGuid)
                            }
                        };
                        childRdo = _client.Repositories.RDO.ReadSingle(child.ArtifactID);
                        string childNameValue = childRdo.Fields.Where(x => x.Guids.Contains(childFieldNameGuid)).FirstOrDefault().ToString();

                        resultData.Add(new GravityLevel2()
                        {
                            ArtifactId = child.ArtifactID, Name = childNameValue
                        });
                    }
                    newObjectValue = resultData.ToDictionary(x => x.ArtifactId, x => x.Name);
                    expectedData   = ((IEnumerable <GravityLevel2>)expectedData).ToDictionary(x => x.ArtifactId, x => x.Name);

                    break;
                }

                LogEnd("Act");

                //Assert
                LogStart("Assertion");

                //Assert
                Assert.AreEqual(expectedData, newObjectValue);

                LogEnd("Assertion");
            }

            TestWrapper(Inner);
        }