internal ManagedThread(ManagedJob job, ThreadType type, bool signal, bool wait)
        {
            _job  = job;
            _name = job.Name;
            _args = job.GetArguments();

            if (wait)
            {
                _waitFlag = new AutoResetEvent(signal);
                _wait     = true;
            }

            CurrentState = JobState.Stopped;
            _thread      = new Thread(new ThreadStart(Run));
            _type        = type;
        }
Esempio n. 2
0
        public static List <ManagedJob> CreateJobs()
        {
            List <ManagedJob> jobCollection = new List <ManagedJob>();
            List <JobElement> jobList       = ConfigurationHelper.GetEnabledJobs();

            foreach (JobElement job in jobList)
            {
                // Look for implementation for the Job
                Type jobImplClass = LoadImplementationClass(ConfigurationHelper.GetJobType(job));

                if (jobImplClass != null)
                {
                    JobArgumentCollection jac = ConfigurationHelper.GetJobArgumentCollection(job);

                    List <object> arguments = new List <object>();
                    arguments.Add(job.Name);
                    arguments.Add(job.WaitForEvent);
                    arguments.Add(jac);

                    // Create an instance of the job
                    ManagedJob managedJob = Activator.CreateInstance(jobImplClass, arguments.ToArray()) as ManagedJob;

                    ISpawn spawn = managedJob as ISpawn;

                    if (spawn != null)
                    {
                        ManagedJob[] spawnedJobs = spawn.SpawnJobs();

                        foreach (ManagedJob j in spawnedJobs)
                        {
                            job.Log.FileName = Path.Combine(Path.GetDirectoryName(job.Log.FileName), j.Name) + Path.GetExtension(job.Log.FileName);
                            InitializeTracing(j, job.Log);
                            jobCollection.Add(j);
                        }
                    }
                    else
                    {
                        InitializeTracing(managedJob, job.Log);
                        jobCollection.Add(managedJob);
                    }
                }
            }

            return(jobCollection);
        }
        public ServiceHostJob(string name, bool wait, JobArgumentCollection args)
            : base(name, wait, args)
        {
            typeName = args["type"];

            if (string.IsNullOrEmpty(typeName))
            {
                throw new NullReferenceException(string.Format("Error in service {0}. The type parameter is null, must be defined.", name));
            }

            serviceType = Type.GetType(typeName, true);

            waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
            syncLock   = new object();

            CustomServiceHost.ContractNamespace       = "ServiceContracts";
            CustomServiceHost.ImplementationNamespace = "ServiceImplementation";
        }
Esempio n. 4
0
        public void Execute(JobArgumentCollection ARGS_I, ref Array eventArr)
        {
            if (sp_Execute == null)
            {
                CreateSP_Execute();
            }

            sp_Execute.Transaction = connectionProvider.CurrentTransaction;

            // Set In Parameters
            string argsXml = DbJob.CreateNameValuePairListXml(ARGS_I);

            if (ARGS_I == null)
            {
                (sp_Execute.Parameters["ARGS_I"] as IDbDataParameter).Value = DBNull.Value;
            }
            else
            {
                (sp_Execute.Parameters["ARGS_I"] as IDbDataParameter).Value = argsXml;
            }

            // Execute stored procedure

            sp_Execute.Prepare();
            sp_Execute.ExecuteNonQuery();

            // Set Out Parameters
            if ((sp_Execute.Parameters["EVENTLIST_O"] as IDbDataParameter).Value == DBNull.Value)
            {
                eventArr = null;
            }
            else
            {
                String eventXml = (sp_Execute.Parameters["EVENTLIST_O"] as IDbDataParameter).Value as string;
                eventArr = CreateArrayFromXml(eventXml, "Event");
            }
        }
Esempio n. 5
0
 public WebServiceSend(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
 }
 public OutputManagerSend(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
     _endpointName           = args["endpointName"];
     _maxNumOfConcurrentJobs = Convert.ToInt32(args["maxConcurrentJobs"]);
 }
