Example #1
0
    // 更新错误统计
    private void RefreshErrorStatistics()
    {
        if (!Directory.Exists(AssetsCheckConfig.OutputDir))
        {
            Directory.CreateDirectory(AssetsCheckConfig.OutputDir);
        }

        if (!Directory.Exists(AssetsCheckConfig.ExcludeDir))
        {
            Directory.CreateDirectory(AssetsCheckConfig.ExcludeDir);
        }

        statisticsErrorDic.Clear();

        string[] lines;
        ReadErrorStatisticsLines(out lines);
        for (int i = 0; i < lines.Length; i++)
        {
            string[] ary = lines[i].Split(' ');
            if (ary.Length >= 3 && !string.IsNullOrEmpty(ary[0]) && Convert.ToInt32(ary[1]) > 0)
            {
                ErrorItem error_item = new ErrorItem();
                error_item.count = Convert.ToInt32(ary[1]);
                error_item.desc  = ary[2];
                statisticsErrorDic.Add(ary[0], error_item);
            }
        }
    }
        public void Test_Default()
        {
            List<string> extensions;
            ErrorItem errorCS;
            ErrorItem errorCS_Upper;
            ErrorItem errorTxt;

            errorCS = new ErrorItem("C:\\dir\\file.cs", 1);
            errorCS_Upper = new ErrorItem("C:\\dir\\file.CS", 1);
            errorTxt = new ErrorItem("C:\\dir\\file.txt", 1);

            Assert.That(_empty.Count, Is.EqualTo(0));
            Assert.That(_empty.HasExtension("cs"), Is.False);
            Assert.That(_empty.HasLanguage("C#"), Is.False);
            Assert.That(_empty, Is.EquivalentTo(new List<string>()));                
                
            Assert.That(_filled.Count, Is.EqualTo(2));

            Assert.That(_filled["C#"], Is.EqualTo(_csFormatter));
            Assert.That(_filled["Plain text"], Is.EqualTo(_defaultFormatter));

            Assert.That(_filled.HasExtension("cs"), Is.True);
            Assert.That(_filled.HasLanguage("C#"), Is.True);

            extensions = new List<string>();
            extensions.Add("cs");
            extensions.Add("txt");
            Assert.That(_filled.Extensions, Is.EquivalentTo(extensions));

            return;
        }
Example #3
0
        protected override bool CheckHeader(List <String> headerList, List <ErrorItem> ErrorList, string[] keyValue)
        {
            String errorReason = "【分公司客户经理模板】不正确,请使用正确Excel模板!";

            ErrorItem item = new ErrorItem();

            if (headerList != null && headerList.Count > 0)
            {
                string[] rightHeaderList = Constant.CustomerManagerTempleteListColumn;

                if (rightHeaderList.Length != headerList.Count)
                {
                    item.ErrorReson = errorReason;
                    ErrorList.Add(item);
                    return(false);
                }
                for (int i = 0; i < headerList.Count; i++)
                {
                    if (!headerList[i].Equals(rightHeaderList[i]))
                    {
                        item.ErrorReson = errorReason;
                        ErrorList.Add(item);
                        return(false);
                    }
                }
            }
            else
            {
                item.ErrorReson = errorReason;
                ErrorList.Add(item);
                return(false);
            }

            return(true);
        }
 private Folder ToErrorFolder(ErrorItem onedriveFolder)
 {
     if (onedriveFolder == null)
     {
         return(null);
     }
     return(new Folder
     {
         ID = MakeId(onedriveFolder.ErrorId),
         ParentFolderID = null,
         CreateBy = OneDriveProviderInfo.Owner,
         CreateOn = TenantUtil.DateTimeNow(),
         FolderType = FolderType.DEFAULT,
         ModifiedBy = OneDriveProviderInfo.Owner,
         ModifiedOn = TenantUtil.DateTimeNow(),
         ProviderId = OneDriveProviderInfo.ID,
         ProviderKey = OneDriveProviderInfo.ProviderKey,
         RootFolderCreator = OneDriveProviderInfo.Owner,
         RootFolderId = MakeId(),
         RootFolderType = OneDriveProviderInfo.RootFolderType,
         Shareable = false,
         Title = MakeItemTitle(onedriveFolder),
         TotalFiles = 0,
         TotalSubFolders = 0,
         Error = onedriveFolder.Error
     });
 }
Example #5
0
        /// <summary>
        /// Set Default Value into selected cell, will be used when select Item Code.
        /// </summary>
        private void SetItemCDandItemDesc()
        {
            eItemType[]    itemTypeEnum = { eItemType.All };
            ItemFindDialog dialog       = new ItemFindDialog(eSqlOperator.Equal, itemTypeEnum);

            dialog.ShowDialog(this);
            if (dialog.IsSelected)
            {
                shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value = dialog.SelectedItem.ITEM_CD.StrongValue;

                // set default into ItemCode, ItemDesc, Unit, InventoryU/M and Rate of unit.
                ErrorItem errItem = ValidateDupplicateItem();
                if (errItem != null)
                {
                    shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value   = string.Empty;
                    shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = string.Empty;
                    ValidateException.ThrowErrorItem(errItem);
                }
                ValidateException.ThrowErrorItem(errItem);

                shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = dialog.SelectedItem.ITEM_DESC.StrongValue;
                //shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.UNIT].Value = dialog.SelectedItem.ORDER_UM_CLS.StrongValue;
                //shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.INV_UM].Value = dialog.SelectedItem.INV_UM_CLS.StrongValue;
                //shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.RATE].Value = dialog.SelectedItem.INV_UM_RATE.StrongValue / dialog.SelectedItem.ORDER_UM_RATE.StrongValue;
            }
        }
