Beispiel #1
0
        /// <summary>
        /// Lists the with rules.
        /// </summary>
        /// <returns></returns>
        public static IncidentBox[] ListWithoutRules()
        {
            ArrayList retVal = new ArrayList();

            foreach (IncidentBoxRow row in IncidentBoxRow.ListWithoutRules())
            {
                retVal.Add(new IncidentBox(row));
            }

            return((IncidentBox[])retVal.ToArray(typeof(IncidentBox)));
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public static int Create(string Name, string IdentifierMask, bool IsDefault, int Index)
        {
            if (!CanModify())
            {
                throw new AccessDeniedException();
            }


            try
            {
                IncidentBoxRow row = new IncidentBoxRow();

                row.Name           = Name;
                row.IdentifierMask = IdentifierMask;
                row.IsDefault      = IsDefault;
                row.Index          = Index;

                row.Update();

                // Create Default IncidentBoxDocument
                IncidentBoxDocument doc = IncidentBoxDocument.Load(row.PrimaryKeyId);

                doc.GeneralBlock.Manager     = Security.CurrentUser.UserID;
                doc.GeneralBlock.Responsible = Security.CurrentUser.UserID;

                IncidentBoxDocument.Save(doc);

                return(row.PrimaryKeyId);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                if (ex.Message.IndexOf("'IX_IncidentBox_1'") != -1)
                {
                    throw new IncidentBoxDuplicateIdentifierMaskException();
                }
                else if (ex.Message.IndexOf("'IX_IncidentBox'") != -1)
                {
                    throw new IncidentBoxDuplicateNameException();
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #4
0
        public static void Delete(int IncidentBoxId)
        {
            if (!CanModify())
            {
                throw new AccessDeniedException();
            }

            using (Database.DbTransaction tran = Database.DbTransaction.Begin())
            {
//				using(IDataReader reader = Incident.GetListIncidentsByIncidentBox(IncidentBoxId))
//				{
//					while(reader.Read())
//					{
//						int IncidentId = (int)reader["IncidentId"];
//						Incident.Delete(IncidentId, true, false);
//					}
//				}

                IncidentBoxRow.Delete(IncidentBoxId);

                tran.Commit();
            }
        }
Beispiel #5
0
 /// <summary>
 /// Determines whether this instance can delete.
 /// </summary>
 /// <returns>
 ///     <c>true</c> if this instance can delete; otherwise, <c>false</c>.
 /// </returns>
 public static bool CanDelete(int IncidentBoxId)
 {
     return(IncidentBoxRow.CanDelete(IncidentBoxId));
 }
Beispiel #6
0
 private IncidentBox(IncidentBoxRow row)
 {
     _srcRow = row;
 }
Beispiel #7
0
 public static IncidentBox Load(int IncidentBoxId)
 {
     return(new IncidentBox(IncidentBoxRow.Load(IncidentBoxId)));
 }
Beispiel #8
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();
            }
        }