コード例 #1
0
 private static Dictionary <string, IEnumerable <string> > GetErrorsStatic(FailureInfo failureInfo)
 {
     return(failureInfo switch
     {
         ValidationFailureInfo vfi => GetValidationFailureInfo(vfi),
         _ => EmptyResults.EmptyErrors
     });
コード例 #2
0
ファイル: QueryInfo.cs プロジェクト: iodes/PrestoClient
        public QueryInfo(
            QueryId queryId,
            SessionRepresentation session,
            QueryState state,
            MemoryPoolId memoryPool,
            bool scheduled,
            Uri self,
            IEnumerable <string> fieldNames,
            string query,
            QueryStats queryStats,
            string setCatalog,
            string setSchema,
            IDictionary <string, string> setSessionProperties,
            HashSet <string> resetSessionProperties,
            IDictionary <string, string> addedPreparedStatements,
            HashSet <string> deallocatedPreparedStatemetns,
            TransactionId startedTransactionId,
            bool clearTransactionId,
            string updateType,
            StageInfo outputStage,
            FailureInfo failureInfo,
            ErrorCode errorCode,
            HashSet <Input> inputs,
            Output output,
            bool completeInfo,
            string resourceGroupName
            )
        {
            if (String.IsNullOrEmpty(query))
            {
                throw new ArgumentNullException("query");
            }

            this.QueryId                       = queryId ?? throw new ArgumentNullException("queryId");
            this.Session                       = session ?? throw new ArgumentNullException("session");
            this.State                         = state;
            this.MemoryPool                    = memoryPool ?? throw new ArgumentNullException("memoryPool");
            this.Scheduled                     = scheduled;
            this.Self                          = self ?? throw new ArgumentNullException("self");
            this.FieldNames                    = fieldNames ?? throw new ArgumentNullException("fieldNames");
            this.Query                         = query;
            this.QueryStats                    = queryStats ?? throw new ArgumentNullException("queryStats");
            this.SetCatalog                    = setCatalog;
            this.SetSchema                     = setSchema;
            this.SetSessionProperties          = setSessionProperties ?? throw new ArgumentNullException("setSessionProperties");
            this.ResetSessionProperties        = resetSessionProperties ?? throw new ArgumentNullException("resetSessionProperties");
            this.AddedPreparedStatements       = addedPreparedStatements ?? throw new ArgumentNullException("addedPreparedStatements");
            this.DeallocatedPreparedStatements = deallocatedPreparedStatemetns; // ?? throw new ArgumentNullException("deallocatedPreparedStatements");
            this.StartedTransactionId          = startedTransactionId;
            this.ClearTransactionId            = clearTransactionId;
            this.UpdateType                    = updateType;
            this.OutputStage                   = outputStage;
            this.FailureInfo                   = failureInfo;
            this.ErrorType                     = errorCode == null ? ErrorType.NONE : errorCode.Type;
            this.ErrorCode                     = errorCode;
            this.Inputs                        = inputs ?? throw new ArgumentNullException("inputs");
            this.Output                        = output;
            this.CompleteInfo                  = completeInfo;
            this.ResourceGroupName             = resourceGroupName;
        }
コード例 #3
0
 private void Save(FailureInfo info)
 {
     using (IStatelessSession statelessSession = _sessionFactory.OpenStatelessSession())
      {
     statelessSession.Insert(info);
      }
 }
        public void Stack_trace_information_should_be_combined_from_all_the_exceptions()
        {
            var e = CreateNestedException();
             var info = new FailureInfo(new TransportMessage(), e, true);

             Assert.That(info.StackTraces,Is.StringStarting(e.StackTrace));
             Assert.That(info.StackTraces,Is.StringEnding(e.InnerException.StackTrace));
        }
コード例 #5
0
        public void Stack_trace_information_should_be_combined_from_all_the_exceptions()
        {
            var e    = CreateNestedException();
            var info = new FailureInfo(new TransportMessage(), e, true);

            Assert.That(info.StackTraces, Is.StringStarting(e.StackTrace));
            Assert.That(info.StackTraces, Is.StringEnding(e.InnerException.StackTrace));
        }
コード例 #6
0
ファイル: Result.cs プロジェクト: pdebacker/RailwayResult
        public override string ToString()
        {
            if (IsSuccess)
            {
                return(ReturnValue.ToString());
            }

            return(FailureInfo.ToString());
        }
コード例 #7
0
        public PrestoQueryException(QueryError error, HttpStatusCode code) : base(error.Message, code)
        {
            if (error == null)
            {
                throw new ArgumentNullException("error");
            }

            this.ErrorCode     = error.ErrorCode;
            this.ErrorLocation = error.ErrorLocation;
            this.ErrorName     = error.ErrorName;
            this.ErrorType     = error.ErrorType;
            this.FailureInfo   = error.FailureInfo;
        }
コード例 #8
0
        public async Task <HandlerResult <TTo> > Handle(ChangeStateOrderContext <TCommand, TFrom> input)
        {
            using var tr = _unitOfWork.BeginTransaction();
            try
            {
                await Task.Delay(300);

                var result = ChangeStateOrder(input);

                _unitOfWork.Commit();
                await tr.CommitAsync();

                return(result);
            }
            catch (Exception e)
            {
                await tr.RollbackAsync();

                return(FailureInfo.Invalid(e.Message));
            }
        }
コード例 #9
0
        public void Topmost_messages_should_belong_to_the_outermost_exception()
        {
            var info = new FailureInfo(new TransportMessage(), CreateNestedException(), true);

            Assert.AreEqual(info.TopmostExceptionMessage, "Outer");
        }
コード例 #10
0
        private List <FailureInfo> GetListData(DataTable dt, string prjGUID, string hostWhere, string alarmWhere, DateTime startTime, DateTime endTime, string LightName)
        {
            List <FailureInfo> list = new List <FailureInfo>();

            if (dt != null)
            {
                string strWhere = "";
                //int iWhere;
                FailureInfo ai, all;
                all      = new FailureInfo();
                all.sKey = "其他";
                long allCount   = 0; //总的个数
                long aiAllCount = 0; //
                if (!string.IsNullOrEmpty(hostWhere))
                {
                    strWhere += "(";
                    string[] s = hostWhere.Split(new char[] { ',' });
                    for (int i = 0; i < s.Length; i++)
                    {
                        if (s[i] != "")
                        {
                            strWhere += "( h.sGUID='" + s[i] + "') or";
                        }
                    }
                    if (strWhere != "")
                    {
                        strWhere = strWhere.Remove(strWhere.LastIndexOf("or"), 2);
                    }
                    strWhere += ")";
                    allCount  = GetFalutCount(prjGUID, strWhere, startTime, endTime, LightName);
                }
                if (!string.IsNullOrEmpty(alarmWhere))
                {
                    if (!string.IsNullOrEmpty(hostWhere))
                    {
                        strWhere += " and ";
                    }
                }
                foreach (DataRow dr in dt.Rows)
                {
                    ai      = new FailureInfo();
                    ai.sKey = ToString(dr["sDesc"]);

                    long aiCount = GetFalutCount(prjGUID, strWhere + "ls.iFault=" + Convert.ToInt32(ToString(dr["sKey"]).Split('_')[2]), startTime, endTime, LightName);
                    aiAllCount += aiCount;
                    if (aiCount != 0)
                    {
                        ai.sValue = ToString(aiCount * 10000 / allCount);
                    }
                    else
                    {
                        ai.sValue = ToString(aiCount);
                    }
                    list.Add(ai);
                }
                if (allCount != 0)
                {
                    all.sValue = ToString((allCount - aiAllCount) * 10000 / allCount);
                    list.Add(all);
                }
            }
            return(list);
        }
        public void Topmost_messages_should_belong_to_the_outermost_exception()
        {
            var info = new FailureInfo(new TransportMessage(), CreateNestedException(), true);

             Assert.AreEqual(info.TopmostExceptionMessage,"Outer");
        }
コード例 #12
0
 /// <summary>
 /// Creates a new presto node information object
 /// with LastFailureInfo set to null and an empty
 /// RecentFailuresByType property. The rest of the
 /// properties are default values.
 /// </summary>
 public HeartbeatFailureDetectorStats()
 {
     LastFailureInfo      = null;
     RecentFailuresByType = new Dictionary <string, double>();
 }
コード例 #13
0
 public HandlerResult(FailureInfo failure) : base(failure)
 {
 }
コード例 #14
0
        public ActionResult Index(string startDate, string endDate, string hostWhere, string alarmWhere, string LightName)
        {
            string   strLightName;
            DateTime dtStart;
            DateTime dtEnd;

            VStartAndEndTime(startDate, endDate, out dtStart, out dtEnd);
            if (!string.IsNullOrWhiteSpace(LightName))
            {
                strLightName = " li.sName like '%" + LightName + "%' and ";
            }
            else
            {
                strLightName = " 1=1 and ";
            }
            LumluxSSYDB.BLL.tPrjectSet light_bll = new LumluxSSYDB.BLL.tPrjectSet();
            DataTable          dt   = null;
            List <FailureInfo> list = new List <FailureInfo>();

            if (!string.IsNullOrWhiteSpace(hostWhere) && !string.IsNullOrWhiteSpace(alarmWhere))
            {
                //int iWherebyhost;
                string strWherebyalarm = "";

                strWherebyalarm += "(";

                string[] s = alarmWhere.Split(new char[] { ',' });

                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] != "")
                    {
                        strWherebyalarm += "'" + s[i] + "',";
                    }
                }
                if (strWherebyalarm != "")
                {
                    strWherebyalarm = strWherebyalarm.Remove(strWherebyalarm.LastIndexOf(","), 1);
                }
                strWherebyalarm += ")";
                dt = light_bll.GetTableByWhere("sPrjectGUID='" + PrjGUID + "' and sKey in " + strWherebyalarm);

                if (dt != null)
                {
                    list = GetListData(dt, PrjGUID, hostWhere, alarmWhere, dtStart, dtEnd, strLightName);
                }
                LumluxSSYDB.BLL.tLightInfoes blllight = new LumluxSSYDB.BLL.tLightInfoes();
                if (list.Count > 0)
                {
                    int x = 0;
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].sValue == "0")
                        {
                            x = x + 1;
                        }
                    }
                    if (x == list.Count)
                    {
                        FailureInfo fInfos = new FailureInfo();
                        fInfos.sKey   = "当前无数据";
                        fInfos.sValue = "100";
                        list.Add(fInfos);
                        return(this.Json(list));
                    }
                    else
                    {
                        return(this.Json(list));
                    }
                }
            }
            FailureInfo fInfo = new FailureInfo();

            fInfo.sKey   = "请选择条件统计";
            fInfo.sValue = "100";
            list.Add(fInfo);
            return(this.Json(list));
        }
