private static void SetName(Entity e, PrimaryFieldInfo info, Func <Entity, PrimaryFieldInfo, string> getName) { if (info.AttributeName == null || info.IsAttributeOf || (info.ReadOnly && info.BaseAttributes.Count == 0)) { return; } var name = getName(e, info).PadRight(info.MaximumLength).Substring(0, info.MaximumLength).TrimEnd(); if (info.ReadOnly) { if (info.BaseAttributes.Count == 1) { e[info.BaseAttributes[0]] = name; } // Split name amoungst first two attributes. If odd, subtract 1 to have equal lengths var length = name.Length % 2 == 0 ? name.Length : name.Length - 1; length = length / 2; SetIfNotDefined(e, info.BaseAttributes[0], name.Substring(0, length)); SetIfNotDefined(e, info.BaseAttributes[1], name.Substring(length, length)); } else { SetIfNotDefined(e, info.AttributeName, name); } }
public PrimaryFieldInfo GetIrregularPrimaryFieldInfo(string logicalName, PrimaryFieldInfo defaultInfo = null) { if (logicalName == "customactivity") { defaultInfo = defaultInfo ?? new PrimaryFieldInfo(); defaultInfo.AttributeName = "subject"; return(defaultInfo); } return(null); }
public PrimaryFieldInfo GetIrregularPrimaryFieldInfo(string logicalName, PrimaryFieldInfo defaultInfo = null) { return(null); }
/// <summary> /// Gets the Primary Field (name) info. /// </summary> /// <param name="logicalName">Name of the logical.</param> /// <param name="config">Interface for handling irregular primary attribute names.</param> /// <returns></returns> public static PrimaryFieldInfo GetPrimaryFieldInfo(string logicalName, IEntityHelperConfig config = null) { var info = new PrimaryFieldInfo(); switch (logicalName) { case "businessunitnewsarticle": info.AttributeName = "articletitle"; info.MaximumLength = 300; break; case "transactioncurrency": info.AttributeName = "currencyname"; break; case "customerrelationship": info.AttributeName = "customerroleidname"; info.ReadOnly = true; info.IsAttributeOf = true; break; case "importjob": info.AttributeName = "data"; info.MaximumLength = 1073741823; break; case "transformationparametermapping": info.AttributeName = "data"; info.MaximumLength = 500; break; case "activitymimeattachment": info.AttributeName = "fileName"; info.MaximumLength = 255; break; case "contact": case "systemuser": case "lead": info.AttributeName = "fullname"; info.BaseAttributes.Add("firstname"); info.BaseAttributes.Add("lastname"); if (logicalName == "lead") { info.BaseAttributes.Add("companyname"); } info.ReadOnly = true; break; case "solution": case "publisher": info.AttributeName = "friendlyname"; break; case "account": case "asyncoperation": case "bulkdeleteoperation": case "businessunit": case "calendar": case "calendarrule": case "campaign": case "competitor": case "connection": case "connectionrole": case "constraintbasedgroup": case "contracttemplate": case "convertrule": case "convertruleitem": case "customeraddress": case "discounttype": case "duplicaterule": case "emailserverprofile": case "entitlement": case "entitlementchannel": case "entitlementtemplate": case "entitlementtemplatechannel": case "equipment": case "fieldsecurityprofile": case "goalrollupquery": case "import": case "importfile": case "importmap": case "invoice": case "mailbox": case "mailmergetemplate": case "metric": case "opportunity": case "organization": case "pluginassembly": case "plugintype": case "pricelevel": case "privilege": case "processsession": case "product": case "publisheraddress": case "queue": case "quote": case "relationshiprole": case "report": case "resource": case "resourcegroup": case "resourcespec": case "role": case "routingrule": case "routingruleitem": case "salesliterature": case "salesorder": case "savedquery": case "savedqueryvisualization": case "sdkmessage": case "sdkmessageprocessingstep": case "sdkmessageprocessingstepimage": case "service": case "serviceendpoint": case "sharepointdocumentlocation": case "sharepointsite": case "site": case "sla": case "systemform": case "team": case "territory": case "uom": case "uomschedule": case "userform": case "userquery": case "userqueryvisualization": case "webresource": info.AttributeName = "name"; break; case "list": info.AttributeName = "listname"; info.MaximumLength = 128; break; case "activityparty": info.AttributeName = "partyidname"; info.MaximumLength = 400; info.ReadOnly = true; info.IsAttributeOf = true; break; case "invoicedetail": case "opportunityproduct": case "productpricelevel": case "quotedetail": case "salesorderdetail": info.AttributeName = "productidname"; info.ReadOnly = true; info.IsAttributeOf = true; break; case "socialprofile": info.AttributeName = "profilename"; break; case "postfollow": info.AttributeName = "regardingobjectidname"; info.ReadOnly = true; info.IsAttributeOf = true; info.MaximumLength = 4000; break; case "columnmapping": info.AttributeName = "sourceattributename"; info.MaximumLength = 160; break; case "processstage": info.AttributeName = "stagename"; break; case "activitypointer": case "annotation": case "appointment": case "bulkoperation": case "campaignactivity": case "campaignresponse": case "email": case "fax": case "incidentresolution": case "letter": case "opportunityclose": case "orderclose": case "phonecall": case "quoteclose": case "recurringappointmentmaster": case "serviceappointment": case "socialactivity": case "task": info.AttributeName = "subject"; info.MaximumLength = 200; break; case "teamtemplate": info.AttributeName = "teamtemplatename"; break; case "post": case "postcomment": case "tracelog": info.AttributeName = "text"; info.MaximumLength = 1000; break; case "contract": case "contractdetail": case "goal": case "incident": case "kbarticle": case "kbarticlecomment": case "kbarticletemplate": case "queueitem": case "salesliteratureitem": case "subject": case "template": info.AttributeName = "title"; break; default: if (logicalName.Contains('_')) { info.AttributeName = logicalName.SubstringByString(0, "_") + "_name"; } else { info.AttributeName = null; } info = (config ?? DLaBEntityHelperConfig.Config).GetIrregularPrimaryFieldInfo(logicalName, info) ?? info; break; } return(info); }
public PrimaryFieldInfo GetIrregularPrimaryFieldInfo(string logicalName, PrimaryFieldInfo defaultInfo = null) { defaultInfo = defaultInfo ?? new PrimaryFieldInfo(); defaultInfo.AttributeName = PrimaryNameFieldProviderBase.GetConfiguredProvider(TestSettings.EarlyBound.Assembly, TestSettings.EarlyBound.Namespace).GetPrimaryName(logicalName); return(defaultInfo); }