Ejemplo n.º 1
0
        public void ParseHeader(Prism650Context context, string[] marketFields)
        {
            var headerModel = new Type650Header
            {
                TransactionSetPurposeCode = marketFields.AtIndex(3),
                TransactionDate           = marketFields.AtIndex(4),
                TransactionNbr            = marketFields.AtIndex(5),
                ReferenceNbr              = marketFields.AtIndex(6),
                TransactionType           = marketFields.AtIndex(7),
                ActionCode                = marketFields.AtIndex(8),
                TdspName                  = marketFields.AtIndex(20),
                TdspDuns                  = marketFields.AtIndex(21),
                CrName                    = marketFields.AtIndex(22),
                CrDuns                    = marketFields.AtIndex(23),
                ProcessedReceivedDateTime = marketFields.AtIndex(24),
            };

            var identifiedMarket = clientDataAccess.IdentifyMarket(headerModel.TdspDuns);

            if (identifiedMarket.HasValue)
            {
                context.SetMarket(identifiedMarket.Value);
            }

            headerModel.MarketId   = context.MarketId;
            headerModel.ProviderId = 1;

            context.PushModel(headerModel);

            var hasEntityName  = false;
            var hasContactName = false;

            marketFields.TryAtIndex(9, x => hasEntityName   = true);
            marketFields.TryAtIndex(17, x => hasContactName = true);

            if (!hasEntityName || !hasContactName)
            {
                return;
            }

            var nameModel = new Type650Name
            {
                EntityName       = marketFields.AtIndex(9),
                EntityName2      = marketFields.AtIndex(10),
                EntityName3      = marketFields.AtIndex(11),
                Address1         = marketFields.AtIndex(12),
                Address2         = marketFields.AtIndex(13),
                City             = marketFields.AtIndex(14),
                State            = marketFields.AtIndex(15),
                PostalCode       = marketFields.AtIndex(16),
                ContactName      = marketFields.AtIndex(17),
                ContactPhoneNbr1 = marketFields.AtIndex(18),
                ContactPhoneNbr2 = marketFields.AtIndex(19),
            };

            headerModel.AddName(nameModel);
        }
Ejemplo n.º 2
0
        public Type650Header ParseHeader(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

            if (!namespaces.TryGetValue(string.Empty, out empty))
            {
                empty = XNamespace.None;
            }

            var model = new Type650Header
            {
                TransactionSetId          = element.GetChildText(empty + "TransactionSetId"),
                TransactionSetControlNbr  = element.GetChildText(empty + "TransactionSetControlNbr"),
                TransactionSetPurposeCode = element.GetChildText(empty + "TransactionSetPurposeCode"),
                TransactionDate           = element.GetChildText(empty + "TransactionDate"),
                TransactionNbr            = element.GetChildText(empty + "TransactionNbr"),
                ReferenceNbr              = element.GetChildText(empty + "ReferenceNbr"),
                TransactionType           = element.GetChildText(empty + "TransactionType"),
                ActionCode                = element.GetChildText(empty + "ActionCode"),
                TdspName                  = element.GetChildText(empty + "TdspName"),
                TdspDuns                  = element.GetChildText(empty + "TdspDuns"),
                CrName                    = element.GetChildText(empty + "CrName"),
                CrDuns                    = element.GetChildText(empty + "CrDuns"),
                ProcessedReceivedDateTime = element.GetChildText(empty + "ProcessedReceivedDateTime"),
            };

            var nameLoopElement = element.Element(empty + "NameLoop");

            if (nameLoopElement != null)
            {
                var nameElements = nameLoopElement.Elements(empty + "Name");
                foreach (var nameElement in nameElements)
                {
                    var nameModel = ParseName(nameElement, namespaces);
                    model.AddName(nameModel);
                }
            }

            var serviceLoopElement = element.Element(empty + "ServiceLoop");

            if (serviceLoopElement != null)
            {
                var serviceElements = serviceLoopElement.Elements(empty + "Service");
                foreach (var serviceElement in serviceElements)
                {
                    var serviceModel = ParseService(serviceElement, namespaces);
                    model.AddService(serviceModel);
                }
            }

            return(model);
        }
Ejemplo n.º 3
0
        public Type650Header[] ListUnprocessed(string ldcDuns, string duns, int providerId)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp650ExportList"))
                {
                    command.AddWithValue("@TDSPDuns", ldcDuns)
                    .AddWithValue("@CrDuns", duns)
                    .AddWithValue("@ProviderID", providerId);

                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    var collection = new List <Type650Header>();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new Type650Header
                            {
                                HeaderKey   = reader.GetInt32("650_Key"),
                                Direction   = reader.GetBoolean("Direction"),
                                ProcessFlag = reader.GetInt16("ProcessFlag"),
                            };

                            reader.TryGetString("TransactionDate", x => item.TransactionDate = x);
                            reader.TryGetString("TransactionSetPurposeCode", x => item.TransactionSetPurposeCode = x);
                            reader.TryGetString("TransactionNbr", x => item.TransactionNbr   = x);
                            reader.TryGetString("ReferenceNbr", x => item.ReferenceNbr       = x);
                            reader.TryGetString("TransactionType", x => item.TransactionType = x);
                            reader.TryGetString("ActionCode", x => item.ActionCode           = x);
                            reader.TryGetString("TdspName", x => item.TdspName = x);
                            reader.TryGetString("TdspDuns", x => item.TdspDuns = x);
                            reader.TryGetString("CrName", x => item.CrName     = x);
                            reader.TryGetString("CrDuns", x => item.CrDuns     = x);
                            reader.TryGetString("ProcessedReceivedDateTime", x => item.ProcessedReceivedDateTime = x);
                            reader.TryGetInt32("MarketID", x => item.MarketId = x);
                            reader.TryGetInt32("TransactionTypeID", x => item.TransactionTypeId = x);
                            reader.TryGetInt32("ProviderID", x => item.ProviderId = x);

                            // this is a little concerning since this stored procedure
                            // actually returns a name record as well
                            var name = new Type650Name {
                                HeaderKey = reader.GetInt32("650_Key")
                            };
                            reader.TryGetString("Customer", x => name.EntityName       = x);
                            reader.TryGetString("CustomerName1", x => name.EntityName2 = x);
                            reader.TryGetString("CustomerName2", x => name.EntityName3 = x);
                            reader.TryGetString("Address1", x => name.Address1         = x);
                            reader.TryGetString("Address2", x => name.Address2         = x);
                            reader.TryGetString("City", x => name.City                         = x);
                            reader.TryGetString("State", x => name.State                       = x);
                            reader.TryGetString("PostalCode", x => name.PostalCode             = x);
                            reader.TryGetString("TechnicalContact", x => name.ContactName      = x);
                            reader.TryGetString("ContactPhoneNbr1", x => name.ContactPhoneNbr1 = x);
                            reader.TryGetString("ContactPhoneNbr2", x => name.ContactPhoneNbr2 = x);
                            item.AddName(name);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }