/// <summary> /// Sets NonActual sign of email to false. /// </summary> /// <param name="args">Parameters object for update query.</param> public void SetActualEmailAction(object args) { var argsDictionary = (Dictionary <string, object>)args; var filters = (string)argsDictionary["filters"]; var entitySchemaUIdAsString = (string)argsDictionary["entitySchemaUId"]; Thread.CurrentThread.CurrentCulture = (CultureInfo)argsDictionary["Culture"]; var entitySchemaUId = new Guid(entitySchemaUIdAsString); try { EntitySchemaQuery contactEsq = GetContactEsq(filters, entitySchemaUId); Select contactsSelect = contactEsq.GetSelectQuery(UserConnection); Update contactCommunicationUpdate = GetContactCommunicationUpdate(contactsSelect); Update contactUpdate = GetContactUpdate(contactsSelect); string description = CreateReminding(contactEsq); contactCommunicationUpdate.Execute(); contactUpdate.Execute(); RemindingConfig remindingConfig = new RemindingConfig(entitySchemaUId); remindingConfig.Description = description; remindingConfig.AuthorId = remindingConfig.ContactId = UserConnection.CurrentUser.ContactId; this.RemindingUtilities.CreateReminding(UserConnection, remindingConfig); } catch (Exception e) { MandrillUtilities.Log.Error("[ContactService.SetActualEmailAction]: ", e); throw e; } }
/// <summary> /// Creates notification message for user. /// </summary> /// <param name="userConnection">Instance of user connection.</param> /// <param name="config">Configuration object for notification message.</param> public virtual void CreateReminding(UserConnection userConnection, RemindingConfig config) { ValidateConfig(config); DateTime userDateTime = GetUserDateTime(userConnection, config); string subject = TruncateString(config.Description, SubjectCaptionTypeStringLength); string description = TruncateString(config.Description, DescriptionTypeStringLength); Reminding remindingEntity = GetRemindingEntity(userConnection, config); remindingEntity.SetColumnValue("ModifiedOn", userDateTime); remindingEntity.SetColumnValue("AuthorId", config.AuthorId); remindingEntity.SetColumnValue("ContactId", config.ContactId); remindingEntity.SetColumnValue("SourceId", config.SourceId); remindingEntity.SetColumnValue("RemindTime", userDateTime); remindingEntity.SetColumnValue("Description", description); remindingEntity.SetColumnValue("SubjectCaption", subject); remindingEntity.SetColumnValue("SysEntitySchemaId", config.EntitySchemaUId); remindingEntity.SetColumnValue("SubjectId", config.SubjectId); remindingEntity.SetColumnValue("NotificationTypeId", config.NotificationTypeId); remindingEntity.SetColumnValue("LoaderId", config.LoaderId); remindingEntity.SetColumnValue("SenderId", config.SenderId); remindingEntity.SetColumnValue("IsNeedToSend", config.IsNeedToSend); remindingEntity.SetColumnValue("PopupTitle", config.PopupTitle); remindingEntity.SetColumnValue("Config", config.Config != null ? JsonConvert.SerializeObject(config.Config) : string.Empty); remindingEntity.Save(); }
private void SendReminding(IEntity sysUserEntity, FileConversionTask fileConversionTask, ReportGenerationTask reportGenerationTask) { var contactId = sysUserEntity.GetTypedColumnValue <Guid>("ContactId"); contactId.CheckDependencyNull(nameof(contactId)); var systemUserConnection = _appConnection.SystemUserConnection; var sysModuleReportEntity = systemUserConnection.EntitySchemaManager.FindInstanceByName("SysModuleReport"); sysModuleReportEntity.CheckDependencyNull(nameof(sysModuleReportEntity)); var config = new RemindingConfig(sysModuleReportEntity.UId) { AuthorId = contactId, SourceId = RemindingConsts.RemindingSourceAuthorId, ContactId = contactId, SubjectId = Guid.Empty, Description = string.Empty, RemindTime = DateTime.UtcNow, Config = new Dictionary <string, object> { { "serviceName", nameof(PdfAsyncReportGenerationController) }, { "methodName", nameof(PdfAsyncReportGenerationController.GetReportFile) }, { "success", fileConversionTask.Status == TaskStatus.Successed }, { "reportName", reportGenerationTask.ReportName }, { "taskId", reportGenerationTask.TaskId } } }; _remindingUtilities.CreateReminding(systemUserConnection, config); }
private void CreateNotification(Guid campaignId, string notification) { var campaign = CampaignHelper.GetCampaign(campaignId, "Owner"); var config = new RemindingConfig(campaign.Schema.UId) { AuthorId = _userConnection.CurrentUser.ContactId, ContactId = campaign.OwnerId, SubjectId = campaignId, Description = notification }; RemindingUtilities.CreateReminding(_userConnection, config); }
private void ValidateConfig(RemindingConfig config) { config.CheckArgumentNull(nameof(config)); if (config.AuthorId == Guid.Empty) { throw new ArgumentEmptyException("AuthorId"); } if (config.ContactId == Guid.Empty) { throw new ArgumentEmptyException("ContactId"); } if (config.UpdateExisting && config.SubjectId == Guid.Empty) { throw new ArgumentEmptyException("SubjectId"); } }
private string CreateRemindingHash(Guid contactId, Guid authorId, RemindingConfig config) { var condition = new Dictionary <string, object> { { "Author", authorId }, { "Contact", contactId }, { "Source", RemindingConsts.RemindingSourceAuthorId }, { "SubjectId", config.SubjectId }, { "SysEntitySchema", config.EntitySchemaUId } }; var str = new StringBuilder(); foreach (object value in condition.Values) { str.Append(value); } return(FileUtilities.GetMD5Hash(Encoding.Unicode.GetBytes(str.ToString()))); }
private Reminding GetRemindingEntity(UserConnection userConnection, RemindingConfig config) { string hash = config.UpdateExisting ? CreateRemindingHash(config.ContactId, config.AuthorId, config) : string.Empty; EntitySchema remindingSchema = userConnection.EntitySchemaManager.GetInstanceByName("Reminding"); Reminding newReminding = (Reminding)remindingSchema.CreateEntity(userConnection); if (!config.UpdateExisting || !FindRecordByHash(newReminding, hash)) { newReminding.SetDefColumnValues(); } if (config.UpdateExisting) { newReminding.SetColumnValue("Hash", hash); } return(newReminding); }
private DateTime GetUserDateTime(UserConnection userConnection, RemindingConfig config) { return(config.RemindTime.Equals(default(DateTime)) ? userConnection.CurrentUser.GetCurrentDateTime() : config.RemindTime); }