本文整理汇总了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);
}
}
示例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;
}