예제 #1
0
        void IGatewayComponent.ProcessRequest(IContext objContext, string strAction)
        {
            MasterDetailEngine engine = new MasterDetailEngine(typeof(TxferTxtIEMaster), typeof(TxferTxtIEDetails), new MasterDetailSelector(RecSelector));

            string path = txtFileName.Text.Trim();

            if (path.Length > 0)
            {
                string fileName = "TxferExportList_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string fullName = Path.Combine(path, fileName);

                engine.WriteFile(fullName, md);

                HttpResponse objResponse = this.Context.HttpContext.Response;

                objResponse.Clear();
                objResponse.ClearHeaders();

                objResponse.ContentType = "application/txt";
                objResponse.AddHeader("content-disposition", "attachment; filename=" + fileName);
                objResponse.BinaryWrite(File.ReadAllBytes(fullName));
                objResponse.Flush();
                objResponse.End();

                MessageBox.Show("Successful!\n " + fullName, "Message");
            }
            else
            {
                MessageBox.Show("Please input the file location!", "Warning");
            }
        }
        //-> {Example.Name:Master Detail sample}
        //-> {Example.Description:Show how to implement Master detail reading where record contains characters}
        //-> {Example.File:RunEngine.cs}
        /// <summary>
        /// Run a record through engine using a Common selector where master contains a characrter to create a master detail input
        /// </summary>
        public override void Run()
        {
            var engine = new MasterDetailEngine<Customers, Orders>
                                         (CommonSelector.MasterIfContains, "@");
            // to Read use:
            var res = engine.ReadFile("Input.txt");

            // to Write use:
            engine.WriteFile("Output.txt", res);
        }
        //-> Name:Master Detail sample
        //-> Description:Show how to implement Master detail reading where record contains characters

        //-> File:RunEngine.cs
        /// <summary>
        /// Run a record through engine using a Common selector where master contains a characrter to create a master detail input
        /// </summary>
        public override void Run()
        {
            var engine = new MasterDetailEngine <Customers, Orders>
                             (CommonSelector.MasterIfContains, "@");
            // to Read use:
            var res = engine.ReadFile("Input.txt");

            // to Write use:
            engine.WriteFile("Output.txt", res);
        }
예제 #4
0
        public void CustomerOrdersWrite()
        {
            var engine = new MasterDetailEngine(typeof(CustomersVerticalBar),
                                                typeof(OrdersVerticalBar),
                                                new MasterDetailSelector(Test1Selector));

            MasterDetails[] resTmp = engine.ReadFile(FileTest.Good.MasterDetail1.Path);
            Assert.AreEqual(4, resTmp.Length);

            engine.WriteFile("tempmd.txt", resTmp);


            MasterDetails[] res = engine.ReadFile("tempmd.txt");

            Assert.AreEqual(4, res.Length);

            Assert.AreEqual(4, engine.TotalRecords);

            Assert.AreEqual(4, res[0].Details.Length);
            Assert.AreEqual(3, res[1].Details.Length);
            Assert.AreEqual(2, res[2].Details.Length);
            Assert.AreEqual(0, res[3].Details.Length);

            Assert.AreEqual("ALFKI", ((CustomersVerticalBar)res[0].Master).CustomerID);
            Assert.AreEqual(10248, ((OrdersVerticalBar)res[0].Details[0]).OrderID);
            Assert.AreEqual(10249, ((OrdersVerticalBar)res[0].Details[1]).OrderID);
            Assert.AreEqual(10250, ((OrdersVerticalBar)res[0].Details[2]).OrderID);
            Assert.AreEqual(10251, ((OrdersVerticalBar)res[0].Details[3]).OrderID);

            Assert.AreEqual("ANATR", ((CustomersVerticalBar)res[1].Master).CustomerID);
            Assert.AreEqual(10252, ((OrdersVerticalBar)res[1].Details[0]).OrderID);
            Assert.AreEqual(10253, ((OrdersVerticalBar)res[1].Details[1]).OrderID);
            Assert.AreEqual(10254, ((OrdersVerticalBar)res[1].Details[2]).OrderID);

            Assert.AreEqual("ANTON", ((CustomersVerticalBar)res[2].Master).CustomerID);
            Assert.AreEqual(10257, ((OrdersVerticalBar)res[2].Details[0]).OrderID);
            Assert.AreEqual(10258, ((OrdersVerticalBar)res[2].Details[1]).OrderID);

            Assert.AreEqual("DUMON", ((CustomersVerticalBar)res[3].Master).CustomerID);


            if (File.Exists("tempmd.txt"))
            {
                File.Delete("tempmd.txt");
            }
        }
