Пример #1
0
 public abstract void Delete_WorkOrderGroup(WOGroupInfo WorkOrderGroup);
Пример #2
0
 public abstract int Add_WorkOrderGroup(WOGroupInfo WorkOrderGroup);
Пример #3
0
 public abstract void Update_WorkOrderGroup(WOGroupInfo WorkOrderGroup);
Пример #4
0
        public string buildRequest(string ticket)
        {
            string req = "";

            string[] custCodes = new string[6] {
                "CUSTOMIZATION 30 MIN", "HD CUSTOMIZATION 30 MIN", "SPOT CUSTOMIZATION", "HD CUSTOMIZATION SPOT", "CUSTOMIZATION 5 MIN", "HD CUSTOMIZATION 5 MIN"
            };
            int custIndex = 2;

            int                i         = 1;
            string             xmlString = "";
            List <InvoiceInfo> invs      = aCont.Get_InvoicesByToSend();

            if (invs.Count > 0)
            {
                xmlString += "<?xml version=\"1.0\" encoding=\"utf-8\"?><?qbxml version=\"6.0\"?><QBXML><QBXMLMsgsRq onError=\"stopOnError\">";
                //build array of xml
                foreach (InvoiceInfo inv in invs)
                {
                    xmlString += "<InvoiceAddRq requestID=\"" + inv.Id.ToString() + "\"><InvoiceAdd>";//
                    List <int> woIds = aCont.Get_WOInsByInvoiceId(inv.Id);
                    if (woIds.Count > 0 && woIds[0] > 0)
                    {
                        WorkOrderInfo  wo1    = aCont.Get_WorkOrderById(woIds[0]);
                        AdvertiserInfo billto = aCont.Get_AdvertiserById(wo1.BillToId);
                        if (billto.Id == -1)
                        {
                            billto = aCont.Get_AdvertiserById(wo1.AdvertiserId);
                        }
                        i++;
                        xmlString += "<CustomerRef><FullName>" + billto.AdvertiserName.Trim().Replace("&", "&#038;") + "</FullName></CustomerRef>";
                        xmlString += "<BillAddress><Addr1>" + billto.AdvertiserName.Trim().Replace("&", "&#038;") + "</Addr1><Addr2>" + billto.Address1.Trim().Replace("&", "&#038;");
                        if (billto.Address2.Trim() != "")
                        {
                            xmlString += " - " + billto.Address2.Trim().Replace("&", "&#038;");
                        }
                        xmlString += "</Addr2><City>" + billto.City.Trim().Replace("&", "&#038;") + "</City><State>" + billto.State.Trim().Replace("&", "&#038;") + "</State><PostalCode>" + billto.Zip.Trim().Replace("&", "&#038;") + "</PostalCode><Country>" + billto.Country.Trim().Replace("&", "&#038;") + "</Country></BillAddress>";
                        string po = wo1.PONumber;
                        if (po == "")
                        {
                            try
                            {
                                po = wo1.Groups[0].LibraryItems[0].PMTMediaId.Replace("&", "&#038;");
                            }
                            catch { }
                        }
                        xmlString += "<PONumber>" + po.Replace("&", "&#038;") + "</PONumber>";
                        if (woIds.Count == 1)
                        {
                            xmlString += "<FOB>WO: " + woIds[0].ToString() + "</FOB>";
                        }
                        else if (woIds.Count > 1)
                        {
                            xmlString += "<FOB>SEE BELOW</FOB>";
                        }
                        xmlString += "<Memo>" + inv.Id.ToString() + "</Memo>";
                        AgencyInfo ag = aCont.Get_AgencyById(wo1.AgencyId);
                        xmlString += "<Other>" + ag.AgencyName.Trim().Replace("&", "&#038;") + "</Other>";
                        foreach (int woId in woIds)
                        {
                            WorkOrderInfo   wo       = aCont.Get_WorkOrderById(woId);
                            List <TaskInfo> tasks    = aCont.Get_TasksByWOId(wo.Id);
                            int             groupId  = -1;
                            bool            groupNew = true;
                            for (int j = 0; j < tasks.Count; j++)
                            {
                                TaskInfo task = tasks[j];
                                if (groupId == -1)
                                {
                                    groupId = task.WOGroupId;
                                }
                                if (task.WOGroupId != groupId)
                                {
                                    groupNew = true;
                                    groupId  = task.WOGroupId;
                                }
                                if (task.DeliveryStatus.ToLower() != "cancelled" && !task.isDeleted)
                                {
                                    if (task.TaskType != GroupTypeEnum.Delivery)
                                    {
                                        WOGroupInfo       group     = aCont.Get_WorkOrderGroupById(task.WOGroupId);
                                        List <QBCodeInfo> servCodes = aCont.FindQBCodesByTask(task.Id, 0, true);
                                        LibraryItemInfo   lib       = aCont.Get_LibraryItemById(task.LibraryId);
                                        MasterItemInfo    master    = new MasterItemInfo();
                                        if (task.TaskType == GroupTypeEnum.Non_Deliverable)
                                        {
                                            master = aCont.Get_MasterItemById(task.MasterId);
                                        }
                                        //foreach (ServiceInfo serv in group.Services)
                                        if (groupNew)
                                        {
                                            foreach (QBCodeInfo code in servCodes)
                                            {
                                                if (task.TaskType != GroupTypeEnum.Non_Deliverable)
                                                {
                                                    xmlString += "<InvoiceLineAdd>";
                                                    xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&#038;") + "</FullName></ItemRef>";
                                                    xmlString += "<Desc>" + lib.Title.Replace("&", "&#038;"); //code.QBCode.Replace("&", "&#038;");
                                                    if (woIds.Count > 1 && j == 0)
                                                    {
                                                        xmlString += " WO " + wo.Id.ToString();
                                                    }
                                                    xmlString += "</Desc>";
                                                    if (task.Quantity == 0)
                                                    {
                                                        task.Quantity = 1;
                                                    }
                                                    xmlString += "<Quantity>" + group.LibraryItems.Count.ToString() + "</Quantity>";
                                                    xmlString += "<Other1></Other1>";
                                                    xmlString += "<Other2></Other2></InvoiceLineAdd>";
                                                }
                                                else
                                                {
                                                    xmlString += "<InvoiceLineAdd>";
                                                    xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&#038;") + "</FullName></ItemRef>";
                                                    xmlString += "<Desc>" + master.Title.Replace("&", "&#038;");
                                                    if (woIds.Count > 1 && j == 0)
                                                    {
                                                        xmlString += " WO " + wo.Id.ToString();
                                                    }
                                                    xmlString += "</Desc>";
                                                    if (task.Quantity == 0)
                                                    {
                                                        task.Quantity = 1;
                                                    }
                                                    xmlString += "<Quantity>" + task.Quantity + "</Quantity>";
                                                    xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&#038;") + "</Other1>";
                                                    xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&#038;") + "</Other2></InvoiceLineAdd>";
                                                }
                                            }
                                            groupNew = false;
                                        }
                                    }
                                    if (task.TaskType == GroupTypeEnum.Bundle || task.TaskType == GroupTypeEnum.Delivery || task.TaskType == GroupTypeEnum.Customized)
                                    {
                                        LibraryItemInfo lib  = aCont.Get_LibraryItemById(task.LibraryId);
                                        bool            isHd = lib.MediaType.IndexOf("HD") != -1;
                                        string[]        pcs  = lib.MediaLength.Split(':');
                                        int             secs = 0;
                                        if (pcs.Length == 2)
                                        {
                                            try
                                            {
                                                secs = 60 * Convert.ToInt32(pcs[0]) + Convert.ToInt32(pcs[1]);
                                            }
                                            catch { }
                                        }
                                        if (secs <= 120 && !isHd)
                                        {
                                            custIndex = 2;
                                        }
                                        else if (secs <= 120 && isHd)
                                        {
                                            custIndex = 3;
                                        }
                                        else if (secs >= 1500 && secs <= 1800 && !isHd)
                                        {
                                            custIndex = 0;
                                        }
                                        else if (secs >= 1500 && secs <= 1800 && isHd)
                                        {
                                            custIndex = 1;
                                        }
                                        else if (secs >= 180 && secs <= 300 && !isHd)
                                        {
                                            custIndex = 4;
                                        }
                                        else if (secs >= 180 && secs <= 300 && !isHd)
                                        {
                                            custIndex = 5;
                                        }
                                        xmlString += "<InvoiceLineAdd>";
                                        if (task.TaskType != GroupTypeEnum.Customized)
                                        {
                                            xmlString += "<ItemRef><FullName>" + task.QBCode.Trim().Replace("&", "&#038;") + "</FullName></ItemRef>";
                                        }
                                        else
                                        {
                                            xmlString += "<ItemRef><FullName>" + custCodes[custIndex] + "</FullName></ItemRef>";
                                        }
                                        xmlString += "<Desc>" + lib.Title.Trim().Replace("&", "&#038;");
                                        if (woIds.Count > 1 && j == 0)
                                        {
                                            xmlString += " WO " + wo.Id.ToString();
                                        }
                                        xmlString += "</Desc>";
                                        if (task.Quantity == 0)
                                        {
                                            task.Quantity = 1;
                                        }
                                        xmlString += "<Quantity>" + task.Quantity + "</Quantity>";
                                        xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&#038;") + "</Other1>";
                                        if (lib.TapeCode.Trim() == "")
                                        {
                                            xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&#038;") + "</Other2></InvoiceLineAdd>";
                                        }
                                        else
                                        {
                                            xmlString += "<Other2>" + lib.TapeCode.Trim().Replace("&", "&#038;") + "</Other2></InvoiceLineAdd>";
                                        }
                                        WOGroupStationInfo station = aCont.Get_WorkOrderGroupStationById(task.StationId);
                                        if (station.DeliveryMethod.ToLower().IndexOf("tf_") != -1)
                                        {
                                            //check to see if we need to add shipping
                                            if (station.ShippingMethodId == -1)
                                            {
                                                int            weight = 1;
                                                TapeFormatInfo tape   = aCont.Get_TapeFormatById(Convert.ToInt32(station.DeliveryMethod.Replace("tf_", "")));
                                                if (station.Quantity * tape.Weight > 1.0)
                                                {
                                                    weight = 2;
                                                }
                                                string shippingPrice = "";
                                                if (weight == 1)
                                                {
                                                    if (station.PriorityId == 1)
                                                    {
                                                        shippingPrice = ConfigurationManager.AppSettings["FedEx1LbPriority"].ToString();
                                                    }
                                                    else if (station.PriorityId == 2)
                                                    {
                                                        shippingPrice = ConfigurationManager.AppSettings["FedEx1LbStandard"].ToString();
                                                    }
                                                    else if (station.PriorityId == 3)
                                                    {
                                                        shippingPrice = ConfigurationManager.AppSettings["FedEx1Lb2Day"].ToString();
                                                    }
                                                }
                                                else
                                                {
                                                    if (station.PriorityId == 1)
                                                    {
                                                        shippingPrice = ConfigurationManager.AppSettings["FedEx2LbPriority"].ToString();
                                                    }
                                                    else if (station.PriorityId == 2)
                                                    {
                                                        shippingPrice = ConfigurationManager.AppSettings["FedEx2LbStandard"].ToString();
                                                    }
                                                    else if (station.PriorityId == 3)
                                                    {
                                                        shippingPrice = ConfigurationManager.AppSettings["FedEx2Lb2Day"].ToString();
                                                    }
                                                }
                                                xmlString += "<InvoiceLineAdd><ItemRef><FullName>SHIPPING</FullName></ItemRef><Desc>P" + station.PriorityId.ToString() + " " + weight.ToString() + "LB SHIPPING CHARGE</Desc><Quantity>1</Quantity><Rate>" + shippingPrice + "</Rate></InvoiceLineAdd>";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    xmlString += "</InvoiceAdd></InvoiceAddRq>";
                    //xmlString += "";
                }
                xmlString += "</QBXMLMsgsRq></QBXML>";
                req        = xmlString;
                //}
            }
            return(req);
        }