Пример #1
0
        public void WriteServiceChange(Prism814Context context, Type814Header header, Type814Service[] services)
        {
            var actionCode = context.ActionCode.TrimStart('0');

            foreach (var service in services)
            {
                if (!service.ServiceKey.HasValue)
                {
                    continue;
                }

                var serviceKey         = service.ServiceKey.Value;
                var lineTrackingNumber = "1";
                var crDuns             = string.Empty;
                var specialNeedsFlag   = string.Empty;

                if (context.Market != MarketOptions.Texas)
                {
                    lineTrackingNumber = serviceKey.ToString();
                }
                if (actionCode.Equals("PC", StringComparison.Ordinal))
                {
                    specialNeedsFlag = service.SpecialNeedsIndicator;
                }

                var membershipId      = IdentifyLdcAccountNumber(context, service);
                var premiseNumber     = IdentifyEsiId(context, service);
                var serviceActionCode = string.Empty;

                if (actionCode.Equals("C", StringComparison.Ordinal))
                {
                    serviceActionCode = "A";
                }
                if (actionCode.Equals("13") || actionCode.Equals("21"))
                {
                    if (service.ActionCode.Equals("WQ", StringComparison.Ordinal))
                    {
                        serviceActionCode = "A";
                    }
                    if (service.ActionCode.Equals("U", StringComparison.Ordinal))
                    {
                        serviceActionCode = "R";
                    }
                }

                var changes = exportDataAccess.ListServiceAccountChanges(serviceKey);
                if (context.Market == MarketOptions.Maryland)
                {
                    crDuns = header.CrDuns;
                    if (changes.Any(x => x.ChangeReason.Equals("REFPC", StringComparison.Ordinal)))
                    {
                        continue;
                    }
                }

                var line =
                    string.Format(
                        "10|{0}|{1}|{2}||{3}|C|{4}||{5}|||{9}||||||||||||||||||{6}|{10}||||||{7}||||||{8}|||||||||||{11}|",
                        context.TradingPartnerId, service.ServiceType1, service.ServiceType2, lineTrackingNumber,
                        serviceActionCode, membershipId, service.BillType, service.CsaFlag, premiseNumber, crDuns,
                        service.BillCalculator, specialNeedsFlag);

                context.AppendLine(line);
                logger.TraceFormat("Wrote 814 \"10\" PRISM line for Header {0}", header.HeaderKey);

                if (context.Market == MarketOptions.Maryland)
                {
                    WriteServiceMeter(context, service);
                    WriteServiceMeterChange(context, service);
                    WriteServiceAccountChange(context, service, changes);
                    continue;
                }

                if (actionCode.Equals("12"))
                {
                    WriteServiceDate(context, service);
                }

                if (actionCode.Equals("PC", StringComparison.Ordinal))
                {
                    WriteServiceMeter(context, service);
                }
            }
        }
