Beispiel #1
0
        private bool UpdateJobState(PdfJob job, JOB_STATE job_state)
        {
            try
            {
                string data_path     = Directory.GetParent(job.DataPath + this.scanned_file_name).FullName;
                string dbf_file_name = Path.GetFileNameWithoutExtension(job.DataPath + this.scanned_file_name);

                OleDbConnection conn = new OleDbConnection(
                    @"Provider=VFPOLEDB.1;Data Source=" + data_path);

                conn.Open();

                if (conn.State == ConnectionState.Open)
                {
                    string mySQL = "Update " + dbf_file_name + " Set Status = '" + ((int)job_state).ToString() + "', SendDate = CTOD('" + job.SendTime.Value.ToString("MM/dd/yyyy", CultureInfo.GetCultureInfo("en-US")) + "'), SendTime = '" + job.SendTime.Value.ToString("HH:mm:ss", CultureInfo.GetCultureInfo("en-US")) + "' Where docnum='" + job.Docnum + "'";

                    OleDbCommand cmd = new OleDbCommand(mySQL, conn);
                    cmd.ExecuteNonQuery();

                    conn.Close();
                }

                return(true);
            }
            catch (Exception)
            {
                return(this.UpdateJobState(job, job_state));
            }
        }
Beispiel #2
0
        public void f_runLoop(object state, bool timedOut)
        {
            if (!_inited)
            {
                _inited = true;
                f_Init();
                _state = JOB_STATE.INIT;
                if (jobInfo != null)
                {
                    lock (jobInfo)
                        jobInfo = (JobInfo)state;
                }
                else
                {
                    jobInfo = (JobInfo)state;
                }
                return;
            }

            if (!timedOut)
            {
                //Tracer.WriteLine("J{0} executes on thread {1}: SIGNAL -> STOP ...", Id, Thread.CurrentThread.GetHashCode().ToString());
                JobInfo ti = (JobInfo)state;
                ti.f_stopJob();
                _state = JOB_STATE.STOPED;
                return;
            }

            if (_state != JOB_STATE.RUNNING)
            {
                _state = JOB_STATE.RUNNING;
            }

            //Tracer.WriteLine("J{0} executes on thread {1}:DO SOMETHING ...", Id, Thread.CurrentThread.GetHashCode().ToString());
            // Do something ...

            if (msg.Count > 0)
            {
                Message m = msg.Dequeue(null);
                if (m != null)
                {
                    //[1] SEND REQUEST TO JOB FOR EXECUTE
                    if (m.Type == MESSAGE_TYPE.REQUEST)
                    {
                        IJob[] jobs = this.StoreJob.f_job_getByID(m.GetReceiverId());
                        if (jobs.Length > 0)
                        {
                            for (int i = 0; i < jobs.Length; i++)
                            {
                                jobs[i].f_receiveMessage(m);
                            }
                        }
                    }
                    else
                    {
                        //[2] RESPONSE TO SENDER
                        switch (m.getSenderType())
                        {
                        case SENDER_TYPE.IS_FORM:
                            IFORM fom = this.StoreJob.f_form_Get(m.GetSenderId());
                            if (fom != null)
                            {
                                fom.f_receiveMessage(m.GetMessageId());
                            }
                            // write to LOG ...
                            break;

                        case SENDER_TYPE.HIDE_SENDER:
                            // do not send response to sender
                            // write to LOG ...
                            break;
                        }
                    }
                }
            }
        }