Ejemplo n.º 1
0
        public static void PickUp(ApiUser User, int TktId, string NoteText)
        {
            var _tktOld = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);

            if (_tktOld.TechnicianType == Logins.UserType.Queue) //Queue PickUp
            {
                UpdateTechnician(User.OrganizationId, User.DepartmentId, TktId, User.UserId, false);
                InsertLogMessage(User.OrganizationId, User.DepartmentId, TktId, User.UserId, "Queue Pickup", NoteText, "Picked Up from " + _tktOld.TechnicianFirstName + " " + _tktOld.TechnicianLastName + " by " + User.FullName);
                var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);
                NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.PickUpTicket, _tktNew, _tktOld, 0, DateTime.MinValue, null);
            }
            else
            {
                Ticket.UpdateTechnician(User.OrganizationId, User.DepartmentId, TktId, User.UserId, true);
                if (_tktOld.TicketStatus == Status.OnHold)
                {
                    Ticket.UpdateStatus(User.OrganizationId, User.DepartmentId, TktId, Ticket.Status.Open);
                }
                CustomNames _cNames          = CustomNames.GetCustomNames(User.OrganizationId, User.DepartmentId);
                string      sysGeneratedText = User.FullName + " picked up this " + _cNames.Ticket.FullSingular + " from " + _tktOld.TechnicianFirstName + " " + _tktOld.TechnicianLastName;
                sysGeneratedText += "<br>This " + _cNames.Ticket.FullSingular + " was transferred by choosing route by " + _cNames.Technician.FullSingular + ".";
                if (_tktOld.TicketStatus == Status.OnHold)
                {
                    sysGeneratedText += "<br>This " + _cNames.Ticket.FullSingular + " was set back to \"Open\" staus from \"On Hold\" status.";
                }
                InsertLogMessage(User.OrganizationId, User.DepartmentId, TktId, User.UserId, "Transfer", NoteText, sysGeneratedText);
                var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);
                NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.TransferTicket, _tktNew, _tktOld, 0, DateTime.MinValue, null);
            }
        }
Ejemplo n.º 2
0
        public static void OnHold(ApiUser User, int TktId, string NoteText)
        {
            var _tktOld = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);

            InsertResponse(User.OrganizationId, User.DepartmentId, TktId, User.UserId, false, false, true, NoteText, string.Empty, 0, string.Empty, false);
            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.PlaceOnHoldTicket, new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true), _tktOld, 0, DateTime.MinValue, null);
        }
Ejemplo n.º 3
0
        public static void OnHold(ApiUser User, int TktId, string NoteText)
        {
            Config      _cfg    = new Config(User.OrganizationId, User.DepartmentId);
            CustomNames _cNames = CustomNames.GetCustomNames(User.OrganizationId, User.DepartmentId);

            if (!_cfg.OnHoldStatus)
            {
                throw new HttpError("On Hold " + _cNames.Ticket.fullSingular + " statuses are not enabled for this instance.");
            }

            var _tktOld = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);

            InsertResponse(User.OrganizationId, User.DepartmentId, TktId, User.UserId, false, false, true, NoteText, string.Empty, 0, string.Empty, false);
            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.PlaceOnHoldTicket, new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true), _tktOld, 0, DateTime.MinValue, null);
        }