Пример #2
0
        public void WriteService(XContainer container, Type814Service[] services)
        {
            var loopElement = new XElement("ServiceLoop");

            container.Add(loopElement);

            if (services == null || services.Length == 0)
            {
                return;
            }

            foreach (var service in services)
            {
                if (!service.ServiceKey.HasValue)
                {
                    continue;
                }

                var serviceKey = service.ServiceKey.Value;
                var element    = new XElement("Service",
                                              new XElement("ServiceKey", service.ServiceKey),
                                              new XElement("HeaderKey", service.HeaderKey));

                element.TryAddElement("AssignId", service.AssignId);
                element.Add(
                    new XElement("ServiceTypeCode1", service.ServiceTypeCode1),
                    new XElement("ServiceType1", service.ServiceType1),
                    new XElement("ServiceTypeCode2", service.ServiceTypeCode2),
                    new XElement("ServiceType2", service.ServiceType2));
                element.TryAddElement("ServiceTypeCode3", service.ServiceTypeCode3);
                element.TryAddElement("ServiceType3", service.ServiceType3);
                element.TryAddElement("ServiceTypeCode4", service.ServiceTypeCode4);
                element.TryAddElement("ServiceType4", service.ServiceType4);
                element.Add(
                    new XElement("ActionCode", service.ActionCode),
                    new XElement("MaintenanceTypeCode", service.MaintenanceTypeCode));
                element.TryAddElement("DistributionLossFactorCode", service.DistributionLossFactorCode);
                element.TryAddElement("PremiseType", service.PremiseType);
                element.TryAddElement("BillType", service.BillType);
                element.TryAddElement("BillCalculator", service.BillCalculator);
                element.Add(new XElement("EsiId", service.EsiId));
                element.TryAddElement("SpecialNeedsIndicator", service.SpecialNeedsIndicator);
                element.TryAddElement("StationId", service.StationId);
                element.TryAddElement("PowerRegion", service.PowerRegion);
                element.TryAddElement("EnergizedFlag", service.EnergizedFlag);
                element.TryAddElement("NotificationWaiver", service.NotificationWaiver);
                element.TryAddElement("EsiIdStartDate", service.EsiIdStartDate);
                element.TryAddElement("EsiIdEndDate", service.EsiIdEndDate);
                element.TryAddElement("EsiIdEligibilityDate", service.EsiIdEligbilityDate);
                element.TryAddElement("SpecialReadSwitchDate", service.SpecialReadSwitchDate);
                element.TryAddElement("SpecialReadSwitchTime", service.SpecialReadSwitchTime);
                element.TryAddElement("PriorityCode", service.PriorityCode);
                element.TryAddElement("RTODate", service.RtoDate);
                element.TryAddElement("RTOTime", service.RtoTime);
                element.TryAddElement("PermitIndicator", service.PermitIndicator);
                element.TryAddElement("CSAFlag", service.CsaFlag);
                element.TryAddElement("MembershipID", service.MembershipId);
                element.TryAddElement("ESPAccountNumber", service.EspAccountNumber);
                element.TryAddElement("LDCBillingCycle", service.LdcBillingCycle);
                element.TryAddElement("LDCBudgetBillingCycle", service.LdcBudgetBillingCycle);
                element.TryAddElement("WaterHeaters", service.WaterHeaters);
                element.TryAddElement("LDCBudgetBillingStatus", service.LdcBudgetBillingStatus);
                element.TryAddElement("PaymentArrangement", service.PaymentArrangement);
                element.TryAddElement("NextMeterReadDate", service.NextMeterReadDate);
                element.TryAddElement("ParticipatingInterest", service.ParticipatingInterest);
                element.TryAddElement("EligibleLoadPercentage", service.EligibleLoadPercentage);
                element.TryAddElement("TaxExemptionPercent", service.TaxExceptionPercent);
                element.TryAddElement("CapacityObligation", service.CapacityObligation);
                element.TryAddElement("TransmissionObligation", service.TransmissionObligation);
                element.TryAddElement("TotalKWHHistory", service.TotalKwhHistory);
                element.TryAddElement("NumberOfMonthsHistory", service.NumberOfMonthsHistory);
                element.TryAddElement("PeakDemandHistory", service.PeakDemandHistory);
                element.TryAddElement("AirConditioners", service.AirConditioners);
                element.TryAddElement("PreviousEsiId", service.PreviousEsiId);
                element.TryAddElement("GasPoolId", service.GasPoolId);
                element.TryAddElement("LBMPZone", service.LbmpZone);
                element.TryAddElement("ResidentialTaxPortion", service.ResidentialTaxPortion);

                // trim leading zeros
                element.TryAddElement("ESPCommodityPrice", service.EspCommodityPrice,
                                      x => (x.Substring(0, 1) == "0" ? x.Substring(1) : x));
                element.TryAddElement("ESPFixedCharge", service.EspFixedCharge,
                                      x => (x.Substring(0, 1) == "0" ? x.Substring(1) : x));
                element.TryAddElement("ESPChargesCommTaxRate", service.EspChargesCommTaxRate,
                                      x => (x.Substring(0, 1) == "0" ? x.Substring(1) : x));
                element.TryAddElement("ESPChargesResTaxRate", service.EspChargesResTaxRate,
                                      x => (x.Substring(0, 1) == "0" ? x.Substring(1) : x));

                element.TryAddElement("GasSupplyServiceOption", service.GasSupplyServiceOption);
                element.TryAddElement("GasSupplyServiceOptionCode", service.GasSupplyServiceOptionCode);
                element.TryAddElement("BudgetBillingStatus", service.BudgetBillingStatus);
                element.TryAddElement("FixedMonthlyCharge", service.FixedMonthlyCharge);
                element.TryAddElement("TaxRate", service.TaxRate);
                element.TryAddElement("MeterCycleCodeDesc", service.MeterCycleCodeDesc);
                element.TryAddElement("MeterCycleCode", service.MeterCycleCode);
                element.TryAddElement("BillCycleCodeDesc", service.BillCycleCodeDesc);
                element.TryAddElement("FeeApprovedApplied", service.FeeApprovedApplied);
                element.TryAddElement("MarketerCustomerAccountNumber", service.MarketerCustomerAccountNumber);
                element.TryAddElement("HumanNeeds", service.HumanNeeds);
                element.TryAddElement("NewCustomerIndicator", service.NewCustomerIndicator);
                element.TryAddElement("NewPremiseIndicator", service.NewPremiseIndicator);
                element.TryAddElement("CustomerAuthorization", service.CustomerAuthorization);
                element.TryAddElement("LDCAccountBalance", service.LdcAccountBalance);
                element.TryAddElement("DisputedAmount", service.DisputedAmount);
                element.TryAddElement("CurrentBalance", service.CurrentBalance);
                element.TryAddElement("ArrearsBalance", service.ArrearsBalance);
                element.TryAddElement("LDCSupplierBalance", service.LdcSupplierBalance);
                element.TryAddElement("BudgetPlan", service.BudgetPlan);
                element.TryAddElement("BudgetInstallment", service.BudgetInstallment);
                element.TryAddElement("Deposit", service.Deposit);
                element.TryAddElement("RemainingUtilBalanceBucket1", service.RemainingUtilBalanceBucket1);
                element.TryAddElement("RemainingUtilBalanceBucket2", service.RemainingUtilBalanceBucket2);
                element.TryAddElement("RemainingUtilBalanceBucket3", service.RemainingUtilBalanceBucket3);
                element.TryAddElement("RemainingUtilBalanceBucket4", service.RemainingUtilBalanceBucket4);
                element.TryAddElement("RemainingUtilBalanceBucket5", service.RemainingUtilBalanceBucket5);
                element.TryAddElement("RemainingUtilBalanceBucket6", service.RemainingUtilBalanceBucket6);
                element.TryAddElement("IntervalStatusType", service.IntervalStatusType);
                element.TryAddElement("PaymentOption", service.PaymentOption);
                element.TryAddElement("SystemNumber", service.SystemNumber);
                element.TryAddElement("SpecialMeterConfig", service.SpecialMeterConfig);
                element.TryAddElement("MaximumGeneration", service.MaximumGeneration);
                element.TryAddElement("DaysInArrears", service.DaysInArrears);
                element.TryAddElement("ServiceDeliveryPoint", service.ServiceDeliveryPoint);
                element.TryAddElement("GasCapacityAssignment", service.GasCapacityAssignment);
                loopElement.Add(element);
                logger.TraceFormat("Added 814 \"Service\" XML element for Header {0}", service.HeaderKey);

                var meters = exportDataAccess.ListServiceMeters(serviceKey);
                WriteServiceMeter(element, meters);

                var rejects = exportDataAccess.ListServiceRejects(serviceKey);
                WriteServiceReject(element, rejects);

                var statuses = exportDataAccess.ListServiceStatuses(serviceKey);
                WriteServiceStatus(element, statuses);

                var changes = exportDataAccess.ListServiceAccountChanges(serviceKey);
                WriteServiceAccountChange(element, changes);

                var dates = exportDataAccess.ListServiceDates(serviceKey);
                WriteServiceDate(element, dates);
            }
        }