Ejemplo n.º 1
0
        /// <summary>
        /// Loads the specified incident box id.
        /// </summary>
        /// <param name="IncidentBoxId">The incident box id.</param>
        /// <returns></returns>
        public static IncidentBoxDocument  Load(int IncidentBoxId)
        {
            IncidentBoxDocument retVal = new IncidentBoxDocument(IncidentBoxId);

            IncidentBoxRow row = IncidentBoxRow.Load(IncidentBoxId);

            if (row.Document != string.Empty)
            {
                retVal.Load(row.Document);
            }

            return(retVal);
        }
Ejemplo n.º 2
0
 public static IncidentBox Load(int IncidentBoxId)
 {
     return(new IncidentBox(IncidentBoxRow.Load(IncidentBoxId)));
 }
Ejemplo n.º 3
0
        public static void Save(IncidentBoxDocument document)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                IncidentBoxRow row = IncidentBoxRow.Load(document.OwnerIncidentBoxId);

                IncidentBoxDocument prevDocument = IncidentBoxDocument.Load(document.OwnerIncidentBoxId, row.Document);

                row.Document = document.GetDocumentString();

                row.ManagerId = document.GeneralBlock.Manager;

                if (document.GeneralBlock.AllowControl)
                {
                    if (document.GeneralBlock.ControllerAssignType == ControllerAssignType.CustomUser)
                    {
                        row.ControllerId = document.GeneralBlock.Controller;
                    }

                    if (document.GeneralBlock.ControllerAssignType == ControllerAssignType.Manager)
                    {
                        row.ControllerId = document.GeneralBlock.Manager;
                    }

                    if (document.GeneralBlock.ControllerAssignType == ControllerAssignType.Creator)
                    {
                        row.ControllerId = 0;
                    }
                }
                else
                {
                    row.ControllerId = -1;
                }

                row.CalendarId           = document.GeneralBlock.CalendarId;
                row.ExpectedDuration     = document.GeneralBlock.ExpectedDuration;
                row.ExpectedResponseTime = document.GeneralBlock.ExpectedResponseTime;
                row.ExpectedAssignTime   = document.GeneralBlock.ExpectedAssignTime;
                row.TaskTime             = document.GeneralBlock.TaskTime;

                row.Update();

                // Find Real Update
                if (prevDocument.GeneralBlock.AllowControl && !document.GeneralBlock.AllowControl)
                {
                    // Turn OffControling
                    Incident.RaiseTurnOffControling(document.OwnerIncidentBoxId);
                }
                else if (document.GeneralBlock.AllowControl)
                {
                    if (prevDocument.GeneralBlock.Manager != document.GeneralBlock.Manager &&
                        document.GeneralBlock.ControllerAssignType == ControllerAssignType.Manager)
                    {
                        Incident.RaiseChangeController(document.OwnerIncidentBoxId,
                                                       prevDocument.GeneralBlock.Manager,
                                                       document.GeneralBlock.Manager);
                    }
                    else if (document.GeneralBlock.ControllerAssignType == ControllerAssignType.CustomUser &&
                             prevDocument.GeneralBlock.Controller != document.GeneralBlock.Controller)
                    {
                        Incident.RaiseChangeController(document.OwnerIncidentBoxId,
                                                       prevDocument.GeneralBlock.Controller,
                                                       document.GeneralBlock.Controller);
                    }
                }

                if (prevDocument.GeneralBlock.Manager != document.GeneralBlock.Manager)
                {
                    Incident.RaiseChangeManager(document.OwnerIncidentBoxId, prevDocument.GeneralBlock.Manager, document.GeneralBlock.Manager);
                }
                tran.Commit();
            }
        }