Example #6
0
        public void Test_Default()
        {
            List <string> extensions;
            ErrorItem     errorCS;
            ErrorItem     errorCS_Upper;
            ErrorItem     errorTxt;

            errorCS       = new ErrorItem("C:\\dir\\file.cs", 1);
            errorCS_Upper = new ErrorItem("C:\\dir\\file.CS", 1);
            errorTxt      = new ErrorItem("C:\\dir\\file.txt", 1);

            Assert.That(_empty.Count, Is.EqualTo(0));
            Assert.That(_empty.HasExtension("cs"), Is.False);
            Assert.That(_empty.HasLanguage("C#"), Is.False);
            Assert.That(_empty, Is.EquivalentTo(new List <string>()));

            Assert.That(_filled.Count, Is.EqualTo(2));

            Assert.That(_filled["C#"], Is.EqualTo(_csFormatter));
            Assert.That(_filled["Plain text"], Is.EqualTo(_defaultFormatter));

            Assert.That(_filled.HasExtension("cs"), Is.True);
            Assert.That(_filled.HasLanguage("C#"), Is.True);

            extensions = new List <string>();
            extensions.Add("cs");
            extensions.Add("txt");
            Assert.That(_filled.Extensions, Is.EquivalentTo(extensions));

            return;
        }
Example #7
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Error" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="errorItem">The error item.</param>
        public Error(IConfiguration configuration, ErrorItem errorItem)
        {
            var errorCode = errorItem + ":" + "ErrorCode";

            ErrorCode        = configuration[errorCode];
            ErrorDescription = configuration[errorItem + ":" + "ErrorDescription"];
        }
        private void DrawItem(ErrorItem item, int index, bool selected, bool last, bool hover, Graphics g, Rectangle viewport)
        {
            Rectangle src;
            Font      font;

            int x = -viewport.X;
            int y = _itemHeight * index - viewport.Y;

            src  = (index % 2 == 0) ? _rectItemWhite : _rectItemGray;
            font = (hover == true) ? _fontUnderlined : _font;

            g.DrawImage(Resources.ImageErrorList,
                        new Rectangle(0, y, viewport.Width, _itemHeight), src,
                        GraphicsUnit.Pixel);

            if (selected)
            {
                g.DrawImage(Resources.ImageErrorList,
                            new Rectangle(0, y + 1, viewport.Width, _itemHeight),
                            _rectSelectionMiddle, GraphicsUnit.Pixel);
            }

            if (item.HasSourceAttachment)
            {
                g.DrawImage(Resources.ImageErrorList, new Rectangle(x + 1, y + 2 + font.Height, 14, 15),
                            _rectIconCSharp, GraphicsUnit.Pixel);
                g.DrawImage(Resources.ImageErrorList,
                            new Rectangle(TEXT_MARGIN_X - 3 + x, y + 5 + 2 * font.Height, 9, 5),
                            _rectIconArrow, GraphicsUnit.Pixel);

                g.DrawString(String.Format("Line {0}", item.LineNumber),
                             font, _brushGray, _offsetLine, y + 2);
                g.DrawString(item.ClassName, font, _brushBlue, x + TEXT_MARGIN_X, y + 2 + font.Height);
                g.DrawString(item.BaseMethodName + "()", font, _brushBlue,
                             x + TEXT_MARGIN_X + 5, y + 2 + 2 * font.Height);
                g.DrawString(item.FileName, font, _brushGray,
                             x + TEXT_MARGIN_X, y + 2 + 3 * _font.Height);
            }
            else
            {
                g.DrawImage(Resources.ImageErrorList, new Rectangle(x + 1, y + 2 + font.Height, 16, 15),
                            _rectIconDll, GraphicsUnit.Pixel);

                g.DrawString("N/A", font, _brushGray, _offsetLine, y + 2);
                g.DrawString(item.ClassName, font, _brushGray,
                             x + TEXT_MARGIN_X, y + 2 + font.Height);
                g.DrawString(item.BaseMethodName + "()", font, _brushGray,
                             x + TEXT_MARGIN_X, y + 2 + 2 * font.Height);
            }

            if (!last)
            {
                return;
            }

            PaintTile(Resources.ImageErrorList, g, _rectListShadow,
                      new Rectangle(0, y + _itemHeight, viewport.Width, 9));

            return;
        }
        public void Test_MethodName()
        {
            ErrorItem item;

            // test to pass

            item = new ErrorItem("path", "namespace1.class.fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo("class"));

            item = new ErrorItem("path", ".class.fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo("class"));

            item = new ErrorItem("path", "0123456789012.a()", 1);
            Assert.That(item.MethodName, Is.EqualTo("a()"));
            Assert.That(item.BaseMethodName, Is.EqualTo("a"));
            Assert.That(item.ClassName, Is.EqualTo("0123456789012"));                

            // test to fail

            item = new ErrorItem("path", "fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo(""));

            item = new ErrorItem("path", "", 1);
            Assert.That(item.MethodName, Is.EqualTo(""));
            Assert.That(item.BaseMethodName, Is.EqualTo(""));
            Assert.That(item.ClassName, Is.EqualTo(""));

            return;
        }
Example #10
0
        protected override bool CheckHeader(List <String> headerList, List <ErrorItem> ErrorList, string[] keyValue)
        {
            String    errorReason = "【全年任务模板】不正确,请下载最新Excel模板、并按正确顺序上传!";
            string    taskType    = keyValue[1];
            ErrorItem item        = new ErrorItem();

            if (headerList != null && headerList.Count > 0)
            {
                string[] rightHeaderList = taskType.Equals("0") ? Constant.YearlyTaskTempleteCompanyListColumn : Constant.YearlyTaskTempletePersonListColumn;

                if (rightHeaderList.Length != headerList.Count)
                {
                    item.ErrorReson = errorReason;
                    ErrorList.Add(item);
                    return(false);
                }
                for (int i = 0; i < headerList.Count; i++)
                {
                    if (!headerList[i].Equals(rightHeaderList[i]))
                    {
                        item.ErrorReson = errorReason;
                        ErrorList.Add(item);
                        return(false);
                    }
                }
            }
            else
            {
                item.ErrorReson = errorReason;
                ErrorList.Add(item);
                return(false);
            }

            return(true);
        }
Example #11
0
 protected override bool CheckDataRow(DataRow dr, ErrorItem item, string[] keyValue)
 {
     for (int i = 0; i < dr.ItemArray.Length; i++)
     {
         if (i == 0)
         {
             string branchName = dr.ItemArray[0] + "";
             if (string.IsNullOrEmpty(branchName))
             {
                 item.ErrorReson = "分公司名称不能为空";
                 return(false);
             }
             if (organizeApp.GetOrgByName(branchName) == null)
             {
                 item.ErrorReson = "“" + branchName + "”该分公司不存在";
                 return(false);
             }
         }
         else
         {
             string value = dr.ItemArray[i] + "";
             if (string.IsNullOrEmpty(value))
             {
                 item.ErrorReson = "完成量不能为空";
                 return(false);
             }
             if (!Validate.IsNumber(value))
             {
                 item.ErrorReson = "指标量必须是数字";
                 return(false);
             }
         }
     }
     return(true);
 }
Example #12
0
        protected override bool CheckHeader(List <String> headerList, List <ErrorItem> ErrorList, string[] keyValue)
        {
            String    errorReason = "【金融产品模板】不正确,请下载最新Excel模板、并按正确顺序上传!";
            string    taskType    = keyValue[1];
            ErrorItem item        = new ErrorItem();

            //分公司
            if (headerList != null && headerList.Count > 0)
            {
                string[] rightHeaderList = Constant.FinancialProductTaskTempleteListColumn;
                for (int i = 0; i < headerList.Count; i++)
                {
                    if (!headerList[i].Equals(rightHeaderList[i]))
                    {
                        item.ErrorReson = errorReason;
                        ErrorList.Add(item);
                        return(false);
                    }
                }
            }
            else
            {
                item.ErrorReson = errorReason;
                ErrorList.Add(item);
                return(false);
            }

            return(true);
        }
Example #13
0
 /// <summary>
 /// 取得告警列表
 /// </summary>
 /// <returns></returns>
 public void GetFaultList()
 {
     if (this.listTcpbug != null && listTcpbug.Count > 0)
     {
         Fault fault        = null;
         int   colllectorID = GetCollectorId();
         foreach (Bug bug in listTcpbug)
         {
             fault           = new Fault();
             fault.address   = bug.deviceAddress.ToString();
             fault.errorCode = bug.faultType;
             ErrorItem errorItem = ErrorItem.getErrotItemByCode(bug.faultType);
             fault.errorTypeCode = errorItem == null?ErrorType.ERROR_TYPE_FAULT:errorItem.errorType;
             fault.sendTime      = bug.faultTime;
             fault.collectorID   = colllectorID;
             fault.confirm       = false;
             int deviceID = this.GetDeviceId(colllectorID, bug.deviceAddress);
             fault.device = new Device()
             {
                 id = deviceID
             };
             faultList.Add(fault);
         }
     }
 }
Example #14
0
 /// <summary>
 /// Queue Error Item
 /// </summary>
 /// <param name="error">Error Item</param>
 internal void Queue(ErrorItem error)
 {
     if (null != error)
     {
         this.errors.Enqueue(error);
     }
 }
        /// <summary>
        /// Log an error to the database.
        /// </summary>
        /// <param name="ticker"></param>
        /// <param name="reason"></param>
        public static void HandleError(string ticker, string subsystem = "", string reason = "", Exception ex = null)
        {
            ErrorItem errorItem = new ErrorItem
            {
                Ticker    = ticker,
                Subsystem = subsystem,
                Reason    = reason
            };

            if (null == ex)
            {
                log.Error(reason);
            }
            else
            {
                log.Error(reason, ex);
            }

            var factory = ErrorItem.ErrorItemFactory();

            using (IDbConnection db = factory.OpenDbConnection())
            {
                db.CreateTableIfNotExists <ErrorItem>();
                db.Insert <ErrorItem>(errorItem);
            }
        }
Example #16
0
 /// <summary>
 /// 取得告警列表
 /// </summary>
 /// <returns></returns>
 public void GetFaultList()
 {
     if (this.listTcpbug != null && listTcpbug.Count > 0)
     {
         Fault fault        = null;
         int   colllectorID = GetCollectorId();
         foreach (Bug bug in listTcpbug)
         {
             fault               = new Fault();
             fault.address       = bug.deviceAddress.ToString();
             fault.errorCode     = bug.faultType;
             fault.errorTypeCode = ErrorItem.getErrorTypefromMemcached(bug.faultType);
             fault.data1         = bug.data1;
             fault.data2         = bug.data2;
             fault.sendTime      = bug.faultTime;
             fault.collectorID   = colllectorID;
             fault.confirm       = false;
             int deviceID = this.GetDeviceId(colllectorID, bug.deviceAddress);
             fault.device = new Device()
             {
                 id = deviceID
             };
             faultList.Add(fault);
         }
     }
 }
        public StackifyError(string message, Exception exception)
            : base(message)
        {
            Init();

            if (exception != null)
            {
                //Reflection caused error. Real error is the inner exception
                if (exception is TargetInvocationException && exception.InnerException != null)
                {
                    Error      = new ErrorItem(exception.InnerException);
                    _Exception = exception.InnerException;
                }
#if NET451 || NET45 || NET40
                else if (exception is HttpUnhandledException && exception.InnerException != null)
                {
                    Error      = new ErrorItem(exception.GetBaseException());
                    _Exception = exception.GetBaseException();
                }
#endif
                else
                {
                    Error      = new ErrorItem(exception);
                    _Exception = exception;
                }
            }

            SetAdditionalMessage(message);
        }
        public void FormatResource(TestResource res)
        {
            ErrorItem             error;
            FormattedCode         code;
            List <ICodeFormatter> array = GetAllFormatters();

            foreach (ICodeFormatter item in array)
            {
                error = new ErrorItem(res.Path, 1);
                code  = item.Format(error.ReadFile());

                Assert.That(code, Is.Not.Null,
                            "Formatter: " + item + " failed to format resource.");

                try
                {
                    FormattedCode.CheckData(code);
                }
                catch (Exception e)
                {
                    Assert.Fail("Formatter: " + item + " has created an ill-formed data. Error: " + e.Message);
                }
            }

            return;
        }
        public void DrawToGraphics(ErrorItemCollection items,
            ErrorItem selected, Graphics g, Rectangle viewport)
        {
            SizeF sizeLineSource;
            int last;
            int i;

            UiExceptionHelper.CheckNotNull(items, "items");
            UiExceptionHelper.CheckNotNull(g, "g");

            if (!_paintData.Equals(items, selected, viewport))
            {
                _paintData.Dispose();
                _paintData = new PaintData(items, selected, viewport, g);

                PaintBackground(Resources.ImageErrorList, _paintData.WorkingGraphics,
                    _rectListBackground, viewport);

                sizeLineSource = g.MeasureString("Line 9999", _font);
                _offsetLine = viewport.Width - sizeLineSource.Width;

                last = LastIndexVisible(items.Count, viewport);
                for (i = FirstIndexVisible(items.Count, viewport); i <= last; ++i)
                    DrawItem(items[i], i, selected == items[i], i == items.Count - 1, false, 
                        _paintData.WorkingGraphics, viewport);

                //_paintData.WorkingGraphics.DrawImage(Resources.ErrorList,
                //new Rectangle(0, 0, viewport.Width, _rectShadow.Height),
                //_rectShadow, GraphicsUnit.Pixel);
            }
            
            _paintData.PaintTo(g);           

            return;
        }
        public void Format_Pick_Best_Formatter()
        {
            ErrorItem      itemHelloTxt;
            ErrorItem      itemBasicCs;
            ICodeFormatter txtFormatter;
            ICodeFormatter csFormatter;
            FormattedCode  exp;

            using (TestResource resource = new TestResource("HelloWorld.txt"))
            {
                itemHelloTxt = new ErrorItem(resource.Path, 1);
                txtFormatter = new PlainTextCodeFormatter();
                exp          = txtFormatter.Format(itemHelloTxt.ReadFile());
                Assert.That(
                    _formatter.FormatFromExtension(itemHelloTxt.ReadFile(), itemHelloTxt.FileExtension),
                    Is.EqualTo(exp));
                FormattedCode.CheckData(exp);
            }

            using (TestResource resource = new TestResource("Basic.cs"))
            {
                itemBasicCs = new ErrorItem(resource.Path, 1);
                csFormatter = new CSharpCodeFormatter();
                exp         = csFormatter.Format(itemBasicCs.ReadFile());
                Assert.That(
                    _formatter.FormatFromExtension(itemBasicCs.ReadFile(), itemBasicCs.FileExtension),
                    Is.EqualTo(exp));
                FormattedCode.CheckData(exp);
            }

            return;
        }
Example #21
0
        public void NullDeleteErrorItemToken()
        {
            LogCore core = new LogCore();
            var     item = new ErrorItem();

            core.Delete(item);
        }
Example #22
0
        public void Test_MethodName()
        {
            ErrorItem item;

            // test to pass

            item = new ErrorItem("path", "namespace1.class.fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo("class"));

            item = new ErrorItem("path", ".class.fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo("class"));

            item = new ErrorItem("path", "0123456789012.a()", 1);
            Assert.That(item.MethodName, Is.EqualTo("a()"));
            Assert.That(item.BaseMethodName, Is.EqualTo("a"));
            Assert.That(item.ClassName, Is.EqualTo("0123456789012"));

            // test to fail

            item = new ErrorItem("path", "fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo(""));

            item = new ErrorItem("path", "", 1);
            Assert.That(item.MethodName, Is.EqualTo(""));
            Assert.That(item.BaseMethodName, Is.EqualTo(""));
            Assert.That(item.ClassName, Is.EqualTo(""));

            return;
        }
        public void Format_Pick_Best_Formatter()
        {
            ErrorItem itemHelloTxt;
            ErrorItem itemBasicCs;
            ICodeFormatter txtFormatter;
            ICodeFormatter csFormatter;
            FormattedCode exp;

            using (new TestResource("HelloWorld.txt"))
            {
                itemHelloTxt = new ErrorItem("HelloWorld.txt", 1);
                txtFormatter = new PlainTextCodeFormatter();
                exp = txtFormatter.Format(itemHelloTxt.ReadFile());
                Assert.That(
                    _formatter.FormatFromExtension(itemHelloTxt.ReadFile(), itemHelloTxt.FileExtension),
                    Is.EqualTo(exp));
                FormattedCode.CheckData(exp);
            }

            using (new TestResource("Basic.cs"))
            {
                itemBasicCs = new ErrorItem("Basic.cs", 1);
                csFormatter = new CSharpCodeFormatter();
                exp = csFormatter.Format(itemBasicCs.ReadFile());
                Assert.That(
                    _formatter.FormatFromExtension(itemBasicCs.ReadFile(), itemBasicCs.FileExtension),
                    Is.EqualTo(exp));
                FormattedCode.CheckData(exp);
            }

            return;
        }
 public StackifyError(DateTime errorOccurredUtc, ErrorItem errorItem)
     : this(errorItem.Message, null)
 {
     TimeSpan ts = errorOccurredUtc.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0));
     OccurredEpochMillis = (long)ts.TotalMilliseconds;
     this.Error = errorItem;
 }
Example #25
0
        private void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string MACHINE_CD = shtView.GetValue(shtView.ActiveRowIndex, (int)eColView.MACHINE_CD).ToString();

                MachineValidator validator = new MachineValidator();
                ErrorItem        errorItem = null;
                errorItem = validator.ValidateBeforeDelete(MACHINE_CD.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo);
                if (dr == MessageDialogResult.No)
                {
                    return;
                }


                m_machineController.DeleteMachine(MACHINE_CD.ToNZString());
                LoadData(false);

                MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription);
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }
Example #26
0
        public void EventType()
        {
            var item = new ErrorItem();
            var data = EventTypes.Stop;

            item.EventType = data;
            Assert.AreEqual <EventTypes>(data, item.EventType);
        }
Example #27
0
        public void ClassName()
        {
            var item = new ErrorItem();
            var data = StringHelper.ValidString();

            item.ClassName = data;
            Assert.AreEqual <string>(data, item.ClassName);
        }
Example #28
0
        public void StackTrace()
        {
            var item = new ErrorItem();
            var data = StringHelper.ValidString();

            item.StackTrace = data;
            Assert.AreEqual <string>(data, item.StackTrace);
        }
        /// <summary>
        /// Determines whether the errors are equal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="error">The error.</param>
        /// <returns>True if the errors are equal; otherwise false.</returns>
        private static bool ErrorsEqual(ErrorItem item, IJSLintError error)
        {
            var description = string.Concat(Resources.ErrorTextPrefix, error.Reason);

            return(item.Description.Equals(description, StringComparison.OrdinalIgnoreCase) &&
                   item.Line == error.Line &&
                   item.Column == error.Character);
        }
Example #30
0
        public void EmptyGuidDeleteErrorItem()
        {
            LogCore core = new LogCore();
            var     item = new ErrorItem();

            item.Token = new Token();
            core.Delete(item);
        }
Example #31
0
        public void Parent()
        {
            var item = new ErrorItem();
            var data = new ErrorItem();

            item.Parent = data;
            Assert.AreEqual <ErrorItem>(data, item.Parent);
        }
Example #32
0
        private static DataRow AddDataRow(DataRow dr, IAppError err, ErrorItem item)
        {
            dr[0] = err.AppErrorId;
            dr[1] = err.ToHtmlName(item);
            dr[2] = err.ToHtmlValue(item);

            return(dr);
        }
            public bool Equals(ErrorItemCollection items, ErrorItem item, Rectangle rectangle)
            {
                ErrorItem first = ((items.Count > 0) ? items[0] : null);

                return(viewport.Equals(rectangle) &&
                       object.ReferenceEquals(item, selection) &&
                       object.ReferenceEquals(first, _firstItem));
            }
Example #34
0
        /// <summary>
        /// Determines whether the errors are equal.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="error">The error.</param>
        /// <returns>True if the errors are equal; otherwise false.</returns>
        private static bool ErrorsEqual(ErrorItem item, IJSLintWarning error)
        {
            var description = string.Concat(Resources.ErrorTextPrefix, error.Message);

            return(item.Description.Equals(description, StringComparison.OrdinalIgnoreCase) &&
                   item.Line == error.Line + 1 &&
                   item.Column == error.Column + 1);
        }
        public StackifyError(DateTime errorOccurredUtc, ErrorItem errorItem)
            : this(errorItem.Message, null)
        {
            TimeSpan ts = errorOccurredUtc.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0));

            OccurredEpochMillis = (long)ts.TotalMilliseconds;
            this.Error          = errorItem;
        }
