Пример #1
0
        /// <summary>
        /// This method return a list of Tarifs.
        /// </summary>
        /// <param name="element">Migration element.</param>
        /// <param name="id">Id of the element.</param>
        /// <param name="quantite">Quantity of the element.</param>
        /// <returns>List of tarifs.</returns>
        public List <Tarifs> GetTarifsForImmeuble(MigrationElement element, string id, string quantite)
        {
            var returnedValues = from xml in _xdoc.Descendants("Articles")
                                 where (id.Equals(xml.Attribute("ID").Value))
                                 select new Tarifs
            {
                Id            = xml.Attribute("ID").Value,
                Name          = xml.Attribute("nom").Value,
                Releve        = float.Parse(xml.Attribute("releve").Value),
                Value         = float.Parse(xml.Attribute("value").Value),
                Vente         = float.Parse(xml.Attribute("vente").Value),
                LocationMax15 = float.Parse(xml.Attribute("locationMax15").Value)
            };

            return(returnedValues.ToList());
        }
Пример #2
0
        /// <summary>
        /// Method the process the value to Excel
        /// </summary>
        /// <param name="currentExcel">Excel file instance.</param>
        /// <param name="currentElement">Current data element.</param>
        /// <param name="rowCount">The row where the data will be placed.</param>
        private void CoreBuiness(ExcelExportHelper currentExcel, MigrationElement currentElement, int rowCount, string saleseName)
        {
            //int tot = currentElement.Element.TotEau + currentElement.Element.TotInteg + currentElement.Element.TotNchauf;

            currentExcel.InsertRows(rowCount);

            if (currentElement.Element.TotalDevice < 51)
            {
                for (int i = 1; i < 40; i++)
                {
                    currentExcel.SetLineColor(rowCount, i);
                }
            }
            else
            {
                for (int i = 1; i < 40; i++)
                {
                    currentExcel.SetSecondLineColor(rowCount, i);
                }
            }

            currentExcel.SetCell(rowCount, 1, saleseName);
            currentExcel.SetCell(rowCount, 2, currentElement.Site);
            currentExcel.SetCell(rowCount, 4, currentElement.NumeroImmeuble);
            currentExcel.SetCell(rowCount, 6, currentElement.Element.TotalAdressImeuble);
            currentExcel.SetCell(rowCount, 7, currentElement.CodePostalImmeuble);
            currentExcel.SetCell(rowCount, 8, currentElement.LocaliteImmeuble);
            currentExcel.SetCell(rowCount, 9, currentElement.Element.CodeNameGerant);
            currentExcel.SetCell(rowCount, 10, currentElement.ChauffageNombreNRad);
            currentExcel.SetCell(rowCount, 11, "DR3");
            currentExcel.SetCell(rowCount, 12, currentElement.Element.Dop3RadioChaufLocatValue);
            currentExcel.SetCell(rowCount, 13, currentElement.Element.Dop3RadioChaufVenteValue);
            currentExcel.SetCell(rowCount, 14, currentElement.Element.Dop3RadioChaufRelevValue);

            string TypeText = "";

            if (currentElement.Element.TotEau > 0)
            {
                if (currentElement.Element.TotNEauch > 0 & currentElement.Element.TotNEauFr == 0)
                {
                    TypeText = "EC";
                }
                else if (currentElement.Element.TotNEauch == 0 & currentElement.Element.TotNEauFr > 0)
                {
                    TypeText = "EF";
                }
                else
                {
                    TypeText = "EF EC";
                }
            }

            currentExcel.SetCell(rowCount, 15, currentElement.Element.TotEau);
            currentExcel.SetCell(rowCount, 16, TypeText);
            currentExcel.SetCell(rowCount, 17, currentElement.Element.DomaquaTotalLocatiValue);
            currentExcel.SetCell(rowCount, 18, currentElement.Element.DomaquaTotalVenteValue);
            currentExcel.SetCell(rowCount, 19, currentElement.Element.DomaquaTotalReleveValue);

            currentExcel.SetCell(rowCount, 20, currentElement.Element.TotInteg);
            currentExcel.SetCell(rowCount, 21, "RADIO");
            currentExcel.SetCell(rowCount, 22, currentElement.Element.SensonicIn1_2LocatValue);
            currentExcel.SetCell(rowCount, 23, currentElement.Element.SensonicIn1_2VenteValue);
            currentExcel.SetCell(rowCount, 24, currentElement.Element.SensonicIn1_2RelevValue);

            currentExcel.SetCell(rowCount, 28, currentElement.DocumentName);
            currentExcel.SetCell(rowCount, 29, DateTime.Now.ToString("dd/MM/yyyy"));
        }
