Esempio n. 1
0
        public SpecfileResult FileCheck(File file)
        {
            if (file.Type != FileType.RepGen)
            {
                throw new Exception("Cannot check a " + file.FileTypeString() + " file");
            }

            _socket.Write("mm3\u001B");
            _socket.ReadCommand();
            _socket.Write("7\r");
            _socket.ReadCommand();
            _socket.ReadCommand();
            _socket.Write(file.Name + '\r');

            ISymCommand cmd = _socket.ReadCommand();

            if (cmd.HasParameter("Warning") || cmd.HasParameter("Error"))
            {
                _socket.ReadCommand();
                throw new FileNotFoundException();
            }
            if (cmd.Get("Action") == "NoError")
            {
                _socket.ReadCommand();
                return(SpecfileResult.Success());
            }

            int    errRow = 0, errCol = 0;
            string errFile = "", errText = "";

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

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

            throw new Exception("An unknown error occurred.");
        }
Esempio n. 2
0
        public static SpecfileResult Success(int size)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size", "Specfile install size cannot be less than 0.");
            }

            var result = new SpecfileResult(null, "", "", 0, 0);

            result.InstallSize = size;

            if (size == 0)
            {
                result.InvalidInstall = true;
            }

            return(result);
        }
Esempio n. 3
0
        public SpecfileResult FileInstall(File file)
        {
            int         errRow = 0, errCol = 0;
            string      errFile = "", errText = "";
            ISymCommand cmd;

            if (file.Type != FileType.RepGen)
            {
                throw new Exception("Cannot Install a " + file.FileTypeString() + " File");
            }

            _socket.Write("mm3\u001B");
            cmd = _socket.ReadCommand();
            LogCommand(cmd);
            _socket.Write("8\r");
            cmd = _socket.ReadCommand();
            LogCommand(cmd);
            _socket.Write(file.Name + '\r');

            cmd = _socket.ReadCommand();
            LogCommand(cmd);

            DateTime startTime = DateTime.Now;

            while (!cmd.HasParameter("Action"))
            {
                if ((DateTime.Now - startTime).TotalSeconds > 15)
                {
                    throw new TimeoutException("Specfile Install Timeout");
                }

                if (cmd.Get("Type") == "Warning" || cmd.HasParameter("Warning") ||
                    cmd.Get("Type") == "Error" || cmd.HasParameter("Error"))
                {
                    throw new FileNotFoundException();
                }

                if (cmd.Command == "SpecfileData")
                {
                    _socket.Write("1\r");
                    while (!cmd.HasParameter("Size"))
                    {
                        cmd = _socket.ReadCommand();
                        LogCommand(cmd);
                    }
                    return(SpecfileResult.Success(int.Parse(cmd.Get("Size").Replace(",", ""))));
                }

                cmd = _socket.ReadCommand();
                LogCommand(cmd);
            }

            if (cmd.Get("Action") == "Init")
            {
                errFile = cmd.Get("FileName");
            }

            startTime = DateTime.Now;
            cmd       = _socket.ReadCommand();
            while (cmd.Get("Action") != "DisplayEdit" && cmd.Command != "SpecfileData")
            {
                var elapsedTime = DateTime.Now - startTime;
                if (elapsedTime.TotalSeconds > 5)
                {
                    throw new TimeoutException("Specfile Install Timeout");
                }
                if (cmd.Get("Action") == "FileInfo")
                {
                    errRow = int.Parse(cmd.Get("Line").Replace(",", ""));
                    errCol = int.Parse(cmd.Get("Col").Replace(",", ""));
                }
                else if (cmd.Get("Action") == "ErrText")
                {
                    errText += cmd.Get("Line") + " ";
                }
                cmd = _socket.ReadCommand();
                LogCommand(cmd);
            }
            return(new SpecfileResult(file, errFile, errText, errRow, errCol));
        }
Esempio n. 4
0
        public static SpecfileResult Success()
        {
            var result = new SpecfileResult(null, "", "", 0, 0);

            return(result);
        }
Esempio n. 5
0
        public static SpecfileResult Success(int size)
        {
            if (size < 0)
                throw new ArgumentOutOfRangeException("size", "Specfile install size cannot be less than 0.");

            var result = new SpecfileResult(null, "", "", 0, 0);
            result.InstallSize = size;

            if (size == 0)
                result.InvalidInstall = true;

            return result;
        }
Esempio n. 6
0
 public static SpecfileResult Success()
 {
     var result = new SpecfileResult(null, "", "", 0, 0);
     return result;
 }