Добрый день .
Есть стандартный БП Запуск процесса Отправка email сообщения группе о назначении обращения. Работает отлично. Но начиная с версии 7.17 можно отправлять вложения в ходе БП.
Кто подскажет как модернизировать стандартный БП, что бы вложения отправлялись ?
UserConnection userConnection = UserConnection;
if (userConnection.CurrentUser.ConnectionType == UserType.SSP) {
userConnection = userConnection.AppConnection.SystemUserConnection;
}
var senderEmail = Terrasoft.Core.Configuration.SysSettings.GetValue(userConnection,
"SupportServiceEmail", string.Empty);
if (userConnection.GetIsFeatureEnabled("EmailMessageMultiLanguage") || userConnection.GetIsFeatureEnabled("EmailMessageMultiLanguageV2")) {
var caseRecordId = (StartSignal1.RecordId != Guid.Empty)
? StartSignal1.RecordId
: StartSignal2.RecordId;
var esq = new EntitySchemaQuery(userConnection.EntitySchemaManager, "Case");
esq.AddColumn("Group");
var caseEntity = esq.GetEntity(userConnection, caseRecordId);
if (caseEntity != null) {
var adminUnitEsq = new EntitySchemaQuery(userConnection.EntitySchemaManager, "SysAdminUnit");
adminUnitEsq.UseAdminRights = false;
var emailColumnName = adminUnitEsq.AddColumn("Contact.Email").Name;
var groupId = caseEntity.GetTypedColumnValue("GroupId");
adminUnitEsq.Filters.Add(adminUnitEsq.CreateFilterWithParameters(FilterComparisonType.Equal, "[SysUserInRole:SysUser].SysRole", groupId));
var collection = adminUnitEsq.GetEntityCollection(userConnection);
var result = string.Join(";", collection.Select(e => e.GetTypedColumnValue(emailColumnName)));
if (!string.IsNullOrWhiteSpace(result)) {
var emailTemplateSender = new Terrasoft.Configuration.EmailWithMacrosManager(userConnection);
var emailTemplateId = Terrasoft.Configuration.CaseConsts.GroupTemplateId;
if (userConnection.GetIsFeatureEnabled("EmailMessageMultiLanguageV2")) {
emailTemplateSender.SendEmailFromTo(caseRecordId, emailTemplateId, senderEmail, result);
return true;
} else {
var emailTemplateStore = new Terrasoft.Configuration.EmailTemplateStore(userConnection);
var emailTemplateLanguageHelper = new Terrasoft.Configuration.EmailTemplateLanguageHelper(caseRecordId, userConnection);
var languageId = emailTemplateLanguageHelper.GetLanguageId(emailTemplateId);
var templateEntity = emailTemplateStore.GetTemplate(emailTemplateId, languageId);
emailTemplateSender.SendEmailFromTo(caseRecordId, templateEntity.PrimaryColumnValue, senderEmail, result);
}
}
}
} else {
Guid sendEmailToCaseGroup = new Guid("C68F5A4E-AD06-4C83-88C4-040D2480FACB");
var manager = userConnection.ProcessSchemaManager;
var processSchema = manager.GetInstanceByUId(sendEmailToCaseGroup);
if (ProcessSchemaManager.GetCanUseFlowEngine(userConnection, processSchema)) {
var flowEngine = new FlowEngine(userConnection);
Dictionary parameter = new Dictionary();
parameter.Add("CaseRecordId", CaseRecordId.ToString());
flowEngine.RunProcess(processSchema, parameter);
} else {
var moduleProcess = processSchema.CreateProcess(userConnection);
if (processSchema.Parameters.ExistsByName("CaseRecordId")) {
moduleProcess.SetPropertyValue("CaseRecordId", CaseRecordId);
}
moduleProcess.Execute(userConnection);
}
}
return true;