本文整理汇总了C#中IOrganizationService.Update方法的典型用法代码示例。如果您正苦于以下问题:C# IOrganizationService.Update方法的具体用法?C# IOrganizationService.Update怎么用?C# IOrganizationService.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrganizationService
的用法示例。
在下文中一共展示了IOrganizationService.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: UpdateCharts
private void UpdateCharts(IOrganizationService service, AttributeMetadata att)
{
foreach (var chart in GetSystemChartsWithAttribute(service, att))
{
Trace("Updating Chart " + chart.Name);
chart.DataDescription = RemoveFieldFromFetchXml(chart.DataDescription, att.LogicalName);
service.Update(chart);
}
foreach (var chart in GetUserChartsWithAttribute(service, att))
{
Trace("Updating Chart " + chart.Name);
chart.DataDescription = RemoveFieldFromFetchXml(chart.DataDescription, att.LogicalName);
service.Update(chart);
}
}
示例3: UpdateForms
private void UpdateForms(IOrganizationService service, AttributeMetadata att)
{
/*
* <row>
* <cell id="{056d159e-9144-d809-378b-9e04a7626953}" showlabel="true" locklevel="0">
* <labels>
* <label description="Points" languagecode="1033" />
* </labels>
* <control id="new_points" classid="{4273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="new_points" disabled="true" />
* </cell>
* </row>
*/
foreach (var form in GetFormsWithAttribute(service, att))
{
Trace("Updating Form " + form.Name);
var xml = form.FormXml;
var dataFieldStart = "datafieldname=\"" + att.LogicalName + "\"";
var index = xml.IndexOf(dataFieldStart, StringComparison.OrdinalIgnoreCase);
while (index >= 0)
{
index = xml.LastIndexOf("<cell ", index, StringComparison.OrdinalIgnoreCase);
var cellEnd = xml.IndexOf("</cell>", index, StringComparison.OrdinalIgnoreCase) + "</cell>".Length;
xml = xml.Remove(index, cellEnd - index);
index = xml.IndexOf(dataFieldStart, index, StringComparison.OrdinalIgnoreCase);
}
form.FormXml = xml;
service.Update(form);
}
}
示例4: accUpdate
public void accUpdate(Microsoft.Crm.Sdk.Samples.ServerConnection.Configuration serverconfig, ArrayList data)
{
try
{
using (_serviceProxy = Microsoft.Crm.Sdk.Samples.ServerConnection.GetOrganizationProxy(serverconfig))
{
String a_id = (String)data[0];
Guid _accountId = new Guid(a_id);
_serviceProxy.EnableProxyTypes();
_service = (IOrganizationService)_serviceProxy;
Account accountToUpdate = new Account
{
Name = (String)data[1],
EMailAddress1= (String)data[2],
Address1_City= (String)data[3],
Address1_Country= (String)data[4],
Address1_Latitude= Convert.ToDouble(data[5]),
Address1_Longitude= Convert.ToDouble(data[6]),
AccountId = _accountId
};
_service.Update(accountToUpdate);
}
}
catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
{
throw;
}
}
示例5: UpdateViews
private void UpdateViews(IOrganizationService service, AttributeMetadata att)
{
foreach (var query in GetViewsWithAttribute(service, att))
{
Trace("Updating View " + query.Name);
query.FetchXml = RemoveFieldFromFetchXml(query.FetchXml, att.LogicalName);
if (query.LayoutXml != null)
{
query.LayoutXml = RemoveFieldFromFetchXml(query.LayoutXml, att.LogicalName);
}
service.Update(query);
}
}
示例6: PurchaseCropUpdateMethod
private void PurchaseCropUpdateMethod(new_aprove_price _proxyentity, List<new_port> _portList, OrganizationServiceContext orgContext, IOrganizationService service)
{
List<Guid> _cropListForUpdate = (from i in orgContext.CreateQuery<new_purchase_crop>()
where i.new_crop.Id == _proxyentity.new_cropid.Id &&
i.new_offer_status == new OptionSetValue(100000000)
select i.Id).ToList();
foreach ( var item in _cropListForUpdate )
{
new_purchase_crop _updateCrop = new new_purchase_crop();
_updateCrop.Id = item;
_updateCrop.new_recom_price_mykolaiv = _proxyentity.new_recom_purchase_price_nikolaev;
_updateCrop.new_recom_price_odesa = _proxyentity.new_recom_purchase_price_odessa;
service.Update(_updateCrop);
}
}
示例7: Update
public void Update(IOrganizationService service, List<Entity> profiles)
{
foreach (var profile in profiles)
{
var field = Fields.FirstOrDefault(
f => f.GetAttributeValue<EntityReference>("fieldsecurityprofileid").Id == profile.Id);
if (field == null)
{
field = new Entity("fieldpermission");
field["fieldsecurityprofileid"] = profile.ToEntityReference();
field["canread"] = new OptionSetValue(0);
field["cancreate"] = new OptionSetValue(0);
field["canupdate"] = new OptionSetValue(0);
field["entityname"] = Entity;
field["attributelogicalname"] = Attribute;
}
if (CanRead.HasValue)
{
field["canread"] = new OptionSetValue(CanRead.Value ? 4 : 0);
}
if (CanCreate.HasValue)
{
field["cancreate"] = new OptionSetValue(CanCreate.Value ? 4 : 0);
}
if (CanUpdate.HasValue)
{
field["canupdate"] = new OptionSetValue(CanUpdate.Value ? 4 : 0);
}
if (field.Id == Guid.Empty)
{
field.Id = service.Create(field);
Fields.Add(field);
}
else
{
service.Update(field);
}
}
}
示例8: ReplaceContent
private void ReplaceContent(Entity entity, string proxyPath, IOrganizationService service)
{
try
{
var url = proxyPath.Substring(6).Split('\n')[0].TrimEnd();
var request = (HttpWebRequest)WebRequest.Create(url);
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
using (var stream = response.GetResponseStream())
using (var memoryStream = new MemoryStream())
{
stream.CopyTo(memoryStream);
entity["content"] = Convert.ToBase64String(memoryStream.ToArray());
service.Update(new Entity("webresource") { Id = entity.Id });
}
}
}
catch { }
}
示例9: AnswerNpsSurvey
public static MsCrmResult AnswerNpsSurvey(Guid npsSurveyId, int suggest, int suggestPoint, IOrganizationService service)
{
MsCrmResult returnValue = new MsCrmResult();
try
{
Entity ent = new Entity("new_npssurvey");
ent.Id = npsSurveyId;
ent["new_issuggest"] = new OptionSetValue(suggest);
ent["new_suggestpoint"] = suggestPoint;
ent["statuscode"] = new OptionSetValue((int)NpsSurveyStatus.Answered);
service.Update(ent);
returnValue.Success = true;
returnValue.Result = "Nps Survey güncellendi.";
}
catch (Exception ex)
{
returnValue.HasException = true;
returnValue.Result = ex.Message;
}
return returnValue;
}
示例10: UpdateForms
private void UpdateForms(IOrganizationService service, AttributeMetadata from, AttributeMetadata to)
{
Trace("Retrieving Forms");
var forms = service.GetEntities<SystemForm>(
"objecttypecode", from.EntityLogicalName,
new ConditionExpression("formxml", ConditionOperator.Like, "%<control id=\"" + from.LogicalName + "\"%"));
foreach (var form in forms)
{
Trace("Updating Form " + form.Name);
form.FormXml = form.FormXml.Replace("<control id=\"" + from.LogicalName + "\"", "<control id=\"" + to.LogicalName + "\"").
Replace("datafieldname=\"" + from.LogicalName + "\"", "datafieldname=\"" + to.LogicalName + "\"");
service.Update(form);
}
}
示例11: UpdateCharts
private void UpdateCharts(IOrganizationService service, AttributeMetadata from, AttributeMetadata to)
{
var fromValue = "name=\"" + from.LogicalName + "\"";
var toValue = "name=\"" + to.LogicalName + "\"";
var entityAttributeLikeExpression = $"%<entity name=\"{@from.EntityLogicalName}\">%{fromValue}%";
Trace("Retrieving System Charts with cond: " + fromValue);
var systemCharts = service.GetEntities<SavedQueryVisualization>(c => new { c.Id, c.DataDescription },
new ConditionExpression(SavedQueryVisualization.Fields.DataDescription, ConditionOperator.Like, entityAttributeLikeExpression));
foreach (var chart in systemCharts)
{
Trace("Updating Chart " + chart.Name);
chart.DataDescription = chart.DataDescription.Replace(fromValue, toValue);
service.Update(chart);
}
Trace("Retrieving User Charts with cond: " + fromValue);
var userCharts = service.GetEntities<UserQueryVisualization>(c => new { c.Id, c.DataDescription },
new ConditionExpression(UserQueryVisualization.Fields.DataDescription, ConditionOperator.Like, entityAttributeLikeExpression));
foreach (var chart in userCharts)
{
Trace("Updating Chart " + chart.Name);
chart.DataDescription = chart.DataDescription.Replace(fromValue, toValue);
service.Update(chart);
}
}
示例12: CreateOrUpdateProfile
public static MsCrmResult CreateOrUpdateProfile(Contact contact, IOrganizationService service)
{
MsCrmResult returnValue = new MsCrmResult();
try
{
Entity ent = new Entity("contact");
if (!string.IsNullOrEmpty(contact.MobilePhone))
{
ent["mobilephone"] = contact.MobilePhone;
}
if (!string.IsNullOrEmpty(contact.WorkPhone))
{
ent["telephone1"] = contact.WorkPhone;
}
if (!string.IsNullOrEmpty(contact.IdentityNumber))
{
ent["new_identitynumber"] = contact.IdentityNumber;
}
if (contact.Gender != null)
{
ent["gendercode"] = new OptionSetValue((int)contact.Gender);
}
if (contact.BirthDate != null)
{
ent["birthdate"] = contact.BirthDate;
}
if (!string.IsNullOrEmpty(contact.Description))
{
ent["description"] = contact.Description;
}
if (!string.IsNullOrEmpty(contact.EmailAddress))
{
ent["emailaddress1"] = contact.EmailAddress;
}
if (!string.IsNullOrEmpty(contact.FirstName))
{
ent["firstname"] = contact.FirstName;
}
if (!string.IsNullOrEmpty(contact.LastName))
{
ent["lastname"] = contact.LastName;
}
if (!string.IsNullOrEmpty(contact.Title))
{
ent["jobtitle"] = contact.Title;
}
if (!string.IsNullOrEmpty(contact.FunctionName))
{
ent["new_functionname"] = contact.FunctionName;
}
if (contact.ParentAccount != null)
{
ent["parentaccountid"] = contact.ParentAccount;
}
if (contact.CityId != null)
{
ent["new_cityid"] = contact.CityId;
}
if (contact.TownId != null)
{
ent["new_townid"] = contact.TownId;
}
if (!string.IsNullOrEmpty(contact.AddressDetail))
{
ent["new_addressdetail"] = contact.AddressDetail;
}
if (contact.MarkContact != null)
{
ent["new_markcontact"] = contact.MarkContact;
}
if (contact.ContactId != Guid.Empty)
{
ent["contactid"] = contact.ContactId;
service.Update(ent);
returnValue.Success = true;
returnValue.Result = "M009"; //"Profil güncellendi.";
}
else
{
returnValue.CrmId = service.Create(ent);
returnValue.Success = true;
returnValue.Result = "M010"; //"Profil oluşturuldu.";
}
//.........这里部分代码省略.........
示例13: UpdateAssemblyRequest
public static MsCrmResult UpdateAssemblyRequest(AssemblyRequestInfo requestInfo, IOrganizationService service)
{
MsCrmResult returnValue = new MsCrmResult();
try
{
Entity ent = requestInfo.ToCrmEntity();
service.Update(ent);
returnValue.Success = true;
returnValue.Result = "Talep güncellendi.";
}
catch (Exception ex)
{
returnValue.HasException = true;
returnValue.Result = ex.Message;
}
return returnValue;
}
示例14: PurchaseTaskUpdateMethod
private void PurchaseTaskUpdateMethod(new_aprove_price _proxyentity, List<new_port> _portList, OrganizationServiceContext orgContext, IOrganizationService service)
{
List<new_purchase_task> _taskListForUpdate = (from i in orgContext.CreateQuery<new_purchase_task>()
where i.new_product.Id == _proxyentity.new_cropid.Id &&
i.new_status == new OptionSetValue(100000000)
select i).ToList();
foreach ( var item in _taskListForUpdate )
{
new_purchase_task _updateTask = new new_purchase_task();
_updateTask.Id = item.Id;
if ( item.new_port == null )
continue;
if ( _portList.Where(x => x.Id == item.new_port.Id).FirstOrDefault().new_name == "Одеса" )
{
_updateTask.new_aprove_purchase_price = _proxyentity.new_recom_purchase_price_odessa;
}
else if ( _portList.Where(x => x.Id == item.new_port.Id).FirstOrDefault().new_name == "Миколаїв" )
{
_updateTask.new_aprove_purchase_price = _proxyentity.new_recom_purchase_price_nikolaev;
}
service.Update(_updateTask);
}
}
示例15: SaveOrUpdateGraffiti
public static MsCrmResult SaveOrUpdateGraffiti(Graffiti graffiti, IOrganizationService service)
{
MsCrmResult returnValue = new MsCrmResult();
try
{
Entity ent = new Entity("new_graffiti");
ent["new_name"] = graffiti.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm");
ent["new_hasmedia"] = graffiti.HasMedia;
if (graffiti.PortalUser != null)
{
ent["new_userid"] = graffiti.PortalUser;
}
if (graffiti.Portal != null)
{
ent["new_portalid"] = graffiti.Portal;
}
if (!string.IsNullOrEmpty(graffiti.Description))
{
ent["new_content"] = graffiti.Description;
}
if (!string.IsNullOrEmpty(graffiti.ImagePath))
{
ent["new_imageurl"] = graffiti.ImagePath;
}
if (graffiti.GraffitiId != Guid.Empty)
{
ent["new_graffitiid"] = graffiti.GraffitiId;
service.Update(ent);
returnValue.Success = true;
returnValue.Result = "M014"; //"Duvar yazısı güncellendi.";
}
else
{
returnValue.CrmId = service.Create(ent);
returnValue.Success = true;
returnValue.Result = "M015"; //"Duvar yazısı oluşturuldu.";
}
}
catch (Exception ex)
{
returnValue.Result = ex.Message;
returnValue.Success = false;
}
return returnValue;
}