/// <summary>
        /// in source List:
        /// first string should look like 'Контракт № 395409092966  Моб.номер: 380500251894'
        /// second line - 'Ціновий Пакет: RED Business M'
        /// </summary>
        /// <param name="list"> wait List<string> as the first 2 strings of the whole Contract</param>
        /// <param name="parsers"></param>
        /// <returns></returns>
        public static HeaderOfContractOfBill ParseHeaderOfContractOfBill(this List <string> list, string[] parsers)
        {
            HeaderOfContractOfBill header = new HeaderOfContractOfBill();

            if (!(list?.Count > 0))
            {
                return(header);
            }

            string contractId = "", mobileNumber = "", tarifPackage = "";

            foreach (var rawData in list)
            {
                if (rawData.Contains(parsers[1]))           //"Контракт №"  //Raw data = Контракт № 395409092966  Моб.номер: 380500251894
                {
                    //look for Contract's ID
                    contractId = GetContractId(rawData);

                    //look for Contract's Mobile number
                    mobileNumber = SetMobileNumber(rawData);
                }
                else if (rawData.Contains(parsers[3]))  //@"Ціновий Пакет" //Raw data = Ціновий Пакет: RED Business M
                {
                    tarifPackage = GetTarifPackage(rawData);
                }
            }
            header = new HeaderOfContractOfBill(contractId, mobileNumber, tarifPackage);

            return(header);
        }
        public static ContractOfBill SplitWholeContractToSeparatedMainParts(this List <string> theWholeContract, string[] parsers)
        {
            HeaderOfContractOfBill       header               = null;
            ServicesOfBill               services             = null;
            DetalizationOfContractOfBill billDetalizationList = null;

            List <string> partOfContract = new List <string>();

            if (theWholeContract?.Count > 0)
            {
                foreach (var row in theWholeContract)
                {
                    partOfContract.Add(row);

                    if (row.StartsWith(parsers[1])) // Start Header // "Контракт №"
                    {
                        partOfContract = new List <string>();
                        partOfContract.Add(row);
                    }
                    else if (row.StartsWith(parsers[3])) // Stop Header // "Ціновий Пакет" or "Тарифний Пакет"
                    {
                        header = new HeaderOfContractOfBill(partOfContract.ParseHeaderOfContractOfBill(parsers));

                        partOfContract = new List <string>(); //start part of Services
                    }
                    else if (row.StartsWith(parsers[7]))      // Stop Services // @"ЗАГАЛОМ ЗА КОНТРАКТОМ (БЕЗ ПДВ ТА ПФ)"
                    {
                        services = new ServicesOfBill(partOfContract.ParseServicesOfBill());

                        partOfContract = new List <string>(); //start part of Detalization
                    }
                }

                billDetalizationList = new DetalizationOfContractOfBill(partOfContract.ParseDetalizationOfContractOfBill());
            }
            if (!(header?.ContractId?.Length > 0))
            {
                return(null);
            }

            return(new ContractOfBill(header, services, billDetalizationList));  //contractOfBill;
        }
Exemplo n.º 3
0
 public ContractOfBill(HeaderOfContractOfBill header, ServicesOfBill services, DetalizationOfContractOfBill detalization)
 {
     Header                 = header;
     ServicesOfContract     = services;
     DetalizationOfContract = detalization;
 }
Exemplo n.º 4
0
 public HeaderOfContractOfBill(HeaderOfContractOfBill header)
 {
     ContractId   = header.ContractId;
     MobileNumber = header.MobileNumber;
     TarifPackage = header.TarifPackage;
 }