コード例 #1
0
        public static string GetDeletedTickets(RestCommand command)
        {
            DeletedTickets deletedTickets = new DeletedTickets(command.LoginUser);

            deletedTickets.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(deletedTickets.GetXml("DeletedTickets", "DeletedTicket", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
コード例 #2
0
        public static string GetDeletedTickets(RestCommand command)
        {
            string xml             = "";
            bool   hasBeenFiltered = false;
            int    totalRecords    = 0;

            DeletedTickets deletedTickets = new DeletedTickets(command.LoginUser);

            if (command.IsPaging)
            {
                try
                {
                    deletedTickets.LoadByOrganizationID(command.Organization.OrganizationID, command.Filters, command.PageNumber, command.PageSize);
                    hasBeenFiltered = true;
                    XmlTextWriter writer = DeletedTickets.BeginXmlWrite("DeletedTicketx");
                    try
                    {
                        foreach (DataRow row in deletedTickets.Table.Rows)
                        {
                            int  recordId = (int)row["ID"];
                            Tags tags     = new Tags(command.LoginUser);
                            tags.LoadByReference(ReferenceType.DeletedTickets, recordId);
                            tags = tags ?? new Tags(command.LoginUser);
                            deletedTickets.WriteXml(writer, row, "DeletedTicket", true, !hasBeenFiltered ? command.Filters : new System.Collections.Specialized.NameValueCollection(), tags);
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestDeletedTickets. GetDeletedTickets(). Paging.");
                    }

                    if (deletedTickets.Count > 0)
                    {
                        totalRecords = deletedTickets[0].TotalRecords;
                    }

                    writer.WriteElementString("TotalRecords", totalRecords.ToString());
                    xml = DeletedTickets.EndXmlWrite(writer);
                }
                catch (Exception ex)
                {
                    ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestDeletedTickets. GetDeletedTickets(). Paging. SQL filtering generation failed.");
                    throw new RestException(HttpStatusCode.InternalServerError, "There was an error processing your request. Please contact TeamSupport.com", ex);
                }
            }
            else
            {
                //No Paging
                try
                {
                    deletedTickets.LoadByOrganizationID(command.Organization.OrganizationID, command.Filters);
                    xml = deletedTickets.GetXml("DeletedTickets", "DeletedTicket", true, command.Filters);
                    //xml = AddTagsToDeletedTickets(xml, command);
                }
                catch (Exception ex)
                {
                    ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestDeletedTickets. GetDeletedTickets(). No Paging. SQL filtering generation failed.");
                }
            }

            return(xml);
        }