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


C# IEditableRoot.GetValueByPropertyName方法代码示例

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


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

示例1: Create

        /// <summary>
        /// The create.
        /// </summary>
        /// <returns>
        /// The <see cref="ResultFieldOptions"/>.
        /// </returns>
        public static SampleFieldOptions Create(PropertyInfo property, IEditableRoot model)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var result = new SampleFieldOptions();

            var settingsString = model.GetValueByPropertyName(string.Format(CultureInfo.InvariantCulture, "{0}{1}", property.Name, Constants.SampleSettingPostfix));
            if (!string.IsNullOrEmpty(settingsString))
            {
                var sampleSettings = XElement.Parse(settingsString);
                SetProperties(result, sampleSettings, model);
            }

            result.IsNewItem = model.Id == 0;

            return result;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:31,代码来源:SampleFieldOptions.cs

示例2: 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

示例3: 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

示例4: Create

        public static IFieldOptions Create(PropertyInfo property, IEditableRoot editableRoot)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            if (editableRoot == null)
            {
                throw new ArgumentNullException("editableRoot");
            }

            var crossRefAttr = property.GetCustomAttributes(typeof(CrossRefFieldAttribute), false).Select(d => d).FirstOrDefault() as CrossRefFieldAttribute;
            if (crossRefAttr == null)
            {
                throw new VeyronException("CrossRef attribute not found on Cross-reference field property");
            }

            string valueAsText = "Unknown";

            var crId = editableRoot.GetValueByPropertyName(property.Name) as int?;

            if (crId.HasValue)
            {
                var ancestor = editableRoot.GetAncestor(property);
                if (ancestor != null)
                {
                    var crItem = DynamicTypeManager.Instance.GetCrossReferenceItem(ancestor.ProcessName, property.Name, crId.Value);
                    if (crItem != null)
                    {
                        valueAsText = crItem.GetValueByPropertyName(crossRefAttr.RefFieldName) == null ? "Unknown" : crItem.GetValueByPropertyName(crossRefAttr.RefFieldName).ToString();
                    }
                }
            }
            
            var result = new SingleCrossRefFieldOptions
            {
                ValueAsText = valueAsText, 
                ProcessSystemName = crossRefAttr.ReferenceTableName, 
                FieldName = crossRefAttr.RefFieldName,
                AllowViewDetail = crossRefAttr.AllowViewDetail,
                AllowClear = crossRefAttr.AllowClear
            };

            return result;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:46,代码来源:SingleCrossRefFieldOptions.cs