Ejemplo n.º 4
0
        public static void TransferToTech(ApiUser User, int TktId, int TechId, string NoteText, bool KeepTechAttached)
        {
            DataRow _row = Logins.SelectUserDetails(User.OrganizationId, User.DepartmentId, TechId);

            if (_row == null)
            {
                throw new HttpError("The user account Id=" + TechId.ToString() + " is not associated with this Department.");
            }

            string      techFullName = _row["FirstName"].ToString() + " " + _row["LastName"].ToString();
            CustomNames _cNames      = CustomNames.GetCustomNames(User.OrganizationId, User.DepartmentId);

            if ((int)_row["UserType_Id"] != 2 && (int)_row["UserType_Id"] != 3)
            {
                throw new HttpError("User " + techFullName + " is not " + _cNames.Technician.FullSingular + " or Administrator.");
            }

            var _tktOld = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);

            UpdateTechnician(User.OrganizationId, User.DepartmentId, TktId, TechId, KeepTechAttached);
            if (_tktOld.TicketStatus == Status.OnHold)
            {
                UpdateStatus(User.OrganizationId, User.DepartmentId, TktId, Status.Open);
            }
            string sysGeneratedText = User.FullName;

            if (TechId == User.UserId)
            {
                sysGeneratedText += " picked up this " + _cNames.Ticket.FullSingular + " from " + _tktOld.TechnicianFirstName + " " + _tktOld.TechnicianLastName;
            }
            else
            {
                sysGeneratedText += " transfered this " + _cNames.Ticket.FullSingular + " to " + techFullName + ".";
            }
            sysGeneratedText += "<br>This " + _cNames.Ticket.FullSingular + " was transferred by choosing route by " + _cNames.Technician.FullSingular + ".";
            if (_tktOld.TicketStatus == Status.OnHold)
            {
                sysGeneratedText += "<br>This " + _cNames.Ticket.FullSingular + " was set back to \"Open\" staus from \"On Hold\" status.";
            }
            InsertLogMessage(User.OrganizationId, User.DepartmentId, TktId, User.UserId, "Transfer", NoteText, sysGeneratedText);
            var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);

            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.TransferTicket, _tktNew, _tktOld, 0, DateTime.MinValue, null);
        }
Ejemplo n.º 5
0
        private void ProcessEventNotification(Event eventToHandle, NotificationRules notificationRule, IDictionary <string, string> data)
        {
            try
            {
                var parcedRule = _ruleParser.ParseNotificationRule(notificationRule.Query);

                var eventRule = parcedRule as IEventNotificationRule;

                if (eventRule == null)
                {
                    _log.Warning("Event notification rule has incorrect type. Type='{0}'".FormatWith(parcedRule.GetType().FullName));

                    return;
                }

                if (!(eventRule.IsForAllEvents || (eventRule.HasDependentEvents && eventRule.IsEventMatch(eventToHandle.Key))))
                {
                    _log.Trace("Event notification rule skipped. Current event='{0}', Target event='{0}'".FormatWith(
                                   eventToHandle.Key,
                                   eventRule.GetDependentEvents.ToCommaSeparatedString()));

                    return;
                }

                _ruleExecutorDirector.Execute <INotificationRule, NotificationRuleResult>((dynamic)eventRule, data);

                _log.Info("Event notification rule processed. Event='{0}', Notification rule Id='{1}', Notification rule name='{2}'"
                          .FormatWith(
                              eventToHandle.Key,
                              notificationRule.Id,
                              notificationRule.DisplayName));
            }
            catch (Exception exc)
            {
                _log.Error(
                    "Event notification rule processing has failed. Event='{0}', Notification rule Id='{1}', Notification rule name='{2}'"
                    .FormatWith(eventToHandle.Key, notificationRule.Id, notificationRule.DisplayName),
                    exc);
            }
        }
Ejemplo n.º 6
0
        public static void Confirm(ApiUser User, int TktId, string NoteText)
        {
            Config _cfg = new Config(User.OrganizationId, User.DepartmentId);

            if (!_cfg.ConfirmationTracking)
            {
                throw new HttpError("Confirmation Tracking is not enabled for this instance.");
            }

            UpdateConfirmation(User.OrganizationId, User.DepartmentId, TktId, User.UserId, true, NoteText);
            var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);

            foreach (TicketAssignee _ta in _tktNew.Users)
            {
                _ta.SendResponse = true;
            }
            foreach (TicketAssignee _ta in _tktNew.Technicians)
            {
                _ta.SendResponse = true;
            }
            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.TicketConfirmation, _tktNew, null, 0, DateTime.MinValue, null);
        }
Ejemplo n.º 7
0
        public static void ReOpen(ApiUser User, int TktId, string NoteText)
        {
            CustomNames _cNames = CustomNames.GetCustomNames(User.OrganizationId, User.DepartmentId);
            Ticket      _tktOld = new Ticket(User.OrganizationId, User.DepartmentId, TktId, User.InstanceId);

            if (_tktOld.TicketStatus != Ticket.Status.Closed)
            {
                throw new HttpError(_cNames.Ticket.FullSingular + " is not Closed now to ReOpen it.");
            }
            InsertResponse(User.OrganizationId, User.DepartmentId, TktId, User.UserId, false, _tktOld.UserId == User.UserId, false, NoteText, string.Empty, 0, string.Empty, true);
            var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);

            foreach (TicketAssignee _ta in _tktNew.Users)
            {
                _ta.SendResponse = true;
            }
            foreach (TicketAssignee _ta in _tktNew.Technicians)
            {
                _ta.SendResponse = true;
            }
            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.ReOpenTicket, _tktNew, null, 0, DateTime.MinValue, null);
        }