Пример #3
0
        /// <summary>
        /// Initialize a new word element to process.
        /// </summary>
        /// <param name="currentElement">Current Element.</param>
        /// <param name="tarifsPath">Path of the </param>
        public WordElement(MigrationElement currentElement, string tarifsPath)
        {
            CodeNameGerant = !string.IsNullOrEmpty(currentElement.NomDeGerant)
                                        ? currentElement.NomDeGerant : currentElement.NomDeGerant2;
            CodeAdresseGerant = !string.IsNullOrEmpty(currentElement.AdresseGerant2)
                                ? currentElement.AdresseGerant2: currentElement.AdresseGerant1;
            TotalAdresseGerant = CodeAdresseGerant + ", " + currentElement.CodePostauxGerant + " " + currentElement.LocaliteGerant;
            CodeOffreNum       = currentElement.Site + "-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.ToString("MM") + "-" + currentElement.NumeroImmeuble;
            CodeImmeuble       = currentElement.NumeroImmeuble;
            CodeAdressIm       = !string.IsNullOrEmpty(currentElement.AdresseImmeuble1)
                                           ? currentElement.AdresseImmeuble1
                                           : currentElement.AdresseImmeuble2;
            TotalAdressImeuble = CodeAdressIm + ", " + currentElement.CodePostalImmeuble + " " +
                                 currentElement.LocaliteImmeuble;

            NbrChauf  = currentElement.ChauffageNombreRad;
            NbrNChauf = currentElement.ChauffageNombreNRad;

            NbrEauCh  = currentElement.EauChaudeNombreRad;
            NbrNEauCh = currentElement.EauChaudeNombreNRad;

            NbrEauFr  = currentElement.EauFroideNombreRad;
            NbrNEauFr = currentElement.EauFroideNombreNRad;

            NbrInteg  = currentElement.IntegrateurNombreRad;
            NbrNInteg = currentElement.IntegrateurNombreNRad;

            List <Tarifs> prices = new ReadPriceXML(tarifsPath).GetTarifsForImmeuble();

            int totNchauf = 0;
            int totNEauch = 0;
            int totNEauFr = 0;
            int totInteg  = 0;
            int totalEau  = 0;

            NChaufPrices = new List <Tarifs>();
            NEauChPrices = new List <Tarifs>();
            NEauFrPrices = new List <Tarifs>();
            NToEauPrices = new List <Tarifs>();
            NIntegPrices = new List <Tarifs>();

            if (!string.IsNullOrEmpty(NbrNChauf))
            {
                int.TryParse(NbrNChauf, out totNchauf);
                TotNchauf    = totNchauf;
                NChaufPrices = Compteur(totNchauf, prices, "doprimoIIIRadio", false, true);
            }

            if (!string.IsNullOrEmpty(NbrNInteg))
            {
                int.TryParse(NbrNInteg, out totInteg);
                NIntegPrices = Compteur(totInteg, prices, "sensonicRadio", true, false);
                TotInteg     = totInteg;
            }

            if (!string.IsNullOrEmpty(NbrNEauCh) && !string.IsNullOrEmpty(NbrNEauFr))
            {
                int eauCh = 0;
                int.TryParse(NbrNEauCh, out eauCh);
                int eauFr = 0;
                int.TryParse(NbrNEauFr, out eauFr);

                totalEau  = eauCh + eauFr;
                TotNEauch = eauCh;
                TotNEauFr = eauFr;
                totNEauch = eauCh;
                totNEauFr = eauFr;
                TotEau    = totalEau;
            }
            else if (string.IsNullOrEmpty(NbrNEauCh) && !string.IsNullOrEmpty(NbrNEauFr))
            {
                int eauCh = 0;
                int.TryParse(NbrNEauCh, out eauCh);

                TotNEauch = eauCh;
                totalEau  = eauCh;
                TotEau    = totalEau;
            }
            else if (!string.IsNullOrEmpty(NbrNEauCh) && string.IsNullOrEmpty(NbrNEauFr))
            {
                int eauFr = 0;
                int.TryParse(NbrNEauCh, out eauFr);

                TotNEauFr = eauFr;
                totalEau  = eauFr;
                TotEau    = totalEau;
            }

            NToEauPrices = Compteur(totalEau, prices, "domaquaRadio", false, false);

            if (!string.IsNullOrEmpty(NbrNEauCh))
            {
                int.TryParse(NbrNEauCh, out totNEauch);
                NEauChPrices = Compteur(totNEauch, prices, "domaquaRadio", false, false);
            }
            if (!string.IsNullOrEmpty(NbrNEauFr))
            {
                int.TryParse(NbrNEauFr, out totNEauFr);
                NEauFrPrices = Compteur(totNEauFr, prices, "domaquaRadio", false, false);
            }



            var doprimo3RadioChauf = NChaufPrices.Find(x => x.Id == "doprimoIIIRadio");
            var domaAquaEauTot     = NToEauPrices.Find(x => x.Id == "domaquaRadio");

            var sensonic1_2Integ = NIntegPrices.Find(x => x.Id == "sensonicRadio1_2");
            var sensonic3_4Integ = NIntegPrices.Find(x => x.Id == "sensonicRadio3_4");

            string zeroVal = "N/A";

            int totalDevice = totNchauf + totalEau + totInteg;

            TotalDevice = totalDevice;

            float totalRadioRelevePrice = 0;
            float totaldomaqRelevePrice = 0;
            float totalSen12RelevePrice = 0;
            float totalSen34RelevePrice = 0;

            if (totNchauf == 0)
            {
                Dop3RadioChaufVente = zeroVal;
                Dop3RadioChaufRelev = zeroVal;
                Dop3RadioChaufLocat = zeroVal;

                Dop3RadioChaufVenteValue = 0;
                Dop3RadioChaufRelevValue = 0;
                Dop3RadioChaufLocatValue = 0;
            }
            else
            {
                Dop3RadioChaufVente      = doprimo3RadioChauf.Vente.ToString();
                Dop3RadioChaufVenteValue = doprimo3RadioChauf.Vente;
                Dop3RadioChaufRelev      = doprimo3RadioChauf.Releve.ToString();
                Dop3RadioChaufRelevValue = doprimo3RadioChauf.Releve;

                totalRadioRelevePrice = TotNchauf * Dop3RadioChaufRelevValue;

                if (totalDevice < 8)
                {
                    Dop3RadioChaufLocat      = zeroVal;
                    Dop3RadioChaufLocatValue = 0;
                }
                else
                {
                    Dop3RadioChaufLocat      = doprimo3RadioChauf.LocationMax15.ToString();
                    Dop3RadioChaufLocatValue = doprimo3RadioChauf.LocationMax15;
                }
            }

            DomaquaTotal = totalEau.ToString();
            if (totalEau == 0)
            {
                DomaquaTotalReleveValue = 0;
                DomaquaTotalVenteValue  = 0;
                DomaquaTotalLocatiValue = 0;

                DomaAquaEauChRVente = zeroVal;
                DomaAquaEauChRRelev = zeroVal;
                DomaAquaEauChRLocat = zeroVal;

                DomaAquaEauFrRVente = zeroVal;
                DomaAquaEauFrRRelev = zeroVal;
                DomaAquaEauFrRLocat = zeroVal;

                DomaquaTotalReleve = zeroVal;
                DomaquaTotalVente  = zeroVal;
                DomaquaTotalLocati = zeroVal;
            }
            else
            {
                DomaquaTotalReleve = domaAquaEauTot.Releve.ToString();
                DomaquaTotalVente  = domaAquaEauTot.Vente.ToString();

                DomaquaTotalReleveValue = domaAquaEauTot.Releve;
                DomaquaTotalVenteValue  = domaAquaEauTot.Vente;

                totaldomaqRelevePrice = totalEau * DomaquaTotalReleveValue;

                if (TotalDevice < 4)
                {
                    DomaquaTotalLocati      = zeroVal;
                    DomaquaTotalLocatiValue = 0;
                }
                else
                {
                    DomaquaTotalLocati      = domaAquaEauTot.LocationMax15.ToString();
                    DomaquaTotalLocatiValue = domaAquaEauTot.LocationMax15;
                }

                if (totNEauFr == 0)
                {
                    DomaAquaEauFrRVente = zeroVal;
                    DomaAquaEauFrRRelev = zeroVal;
                    DomaAquaEauFrRLocat = zeroVal;
                }
                else
                {
                    DomaAquaEauFrRVente = DomaquaTotalVente;
                    DomaAquaEauFrRRelev = DomaquaTotalReleve;
                    DomaAquaEauFrRLocat = DomaquaTotalLocati;
                }

                if (totNEauch == 0)
                {
                    DomaAquaEauChRVente = zeroVal;
                    DomaAquaEauChRRelev = zeroVal;
                    DomaAquaEauChRLocat = zeroVal;
                }
                else
                {
                    DomaAquaEauChRVente = DomaquaTotalVente;
                    DomaAquaEauChRRelev = DomaquaTotalReleve;
                    DomaAquaEauChRLocat = DomaquaTotalLocati;
                }
            }

            if (totInteg == 0)
            {
                SensonicIn1_2Vente = zeroVal;
                SensonicIn1_2Relev = zeroVal;
                SensonicIn1_2Locat = zeroVal;

                SensonicIn3_4Vente = zeroVal;
                SensonicIn3_4Relev = zeroVal;
                SensonicIn3_4Locat = zeroVal;

                SensonicIn1_2RelevValue = 0;
                SensonicIn1_2LocatValue = 0;
                SensonicIn1_2VenteValue = 0;
                SensonicIn3_4VenteValue = 0;
                SensonicIn3_4RelevValue = 0;
                SensonicIn3_4LocatValue = 0;
            }
            else
            {
                SensonicIn1_2Vente = sensonic1_2Integ.Vente.ToString();
                SensonicIn1_2Relev = sensonic1_2Integ.Releve.ToString();

                SensonicIn3_4Vente = sensonic3_4Integ.Vente.ToString();
                SensonicIn3_4Relev = sensonic3_4Integ.Releve.ToString();

                SensonicIn1_2RelevValue = sensonic1_2Integ.Releve;
                SensonicIn1_2VenteValue = sensonic1_2Integ.Vente;
                SensonicIn3_4VenteValue = sensonic3_4Integ.Vente;
                SensonicIn3_4RelevValue = sensonic3_4Integ.Releve;

                totalSen12RelevePrice = totInteg * SensonicIn1_2RelevValue;
                totalSen34RelevePrice = totInteg * SensonicIn3_4RelevValue;

                if (TotalDevice < 2)
                {
                    SensonicIn1_2Locat = zeroVal;
                    SensonicIn3_4Locat = zeroVal;

                    SensonicIn1_2LocatValue = 0;
                    SensonicIn3_4LocatValue = 0;
                }
                else
                {
                    SensonicIn1_2Locat = sensonic1_2Integ.LocationMax15.ToString();
                    SensonicIn3_4Locat = sensonic3_4Integ.LocationMax15.ToString();

                    SensonicIn1_2LocatValue = sensonic1_2Integ.LocationMax15;
                    SensonicIn3_4LocatValue = sensonic3_4Integ.LocationMax15;
                }
            }

            float totalReleve = totalRadioRelevePrice + totaldomaqRelevePrice + totalSen12RelevePrice + totalSen34RelevePrice;

            if (totalReleve < 98)
            {
                if (totNchauf > 0)
                {
                    Dop3RadioChaufRelev      = "97,75€ (Forfait)";
                    Dop3RadioChaufRelevValue = 97.75f;
                }
                if (totalEau > 0)
                {
                    DomaquaTotalReleve = "97,75€ (Forfait)";
                }
                if (totNEauch > 0)
                {
                    DomaAquaEauChRRelev = "97,75€ (Forfait)";
                }
                if (totNEauFr > 0)
                {
                    DomaAquaEauFrRRelev = "97,75€ (Forfait)";
                }
                if (totInteg > 0)
                {
                    SensonicIn1_2Relev      = "97,75€ (Forfait)";
                    SensonicIn1_2RelevValue = 97.75f;
                }
                if (totInteg > 0)
                {
                    SensonicIn3_4Relev      = "97,75€ (Forfait)";
                    SensonicIn3_4RelevValue = 97.75f;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Method to create the template word and replace all tags by values.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="saveAs"></param>
        /// <param name="currentElement"></param>
        public void CreatWordDocument(object fileName, object saveAs, MigrationElement currentElement)
        {
            try
            {
                object missing = System.Reflection.Missing.Value;

                Application wordApp = new Application();

                //next line gives a bug :
                // http://stackoverflow.com/questions/2483659/interop-type-cannot-be-embedded
                //Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

                Microsoft.Office.Interop.Word.Document aDoc = null;

                if (File.Exists((string)fileName))
                {
                    DateTime today     = DateTime.Now;
                    object   readOnly  = false;
                    object   isVisible = false;

                    wordApp.Visible = false;

                    aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing,
                                                  ref missing, ref missing, ref missing, ref missing, ref missing,
                                                  ref missing, ref isVisible, ref missing, ref missing, ref missing,
                                                  ref missing);
                    aDoc.Activate();

                    FindAndReplace(wordApp, "CodeNameGerant", currentElement.Element.CodeNameGerant);
                    FindAndReplace(wordApp, "CodeAdresseGerant", currentElement.Element.CodeAdresseGerant);
                    FindAndReplace(wordApp, "CodePostauxGerant", currentElement.CodePostauxGerant);
                    FindAndReplace(wordApp, "LocaliteGerant", currentElement.LocaliteGerant);
                    FindAndReplace(wordApp, "CodeOffreNum", currentElement.Element.CodeOffreNum);
                    FindAndReplace(wordApp, "CodeImmeuble", currentElement.Element.CodeImmeuble);
                    FindAndReplace(wordApp, "CodeAdresseImeuble", currentElement.Element.TotalAdressImeuble);

                    if (currentElement.Element.TotNchauf > 0)
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/
                        FindAndReplace(wordApp, "CodeDPRLoc", currentElement.ChauffageNombreNRad);
                        FindAndReplace(wordApp, "PrixDPRLoc", currentElement.Element.Dop3RadioChaufLocat + " €");
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeDPRVente", currentElement.ChauffageNombreNRad);
                        FindAndReplace(wordApp, "PrixDPRVente", currentElement.Element.Dop3RadioChaufVente + " €");
                        /*************/
                        /** Reading **/
                        /*************/
                        FindAndReplace(wordApp, "CodeRep", currentElement.ChauffageNombreNRad);
                        FindAndReplace(wordApp, "PrixRep", currentElement.Element.Dop3RadioChaufRelev == "97,75€ (Forfait)" ? currentElement.Element.Dop3RadioChaufRelev : currentElement.Element.Dop3RadioChaufRelev + " €");
                    }
                    else
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/
                        FindAndReplace(wordApp, "CodeDPRLoc", "");
                        FindAndReplace(wordApp, "PrixDPRLoc", "");
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeDPRVente", "");
                        FindAndReplace(wordApp, "PrixDPRVente", "");
                        /*************/
                        /** Reading **/
                        /*************/
                        FindAndReplace(wordApp, "CodeRep", "");
                        FindAndReplace(wordApp, "PrixRep", "");
                    }
                    /*******************/
                    /** Location part **/
                    /*******************/
                    FindAndReplace(wordApp, "CodeDPRSLoc", "");
                    FindAndReplace(wordApp, "PrixDPRSLoc", "");
                    /*************/
                    /** Selling **/
                    /*************/
                    FindAndReplace(wordApp, "CodeDPRSVente", "");
                    FindAndReplace(wordApp, "PrixDPRSVente", "");

                    /*******************/
                    /** Location part **/
                    /*******************/
                    FindAndReplace(wordApp, "CodeDomaquaLoc", "");
                    FindAndReplace(wordApp, "PrixDomaquaLoc", "");
                    FindAndReplace(wordApp, "CodeDomaquaChLoc", "");
                    FindAndReplace(wordApp, "PrixDomaquaChLoc", "");
                    /*************/
                    /** Selling **/
                    /*************/
                    FindAndReplace(wordApp, "CodeDomaquaVente", "");
                    FindAndReplace(wordApp, "PrixDomaquaVente", "");
                    FindAndReplace(wordApp, "CodeDomaquaChVente", "");
                    FindAndReplace(wordApp, "PrixDomaquaChVente", "");

                    if (currentElement.Element.TotNEauFr > 0)
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/

                        //06/03/2013: changement demandé par edouard!! si la location n'est pas permise (c'est à dire en dessous de la limite)
                        //Alors les valeurs ne doivent pas se voir.

                        if (currentElement.Element.DomaAquaEauFrRLocat == "0")
                        {
                            FindAndReplace(wordApp, "CodeDomaquaRLoc", "");
                            FindAndReplace(wordApp, "PrixDomaquaRLoc", "");
                        }
                        else
                        {
                            FindAndReplace(wordApp, "CodeDomaquaRLoc", currentElement.EauFroideNombreNRad);
                            FindAndReplace(wordApp, "PrixDomaquaRLoc", currentElement.Element.DomaAquaEauFrRLocat + " €");
                        }


                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeDomaquaRVente", currentElement.EauFroideNombreNRad);
                        FindAndReplace(wordApp, "PrixDomaquaRVente", currentElement.Element.DomaAquaEauFrRVente + " €");
                    }
                    else
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/
                        FindAndReplace(wordApp, "CodeDomaquaRLoc", "");
                        FindAndReplace(wordApp, "PrixDomaquaRLoc", "");
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeDomaquaRVente", "");
                        FindAndReplace(wordApp, "PrixDomaquaRVente", "");
                    }
                    /*******************/
                    /** Location part **/
                    /*******************/
                    FindAndReplace(wordApp, "CodeDomaquaChLoc", "");
                    FindAndReplace(wordApp, "PrixDomaquaLoc", "");
                    /*************/
                    /** Selling **/
                    /*************/
                    FindAndReplace(wordApp, "CodeDomaquaChVente", "");
                    FindAndReplace(wordApp, "PrixDomaquaVente", "");
                    if (currentElement.Element.TotNEauch > 0)
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/

                        //06/03/2013: changement demandé par edouard!! si la location n'est pas permise (c'est à dire en dessous de la limite)
                        //Alors les valeurs ne doivent pas se voir.
                        if (currentElement.Element.DomaAquaEauChRLocat == "0")
                        {
                            FindAndReplace(wordApp, "CodeDomaquaChRLoc", "");
                            FindAndReplace(wordApp, "PrixDomaquaChRLoc", "");
                        }
                        else
                        {
                            FindAndReplace(wordApp, "CodeDomaquaChRLoc", currentElement.EauChaudeNombreNRad);
                            FindAndReplace(wordApp, "PrixDomaquaChRLoc", currentElement.Element.DomaAquaEauChRLocat + " €");
                        }
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeDomaquaChRVente", currentElement.EauChaudeNombreNRad);
                        FindAndReplace(wordApp, "PrixDomaquaChRVente", currentElement.Element.DomaAquaEauChRVente + " €");
                    }
                    else
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/
                        FindAndReplace(wordApp, "CodeDomaquaChRLoc", "");
                        FindAndReplace(wordApp, "PrixDomaquaChRLoc", "");
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeDomaquaChRVente", "");
                        FindAndReplace(wordApp, "PrixDomaquaChRVente", "");
                    }
                    if (currentElement.Element.TotInteg > 0)
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/
                        FindAndReplace(wordApp, "CodeSensonicLoc", currentElement.IntegrateurNombreNRad);
                        FindAndReplace(wordApp, "PrixSensonicLoc", currentElement.Element.SensonicIn1_2Locat + " €");
                        FindAndReplace(wordApp, "CodeSensonicRLoc", currentElement.IntegrateurNombreNRad);
                        FindAndReplace(wordApp, "PrixSensonicRLoc", currentElement.Element.SensonicIn3_4Locat + " €");
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeSensonicVente", currentElement.IntegrateurNombreNRad);
                        FindAndReplace(wordApp, "PrixSensonicVente", currentElement.Element.SensonicIn1_2Vente + " €");
                        FindAndReplace(wordApp, "CodeSensonicRVente", currentElement.IntegrateurNombreNRad);
                        FindAndReplace(wordApp, "PrixSensonicRVente", currentElement.Element.SensonicIn3_4Vente + " €");
                    }
                    else
                    {
                        /*******************/
                        /** Location part **/
                        /*******************/
                        FindAndReplace(wordApp, "CodeSensonicLoc", "");
                        FindAndReplace(wordApp, "PrixSensonicLoc", "");
                        FindAndReplace(wordApp, "CodeSensonicRLoc", "");
                        FindAndReplace(wordApp, "PrixSensonicRLoc", "");
                        /*************/
                        /** Selling **/
                        /*************/
                        FindAndReplace(wordApp, "CodeSensonicVente", "");
                        FindAndReplace(wordApp, "PrixSensonicVente", "");
                        FindAndReplace(wordApp, "CodeSensonicRVente", "");
                        FindAndReplace(wordApp, "PrixSensonicRVente", "");
                    }
                    if (currentElement.Element.TotEau > 0)
                    {
                        FindAndReplace(wordApp, "CodeEau", currentElement.Element.TotEau.ToString());
                        FindAndReplace(wordApp, "PrixEau", currentElement.Element.DomaquaTotalReleve == "97,75€ (Forfait)" ? currentElement.Element.DomaquaTotalReleve : currentElement.Element.DomaquaTotalReleve + " €");
                    }
                    else
                    {
                        FindAndReplace(wordApp, "CodeEau", "");
                        FindAndReplace(wordApp, "PrixEau", "");
                    }
                    if (currentElement.Element.TotInteg > 0)
                    {
                        FindAndReplace(wordApp, "CodeIntegr", currentElement.IntegrateurNombreNRad);

                        FindAndReplace(wordApp, "PrixIntegr", currentElement.Element.SensonicIn1_2Relev == "97,75€ (Forfait)" ? currentElement.Element.SensonicIn1_2Relev : currentElement.Element.SensonicIn1_2Relev + " €");

                        FindAndReplace(wordApp, "CodeElec", currentElement.IntegrateurNombreNRad);
                        FindAndReplace(wordApp, "PrixElec", currentElement.Element.SensonicIn3_4Relev == "97,75€ (Forfait)" ? currentElement.Element.SensonicIn3_4Relev : currentElement.Element.SensonicIn3_4Relev + " €");
                    }
                    else
                    {
                        FindAndReplace(wordApp, "CodeIntegr", "");
                        FindAndReplace(wordApp, "PrixIntegr", "");
                        FindAndReplace(wordApp, "CodeElec", "");
                        FindAndReplace(wordApp, "PrixElec", "");
                    }
                }
                else
                {
                    Console.WriteLine("Error");
                    return;
                }

                aDoc.SaveAs(ref saveAs, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                            ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                aDoc.Close(ref missing, ref missing, ref missing);

                Console.WriteLine("File Created.");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// Create List of migration element to populate the grid with good value in good field.
        /// </summary>
        /// <param name="basePath"></param>
        /// <returns></returns>
        public List <MigrationElement> GetGridData(string basePath)
        {
            List <MigrationElement> data = new List <MigrationElement>();

            string[] antw = new string[] { "2", "8", "90", "91", "92", "97", "98", "99", "35", "36", "37", "39" };
            string[] brux = new string[] { "30", "31", "32", "33", "34", "38", "1", "7", "60", "61", "62", "64", "93", "94", "95", "96" };
            string[] Verv = new string[] { "4", "5", "66", "67", "69" };

            foreach (var item in PopulateData())
            {
                MigrationElement current = new MigrationElement();
                current.PhysicalPerson     = false;
                current.Site               = item[0];
                current.NumeroDeGroupe     = item[1];
                current.NomDeGroupe        = item[2];
                current.AdresseGroupe1     = item[3];
                current.AdresseGroupe2     = item[4];
                current.AdresseGroupe3     = item[5];
                current.CodePostauxGroupe  = item[6];
                current.LocaliteGroupe     = item[7];
                current.NumeroImmeuble     = item[8];
                current.NomImmeuble1       = item[9];
                current.NomImmeuble2       = item[10];
                current.AdresseImmeuble1   = item[11];
                current.AdresseImmeuble2   = item[12];
                current.AdresseImmeuble3   = item[13];
                current.CodePostalImmeuble = item[14];
                current.LocaliteImmeuble   = item[15];
                current.NumeroDuGerant     = item[16];
                current.NomDeGerant        = item[17];
                current.FJuridique         = item[18];
                current.NomDeGerant2       = item[19];
                current.AdresseGerant1     = item[20];
                current.AdresseGerant2     = item[21];
                current.AdresseGerant3     = item[22];
                current.CodePostauxGerant  = item[23];
                current.LocaliteGerant     = item[24];
                current.Langue             = item[25];
                current.NombreAppartement  = item[26];
                current.ChauffageType      = item[27];
                current.ChauffageDescr     = item[28];
                // 27/05/2013 ajout de nouvelles colonnes dans ISEC
                // pusqu'il y a des colonne prix
                current.ChauffageNombreRad = item[30];
                // ATTENTION RAJOUT D'UNE COLONNE DANS LE FICHIER XML(total pour doprimo)
                // => +1 au item ci dessous
                current.ChauffageNombreNRad = item[31];
                current.EauChaudeType       = item[32];
                current.EauChaudeDescr      = item[33];
                // 27/05/2013 ajout de nouvelles colonnes dans ISEC
                // pusqu'il y a des colonne prix
                current.EauChaudeNombreRad  = item[35];
                current.EauChaudeNombreNRad = item[36];
                current.EauFroideType       = item[37];
                current.EauFroideDescr      = item[38];
                // 27/05/2013 ajout de nouvelles colonnes dans ISEC
                // pusqu'il y a des colonne prix
                current.EauFroideNombreRad  = item[40];
                current.EauFroideNombreNRad = item[41];
                current.IntegrateurType     = item[42];
                current.IntegrateurDescr    = item[43];
                // 27/05/2013 ajout de nouvelles colonnes dans ISEC
                // pusqu'il y a des colonne prix
                current.IntegrateurNombreRad  = item[45];
                current.IntegrateurNombreNRad = item[46];

                if (current.CodePostalImmeuble.StartsWithAny(Verv))
                {
                    current.DocumentName = "Migr-VV-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.ToString("MM") + "-" + current.NumeroImmeuble;
                }
                else if (current.CodePostalImmeuble.StartsWithAny(antw))
                {
                    current.DocumentName = "Migr-AN-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.ToString("MM") + "-" + current.NumeroImmeuble;
                }
                else
                {
                    current.DocumentName = "Migr-BX-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.ToString("MM") + "-" + current.NumeroImmeuble;
                }
                current.Element = new WordElement(current, basePath);

                data.Add(current);
            }

            return(data);
        }