Esempio n. 1
0
        public object Post(POST_Time_Logs request)
        {
            ApiUser hdUser        = request.ApiUser;
            bool    is_billable   = request.is_billable ?? true;
            bool    is_local_time = request.is_local_time ?? false;
            int     techID        = (request.tech_id > 0 && hdUser.IsTechAdmin) ? request.tech_id : hdUser.UserId;

            bigWebApps.bigWebDesk.Data.Ticket _tktNew = null;
            DateTime?start_date = request.start_date;
            DateTime?stop_date  = request.stop_date;

            if (is_local_time)
            {
                if (request.start_date.HasValue && request.start_date > DateTime.MinValue)
                {
                    start_date = request.start_date.Value.AddHours(-1 * hdUser.TimeZoneOffset);
                }
                if (request.stop_date.HasValue && request.stop_date > DateTime.MinValue)
                {
                    stop_date = request.stop_date.Value.AddHours(-1 * hdUser.TimeZoneOffset);
                }
            }
            string key      = request.ticket_key;
            string response = "";

            if (!string.IsNullOrEmpty(key) && key != "0" && request.project_time_id <= 0)
            {
                Ticket.InputTime(hdUser, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, key), request.task_type_id, start_date,
                                 stop_date, request.hours, hdUser.TimeZoneOffset, HttpUtility.HtmlDecode(request.note_text), is_billable, request.date, request.ticket_time_id,
                                 techID, ref _tktNew, request.complete, request.remain_hours, request.prepaid_pack_id, string.Empty);
            }
            else
            {
                int accountID = request.account_id != 0 ? request.account_id : -1;
                int projectID = request.project_id > 0 ? request.project_id : -1;
                response = Models.Projects.PostProjectTime(hdUser, accountID, projectID, techID, request.task_type_id, start_date, stop_date, request.hours, hdUser.TimeZoneOffset,
                                                           HttpUtility.HtmlDecode(request.note_text), is_billable, request.date, request.project_time_id, request.prepaid_pack_id, string.Empty, key);
            }
            if (_tktNew != null)
            {
                return(TicketLogRecords.TicketLog(hdUser.OrganizationId, hdUser.DepartmentId, _tktNew.ID, _tktNew.PseudoID));
            }
            return(new HttpResult(response, HttpStatusCode.OK));
        }
Esempio n. 2
0
        public object Get(Posts request)
        {
            ApiUser hdUser = request.ApiUser;
            //v1
            string ticket_key = request.key;

            //v2
            if (!string.IsNullOrEmpty(request.ticket))
            {
                ticket_key = request.ticket;
            }
            int ticket_id      = Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, ticket_key);
            int test_ticket_id = 0;

            if (int.TryParse(ticket_key, out test_ticket_id))
            {
                ticket_key = Ticket.GetPseudoId(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id);
            }

            return(request.FilteredResult <TicketLogRecord>(TicketLogRecords.TicketLog(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, ticket_key)));
        }
Esempio n. 3
0
        public object Post(Posts request)
        {
            ApiUser hdUser = request.ApiUser;
            //v1
            string ticket_key = request.key;

            //v2
            if (!string.IsNullOrEmpty(request.ticket))
            {
                ticket_key = request.ticket;
            }
            request.note_text = request.note_text ?? "";
            int ticketId = Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, ticket_key);

            bigWebApps.bigWebDesk.Data.Ticket _tktNew = null;
            Ticket.Response(hdUser, ticketId, request.note_text, request.is_waiting_on_response, ref _tktNew, request.files, request.user_id);
            if (_tktNew != null)
            {
                return(TicketLogRecords.TicketLog(hdUser.OrganizationId, hdUser.DepartmentId, _tktNew.ID, _tktNew.PseudoID));
            }
            return(new HttpResult("", HttpStatusCode.OK));
        }
Esempio n. 4
0
        public object Post(Ticket_Actions request)
        {
            ApiUser hdUser = request.ApiUser;

            bigWebApps.bigWebDesk.Data.Ticket _tktNew = null;
            if (request.action == "response" || !string.IsNullOrEmpty(request.note_text))
            {
                Ticket.Response(hdUser, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key), request.note_text, request.is_waiting_on_response, ref _tktNew, request.files, request.user_id);
                //return new HttpResult("", HttpStatusCode.OK);
            }
            else if (request.action == "workpad")
            {
                string workpad = HttpUtility.HtmlDecode(request.workpad + "");
                Ticket.UpdateTicketWorkpad(hdUser.OrganizationId, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key), workpad);
                //return new HttpResult("", HttpStatusCode.OK);
            }
            else if (request.action == "note" && hdUser.IsTechAdmin)
            {
                string note = request.note + "";
                Ticket.UpdateTechNote(hdUser.OrganizationId, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key), note);
                //return new HttpResult("", HttpStatusCode.OK);
            }
            else if (request.action == "add_tech" || request.tech_id > 0)
            {
                Ticket.AttachAlternateTechnician(hdUser, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key), request.tech_id);
            }
            else if (request.action == "add_user" || request.user_id > 0)
            {
                Ticket.AttachAlternateUser(hdUser, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key), request.user_id);
            }

            if (_tktNew != null)
            {
                return(TicketLogRecords.TicketLog(hdUser.OrganizationId, hdUser.DepartmentId, _tktNew.ID, _tktNew.PseudoID));
            }
            return(new HttpResult("", HttpStatusCode.OK));
        }