Ejemplo n.º 8
0
        public static void Close(ApiUser User, int TktId, string NoteText, bool SendNotifications, bool resolved, bool confirmed, string confirm_note)
        {
            Config      _cfg    = new Config(User.OrganizationId, User.DepartmentId);
            CustomNames _cNames = CustomNames.GetCustomNames(User.OrganizationId, User.DepartmentId);
            var         _tktOld = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);

            if (_cfg.ResolutionTracking)
            {
                UpdateResolution(User.OrganizationId, User.DepartmentId, TktId, 0, resolved);
                if (_cfg.ConfirmationTracking && confirmed)
                {
                    UpdateConfirmation(User.OrganizationId, User.DepartmentId, TktId, User.UserId, true, confirm_note);
                }
            }

            string sysGeneratedText = _cNames.Ticket.FullSingular + " was CLOSED by " + User.FullName + ".";

            CloseTicket(User.OrganizationId, User.DepartmentId, TktId, User.UserId, NoteText, sysGeneratedText, DateTime.UtcNow, string.Empty);
            if (SendNotifications)
            {
                var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true)
                {
                    IsSendNotificationEmail = true
                };
                foreach (TicketAssignee _ta in _tktNew.Users)
                {
                    _ta.SendResponse = true;
                }
                foreach (TicketAssignee _ta in _tktNew.Technicians)
                {
                    _ta.SendResponse = true;
                }
                NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId,
                                                         NotificationRules.TicketEvent.CloseTicket, _tktNew, _tktOld, 0,
                                                         DateTime.MinValue, null);
            }
        }
Ejemplo n.º 9
0
        public static void Response(ApiUser User, int TktId, string NoteText)
        {
            var    _tktOld     = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);
            string _toReceipts = string.Empty;
            List <Models.TicketAssignee> _tktUsers = Models.TicketAssignments.TicketUsers(User.OrganizationId, User.DepartmentId, TktId);

            foreach (Models.TicketAssignee _ta in _tktUsers)
            {
                if (_ta.UserId == User.UserId)
                {
                    continue;
                }
                _toReceipts += _ta.UserFullName + ", ";
            }
            List <Models.TicketAssignee> _tktTechs = Models.TicketAssignments.TicketTechnicians(User.OrganizationId, User.DepartmentId, TktId);

            foreach (Models.TicketAssignee _ta in _tktTechs)
            {
                if (_ta.UserId == User.UserId)
                {
                    continue;
                }
                _toReceipts += _ta.UserFullName + ", ";
            }
            InsertResponse(User.OrganizationId, User.DepartmentId, TktId, User.UserId, false, _tktOld.UserId == User.UserId, false, NoteText, string.Empty, 0, _toReceipts, false);
            var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);

            foreach (TicketAssignee _usrTkt in _tktNew.Users)
            {
                _usrTkt.SendResponse = true;
            }
            foreach (TicketAssignee _usrTkt in _tktNew.Technicians)
            {
                _usrTkt.SendResponse = true;
            }
            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.TicketResponse, _tktNew, null, 0, DateTime.MinValue, null);
        }
        public long Create(long projectId,
                           string name,
                           string query,
                           string description = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrEmpty(query))
            {
                throw new ArgumentNullException(nameof(query));
            }

            if (_notificationRuleRepository.Get(projectId, name).Any())
            {
                throw new NotificationAlreadyExistsException(projectId, name);
            }

            var rule = new NotificationRules
            {
                ProjectId   = projectId,
                Added       = _timeService.GetUtc(),
                Description = description,
                DisplayName = name,
                Query       = query
            };

            _notificationRuleRepository.Insert(rule);

            _notificationRuleRepository.Save();

            _log.Info(Properties.Resources.NotificationHasBeenCreated.FormatWith(rule.Id, name));

            return(rule.Id);
        }
