Esempio n. 1
0
        public static async Task <HttpResponseMessage> GetTaskByBorderau(FluxAOptimiser FluxMroad)
        {
            //TODO faire le traitement
            #region creation de l'objet FluxLivUrbant contenant la liste de l'objet FluxMroad
            ListFluxLivUrbants    ListFluxLivUrbant = new ListFluxLivUrbants();
            List <FluxLivUrbantz> FluxVsUrbantz     = new List <FluxLivUrbantz>();
            foreach (var item in FluxMroad.TrajetList)
            {
                FluxVsUrbantz.Add(new FluxLivUrbantz());
            }
            ListFluxLivUrbant.ListFluxLivUrbantz = FluxVsUrbantz;
            #endregion

            #region Remplir le modèle flux livraison de Mroad à Urbantz
            for (int i = 0; i < FluxVsUrbantz.Count; i++)
            {
                var TypeLivraison = "";
                if (FluxMroad.TrajetList[i].CommandeEntete.Trafic.Code == "LIV")
                {
                    TypeLivraison = "delivery";
                }
                else if (FluxMroad.TrajetList[i].CommandeEntete.Trafic.Code == "REP")
                {
                    TypeLivraison = "pickup";
                }
                else if (FluxMroad.TrajetList[i].CommandeEntete.Trafic.Code == "SAV")
                {
                    FluxMroad.TrajetList[i].CommandeEntete.Trafic.Code = "LIV";
                    TypeLivraison = "delivery";
                }
                #region
                //calcul de numero de telephone
                var Telephone        = "";
                var TelInternational = "";
                if (FluxMroad.TrajetList[i].LocaliteArrivee.CodePays == "FR")
                {
                    if ((FluxMroad.TrajetList[i].CommandeEntete.PortableDestinataire != null) && ((FluxMroad.TrajetList[i].CommandeEntete.PortableDestinataire.Substring(0, 2) == "06") ||
                                                                                                  (FluxMroad.TrajetList[i].CommandeEntete.PortableDestinataire.Substring(0, 2) == "07"))
                        )

                    {
                        Telephone = FluxMroad.TrajetList[i].CommandeEntete.PortableDestinataire;
                    }
                    else if (FluxMroad.TrajetList[i].CommandeEntete.TelephoneDestinataire != null)
                    {
                        if ((FluxMroad.TrajetList[i].CommandeEntete.TelephoneDestinataire.Substring(0, 2) == "06") ||
                            (FluxMroad.TrajetList[i].CommandeEntete.TelephoneDestinataire.Substring(0, 2) == "07"))

                        {
                            Telephone = FluxMroad.TrajetList[i].CommandeEntete.TelephoneDestinataire;
                        }
                    }
                    //changement du téléphone au format international


                    if (Telephone != "")
                    {
                        if ((Telephone.Substring(0, 2) == "06") || (Telephone.Substring(0, 2) == "07"))
                        {
                            TelInternational = string.Concat("+33", Telephone.Substring(1, Telephone.Length - 1));
                        }
                        else if (Telephone.Substring(0, 3) == "+33")
                        {
                            TelInternational = Telephone;
                        }
                    }
                }


                else if ((FluxMroad.TrajetList[i].LocaliteArrivee.CodePays == "LU") || (FluxMroad.TrajetList[i].LocaliteArrivee.CodePays == "BE"))

                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.PortableDestinataire != null)
                    {
                        TelInternational = FluxMroad.TrajetList[i].CommandeEntete.PortableDestinataire;
                    }
                    else
                    {
                        TelInternational = FluxMroad.TrajetList[i].CommandeEntete.TelephoneDestinataire;
                    }
                }

                #endregion


                FluxVsUrbantz[i].taskId        = FluxMroad.TrajetList[i].CommandeEntete.NumeroRecepisse;
                FluxVsUrbantz[i].hubName       = string.Concat("VIR", FluxMroad.Agence.CodeNumerique);
                FluxVsUrbantz[i].type          = TypeLivraison;
                FluxVsUrbantz[i].taskReference = FluxMroad.TrajetList[i].CommandeEntete.IdCommandeEntete.ToString();
                //Nom du Do
                FluxVsUrbantz[i].client           = FluxMroad.TrajetList[i].CommandeEntete.Payeur.Nom;
                FluxVsUrbantz[i].contact.email    = FluxMroad.TrajetList[i].CommandeEntete.MailDestinataire;
                FluxVsUrbantz[i].contact.language = FluxMroad.TrajetList[i].LocaliteArrivee.CodePays;
                FluxVsUrbantz[i].contact.phone    = TelInternational;
                FluxVsUrbantz[i].contact.name     = FluxMroad.TrajetList[i].CommandeEntete.NomDestinataire;
                FluxVsUrbantz[i].contact.person   = FluxMroad.TrajetList[i].NomArrivee;
                FluxVsUrbantz[i].address.street   = FluxMroad.TrajetList[i].Adresse1Arrivee;
                //FluxVsUrbantz[i].address.street = "";
                FluxVsUrbantz[i].address.country = FluxMroad.TrajetList[i].LocaliteArrivee.CodePays;
                FluxVsUrbantz[i].address.city    = FluxMroad.TrajetList[i].LocaliteArrivee.Nom;
                FluxVsUrbantz[i].address.zip     = FluxMroad.TrajetList[i].LocaliteArrivee.CodePostal;
                if (FluxMroad.TrajetList[i].CommandeEntete.Ascenseur == false)
                {
                    FluxVsUrbantz[i].metadata.libelle_adresse = "ASC=NON";
                }
                else if (FluxMroad.TrajetList[i].CommandeEntete.Ascenseur == true)
                {
                    FluxVsUrbantz[i].metadata.libelle_adresse = "ASC=OUI";
                }

                FluxVsUrbantz[i].metadata.Tel_supplementaire = FluxMroad.TrajetList[i].CommandeEntete.TelephoneDestinataire;
                FluxVsUrbantz[i].metadata.Agence             = string.Concat("VIR", FluxMroad.Agence.CodeNumerique);
                FluxVsUrbantz[i].instructions     = FluxMroad.TrajetList[i].CommandeEntete.InstructionLivraison;
                FluxVsUrbantz[i].timeWindow.start = FluxMroad.TrajetList[i].CommandeEntete.THeureDebutRDV.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.000Z");
                FluxVsUrbantz[i].timeWindow.stop  = FluxMroad.TrajetList[i].CommandeEntete.THeureFinRDV.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.000Z");
                FluxVsUrbantz[i].date             = DateTime.UtcNow;

                FluxVsUrbantz[i].price            = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotauxMontant.ChiffreAffaire;
                FluxVsUrbantz[i].dimensions.price = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotauxMontant.ChiffreAffaire.ToString().Replace(",", ".");

                #region calcul temps de montage
                int tmps_poids = 0;
                if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                {
                    tmps_poids = 15;
                }
                if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                {
                    tmps_poids = 15;
                }
                if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                {
                    tmps_poids = 30;
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                {
                    tmps_poids = 30;
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                {
                    tmps_poids = 30;
                }
                if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                {
                    tmps_poids = 45;
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                {
                    tmps_poids = 30;
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                {
                    tmps_poids = 15;
                }

                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 400)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 15;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 15;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 20;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 20;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 20;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 32;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 20;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 15;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 300)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 10;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 10;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 15;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 15;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 15;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 27;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 15;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 15;
                    }
                }

                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 200)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 10;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 10;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 15;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 12;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 12;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 22;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 12;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 15;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 150)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 12;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 12;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 22;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 12;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 10;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 120)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 12;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 12;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 19;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 12;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 10;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 100)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 10;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 15;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 10;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 80)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 5;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 5;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 7;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 10;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 15;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 10;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 50)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 5;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 5;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS")
                    {
                        tmps_poids = 7;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 7;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 7;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 7;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 10;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids < 30)
                {
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LX")
                    {
                        tmps_poids = 3;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LC") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "PDC"))
                    {
                        tmps_poids = 3;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LS") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LIV"))
                    {
                        tmps_poids = 5;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LD")
                    {
                        tmps_poids = 5;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "RS")
                    {
                        tmps_poids = 5;
                    }
                    if ((FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LI") || (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "DMI"))
                    {
                        tmps_poids = 10;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LM")
                    {
                        tmps_poids = 5;
                    }
                    if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "LE")
                    {
                        tmps_poids = 10;
                    }
                }
                if (FluxMroad.TrajetList[i].CommandeEntete.Prestation.Code == "CC")
                {
                    tmps_poids = 3;
                }
                #endregion



                //en dur pour le moment
                FluxVsUrbantz[i].serviceTime       = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalTempsMontage + tmps_poids;
                FluxVsUrbantz[i].dimensions.weight = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids.ToString().Replace(",", ".");
                FluxVsUrbantz[i].dimensions.volume = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalVolume.ToString().Replace(",", ".");
                FluxVsUrbantz[i].quantity          = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalColis.ToString();

                for (int j = 0; j < FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList?.Count; j++)
                {
                    if (j == 0)
                    {
                        FluxVsUrbantz[i].items.Add(new Item
                        {
                            barcode     = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CodeBarre,
                            description = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.Article.Libelle,
                            name        = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.LibelleRubrique,
                            type        = "COL",
                            quantity    = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.NbArticle.ToString(),
                            dimensions  = new Dimensions()
                            {
                                volume = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalVolume.ToString().Replace(",", "."),
                                weight = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotaux.TotalPoids.ToString().Replace(",", "."),
                                price  = FluxMroad.TrajetList[i].CommandeEntete.CommandeTotauxMontant.ChiffreAffaire != null ? FluxMroad.TrajetList[i].CommandeEntete.CommandeTotauxMontant.ChiffreAffaire.ToString().Replace(",", ".") : string.Empty
                            },
                            labels = new List <string>()
                            {
                                FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.Prestation.Code
                            }
                        });
                    }
                    else
                    {
                        FluxVsUrbantz[i].items.Add(new Item
                        {
                            barcode     = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CodeBarre,
                            description = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.Article.Libelle,
                            name        = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.LibelleRubrique,
                            type        = "COL",
                            quantity    = FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.NbArticle.ToString(),
                            dimensions  = new Dimensions()
                            {
                                volume = "",
                                weight = "",
                                price  = ""
                            },
                            labels = new List <string>()
                            {
                                FluxMroad.TrajetList[i].CommandeEntete.CommandeColisList[j].CommandeDetail.Prestation.Code
                            }
                        });
                    }
                }
            }

            #endregion


            var json = new JavaScriptSerializer().Serialize(ListFluxLivUrbant.ListFluxLivUrbantz);
            json = json.Replace("\u0027", "");
            var passflux = SendData(ListFluxLivUrbant.ListFluxLivUrbantz);
            await System.Threading.Tasks.Task.Delay(500);

            return(await await System.Threading.Tasks.Task.FromResult(passflux));
        }
Esempio n. 2
0
        //Creation du flux à envoyer à Notico
        public static async Task <HttpResponseMessage> FluxRdvVersNotico(List <ElementEnvoiSms> FluxRdv)
        {
            //TODO faire le traitement ici le mapping ....
            #region creation de l'objet Interventions contenant le meme nombre d'intervention que le trajet list de l'objet Borderau
            ListFluxLivUrbants    FluxRdvUrb      = new ListFluxLivUrbants();
            List <FluxLivUrbantz> FluxRdvListUrbz = new List <FluxLivUrbantz>();
            foreach (var item in FluxRdv)
            {
                FluxRdvListUrbz.Add(new FluxLivUrbantz());
            }
            FluxRdvUrb.ListFluxLivUrbantz = FluxRdvListUrbz;
            #endregion

            for (int i = 0; i < FluxRdvListUrbz.Count; i++)
            {
                //Traitement du numero de téléphone
                var telSms = "";
                if ((FluxRdv[i].Commande.PortableDestinataire != null) && ((FluxRdv[i].Commande.PortableDestinataire.Substring(0, 2) == "06") || (FluxRdv[i].Commande.PortableDestinataire.Substring(0, 2) == "07")))
                {
                    telSms = FluxRdv[i].Commande.PortableDestinataire;
                }

                else if ((FluxRdv[i].Commande.PortableDestinataire != null) && ((FluxRdv[i].Commande.PortableDestinataire.Substring(0, 4) == "+337") || (FluxRdv[i].Commande.PortableDestinataire.Substring(0, 4) == "+336")))
                {
                    telSms = FluxRdv[i].Commande.PortableDestinataire;
                }

                else if ((FluxRdv[i].Commande.PortableDestinataire != null) && (FluxRdv[i].Commande.PortableDestinataire.Substring(0, 4) == "0044"))
                {
                    telSms = FluxRdv[i].Commande.PortableDestinataire;
                }

                else if ((FluxRdv[i].Commande.TelephoneDestinataire != null) && ((FluxRdv[i].Commande.TelephoneDestinataire.Substring(0, 2) == "06") || (FluxRdv[i].Commande.TelephoneDestinataire.Substring(0, 2) == "07")))
                {
                    telSms = FluxRdv[i].Commande.TelephoneDestinataire;
                }

                else if ((FluxRdv[i].Commande.TelephoneDestinataire != null) && ((FluxRdv[i].Commande.TelephoneDestinataire.Substring(0, 4) == "+337") || (FluxRdv[i].Commande.TelephoneDestinataire.Substring(0, 4) == "+336")))
                {
                    telSms = FluxRdv[i].Commande.TelephoneDestinataire;
                }

                else if ((FluxRdv[i].Commande.TelephoneDestinataire != null) && (FluxRdv[i].Commande.TelephoneDestinataire.Substring(0, 4) == "0044"))
                {
                    telSms = FluxRdv[i].Commande.TelephoneDestinataire;
                }

                else if ((FluxRdv[i].Commande.PortableDestinataire == null) && (FluxRdv[i].Commande.TelephoneDestinataire == null))
                {
                    telSms = null;
                }

                var TelDest = "";
                if ((telSms != null) && ((telSms.Substring(0, 2) == "06") || (telSms.Substring(0, 2) == "07")))
                {
                    TelDest = string.Concat("+33", telSms.Substring(1, telSms.Length - 1));
                }
                else if ((telSms != null) && (telSms.Substring(0, 3) == "+33"))
                {
                    TelDest = telSms;
                }

                else if ((telSms != null) && (telSms.Substring(0, 4) == "0044"))
                {
                    TelDest = string.Concat("+", telSms.Substring(2, telSms.Length - 2));
                }
                // Traitement du nom du donneur d'ordre

                string Do = "";
                if (FluxRdv[i].Commande.DonneurOrdre.ServiceTiersList?.Count > 0)
                {
                    if (FluxRdv[i].Commande.DonneurOrdre.ServiceTiersList[0].Interlocuteur == null)
                    {
                        Do = (FluxRdv[i].Commande.DonneurOrdre.Nom);
                    }
                    else
                    {
                        Do = FluxRdv[i].Commande.DonneurOrdre.ServiceTiersList[0].Interlocuteur;
                    }
                }


                FluxRdvListUrbz[i].taskId  = FluxRdv[i].Commande.IdCommandeEntete;
                FluxRdvListUrbz[i].hubName = string.Concat("Agence ", FluxRdv[i].CodeAgence.ToString());
                FluxRdvListUrbz[i].client  = Do;
                //infos du contact
                FluxRdvListUrbz[i].contact.person   = FluxRdv[i].Commande.NomDestinataire;
                FluxRdvListUrbz[i].contact.name     = FluxRdv[i].Commande.NomDestinataire;
                FluxRdvListUrbz[i].contact.phone    = TelDest;
                FluxRdvListUrbz[i].contact.email    = FluxRdv[i].Commande.MailDestinataire;
                FluxRdvListUrbz[i].contact.language = "Fr";
                //infos adresse
                FluxRdvListUrbz[i].address.street    = "rue les chemins";
                FluxRdvListUrbz[i].address.zip       = "35120";
                FluxRdvListUrbz[i].address.city      = "Rennes";
                FluxRdvListUrbz[i].address.country   = "Fr";
                FluxRdvListUrbz[i].price             = null;
                FluxRdvListUrbz[i].dimensions.weight = "";
                FluxRdvListUrbz[i].dimensions.volume = "";
                FluxRdvListUrbz[i].dimensions.price  = "";
                FluxRdvListUrbz[i].quantity          = "";
                FluxRdvListUrbz[i].type        = "delivery";
                FluxRdvListUrbz[i].serviceTime = 0;
            }
            var json = new JavaScriptSerializer().Serialize(FluxRdvUrb.ListFluxLivUrbantz);
            json = json.Replace("\u0027", "");
            var passflux = PassComplexDat(FluxRdvUrb.ListFluxLivUrbantz);
            await System.Threading.Tasks.Task.Delay(500);

            return(await await System.Threading.Tasks.Task.FromResult(passflux));
        }