示例#1
0
 void ctlDate_ValueChanged(object sender, EventArgs e)
 {
     if (!date_noEvents)
     {
         DateType = DateTypes.Custom;
     }
 }
示例#2
0
        internal static AlertVariable[] GetVariables(DateTypes dateType)
        {
            // TODO: назначить событиям переменные.
            ArrayList vars = new ArrayList();

            vars.Add(new AlertVariable(Variable.End));
            vars.Add(new AlertVariable(Variable.Start));
            vars.Add(new AlertVariable(Variable.Title));

            bool linkForExternalUser = false;

            switch (dateType)
            {
            case DateTypes.CalendarEntry_FinishDate:
            case DateTypes.CalendarEntry_StartDate:
            case DateTypes.Task_FinishDate:
            case DateTypes.Task_StartDate:
            case DateTypes.Todo_FinishDate:
            case DateTypes.Todo_StartDate:
                linkForExternalUser = true;
                break;
            }
            vars.Add(new AlertVariable(Variable.Link, true, linkForExternalUser, false));

            return(vars.ToArray(typeof(AlertVariable)) as AlertVariable[]);
        }
示例#3
0
        private void BindRow(DateTypes DateType, ImageButton ibRestore, Label lblInterval)
        {
            int  Lag                = -1;
            bool IsActive           = false;
            int  SubscriptionTypeId = (int)SubscriptionTypes.Global;

            using (IDataReader reader = Schedule.GetReminderSubscriptionPersonal(DateType))
            {
                // SubscriptionId, DateTypeId, UserId, ObjectId, ObjectUid, Lag, IsActive, HookId, SubscriptionType
                if (reader.Read())
                {
                    Lag                = (int)reader["Lag"];
                    IsActive           = (bool)reader["IsActive"];
                    SubscriptionTypeId = (int)reader["SubscriptionType"];
                }
            }

            if (SubscriptionTypeId == (int)SubscriptionTypes.Personal)
            {
                ibRestore.Visible = true;
            }
            if (!IsActive)
            {
                Lag = -1;
            }
            lblInterval.Text = CommonHelper.GetIntervalString(Lag);
        }
示例#4
0
        private object GetValueByType()
        {
            const string isoDateFormat = "yyyy-MM-dd"; // default iso format required for HTML5 date input
            const string numericFormat = "0.00";

            var propertyType = For.ModelExplorer.ModelType;

            if (DateTypes.Contains(propertyType))
            {
                var parsedValue = (DateTime?)For.Model;
                return(parsedValue.HasValue
                    ? parsedValue.Value.ToString(isoDateFormat)
                    : string.Empty);
            }

            if (DecimalTypes.Contains(propertyType))
            {
                var parsedValue = (decimal?)For.Model;
                return(parsedValue.HasValue
                    ? parsedValue.Value.ToString(numericFormat)
                    : string.Empty);
            }

            return(For.Model);
        }
示例#5
0
        /// <summary>
        /// Gets the message template.
        /// </summary>
        /// <param name="dateType">Type of the date.</param>
        /// <param name="objecTypeId">The objec type id.</param>
        /// <param name="languageId">The language id.</param>
        /// <returns></returns>
        public static ReminderTemplate GetMessageTemplate(DateTypes dateType, int languageId)
        {
            ReminderTemplate retVal = null;

            retVal = new ReminderTemplate(dateType, languageId);
            retVal.Load();

            return(retVal);
        }
示例#6
0
 public ValueElementDateTime(string rawName,
                             Type propertyType,
                             DateTypes dateType,
                             DateTime data,
                             bool isOffset)
 {
     RawName          = rawName;
     PropertyType     = propertyType;
     DateType         = dateType;
     _data            = data;
     RawData          = data;
     IsDateTimeOffset = isOffset;
 }
示例#7
0
        public static SubscriptionTypes GetSubscriptionType(DateTypes dateType, int UserId, int ObjectId)
        {
            SubscriptionTypes SubscriptionType = SubscriptionTypes.UNDEFINED;

            using (IDataReader reader = DbSchedule2.GetReminderSubscriptionPersonalForObject((int)dateType, UserId, ObjectId))
            {
                if (reader.Read())
                {
                    SubscriptionType = (SubscriptionTypes)((int)reader["SubscriptionType"]);
                }
            }
            return(SubscriptionType);
        }
示例#8
0
        private void SelectValue(DropDownList ddl, DateTypes DateType)
        {
            ddl.ClearSelection();

            using (IDataReader reader = Schedule.GetReminderSubscriptionPersonal(DateType))
            {
                ///  SubscriptionId, DateTypeId, UserId, ObjectId, ObjectUid, Lag, IsActive, HookId
                if (reader.Read())
                {
                    if ((bool)reader["IsActive"])
                    {
                        Util.CommonHelper.SafeSelect(ddl, reader["Lag"].ToString());
                    }
                }
            }
        }
示例#9
0
        public ReminderTemplate(DateTypes dateType, string locale)
        {
            Locale   = locale;
            DateType = dateType;

            using (IDataReader reader = Common.GetListLanguages())
            {
                while (reader.Read())
                {
                    if (Locale == reader["Locale"].ToString())
                    {
                        LanguageId = (int)reader["LanguageId"];
                        break;
                    }
                }
            }
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReminderTemplate"/> class.
        /// </summary>
        /// <param name="dateType">Type of the date.</param>
        /// <param name="objecTypeId">The objec type id.</param>
        /// <param name="languageId">The language id.</param>
        public ReminderTemplate(DateTypes dateType, int languageId)
        {
            LanguageId = languageId;
            DateType   = dateType;
            //ObjecTypeId = objecTypeId;

            using (IDataReader reader = Common.GetListLanguages())
            {
                while (reader.Read())
                {
                    if ((int)reader["LanguageId"] == languageId)
                    {
                        Locale = reader["Locale"].ToString();
                        break;
                    }
                }
            }
        }
        private static object GetParsedRangeValue(Type fieldType, string value = null)
        {
            if (DateTypes.Contains(fieldType))
            {
                if (!string.IsNullOrWhiteSpace(value) && DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var typedValue))
                {
                    return(typedValue);
                }

                return(null);
            }
            if (NotIntTypes.Contains(fieldType))
            {
                return(string.IsNullOrWhiteSpace(value) ? (decimal?)null : decimal.Parse(value, CultureInfo.InvariantCulture));
            }

            return(string.IsNullOrWhiteSpace(value) ? (int?)null : int.Parse(value));
        }
