本文整理汇总了C#中System.Entity.GetAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetAttributeValue方法的具体用法?C# Entity.GetAttributeValue怎么用?C# Entity.GetAttributeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.GetAttributeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CrmForm
public CrmForm(Entity form)
{
var emd = entitiesMetadatas.ToList().First(e => e.LogicalName == form.GetAttributeValue<string>("objecttypecode"));
this.form = form;
Name = form.GetAttributeValue<string>("name");
EntityLogicalName = form.GetAttributeValue<string>("objecttypecode");
EntityDisplayName = emd.DisplayName != null ? emd.DisplayName.UserLocalizedLabel.Label : "N/A";
Id = form.Id;
ListParameters();
}
示例2: UpdateRank
public static int UpdateRank(IOrganizationService service, Entity workflow)
{
var wf = service.Retrieve("workflow", workflow.Id, new ColumnSet("statecode"));
if (wf.GetAttributeValue<OptionSetValue>("statecode").Value != 0)
{
service.Execute(new SetStateRequest
{
EntityMoniker = wf.ToEntityReference(),
State = new OptionSetValue(0),
Status = new OptionSetValue(-1)
});
}
workflow.Attributes.Remove("statecode");
workflow.Attributes.Remove("statuscode");
service.Update(workflow);
if (wf.GetAttributeValue<OptionSetValue>("statecode").Value != 0)
{
service.Execute(new SetStateRequest
{
EntityMoniker = wf.ToEntityReference(),
State = new OptionSetValue(1),
Status = new OptionSetValue(-1)
});
}
return workflow.GetAttributeValue<int>("rank");
}
示例3: GetAliasedValue
internal object GetAliasedValue(Entity entry, string attributeName)
{
if (!entry.Attributes.Contains(attributeName)) return null;
var aliasedValue = entry.GetAttributeValue<AliasedValue>(attributeName);
if (aliasedValue == null) return null;
var entityReferenceValue = aliasedValue.Value as EntityReference;
return entityReferenceValue != null ? entityReferenceValue.Id : aliasedValue.Value;
}
示例4: FormInfo
public FormInfo(Entity form)
{
if (form.LogicalName != "systemform")
{
throw new ArgumentException("Only systemform entity can be used in FormInfo", "form");
}
this.form = form;
formXml = new XmlDocument();
formXml.LoadXml(form.GetAttributeValue<string>("formxml"));
}
示例5: SynchronousWorkflow
public SynchronousWorkflow(Entity workflow)
{
this.workflow = workflow;
initialRank = Rank;
// Stage
if (workflow.GetAttributeValue<bool>("triggeroncreate"))
{
var stageCode = workflow.GetAttributeValue<OptionSetValue>("createstage");
Stage = stageCode != null ? stageCode.Value : 40;
Message = "Create";
}
else if (workflow.GetAttributeValue<bool>("triggeronupdate"))
{
var stageCode = workflow.GetAttributeValue<OptionSetValue>("updatestage");
Stage = stageCode != null ? stageCode.Value : 40;
Message = "Update";
}
else if (workflow.GetAttributeValue<bool>("triggerondelete"))
{
var stageCode = workflow.GetAttributeValue<OptionSetValue>("deletestage");
Stage = stageCode != null ? stageCode.Value : 20;
Message = "Delete";
}
else
{
// throw new Exception("Unexpected stage data");
}
}
示例6: UpdateFormEventHanders
public void UpdateFormEventHanders(Entity form, string eventName, List<FormEvent> formEvents)
{
WorkAsync(new WorkAsyncInfo
{
Message = "Updating Form " + form.GetAttributeValue<string>("name") + "...",
Work = (bw, e) =>
{
try
{
var manager = new FormManager(Service);
manager.UpdateFormEventHandlers(form, eventName, formEvents);
bw.ReportProgress(0, string.Format("Publishing entity '{0}'...", form.GetAttributeValue<string>("objecttypecode")));
new FormManager(Service).PublishEntity(form.GetAttributeValue<string>("objecttypecode"));
ListViewDelegates.AddItem(lvLogs,
new ListViewItem
{
Text = form.GetAttributeValue<string>("objecttypecode"),
SubItems =
{
new ListViewItem.ListViewSubItem {Text = form.GetAttributeValue<string>("name")},
new ListViewItem.ListViewSubItem {Text = eventName},
new ListViewItem.ListViewSubItem {Text = "Updated!"}
},
ForeColor = Color.Green
});
}
catch (Exception error)
{
ListViewDelegates.AddItem(lvLogs,
new ListViewItem
{
Text = form.GetAttributeValue<string>("objecttypecode"),
SubItems =
{
new ListViewItem.ListViewSubItem {Text = form.GetAttributeValue<string>("name")},
new ListViewItem.ListViewSubItem {Text = eventName},
new ListViewItem.ListViewSubItem {Text = error.Message}
},
ForeColor = Color.Red
});
}
},
PostWorkCallBack = e =>
{
if (e.Error != null)
{
MessageBox.Show(ParentForm, "An error occured:" + e.Error.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
},
ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
});
}
示例7: AddLibrary
public void AddLibrary(Entity form, string libraryName, bool addFirst)
{
// Read the form xml content
var formXml = form.GetAttributeValue<string>("formxml");
var formDoc = new XmlDocument();
formDoc.LoadXml(formXml);
var formNode = formDoc.SelectSingleNode("form");
if (formNode == null)
{
throw new Exception("Expected node \"formNode\" was not found");
}
var formLibrariesNode = formNode.SelectSingleNode("formLibraries");
if (formLibrariesNode == null)
{
formLibrariesNode = formDoc.CreateElement("formLibraries");
formNode.AppendChild(formLibrariesNode);
}
// Search for existing library
var libraryNode = formLibrariesNode.SelectSingleNode(string.Format("Library[@name='{0}']", libraryName));
if (libraryNode != null)
{
throw new Exception("This library is already included in this form");
}
// Create the new library node
var nameAttribute = formDoc.CreateAttribute("name");
var libraryUniqueIdAttribute = formDoc.CreateAttribute("libraryUniqueId");
nameAttribute.Value = libraryName;
libraryUniqueIdAttribute.Value = Guid.NewGuid().ToString("B");
libraryNode = formDoc.CreateElement("Library");
if (libraryNode.Attributes != null)
{
libraryNode.Attributes.Append(nameAttribute);
libraryNode.Attributes.Append(libraryUniqueIdAttribute);
}
if (formLibrariesNode.ChildNodes.Count > 0 && addFirst)
{
formLibrariesNode.InsertBefore(libraryNode, formLibrariesNode.FirstChild);
}
else
{
formLibrariesNode.AppendChild(libraryNode);
}
// Update the form xml content
form["formxml"] = formDoc.OuterXml;
}
示例8: PluginStep
public PluginStep(Entity pluginStep, IEnumerable<Entity> sdkMessageFilers, IEnumerable<Entity> sdkMessages)
{
this.pluginStep = pluginStep;
initialRank = Rank;
// EntityLogicalName
var messageFilter = sdkMessageFilers.FirstOrDefault(
s => pluginStep.GetAttributeValue<EntityReference>("sdkmessagefilterid") != null &&
s.Id == pluginStep.GetAttributeValue<EntityReference>("sdkmessagefilterid").Id);
if (messageFilter != null)
{
EntityLogicalName = messageFilter.GetAttributeValue<string>("primaryobjecttypecode");
if (EntityLogicalName.Length == 0)
{
EntityLogicalName = "None";
}
var message = sdkMessages.FirstOrDefault(
m => m.Id == messageFilter.GetAttributeValue<EntityReference>("sdkmessageid").Id);
if (message != null)
{
Message = message.GetAttributeValue<string>("name");
}
}
else
{
EntityLogicalName = "(none)";
var message = sdkMessages.FirstOrDefault(
m => m.Id == pluginStep.GetAttributeValue<EntityReference>("sdkmessageid").Id);
if (message != null)
{
Message = message.GetAttributeValue<string>("name");
}
}
}
示例9: IdentityUser
public IdentityUser(Entity entity)
{
if (entity == null) throw new ArgumentNullException("entity");
Entity = entity;
KeyProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserKey);
UserNameProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserName) ?? ProjectUtilities.FindNameProperty(entity);
NormalizedUserNameProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserNormalizedName) ?? UserNameProperty;
CreationDateProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserCreationDate);
EmailProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserEmail);
EmailConfirmedProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserEmailConfirmed);
PhoneNumberProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserPhoneNumber);
PhoneNumberConfirmedProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserPhoneNumberConfirmed);
PasswordProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserPassword);
LastPasswordChangeDateProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserLastPasswordChangeDate);
FailedPasswordAttemptCountProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserFailedPasswordAttemptCount);
FailedPasswordAttemptWindowStartProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserFailedPasswordAttemptWindowStart);
LockoutEnabledProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserLockoutEnabled);
LockoutEndDateProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserLockoutEndDate);
LastProfileUpdateDateProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserLastProfileUpdateDate);
TwoFactorEnabledProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserTwoFactorEnabled);
SecurityStampProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserSecurityStamp);
RolesProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserRoles);
ClaimsProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserClaims);
LoginsProperty = ProjectUtilities.FindByPropertyType(Entity, PropertyType.UserLogins);
LoadByKeyMethod = ProjectUtilities.FindByMethodType(Entity, MethodType.LoadUserByKey);
if (LoadByKeyMethod != null)
{
LoadByKeyMethodName = LoadByKeyMethod.Name;
}
else if (KeyProperty != null && Entity.LoadByKeyMethod != null)
{
LoadByKeyMethod = Entity.LoadByKeyMethod;
LoadByKeyMethodName = Entity.LoadByKeyMethod.Name;
}
else
{
LoadByKeyMethodName = "LoadByEntityKey";
}
LoadByUserNameMethod = ProjectUtilities.FindByMethodType(Entity, MethodType.LoadUserByUserName) ?? Entity.LoadByCollectionKeyMethod;
LoadByEmailMethod = ProjectUtilities.FindByMethodType(Entity, MethodType.LoadUserByEmail) ?? Entity.Methods.Find("LoadByEmail", StringComparison.OrdinalIgnoreCase) ?? (EmailProperty != null && EmailProperty.IsCollectionKey ? Entity.LoadByCollectionKeyMethod : null);
LoadByUserLoginInfoMethod = ProjectUtilities.FindByMethodType(Entity, MethodType.LoadUserByUserLoginInfo);
LoadAllMethod = ProjectUtilities.FindByMethodType(Entity, MethodType.LoadAllUsers) ?? Entity.LoadAllMethod;
DeleteMethodName = ProjectUtilities.FindByMethodType(Entity, MethodType.DeleteUser)?.Name ?? Entity.GetAttributeValue("deleteMethodName", Constants.NamespaceUri, (string)null) ?? "Delete";
}
示例10: GetFormLibraries
public static XmlNode GetFormLibraries(Entity form)
{
var formXml = form.GetAttributeValue<string>("formxml");
var formDoc = new XmlDocument();
formDoc.LoadXml(formXml);
var formNode = formDoc.SelectSingleNode("form");
if (formNode == null)
{
throw new Exception("Expected node \"formNode\" was not found");
}
var formLibrariesNode = formNode.SelectSingleNode("formLibraries");
if (formLibrariesNode == null)
{
formLibrariesNode = formDoc.CreateElement("formLibraries");
formNode.AppendChild(formLibrariesNode);
}
return formLibrariesNode;
}
示例11: Execute
public decimal Execute(Entity autoNumber)
{
// Need to handle shared numbers and we're almost done!!!
var internalAutoNumber = new Entity("smp_autonumber") {Id = autoNumber.Id};
internalAutoNumber["name"] = autoNumber["name"];
_organizationService.Update(internalAutoNumber);
// Once here we have a transaction open. Get the autonumber again in case the number has moved
var queryByAttribute = new QueryByAttribute("smp_autonumber");
queryByAttribute.AddAttributeValue("smp_name", autoNumber["name"]);
queryByAttribute.ColumnSet = new ColumnSet("smp_name", "smp_nextnumber");
internalAutoNumber = _organizationService.RetrieveMultiple(queryByAttribute).Entities[0];
decimal number = internalAutoNumber.GetAttributeValue<decimal>("smp_nextnumber");
// Update the new number
internalAutoNumber["smp_nextnumber"] = number + 1;
_organizationService.Update(internalAutoNumber);
return number;
}
示例12: LoadWebResourcesGeneral
public void LoadWebResourcesGeneral(Entity specificSolution)
{
wrManager = new WebResourceManager(Service);
tvWebResources.Nodes.Clear();
var dialog = new WebResourceTypeSelectorDialog();
if (dialog.ShowDialog(ParentForm) == DialogResult.OK)
{
var settings = new LoadCrmResourcesSettings
{
SolutionId = specificSolution != null ? specificSolution.Id : Guid.Empty,
SolutionName = specificSolution != null ?specificSolution.GetAttributeValue<string>("friendlyname") : "",
SolutionVersion = specificSolution != null ?specificSolution.GetAttributeValue<string>("version") : "",
Types = dialog.TypesToLoad
};
SetWorkingState(true);
tvWebResources.Nodes.Clear();
WorkAsync("Loading web resources...",
e =>
{
Guid solutionId = e.Argument != null ? ((LoadCrmResourcesSettings)e.Argument).SolutionId : Guid.Empty;
RetrieveWebResources(solutionId, ((LoadCrmResourcesSettings)e.Argument).Types);
e.Result = e.Argument;
},
e =>
{
if (e.Error != null)
{
string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, true);
MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
tvWebResources.Enabled = true;
var currentSettings = (LoadCrmResourcesSettings)e.Result;
tssCurrentlyLoadedSolution.Visible = currentSettings.SolutionId != Guid.Empty;
tslCurrentlyLoadedSolution.Visible = currentSettings.SolutionId != Guid.Empty;
tslCurrentlyLoadedSolution.Text = string.Format("Solution loaded: {0} - v{1}", currentSettings.SolutionName, currentSettings.SolutionVersion);
}
tvWebResources.ExpandAll();
tvWebResources.TreeViewNodeSorter = new NodeSorter();
tvWebResources.Sort();
TvWebResourcesAfterSelect(null, null);
tsbClear.Visible = true;
SetWorkingState(false);
},
settings);
}
}
示例13: GetParameterValue
public string GetParameterValue(Entity Target)
{
if (Target.Contains(AttributeName))
{
if (Target[AttributeName] is EntityReference)
{
// Lookup condition is based on GUID
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<EntityReference>(AttributeName).Id) : Target.GetAttributeValue<EntityReference>(AttributeName).Name;
}
else if (Target[AttributeName] is OptionSetValue)
{
// Conditional OptionSetValue is based on the integer value
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<OptionSetValue>(AttributeName).Value.ToString()) : Target.FormattedValues[AttributeName];
}
else if (Target[AttributeName] is bool)
{
// Note: Boolean values ignore the match value, they just use the attribute value itself as the condition
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<bool>(AttributeName)) : Target.FormattedValues[AttributeName];
}
else if (Target[AttributeName] is DateTime)
{
// If there is a format AND a condition, apply formatting first, then evaluate condition as a string
// If there is a condition without any format, evaluate condition as DateTime
return String.IsNullOrEmpty(StringFormatter) ? Conditional.GetResult(Target.GetAttributeValue<DateTime>(AttributeName)) : Conditional.GetResult(Target.GetAttributeValue<DateTime>(AttributeName).ToString(StringFormatter));
}
else if (Target[AttributeName] is Money)
{
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<Money>(AttributeName).Value) : Target.GetAttributeValue<Money>(AttributeName).Value.ToString(StringFormatter);
}
else if (Target[AttributeName] is int)
{
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<double>(AttributeName)) : Target.GetAttributeValue<double>(AttributeName).ToString(StringFormatter);
}
else if (Target[AttributeName] is decimal)
{
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<decimal>(AttributeName)) : Target.GetAttributeValue<decimal>(AttributeName).ToString(StringFormatter);
}
else if (Target[AttributeName] is double)
{
return Conditional.HasCondition ? Conditional.GetResult(Target.GetAttributeValue<double>(AttributeName)) : Target.GetAttributeValue<double>(AttributeName).ToString(StringFormatter);
}
else if (Target[AttributeName] is string)
{
return Conditional.GetResult(Target[AttributeName].ToString());
}
}
else if (AttributeName.Equals("rand"))
{
string length = "";
string stringStyle = "upper";
int stringLength = 5; // Seems like reasonable default
if (StringFormatter.Contains('?'))
{
length = StringFormatter.Split('?')[0];
stringStyle = StringFormatter.Split('?')[1].ToLower();
}
else
{
length = StringFormatter;
}
if (!Int32.TryParse(length, out stringLength))
{
stringLength = 5;
}
string stringValues = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (stringStyle == "mix")
{
stringValues = stringValues + stringValues.ToLower();
}
else if (stringStyle == "lower")
{
stringValues = stringValues.ToLower();
}
Random rnd = new Random();
return String.Join("", Enumerable.Range(0, stringLength).Select(n => stringValues[rnd.Next(stringValues.Length)]));
}
return DefaultValue;
}
示例14: RemoveLibrary
public bool RemoveLibrary(Entity form, string libraryName, Form parentForm)
{
// Read the form xml content
var formXml = form.GetAttributeValue<string>("formxml");
var formDoc = new XmlDocument();
formDoc.LoadXml(formXml);
var formNode = formDoc.SelectSingleNode("form");
if (formNode == null)
{
throw new Exception("Expected node \"formNode\" was not found");
}
// Retrieve events that use the library
var eventNodes = formNode.SelectNodes(string.Format("events/event/Handlers/Handler[@libraryName='{0}']", libraryName));
if (eventNodes != null && eventNodes.Count > 0)
{
var result =
MessageBox.Show(parentForm,
string.Format(
"The library '{2}' is used by {0} event{1}. If you remove the library, {0} event{1} will be removed too\r\n\r\nDo you want to continue?",
eventNodes.Count, eventNodes.Count > 1 ? "s" : "", libraryName), "Question", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.No)
{
return false;
}
}
var formLibrariesNode = formNode.SelectSingleNode("formLibraries");
if (formLibrariesNode == null)
{
throw new Exception("Expected node \"formLibraries\" was not found");
}
// Search for existing library
var libraryNode = formLibrariesNode.SelectSingleNode(string.Format("Library[@name='{0}']", libraryName));
if (libraryNode == null)
{
throw new Exception("This library is noy included in this form");
}
// Remove library
formLibrariesNode.RemoveChild(libraryNode);
if (formLibrariesNode.ChildNodes.Count == 0)
{
formLibrariesNode.ParentNode.RemoveChild(formLibrariesNode);
}
// Remove events that was using the library
foreach (XmlNode eventNode in eventNodes)
{
if (eventNode.ParentNode.ChildNodes.Count == 1)
{
formNode.SelectSingleNode("events").RemoveChild(eventNode.ParentNode.ParentNode);
}
else
{
eventNode.ParentNode.RemoveChild(eventNode);
}
}
// Update the form xml content
form["formxml"] = formDoc.OuterXml;
return true;
}
示例15: RemoveFormatting
private void RemoveFormatting(Entity entity, string attribute)
{
var number = entity.GetAttributeValue<string>(attribute);
if (number == null)
{
return;
}
entity[attribute] = new String(number.Where(char.IsNumber).ToArray());
}