コード例 #1
0
        public DataSet GetAgents()
        {
            //Get a list of agents
            DataSet agents = new DataSet();

            try {
                DataSet ds = new ShipScheduleTemplatesGateway().GetAgents();
                if (ds != null && ds.Tables["AgentTable"] != null && ds.Tables["AgentTable"].Rows.Count > 0)
                {
                    agents.Merge(ds);
                }
            }
            catch (Exception ex) { throw new FaultException <ShipScheduleFault>(new ShipScheduleFault(ex.Message), "Service Error"); }
            return(agents);
        }
コード例 #2
0
        public DataSet GetShippersAndTerminals()
        {
            //Get a list of shippers and terminals
            DataSet terminals = new DataSet();

            try {
                DataSet ds = new ShipScheduleTemplatesGateway().GetShippersAndTerminals();
                if (ds != null && ds.Tables["TerminalTable"] != null && ds.Tables["TerminalTable"].Rows.Count > 0)
                {
                    terminals.Merge(ds);
                }
            }
            catch (Exception ex) { throw new FaultException <ShipScheduleFault>(new ShipScheduleFault(ex.Message), "Service Error"); }
            return(terminals);
        }
コード例 #3
0
        public DataSet GetTemplates()
        {
            //Get a collection of ship schedules templates for all terminals
            DataSet templates = new DataSet();

            try {
                DataSet ds = new ShipScheduleTemplatesGateway().GetShipScheduleTemplates();
                if (ds != null && ds.Tables["ShipScheduleTemplateTable"] != null && ds.Tables["ShipScheduleTemplateTable"].Rows.Count > 0)
                {
                    templates.Merge(ds);
                }
            }
            catch (Exception ex) { throw new FaultException <ShipScheduleFault>(new ShipScheduleFault(ex.Message), "Service Error"); }
            return(templates);
        }
コード例 #4
0
        public string AddTemplate(ShipScheduleTemplate template)
        {
            //
            string templateID = "";

            try {
                //Apply simple business rules
                if (template == null)
                {
                    return("");
                }

                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //Create the trip
                    templateID = new ShipScheduleTemplatesGateway().CreateShipScheduleTemplate(template);

                    //Stop 1
                    new ShipScheduleTemplatesGateway().CreateShipScheduleTemplateStop(templateID, template.StopNumber, template.AgentTerminalID,
                                                                                      template.Tag, template.Notes, template.ScheduledArrivalDateOffset,
                                                                                      template.ScheduledArrivalTime, template.ScheduledOFD1Offset,
                                                                                      DateTime.Now, template.Stop1User);

                    //Stop 2
                    if (template.S2MainZone.Trim().Length > 0)
                    {
                        new ShipScheduleTemplatesGateway().CreateShipScheduleTemplateStop(templateID, template.S2StopNumber, template.S2AgentTerminalID,
                                                                                          template.S2Tag, template.S2Notes, template.S2ScheduledArrivalDateOffset,
                                                                                          template.S2ScheduledArrivalTime, template.S2ScheduledOFD1Offset,
                                                                                          DateTime.Now, template.Stop2User);
                    }

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <ShipScheduleFault>(new ShipScheduleFault(ex.Message), "Service Error"); }
            return(templateID);
        }