Example #36
0
 private void AddUpErrors(CompilerErrors errors, ErrorItem item)
 {
     switch (item.ErrorLevel)
     {
         case vsBuildErrorLevel.vsBuildErrorLevelHigh:
             errors.ErrorCount++; break;
         case vsBuildErrorLevel.vsBuildErrorLevelMedium:
         case vsBuildErrorLevel.vsBuildErrorLevelLow:
             errors.WarningCount++; break;
         default: break;
     }
 }
        public void SetUp()
        {
            _items = new InternalTraceItemCollection();

            _resourceA = new TestResource("HelloWorld.txt");
            _resourceB = new TestResource("TextCode.txt");

            _itemA = new ErrorItem(_resourceA.Path, 1);
            _itemB = new ErrorItem(_resourceB.Path, 2);

            return;
        }
 public ErrorItem Find(string code)
 {
     var retVal = new ErrorItem();
     foreach (ErrorItem item in list)
     {
         if (item.code == code)
         {
             retVal = item;
             break;
         }
     }
     return retVal;
 }
        public void Save()
        {
            IErrorRepository iErrorRepository = new ErrorRepository(this.connectionString);

            ErrorItem errorItem = new ErrorItem
                (
                    "data",
                    "eventName",
                    new DeviceDynamicInformation(2342344423333332333, 2342344423333332333, 50),
                    new AppActs.DomainModel.Exception.DeviceException("message", "stackTrace", "source", "data"),
                    "screenName",
                    Guid.NewGuid(),
                    DateTime.Now,
                    "1.1"
                );

            iErrorRepository.Save(this.Application.Id, this.Device.Id, errorItem);
        }
        public void Ctor_2()
        {
            ErrorItem item;
            
            item = new ErrorItem("Test.cs", "myFunction()", 1);

            Assert.That(item.Path, Is.EqualTo("Test.cs"));
            Assert.That(item.FullyQualifiedMethodName, Is.EqualTo("myFunction()"));            
            Assert.That(item.LineNumber, Is.EqualTo(1));
            Assert.That(item.HasSourceAttachment, Is.True);
            Assert.That(item.FileExtension, Is.EqualTo("cs"));

            item = new ErrorItem(null, "myFunction()", 1);
            Assert.That(item.Path, Is.Null);
            Assert.That(item.FileExtension, Is.Null);
            Assert.That(item.FullyQualifiedMethodName, Is.EqualTo("myFunction()"));
            Assert.That(item.LineNumber, Is.EqualTo(1));
            Assert.That(item.HasSourceAttachment, Is.False);

            return;
        }