Esempio n. 5
0
        public object Get(Posts request)
        {
            ApiUser hdUser = request.ApiUser;

            return(TicketLogRecords.TicketLog(hdUser.OrganizationId, hdUser.DepartmentId, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key), request.key, request.page, request.limit));
        }
Esempio n. 6
0
        public object Put(Ticket_Actions request)
        {
            ApiUser hdUser = request.ApiUser;

            request.note_text = request.note_text ?? "";
            request.status    = request.status ?? "";
            request.status    = request.status.Replace("_", "");
            int ticket_id = Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.key);

            var _tktOld = new bigWebApps.bigWebDesk.Data.Ticket(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, true);

            bigWebApps.bigWebDesk.Data.Ticket _tktNew = null;
            Ticket.Status status;

            if (Enum.TryParse <Ticket.Status>(request.status, true, out status))
            {
                if (_tktOld.TicketStatus != status)
                {
                    switch (status)
                    {
                    case Ticket.Status.OnHold:
                        Ticket.OnHold(hdUser, ticket_id, request.note_text, ref _tktNew);
                        break;

                    case Ticket.Status.PartsOnOrder:
                        throw new HttpError(HttpStatusCode.NotFound, "Incorrect status");

                    case Ticket.Status.Closed:
                        Ticket.Close(hdUser, ticket_id, request.note_text, request.is_send_notifications, request.resolved, request.resolution_id, request.confirmed, request.confirm_note, ref _tktNew);
                        break;

                    case Ticket.Status.Open:
                        Ticket.ReOpen(hdUser, ticket_id, request.note_text, ref _tktNew);
                        break;
                    }
                }
            }

            bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.TicketResponse;

            if (request.action == "transfer" || (request.user_id > 0 && _tktOld.UserId != request.user_id))
            {
                Ticket.TransferToUser(hdUser, ticket_id, request.user_id, request.note_text, ref _tktNew);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangeEndUser;
            }

            if (request.action == "transfer" || (request.tech_id > 0 && _tktOld.TechnicianId != request.tech_id))
            {
                Ticket.TransferToTech(hdUser, ticket_id, request.tech_id, request.note_text, request.keep_attached, ref _tktNew);
                if (_tktNew.TechnicianId == hdUser.UserId)
                {
                    bigWebApps.bigWebDesk.Data.Ticket.UpdateNewPostIcon(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, hdUser.UserId, false);
                }
                else if (_tktNew.TechnicianId != hdUser.UserId)
                {
                    bigWebApps.bigWebDesk.Data.Ticket.UpdateNewPostIcon(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, hdUser.UserId, true);
                }
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.TransferTicket;
            }

            if (request.priority_id > 0 && _tktOld.PriorityId != request.priority_id)
            {
                Ticket.UpdatePriority(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, request.priority_id);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangePriority;
            }

            /** not implemented
             *  need to add parameters LocationId, Transfermode, is_transfer_user_to_account
             *  look page https://support.sherpadesk.com/home/accts/assignticket.aspx
             *  Transfermode:
             *                          0 - This ticket only (default)
             *                          1 - Only unassigned tickets for this user
             *                          2 - All tickets for this user
             */
            if (request.account_id != 0 && _tktOld.AccountId != request.account_id)
            {
                Ticket.UpdateAccount(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, request.account_id, request.account_location_id, 0, request.is_transfer_user_to_account);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangeAccount;
            }
            if (request.location_id != 0 && _tktOld.LocationId != request.location_id)
            {
                Ticket.UpdateLocation(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, request.location_id);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangeLocation;
            }
            if (request.project_id != 0 && _tktOld.ProjectId != request.project_id)
            {
                Ticket.UpdateProject(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, request.project_id);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangeProject;
            }
            if (request.level_id > 0 && _tktOld.Level != request.level_id)
            {
                Ticket.UpdateLevel(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, request.level_id, hdUser.UserId, request.note_text);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangeLevel;
            }
            if (request.class_id > 0 && _tktOld.ClassId != request.class_id)
            {
                Ticket.UpdateClass(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, request.class_id);
                tktEvent = bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.ChangeClass;
            }

            if (tktEvent != bigWebApps.bigWebDesk.Data.NotificationRules.TicketEvent.TicketResponse)
            {
                _tktNew = _tktNew ?? new bigWebApps.bigWebDesk.Data.Ticket(hdUser.OrganizationId, hdUser.DepartmentId, ticket_id, true);
                bigWebApps.bigWebDesk.Data.NotificationRules.RaiseNotificationEvent(hdUser.OrganizationId, hdUser.DepartmentId, hdUser.UserId, tktEvent, _tktNew);
            }

            if (!string.IsNullOrEmpty(request.action))
            {
                switch (request.action.ToLower())
                {
                case "pickup": Ticket.PickUp(hdUser, ticket_id, request.note_text, ref _tktNew);
                    break;

                case "confirm": Ticket.Confirm(hdUser, ticket_id, request.note_text, ref _tktNew);
                    break;

                case "escalate":
                    Ticket.EscalateTicketByLevel(hdUser, ticket_id, true);
                    return(getTicket(hdUser, request.key, false));

                    break;

                case "deescalate":
                    Ticket.EscalateTicketByLevel(hdUser, ticket_id, false);
                    return(getTicket(hdUser, request.key, false));

                    break;
                }
            }
            if (_tktNew != null)
            {
                return(TicketLogRecords.TicketLog(hdUser.OrganizationId, hdUser.DepartmentId, _tktNew.ID, _tktNew.PseudoID));
            }
            return(new HttpResult("", HttpStatusCode.OK));
        }