示例#12
0
        private static void ProcessPersonalSubscriptionForObject(int hookId, DateTypes dateType, int userId, ObjectTypes objectType, int?objectId, Guid?objectUid)
        {
            // Check Security
            if (objectId.HasValue && !CheckSecurityForObject(objectType, objectId.Value, userId))
            {
                return;
            }
            if (objectUid.HasValue && !CheckSecurityForObject(objectType, objectUid.Value, userId))
            {
                return;
            }

            // Send Reminder
            List <int> users = new List <int>();

            users.Add(userId);
            SendReminder(dateType, objectType, objectId, objectUid, users);
        }
示例#13
0
        private string GetInputTypeFromModel(Type modelType)
        {
            if (NumericTypes.Contains(modelType))
            {
                return("number");
            }

            if (DateTypes.Contains(modelType))
            {
                return("date");
            }

            if (modelType == typeof(string))
            {
                return("text");
            }

            return(string.Empty);
        }
示例#14
0
        private static bool ConfirmNotification(ObjectTypes objectType, DateTypes dateType, int?objectId, Guid?objectUid)
        {
            bool notify = false;

            bool hasRecurrence = false;

            if (objectId.HasValue)
            {
                using (IDataReader reader = DBCommon.GetRecurrence((int)objectType, objectId.Value))
                {
                    hasRecurrence = reader.Read();
                }
            }

            switch (objectType)
            {
            case ObjectTypes.CalendarEntry:
                notify = CalendarEntry.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.Project:
                notify = Project.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.Task:
                notify = Task.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.ToDo:
                notify = ToDo.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.Assignment:
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value);
                if (entity != null && entity.State == (int)AssignmentState.Active)
                {
                    notify = true;
                }
                break;
            }

            return(notify);
        }
示例#15
0
        public static void UpdateReminderSubscriptionPersonalForObject(DateTypes dateType, int ObjectId, int Lag, bool IsActive)
        {
            bool WasActive = false;
            int  HookId    = -1;
            int  OldLag    = -1;

            using (IDataReader reader = DbSchedule2.GetReminderSubscriptionPersonalForObject((int)dateType, Security.CurrentUser.UserID, ObjectId))
            {
                ///  SubscriptionId, DateTypeId, UserId, ObjectId, Lag, IsActive, HookId, SubscriptionType
                if (reader.Read())
                {
                    if ((int)reader["SubscriptionType"] == (int)SubscriptionTypes.PersonalForObject)
                    {
                        WasActive = (bool)reader["IsActive"];
                        if (reader["HookId"] != DBNull.Value)
                        {
                            HookId = (int)reader["HookId"];
                        }
                        OldLag = (int)reader["Lag"];
                    }
                }
            }

            int SubscriptionId = DbSchedule2.AddReminderSubscriptionPersonalForObject((int)dateType, Security.CurrentUser.UserID, ObjectId, Lag, IsActive);

            if (IsActive && !WasActive)                 // Activation
            {
                HookId = DbSchedule2.AddHook((int)dateType, ObjectId, Lag, (int)DateTypeHandlers.SendReminder, ((int)SubscriptionTypes.PersonalForObject).ToString());
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, HookId);
            }
            else if (IsActive && WasActive && Lag != OldLag)                    // Lag changed
            {
                DbSchedule2.UpdateHook(HookId, Lag);
            }
            else if (!IsActive && WasActive)                    // Deactivation
            {
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, -1);
                DbSchedule2.DeleteHook(HookId);
            }
        }
示例#16
0
        private static void ProcessPersonalSubscription(int hookId, DateTypes dateType, int userId, ObjectTypes objectType, int?objectId, Guid?objectUid)
        {
            // Проверим отсутствие индивидуальной подписки
            if (objectId.HasValue && GetSubscriptionType(dateType, userId, objectId.Value) != SubscriptionTypes.Personal)
            {
                return;
            }

            // Check Security
            if (objectId.HasValue && !CheckSecurityForObject(objectType, objectId.Value, userId))
            {
                return;
            }
            if (objectUid.HasValue && !CheckSecurityForObject(objectType, objectUid.Value, userId))
            {
                return;
            }

            // Send Reminder
            List <int> users = new List <int>();

            users.Add(userId);
            SendReminder(dateType, objectType, objectId, objectUid, users);
        }
示例#17
0
        private static void UpdateReminderSubscriptionGlobal(DateTypes dateType, int Lag, bool IsActive)
        {
            bool WasActive = false;
            int  HookId    = -1;
            int  OldLag    = -1;

            using (IDataReader reader = DbSchedule2.GetReminderSubscriptionGlobal((int)dateType))
            {
                if (reader.Read())
                {
                    WasActive = (bool)reader["IsActive"];
                    if (reader["HookId"] != DBNull.Value)
                    {
                        HookId = (int)reader["HookId"];
                    }
                    OldLag = (int)reader["Lag"];
                }
            }

            int SubscriptionId = DbSchedule2.AddReminderSubscriptionGlobal((int)dateType, Lag, IsActive);

            if (IsActive && !WasActive)                 // Activation
            {
                HookId = DbSchedule2.AddHook((int)dateType, -1, Lag, (int)DateTypeHandlers.SendReminder, ((int)SubscriptionTypes.Global).ToString());
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, HookId);
            }
            else if (IsActive && WasActive && Lag != OldLag)                    // Lag changed
            {
                DbSchedule2.UpdateHook(HookId, Lag);
            }
            else if (!IsActive && WasActive)                    // Deactivation
            {
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, -1);
                DbSchedule2.DeleteHook(HookId);
            }
        }
        private static IFacetItemRangeValue GetFacetItemRangeValue(Type fieldType, string rawMinimumValue = null, string rawMaximumValue = null)
        {
            if (DateTypes.Contains(fieldType))
            {
                var minimumValue = (DateTime?)GetParsedRangeValue(fieldType, rawMinimumValue);
                var maximumValue = (DateTime?)GetParsedRangeValue(fieldType, rawMaximumValue);

                return(new FacetItemRangeValue <DateTime>(minimumValue, maximumValue));
            }
            if (NotIntTypes.Contains(fieldType))
            {
                var minimumValue = (decimal?)GetParsedRangeValue(fieldType, rawMinimumValue);
                var maximumValue = (decimal?)GetParsedRangeValue(fieldType, rawMaximumValue);

                return(new FacetItemRangeValue <decimal>(minimumValue, maximumValue));
            }
            else
            {
                var minimumValue = (int?)GetParsedRangeValue(fieldType, rawMinimumValue);
                var maximumValue = (int?)GetParsedRangeValue(fieldType, rawMaximumValue);

                return(new FacetItemRangeValue <int>(minimumValue, maximumValue));
            }
        }