Example #41
0
        /// <summary>
        /// Log an error to the database.
        /// </summary>
        /// <param name="ticker"></param>
        /// <param name="reason"></param>
        public static void HandleError(string ticker, string subsystem = "", string reason = "", Exception ex = null)
        {
            ErrorItem errorItem = new ErrorItem
            {
                Ticker = ticker,
                Subsystem = subsystem,
                Reason = reason
            };

            if (null == ex)
                log.Error(reason);
            else
                log.Error(reason, ex);

            var factory = ErrorItem.ErrorItemFactory();

            using (IDbConnection db = factory.OpenDbConnection())
            {
                db.CreateTableIfNotExists<ErrorItem>();
                db.Insert<ErrorItem>(errorItem);
            }
        }
        public void MeasureItem()
        {
            TestingRenderer renderer = new TestingRenderer();
            SizeF exp;
            SizeF actual;

            ErrorItem itemClass = new ErrorItem("/dir/f.cs", "0123456789012.a()", 3);
            ErrorItem itemMethod = new ErrorItem("/dir/f.cs", "a.0123456789012()", 3);
            ErrorItem itemFile = new ErrorItem("/dir/0123456789012.cs", "a.b()", 3);

            // measure an item whoose width should be determined
            // by class field value

            exp = _gr.MeasureString("0123456789012", renderer.Font);
            actual = renderer.MeasureItem(_gr, itemClass);
            int itemHeight = renderer.Font.Height * 4 + 6;
            
            Assert.That((int)actual.Width, Is.EqualTo((int)exp.Width + 16));
            Assert.That((int)actual.Height, Is.EqualTo(itemHeight));

            // measure an item whoose width should be determined
            // by method field value

            exp = _gr.MeasureString("0123456789012()", renderer.Font);
            actual = renderer.MeasureItem(_gr, itemMethod);
            Assert.That((int)actual.Width, Is.EqualTo((int)exp.Width + 16));
            Assert.That((int)actual.Height, Is.EqualTo(itemHeight));

            // measure an item whoose width should be determined
            // by filename field value

            exp = _gr.MeasureString("0123456789012.cs", renderer.Font);
            actual = renderer.MeasureItem(_gr, itemFile);
            Assert.That((int)actual.Width, Is.EqualTo((int)exp.Width + 16));
            Assert.That((int)actual.Height, Is.EqualTo(itemHeight));

            return;
        }        
        public StackifyError(string message, Exception exception)
        {
            Init();

            //Reflection caused error. Real error is the inner exception
            if (exception is TargetInvocationException && exception.InnerException != null)
            {
                Error = new ErrorItem(exception.InnerException);
                _Exception = exception.InnerException;
            }
            else if (exception is HttpUnhandledException && exception.InnerException != null)
            {
                Error = new ErrorItem(exception.GetBaseException());
                _Exception = exception.GetBaseException();
            }
            else
            {
                Error = new ErrorItem(exception);
                _Exception = exception;
            }

            SetAdditionalMessage(message);
        }
        ErrorItem ParseInterpreterOutput(string errOutput)
        {
            if(rx.IsMatch(errOutput)) {
                var m = rx.Match(errOutput);
                string filepath = m.Groups[1].Value;
                int linenum = int.Parse(m.Groups[2].Value);
                string description = m.Groups[3].Value + Environment.NewLine;

                int i = 0;
                foreach(var s in errOutput.Split('\n')) {
                    if(i > 0)
                        description += s.Trim() + Environment.NewLine;
                        i++;
                }

                var targetItem = this.Project.FindCodeDocumentByPath(filepath);

                if(targetItem != null) {
                    var error = new ErrorItem(linenum, targetItem, description.Trim())
                    {
                        Source = ErrorSource.External
                    };
                    return error;
                }
            }
            return null;
        }
 public new bool IsDirty(ErrorItemCollection items, ErrorItem selection, Rectangle viewport) {
     return (base.IsDirty(items, selection, viewport));
 }
