Beispiel #1
0
        /// <summary>
        /// Creates job to monitor fails.
        /// <param name="userConnection">The user connection.</param>
        /// </summary>
        public void CreateJob(UserConnection userConnection)
        {
            SysUserInfo currentUser     = userConnection.CurrentUser;
            int         periodInMinutes = (int)SysSettingsCore.GetValue(userConnection, "BulkEmailFailoverJobInterval");
            string      jobGroupName    = "Mailing";
            bool        isSystemUser    = true;
            var         misfirePolicy   = AppSchedulerMisfireInstruction.RescheduleNowWithRemainingRepeatCount;

            AppScheduler.ScheduleMinutelyJob <BulkEmailFailoverHandler>(jobGroupName, userConnection.Workspace.Name,
                                                                        currentUser.Name, periodInMinutes, null, isSystemUser, misfirePolicy);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the time zone by system setting.
        /// </summary>
        /// <returns>Time zone.</returns>
        /// <exception cref="Exception">Unable to get time zone for calendar.</exception>
        private TimeZoneInfo GetTimeZoneBySystemSetting()
        {
            var unableToGetTimeZoneException = new Exception("Unable to get time zone for calendar.");
            var defaultTimeZoneId            = SystemSettings.GetValue(_userConnection,
                                                                       CalendarConsts.DefaultTimeZoneCode, default(Guid));

            if (defaultTimeZoneId == default(Guid))
            {
                throw unableToGetTimeZoneException;
            }
            var    esq = new EntitySchemaQuery(_userConnection.EntitySchemaManager, "TimeZone");
            string timeZoneCodeColumnName = esq.AddColumn("Code").Name;
            Entity entity = esq.GetEntity(_userConnection, defaultTimeZoneId);

            if (entity == null)
            {
                throw unableToGetTimeZoneException;
            }
            var timeZoneCode = entity.GetTypedColumnValue <string>(timeZoneCodeColumnName);

            return(FindTimeZoneById(timeZoneCode));
        }
Beispiel #3
0
        /// <summary>
        /// Gets the broken bulk emails list.
        /// </summary>
        /// <param name="userConnection">The user connection.</param>
        /// <returns>List of <see cref="BulkEmail"/>.</returns>
        public virtual List <BulkEmail> GetBrokenBulkEmails(UserConnection userConnection)
        {
            var      preparingToSendTimeOut   = (int)SysSettingsCore.GetValue(userConnection, "PreparingToSendTimeoutPeriod");
            var      sendingInProgressTimeOut = (int)SysSettingsCore.GetValue(userConnection, "SendingInProgressTimeoutPeriod");
            Select   bulkEmailSelect          = CreateBulkEmailsSelect(userConnection);
            DateTime currentDate = DateTime.UtcNow;
            var      resultList  = new List <BulkEmail>();

            using (DBExecutor dbExecutor = userConnection.EnsureDBConnection()) {
                using (IDataReader dr = bulkEmailSelect.ExecuteReader(dbExecutor)) {
                    while (dr.Read())
                    {
                        var  sendStartDate  = (DateTime)dr["SendStartDate"];
                        Guid statusId       = userConnection.DBTypeConverter.DBValueToGuid(dr["StatusId"]);
                        Guid launchOptionId = userConnection.DBTypeConverter.DBValueToGuid(dr["LaunchOptionId"]);
                        int  emailTimeout   = statusId == MarketingConsts.BulkEmailStatusStartsId
                                                        ? preparingToSendTimeOut
                                                        : sendingInProgressTimeOut;
                        if (currentDate <= sendStartDate.AddMinutes(emailTimeout))
                        {
                            continue;
                        }
                        var bulkEmail = new BulkEmail(userConnection)
                        {
                            Id             = userConnection.DBTypeConverter.DBValueToGuid(dr["Id"]),
                            CategoryId     = userConnection.DBTypeConverter.DBValueToGuid(dr["CategoryId"]),
                            SendStartDate  = sendStartDate,
                            StatusId       = statusId,
                            LaunchOptionId = launchOptionId
                        };
                        resultList.Add(bulkEmail);
                    }
                }
            }
            return(resultList);
        }