Ejemplo n.º 1
0
        //[PrincipalPermission(SecurityAction.Demand,Role = "Roadshow Specialist")]
        public bool UpdateExportDate(DateTime lastUpdated)
        {
            bool updated = false;

            //Update the latest delivery point LastUpdated date from the last export
            try {
                updated = new DeliveryPointsGateway().UpdateExportDate(lastUpdated);
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(ex.Message), "Service Error"); }
            return(updated);
        }
Ejemplo n.º 2
0
        public DateTime GetExportDate()
        {
            //Get the latest delivery point LastUpdated date from the last export
            DateTime exportDate;

            try {
                exportDate = new DeliveryPointsGateway().GetExportDate();
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(ex.Message), "Service Error"); }
            return(exportDate);
        }
Ejemplo n.º 3
0
        public DataSet GetDeliveryPoints(DateTime startDate, DateTime lastUpated)
        {
            //Update a collection (dataset) of all delivery points
            DataSet      points    = new DataSet();
            const string CSV_DELIM = ",";

            try {
                //Clear and fetch new data
                DataSet ds = new DeliveryPointsGateway().GetDeliveryPoints(startDate, lastUpated);
                if (ds != null && ds.Tables["DeliveryPointTable"] != null && ds.Tables["DeliveryPointTable"].Rows.Count > 0)
                {
                    //Create a dataset of containing unique entries
                    DeliveryPointsDataset _ds = new DeliveryPointsDataset();
                    _ds.Merge(ds);
                    DeliveryPointsDataset rds = new DeliveryPointsDataset();
                    rds.Merge(_ds.DeliveryPointTable.Select("", "Account ASC"));
                    Hashtable ht   = new Hashtable();
                    string    acct = "";
                    for (int i = 0; i < rds.DeliveryPointTable.Rows.Count; i++)
                    {
                        //Remove duplicate account entries
                        acct = rds.DeliveryPointTable[i].Account;
                        if (ht.ContainsKey(acct))
                        {
                            rds.DeliveryPointTable[i].Delete();
                        }
                        else
                        {
                            ht.Add(acct, null);          //Keep track of keys (unique accounts)
                        }
                    }
                    rds.AcceptChanges();

                    //Modify data
                    for (int i = 0; i < rds.DeliveryPointTable.Rows.Count; i++)
                    {
                        //Set command as follows:
                        //	A:	OpenDate > lastpDated; U: OpenDate <= lastUpdated
                        DateTime opened = rds.DeliveryPointTable[i].OpenDate;
                        rds.DeliveryPointTable[i].Command = (opened.CompareTo(lastUpated) > 0) ? "A" : "U";

                        //Remove commas from address fields
                        rds.DeliveryPointTable[i].Building    = rds.DeliveryPointTable[i].Building.Replace(CSV_DELIM, " ");
                        rds.DeliveryPointTable[i].Address     = rds.DeliveryPointTable[i].Address.Replace(CSV_DELIM, " ");
                        rds.DeliveryPointTable[i].StopComment = rds.DeliveryPointTable[i].StopComment.Replace(CSV_DELIM, " ");
                    }
                    rds.AcceptChanges();
                    points.Merge(rds);
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(ex.Message), "Service Error"); }
            return(points);
        }