Example #46
0
        /// <summary>
        /// Parse the complete verbose output text looking for errors and warnings
        /// </summary>
        /// <returns>Returns a sorted list of error item structs that are the cursor positions for 'warning ' or ' error' in the verbose output</returns>
        public static List <ErrorItem>FindWarnings()
        {
            List <ErrorItem>list = new List <ErrorItem>();
            string[] candidates =
            {
                "BUILD FAILED", "error", "warning", "exception"
            };
            bool bIsValid = false;
            int itemID = 0;

            foreach (string lookFor in candidates)
            {
                int p = 0;

                while (p >= 0)
                {
                    p = _verboseOutput.IndexOf(lookFor, p, StringComparison.InvariantCultureIgnoreCase);

                    if (p >= 0)
                    {
                        bIsValid = true;

                        if ((itemID == 1) || (itemID == 2))
                        {
                            // error and warning must not be plural because this is just a repeat of what we know already
                            bIsValid =
                                (_verboseOutput.Substring(p + lookFor.Length, 3).CompareTo("(s)") != 0
                                 && _verboseOutput.Substring(p + lookFor.Length, 1).CompareTo("s") != 0
                                 && _verboseOutput.Substring(p - 2, 8).CompareTo("s_error_") != 0
                                 && _verboseOutput.Substring(p - 1, 12).CompareTo("\\ErrorLog.cs") != 0
                                 && _verboseOutput.Substring(p - 1, 22).CompareTo("\\ErrorCodeInventory.cs") != 0
                                 && _verboseOutput.Substring(p - 1, 20).CompareTo("\\ErrorCodesHelper.cs") != 0
                                 && _verboseOutput.Substring(p - 1, 14).CompareTo("\\ErrorCodes.cs") != 0
                                 && _verboseOutput.Substring(p, 15).CompareTo("ErrorCodeDoc.cs") != 0);
                        }
                        else if (itemID == 3)
                        {
                            // exception must not be ExceptionDetailsDialog or ExceptionLogFileDialog-
                            bIsValid =
                                (_verboseOutput.LastIndexOf('\\', p, 24) == -1
                                 && _verboseOutput.IndexOf("DetailsDialog", p, 24) == -1
                                 && _verboseOutput.IndexOf("LogFileDialog", p, 24) == -1);
                        }

                        if (bIsValid)
                        {
                            ErrorItem ei = new ErrorItem();
                            ei.Position = p;
                            ei.SelLength = lookFor.Length;
                            list.Add(ei);

                            if (itemID == 0)
                            {
                                ErrorCount++;
                            }
                            else
                            {
                                WarningCount++;
                            }
                        }

                        p++;
                    }
                }

                itemID++;
            }

            // Put everything in order of occurrence in the text
            list.Sort(ErrorItemComparisonDelegate);
            return list;
        }
 public new SizeF MeasureItem(Graphics g, ErrorItem item) {
     return (base.MeasureItem(g, item));
 }
            public bool Equals(ErrorItemCollection items, ErrorItem item, Rectangle rectangle)
            {               
                ErrorItem first = ((items.Count > 0) ? items[0] : null);

                return (viewport.Equals(rectangle) &&
                        object.ReferenceEquals(item, selection) &&
                        object.ReferenceEquals(first, _firstItem));
            }