示例#19
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static void DeleteReminderSubscriptionPersonalForObject(DateTypes DateType, int ObjectId)
 {
     DbSchedule2.DeleteReminderSubscriptionPersonalForObject((int)DateType, Security.CurrentUser.UserID, ObjectId);
 }
示例#20
0
 public DateTypeAttribute(DateTypes dateType = DateTypes.DateTime)
 {
     this.DateType = dateType;
 }
示例#21
0
文件: Schedule2.cs 项目: 0anion0/IBN
 /// <summary>
 /// Reader returns fields:
 ///  SubscriptionId, DateTypeId, UserId, ObjectId, ObjectUid, Lag, IsActive, HookId, SubscriptionType 
 /// </summary>
 /// <returns></returns>
 public static IDataReader GetReminderSubscriptionPersonal(DateTypes DateType)
 {
     return DbSchedule2.GetReminderSubscriptionPersonal((int)DateType, Security.CurrentUser.UserID);
 }
        private void BindRow(DateTypes DateType, ImageButton ibRestore, Label lblInterval)
        {
            int Lag = -1;
            bool IsActive = false;
            int SubscriptionTypeId = (int)SubscriptionTypes.Global;

            using (IDataReader reader = Schedule.GetReminderSubscriptionPersonalForObject(DateType, ObjectId))
            {
                // SubscriptionId, DateTypeId, UserId, ObjectId, Lag, IsActive, HookId, SubscriptionType
                if (reader.Read())
                {
                    Lag = (int)reader["Lag"];
                    IsActive = (bool)reader["IsActive"];
                    SubscriptionTypeId = (int)reader["SubscriptionType"];
                }
            }

            if (SubscriptionTypeId == (int)SubscriptionTypes.PersonalForObject)
                ibRestore.Visible = true;
            if (!IsActive)
                Lag = -1;
            lblInterval.Text = CommonHelper.GetIntervalString(Lag);
        }
示例#23
0
文件: Schedule2.cs 项目: 0anion0/IBN
        private static void UpdateReminderSubscriptionGlobal(DateTypes dateType, int Lag, bool IsActive)
        {
            bool WasActive = false;
            int HookId = -1;
            int OldLag = -1;
            using (IDataReader reader = DbSchedule2.GetReminderSubscriptionGlobal((int)dateType))
            {
                if (reader.Read())
                {
                    WasActive = (bool)reader["IsActive"];
                    if (reader["HookId"] != DBNull.Value)
                        HookId = (int)reader["HookId"];
                    OldLag = (int)reader["Lag"];
                }
            }

            int SubscriptionId = DbSchedule2.AddReminderSubscriptionGlobal((int)dateType, Lag, IsActive);

            if (IsActive && !WasActive)	// Activation
            {
                HookId = DbSchedule2.AddHook((int)dateType, -1, Lag, (int)DateTypeHandlers.SendReminder, ((int)SubscriptionTypes.Global).ToString());
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, HookId);
            }
            else if (IsActive && WasActive && Lag != OldLag)	// Lag changed
            {
                DbSchedule2.UpdateHook(HookId, Lag);
            }
            else if (!IsActive && WasActive)	// Deactivation
            {
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, -1);
                DbSchedule2.DeleteHook(HookId);
            }
        }
示例#24
0
文件: Schedule2.cs 项目: 0anion0/IBN
        private static bool ConfirmNotification(ObjectTypes objectType, DateTypes dateType, int? objectId, Guid? objectUid)
        {
            bool notify = false;

            bool hasRecurrence = false;
            if (objectId.HasValue)
            {
                using (IDataReader reader = DBCommon.GetRecurrence((int)objectType, objectId.Value))
                {
                    hasRecurrence = reader.Read();
                }
            }

            switch (objectType)
            {
                case ObjectTypes.CalendarEntry:
                    notify = CalendarEntry.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                    break;
                case ObjectTypes.Project:
                    notify = Project.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                    break;
                case ObjectTypes.Task:
                    notify = Task.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                    break;
                case ObjectTypes.ToDo:
                    notify = ToDo.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                    break;
                case ObjectTypes.Assignment:
                    AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value);
                    if (entity != null && entity.State == (int)AssignmentState.Active)
                        notify = true;
                    break;

            }

            return notify;
        }
示例#25
0
文件: Reminder.cs 项目: 0anion0/IBN
        internal static AlertVariable[] GetVariables(DateTypes dateType)
        {
            // TODO: назначить событиям переменные.
            ArrayList vars = new ArrayList();

            vars.Add(new AlertVariable(Variable.End));
            vars.Add(new AlertVariable(Variable.Start));
            vars.Add(new AlertVariable(Variable.Title));

            bool linkForExternalUser = false;
            switch (dateType)
            {
                case DateTypes.CalendarEntry_FinishDate:
                case DateTypes.CalendarEntry_StartDate:
                case DateTypes.Task_FinishDate:
                case DateTypes.Task_StartDate:
                case DateTypes.Todo_FinishDate:
                case DateTypes.Todo_StartDate:
                    linkForExternalUser = true;
                    break;
            }
            vars.Add(new AlertVariable(Variable.Link, true, linkForExternalUser, false));

            return vars.ToArray(typeof(AlertVariable)) as AlertVariable[];
        }
示例#26
0
 public static int AddDateTypeValue(DateTypes DateType, int ObjectId, DateTime DateValue)
 {
     return(AddDateTypeValue((int)DateType, ObjectId, DateValue));
 }
