private string Json_to_URL_encoded(ref SharedLTL.LTLBookingInfo json)
        {
            return(string.Concat("intCustCompanyID=0&intShipmentID=0&intSegmentID=0&intSegmentID2=0",
                                 "&intCarrierCompID=0&intRQID&intPUCompID=&glbDeliveryDate=01/01/2020",
                                 "&insuranceCost=&minInsuranceCost=&isAAFES_Shipment=false&isDUR=false&isAssociationID_5=false",
                                 "&isUSED=false",
                                 "&chkHazMat1=false&chkHazMat2=false&chkHazMat3=false&chkHazMat4=false",
                                 "&q_HazMat1=false&q_HazMat2=false&q_HazMat3=false&q_HazMat4=false",

                                 "&oCityState=&dCityState=&oState=&dState=&q_OCity=&q_DCity=",
                                 "&rate=0&ourRate=0&txtSellRate=&hasInsurance=false&shipmentValue=0&deliveryDay=",
                                 "&username=&repName=&Initials=&Status=&carrier=&carrierKey=&DLS_PrimaryReferencePNW=",
                                 "&txtShipmentDate=", json.shipmentDate, "&q_ShipmentReadyDate=01/01/2020&rateType=&txtComment=",
                                 "&txtPONumber=&selectedTransit=&selectedOnTime=&selectedRate=&selectedCarrier=",
                                 "&topCarrier=&topOnTime=&topTransit=&topRate=",
                                 "&txtDesc1=&txtDesc2=&txtDesc3=&txtDesc4=",
                                 "&DimsCubeDesc1=&DimsCubeDesc2=&DimsCubeDesc3=&DimsCubeDesc4=",

                                 "&txtPName=&txtPCompany=&txtPAddress1=&txtPAddress2=&txtPCity=&txtPST=",
                                 "&txtPZip=&txtPEmail=&txtPPhone=&txtPFax",

                                 "&txtDName=&txtDCompany=&txtDAddress1=&txtDAddress2=&txtDCity=&txtDST=",
                                 "&txtDZip=&txtDEmail=&txtDPhone=&txtDFax",

                                 "&txtTPName=&txtTPCompany=&txtTPAddress1=&txtTPAddress2=&txtTPCity=&txtTPST",
                                 "&txtTPZip=&txtTPEmail=&txtTPPhone=&txtTPFax=",

                                 "&q_ResPick=false&q_ResDel=&q_ConstPick=&q_ConstDel=&q_TradePick=&q_TradeDel=",
                                 "&q_TailPick=&q_TailDel=&q_AppPick=&q_AppDel=&q_InsPick=&q_InsDel=",
                                 "&commodityName",

                                 "&q_Weight1=&q_Weight2=&q_Weight3=&q_Weight4=",
                                 "&q_Length1=&q_Length2=&q_Length3=&q_Length4=",
                                 "&=q_Width1&q_Width2=&q_Width3=&q_Width4=",
                                 "&q_Height1=&q_Height2=&q_Height3=&q_Height4=",
                                 "&txtPallet1=&txtPallet2=&txtPallet3=&txtPallet4=",
                                 "&lblClass1=&lblClass2=&lblClass3=&lblClass4=",
                                 "&q_Class1=&q_Class2=&q_Class3=&q_Class4=",
                                 "&lblWeight1=&lblWeight2=&lblWeight3=&lblWeight4=",
                                 "&lblType1=&lblType2=&lblType3=&lblType4=",
                                 "&lblPiece1=&lblPiece2=&lblPiece3=&lblPiece4=",
                                 "&q_Piece1=&q_Piece2=&q_Piece3=&q_Piece4=",
                                 "&txtNMFC1=&txtNMFC2=&txtNMFC3=&txtNMFC4=",
                                 "&q_Unit1=&q_Unit2=&q_Unit3=&q_Unit4=",
                                 "&Commodity1=&Commodity2=&Commodity3=&Commodity4=",

                                 "&ddlDeliveryAddress=&ddlPickupAddress=&rdblClientType=&rdblBill=",
                                 "&ddlRHour=&ddlRMinute=&ddlRAMPM=&ddlCHour=",
                                 "&ddlCMinute=&ddlCAMPM=",
                                 "&exportPath=&exportPath2=&BOLReportName2=&strReportFileName=",
                                 "&strReportFileName2="
                                 ));
        }
        // This function will go into Public CreateLTLBooking
        public string Post(SharedLTL.LTLBookingInfo json)
        {
            //LTLBooking booking = new LTLBooking();
            //HelperFuncs.writeToSiteErrors("test SearchObject", string.Concat(json.origName, " ", json.origEmail));

            DB.Log("LTLBookingInfo", json);

            LTLBooking booking = new LTLBooking();

            booking.makeBookingViaSOAP(ref json);

            return(booking.makeBookingViaSOAP(ref json));

            #region Not used
            //FormDataCollection form = new FormDataCollection("");
            ////

            //DispatchData dispatch_data = new DispatchData();

            //RequestParser parser = new RequestParser(ref form, ref dispatch_data);

            //parser.SetParameters();
            //parser.SetParameters_companies_info();
            //parser.SetParameters_accessorials_info();
            //parser.SetParameters_line_items_info();

            //StringBuilder sb = new StringBuilder();

            //Logger logger = new Logger(ref dispatch_data, ref sb);
            //logger.Log_all_request_info();

            //Dispatch dispatch = new Dispatch(ref dispatch_data);
            //dispatch.SaveDispatchInformation();

            //return sb.ToString();
            #endregion
        }
