Example #1
0
 protected void ExportSortedItems(ISDExportDataset sortedItems, string xsltFile, string csvFile)
 {
     //UNUSED: This is for an xsl-based approach
     //XmlTextWriter writer = null;
     //try {
     //    //
     //    XmlDataDocument xml = new XmlDataDocument(sortedItems);
     //    XslTransform xslt = new XslTransform();
     //    xslt.Load(xsltFile);
     //    writer = new XmlTextWriter(csvFile,Encoding.ASCII);
     //    xslt.Transform(xml,null,writer,null);
     //}
     //catch(Exception ex) { throw new ApplicationException("Unexpected error while exporting sorted items.",ex); }
     //finally { if(writer != null) writer.Close(); }
 }
Example #2
0
        public static ISDExportDataset GetClients(string clientNumber)
        {
            ISDExportDataset configuration = null;

            try {
                configuration = new ISDExportDataset();
                DataSet ds = fillDataset(USP_EXPORTFILECONFIG, TBL_EXPORTFILECONFIG, new object[] { clientNumber });
                if (ds != null)
                {
                    configuration.Merge(ds);
                }
            }
            catch (Exception ex) { throw new ApplicationException("", ex); }
            return(configuration);
        }
Example #3
0
        public static ISDExportDataset GetSortedItems(string pickupID)
        {
            //Get sorted items for a pickup
            ISDExportDataset sortedItems = null;

            try {
                sortedItems = new ISDExportDataset();
                DataSet ds = fillDataset(USP_SORTEDITEMS, TBL_SORTEDITEMS, new object[] { pickupID });
                if (ds != null)
                {
                    sortedItems.Merge(ds, false, MissingSchemaAction.Ignore);
                }
            }
            catch (Exception ex) { throw ex; }
            return(sortedItems);
        }
Example #4
0
        public static ISDExportDataset GetPickups(DateTime pickupDate)
        {
            //Update a collection (dataset) of all pickups for the terminal on the local LAN database
            ISDExportDataset pickups = null;

            try {
                pickups = new ISDExportDataset();
                DataSet ds = fillDataset(USP_PICKUPS, TBL_PICKUPS, new object[] { pickupDate });
                if (ds != null)
                {
                    pickups.Merge(ds);
                }
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while reading pickups.", ex); }
            return(pickups);
        }
Example #5
0
        public static ISDExportDataset GetPickups(DateTime pickupDate)
        {
            //
            ISDExportDataset       pickups = new ISDExportDataset();
            ISDExportServiceClient client  = new ISDExportServiceClient();

            try {
                DataSet ds = client.GetPickups(int.Parse(Program.TerminalCode), pickupDate);
                if (ds != null)
                {
                    pickups.Merge(ds);
                }
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <AgentLineHaulFault> afe) { client.Abort(); throw new ApplicationException(afe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(pickups);
        }
Example #6
0
        public override bool Export(string exportFile, ISDClient isdClient, Pickup pickup, ISDExportDataset sortedItems)
        {
            //Exports sorted items dataset to a file specified by the database
            bool         exported = false;
            StreamWriter writer   = null;

            try {
                //Validate file is unique
                if (File.Exists(exportFile))
                {
                    throw new Exception("Export file " + exportFile + " already exists. ");
                }

                //Create the new file and save sorted items for this pickup to disk
                writer = new StreamWriter(new FileStream(exportFile, FileMode.Create, FileAccess.ReadWrite));
                writer.BaseStream.Seek(0, SeekOrigin.Begin);
                for (int j = 0; j < sortedItems.SortedItemTable.Rows.Count; j++)
                {
                    writer.WriteLine(formatSortedItemRecord((ISDExportDataset.SortedItemTableRow)sortedItems.SortedItemTable.Rows[j]));
                }
                writer.Flush();
                exported = true;
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            finally { if (writer != null)
                      {
                          writer.Close();
                      }
            }
            return(exported);
        }
Example #7
0
 public abstract bool Export(string exportFile, ISDClient isdClient, Pickup pickup, ISDExportDataset sortedItems);