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


C# IData.GetUniqueKey方法代码示例

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


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

示例1: HandlePublishUnpublishWorkflows

        public static void HandlePublishUnpublishWorkflows(IData selectedData, string cultureName, DateTime? publishDate, DateTime? unpublishDate, ref WorkflowInstance publishWorkflowInstance, ref WorkflowInstance unpublishWorkflowInstance)
        {
            var key = selectedData.GetUniqueKey().ToString();

            var existingPublishSchedule = PublishScheduleHelper.GetPublishSchedule(selectedData.DataSourceId.InterfaceType, key, cultureName);
            if (existingPublishSchedule != null)
            {
                WorkflowFacade.AbortWorkflow(existingPublishSchedule.WorkflowInstanceId);

                DataFacade.Delete(existingPublishSchedule);
            }

            if (publishDate != null)
            {
                publishWorkflowInstance = WorkflowFacade.CreateNewWorkflow(
                        typeof(DataPublishSchedulerWorkflow),
                        new Dictionary<string, object> 
                        { 
                            { "Date", publishDate },
                            { "DataType", selectedData.DataSourceId.InterfaceType.FullName },
                            { "DataId", selectedData.GetUniqueKey().ToString() },
                            { "LocaleName", cultureName }
                        }
                    );

                PublishScheduleHelper.CreatePublishSchedule(selectedData.DataSourceId.InterfaceType, selectedData.GetUniqueKey().ToString(), cultureName, publishDate.Value, publishWorkflowInstance);
            }

            var existingUnpublishSchedule = PublishScheduleHelper.GetUnpublishSchedule(selectedData.DataSourceId.InterfaceType, key, cultureName);
            if (existingUnpublishSchedule != null)
            {
                WorkflowFacade.AbortWorkflow(existingUnpublishSchedule.WorkflowInstanceId);

                DataFacade.Delete(existingUnpublishSchedule);
            }

            if (unpublishDate != null)
            {
                unpublishWorkflowInstance = WorkflowFacade.CreateNewWorkflow(
                        typeof(DataUnpublishSchedulerWorkflow),
                        new Dictionary<string, object> 
                        { 
                            { "Date", unpublishDate },
                            { "DataType", selectedData.DataSourceId.InterfaceType.FullName },
                            { "DataId", key },
                            { "LocaleName", cultureName }
                        }
                    );

                PublishScheduleHelper.CreateUnpublishSchedule(selectedData.DataSourceId.InterfaceType, key, cultureName, unpublishDate.Value, unpublishWorkflowInstance);
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:52,代码来源:PublishControlledHelper.cs

示例2: GetBindings

        /// <exclude />
        public Dictionary<string, object> GetBindings(IData dataObject, bool allowMandatoryNonDefaultingProperties)
        {
            if (dataObject == null) throw new ArgumentNullException("dataObject");

            var bindings = new Dictionary<string, object>();

            foreach (var fieldDescriptor in _dataTypeDescriptor.Fields)
            {
                var propertyInfo = dataObject.GetType().GetProperty(fieldDescriptor.Name);

                if (propertyInfo.CanRead)
                {
                    var value = propertyInfo.GetGetMethod().Invoke(dataObject, null);

                    if (value == null && !fieldDescriptor.IsNullable)
                    {
                        if (fieldDescriptor.IsNullable)
                        {
                            // Ignore, null is allowed
                        }
                        else if (fieldDescriptor.InstanceType.IsGenericType
                                 && fieldDescriptor.InstanceType.GetGenericTypeDefinition() == typeof(Nullable<>))
                        {
                            // Ignore, null is allowed
                        }
                        else if (allowMandatoryNonDefaultingProperties)
                        {
                            if (propertyInfo.PropertyType == typeof(string) && fieldDescriptor.ForeignKeyReferenceTypeName == null) //FK fields stay NULL
                            {
                                value = "";
                            }
                            else
                            {
                                value = GetDefaultValue(propertyInfo.PropertyType);
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException(string.Format("Field '{0}' on type '{1}' is null, does not allow null and does not have a default value", fieldDescriptor.Name, _dataTypeDescriptor.TypeManagerTypeName));
                        }
                    }

                    bindings.Add(GetBindingName(fieldDescriptor), value);
                }
            }

            if (_showPublicationStatusSelector &&
                _dataTypeDescriptor.SuperInterfaces.Contains(typeof(IPublishControlled)))
            {
                bindings[PublicationStatusBindingName] = ((IPublishControlled)dataObject).PublicationStatus;
                bindings.Add(PublicationStatusOptionsBindingName, GetAvailablePublishingFlowTransitions(EntityToken));

                var interfaceType = dataObject.DataSourceId.InterfaceType;
                var stringKey = dataObject.GetUniqueKey().ToString();
                var locale = dataObject.DataSourceId.LocaleScope.Name;

                var existingPublishSchedule = PublishScheduleHelper.GetPublishSchedule(interfaceType, stringKey, locale);
                bindings.Add("PublishDate", existingPublishSchedule?.PublishDate);

                var existingUnpublishSchedule = PublishScheduleHelper.GetUnpublishSchedule(interfaceType, stringKey, locale);
                bindings.Add("UnpublishDate", existingUnpublishSchedule?.UnpublishDate);
            }

            return bindings;
        }
开发者ID:Orckestra,项目名称:C1-CMS,代码行数:66,代码来源:DataTypeDescriptorFormsHelper.cs


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