Example #49
0
 public void Remove(ErrorItem error)
 {
     _errors.Remove(error);
     OnErrorRemoved(error);
 }
Example #50
0
        /// <summary>
        /// Get project associated with the ErrorItem
        /// </summary>
        /// <param name="item">The ErrorItem</param>
        /// <returns>Project associated with the ErrorItem</returns>
        private Project GetProject(ErrorItem item)
        {
            Projects projects = _dte.Solution.Projects;
            for (int i = 1; i <= projects.Count; i++)
            {
                if (projects.Item(i).UniqueName == item.Project)
                    return projects.Item(i);
            }

            return null;
        }
Example #51
0
		private static DataRow AddDataRow(DataRow dr, IAppError err, ErrorItem item)
		{
			dr[0] = err.AppErrorId;
			dr[1] = err.ToHtmlName(item);
			dr[2] = err.ToHtmlValue(item);

			return dr;
		}
Example #52
0
        /// <summary>
        /// Get the unresolved symbols mangled name from an ErrorItem
        /// </summary>
        /// <param name="item">The ErrorItem</param>
        /// <returns>The symbols mangled name, or null if the item is not an 'unresolved external symbol' error</returns>
        private string GetUnresolvedSymbol(ErrorItem item)
        {
            string error = item.Description;
            if (!error.StartsWith("unresolved external symbol"))
                return null;

            error = error.Substring(error.IndexOf("\" (") + 3);
            error = error.Substring(0, error.IndexOf(')'));
            return error;
        }
