Exemple #1
0
        private string ModulePath(ErrorModule module)
        {
            string str;

            switch (module)
            {
            case ErrorModule.Error_All:
            {
                str = errorlogpath + "\\AllError.txt";
            }
            break;

            case ErrorModule.Error_AP:
            {
                str = errorlogpath + "\\ApError.txt";
            }
            break;

            case ErrorModule.Error_HANDLER:
            {
                str = errorlogpath + "\\HandleError.txt";
            }
            break;

            default:
            {
                str = Application.StartupPath + "\\ErrorLog.txt";
            }
            break;
            }

            return(str);
        }
Exemple #2
0
        public ArrayValue getTrace(Env env)
        {
            if (_trace == null)
            {
                _trace = ErrorModule.debug_backtrace_exception(env, this, 0);
            }

            return(_trace);
        }
Exemple #3
0
        public ErrorCode(ErrorType type, ErrorModule module, ErrorOperation operation, ErrorScope scope)
        {
            Family    = (ErrorFamily)Enum.ToObject(typeof(ErrorFamily), (int)type / 1000);
            Type      = ErrorType.Unknown;
            Module    = module;
            Operation = operation;
            Scope     = scope;
            Entity    = ErrorEntity.None;
            long shift = 1;

            Code = (long)scope + (long)operation * (shift *= 100000) + (long)module * (shift *= 1000) +
                   (long)type * (shift * 100);
            Name = $"{type}{module}{operation}{scope}";
        }
Exemple #4
0
        public ErrorCode(ErrorFamily family, ErrorModule module, ErrorOperation operation, ErrorScope scope)
        {
            Family    = family;
            Type      = ErrorType.Unknown;
            Module    = module;
            Operation = operation;
            Scope     = scope;
            Entity    = ErrorEntity.None;
            long shift = 1;

            Code = (long)scope + (long)operation * (shift *= 100000) + (long)module * (shift *= 1000) +
                   (long)family * (shift * 100000);
            Name = $"{family}{module}{operation}{scope}";
        }
Exemple #5
0
        public ErrorCode(ErrorFamily family, ErrorModule module, ErrorOperation operation, ErrorEntity entity)
        {
            Family    = family;
            Type      = ErrorType.Unknown;
            Module    = module;
            Operation = operation;
            Scope     = (ErrorScope)Enum.ToObject(typeof(ErrorScope), (int)entity / 1000);
            Entity    = entity;
            long shift = 1;

            Code = (long)entity + (long)operation * (shift *= 100000) + (long)module * (shift *= 1000) +
                   (long)family * (shift * 100);
            Name = $"{family}{module}{operation}{entity}";
        }
Exemple #6
0
        public ErrorCode(ErrorType type, ErrorModule module, ErrorOperation operation, ErrorEntity entity)
        {
            Family    = (ErrorFamily)Enum.ToObject(typeof(ErrorFamily), (int)type / 1000);
            Type      = type;
            Module    = module;
            Operation = operation;
            Scope     = (ErrorScope)Enum.ToObject(typeof(ErrorScope), (int)entity / 1000);
            Entity    = entity;
            long shift = 1;

            Code = (long)entity + (long)operation * (shift *= 100000) + (long)module * (shift *= 1000) +
                   (long)type * (shift * 100);
            Name = $"{type}{module}{operation}{entity}";
        }
Exemple #7
0
        public void SetErrorPage_should_move_stream_to_beginning_so_that_The_contents_can_Be_Served()
        {
            var context = Substitute.For <IHttpContext>();

            context.Response.Returns(new HttpResponse(HttpStatusCode.OK, "OK", "HTTP/1.1"));
            context.LastException = new InvalidOperationException();
            var errModule = new ErrorModule();

            errModule.BuildCustomErrorPage(x => "Error!");

            errModule.EndRequest(context);

            context.Response.Body.Position.Should().Be(0);
            context.Response.Body.Length.Should().Be(6);
        }