コード例 #15
0
 /// <summary>
 /// 将异常信息作为错误信息写入错误日志
 /// </summary>
 /// <param name="e">异常对象</param>
 /// <param name="info">错误说明信息</param>
 /// <param name="usingExcepMsg">错误说明信息中是否添加异常信息(string Exception.Message)</param>
 public static void WriteExceptionInfo(Exception e, string info, bool usingExcepMsg)
 {
     WriteFailureInfo(FailureInfo.GetFailureInfoArray(e, info, usingExcepMsg));
 }
コード例 #16
0
 protected virtual Dictionary <string, IEnumerable <string> > GetErrors(FailureInfo failureInfo)
 {
     return(GetErrorsStatic(failureInfo));
 }
コード例 #17
0
 /// <summary>
 /// 将异常信息作为错误信息写入错误日志
 /// </summary>
 /// <param name="e">异常对象</param>
 /// <param name="info">错误说明信息</param>
 /// <param name="extraInfos">额外包含的信息字符串数组</param>
 public static void WriteExceptionInfo(Exception e, string info, string[] extraInfos)
 {
     WriteFailureInfo(FailureInfo.GetFailureInfoArray(e, info, extraInfos));
 }
コード例 #18
0
 /// <summary>
 /// 将异常的信息作为错误信息写入错误日志
 /// </summary>
 /// <param name="e">异常对象</param>
 public static void WriteExceptionInfo(Exception e)
 {
     WriteFailureInfo(FailureInfo.GetFailureInfoArray(e));
 }
コード例 #19
0
 /// <summary>
 /// 将异常信息作为错误信息写入错误日志
 /// </summary>
 /// <param name="e">异常对象</param>
 /// <param name="info">异常说明信息</param>
 public static void WriteExceptionInfo(Exception e, string info)
 {
     WriteFailureInfo(FailureInfo.GetFailureInfoArray(e, info));
 }