Esempio n. 7
0
 protected abstract void ExecuteProcedure(JobArgumentCollection args);
Esempio n. 8
0
 public OracleJob(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
     _syncLock = new object();
 }
 public AutoServiceHostJob(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
 }
Esempio n. 10
0
 public Scheduler(string name, bool wait, JobArgumentCollection args)
     : base(name, false, args)
 {
     scheduleDictionary = new Dictionary <string, ManagedSchedule>();
     multiplier         = 1;
 }
Esempio n. 11
0
 public MailAgent(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
 }
Esempio n. 12
0
        protected override void ExecuteProcedure(JobArgumentCollection args)
        {
            // Check parameters
            _userName    = args["userName"];
            _password    = args["password"];
            _useLogTable = Convert.ToBoolean(args["useLogTable"]);

            _logDirectory = args["logDirectory"];
            _printerType  = args["printerType"];

            if (!string.IsNullOrEmpty(_printerType))
            {
                _fetchEachPrinterType = false;
            }

            string dumpXmlValue = args["dumpXml"];

            if (!string.IsNullOrEmpty(dumpXmlValue))
            {
                _isXmlDumpEnabled = (dumpXmlValue == "true");
            }

            _documentType = args["documentType"];

            if (string.IsNullOrEmpty(_documentType))
            {
                _documentType = "Rdf";
            }

            Tracing.TraceEvent(TraceEventType.Verbose, 0, "Start");

            _getMessages = true;
            _stopJob     = false;

            while (_getMessages && !_stopJob)
            {
                DateTime startDT = DateTime.Now;

                long start = DateTime.Now.Ticks;
                _getMessages = false;

                MessageId = Convert.ToString(DateTime.Now.Ticks);

                DateTime startDBDT = DateTime.Now;

                StartTransaction();

                CENTIROTRANS transaction = FindMessageToSend();

                Commit();

                DateTime doneDBDT = DateTime.Now;


                if (transaction != null)
                {
                    string error = "";

                    try
                    {
                        //Write log table
                        NewLog("Start message loop", startDT, 0, transaction);

                        //Write log table
                        NewLog("Start fetching message from database", startDBDT, 10, transaction);

                        //Write log table
                        NewLog("Done fetching message from database", doneDBDT, 20, transaction);

                        _getMessages = true;

                        if (_isXmlDumpEnabled)
                        {
                            //Write log table
                            NewLog("Start XML dump to file", DateTime.Now, 30, transaction);

                            new XMLHelper().DumpToFile(transaction.REPORT, LogFileName("FromPLQueue_type_" + transaction.REPORTTYPE));

                            //Write log table
                            NewLog("Done XML dump to file", DateTime.Now, 40, transaction);
                        }

                        //Write log table
                        NewLog("Start logging message", DateTime.Now, 50, transaction);

                        Tracing.TraceEvent(TraceEventType.Verbose, 0,
                                           string.Format("Found REPORTJOBID {0} REPORTTYPE {1}", transaction.REPORTJOBID, transaction.REPORTTYPE));

                        //Write log table
                        NewLog("Done logging message", DateTime.Now, 60, transaction);

                        StartTransaction();

                        //Write log table
                        NewLog("Start Centiro send and receive process", DateTime.Now, 70, transaction);

                        switch (transaction.REPORTTYPE)
                        {
                        case "UP":      /* Update Parcel */
                            UpdateParcel(transaction.REPORT);
                            break;

                        case "RP":      /* Remove Parcel */
                            RemoveParcel(transaction.REPORT);
                            break;

                        case "PP":      /* Print Parcel */
                            PrintParcel(transaction.REPORT, transaction.WHID);
                            break;

                        case "US":      /* Update Shipment */
                            UpdateShipment(transaction.REPORT);
                            break;

                        case "PS":      /* Print Shipment */
                            PrintShipment(transaction.REPORT, transaction.WHID);
                            break;

                        case "PD":      /* Print Departure */
                            PrintDeparture(transaction.REPORT);
                            break;

                        case "CD":      /* Close Departure */
                            CloseDeparture(transaction.REPORT);
                            break;

                        default:
                            Tracing.TraceEvent(TraceEventType.Verbose, 0,
                                               string.Format("REPORTTYPE {0} not supported", transaction.REPORTTYPE));
                            break;
                        }

                        //Write log table
                        NewLog("Done Centiro send and receive process", DateTime.Now, 80, transaction);

                        //Write log table
                        NewLog("Start enqueueing documents in print queue", DateTime.Now, 90, transaction);

                        EnqueueDocuments(transaction.WHID);

                        //Write log table
                        NewLog("Done enqueueing documents in print queue", DateTime.Now, 100, transaction);
                    }
                    catch (Exception ex)
                    {
                        Rollback();

                        //Write log table
                        NewLog("Start exception handler", DateTime.Now, 110, transaction);

                        Tracing.TraceEvent(TraceEventType.Error, 0, string.Format("Exception while printing REPORTJOBID {0} REPORTTYPE {1}", transaction.REPORTJOBID, transaction.REPORTTYPE));
                        Tracing.TraceData(TraceEventType.Error, 0, ex);

                        error = ex.Message;

                        StartTransaction();

                        //Write log table
                        NewLog("Done exception handler", DateTime.Now, 120, transaction);
                    }

                    string almid = "";

                    if (string.IsNullOrEmpty(error))
                    {
                        //Write log table
                        NewLog("Start updating status processed and logging status change", DateTime.Now, 130, transaction);

                        Tracing.TraceEvent(TraceEventType.Verbose, 0, String.Format("No error reported for REPORTJOBID {0} REPORTTYPE {1}", transaction.REPORTJOBID, transaction.REPORTTYPE));
                        _carrierCompliantQueue.ModifyProcessed(transaction.REPORTJOBID, MessageId, ref almid);

                        //Write log table
                        NewLog("Done updating status processed and logging status change", DateTime.Now, 140, transaction);
                    }
                    else
                    {
                        //Write log table
                        NewLog("Start updating status error and logging status change", DateTime.Now, 150, transaction);

                        Tracing.TraceEvent(TraceEventType.Error, 0, String.Format("Error reported for REPORTJOBID {0} REPORTTYPE {1}", transaction.REPORTJOBID, transaction.REPORTTYPE));

                        _carrierCompliantQueue.ModifyError(transaction.REPORTJOBID, error, MessageId, null, ref almid);

                        //Write log table
                        NewLog("Done updating status error and logging status change", DateTime.Now, 160, transaction);
                    }

                    if (!string.IsNullOrEmpty(almid))
                    {
                        //Write log table
                        NewLog("Start logging almid", DateTime.Now, 170, transaction);

                        Tracing.TraceEvent(TraceEventType.Error, 0, String.Format("Error while updating transaction status. Almid={0}. REPORTJOBID {1} REPORTTYPE {2}", almid, transaction.REPORTJOBID, transaction.REPORTTYPE));

                        //Write log table
                        NewLog("Done logging almid", DateTime.Now, 180, transaction);
                    }

                    Commit();

                    //Write log table
                    NewLog("Done processing message", DateTime.Now, 190, transaction);
                }

                long     stop = DateTime.Now.Ticks;
                TimeSpan ts   = new TimeSpan(stop - start);

                Tracing.TraceEvent(TraceEventType.Verbose, 0, String.Format("Stop (used {0}s)", ts.TotalSeconds.ToString("0.00")));
            }
            ;
        }
 public GatewayReceiver(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
 }
 public StandardOracleJob(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
 }
Esempio n. 15
0
 public GatewaySender(string name, bool wait, JobArgumentCollection args)
     : base(name, wait, args)
 {
     // get the temp directory as defined in Windows environment
     tempDirectory = Path.GetTempPath();
 }