示例5: Update

        /// <summary>
        /// Updates the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <exception cref="System.InvalidOperationException">
        /// Failed to load system options.
        /// or
        /// Temp document UNC is empty.
        /// </exception>
        public void Update(IDynamicObject source, IEditableRoot destination)
        {
            var fileLocation = ESyncTypeConverter.Convert<string>(_valueCalculator.GetValue(source, _field.MappingKey));

            if (string.IsNullOrWhiteSpace(fileLocation))
                return;

            var systemOptions = SystemOptionsInfo.GetSystemOptionsInfo();

            if (systemOptions == null)
                throw new InvalidOperationException("Failed to load system options.");

            var tempDocumentUnc = systemOptions.TempDocumentUNC;

            if (string.IsNullOrWhiteSpace(tempDocumentUnc))
                throw new InvalidOperationException("Temp document UNC is empty.");

            if (!Directory.Exists(tempDocumentUnc))
                Directory.CreateDirectory(tempDocumentUnc);

            var fileField = (IFileProcess)destination.GetValueByPropertyName(_property.Name);

            if (fileField == null)
                return;

            fileField.OriginalFileName = Path.GetFileName(fileLocation);
            fileField.FileName = Guid.NewGuid() + Path.GetExtension(fileLocation);

            var tempFilePath = Path.Combine(tempDocumentUnc, fileField.FileName);

            using (var client = new WebClient())
            {
                // Copy file to temp directory.
                client.DownloadFile(fileLocation, tempFilePath);
            }

            var convertToPdef = (fileField.ConvertToPdf ?? false) && FileHelper.ConversionToPdfSupported(fileField.FileName);

            if (convertToPdef)
            {
                fileField.ConvertedFileName = FileHelper.GetNewFileNameWithPdfExtension(fileField.FileName);
                var tempPdfFilePath = Path.Combine(tempDocumentUnc, fileField.ConvertedFileName);

                if (!fileField.IsPdfWithReport())
                    FileManager.ConvertToPdf(tempFilePath, tempPdfFilePath);
            }

            // Copy file to final directory.
            fileField.UploadFile();

            if (convertToPdef)
            {
                if (fileField.IsPdfWithReport())
                {
                    (new FileManager()).UpdatePdf(destination, fileField);
                }
                else
                {
                    //When we change IFileProcess, we'll need to add UploadFile(string fileName) method
                    var fileName = fileField.FileName;
                    fileField.FileName = fileField.ConvertedFileName;
                    fileField.UploadFile();
                    fileField.FileName = fileName;
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:76,代码来源:FileFieldUpdater.cs

示例6: GetSampleType

        /// <summary>
        /// Gets the sample type of the specified sample field.
        /// </summary>
        /// <param name="item">
        /// The editable root item.
        /// </param>
        /// <param name="sampleFieldName">
        /// The sample field name.
        /// </param>
        /// <returns>
        /// The <see cref="SampleTypes"/>.
        /// </returns>
        public SampleTypes GetSampleType(IEditableRoot item, string sampleFieldName)
        {
            var settings = GetSampleSettings(item, sampleFieldName);

            if (!string.IsNullOrEmpty(settings.SampleTypeFieldName))
            {
                SampleTypes sampleType;
                if (Enum.TryParse(item.GetValueByPropertyName(settings.SampleTypeFieldName), out sampleType))
                    return sampleType;
            }

            return SampleTypes.Number;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:25,代码来源:SampleUtils.cs

示例7: GetSampleSettings

        /// <summary>
        /// Gets the settings of the specified sample field.
        /// </summary>
        /// <param name="item">
        /// The editable root item.
        /// </param>
        /// <param name="sampleFieldName">
        /// The sample field name.
        /// </param>
        /// <returns>
        /// The <see cref="SampleSettings"/>.
        /// </returns>
        public SampleSettings GetSampleSettings(IEditableRoot item, string sampleFieldName)
        {
            var xml = item.GetValueByPropertyName(sampleFieldName + Constants.SampleSettingPostfix) as string;

            return SampleSettings.Parse(xml);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:18,代码来源:SampleUtils.cs

示例8: GetChartDescriptor

        private static ChartPanel GetChartDescriptor(IEditableRoot instance, string exprFieldName, string spcFieldName, ChartTypesEnum chartType, int subgroupSize, int dataPoints = 0)
        {
            ChartPanel chartDescriptor = null;

            MobileDictionary<string, ChartPanel> dict = null;
            if (!exprFieldName.Contains("_Rule"))
            {
                dict = instance.GetValueByPropertyName("ChartDescriptorExp") as MobileDictionary<string, ChartPanel>;
                if (dict != null)
                    dict.TryGetValue(string.Format("{0}{1}", exprFieldName, spcFieldName), out chartDescriptor);
                else
                    dict = new MobileDictionary<string, ChartPanel>();
            }

            if (chartDescriptor == null)
            {
                chartDescriptor = SpcManager.CreateChartDescriptor(chartType);
                chartDescriptor.DataPoints = dataPoints;
                chartDescriptor.SubgroupSize = subgroupSize;

                chartDescriptor = MethodCaller.CallFactoryMethod(instance.GetType(), "GetSampleDataForSPC", spcFieldName, instance, chartType, chartDescriptor, true) as ChartPanel;

                if (!exprFieldName.Contains("_Rule"))
                {
                    ChartPanel chartPanel;
                    if (dict.TryGetValue(string.Format("{0}{1}", exprFieldName, spcFieldName), out chartPanel))
                        dict[string.Format("{0}{1}", exprFieldName, spcFieldName)] = chartDescriptor;
                    else
                        dict.Add(string.Format("{0}{1}", exprFieldName, spcFieldName), chartDescriptor);

                    instance.LoadValueByPropertyName("ChartDescriptorExp", dict);
                }
            }
            else
            {
                chartDescriptor.DataPoints = dataPoints;
                chartDescriptor.SubgroupSize = subgroupSize;

                chartDescriptor = MethodCaller.CallFactoryMethod(instance.GetType(), "GetSampleDataForSPC", spcFieldName, instance, chartType, chartDescriptor, true) as ChartPanel;
            }

            return chartDescriptor;
        }        
开发者ID:mparsin,项目名称:Elements,代码行数:43,代码来源:SpcExpressionHelperModule.cs

示例9: IsMatch

 private static bool IsMatch(IEditableRoot answer, IEnumerable<ColumnFilter> filters)
 {
     return filters.All(filter => AreEqual(answer.GetValueByPropertyName(filter.ColumnName), filter.Value));
 }
开发者ID:mparsin,项目名称:Elements,代码行数:4,代码来源:ChecklistFieldMapping.cs

示例10: SetMultiReferenceValue

        private void SetMultiReferenceValue(DetailsSaveFieldModel field, IEditableRoot editableRoot)
        {
            var currentMcrValue = (ICrossRefItemList)editableRoot.GetValueByPropertyName(field.SystemName);
            if (field.Value == null)
            {
                currentMcrValue.Clear();
                return;
            }

            var mcrContent = JsonConvert.DeserializeObject<List<MultiCrossReferenceModel>>(field.Value.ToString());
            if (mcrContent == null || mcrContent.ToArray().Length == 0)
            {
                if (currentMcrValue != null)
                {
                    currentMcrValue.Clear();
                }
                return;
            }                      

            var newItemsList =  mcrContent
                .Where(mcrItem => !currentMcrValue.Contains(mcrItem.Id))
                .Select(c => (ICrossRefItemInfo)_dynamicTypeManager.GetMultiCrossReferenceItem(editableRoot.ProcessName, field.SystemName, c.Id)).ToList();
            var deletedItems = (from ICrossRefItemInfo item in currentMcrValue where !mcrContent.Select(x=>x.Id).Contains(item.Id) select item).ToList();

            currentMcrValue.RemoveRange(deletedItems);
            currentMcrValue.AddRange(newItemsList);           
        }
开发者ID:mparsin,项目名称:Elements,代码行数:27,代码来源:DetailsCommand.cs

示例11: 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

示例12: 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");

            var sampleList = destination.GetValueByPropertyName(FieldName) as ISampleList;
            if (sampleList == null)
                return;

            sampleList.UpdateSampleList(destination);

            var sampleType = SampleUtils.GetSampleType(destination, FieldName);
            var sample = sampleList.OfType<ISampleEdit>().FirstOrDefault(s => IsEmpty(s, sampleType));
            if (sample == null)
            {
                if (SampleUtils.GetSampleSizeType(destination, FieldName) != SampleSizeTypes.Manual)
                    return;

                sample = sampleList.AddSample();
            }

            UpdateSample(sample, sampleType);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:29,代码来源:SampleFieldUpdater.cs

示例13: ExecuteUpdate

        /// <summary>
        /// Updates the items in destination field.
        /// Items are updated for each data set in the source data collection, using key fields to determine which items to update.
        /// </summary>
        /// <param name="destination">The destination item.</param>
        /// <exception cref="System.InvalidOperationException">Destination field is null.</exception>
        private void ExecuteUpdate(IEditableRoot destination)
        {
            var crList = (ICrossRefItemList)destination.GetValueByPropertyName(Property.Name);
            if (crList == null)
                throw new InvalidOperationException("Destination field is null.");

            var destinationItems = GetItems(ReferencedProcessName, crList.OfType<IDynamicObject>().Select(x => x.Id));

            foreach (var sourceItem in SourceData)
            {
                for (var i = 0; i < destinationItems.Count; ++i)
                {
                    if (!AreEqual(sourceItem, destinationItems[i]))
                        continue;

                    UpdateFieldValues(sourceItem, destinationItems[i]);

                    destinationItems[i] = (IEditableRoot)((ISavable)destinationItems[i]).Save();
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:27,代码来源:MultiCrossReferenceFieldUpdater.cs

示例14: 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

示例15: AreEqual

        /// <summary>
        /// Compares current field value with the value returned by the mapping.
        /// </summary>
        /// <param name="sourceData">The source data set.</param>
        /// <param name="destination">The destination item.</param>
        /// <returns>Returns true if field value is equal to the new value.</returns>
        public bool AreEqual(DataTriggerSourceData sourceData, IEditableRoot destination)
        {
            if (sourceData == null)
                throw new ArgumentNullException("sourceData");

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

            var oldValue = destination.GetValueByPropertyName(FieldName);
            var newValue = GetValue(sourceData, destination, DefaultCultureName);

            return oldValue != null ? oldValue.Equals(SafeTypeConverter.Convert(newValue, oldValue.GetType())) : newValue == null;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:19,代码来源:SimpleFieldUpdater.cs


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