예제 #5
0
        public void CustomerOrdersWrite2()
        {
            var masterDetEng = new MasterDetailEngine <CustomersVerticalBar, OrdersVerticalBar>();

            MasterDetails <CustomersVerticalBar, OrdersVerticalBar> record;
            var records = new List <MasterDetails <CustomersVerticalBar, OrdersVerticalBar> >();

            // Create the master detail item
            record = new MasterDetails <CustomersVerticalBar, OrdersVerticalBar>();
            records.Add(record);

            // Create the master object
            record.Master            = new CustomersVerticalBar();
            record.Master.CustomerID = "ALFKI";
            record.Master.Country    = "Argentina";

            // Create the details object
            var orders = new List <OrdersVerticalBar>();

            foreach (var det in colDetails)
            {
                orders.Add(det);
            }

            record.Details = orders.ToArray();


            // We can create a second master object
            record = new MasterDetails <CustomersVerticalBar, OrdersVerticalBar>();
            records.Add(record);

            record.Master            = new CustomersVerticalBar();
            record.Master.CustomerID = "ALFKI";
            record.Master.Country    = "Argentina";

            orders = new List <OrdersVerticalBar>();
            foreach (var det in colDetails)
            {
                orders.Add(det);
            }
            record.Details = orders.ToArray();

            // And now write it to a file

            masterDetEng.WriteFile("myMDfile.txt", records.ToArray());
        }
예제 #6
0
        public void CustomerOrdersWrite()
        {
            var engine = new MasterDetailEngine(typeof (CustomersVerticalBar),
                typeof (OrdersVerticalBar),
                new MasterDetailSelector(Test1Selector));
            MasterDetails[] resTmp = engine.ReadFile(FileTest.Good.MasterDetail1.Path);
            Assert.AreEqual(4, resTmp.Length);

            engine.WriteFile("tempmd.txt", resTmp);


            MasterDetails[] res = engine.ReadFile("tempmd.txt");

            Assert.AreEqual(4, res.Length);

            Assert.AreEqual(4, engine.TotalRecords);

            Assert.AreEqual(4, res[0].Details.Length);
            Assert.AreEqual(3, res[1].Details.Length);
            Assert.AreEqual(2, res[2].Details.Length);
            Assert.AreEqual(0, res[3].Details.Length);

            Assert.AreEqual("ALFKI", ((CustomersVerticalBar) res[0].Master).CustomerID);
            Assert.AreEqual(10248, ((OrdersVerticalBar) res[0].Details[0]).OrderID);
            Assert.AreEqual(10249, ((OrdersVerticalBar) res[0].Details[1]).OrderID);
            Assert.AreEqual(10250, ((OrdersVerticalBar) res[0].Details[2]).OrderID);
            Assert.AreEqual(10251, ((OrdersVerticalBar) res[0].Details[3]).OrderID);

            Assert.AreEqual("ANATR", ((CustomersVerticalBar) res[1].Master).CustomerID);
            Assert.AreEqual(10252, ((OrdersVerticalBar) res[1].Details[0]).OrderID);
            Assert.AreEqual(10253, ((OrdersVerticalBar) res[1].Details[1]).OrderID);
            Assert.AreEqual(10254, ((OrdersVerticalBar) res[1].Details[2]).OrderID);

            Assert.AreEqual("ANTON", ((CustomersVerticalBar) res[2].Master).CustomerID);
            Assert.AreEqual(10257, ((OrdersVerticalBar) res[2].Details[0]).OrderID);
            Assert.AreEqual(10258, ((OrdersVerticalBar) res[2].Details[1]).OrderID);

            Assert.AreEqual("DUMON", ((CustomersVerticalBar) res[3].Master).CustomerID);


            if (File.Exists("tempmd.txt"))
                File.Delete("tempmd.txt");
        }
        public void CustomerOrdersWrite2()
        {
            MasterDetailEngine<CustomersVerticalBar, OrdersVerticalBar> masterDetEng = new MasterDetailEngine<CustomersVerticalBar, OrdersVerticalBar>();

            MasterDetails<CustomersVerticalBar, OrdersVerticalBar> record;
            List<MasterDetails<CustomersVerticalBar, OrdersVerticalBar>> records = new List<MasterDetails<CustomersVerticalBar,OrdersVerticalBar>>();

            // Create the master detail item
            record = new MasterDetails<CustomersVerticalBar, OrdersVerticalBar>();
            records.Add(record);

            // Create the master object
            record.Master = new CustomersVerticalBar();
            record.Master.CustomerID = "ALFKI";
            record.Master.Country = "Argentina";

            // Create the details object
            List<OrdersVerticalBar> orders = new List<OrdersVerticalBar>();
            foreach (OrdersVerticalBar det in colDetails)
            {
                orders.Add(det);
            }

            record.Details = orders.ToArray();

            // We can create a second master object
            record = new MasterDetails<CustomersVerticalBar, OrdersVerticalBar>();
            records.Add(record);

            record.Master = new CustomersVerticalBar();
            record.Master.CustomerID = "ALFKI";
            record.Master.Country = "Argentina";

            orders = new List<OrdersVerticalBar>();
            foreach (OrdersVerticalBar det in colDetails)
            {
                orders.Add(det);
            }
            record.Details = orders.ToArray();

            // And now write it to a file

            masterDetEng.WriteFile("myMDfile.txt", records.ToArray());
        }