private void UpdateProperties(AWS.Folder folder, DataRow row)
        {
            List <AWS.PropInstParam> propertyValues = new List <AWS.PropInstParam>();

            foreach (DataColumn column in Data.Columns)
            {
                if (IsPropertyColumn(column.ColumnName) == false)
                {
                    continue;
                }
                AWS.PropDefInfo propertyInfo = Properties.FirstOrDefault(p => p.PropDef.DispName.Equals(column.ColumnName, StringComparison.CurrentCultureIgnoreCase));

                if (propertyInfo == null)
                {
                    Log(MessageCategory.Warning, "  Property '{0}' doesn't exist", column.ColumnName);
                    continue;
                }
                object value = GetPropertyValue(propertyInfo.PropDef, row.Field <string>(column));

                if (value == null)
                {
                    continue;
                }
                AWS.PropInstParam propParam = new AWS.PropInstParam();
                propParam.PropDefId = propertyInfo.PropDef.Id;
                propParam.Val       = value;
                propertyValues.Add(propParam);
            }
            if (propertyValues.Count > 0)
            {
                Log(MessageCategory.Info, "  Updating properties");
                ServiceManager.DocumentServiceExtensions.UpdateFolderProperties(new long[] { folder.Id },
                                                                                new AWS.PropInstParamArray[] {
                    new AWS.PropInstParamArray()
                    {
                        Items = propertyValues.ToArray()
                    }
                });
            }
        }
        /*****************************************************************************************/
        public static bool SetProperty(VDF.Vault.Currency.Connections.Connection connection, AWS.File file, string propertyName, object value, string tempPath)
        {
            long userId = connection.UserID;

            if (((file.CheckedOut) && (userId != file.CkOutUserId)) || (file.Locked))
            {
                return(false);
            }
            Option <AWS.PropDef> definition = PropertyOperations.GetPropertyDefinition(connection, propertyName);

            if (definition.IsNone)
            {
                return(false);
            }

            VDF.Vault.Currency.Entities.FileIteration fileIteration = new VDF.Vault.Currency.Entities.FileIteration(connection, file);

            Option <List <AWS.FileAssocLite> > oldAssociations = FileOperations.GetFileChildrenAssocsLite(connection, fileIteration);

            if (oldAssociations.IsNone)
            {
                return(false);
            }

            AWS.FileAssocArray[] files  = connection.WebServiceManager.DocumentService.GetLatestFileAssociationsByMasterIds(new long[] { file.MasterId }, AWS.FileAssociationTypeEnum.None, false, AWS.FileAssociationTypeEnum.Dependency, true, true, true, true);
            bool childCheckedOutByOther = false;

            foreach (AWS.FileAssocArray tempFiles in files)
            {
                try
                {
                    foreach (AWS.FileAssoc tempFile in tempFiles.FileAssocs)
                    {
                        if ((tempFile.CldFile.CheckedOut) && (tempFile.CldFile.CkOutUserId == userId))
                        {
                            VDF.Vault.Currency.Entities.FileIteration tempIteration = new VDF.Vault.Currency.Entities.FileIteration(connection, tempFile.CldFile);
                            connection.FileManager.UndoCheckoutFile(tempIteration);
                        }
                        else if ((tempFile.CldFile.CheckedOut))
                        {
                            childCheckedOutByOther = true;
                        }
                    }
                }
                catch { }
            }

            if (childCheckedOutByOther)
            {
                return(false);
            }



            VDF.Vault.Settings.AcquireFilesSettings acquireFilesSettings = new VDF.Vault.Settings.AcquireFilesSettings(connection, true);
            acquireFilesSettings.OptionsResolution.OverwriteOption = VDF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions.OverwriteOptions.ForceOverwriteAll;
            acquireFilesSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeAttachments          = false;
            acquireFilesSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren             = false; // true?
            acquireFilesSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeRelatedDocumentation = true;
            acquireFilesSettings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren             = false; // true?
            acquireFilesSettings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption      = VDF.Vault.Currency.VersionGatheringOption.Latest;;
            acquireFilesSettings.LocalPath = new VDF.Currency.FolderPathAbsolute(tempPath);
            acquireFilesSettings.AddFileToAcquire(fileIteration, /*VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout | VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download*/ file.CheckedOut ? VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download : VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout);

            try
            {
                VDF.Vault.Results.AcquireFilesResults acquireFilesResults = connection.FileManager.AcquireFiles(acquireFilesSettings);
                if (acquireFilesResults.FileResults.First().Status != VDF.Vault.Results.FileAcquisitionResult.AcquisitionStatus.Success)
                {
                    return(false);
                }


                AWS.PropInstParam property = new AWS.PropInstParam {
                    PropDefId = definition.Get().Id, Val = value
                };

                connection.WebServiceManager.DocumentService.UpdateFileProperties(new long[] { file.MasterId }, new AWS.PropInstParamArray[] { new AWS.PropInstParamArray {
                                                                                                                                                   Items = new AWS.PropInstParam[] { property }
                                                                                                                                               } });
                List <AWS.FileAssocParam> newAssociations = FileOperations.UpdateFileAssociations(connection, fileIteration, oldAssociations.Get());

                connection.FileManager.CheckinFile(fileIteration,
                                                   comment: "Updated property: " + propertyName + " to " + value.ToString(),
                                                   keepCheckedOut: false,
                                                   associations: newAssociations.ToArray(),
                                                   bom: null,
                                                   copyBom: false,
                                                   newFileName: null,
                                                   classification: fileIteration.FileClassification,
                                                   hidden: false,
                                                   filePath: new VDF.Currency.FilePathAbsolute(tempPath + "/" + file.Name));

                return(true);
            }
            catch (Exception ex)
            {
                connection.FileManager.UndoCheckoutFile(fileIteration);
                throw new ErrorMessageException("Child is checked out.");
            }
        }