Example #53
0
        protected ErrorList(IErrorListRenderer renderer)
        {
            UiExceptionHelper.CheckNotNull(renderer, "display");

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            DoubleBuffered = true;

            _renderer = renderer;
            _items = new ErrorItemCollection();
            _stackTrace = null;
            _selection = null;
            _workingGraphics = CreateGraphics();
            _hoveredIndex = -1;

            _autoSelectFirstItem = false;
            _listOrder = ErrorListOrderPolicy.InitialOrder;

            return;
        }
        public void FormatResource(TestResource res)
        {
            ErrorItem error;
            FormattedCode code;
            List<ICodeFormatter> array = GetAllFormatters();

            foreach (ICodeFormatter item in array)
            {
                error = new ErrorItem(res.Path, 1);
                code = item.Format(error.ReadFile());

                Assert.That(code, Is.Not.Null,
                    "Formatter: " + item + " failed to format resource.");

                try
                {
                    FormattedCode.CheckData(code);
                }
                catch (Exception e)
                {
                    Assert.Fail("Formatter: " + item + " has created an ill-formed data. Error: " + e.Message);
                }
            }

            return;
        }
Example #55
0
 internal ShellErrorListItem(ErrorItem item)
 {
     _item = item;
 }
Example #56
0
		/// <summary>
		/// Gets a human readable text representation for the specified <paramref name="enumItem"/>. The text is returned from the resource
		/// file. Example: If <paramref name="enumItem"/> = ErrorItem.StackTrace, the text "Stack Trace" is used.
		/// </summary>
		/// <param name="enumItem">The enum value for which to get human readable text.</param>
		/// <returns>Returns human readable text representation for the specified <paramref name="enumItem"/></returns>
		internal static string GetFriendlyEnum(ErrorItem enumItem)
		{
			switch (enumItem)
			{
				case ErrorItem.AppErrorId: return Resources.Err_AppErrorId_Lbl;
				case ErrorItem.Url: return Resources.Err_Url_Lbl;
				case ErrorItem.Timestamp: return Resources.Err_Timestamp_Lbl;
				case ErrorItem.ExceptionType: return Resources.Err_ExceptionType_Lbl;
				case ErrorItem.Message: return Resources.Err_Message_Lbl;
				case ErrorItem.Source: return Resources.Err_Source_Lbl;
				case ErrorItem.TargetSite: return Resources.Err_TargetSite_Lbl;
				case ErrorItem.StackTrace: return Resources.Err_StackTrace_Lbl;
				case ErrorItem.ExceptionData: return Resources.Err_ExceptionData_Lbl;
				case ErrorItem.InnerExType: return Resources.Err_InnerExType_Lbl;
				case ErrorItem.InnerExMessage: return Resources.Err_InnerExMessage_Lbl;
				case ErrorItem.InnerExSource: return Resources.Err_InnerExSource_Lbl;
				case ErrorItem.InnerExTargetSite: return Resources.Err_InnerExTargetSite_Lbl;
				case ErrorItem.InnerExStackTrace: return Resources.Err_InnerExStackTrace_Lbl;
				case ErrorItem.InnerExData: return Resources.Err_InnerExData_Lbl;
				case ErrorItem.GalleryId: return Resources.Err_GalleryId_Lbl;
				case ErrorItem.HttpUserAgent: return Resources.Err_HttpUserAgent_Lbl;
				case ErrorItem.FormVariables: return Resources.Err_FormVariables_Lbl;
				case ErrorItem.Cookies: return Resources.Err_Cookies_Lbl;
				case ErrorItem.SessionVariables: return Resources.Err_SessionVariables_Lbl;
				case ErrorItem.ServerVariables: return Resources.Err_ServerVariables_Lbl;
				default: throw new Exception(String.Format("Encountered unexpected ErrorItem enum value {0}. Error.GetFriendlyEnum is not designed to handle this enum value. The function must be updated.", enumItem));
			}
		}
Example #57
0
 public void Add(ErrorItem error)
 {
     _errors.Add(error);
     OnErrorAdded(error);
 }
        public void SelectedItemChanged()
        {
            GeneralCodeFormatter formatter = new GeneralCodeFormatter();
            ErrorItem item;

            // test to pass:
            //
            // handle selection changed event when there
            // is a non null selected item

            using (TestResource resource = new TestResource("Basic.cs"))
            {
                item = new ErrorItem(resource.Path, 2);
                Assert.That(item.ReadFile(), Is.Not.Null);

                _mockStack.SelectedItem.Returns(item);
                _mockCode.Formatter.Returns(formatter);
                
                _code.RaiseSelectedItemChanged();

                Assert.That(_mockCode.Text, Is.EqualTo(item.ReadFile()));
                Assert.That(_mockCode.Language, Is.EqualTo("C#"));
                // CurrentLine is a based 0 index
                Assert.That(_mockCode.CurrentLine, Is.EqualTo(1));
            }

            // test to fail:
            //
            // should handle selection changed event even
            // if selection comes to null

            _mockStack.SelectedItem.Returns((ErrorItem) null); 

            _code.RaiseSelectedItemChanged();

            Assert.That(_mockCode.Text, Is.EqualTo(null));

            return;
        }
Example #59
0
 protected virtual void OnErrorRemoved(ErrorItem item)
 {
     if(ErrorRemoved != null)
         ErrorRemoved(this, new EventArgs<ErrorItem>(item));
 }
Example #60
0
 public static int OnErrorItemSort(ErrorItem item1, ErrorItem item2)
 {
     return (item1.Position > item2.Position) ? 1 : (item1.Position == item2.Position) ? 0 : -1;
 }