示例#27
0
        private static void ProcessGlobalSubscription(int hookId, DateTypes dateType, ObjectTypes objectType, int?objectId, Guid?objectUid)
        {
            // Формируем список пользователей, связанных с объектом
            List <int> users = new List <int>();

            if (objectType == ObjectTypes.Project)
            {
                using (IDataReader reader = DBProject.GetProjectSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.Task)
            {
                using (IDataReader reader = DBTask.GetTaskSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        if ((bool)reader["IsRealTaskResource"] || (bool)reader["IsRealTaskManager"] || (bool)reader["IsCreator"])
                        {
                            users.Add((int)reader["UserId"]);
                        }
                    }
                }
            }
            else if (objectType == ObjectTypes.ToDo)
            {
                using (IDataReader reader = DBToDo.GetToDoSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.CalendarEntry)
            {
                using (IDataReader reader = DBEvent.GetListUsersForEvent(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.Document)
            {
                using (IDataReader reader = DBDocument.GetDocumentSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.Assignment)
            {
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value);
                if (entity != null && entity.OwnerDocumentId.HasValue)
                {
                    using (IDataReader reader = DBDocument.GetDocumentSecurity(entity.OwnerDocumentId.Value))
                    {
                        while (reader.Read())
                        {
                            users.Add((int)reader["UserId"]);
                        }
                    }
                }
            }

            // Проверим отсутствие индивидуальной подписки
            for (int i = 0; i < users.Count; i++)
            {
                int userId = users[i];

                // O.R. [2010-04-01]: Don't process inactive users
                if (User.GetUserActivity(userId) != User.UserActivity.Active)
                {
                    users.RemoveAt(i);
                    i--;
                }
                else if (objectId.HasValue)
                {
                    if (GetSubscriptionType(dateType, userId, objectId.Value) != SubscriptionTypes.Global)
                    {
                        users.RemoveAt(i);
                        i--;
                    }
                }
            }

            // Send Reminder
            if (users.Count > 0)
            {
                SendReminder(dateType, objectType, objectId, objectUid, users);
            }
        }
示例#28
0
        public static void ProcessHandler(int handlerId, string argument, int hookId, int?objectId, Guid?objectUid, DateTime dateValue)
        {
            ObjectTypes objectType = ObjectTypes.UNDEFINED;
            DateTypes   dateType   = DateTypes.Undefined;

            if (handlerId == (int)DateTypeHandlers.SendReminder)
            {
                // Напоминать только о тех датах, которые еще не наступили.
                if (dateValue >= DateTime.UtcNow)
                {
                    bool sendReminder = false;

                    int userId = -1;
                    using (IDataReader reader = DbSchedule2.GetReminderSubscriptionByHookId(hookId))
                    {
                        if (reader.Read())
                        {
                            sendReminder = true;

                            if (reader["UserId"] != DBNull.Value)
                            {
                                userId = (int)reader["UserId"];

                                // O.R. [2010-04-01]: Don't process inactive user
                                if (User.GetUserActivity(userId) != User.UserActivity.Active)
                                {
                                    sendReminder = false;
                                }
                            }
                            objectType = (ObjectTypes)reader["ObjectTypeId"];
                            dateType   = (DateTypes)reader["DateTypeId"];
                        }
                    }

                    // Не напоминать о досрочно запущенных или досрочно завершённых объектах [2007-02-16]
                    if (sendReminder)
                    {
                        sendReminder = ConfirmNotification(objectType, dateType, objectId, objectUid);
                    }

                    if (sendReminder)
                    {
                        SubscriptionTypes subscriptionType = (SubscriptionTypes)int.Parse(argument, CultureInfo.InvariantCulture);

                        switch (subscriptionType)
                        {
                        case SubscriptionTypes.Global:
                            ProcessGlobalSubscription(hookId, dateType, objectType, objectId, objectUid);
                            break;

                        case SubscriptionTypes.Personal:
                            ProcessPersonalSubscription(hookId, dateType, userId, objectType, objectId, objectUid);
                            break;

                        case SubscriptionTypes.PersonalForObject:
                            ProcessPersonalSubscriptionForObject(hookId, dateType, userId, objectType, objectId, objectUid);
                            break;
                        }
                    }
                }
            }
            else if (handlerId == (int)DateTypeHandlers.RaiseSystemEvent)
            {
                bool raiseEvent = false;

                using (IDataReader reader = DbSchedule2.GetHook(hookId))
                {
                    if (reader.Read())
                    {
                        raiseEvent = true;

                        objectType = (ObjectTypes)reader["ObjectTypeId"];
                        dateType   = (DateTypes)reader["DateTypeId"];
                    }
                }

                if (raiseEvent)
                {
                    // Не уведомлять о досрочно запущенных или досрочно завершённых объектах [2008-07-29]
                    raiseEvent = ConfirmNotification(objectType, dateType, objectId, objectUid);

                    if (raiseEvent)
                    {
                        SystemEventTypes EventType = (SystemEventTypes)int.Parse(argument);
                        if (objectId.HasValue)
                        {
                            SystemEvents.AddSystemEvents(EventType, objectId.Value);
                        }
                        else if (objectUid.HasValue)
                        {
                            SystemEvents.AddSystemEvents(EventType, objectUid.Value);
                        }
                    }

                    if (objectType == ObjectTypes.Task)
                    {
                        Task.RecalculateAllStates(Task.GetProject(objectId.Value));
                    }
                    else if (objectType == ObjectTypes.ToDo)
                    {
                        ToDo.RecalculateState(objectId.Value);
                    }
                    else if (objectType == ObjectTypes.CalendarEntry)
                    {
                        CalendarEntry.RecalculateState(objectId.Value);
                    }
                }
            }
            else if (handlerId == (int)DateTypeHandlers.BatchAlert)
            {
                if (objectId.HasValue)
                {
                    Alerts2.SendBatch(objectId.Value, dateValue);
                }
            }
            else if (handlerId == (int)DateTypeHandlers.LdapSync)
            {
                if (objectId.HasValue)
                {
                    Ldap.Synchronize(objectId.Value, dateValue);
                }
            }
        }
示例#29
0
 public static void DeleteReminderSubscriptionPersonalForObject(DateTypes DateType, int ObjectId)
 {
     DbSchedule2.DeleteReminderSubscriptionPersonalForObject((int)DateType, Security.CurrentUser.UserID, ObjectId);
 }
示例#30
0
 public static void DeleteReminderSubscriptionPersonal(DateTypes DateType)
 {
     DbSchedule2.DeleteReminderSubscriptionPersonal((int)DateType, Security.CurrentUser.UserID);
 }
示例#31
0
文件: Schedule2.cs 项目: 0anion0/IBN
        private static void ProcessPersonalSubscriptionForObject(int hookId, DateTypes dateType, int userId, ObjectTypes objectType, int? objectId, Guid? objectUid)
        {
            // Check Security
            if (objectId.HasValue && !CheckSecurityForObject(objectType, objectId.Value, userId))
                return;
            if (objectUid.HasValue && !CheckSecurityForObject(objectType, objectUid.Value, userId))
                return;

            // Send Reminder
            List<int> users = new List<int>();
            users.Add(userId);
            SendReminder(dateType, objectType, objectId, objectUid, users);
        }
示例#32
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static void DeleteReminderSubscriptionPersonal(DateTypes DateType)
 {
     DbSchedule2.DeleteReminderSubscriptionPersonal((int)DateType, Security.CurrentUser.UserID);
 }
示例#33
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static int AddDateTypeValue(DateTypes DateType, int ObjectId, DateTime DateValue)
 {
     return AddDateTypeValue((int)DateType, ObjectId, DateValue);
 }
示例#34
0
文件: Schedule2.cs 项目: 0anion0/IBN
        public static void UpdateReminderSubscriptionPersonalForObject(DateTypes dateType, int ObjectId, int Lag, bool IsActive)
        {
            bool WasActive = false;
            int HookId = -1;
            int OldLag = -1;
            using (IDataReader reader = DbSchedule2.GetReminderSubscriptionPersonalForObject((int)dateType, Security.CurrentUser.UserID, ObjectId))
            {
                ///  SubscriptionId, DateTypeId, UserId, ObjectId, Lag, IsActive, HookId, SubscriptionType
                if (reader.Read())
                {
                    if ((int)reader["SubscriptionType"] == (int)SubscriptionTypes.PersonalForObject)
                    {
                        WasActive = (bool)reader["IsActive"];
                        if (reader["HookId"] != DBNull.Value)
                            HookId = (int)reader["HookId"];
                        OldLag = (int)reader["Lag"];
                    }
                }
            }

            int SubscriptionId = DbSchedule2.AddReminderSubscriptionPersonalForObject((int)dateType, Security.CurrentUser.UserID, ObjectId, Lag, IsActive);

            if (IsActive && !WasActive)	// Activation
            {
                HookId = DbSchedule2.AddHook((int)dateType, ObjectId, Lag, (int)DateTypeHandlers.SendReminder, ((int)SubscriptionTypes.PersonalForObject).ToString());
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, HookId);
            }
            else if (IsActive && WasActive && Lag != OldLag)	// Lag changed
            {
                DbSchedule2.UpdateHook(HookId, Lag);
            }
            else if (!IsActive && WasActive)	// Deactivation
            {
                DbSchedule2.UpdateReminderSubscriptionHookId(SubscriptionId, -1);
                DbSchedule2.DeleteHook(HookId);
            }
        }
示例#35
0
文件: Project.cs 项目: 0anion0/IBN
        internal static bool ConfirmReminder(DateTypes dateType, int objectId, bool hasRecurrence)
        {
            int stateId = DBProject.GetStatus(objectId);
            bool retval = Common.ConfirmReminder(
                hasRecurrence
                , (int)dateType
                , stateId
                , (int)DateTypes.Project_StartDate
                , (int)DateTypes.Project_FinishDate
                , (int)ProjectStatus.Pending
                , (int)ProjectStatus.Completed
                , (int)ProjectStatus.OnHold
                );

            // O.R. [2009-12-14]: Check Cancelled State
            if (retval)
                retval = Common.ConfirmReminder(
                hasRecurrence
                , (int)dateType
                , stateId
                , (int)DateTypes.Project_StartDate
                , (int)DateTypes.Project_FinishDate
                , (int)ProjectStatus.Pending
                , (int)ProjectStatus.Cancelled
                , (int)ProjectStatus.OnHold
                );

            return retval;
        }
示例#36
0
        internal static List<HistoryRecord> GetRecords(ServerInfo server, bool isServer, DateTypes dateType, DateTime startDate)
        {
            var records = new List<HistoryRecord>();
            var key = GetKey(server, isServer);
            using (var dateIndexStream = new FileStream(GetFile(false, true), FileMode.OpenOrCreate))
            {
                using (var dateContentStream = new FileStream(GetFile(false, false), FileMode.OpenOrCreate))
                {
                    var dateFormatter = new CustomBinaryFormatter(dateIndexStream, dateContentStream);
                    dateFormatter.Register<HistoryDate>(1);

                    var endDate = DateTime.Now.Date;
                    var samplingSpan = 1;
                    switch (dateType)
                    {
                        case DateTypes.Hour:
                            endDate = startDate.AddDays(1);
                            samplingSpan = 1;
                            break;
                        case DateTypes.Day:
                            endDate = startDate.AddDays(1);
                            samplingSpan = 24;
                            break;
                        case DateTypes.Week:
                            endDate = startDate.AddDays(7);
                            samplingSpan = 7 * 24;
                            break;
                        case DateTypes.Month:
                            endDate = startDate.AddMonths(1);
                            samplingSpan = 31 * 24;
                            break;
                        case DateTypes.Year:
                            endDate = startDate.AddYears(1);
                            samplingSpan = 365 * 24;
                            break;
                        default:
                            break;
                    }
                    var count = dateFormatter.Count;
                    Debug.WriteLine("all date count:" + count);
                    Debug.WriteLine("start date:" + startDate);
                    var dates = new List<HistoryDate>();
                    for (long i = 0; i < count; i++)
                    {
                        var date = dateFormatter.Deserialize<HistoryDate>(false);
                        var dateTime = DateTime.Parse(date.Date);
                        Debug.WriteLine("current date:" + dateTime);
                        if (startDate.Date <= dateTime && dateTime <= endDate)
                            dates.Add(date);
                    }
                    Debug.WriteLine("valid date count:" + dates.Count);
                    if (dates.Count > 0)
                    {
                        var start = dates.Aggregate((d1, d2) => DateTime.Parse(d1.Date) < DateTime.Parse(d2.Date) ? d1 : d2);
                        var end = dates.Aggregate((d1, d2) => DateTime.Parse(d1.Date) > DateTime.Parse(d2.Date) ? d1 : d2);

                        using (var dataIndexStream = new FileStream(GetFile(true, true), FileMode.OpenOrCreate))
                        {
                            using (var dataContentStream = new FileStream(GetFile(true, false), FileMode.OpenOrCreate))
                            {
                                var historyFormatter = new CustomBinaryFormatter(dataIndexStream, dataContentStream);
                                historyFormatter.Register<HistoryRecord>(1);

                                for (var i = start.Index; i < end.Index; i += samplingSpan)
                                {
                                    historyFormatter.MoveTo(i);
                                    var record = historyFormatter.Deserialize<HistoryRecord>(false);
                                    if (record.Key == key)
                                        records.Add(record);
                                }
                                historyFormatter.Close();
                                dataContentStream.Close();
                            }
                            dataIndexStream.Close();
                        }
                    }
                    dateFormatter.Close();
                    dateContentStream.Close();
                }
                dateIndexStream.Close();
            }
            return records;
        }
示例#37
0
 public void FilterReset()
 {
     DateType = DateTypes.MTD;
     FireFilterChanged();
 }
示例#38
0
文件: Schedule2.cs 项目: 0anion0/IBN
        private static void SendReminder(DateTypes dateType, ObjectTypes objecType, int? objectId, Guid? objectUid, List<int> users)
        {
            // TODO: Step 0. Check Security (Not implemented yet)

            // Step 1. Calculate variables
            foreach (int userId in users)
            {
                int reminderType = 0;

                using (IDataReader reader = User.GetUserPreferences(userId))
                {
                    if (reader.Read())
                        reminderType = (int)reader["ReminderType"];
                }

                if (reminderType != 0)
                {
                    // Step 2. Get Message Template
                    ReminderTemplate tmpl = Reminder.GetMessageTemplate(dateType, User.GetUserLanguage(userId));

                    // Step 2.1. Calculate Variables
                    ArrayList vars = new ArrayList();

                    Alerts2.GetObjectVariables(objecType, objectId, objectUid, false, Reminder.GetVariables(dateType), vars);

                    // Step 3. Replace variables and GetMessage
                    Alerts2.Message msg = Reminder.GetMessage(tmpl, objectId, objectUid, objecType, userId, (VariableInfo[])vars.ToArray(typeof(VariableInfo)));

                    // Step 4. Save to log
                    using (DbTransaction tran = DbTransaction.Begin())
                    {
                        int logId = DbAlert2.MessageLogAdd(msg.Subject, msg.Body);
                        DBSystemEvents.RecipientUpdateSend(userId, (reminderType & 1) != 0, PortalConfig.UseIM && (reminderType & 2) != 0, logId); // IsNotifiedByEmail, IsNotifiedByIBN

                        tran.Commit();
                    }

                    #region -- Send via Email --
                    // Step 5. Send via Email
                    try
                    {
                        if ((reminderType & 1) != 0)//IsNotifiedByEmail
                        {
                            string body = "<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\" /></head><body>" + msg.Body + "</body></html>";

                            using (DbTransaction tran = DbTransaction.Begin())
                            {
                                Alerts2.SendMessage(DeliveryType.Email, Reminder.GetAddress(DeliveryType.Email, userId), body, msg.Subject);

                                DBSystemEvents.RecipientUpdateSent(userId, (int)DeliveryType.Email, true);

                                tran.Commit();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.WriteError(ex.ToString());
                    }
                    #endregion

                    #region -- Send via IM --
                    // Step 6. Send via IM
                    try
                    {
                        if ((reminderType & 2) != 0)//uInfo != null && uInfo.IsNotifiedByIBN)
                        {
                            using (DbTransaction tran = DbTransaction.Begin())
                            {
                                Alerts2.SendMessage(DeliveryType.IBN, Reminder.GetAddress(DeliveryType.IBN, userId), msg.Body, msg.Subject);

                                DBSystemEvents.RecipientUpdateSent(userId, (int)DeliveryType.IBN, true);

                                tran.Commit();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.WriteError(ex.ToString());
                    }
                    #endregion
                }
            }
        }
示例#39
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static void UpdateDateTypeValue(DateTypes dateType, Guid objectUid, DateTime dateValue)
 {
     UpdateDateTypeValue((int)dateType, null, objectUid, dateValue);
 }
示例#40
0
文件: Schedule2.cs 项目: 0anion0/IBN
        private static void ProcessGlobalSubscription(int hookId, DateTypes dateType, ObjectTypes objectType, int? objectId, Guid? objectUid)
        {
            // Формируем список пользователей, связанных с объектом
            List<int> users = new List<int>();

            if (objectType == ObjectTypes.Project)
            {
                using (IDataReader reader = DBProject.GetProjectSecurity(objectId.Value))
                {
                    while (reader.Read())
                        users.Add((int)reader["UserId"]);
                }
            }
            else if (objectType == ObjectTypes.Task)
            {
                using (IDataReader reader = DBTask.GetTaskSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        if ((bool)reader["IsRealTaskResource"] || (bool)reader["IsRealTaskManager"] || (bool)reader["IsCreator"])
                            users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.ToDo)
            {
                using (IDataReader reader = DBToDo.GetToDoSecurity(objectId.Value))
                {
                    while (reader.Read())
                        users.Add((int)reader["UserId"]);
                }
            }
            else if (objectType == ObjectTypes.CalendarEntry)
            {
                using (IDataReader reader = DBEvent.GetListUsersForEvent(objectId.Value))
                {
                    while (reader.Read())
                        users.Add((int)reader["UserId"]);
                }
            }
            else if (objectType == ObjectTypes.Document)
            {
                using (IDataReader reader = DBDocument.GetDocumentSecurity(objectId.Value))
                {
                    while (reader.Read())
                        users.Add((int)reader["UserId"]);
                }
            }
            else if (objectType == ObjectTypes.Assignment)
            {
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value);
                if (entity != null && entity.OwnerDocumentId.HasValue)
                {
                    using (IDataReader reader = DBDocument.GetDocumentSecurity(entity.OwnerDocumentId.Value))
                    {
                        while (reader.Read())
                            users.Add((int)reader["UserId"]);
                    }
                }
            }

            // Проверим отсутствие индивидуальной подписки
            for (int i = 0; i < users.Count; i++)
            {
                int userId = users[i];

                // O.R. [2010-04-01]: Don't process inactive users
                if (User.GetUserActivity(userId) != User.UserActivity.Active)
                {
                    users.RemoveAt(i);
                    i--;
                }
                else if (objectId.HasValue)
                {
                    if (GetSubscriptionType(dateType, userId, objectId.Value) != SubscriptionTypes.Global)
                    {
                        users.RemoveAt(i);
                        i--;
                    }
                }
            }

            // Send Reminder
            if (users.Count > 0)
                SendReminder(dateType, objectType, objectId, objectUid, users);
        }
示例#41
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static void UpdateDateTypeValue(DateTypes dateType, int objectId, DateTime dateValue)
 {
     UpdateDateTypeValue((int)dateType, objectId, null, dateValue);
 }
示例#42
0
 internal static bool ConfirmReminder(DateTypes dateType, int objectId, bool hasRecurrence)
 {
     int stateId = DBEvent.GetState(objectId);
     return Common.ConfirmReminder(
         hasRecurrence
         , (int)dateType
         , stateId
         , (int)DateTypes.CalendarEntry_StartDate
         , (int)DateTypes.CalendarEntry_FinishDate
         , (int)ObjectStates.Upcoming
         , (int)ObjectStates.Completed
         , (int)ObjectStates.Suspended
         );
 }
示例#43
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static SubscriptionTypes GetSubscriptionType(DateTypes dateType, int UserId, int ObjectId)
 {
     SubscriptionTypes SubscriptionType = SubscriptionTypes.UNDEFINED;
     using (IDataReader reader = DbSchedule2.GetReminderSubscriptionPersonalForObject((int)dateType, UserId, ObjectId))
     {
         if (reader.Read())
             SubscriptionType = (SubscriptionTypes)((int)reader["SubscriptionType"]);
     }
     return SubscriptionType;
 }
示例#44
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static void DeleteDateTypeValue(DateTypes dateType, Guid objectUid)
 {
     DeleteDateTypeValue((int)dateType, null, objectUid);
 }
示例#45
0
文件: Schedule2.cs 项目: 0anion0/IBN
 /// <summary>
 /// Reader returns fields:
 ///  SubscriptionId, DateTypeId, UserId, ObjectId, Lag, IsActive, HookId, SubscriptionType 
 /// </summary>
 /// <returns></returns>
 public static IDataReader GetReminderSubscriptionPersonalForObject(DateTypes DateType, int ObjectId)
 {
     return DbSchedule2.GetReminderSubscriptionPersonalForObject((int)DateType, Security.CurrentUser.UserID, ObjectId);
 }
示例#46
0
 public static void UpdateDateTypeValue(DateTypes dateType, int objectId, DateTime dateValue)
 {
     UpdateDateTypeValue((int)dateType, objectId, null, dateValue);
 }
示例#47
0
        internal static List <HistoryRecord> GetRecords(ServerInfo server, bool isServer, DateTypes dateType, DateTime startDate)
        {
            var records = new List <HistoryRecord>();
            var key     = GetKey(server, isServer);

            using (var dateIndexStream = new FileStream(GetFile(false, true), FileMode.OpenOrCreate))
            {
                using (var dateContentStream = new FileStream(GetFile(false, false), FileMode.OpenOrCreate))
                {
                    var dateFormatter = new CustomBinaryFormatter(dateIndexStream, dateContentStream);
                    dateFormatter.Register <HistoryDate>(1);

                    var endDate      = DateTime.Now.Date;
                    var samplingSpan = 1;
                    switch (dateType)
                    {
                    case DateTypes.Hour:
                        endDate      = startDate.AddDays(1);
                        samplingSpan = 1;
                        break;

                    case DateTypes.Day:
                        endDate      = startDate.AddDays(1);
                        samplingSpan = 24;
                        break;

                    case DateTypes.Week:
                        endDate      = startDate.AddDays(7);
                        samplingSpan = 7 * 24;
                        break;

                    case DateTypes.Month:
                        endDate      = startDate.AddMonths(1);
                        samplingSpan = 31 * 24;
                        break;

                    case DateTypes.Year:
                        endDate      = startDate.AddYears(1);
                        samplingSpan = 365 * 24;
                        break;

                    default:
                        break;
                    }
                    var count = dateFormatter.Count;
                    Debug.WriteLine("all date count:" + count);
                    Debug.WriteLine("start date:" + startDate);
                    var dates = new List <HistoryDate>();
                    for (long i = 0; i < count; i++)
                    {
                        var date     = dateFormatter.Deserialize <HistoryDate>(false);
                        var dateTime = DateTime.Parse(date.Date);
                        Debug.WriteLine("current date:" + dateTime);
                        if (startDate.Date <= dateTime && dateTime <= endDate)
                        {
                            dates.Add(date);
                        }
                    }
                    Debug.WriteLine("valid date count:" + dates.Count);
                    if (dates.Count > 0)
                    {
                        var start = dates.Aggregate((d1, d2) => DateTime.Parse(d1.Date) < DateTime.Parse(d2.Date) ? d1 : d2);
                        var end   = dates.Aggregate((d1, d2) => DateTime.Parse(d1.Date) > DateTime.Parse(d2.Date) ? d1 : d2);

                        using (var dataIndexStream = new FileStream(GetFile(true, true), FileMode.OpenOrCreate))
                        {
                            using (var dataContentStream = new FileStream(GetFile(true, false), FileMode.OpenOrCreate))
                            {
                                var historyFormatter = new CustomBinaryFormatter(dataIndexStream, dataContentStream);
                                historyFormatter.Register <HistoryRecord>(1);

                                for (var i = start.Index; i < end.Index; i += samplingSpan)
                                {
                                    historyFormatter.MoveTo(i);
                                    var record = historyFormatter.Deserialize <HistoryRecord>(false);
                                    if (record.Key == key)
                                    {
                                        records.Add(record);
                                    }
                                }
                                historyFormatter.Close();
                                dataContentStream.Close();
                            }
                            dataIndexStream.Close();
                        }
                    }
                    dateFormatter.Close();
                    dateContentStream.Close();
                }
                dateIndexStream.Close();
            }
            return(records);
        }
示例#48
0
 public static void UpdateDateTypeValue(DateTypes dateType, Guid objectUid, DateTime dateValue)
 {
     UpdateDateTypeValue((int)dateType, null, objectUid, dateValue);
 }
示例#49
0
文件: Schedule2.cs 项目: 0anion0/IBN
 /// <summary>
 /// Reader returns fields:
 ///  SubscriptionId, DateTypeId, UserId, ObjectId, ObjectUid, Lag, IsActive, HookId 
 /// </summary>
 /// <returns></returns>
 public static IDataReader GetReminderSubscriptionGlobal(DateTypes DateType)
 {
     return DbSchedule2.GetReminderSubscriptionGlobal((int)DateType);
 }
示例#50
0
 public static void DeleteDateTypeValue(DateTypes dateType, int objectId)
 {
     DeleteDateTypeValue((int)dateType, objectId, null);
 }
示例#51
0
        // Funciones del programador
        private String GetDate(DateTypes DateType)
        {
            String sReturnDate = "";

            try
            {

                // Fecha en formato universal
                sReturnDate = this.txtCanvas.Text.Split(new Char[] { '/' })[2] + "-" + this.txtCanvas.Text.Split(new Char[] { '/' })[1] + "-" + this.txtCanvas.Text.Split(new Char[] { '/' })[0];

                // Hora, minuto y segundo
                switch (DateType)
                {
                    case DateTypes.BeginDate:
                        sReturnDate = sReturnDate + " " + "00:00";
                        break;

                    case DateTypes.EndDate:
                        sReturnDate = sReturnDate + " " + "23:59";
                        break;
                }

            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return sReturnDate;
        }
示例#52
0
文件: Reminder.cs 项目: 0anion0/IBN
        /// <summary>
        /// Gets the message template.
        /// </summary>
        /// <param name="dateType">Type of the date.</param>
        /// <param name="objecTypeId">The objec type id.</param>
        /// <param name="languageId">The language id.</param>
        /// <returns></returns>
        public static ReminderTemplate GetMessageTemplate(DateTypes dateType, int languageId)
        {
            ReminderTemplate retVal = null;

            retVal = new ReminderTemplate(dateType, languageId);
            retVal.Load();

            return retVal;
        }
示例#53
0
        private static void SendReminder(DateTypes dateType, ObjectTypes objecType, int?objectId, Guid?objectUid, List <int> users)
        {
            // TODO: Step 0. Check Security (Not implemented yet)

            // Step 1. Calculate variables
            foreach (int userId in users)
            {
                int reminderType = 0;

                using (IDataReader reader = User.GetUserPreferences(userId))
                {
                    if (reader.Read())
                    {
                        reminderType = (int)reader["ReminderType"];
                    }
                }

                if (reminderType != 0)
                {
                    // Step 2. Get Message Template
                    ReminderTemplate tmpl = Reminder.GetMessageTemplate(dateType, User.GetUserLanguage(userId));

                    // Step 2.1. Calculate Variables
                    ArrayList vars = new ArrayList();

                    Alerts2.GetObjectVariables(objecType, objectId, objectUid, false, Reminder.GetVariables(dateType), vars);

                    // Step 3. Replace variables and GetMessage
                    Alerts2.Message msg = Reminder.GetMessage(tmpl, objectId, objectUid, objecType, userId, (VariableInfo[])vars.ToArray(typeof(VariableInfo)));

                    // Step 4. Save to log
                    using (DbTransaction tran = DbTransaction.Begin())
                    {
                        int logId = DbAlert2.MessageLogAdd(msg.Subject, msg.Body);
                        DBSystemEvents.RecipientUpdateSend(userId, (reminderType & 1) != 0, PortalConfig.UseIM && (reminderType & 2) != 0, logId);                         // IsNotifiedByEmail, IsNotifiedByIBN

                        tran.Commit();
                    }

                    #region -- Send via Email --
                    // Step 5. Send via Email
                    try
                    {
                        if ((reminderType & 1) != 0)                        //IsNotifiedByEmail
                        {
                            string body = "<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\" /></head><body>" + msg.Body + "</body></html>";

                            using (DbTransaction tran = DbTransaction.Begin())
                            {
                                Alerts2.SendMessage(DeliveryType.Email, Reminder.GetAddress(DeliveryType.Email, userId), body, msg.Subject);

                                DBSystemEvents.RecipientUpdateSent(userId, (int)DeliveryType.Email, true);

                                tran.Commit();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.WriteError(ex.ToString());
                    }
                    #endregion

                    #region -- Send via IM --
                    // Step 6. Send via IM
                    try
                    {
                        if ((reminderType & 2) != 0)                        //uInfo != null && uInfo.IsNotifiedByIBN)
                        {
                            using (DbTransaction tran = DbTransaction.Begin())
                            {
                                Alerts2.SendMessage(DeliveryType.IBN, Reminder.GetAddress(DeliveryType.IBN, userId), msg.Body, msg.Subject);

                                DBSystemEvents.RecipientUpdateSent(userId, (int)DeliveryType.IBN, true);

                                tran.Commit();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.WriteError(ex.ToString());
                    }
                    #endregion
                }
            }
        }
示例#54
0
文件: Schedule2.cs 项目: 0anion0/IBN
        private static void ProcessPersonalSubscription(int hookId, DateTypes dateType, int userId, ObjectTypes objectType, int? objectId, Guid? objectUid)
        {
            // Проверим отсутствие индивидуальной подписки
            if (objectId.HasValue && GetSubscriptionType(dateType, userId, objectId.Value) != SubscriptionTypes.Personal)
                return;

            // Check Security
            if (objectId.HasValue && !CheckSecurityForObject(objectType, objectId.Value, userId))
                return;
            if (objectUid.HasValue && !CheckSecurityForObject(objectType, objectUid.Value, userId))
                return;

            // Send Reminder
            List<int> users = new List<int>();
            users.Add(userId);
            SendReminder(dateType, objectType, objectId, objectUid, users);
        }
示例#55
0
        private void SelectValue(DropDownList ddl, DateTypes DateType)
        {
            ddl.ClearSelection();

            using (IDataReader reader = Schedule.GetReminderSubscriptionGlobal(DateType))
            {
                ///  SubscriptionId, DateTypeId, UserId, ObjectId, Lag, IsActive, HookId
                if (reader.Read())
                {
                    if ((bool)reader["IsActive"])
                        Util.CommonHelper.SafeSelect(ddl, reader["Lag"].ToString());
                }
            }
        }
示例#56
0
文件: Schedule2.cs 项目: 0anion0/IBN
 public static void DeleteDateTypeValue(DateTypes dateType, int objectId)
 {
     DeleteDateTypeValue((int)dateType, objectId, null);
 }