Пример #1
0
        public void WriteServiceDate(Prism814Context context, Type814Service service)
        {
            if (service == null)
            {
                return;
            }

            var serviceKey = service.ServiceKey ?? 0;

            if (serviceKey == 0)
            {
                return;
            }

            var nextDate    = string.Empty;
            var moveInDate  = string.Empty;
            var moveOutDate = string.Empty;
            var switchDate  = string.Empty;

            var statuses   = exportDataAccess.ListServiceStatuses(serviceKey);
            var statusCode = string.Empty;

            if (statuses.Any())
            {
                statusCode = statuses[0].StatusCode;
            }

            var actionCode = context.ActionCode.TrimStart('0');

            switch (actionCode)
            {
            case "7":
            case "10":
                switchDate = service.SpecialReadSwitchDate;
                break;

            case "24":
                moveOutDate = service.SpecialReadSwitchDate;
                break;

            case "8":
            case "9":
                nextDate = service.SpecialReadSwitchDate;
                break;

            case "12":
            case "13":
                if (statusCode.Equals("DTM375"))
                {
                    moveInDate = service.SpecialReadSwitchDate;
                }
                if (statusCode.Equals("DTM376"))
                {
                    moveOutDate = service.SpecialReadSwitchDate;
                }
                break;

            case "":
                if (service.MaintenanceTypeCode.Equals("E"))
                {
                    moveInDate = service.SpecialReadSwitchDate;
                }
                if (service.MaintenanceTypeCode.Equals("D"))
                {
                    moveOutDate = service.SpecialReadSwitchDate;
                }
                break;

            default:
                if (service.ServiceType3.Equals("SW", StringComparison.Ordinal))
                {
                    switchDate = service.SpecialReadSwitchDate;
                }
                else
                {
                    moveInDate = service.SpecialReadSwitchDate;
                }
                break;
            }

            var agreementDate = DateTime.Now.ToString("yyyyMMdd");
            var agreementTime = DateTime.Now.ToString("hhmmss");

            if (context.Market == MarketOptions.Texas)
            {
                agreementDate = service.RtoDate;
                agreementTime = service.RtoTime;
            }

            var line = string.Format("11|{0}|{1}|{2}||{3}||||||{4}||||{5}|{6}||||", context.TradingPartnerId,
                                     agreementDate, agreementTime, nextDate, switchDate, moveInDate, moveOutDate);

            context.AppendLine(line);
            logger.TraceFormat("Wrote 814 \"11\" PRISM line for Header {0}", service.HeaderKey);
        }
Пример #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);
            }
        }