Exemple #1
0
        public void FileFolderInitializer(List <FolderModels> folders, List <FileModels> files)
        {
            string getParentPath = folders.Select(root => root.ParentPath).FirstOrDefault();

            try {
                GetCurrentPath = folders.Select(root => root.CurrentPath).FirstOrDefault().ToString();
                if (getParentPath == GetCurrentPath)
                {
                    GetParentPath = "none";
                }
                else
                {
                    GetParentPath = getParentPath;
                }
            }
            catch (NullReferenceException ex)
            {
                ExceptionProcessing.ErrorWriting(ex.Message);
            }

            _getFolders = folders;
            _getFiles   = files.Where(path => path.PathName == GetCurrentPath).ToList();

            GetCount = FileCountModels.GetCount();
        }
 public void Run(Instruction instruction)
 {
     if (operations.TryGetValue(ToOpCode(instruction), out var operation))
     {
         operation(instruction);
     }
     else
     {
         ExceptionProcessing.ReservedInstruction(cpu, instruction);
     }
 }
Exemple #3
0
            public FloatingPointUnit(VR4300 cpu)
            {
                this.cpu = cpu;
                ImplementationRevision = new ImplementationRevisionRegister(this);
                ControlStatus          = new ControlStatusRegister(this);
                operations             = new Dictionary <OpCode, Action <Instruction> >
                {
                    [OpCode.CF] = i =>
                    {
                        switch (i.RD)
                        {
                        case 0:
                            cpu.GPR[i.RT] = (ulong)(int)cpu.FCR0;
                            break;

                        case 31:
                            cpu.GPR[i.RT] = (ulong)(int)cpu.FCR31;
                            break;

                        default:
                            ExceptionProcessing.ReservedInstruction(cpu, i);
                            return;
                        }
                    },
                    [OpCode.CT] = i =>
                    {
                        switch (i.RD)
                        {
                        case 0:
                            return;     // Read-only register.

                        case 31:
                            cpu.FCR31 = (uint)cpu.GPR[i.RT];

                            if ((ControlStatus.Cause & (ControlStatus.Enables | ControlStatusRegister.ExceptionFlags.E)) != 0)
                            {
                                ExceptionProcessing.FloatingPoint(cpu);
                                return;
                            }
                            break;

                        default:
                            ExceptionProcessing.ReservedInstruction(cpu, i);
                            return;
                        }
                    }
                };
            }
Exemple #4
0
        /// <summary>
        /// Exception handling & Create the Error Logs to the Errorlog Table
        /// </summary>
        /// <param name="ex">Exception</param>
        /// <param name="UserId">UserId</param>
        /// using the multiple catch and show the custom Message related to the Exception
        /// <returns></returns>
        public ExceptionProcessing ErrorLog(Exception ex, string UserId)
        {
            ExceptionProcessing exceptionp = new ExceptionProcessing();

            Models.ErrorLog Errthrow = new Models.ErrorLog();
            if (ex is MissingMemberException || ex is NotSupportedException)
            {
                Errthrow.LogPriority = "Heigh";
                exceptionp.Code      = HttpStatusCode.InternalServerError;
                exceptionp.Message   = "{\"Error_Code\": 101,\"Message\": \" System Not Respond.\"}";
            }
            else if (ex is FormatException || ex is OverflowException || ex is ArgumentNullException)
            {
                Errthrow.LogPriority = "Medium";
                exceptionp.Code      = HttpStatusCode.BadRequest;
                exceptionp.Message   = "{\"Error_Code\": 102,\"Message\": \" Invalid Input/output Format.\"}";
            }
            else if (ex is BadImageFormatException || ex is XmlException || ex is JsonException || ex is InvalidCastException)
            {
                Errthrow.LogPriority = "Medium";
                exceptionp.Code      = HttpStatusCode.NotAcceptable;
                exceptionp.Message   = "{\"Error_Code\": 103,\"Message\": \" Unable to Parse. \"}";
            }
            else if (ex is IOException)
            {
                Errthrow.LogPriority = "Heigh";
                exceptionp.Code      = HttpStatusCode.Forbidden;
                exceptionp.Message   = "{\"Error_Code\": 104,\"Message\": \" Unable to Perform IO Operation.\"}";
            }
            else if (ex is SqlException)
            {
                Errthrow.LogPriority = "Heigh";
                exceptionp.Code      = HttpStatusCode.InternalServerError;
                exceptionp.Message   = "{\"Error_Code\": 105,\"Message\": \"Unable to Perform DatatBase Operation.\"}";
            }
            else if (ex is NullReferenceException)
            {
                Errthrow.LogPriority = "Heigh";
                exceptionp.Code      = HttpStatusCode.InternalServerError;
                exceptionp.Message   = "{\"Error_Code\": 107,\"Message\": \"Nullable Value Exception.\"}";
            }
            else if (ex is UnauthorizedAccessException)
            {
                Errthrow.LogPriority = "Heigh";
                exceptionp.Code      = HttpStatusCode.Forbidden;
                exceptionp.Message   = "The User is unauthorized.";
            }
            else
            {
                Errthrow.LogPriority = "Medium";
                exceptionp.Code      = HttpStatusCode.InternalServerError;
                exceptionp.Message   = "{\"Error_Code\": 108,\"Message\": \"Unhandled Exception.\"}";
            }
            Errthrow.ErrorCode          = ((int)exceptionp.Code).ToString();
            Errthrow.LogUserId          = UserId;
            Errthrow.LogType            = "Error";
            Errthrow.StackTrace         = ex.StackTrace;
            Errthrow.InnerMessage       = exceptionp.Message;
            Errthrow.ErrorMessage       = ex.Message;
            Errthrow.ErrorSource        = ex.Source;
            Errthrow.LogCreatedDateTime = DateTime.Now;
            Db.ErrorLogs.Add(Errthrow);
            Db.SaveChanges();
            return(exceptionp);
        }