当前位置: 首页>>代码示例>>C#>>正文


C# IEditableRoot.SetValueByPropertyName方法代码示例

本文整理汇总了C#中IEditableRoot.SetValueByPropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# IEditableRoot.SetValueByPropertyName方法的具体用法?C# IEditableRoot.SetValueByPropertyName怎么用?C# IEditableRoot.SetValueByPropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEditableRoot的用法示例。


在下文中一共展示了IEditableRoot.SetValueByPropertyName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValue

        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="editableRoot">The editable root.</param>
        /// <returns></returns>
        public object GetValue(DetailsSaveFieldModel field, IEditableRoot editableRoot)
        {
            if (field.Settings == null)
                return null;

            var fileFieldOptions = field.Settings.ToObject<FileFieldOptions>();
            if (fileFieldOptions == null)
                return null;

            IFileProcess fileEdit = editableRoot.GetValueByPropertyName(field.SystemName);
            if (fileEdit == null)
                return null;

            fileEdit.FileName = fileFieldOptions.FileName;
            fileEdit.OriginalFileName = fileFieldOptions.OriginalFileName;

            if (!fileFieldOptions.Locked)
            {
                fileEdit.LockedDate = null;
            }
            else if (!fileEdit.Locked.HasValue || !fileEdit.Locked.Value)
            {
                fileEdit.LockedDate = DateTime.Now;
            }
            fileEdit.Locked = fileFieldOptions.Locked;
            fileEdit.LockedByAccountId = fileFieldOptions.LockedByAccountId;
            fileEdit.LockedByAccountName = fileFieldOptions.LockedByAccountName;

            if (fileFieldOptions.AuditLog != null)
            {
                fileEdit.FileChangeInfo = new AuditLogInfo
                {
                    LogType = fileFieldOptions.AuditLog.LogType,
                    ProcessName = fileFieldOptions.AuditLog.ProcessName,
                    ItemId = fileFieldOptions.AuditLog.ItemId,
                    FieldName = fileFieldOptions.AuditLog.FieldName,
                    OldValue = fileFieldOptions.AuditLog.OldValue,
                    NewValue = fileFieldOptions.AuditLog.NewValue,
                    DateUpdated = fileFieldOptions.AuditLog.DateUpdated,
                    User = fileFieldOptions.AuditLog.User
                };
            }

            var newModel = ((IBusinessBase)fileEdit).Save();

            if (fileFieldOptions.FileId == 0)
            {
                editableRoot.SetValueByPropertyName(string.Format("{0}Id", field.SystemName), ((IDynamicObject)newModel).Id);
            }

            return newModel;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:58,代码来源:FileFieldTypeHandler.cs

示例2: Update

        /// <summary>
        /// Updates the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        public void Update(IDynamicObject source, IEditableRoot destination)
        {
            var filterList = new List<ColumnFilter>();

            foreach (var filterBuilder in _filterBuilders)
            {
                ColumnFilter filter;
                if (!filterBuilder.TryGetFilter(source, out filter))
                    return;
                filterList.Add(filter);
            }

            var itemIds = RuntimeDatabase.FindItems(_referencedProcess, filterList);
            if (itemIds.Count <= 0)
                return;

            if (_allowMultiple)
            {
                var crList = (ICrossRefItemList)destination.GetValueByPropertyName(_property.Name);

                if (crList == null)
                    return;

                foreach (var id in itemIds.Where(id => !crList.Contains(id)))
                {
                    crList.Assign(id);
                }
            }
            else
            {
                destination.SetValueByPropertyName(_property.Name, itemIds[0]);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:38,代码来源:CrossReferenceFieldUpdater.cs

示例3: Update

        /// <summary>
        /// Updates the specified item.
        /// </summary>
        /// <param name="dataContext">
        /// The data context.
        /// </param>
        /// <param name="item">
        /// The destination item.
        /// </param>
        public void Update(IDataContext dataContext, IEditableRoot item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            try
            {
                var checklist = (ChecklistEdit)item.GetValueByPropertyName(FieldName);
                if (checklist == null || checklist.AnswerProcessList == null)
                {
                    checklist = CreateNewChecklist();
                    item.SetValueByPropertyName(FieldName, checklist);
                }

                if (ValueExpression != null)
                {
                    var items = ValueExpression(dataContext) as IEnumerable;

                    if (items != null)
                    {
                        var enumerator = items.GetEnumerator();

                        while (enumerator.MoveNext())
                        {
                            InsertOrUpdateChildren(dataContext, checklist);
                        }
                    }
                }
                else
                {
                    InsertOrUpdateChildren(dataContext, checklist);
                }
            }
            catch (Exception ex)
            {
                var message = new StringBuilder();
                message.AppendFormat(CultureInfo.InvariantCulture, "Could not update the field \"{0}\" in process \"{1}\".", DisplayName, item.ProcessDisplayName);

                throw new InvalidOperationException(message.ToString(), ex);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:50,代码来源:ChecklistFieldMapping.cs

示例4: Update

        /// <summary>
        /// Updates the field value.
        /// </summary>
        /// <param name="destination">
        /// The destination.
        /// </param>
        public void Update(IEditableRoot destination)
        {
            if (destination == null)
                throw new ArgumentNullException("destination");

            destination.SetValueByPropertyName(FieldName, NewValue);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:13,代码来源:SingleCrossReferenceFieldUpdater.cs

示例5: Update

        /// <summary>
        /// Updates the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <exception cref="System.ArgumentNullException">
        /// source
        /// or
        /// destination
        /// </exception>
        public void Update(IDynamicObject source, IEditableRoot destination)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            if (destination == null)
                throw new ArgumentNullException("destination");

            if (IsLocalizable)
            {
                foreach (var localizationInfo in _property.DeclaringType.GetCustomAttributes<LocalizationInfoAttribute>())
                {
                    var cultureName = localizationInfo.CultureName;
                    var fieldName = LocalizationUtils.GetLocalizedFieldName(_property.Name, cultureName);

                    destination.SetValueByPropertyName(fieldName, GetValue(source, cultureName));
                }
            }
            else
            {
                destination.SetValueByPropertyName(_property.Name, GetValue(source, DefaultCultureName));
            }

            if (_property.Name == Constants.IdColumnName)
                destination.DisableIdGeneration = true;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:36,代码来源:SimpleFieldUpdater.cs

示例6: ExecuteUnlink

        private void ExecuteUnlink(IEditableRoot source, IEditableRoot destination)
        {
            var currentId = destination.GetValueByPropertyName(Property.Name) as int?;
            if (currentId == null)
                return;

            var item = GetSourceItem(CreateLinkedItemFilter(currentId.Value), CreateSourceDataFilter(source));
            if (item == null)
                return;

            var ancestor = item.GetAncestorByProcessName(ReferencedProcessName);
            if (ancestor == null || ancestor.Id != currentId)
                return;

            destination.SetValueByPropertyName(Property.Name, null);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:16,代码来源:SingleCrossReferenceListFieldUpdater.cs

示例7: UpdateModelDefaultValues

        private static void UpdateModelDefaultValues(IEditableRoot model)
        {
            using (new BypassPropertyCheckContext())
            {
                foreach (var prop in model.GetAllPropertiesByFieldType(ColumnTypes.SampleType))
                {
                    var value = model.GetValueByPropertyName(prop.Name);
                    if (string.IsNullOrWhiteSpace(value))
                    {
                        model.SetValueByPropertyName(prop.Name, SampleTypes.Number.ToString());
                    }
                }

                //ELMTSUP 2512
                //foreach (var prop in model.GetAllPropertiesByFieldType(ColumnTypes.SamplingTechnique))
                //{
                //    var value = model.GetValueByPropertyName(prop.Name);
                    //if (string.IsNullOrWhiteSpace(value))
                    //{
                    //    model.SetValueByPropertyName(prop.Name, SampleSizeTypes.Fixed.ToString());
                    //}
                //}
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:24,代码来源:ProcessController.cs

示例8: ExecuteLink

        private void ExecuteLink(IEditableRoot source, IEditableRoot destination)
        {
            var infoItem = GetSourceItem(CreateSourceDataFilter(source));
            if (infoItem == null)
                return;

            var ancestor = infoItem.GetAncestorByProcessName(ReferencedProcessName);
            if (ancestor == null)
                return;

            if (destination.GetValueByPropertyName(Property.Name) == ancestor.Id)
                return;

            destination.SetValueByPropertyName(Property.Name, ancestor.Id);

            if (FieldUpdaters.Count == 0)
                return;

            var criteria = new DetailCriteria(infoItem.Id) { AllowLazyLoading = true };
            var editItem = DynamicTypeManager.GetEditableRoot<IEditableRoot>(SourceDataProcessName, criteria);
            if (editItem == null || editItem.Id <= 0)
                return;

            var sourceData = new DataTriggerSourceData();
            sourceData.SourceItems[DataTriggerFieldMappingExpressionNames.SourceDataProcess] = editItem;

            UpdateFieldValues(sourceData, editItem);
            ((ISavable)editItem).Save();
        }
开发者ID:mparsin,项目名称:Elements,代码行数:29,代码来源:SingleCrossReferenceListFieldUpdater.cs

示例9: UpdateInternal

        private void UpdateInternal(IDataContext dataContext, IEditableRoot item)
        {
            try
            {
                if (ValueExpression != null)
                {
                    item.SetValueByPropertyName(Property.Name, TypeConverter.Convert<int?>(ValueExpression(dataContext)));
                }
                else
                {
                    var filters = new List<ColumnFilter>();

                    foreach (var fieldMapping in ChildMappings.Where(m => m.IsKey))
                    {
                        ColumnFilter filter;
                        if (!fieldMapping.TryCreateFilter(dataContext, out filter))
                            return;

                        filters.Add(filter);
                    }

                    var itemIds = RuntimeDatabase.FindItems(ReferencedProcessName, filters);
                    if (itemIds.Count > 0)
                    {
                        UpdateChild(dataContext, itemIds[0]);
                        item.SetValueByPropertyName(Property.Name, itemIds[0]);
                    }
                    else
                    {
                        var child = CreateChild(dataContext);
                        item.SetValueByPropertyName(Property.Name, child.Id);
                    }
                }
            }
            catch (Exception ex)
            {
                var message = new StringBuilder();
                message.AppendFormat(
                    CultureInfo.InvariantCulture,
                    "Could not update the field \"{0}\" in process \"{1}\".",
                    DisplayName,
                    item.ProcessDisplayName);

                throw new InvalidOperationException(message.ToString(), ex);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:46,代码来源:SingleCrossReferenceFieldMapping.cs

示例10: Update

        /// <summary>
        /// Updates destination field.
        /// </summary>
        /// <param name="destination">The destination item.</param>
        public void Update(IEditableRoot destination)
        {
            if (destination == null)
                throw new ArgumentNullException("destination");

            if (FieldName == Constants.CurrentStateColumnName)
            {
                UpdateCurrentState(destination);
            }
            else
            {
                if (AllowLocalizedData)
                {
                    foreach (var localization in SupportedLocalizations)
                    {
                        var cultureName = localization.CultureName;
                        destination.SetValueByPropertyName(LocalizationUtils.GetLocalizedFieldName(FieldName, cultureName), GetValue(cultureName));
                    }
                }
                else
                {
                    destination.SetValueByPropertyName(FieldName, GetValue(DefaultCultureName));
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:29,代码来源:SimpleFieldUpdater.cs

示例11: Update

        /// <summary>
        /// Updates the specified item.
        /// </summary>
        /// <param name="dataContext">
        /// The data context.
        /// </param>
        /// <param name="item">
        /// The destination item.
        /// </param>
        public void Update(IDataContext dataContext, IEditableRoot item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            try
            {
                switch (Property.Name)
                {
                    case Constants.IdColumnName:
                        UpdateIdField(dataContext, item);
                        break;

                    case Constants.CurrentStateColumnName:
                        UpdateCurrentState(dataContext, item);
                        break;

                    default:
                        {
                            if (AllowLocalizedData)
                            {
                                foreach (var localization in SupportedLocalizations)
                                {
                                    object value;

                                    using (new CultureContext(localization.CultureName))
                                    {
                                        value = GetValue(dataContext);
                                        if (IsKey && value == null)
                                            throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The key field \"{0}\" is null.", FieldName));
                                    }

                                    item.SetValueByPropertyName(LocalizationUtils.GetLocalizedFieldName(Property.Name, localization.CultureName), value);
                                }
                            }
                            else
                            {
                                var value = GetValue(dataContext);
                                if (IsKey && value == null)
                                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The key field \"{0}\" is null.", FieldName));

                                item.SetValueByPropertyName(Property.Name, value);
                            }
                        }

                        break;
                }
            }
            catch (Exception ex)
            {
                var message = new StringBuilder();
                message.AppendFormat(
                    CultureInfo.InvariantCulture,
                    "Could not update the field \"{0}\" in process \"{1}\".",
                    DisplayName,
                    item.ProcessDisplayName);

                throw new InvalidOperationException(message.ToString(), ex);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:69,代码来源:SimpleFieldMapping.cs

示例12: CopyAnswerData

        /// <summary>
        /// Copies the answer data.
        /// </summary>
        /// <param name="answerFieldValues">
        /// The answer field values.
        /// </param>
        /// <param name="answerItem">
        /// The answer item.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="answerFieldValues"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="answerItem"/> parameter is null.
        /// </exception>
        public static void CopyAnswerData(ICollection<ChecklistAnswerFieldValue> answerFieldValues, IEditableRoot answerItem)
        {
            if (answerFieldValues == null)
                throw new ArgumentNullException("answerFieldValues");

            if (answerItem == null)
                throw new ArgumentNullException("answerItem");

            using (new ThreadLocalBypassPropertyCheckContext())
            {
                foreach (var fieldValue in answerFieldValues.Where(f => f.Value != null))
                {
                    var answerProperty = answerItem.GetPropertyByName(fieldValue.FieldName);
                    var answerValue = answerItem.GetValueByPropertyName(fieldValue.FieldName);

                    if (fieldValue.Value is ICrossRefItemList && answerValue is ICrossRefItemList)
                    {
                        var qList = (ICrossRefItemList)fieldValue.Value;
                        var aList = (ICrossRefItemList)answerValue;

                        aList.Clear();
                        foreach (var crItem in qList.Cast<ICrossRefItemInfo>())
                        {
#if !SILVERLIGHT
                            aList.Assign(crItem.Id);
#else
                            aList.Assign(crItem.Id, (o, e) => { });
#endif
                        }

                        continue;
                    }

                    if (answerProperty.PropertyType.IsInstanceOfType(fieldValue.Value))
                    {
                        answerItem.SetValueByPropertyName(fieldValue.FieldName, fieldValue.Value);
                    }
                    else
                    {
                        throw new VeyronException(
                            string.Format(
                                CultureInfo.InvariantCulture,
                                "Cannot assign value of type \"{0}\" to property \"{1}\".",
                                fieldValue.Value.GetType().AssemblyQualifiedName,
                                fieldValue.FieldName));
                    }
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:64,代码来源:ChecklistHelper.cs


注:本文中的IEditableRoot.SetValueByPropertyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。