Esempio n. 1
0
        internal static void UpdateManager(int documentId, int managerId, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(documentId);
            }

            int oldManagerId = DBDocument.GetManager(documentId);

            if (oldManagerId != managerId)
            {
                using (DbTransaction tran = DbTransaction.Begin())
                {
                    DbDocument2.UpdateManager(documentId, managerId);

                    // TODO: implement Document_Updated_Manager
                    // SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_Manager, documentId);

                    // OZ: User Role Addon
                    if (managerId != oldManagerId)
                    {
                        UserRoleHelper.DeleteDocumentManagerRole(documentId, oldManagerId);
                        UserRoleHelper.AddDocumentManagerRole(documentId, managerId);
                    }
                    // end OZ

                    tran.Commit();
                }
            }
        }
Esempio n. 2
0
        public static void DeclineResource(int documentId)
        {
            int userId = Security.CurrentUser.UserID;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DbDocument2.ResourceReply(documentId, userId, false);

                SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_ResourceList_RequestDenied, documentId, userId);

                tran.Commit();
            }
        }
Esempio n. 3
0
        internal static void UpdateGeneralInfo(int documentId, string title, string description, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(documentId);
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DbDocument2.UpdateGeneralInfo(documentId, title, description);
                SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_GeneralInfo, documentId);

                tran.Commit();
            }
        }
Esempio n. 4
0
        internal static void UpdateStatus(int documentId, int statusId, bool checkAccess)
        {
            if (checkAccess && !Document.CanUpdateStatus(documentId))
            {
                throw new AccessDeniedException();
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                if (0 < DbDocument2.UpdateStatus(documentId, statusId))
                {
                    SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_Status, documentId);
                }

                tran.Commit();
            }
        }
Esempio n. 5
0
        internal static void UpdatePriority(int documentId, int priorityId, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(documentId);
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                if (0 < DbDocument2.UpdatePriority(documentId, priorityId))
                {
                    SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_Priority, documentId);
                }

                tran.Commit();
            }
        }
Esempio n. 6
0
        internal static void UpdateClient(int DocumentId, PrimaryKeyId ContactUid, PrimaryKeyId OrgUid, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(DocumentId);
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                if (0 < DbDocument2.UpdateClient(DocumentId, ContactUid == PrimaryKeyId.Empty ? null : (object)ContactUid, OrgUid == PrimaryKeyId.Empty ? null : (object)OrgUid))
                {
                    // TODO:
                    //SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_Client, projectId);
                }

                tran.Commit();
            }
        }
Esempio n. 7
0
        internal static void UpdateTimeLine(int documentId, int taskTime, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(documentId);
            }

            int projectId = Document.GetProject(documentId);

            using (DbTransaction tran = DbTransaction.Begin())
            {
                // O.R TODO: SystemEvent [2/28/2006]
                if (DbDocument2.UpdateTimeline(documentId, taskTime) > 0)
                {
                    // O.R: Recalculating project TaskTime
                    if (projectId > 0)
                    {
                        TimeTracking.RecalculateProjectTaskTime(projectId);
                    }
                }

                tran.Commit();
            }
        }
Esempio n. 8
0
        private static void UpdateListResources(int objectId, DataTable items, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(objectId);
            }

            int managerId = -1;

            using (IDataReader reader = DBDocument.GetDocument(objectId, Security.CurrentUser.TimeZoneId, Security.CurrentUser.LanguageId))
            {
                reader.Read();
                managerId = (int)reader["ManagerId"];
            }

            ArrayList oldItems = new ArrayList();

            using (IDataReader reader = DBDocument.GetListResources(objectId, Security.CurrentUser.TimeZoneId))
            {
                Common.LoadPrincipals(reader, oldItems);
            }

            ArrayList add = new ArrayList();
            ArrayList del = new ArrayList();

            foreach (DataRow row in items.Rows)
            {
                int id = (int)row["PrincipalId"];
                if (oldItems.Contains(id))
                {
                    oldItems.Remove(id);
                }
                else
                {
                    add.Add(id);
                }
            }

            del.AddRange(oldItems);

            using (DbTransaction tran = DbTransaction.Begin())
            {
                foreach (int id in del)
                {
                    DBCommon.DeleteGate((int)OBJECT_TYPE, objectId, id);
                    DBDocument.DeleteResource(objectId, id);

                    // OZ: User Role Addon
                    UserRoleHelper.DeleteDocumentResourceRole(objectId, id);
                    if (id != managerId)
                    {
                        UserRoleHelper.DeleteDocumentManagerRole(objectId, id);
                    }
                    //
                    SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_ResourceList_AssignmentDeleted, objectId, id);
                }

                foreach (DataRow row in items.Rows)
                {
                    int  id = (int)row["PrincipalId"];
                    bool mustBeConfirmed = (bool)row["MustBeConfirmed"];
                    bool canManage       = (bool)row["CanManage"];
                    bool updated         = true;

                    if (add.Contains(id))
                    {
                        DbDocument2.ResourceAdd(objectId, id, mustBeConfirmed, canManage);
                        if (User.IsExternal(id))
                        {
                            DBCommon.AddGate((int)OBJECT_TYPE, objectId, id);
                        }
                    }
                    else
                    {
                        updated = (0 < DbDocument2.ResourceUpdate(objectId, id, mustBeConfirmed, canManage));
                    }

                    // OZ: User Role Addon
                    if (canManage)
                    {
                        if (id != managerId)
                        {
                            UserRoleHelper.AddDocumentManagerRole(objectId, id);
                        }
                    }
                    else
                    {
                        UserRoleHelper.AddDocumentResourceRole(objectId, id);
                    }
                    // end

                    if (updated)
                    {
                        if (mustBeConfirmed)
                        {
                            SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_ResourceList_RequestAdded, objectId, id);
                        }
                        else
                        {
                            SystemEvents.AddSystemEvents(SystemEventTypes.Document_Updated_ResourceList_AssignmentAdded, objectId, id);
                        }
                    }
                }

                tran.Commit();
            }
        }