Example #1
0
        public static void AcceptResource(int todoId)
        {
            int userId = Security.CurrentUser.UserID;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DbTodo2.ResourceReply(todoId, userId, true);

                SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_ResourceList_RequestAccepted, todoId, userId);

                tran.Commit();
            }
        }
Example #2
0
        public static void DeclineResource(int todoId)
        {
            UserLight cu      = Security.CurrentUser;
            int       UserId  = cu.UserID;
            DateTime  utc_now = DateTime.UtcNow;

            int    CompletionTypeId;
            bool   IsManagerConfirmed;
            bool   IsCompleted;
            int    ReasonId;
            int    IncidentId          = -1;
            int    DocumentId          = -1;
            int    TaskId              = -1;
            bool   CompleteIncident    = false;
            bool   CompleteTask        = false;
            bool   CompleteDocument    = false;
            int    oldPercentCompleted = 0;
            string title = "";

            using (IDataReader reader = DBToDo.GetToDo(todoId, cu.TimeZoneId, cu.LanguageId))
            {
                reader.Read();
                CompletionTypeId   = (int)reader["CompletionTypeId"];
                IsManagerConfirmed = (bool)reader["MustBeConfirmed"];
                IsCompleted        = (bool)reader["IsCompleted"];
                ReasonId           = (int)reader["ReasonId"];
                if (reader["IncidentId"] != DBNull.Value)
                {
                    IncidentId = (int)reader["IncidentId"];
                }
                if (reader["DocumentId"] != DBNull.Value)
                {
                    DocumentId = (int)reader["DocumentId"];
                }
                if (reader["TaskId"] != DBNull.Value)
                {
                    TaskId = (int)reader["TaskId"];
                }
                if (reader["CompleteIncident"] != DBNull.Value)
                {
                    CompleteIncident = (bool)reader["CompleteIncident"];
                }
                if (reader["CompleteTask"] != DBNull.Value)
                {
                    CompleteTask = (bool)reader["CompleteTask"];
                }
                if (reader["CompleteDocument"] != DBNull.Value)
                {
                    CompleteDocument = (bool)reader["CompleteDocument"];
                }
                oldPercentCompleted = (int)reader["PercentCompleted"];
                title = reader["Title"].ToString();
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DbTodo2.ResourceReply(todoId, UserId, false);

                // O.R. [2009-02-12]
                DBCalendar.DeleteStickedObject((int)OBJECT_TYPE, todoId, UserId);

                SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_ResourceList_RequestDenied, todoId, UserId);

                if (CompletionTypeId == (int)CompletionType.All)
                {
                    int OverallPercent = ToDo.RecalculateOverallPercent(todoId);

                    if (oldPercentCompleted != OverallPercent)
                    {
                        DBToDo.UpdatePercent(todoId, OverallPercent);
                        SystemEvents.AddSystemEvents(SystemEventTypes.Todo_Updated_Percent, todoId);
                    }

                    if (!IsCompleted && !IsManagerConfirmed && OverallPercent == 100)
                    {
                        DBToDo.UpdateCompletion(todoId, true, (int)CompletionReason.CompletedAutomatically);

                        if (TaskId > 0 && CompleteTask)
                        {
                            ToDo.UpdateTaskCompletion(TaskId);
                        }

                        if (DocumentId > 0 && CompleteDocument)
                        {
                            ToDo.UpdateDocumentCompletion(DocumentId);
                        }

                        if (IncidentId > 0 && CompleteIncident)
                        {
                            ToDo.CompleteIncidentIfNeed(IncidentId);
                        }

                        ToDo.RecalculateState(todoId);
                    }
                }

                tran.Commit();
            }
        }