Ejemplo n.º 1
0
 //========================================================================
 public RepErr(SymFile Source, string ErrFile, string ErrMsg, int Row, int Col)
 {
     fileSrc = Source;
       fileErr = ErrFile;
       error   = ErrMsg;
       line    = Row;
       column  = Col;
       any     = true;
 }
Ejemplo n.º 2
0
        //------------------------------------------------------------------------
        public int GetReportSequence(string repName, int time)
        {
            List<int> seqs = GetPrintSequences("REPWRITER");
              foreach(int i in seqs)
              {
            SymFile file = new SymFile(server, sym, i.ToString(), DateTime.Now, 0, SymFile.Type.REPORT);
            string contents = FileRead(file);
            int beganIndex = contents.IndexOf("Processing begun on");
            if(beganIndex != -1)
            {
              contents = contents.Substring(beganIndex+41);
              string timeStr = contents.Substring(0, 8);
              int currTime =     int.Parse(timeStr.Substring(timeStr.LastIndexOf(':')+1));
              currTime +=   60 * int.Parse(timeStr.Substring(timeStr.IndexOf(':')+1, 2));
              currTime += 3600 * int.Parse(timeStr.Substring(0, timeStr.IndexOf(':')));
              contents = contents.Substring(contents.IndexOf("(newline when done):") + 21);

              string name = contents.Substring(0, contents.IndexOf('\n'));
              if(name == repName)
            if((time+1==currTime) || (time==currTime) || (time-1==currTime))
              return i;
            }
              }
              return -1;
        }
Ejemplo n.º 3
0
 //========================================================================
 // FM Running Stuff
 //========================================================================
 public int GetFMSequence(string title)
 {
     List<int> seqs = GetPrintSequences("MISCFMPOST");
       foreach(int i in seqs)
       {
     SymFile file = new SymFile(server, sym, i.ToString(), DateTime.Now, 0, SymFile.Type.REPORT);
     string contents = FileRead(file);
     contents = contents.Substring(contents.IndexOf("Name of Posting: ")+17);
     if(contents.StartsWith(title))
       return i;
       }
       return -1;
 }
Ejemplo n.º 4
0
 //------------------------------------------------------------------------
 public void FileWrite(SymFile file, string content)
 {
     FileWrite(file.name, file.type, content);
 }
Ejemplo n.º 5
0
        //========================================================================
        public void FileWrite(string name, SymFile.Type type, string content)
        {
            int chunkMax = 1024;

              SymCommand cmd = new SymCommand("File");
              cmd.SetParam("Action", "Store");
              cmd.SetParam("Type"  , SymFile.TypeString(type));
              cmd.SetParam("Name"  , name);
              WakeUp();
              Write(cmd);

              cmd = ReadCommand();
              int wtf_is_this = 0;
              while(cmd.data.IndexOf("BadCharList") == -1)
              {
            cmd = ReadCommand();
            wtf_is_this++;
            if(wtf_is_this > 5)
              throw new Exception("Null Pointer");
              }

              if(cmd.data.IndexOf("MaxBuff") > -1)
              chunkMax = int.Parse(cmd.GetParam("MaxBuff"));
              if(content.Length > (999*chunkMax))
            throw new Exception("File Too Large");

              if(cmd.GetParam("Status").IndexOf("Filename is too long") != -1)
            throw new Exception("Filename Too Long");

              string[] badChars = cmd.GetParam("BadCharList").Split(new char[] { ',' });
              for(int i=0; i<badChars.Length; i++)
            content = content.Replace(((char)int.Parse(badChars[i]))+"", "");

              int sent=0, block=0; string blockStr; byte[] resp;
              while(sent < content.Length)
              {
            int chunkSize = (content.Length - sent);
            if(chunkSize > chunkMax)
              chunkSize = chunkMax;
            string chunk = content.Substring(sent, chunkSize);
            string chunkStr = chunkSize.ToString("D5");
            blockStr = block.ToString("D3");

            resp = new byte[]{0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E};
            while(resp[7] == 0x4E)
            {
              Write("PROT"+blockStr+"DATA"+chunkStr);
              Write(chunk);
              resp = Read(16);
            }

            block++;
            sent += chunkSize;
              }

              blockStr = block.ToString("D3");
              Write("PROT"+blockStr+"EOF\u0020\u0020\u0020\u0020\u0020\u0020");
              resp = Read(16);

              cmd = ReadCommand();
              WakeUp();
        }
