|
![]() |
#1 |
Участник
|
Можно написать свою маленькую программку и выполнить ее.
Код: public static Guid RegisterStep(CrmService.CrmService crmService, Guid pluginTypeID, string entityName, Guid sdkMessageID) { Guid sdkMessageFilterID = GetSdkMessageFilterID(crmService, entityName, sdkMessageID); if (sdkMessageFilterID == Guid.Empty) throw new Exception("Не удалось получить Guid messagefilter для EntityName = '" + entityName + "', sdkMessageID = '" + sdkMessageID + "'"); sdkmessageprocessingstep step = new sdkmessageprocessingstep(); step.plugintypeid = new Lookup(); step.plugintypeid.Value = pluginTypeID; step.sdkmessagefilterid = new Lookup(); step.sdkmessagefilterid.Value = sdkMessageFilterID; step.sdkmessageid = new Lookup(); step.sdkmessageid.Value = sdkMessageID; step.description = "Auditing Plugin"; step.invocationsource = new Picklist(); step.invocationsource.Value = 0; // 0 (parent pipeline) or 1 (child pipeline) step.mode = new Picklist(); step.mode.Value = Config.ModePluginExecution; step.rank = new CrmNumber(); step.rank.Value = 0; step.stage = new Picklist(); step.stage.Value = 50; // 10 (pre-event) or 50 (post-event) step.supporteddeployment = new Picklist(); step.supporteddeployment.Value = 0; // 0 (server), 1 (Outlook client), or 2 (both) //Comma separated list of attributes that must be changed for the plug-in to be invoked. An empty list indicates all attributes step.filteringattributes = ""; //GUID of the system user account that the plug-in is to execute under. //step.ImpersonatingUserId = ""; step.configuration = Config.SqlConnectionString; try { return crmService.Create(step); } catch (Exception ex) { throw new Exception("При регистрации шага произошла ошибка: " + ex.Message); } } public static Guid GetSdkMessageFilterID(CrmService.CrmService crmService, string entityName, Guid sdkMessageID) { QueryByAttribute query = new QueryByAttribute(); ColumnSet cs = new ColumnSet(); cs.Attributes = new string[] { "sdkmessagefilterid" }; query.ColumnSet = cs; query.EntityName = EntityName.sdkmessagefilter.ToString(); query.Attributes = new string[] { "primaryobjecttypecode", "sdkmessageid" }; query.Values = new string[] { entityName.ToLower(), sdkMessageID.ToString() }; BusinessEntityCollection bec; try { bec = crmService.RetrieveMultiple(query); } catch (Exception ex) { throw new Exception("При получении Guid messagefilter для EntityName = '" + entityName + "', sdkMessageID = '" + sdkMessageID + "' произошла ошибка: " + ex.Message); } if (bec.BusinessEntities != null && bec.BusinessEntities.Length > 0) { return ((sdkmessagefilter)bec.BusinessEntities[0]).sdkmessagefilterid.Value; } else { return Guid.Empty; } } public static Guid GetSdkMessageID(CrmService.CrmService crmService, string messageName) { QueryByAttribute query = new QueryByAttribute(); ColumnSet cs = new ColumnSet(); cs.Attributes = new string[] { "sdkmessageid" }; query.ColumnSet = cs; query.EntityName = EntityName.sdkmessage.ToString(); query.Attributes = new string[] { "name" }; query.Values = new string[] { messageName }; BusinessEntityCollection bec; try { bec = crmService.RetrieveMultiple(query); } catch (Exception ex) { throw new Exception("При получении Guid message '" + messageName + "' произошла ошибка: " + ex.Message); } if (bec.BusinessEntities != null && bec.BusinessEntities.Length > 0) { return ((sdkmessage)bec.BusinessEntities[0]).sdkmessageid.Value; } else { return Guid.Empty; } } |
|