Example #3
0
    public string makeBookingViaSOAP(ref SharedLTL.LTLBookingInfo json)
    {
        //gcmAPI.gcmWebService.LTLBookingReply lbr;

        try
        {
            //return "{ \"Notification\" : \"temporarily stopped service\" }";

            #region Testing

            StringBuilder logger = new StringBuilder();
            logger.Append(string.Concat("shipmentDate: ", json.shipmentDate, ", "));
            logger.Append(string.Concat("bookingKey: ", json.bookingKey, ", "));
            logger.Append(string.Concat("customerType: ", json.customerType, ", "));

            logger.Append(string.Concat("origName: ", json.origName, ", "));
            logger.Append(string.Concat("origEmail: ", json.origEmail, ", "));
            logger.Append(string.Concat("origCompany: ", json.origCompany, ", "));
            logger.Append(string.Concat("origPhone: ", json.origPhone, ", "));
            logger.Append(string.Concat("origFax: ", json.origFax, ", "));
            logger.Append(string.Concat("origAddress1: ", json.origAddress1, ", "));
            logger.Append(string.Concat("origAddress2: ", json.origAddress2, ", "));
            logger.Append(string.Concat("origCity: ", json.origCity, ", "));
            logger.Append(string.Concat("origState: ", json.origState, ", "));
            logger.Append(string.Concat("origZip: ", json.origZip, ", "));

            logger.Append(string.Concat("destName: ", json.destName, ", "));
            logger.Append(string.Concat("destEmail: ", json.destEmail, ", "));
            logger.Append(string.Concat("destCompany: ", json.destCompany, ", "));
            logger.Append(string.Concat("destPhone: ", json.destPhone, ", "));
            logger.Append(string.Concat("destFax: ", json.destFax, ", "));
            logger.Append(string.Concat("destAddress1: ", json.destAddress1, ", "));
            logger.Append(string.Concat("destAddress2: ", json.destAddress2, ", "));
            logger.Append(string.Concat("destCity: ", json.destCity, ", "));
            logger.Append(string.Concat("destState: ", json.destState, ", "));
            logger.Append(string.Concat("destZip: ", json.destZip, ", "));

            #endregion

            #region Not used
            //logger.Append(string.Concat("shipmentDate: ", json.shipmentDate, ", "));

            //if(j

            //if (!DateTime.TryParse(json.shipmentDate, out shipmentDate))
            //{
            //    shipmentDate = DateTime.Today.AddDays(1);
            //}



            // Authenticate to the web service/API
            //string sessionId = rs.Authenticate(apiUserName, apiKey);

            //// Initialize SOAP header for authentication
            //rs.AuthHeaderValue = new MyWebReference.AuthHeader();

            //// Set session id to the SOAP header
            //rs.AuthHeaderValue.SessionID = sessionId;
            #endregion

            DateTime shipmentDate = json.shipmentDate;

            // Initialize web service/API object
            gcmAPI.gcmWebService.RateService2 rs = new gcmAPI.gcmWebService.RateService2();

            string bookingKey = json.bookingKey;

            string customerType = json.customerType; //Set customer type

            gcmAPI.gcmWebService.BookingThirdPartyBilling thirdPartyBilling = null;
            //DateTime shipmentDate = DateTime.Now.Date; //Set shipment date

            string readyTime = "02:15 PM"; //Set ready time of the shipment
            string closeTime = "06:15 PM"; //Set close time of the shipment

            //string readyTime = "10"; //Set ready time of the shipment
            //string closeTime = "3"; //Set close time of the shipment

            string bolSendTo = "EML"; //Set BOL sending option
            //string poNumber = "45455"; //Set PO Number
            string poNumber = null;   //Set PO Number

            #region Origin and Destination

            // Set pickup location
            gcmAPI.gcmWebService.BookingPickupLocation pickupLocation = new gcmAPI.gcmWebService.BookingPickupLocation();
            pickupLocation.Name                = json.origName;
            pickupLocation.Email               = json.origEmail;
            pickupLocation.Company             = json.origCompany;
            pickupLocation.Phone               = json.origPhone;
            pickupLocation.Fax                 = json.origFax;
            pickupLocation.Address1            = json.origAddress1;
            pickupLocation.Address2            = json.origAddress2;
            pickupLocation.City                = json.origCity;
            pickupLocation.State               = json.origState;
            pickupLocation.Zip                 = json.origZip;
            pickupLocation.DispatchAddressesId = 1;

            // Set destination location
            gcmAPI.gcmWebService.BookingDestinationLocation destinationLocation = new gcmAPI.gcmWebService.BookingDestinationLocation();
            destinationLocation.Name     = json.destName;
            destinationLocation.Email    = json.destEmail;
            destinationLocation.Company  = json.destCompany;
            destinationLocation.Phone    = json.destPhone;
            destinationLocation.Fax      = json.destFax;
            destinationLocation.Address1 = json.destAddress1;
            destinationLocation.Address2 = json.destAddress2;
            destinationLocation.City     = json.destCity;
            destinationLocation.State    = json.destState;
            destinationLocation.Zip      = json.destZip;

            #endregion

            string SessionID = json.SessionID;
            logger.Append(string.Concat("SessionID: ", json.SessionID, ", "));

            //int testInt;
            List <gcmAPI.gcmWebService.LTLBookingPiece> bookingLineItems = new List <gcmAPI.gcmWebService.LTLBookingPiece>();

            for (byte i = 0; i < json.lineItems.Length; i++)
            {
                gcmAPI.gcmWebService.LTLBookingPiece lineItem = new gcmAPI.gcmWebService.LTLBookingPiece();
                lineItem.Tag            = json.lineItems[i].Tag;
                lineItem.Description    = json.lineItems[i].Description;
                lineItem.NumberOfPallet = json.lineItems[i].NumberOfPallet;

                // Testing
                logger.Append(string.Concat("Tag", i.ToString(), ": ", lineItem.Tag, ", "));
                logger.Append(string.Concat("Description", i.ToString(), ": ", lineItem.Description, ", "));
                logger.Append(string.Concat("NumberOfPallet", i.ToString(), ": ", lineItem.NumberOfPallet, ", "));

                bookingLineItems.Add(lineItem);
            }


            HelperFuncs.writeToSiteErrors("LTL Booking Restful", logger.ToString());

            #region Not used
            //Set other line items
            //gcmWebService.LTLBookingPiece[] bookingLineItems = new gcmWebService.LTLBookingPiece[1];

            //Set first line item for booking
            //bookingLineItems[0] = new gcmWebService.LTLBookingPiece();

            //// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[0].Tag = form.Get("Tag");

            ////bookingLineItems[0].NMFC = 50;
            //bookingLineItems[0].NumberOfPallet = 1;
            //bookingLineItems[0].Description = form.Get("Description");

            //Set second line item for booking
            //bookingLineItems[1] = new MyWebReference.LTLBookingPiece();

            ////// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[1].Tag = "2";

            //bookingLineItems[1].NMFC = 60;
            //bookingLineItems[1].NumberOfPallet = 10;
            //bookingLineItems[1].Description = "TEST";
            #endregion

            string comments = "TEST";
            //string comments = null;
            //bool insuranceRequired = true;
            bool   insuranceRequired = false;
            double declaredValue     = 100;

            //
            //Book an LTL rate and getting the BOL and insurance certificate PDF url
            gcmAPI.gcmWebService.LTLBookingReply lbr = rs.CreateLTLBooking2(SessionID, bookingKey, customerType, thirdPartyBilling, shipmentDate, readyTime, closeTime, bolSendTo,
                                                                            poNumber, pickupLocation, destinationLocation, bookingLineItems.ToArray(), comments, insuranceRequired, declaredValue);

            HelperFuncs.writeToSiteErrors("LTL Booking Restful result", string.Concat("notification=", lbr.Notification, "&shipmentID=", lbr.ShipmentId, "&=BOLURL", lbr.BOLURL));

            return(lbr.ToJSON());

            //return string.Concat("{ \"notification\" : \"", lbr.Notification, "\", \"shipmentID\" : ", lbr.ShipmentId, ", \"BOLURL", lbr.BOLURL, " }");

            //return "test test";
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("LTL Booking Restful", e.ToString());
            return("{ \"Notification\" : \"error\" }");
            //return lbr.ToJSON;
        }
    }