Ejemplo n.º 11
0
        public static void InputTime(ApiUser User, int TktId, int TaskTypeId, decimal Hours, int HoursOffset, string NoteText)
        {
            Config      _cfg    = new Config(User.OrganizationId, User.DepartmentId);
            CustomNames _cNames = CustomNames.GetCustomNames(User.OrganizationId, User.DepartmentId);

            if (!_cfg.TimeTracking)
            {
                throw new HttpError("Time Tracking is not enabled for this instance.");
            }

            int    _taskTypeId   = 0;
            string _taskTypeName = string.Empty;

            if (TaskTypeId == 0)
            {
                DataTable _dtTaskTypes = bigWebApps.bigWebDesk.Data.TaskType.SelectTicketAssignedTaskTypes(User.OrganizationId, User.DepartmentId, User.UserId, TktId);

                if (_dtTaskTypes.Rows.Count == 0)
                {
                    throw new HttpError("No Assigned Task Types found for this " + _cNames.Ticket.fullSingular + ".");
                }

                _taskTypeId   = (int)_dtTaskTypes.Rows[0]["ttID"];
                _taskTypeName = _dtTaskTypes.Rows[0]["TaskTypeName"].ToString();
            }
            else
            {
                _taskTypeId = TaskTypeId;
                DataRow _rowTaskType = bigWebApps.bigWebDesk.Data.TaskType.SelectTaskType(User.OrganizationId, User.DepartmentId, _taskTypeId);

                if (_rowTaskType == null)
                {
                    throw new HttpError("No Task Types found for TaskTypeId=" + _taskTypeId.ToString() + ".");
                }
                _taskTypeName = _rowTaskType["TaskTypeName"].ToString();
            }

            string _hoursFull = "";

            if (Hours >= 1)
            {
                _hoursFull = ((int)Hours).ToString();
                if ((int)Hours == 1)
                {
                    _hoursFull += " hour ";
                }
                else
                {
                    _hoursFull += " hours ";
                }
            }

            string _minutes = string.Format("{0:00}", Hours * 60 % 60).TrimStart('0');

            if (!string.IsNullOrEmpty(_minutes))
            {
                _hoursFull += _minutes;
                if (_minutes == "1")
                {
                    _hoursFull += " minute";
                }
                else
                {
                    _hoursFull += " minutes";
                }
            }

            if (!string.IsNullOrEmpty(_hoursFull))
            {
                _hoursFull = "(" + _hoursFull.Trim() + ")";
            }

            var    _tktOld          = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId);
            string sysGeneratedText = User.FullName;
            int    _timeLogId       = 0;

            if (Hours > 0)
            {
                sysGeneratedText = " logged " + Hours.ToString("0.00") + " hours " + _hoursFull + " as " + _taskTypeName + " task type.";
                decimal _hRate = Logins.SelectTechHourlyRate(User.OrganizationId, User.DepartmentId, User.UserId, _taskTypeId);
                _timeLogId = bigWebApps.bigWebDesk.Data.Tickets.InsertTime(User.OrganizationId, User.DepartmentId, TktId, User.UserId, DateTime.UtcNow, Hours, NoteText, _hRate, DateTime.UtcNow.AddHours(-(double)Hours), DateTime.UtcNow, _taskTypeId, 0, DateTime.UtcNow, User.UserId, HoursOffset, true);
            }
            InsertResponse(User.OrganizationId, User.DepartmentId, TktId, User.UserId, false, _tktOld.UserId == User.UserId, false, NoteText, sysGeneratedText, _timeLogId, string.Empty, false);
            var _tktNew = new bigWebApps.bigWebDesk.Data.Ticket(User.OrganizationId, User.DepartmentId, TktId, true);

            foreach (TicketAssignee _ta in _tktNew.Users)
            {
                _ta.SendResponse = true;
            }
            foreach (TicketAssignee _ta in _tktNew.Technicians)
            {
                _ta.SendResponse = true;
            }
            NotificationRules.RaiseNotificationEvent(User.OrganizationId, User.DepartmentId, User.UserId, NotificationRules.TicketEvent.TicketResponse, _tktNew, _tktOld, 0, DateTime.MinValue, null);
        }