Ejemplo n.º 6
0
        //------------------------------------------------------------------------
        public RepRunErr FileRun(SymFile file, FileRun_Status callStatus, FileRun_Prompt callPrompt, int queue)
        {
            if (file.type != SymFile.Type.REPGEN)
            throw new Exception("Cannot Run a " + file.TypeString() + " File");

              SymCommand cmd;
              callStatus(0,"Initializing...");

              Write("mm0\u001B");
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();
              callStatus(1,"Writing Commands...");

              Write("1\r");
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();
              callStatus(2,"Writing Commands...");

              Write("11\r");
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();
              callStatus(3,"Writing Commands...");

              Write(file.name + "\r");
              bool erroredOut = false;
              while(true)
              {
            cmd = ReadCommand();

            if((cmd.command == "Input") && (cmd.GetParam("HelpCode")=="20301"))
              break;
            if(cmd.command == "Input")
            {
              callStatus(4,"Please Enter Prompts");

              string result = callPrompt(cmd.GetParam("Prompt"));
              if(result == null) //cancelled
              {
            Write("\u001B");
            cmd = ReadCommand();
            while(cmd.command != "Input")
              cmd = ReadCommand();
            return RepRunErr.Cancelled();
              }
              else
            Write(result.Trim()+'\r');
            }
            else if(cmd.command == "Bell")
              callStatus(4, "Invalid Prompt Input, Please Re-Enter");
            else if((cmd.command == "Batch") && (cmd.GetParam("Text")=="No such file or directory"))
            {
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();
              return RepRunErr.NotFound();
            }
            else if(cmd.command == "SpecfileErr")
              erroredOut = true;
            else if(erroredOut && (cmd.command == "Batch") && (cmd.GetParam("Action") == "DisplayLine"))
            {
              string err = cmd.GetParam("Text");
              cmd = ReadCommand();
              while (cmd.command != "Input")
            cmd = ReadCommand();
              return RepRunErr.Errored(err);
            }
            else if((cmd.command == "Batch") && (cmd.GetParam("Action") == "DisplayLine"))
              callStatus(5, cmd.GetParam("Text"));
              }

              Write("\r");
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();

              callStatus(6, "Getting Queue List");
              Write("0\r");
              cmd = ReadCommand();
              Dictionary<int,int> queAvailable = new Dictionary<int,int>();
              while(cmd.command != "Input")
              {
            if((cmd.GetParam("Action") == "DisplayLine") && (cmd.GetParam("Text").Contains("Batch Queues Available:")))
            {
              string line = cmd.GetParam("Text");
              string[] strQueues = line.Substring(line.IndexOf(':')+1).Split(new char[]{','});
              for(int i=0; i<strQueues.Length; i++)
              {
            strQueues[i] = strQueues[i].Trim();
            if(strQueues[i].Contains("-"))
            {
              int pos = strQueues[i].IndexOf('-');
              int start = int.Parse(strQueues[i].Substring(0,pos));
              int end   = int.Parse(strQueues[i].Substring(pos+1));
              for(int c=start; c<=end; c++)
                queAvailable.Add(c,0);
            }
            else
              queAvailable.Add(int.Parse(strQueues[i]),0);
              }
            }
            cmd = ReadCommand();
              }

              callStatus(7, "Getting Queue Counts");
              cmd = new SymCommand("Misc");
              cmd.SetParam("InfoType", "BatchQueues");
              Write(cmd);

              cmd = ReadCommand();
              while(!cmd.HasParam("Done"))
              {
            if((cmd.GetParam("Action") == "QueueEntry") && (cmd.GetParam("Stat") == "Running"))
              queAvailable[int.Parse(cmd.GetParam("Queue"))]++;
            cmd = ReadCommand();
              }

              if(queue == -1) //auto select lowest pending queue, or last available Zero queue
              {
            queue = 0;
            foreach(KeyValuePair<int, int> Q in queAvailable)
              if(Q.Value <= queAvailable[queue])
            queue = Q.Key;
              }

              Write(queue.ToString()+"\r");
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();

              callStatus(8, "Getting Sequence Numbers");
              Write("1\r");
              cmd = ReadCommand();
              while(cmd.command != "Input")
            cmd = ReadCommand();

              cmd = new SymCommand("Misc");
              cmd.SetParam("InfoType", "BatchQueues");
              Write(cmd);

              int newestTime = 0;
              int sequenceNo = -1;
              cmd = ReadCommand();
              while(!cmd.HasParam("Done"))
              {
            if(cmd.GetParam("Action") == "QueueEntry")
            {
              int currTime = 0;
              string timeStr = cmd.GetParam("Time");
              currTime =         int.Parse(timeStr.Substring(timeStr.LastIndexOf(':')+1));
              currTime +=   60 * int.Parse(timeStr.Substring(timeStr.IndexOf(':')+1, 2));
              currTime += 3600 * int.Parse(timeStr.Substring(0, timeStr.IndexOf(':')));
              if(currTime >= newestTime)
              {
            newestTime = currTime;
            sequenceNo = int.Parse(cmd.GetParam("Seq"));
              }
            }
            cmd = ReadCommand();
              }

              callStatus(9, "Running..");
              return RepRunErr.Okay(sequenceNo, newestTime);
        }
Ejemplo n.º 7
0
 //------------------------------------------------------------------------
 public void FileRename(SymFile file, string newName)
 {
     FileRename(file.name, file.type, newName);
 }