Exemple #8
0
 /// <summary>
 /// 写入日志
 /// </summary>
 /// <param name="msg"></param>
 public void WriteLog(ErrorModule module, string msg)
 {
     lock (lockHelp)
     {
         try
         {
             string file = ModulePath(module);
             writer = new StreamWriter(file, true);
             writer.WriteLine("-----------------------{0}-----------------------", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
             writer.WriteLine(msg);
             writer.Flush();
         }
         finally
         {
             if (writer != null)
             {
                 writer.Close();
                 writer.Dispose();
                 writer = null;
             }
         }
     }
 }
Exemple #9
0
 public static uint MakeError(ErrorModule Module, int Code)
 {
     return((uint)Module | ((uint)Code << 9));
 }
Exemple #10
0
        private void CreateErrorWorkItem(SPWeb web, HttpStatusCode code)
        {
            try
            {
                Guid siteId = web.Site.ID;
                Guid webId  = web.ID;

                bool disabled = false;
                WebSiteControllerPrincipalType principalType = WebSiteControllerPrincipalType.None;
                bool   appliesToSSL = true;
                int    sequence     = 1;
                String pricipal     = string.Empty;

                StringBuilder builder = new StringBuilder();
                builder.Append("Error/" + code.ToString() + ".aspx;");
                builder.Append(disabled.ToString() + ";");
                builder.Append(appliesToSSL.ToString() + ";");
                builder.Append(sequence.ToString() + ";");
                builder.Append(principalType.ToString() + ";");
                builder.Append(pricipal + ";");
                builder.Append("#");

                builder.Append(String.Format("{0}:{1};", "ErrorPage", "Error/" + code.ToString() + ".aspx;"));
                builder.Append(String.Format("{0}:{1};", "ErrorCode", ((int)code).ToString()));


                string full = builder.ToString();

                ErrorModule mod = new ErrorModule();
                IWebSiteControllerModule imod = null;  //WebSiteControllerConfig.GetModule(web.Site.WebApplication, mod.RuleType);

                while (imod == null)
                {
                    System.Threading.Thread.Sleep(1000);
                    try
                    {
                        imod = WebSiteControllerConfig.GetModule(web.Site.WebApplication, mod.RuleType);
                    }
                    catch (Exception ex)
                    {
                        SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
                        //ex.ToString();
                    }
                }

                //Guid itemGuid = new Guid("17A3219B-049F-4056-9566-37590122BE8E");
                int item = -1;

                SPSecurity.RunWithElevatedPrivileges(() =>
                {
                    using (SPSite site = new SPSite(siteId))
                    {
                        site.AddWorkItem(
                            Guid.NewGuid(),
                            DateTime.Now.ToUniversalTime(),
                            WebSiteControllerRuleWorkItem.WorkItemTypeId,
                            webId,
                            siteId,
                            item,
                            true,
                            imod.Id,
                            Guid.Empty,
                            site.SystemAccount.ID,
                            null,
                            builder.ToString(),
                            Guid.Empty
                            );
                    }
                });

                try
                {
                    WebSiteControllerRuleWorkItem WebSiteControllerModuleJob = new WebSiteControllerRuleWorkItem(WebSiteControllerRuleWorkItem.WorkItemJobDisplayName + code.ToString(), web.Site.WebApplication);
                    SPOneTimeSchedule             oneTimeSchedule            = new SPOneTimeSchedule(DateTime.Now);

                    WebSiteControllerModuleJob.Schedule = oneTimeSchedule;
                    WebSiteControllerModuleJob.Update();
                }
                catch (Exception ex)
                {
                    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
                    //ex.ToString();
                }
            }
            catch (Exception ex)
            {
                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
            }
        }
 public DotChatNotFoundUserException(ErrorModule module, ErrorOperation operation, Guid?chatId, Guid?userId, Exception innerException = null)
     : base(new ErrorInfo(new ErrorCode(ErrorType.NotFound, module, operation, ErrorEntity.User), $"User {chatId} not found", chatId, userId, null), innerException)
 {
 }
Exemple #12
0
 public static uint MakeError(ErrorModule module, int code)
 {
     return((uint)module | ((uint)code << 9));
 }
Exemple #13
0
 public static long MakeError(ErrorModule Module, int Code)
 {
     return((int)Module | (Code << 9));
 }