Exemple #1
0
        public ReportInfo FMRun(string reportName, FileMaintenanceType fmtype, FileRunStatus callStatus, int queue, RunWorkerCompletedEventHandler Notify = null)
        {
            callStatus(RunState.Initializing, reportName);
            ISymCommand cmd;
            string      outTitle = "FM - " + new Random().Next(8388608).ToString("D7");

            _socket.Write("mm0\u001B");
            cmd = WaitForCommand("Input");

            _socket.Write("1\r");
            cmd = WaitForCommand("Input");

            _socket.Write("24\r"); //Misc. Processing
            cmd = WaitForCommand("Input");

            _socket.Write("5\r"); //Batch FM
            cmd = WaitForCommand("Input");

            _socket.Write(((int)fmtype).ToString() + "\r");  //FM File Type
            cmd = WaitForCommand("Input");

            _socket.Write("0\r"); //Undo a Posting? (NO)
            cmd = WaitForCommand("Input");

            _socket.Write(reportName + "\r"); //Title of Batch Report Output to Use as FM Script
            cmd = WaitForCommand("Input");

            _socket.Write("1\r"); //Number of Search Days? (1)
            cmd = WaitForCommand("Input");

            if (fmtype == FileMaintenanceType.Account)
            {
                _socket.Write("1\r"); //Record FM History (YES)
                cmd = WaitForCommand("Input");
            }

            _socket.Write(outTitle + "\r"); //Name of Posting (needed to lookup later)
            cmd = WaitForCommand("Input");

            _socket.Write("1\r"); //Produce Empty Report If No Exceptions? (YES)
            cmd = WaitForCommand("Input");

            _socket.Write("0\r"); //Batch Options? (NO)

            if (queue < 0)
            {
                queue = GetOpenQueue(null);
            }

            _socket.Write(queue.ToString() + "\r"); //write queue
            cmd = WaitForCommand("Input");

            _socket.Write("1\r"); //Okay (to Proceed)? (YES)
            cmd = WaitForCommand("Input");

            //get queues again
            callStatus(RunState.Initializing, "Finding FM Sequence");
            cmd = new SymCommand("Misc");
            cmd.Set("InfoType", "BatchQueues");
            _socket.Write(cmd);

            int newestTime = 0;
            int sequenceNo = -1;

            cmd = _socket.ReadCommand();
            while (!cmd.HasParameter("Done"))
            {
                if (cmd.Get("Action") == "QueueEntry")
                {
                    int    currTime = 0;
                    string timeStr  = cmd.Get("Time");

                    string[] tokens = timeStr.Split(':');
                    string   seconds = tokens[2], minutes = tokens[1], hours = tokens[0];

                    currTime  = int.Parse(seconds);
                    currTime += 60 * int.Parse(minutes);
                    currTime += 3600 * int.Parse(hours);

                    if (currTime >= newestTime)
                    {
                        newestTime = currTime;
                        sequenceNo = int.Parse(cmd.Get("Seq"));
                    }
                }
                cmd = _socket.ReadCommand();
            }

            callStatus(RunState.Running, sequenceNo);

            if (Notify != null)
            {
                var worker = new BackgroundWorker();

                worker.DoWork += (sender, eventArgs) =>
                {
                    while (IsFileRunning(sequenceNo))
                    {
                        Thread.Sleep(15000);
                    }

                    eventArgs.Result = GetFileMaintenanceSequence(reportName);
                };

                worker.RunWorkerCompleted += Notify;

                worker.RunWorkerAsync();
            }

            return(new ReportInfo(sequenceNo, outTitle));
        }
Exemple #2
0
        public ReportInfo FMRun(string reportName, FileMaintenanceType fmtype, FileRunStatus callStatus, int queue, RunWorkerCompletedEventHandler Notify = null)
        {
            callStatus(RunState.Initializing, reportName);
            ISymCommand cmd;
            string outTitle = "FM - " + new Random().Next(8388608).ToString("D7");

            _socket.Write("mm0\u001B");
            cmd = WaitForCommand("Input");

            _socket.Write("1\r");
            cmd = WaitForCommand("Input");

            _socket.Write("24\r"); //Misc. Processing
            cmd = WaitForCommand("Input");

            _socket.Write("5\r"); //Batch FM
            cmd = WaitForCommand("Input");

            _socket.Write(((int) fmtype).ToString() + "\r"); //FM File Type
            cmd = WaitForCommand("Input");

            _socket.Write("0\r"); //Undo a Posting? (NO)
            cmd = WaitForCommand("Input");

            _socket.Write(reportName + "\r"); //Title of Batch Report Output to Use as FM Script
            cmd = WaitForCommand("Input");

            _socket.Write("1\r"); //Number of Search Days? (1)
            cmd = WaitForCommand("Input");

            if (fmtype == FileMaintenanceType.Account)
            {
                _socket.Write("1\r"); //Record FM History (YES)
                cmd = WaitForCommand("Input");
            }

            _socket.Write(outTitle + "\r"); //Name of Posting (needed to lookup later)
            cmd = WaitForCommand("Input");

            _socket.Write("1\r"); //Produce Empty Report If No Exceptions? (YES)
            cmd = WaitForCommand("Input");

            _socket.Write("0\r"); //Batch Options? (NO)

            if (queue < 0)
            {
                queue = GetOpenQueue(null);
            }

            _socket.Write(queue.ToString() + "\r"); //write queue
            cmd = WaitForCommand("Input");

            _socket.Write("1\r"); //Okay (to Proceed)? (YES)
            cmd = WaitForCommand("Input");

            //get queues again
            callStatus(RunState.Initializing, "Finding FM Sequence");
            cmd = new SymCommand("Misc");
            cmd.Set("InfoType", "BatchQueues");
            _socket.Write(cmd);

            int newestTime = 0;
            int sequenceNo = -1;
            cmd = _socket.ReadCommand();
            while (!cmd.HasParameter("Done"))
            {
                if (cmd.Get("Action") == "QueueEntry")
                {
                    int currTime = 0;
                    string timeStr = cmd.Get("Time");

                    string[] tokens = timeStr.Split(':');
                    string seconds = tokens[2], minutes = tokens[1], hours = tokens[0];

                    currTime = int.Parse(seconds);
                    currTime += 60*int.Parse(minutes);
                    currTime += 3600*int.Parse(hours);

                    if (currTime >= newestTime)
                    {
                        newestTime = currTime;
                        sequenceNo = int.Parse(cmd.Get("Seq"));
                    }
                }
                cmd = _socket.ReadCommand();
            }

            callStatus(RunState.Running, sequenceNo);

            if (Notify != null)
            {
                var worker = new BackgroundWorker();

                worker.DoWork += (sender, eventArgs) =>
                {
                    while (IsFileRunning(sequenceNo))
                    {
                        Thread.Sleep(15000);
                    }

                    eventArgs.Result = GetFileMaintenanceSequence(reportName);
                };

                worker.RunWorkerCompleted += Notify;

                worker.RunWorkerAsync();
            }

            return new ReportInfo(sequenceNo, outTitle);
        }