Пример #1
0
        public void WriteHeader(XContainer container, Type814Header header)
        {
            if (header == null)
            {
                return;
            }

            if (!header.HeaderKey.HasValue)
            {
                return;
            }

            var headerKey = header.HeaderKey.Value;
            var element   = new XElement("Header",
                                         new XElement("HeaderKey", headerKey));

            element.TryAddElement("TransactionSetId", header.TransactionSetId);
            element.TryAddElement("TransactionSetControlNbr", header.TransactionSetControlNbr);
            element.TryAddElement("TransactionSetPurposeCode", header.TransactionSetPurposeCode);
            element.TryAddElement("TransactionNbr", header.TransactionNbr);
            element.TryAddElement("TransactionDate", header.TransactionDate);
            element.TryAddElement("TransactionTime", header.TransactionTime);
            element.TryAddElement("TransactionTimeCode", header.TransactionTimeCode);
            element.TryAddElement("ReferenceNbr", header.ReferenceNbr);
            element.TryAddElement("ActionCode", header.ActionCode);
            element.TryAddElement("TdspDuns", header.TdspDuns);
            element.TryAddElement("TdspName", header.TdspName);
            element.TryAddElement("CrDuns", header.CrDuns);
            element.TryAddElement("CrName", header.CrName);
            element.TryAddElement("SegmentCount", "0");
            element.TryAddElement("TransactionQualifier", header.TransactionQualifier);
            container.Add(element);
            logger.TraceFormat("Added 814 \"Header\" XML element for Header {0}", headerKey);

            var names = exportDataAccess.ListNames(headerKey);

            WriteName(element, names);

            var services = exportDataAccess.ListServices(headerKey);

            WriteService(element, services);
        }
Пример #2
0
        private List <string> GetNameLines(Type814Header header)
        {
            var nameLines = new List <string>();

            var nameLevelColumns = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20}",
                                                 "BillingEntityName",
                                                 "BillingAddress1",
                                                 "BillingAddress2",
                                                 "BillingCity",
                                                 "BillingState",
                                                 "BillingPostalCode",
                                                 "BillingContactName",
                                                 "BillingContactPhoneNumber1",
                                                 "BillingEntityFirstName",
                                                 "BillingEntityLastName",
                                                 "ServiceCustType",
                                                 "ServiceEntityName",
                                                 "ServiceAddress1",
                                                 "ServiceAddress2",
                                                 "ServiceCity",
                                                 "ServiceState",
                                                 "ServicePostalCode",
                                                 "ServiceContactName",
                                                 "ServiceContactPhoneNumber1",
                                                 "ServiceEntityFirstName",
                                                 "ServiceEntityLastName");

            nameLines.Add(nameLevelColumns);


            var billingName      = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", "", "", "", "", "", "", "", "", "", "");
            var serviceName      = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", "", "", "", "", "", "", "", "", "", "", "");
            var serviceNameFound = false;
            var billingNameFound = false;


            if (header.HeaderKey.HasValue)
            {
                //we have to load the Names here
                var names = exportDataAccess.ListNames(header.HeaderKey.Value);



                //Loop for Names
                foreach (var name in names)
                {
                    if (name.EntityIdType.ToUpper() == "8R" && !serviceNameFound)
                    {
                        serviceName = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
                                                    name.CustType,
                                                    name.EntityName,
                                                    name.Address1,
                                                    name.Address2,
                                                    name.City,
                                                    name.State,
                                                    name.PostalCode,
                                                    name.ContactName,
                                                    name.ContactPhoneNbr1,
                                                    name.EntityFirstName,
                                                    name.EntityLastName
                                                    );

                        serviceNameFound = true;
                    }


                    if (GetBillingAddressEntityIdTypes(header.ActionCode).Any(match => name.EntityIdType.ToUpper() == match && !billingNameFound))
                    {
                        billingName = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}",
                                                    name.EntityName,
                                                    name.Address1,
                                                    name.Address2,
                                                    name.City,
                                                    name.State,
                                                    name.PostalCode,
                                                    name.ContactName,
                                                    name.ContactPhoneNbr1,
                                                    name.EntityFirstName,
                                                    name.EntityLastName);


                        billingNameFound = true;
                    }


                    if (!serviceNameFound || !billingNameFound)
                    {
                        continue;
                    }

                    break;
                }//end of name loop
            }


            var nameLevelData = string.Format("{0},{1}", billingName, serviceName);

            nameLines.Add(nameLevelData);


            return(nameLines);
        }
Пример #3
0
        public void WriteName(Prism814Context context, Type814Header header)
        {
            var ignoredActionCodes = new[] { "7", "9", "19", "21", "23", "29" };
            var actionCode         = context.ActionCode;

            if (ignoredActionCodes.Contains(actionCode))
            {
                return;
            }

            var headerKey = header.HeaderKey ?? 0;

            Type814Name[] names = exportDataAccess.ListNames(headerKey);
            foreach (var name in names)
            {
                if (context.Market == MarketOptions.Maryland && name.EntityIdType.Equals("N1", StringComparison.Ordinal))
                {
                    continue;
                }

                var entityName    = name.EntityName.ToUpper().ToAscii();
                var contactPhone1 = numericExp.Replace(name.ContactPhoneNbr1, string.Empty);
                var contactPhone2 = numericExp.Replace(name.ContactPhoneNbr2, string.Empty);
                var postalCode    = numericExp.Replace(name.PostalCode, string.Empty);

                if (entityName.Length > 60)
                {
                    entityName = entityName.Substring(0, 60);
                }

                if (contactPhone1.Length > 16)
                {
                    contactPhone1 = contactPhone1.Substring(0, 16);
                }

                if (contactPhone2.Length > 16)
                {
                    contactPhone2 = contactPhone2.Substring(0, 16);
                }

                var entityIdCode = name.EntityIdCode;
                var entityName2  = name.EntityName2.ToUpper().ToAscii();
                var entityName3  = name.EntityName3.ToUpper().ToAscii();
                var contactName  = name.ContactName.ToUpper().ToAscii();
                var address1     = name.Address1.ToUpper().ToAscii();
                var address2     = name.Address2.ToUpper().ToAscii();
                var city         = name.City.ToUpper().ToAscii();
                var state        = name.State.ToUpper();
                var email        = name.EntityEmail.ToUpper();

                if (context.Market == MarketOptions.Maryland)
                {
                    entityIdCode  = string.Empty;
                    entityName2   = string.Empty;
                    entityName3   = string.Empty;
                    contactPhone1 = string.Empty;
                    contactName   = string.Empty;
                    address1      = string.Empty;
                    address2      = string.Empty;
                    city          = string.Empty;
                    state         = string.Empty;
                    postalCode    = string.Empty;
                }

                var line =
                    string.Format("05|{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|{11}||{12}|{13}|{14}|{15}|{16}||||",
                                  context.TradingPartnerId, name.EntityIdType, entityName, entityIdCode, entityName2, entityName3,
                                  address1, address2, city, state, postalCode, name.CountryCode, contactPhone1, contactPhone1,
                                  contactName, contactPhone2, email);

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