Example #1
0
        private static void UploadCreditCard()
        {
            try
            {
                using (var db = new CreditinfoServiceEntities())
                {
                    for (int i = 0; i < 20; i++)
                    {
                        var data = db.GetInfoForContracts_CreditCardML().ToList();
                        if (data.Count <= 0)
                        {
                            break;
                        }
                        // using (var client = new CreditinfoService.ServiceSoapClient())
                        {
                            var common   = System.IO.File.ReadAllText(@"C:\Users\L.Shanava\Desktop\PAB\CreditInfo\Shablons\ML\contract_outer.xml");
                            var template = System.IO.File.ReadAllText(@"C:\Users\L.Shanava\Desktop\PAB\CreditInfo\Shablons\ML\contract_CreditCard.xml");

                            var guid = Guid.NewGuid().ToString();

                            var   fileName = @"C:\Users\L.Shanava\Desktop\PAB\CreditInfo\Shablons\ML\GeneritedContract_CreditCard\" + guid + ".xml";
                            float id       = 1;
                            foreach (var item in data)
                            {
                                var _clients = db.Clients
                                               .Where(s => s.ActiveID == item.activeid && s.IndividualType == "IndividualRelation")
                                               .ToList <Client>();

                                var _clientsCompany = db.Clients
                                                      .Where(s => s.ActiveID == item.activeid && s.IndividualType != "IndividualRelation")
                                                      .ToList <Client>();


                                string Content            = "";
                                string SubjectWithContent = "";

                                // For Company

                                string ContentCompany            = "";
                                string SubjectWithContentCompany = "";
                                string SubjectResult             = "";
                                Content = Content + $"<Subjects key=\"01\">" + "\n" + "<IndividualRelation>\n" + $"<IdentifierIndividual>{item.Subjects_key__0S__IndividualRelation_IdentifierIndividual}</IdentifierIndividual>\n".Replace(" ", "");
                                Content = Content + $"<RoleOfClient>{item.Subjects_key__0S__IndividualRelation_RoleOfClient}</RoleOfClient>\n";
                                // Content=Content+ item.Subjects_IndividualRelation_RoleOfClient== "RoleOfClient.Guarantor"? $"<GuaranteeAmount>\n<AmountValue>{item.amount}"
                                Content       = Content + "</IndividualRelation>\n</Subjects>";
                                SubjectResult = Content;
                                int step = 1;
                                foreach (var cl in _clients)
                                {
                                    step++;

                                    Content = Content + $"\n<Subjects key=\"0{step}\">" + "\n" + "<IndividualRelation>";// + $"<IdentifierIndividual>{item.Subjects_IndividualRelation_IdentifierIndividual}</IdentifierIndividual>\n";
                                    Content = Content + "\n" + $"<IdentifierIndividual>{cl.PIN.Trim()}</IdentifierIndividual>" + "\n" + $"<RoleOfClient>{cl.RoleOfClient.Trim()}</RoleOfClient>";
                                    //Content = Content + cl.RoleOfClient.Trim() == "RoleOfClient.Guarantor" ? $"\n <GuaranteeAmount>\n<AmountValue>\n{cl.GauarnteeAmount}</AmountValue>\n<Currency>{cl.Currency}</Currency>\n</GuaranteeAmount>" : "";
                                    if (cl.RoleOfClient.Trim() == "RoleOfClient.Guarantor")
                                    {
                                        Content = Content + $"\n <GuaranteeAmount>\n<AmountValue>{cl.GauarnteeAmount}</AmountValue>\n<Currency>{cl.Currency}</Currency>\n</GuaranteeAmount>";
                                    }
                                    Content = Content + "\n</IndividualRelation>\n</Subjects>\n";
                                }
                                if (_clients.Count > 0)
                                {
                                    SubjectWithContent = Content;
                                }
                                foreach (var cl in _clientsCompany)
                                {
                                    //ContentCompany = ContentCompany + "\n" + $"<IdentifierCompany> {cl.PIN.Trim()} </IdentifierCompany>" + "\n" + $"<RoleOfClient> {cl.RoleOfClient.Trim()} </RoleOfClient>";
                                    step++;
                                    Content = Content + $"<Subjects key=\"0{step}\">" + "\n" + "<IndividualCompany>";// + $"<IdentifierIndividual>{item.Subjects_IndividualRelation_IdentifierIndividual}</IdentifierIndividual>\n";
                                    Content = Content + "\n" + $"<IdentifierCompany>{cl.PIN.Trim()}</IdentifierCompany>" + "\n" + $"<RoleOfClient>{cl.RoleOfClient.Trim()}</RoleOfClient>";
                                    //Content = Content + cl.RoleOfClient.Trim() == "RoleOfClient.Guarantor" ? $"\n <GuaranteeAmount>\n<AmountValue>\n{cl.GauarnteeAmount}</AmountValue>\n<Currency>{cl.Currency}</Currency>\n</GuaranteeAmount>" : "";
                                    if (cl.RoleOfClient.Trim() == "RoleOfClient.Guarantor")
                                    {
                                        Content = Content + $"\n <GuaranteeAmount>\n<AmountValue>{cl.GauarnteeAmount}</AmountValue>\n<Currency>{cl.Currency}</Currency>\n</GuaranteeAmount>";
                                    }
                                    Content = Content + "\n</IndividualRelation>\n</Subjects>\n";
                                }
                                if (_clientsCompany.Count > 0)
                                {
                                    SubjectWithContentCompany = ContentCompany;
                                }
                                if (_clients.Count > 0 || _clientsCompany.Count > 0)
                                {
                                    SubjectResult = SubjectWithContent + SubjectWithContentCompany;
                                }


                                var realend = item.Dates_RealEnd;

                                var content = template;

                                content = content.Replace("_Dates_RealEnd_", item.Dates_RealEnd.HasValue ? item.Dates_RealEnd.Value.ToString("yyyy-MM-ddT00:00:00") : "");
                                content = content.Replace("_CaseNumber_", item.CaseNumber);
                                content = content.Replace("_RepaymentCreditCard_", item.RepaymentCreditCard);
                                content = content.Replace("_CommandIdentifier_", "\"" + item.CaseNumber.ToString() + "\"");
                                content = content.Replace("_PeriodicityOfPayments_", item.PeriodicityOfPayments);
                                content = content.Replace("_TotalCreditAmount_AmountValue_", item.TotalCreditAmount_AmountValue.ToString());
                                content = content.Replace("_TotalCreditAmount_Currency_", item.TotalCreditAmount_Currency);
                                content = content.Replace("_StandardInstallmentAmount_Currency_", item.TotalCreditAmount_Currency);
                                content = content.Replace("_OverdueAmount_AmountValue_", item.OverdueAmount_AmountValue.ToString());
                                content = content.Replace("_OverdueAmount_Currency_", item.OverdueAmount_Currency);
                                content = content.Replace("_OutstandingAmount_AmountValue_", item.OutstandingAmount_AmountValue.ToString());
                                content = content.Replace("_OutstandingAmount_Currency_", item.OutstandingAmount_Currency);
                                content = content.Replace("_LoanType_", item.LoanType);
                                content = content.Replace("_CreditPurpose_", item.CreditPurpose);
                                content = content.Replace("_CreditCurrency_", item.CreditCurrency);
                                content = content.Replace("_Dates_Start_", item.Dates_Start.HasValue ? item.Dates_Start.Value.ToString("yyyy-MM-ddT00:00:00") : "");
                                content = content.Replace("_Dates_ExpectedEnd_", item.Dates_ExpectedEnd.HasValue ? item.Dates_ExpectedEnd.Value.ToString("yyyy-MM-ddT00:00:00") : "");
                                content = content.Replace("_Dates_Overdue_", item.Dates_Overdue.HasValue ? item.Dates_Overdue.Value.ToString("yyyy-MM-ddT00:00:00") : "");
                                content = content.Replace("_Dates_Repayment_", item.Dates_Repayment.HasValue ? item.Dates_Repayment.Value.ToString("yyyy-MM-ddT00:00:00") : "");
                                content = content.Replace("_Dates_ExpofLimitation_", item.Dates_ExpofLimitation.HasValue ? item.Dates_ExpofLimitation.Value.ToString("yyyy-MM-ddT00:00:00") : "");
                                content = content.Replace("_Penalty_PenaltySum_AmountValue_", item.Penalty_PenaltySum_AmountValue.ToString());
                                content = content.Replace("_Penalty_PenaltySum_Currency_", item.Penalty_PenaltySum_Currency);
                                content = content.Replace("_Penalty_PenaltyPaid_Currency_", item.Penalty_PenaltyPaid_Currency);
                                content = content.Replace("_Penalty_PenaltyPaid_AmountValue_", item.Penalty_PenaltyPaid_AmountValue.ToString());
                                content = content.Replace("_PhaseofOperation_", item.PhaseofOperation);
                                //content = content.Replace("_Subjects_IndividualRelation_IdentifierIndividual_", item.Subjects_key__0S__IndividualRelation_IdentifierIndividual);
                                // content = content.Replace("_Subjects_IndividualRelation_RoleOfClient_", item.Subjects_key__0S__IndividualRelation_RoleOfClient);
                                content = content.Replace("_Subjects_IndividualRelation_IdentifierIndividual_", null);
                                content = content.Replace("_Subjects_IndividualRelation_RoleOfClient_", null);
                                content = content.Replace("_getdate_", DateTime.Now.AddHours(-5).ToString("yyyy-MM-ddTHH:mm:ss"));
                                content = content.Replace("_CurrentOverduePrincipalAmount_AmountValue_", item.CurrentOverduePrincipalAmount_AmountValue.ToString());
                                content = content.Replace("_CurrentOverduePrincipalAmount_Currency_", item.CurrentOverduePrincipalAmount_Currency);
                                content = content.Replace("_CurrentOverdueInteresetandCommissionAmount_AmountValue_", item.CurrentOverdueInteresetandCommissionAmount_AmountValue.ToString());
                                content = content.Replace("_CurrentOverdueInteresetandCommissionAmount_Currency_", item.CurrentOverdueInteresetandCommissionAmount_Currency);
                                content = content.Replace("_CurrentOutstandingPrincipalAmount_AmountValue_", item.CurrentOutstandingPrincipalAmount_AmountValue.ToString());
                                content = content.Replace("_CurrentOutstandingPrincipalAmount_Currency_", item.CurrentOutstandingPrincipalAmount_Currency);
                                content = content.Replace("_MaximumNumberofDelinquencyDays_", item.MaximumNumberofDelinquencyDays.ToString());
                                content = content.Replace("_TotalNumberofDelinquencyDays_", item.TotalNumberofDelinquencyDays.ToString());
                                content = content.Replace("_TotalNumberofDelinquencyDaysInLastYear_", item.TotalNumberofDelinquencyDaysInLastYear.ToString());
                                content = content.Replace("_CurrentUndisbursedLoanAmount_AmountValue_", item.CurrentUndisbursedLoanAmount_AmountValue.ToString());
                                content = content.Replace("_LoanPartiallySecuredByDeposit_", item.LoanPartiallySecuredByDeposit);
                                content = content.Replace("_CurrentUndisbursedLoanAmount_AmountValue_", item.CurrentUndisbursedLoanAmount_AmountValue.ToString());
                                content = content.Replace("_CurrentUndisbursedLoanAmount_Currency_", item.TotalCreditAmount_Currency);
                                content = content.Replace("_ContractTerm_", item.ContractTerm);
                                content = content.Replace("_MaximumAmountOfInstalmentBySchedule_AmountValue_", item.MaxInstallmentAmount.ToString());
                                content = content.Replace("_MaximumAmountOfInstalmentBySchedule_Currency_", item.MaxInstallmentCurrency);
                                content = content.Replace("<IdentifierIndividual>_Subjects_IndividualRelation_IdentifierIndividual1_</IdentifierIndividual>", SubjectResult);

                                content = string.Format("{0}\r\n_contract_\r\n", content);
                                common  = common.Replace("_contract_", content);
                                id++;
                            }

                            common = common.Replace("_contract_", "");
                            common = common.Replace("_identifier_", CalculateMD5Hash(guid));
                            common = RemoveEmptyNodes(common);
                            System.IO.File.WriteAllText(fileName, common);


                            // es agzavnis
                            UploadFile(fileName);
                        }
                    }

                    //BatchResponse();
                }
            }
            catch (Exception ex)
            {
                SendMail("PubInvest_UploadCreditCard: კრედიტინფოს სერვისის გაშვებისას დაფიქსირდა ხარვეზი,მიზეზი: " + System.Environment.NewLine + ex.Message.ToString());
            }
        }