Ejemplo n.º 8
0
        //========================================================================
        public void FileRename(string oldName, SymFile.Type type, string newName)
        {
            SymCommand cmd = new SymCommand("File");
              cmd.SetParam("Action" , "Rename");
              cmd.SetParam("Type"   , SymFile.TypeString(type));
              cmd.SetParam("Name"   , oldName);
              cmd.SetParam("NewName", newName);
              Write(cmd);

              cmd = ReadCommand(2000);
              if(cmd.HasParam("Status"))
              {
            if(cmd.GetParam("Status").IndexOf("No such file or directory") != -1)
              throw new FileNotFoundException("File \""+oldName+"\" Not Found");
            else
              throw new Exception("Filename Too Long");
              }
              else if(cmd.HasParam("Done"))
            return;
              else
            throw new Exception("Unknown Renaming Error");
        }
Ejemplo n.º 9
0
 //------------------------------------------------------------------------
 public string FileRead(SymFile file)
 {
     return FileRead(file.name, file.type);
 }
Ejemplo n.º 10
0
        //========================================================================
        public string FileRead(string name, SymFile.Type type)
        {
            StringBuilder content = new StringBuilder();

              SymCommand cmd = new SymCommand("File");
              cmd.SetParam("Action", "Retrieve");
              cmd.SetParam("Type"  , SymFile.TypeString(type));
              cmd.SetParam("Name"  , name);
              Write(cmd);

              while(true)
              {
            cmd = ReadCommand();
            if(cmd.HasParam("Status"))
            {
              if(cmd.GetParam("Status").IndexOf("No such file or directory") != -1)
            throw new FileNotFoundException("File \""+name+"\" Not Found");
              else if(cmd.GetParam("Status").IndexOf("Cannot view a blank report") != -1)
            return "";
              else
            throw new Exception("Filename Too Long");
            }

            string chunk = cmd.GetFileData();
            if((chunk.Length > 0) || (type == SymFile.Type.REPORT))
            {
              content.Append(chunk);
              if(type==SymFile.Type.REPORT)
            content.Append('\n');
            }

            if(cmd.HasParam("Done"))
              break;
              }
              return content.ToString();
        }
Ejemplo n.º 11
0
        //========================================================================
        public List<SymFile> FileList(string pattern, SymFile.Type type)
        {
            List<SymFile> files = new List<SymFile>();

              SymCommand cmd = new SymCommand("File");
              cmd.SetParam("Type"  , SymFile.TypeDescriptor[(int)type]);
              cmd.SetParam("Name"  , pattern);
              cmd.SetParam("Action", "List");
              Write(cmd);

              while(true)
              {
            cmd = ReadCommand(2000);
            if(cmd.HasParam("Status"))
              break;
            if(cmd.HasParam("Name"))
              files.Add(new SymFile(server, sym, cmd.GetParam("Name"), cmd.GetParam("Date"), cmd.GetParam("Time"), int.Parse(cmd.GetParam("Size")), type));
            if(cmd.HasParam("Done"))
              break;
              }
              return files;
        }
Ejemplo n.º 12
0
        //========================================================================
        public RepErr FileInstall(SymFile file)
        {
            if(file.type != SymFile.Type.REPGEN)
            throw new Exception("Cannot Install a "+file.TypeString()+" File");

              Write("mm3\u001B");    ReadCommand();
              Write("8\r");          ReadCommand(); ReadCommand();
              Write(file.name+'\r');

              SymCommand cmd = ReadCommand();
              if(cmd.HasParam("Warning") || cmd.HasParam("Error"))
              {
            ReadCommand();
            throw new Exception("File \""+file.name+"\" Not Found");
              }

              if(cmd.command=="SpecfileData")
              {
            ReadCommand();
            Write("1\r");
            ReadCommand(); ReadCommand();
            return RepErr.None(int.Parse(cmd.GetParam("Size").Replace(",","")));
              }

              int errRow = 0, errCol = 0;
              string errFile = "", errText = "";
              if (cmd.GetParam("Action") == "Init")
              {
            errFile = cmd.GetParam("FileName");
            cmd = ReadCommand();
            while (cmd.GetParam("Action") != "DisplayEdit")
            {
              if (cmd.GetParam("Action") == "FileInfo")
              {
            errRow = int.Parse(cmd.GetParam("Line").Replace(",", ""));
            errCol = int.Parse(cmd.GetParam("Col").Replace(",", ""));
              }
              else if (cmd.GetParam("Action") == "ErrText")
            errText += cmd.GetParam("Line") + " ";
              cmd = ReadCommand();
            }
            ReadCommand();

            return new RepErr(file, errFile, errText, errRow, errCol);
              }

              throw new Exception("Unknown Install Error");
        }
Ejemplo n.º 13
0
 //========================================================================
 public SymFile FileGet(string filename, SymFile.Type type)
 {
     List<SymFile> files = FileList(filename, type);
       if(files.Count < 1)
     throw new FileNotFoundException("File \""+filename+"\" Not Found");
       return files[0];
 }
Ejemplo n.º 14
0
 //------------------------------------------------------------------------
 public bool FileExists(string filename, SymFile.Type type)
 {
     return (FileList(filename, type).Count > 0);
 }
Ejemplo n.º 15
0
 //========================================================================
 public bool FileExists(SymFile file)
 {
     return (FileList(file.name, file.type).Count > 0);
 }
Ejemplo n.º 16
0
 //------------------------------------------------------------------------
 public void FileDelete(SymFile file)
 {
     FileDelete(file.name, file.type);
 }