public static String getMessageText(ExceptionMessage msg,params Object[] args) { String message; switch (msg) { case ExceptionMessage.ERROR_FILESYSTEM_NOTALLOW_SIZE: message = String.Format(Properties.Resources.ERROR_FILESYSTEM_NOTALLOW_SIZE, args); break; case ExceptionMessage.ERROR_MINIMUN_PART_SIZE: message = string.Format(Properties.Resources.ERROR_MINIMUN_PART_SIZE, args); break; case ExceptionMessage.ERROR_NO_SPACE_TO_SPLIT: message = Properties.Resources.ERROR_NO_SPACE_TO_SPLIT; break; case ExceptionMessage.ERROR_OPENING_FILE: message = String.Format(Properties.Resources.ERROR_OPENING_FILE, args); break; case ExceptionMessage.ERROR_TOTALSIZE_NOTEQUALS: message = Properties.Resources.ERROR_TOTALSIZE_NOTEQUALS; break; default: message = string.Empty; break; } return message; }
public void Format_MessageIsException_InfoIsWrittenAfterDateInMessage() { var timeService = new FakeTimeService(); var current = new DateTime(2012, 08, 28, 12, 0, 0); timeService.CurrentDateTime = current; var message = new ExceptionMessage(); var formatter = new LogFormater(timeService); var formattedMessage = formatter.Format(message); Assert.IsTrue(formattedMessage.StartsWith("[28.08.2012 12:00][Exception]")); }
public static void SendException(ExceptionMessage message) { if (!analyticsWebsiteConnected) { Connect(); } if (analyticsWebsiteExceptionHubConnection.State == ConnectionState.Connected) analyticsWebsiteProxy.Invoke("SendException", message); else { Connect(); analyticsWebsiteProxy.Invoke("SendException", message); } }
public static MessageBoxIcon getMessageIcon(ExceptionMessage msg) { MessageBoxIcon icon; switch (msg) { case ExceptionMessage.ERROR_NO_SPACE_TO_SPLIT: case ExceptionMessage.ERROR_OPENING_FILE: icon = MessageBoxIcon.Hand; break; case ExceptionMessage.ERROR_FILESYSTEM_NOTALLOW_SIZE: case ExceptionMessage.ERROR_MINIMUN_PART_SIZE: case ExceptionMessage.ERROR_TOTALSIZE_NOTEQUALS: icon = MessageBoxIcon.Error; break; default: icon = MessageBoxIcon.Information; break; } return icon; }
/// <summary> /// this method implements logic to save the graph to .grf file /// first line of file will have vertex info /// second line will have edges info /// third line will have commodities and their respective demands /// </summary> /// <param name="parameter"></param> private void _SaveGraph(object parameter) { int EdgeCount = Graph.EdgeCount; string[] txtArray = new string[3]; foreach (NetVertex vx in Graph.Vertices) { txtArray[0] += vx.ID.ToString() + ","; } txtArray[0] = txtArray[0].TrimEnd(','); for (int i = 0; i < EdgeCount; i++) { txtArray[1] += Graph.Edges.ElementAt(i).Source.ID.ToString() + "-"; txtArray[1] += Graph.Edges.ElementAt(i).Target.ID.ToString() + ","; } txtArray[1] = txtArray[1].TrimEnd(','); foreach (CommoditiesEntryViewModel cvm in CommodityList) { txtArray[2] += cvm.OriginID + "-" + cvm.DestinationID + "-" + cvm.DemandVal + ","; } txtArray[2] = txtArray[2].TrimEnd(','); try { SaveFileDialog saveDlg = new SaveFileDialog(); saveDlg.Filter = "Graph File |*.grf"; saveDlg.FileName = _openedFileName; saveDlg.OverwritePrompt = false; saveDlg.CheckFileExists = false; if (true == saveDlg.ShowDialog()) { File.WriteAllLines(saveDlg.FileName, txtArray); } _openedFileName = saveDlg.FileName; } catch (Exception ex) { ExceptionMessage.Show("Exception saving graph " + ex.ToString()); } }
/// <summary>コンストラクタ</summary> public ComplexConvolution1D(Shape inshape, Shape kernelshape, int stride, bool gradmode) : base(inputs: 2, outputs: 1, allow_resubstitution: false) { if (inshape.Type != ShapeType.Map || inshape.Ndim != 3) { throw new ArgumentException(ExceptionMessage.TensorElements(inshape, ("Ndim", 3), ("Type", ShapeType.Map))); } if (kernelshape.Type != ShapeType.Kernel || kernelshape.Ndim != 3) { throw new ArgumentException(ExceptionMessage.TensorElements(kernelshape, ("Ndim", 3), ("Type", ShapeType.Kernel))); } if (inshape.Channels % 2 != 0) { throw new AggregateException(ExceptionMessage.TensorLengthMultiple("Channels", inshape, inshape.Channels, 2)); } if (kernelshape.InChannels % 2 != 0) { throw new AggregateException(ExceptionMessage.TensorLengthMultiple("InChannels", kernelshape, kernelshape.Channels, 2)); } if (inshape.Channels != kernelshape.InChannels) { throw new ArgumentException(ExceptionMessage.TensorElements(kernelshape, ("InChannels", inshape.Channels))); } if (stride < 1) { throw new ArgumentException(nameof(stride)); } int outwidth = (inshape.Width - kernelshape.Width) / stride + 1; this.InShape = inshape; this.OutShape = Shape.Map1D(kernelshape.OutChannels * 2, outwidth, inshape.Batch); this.KernelShape = kernelshape; this.Stride = stride; this.GradMode = gradmode; }
public static Texture2D LoadPNG(string path) { try { // ファイルバッファ byte[] buf = oulFile.ReadAllBytes(path); // バイナリオープン //using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read)) //using (BinaryReader reader = new BinaryReader(file)) //{ // buf = reader.ReadBytes((int)reader.BaseStream.Length); // 16バイトから開始 int pos = 16; // 画像幅計算 int width = 0; for (int i = 0; i < 4; i++) { width = width * 256 + buf[pos++]; } int height = 0; for (int i = 0; i < 4; i++) { height = height * 256 + buf[pos++]; } // テクスチャ作成 Texture2D texture = new Texture2D(width, height); texture.LoadImage(buf); return(texture); } catch (Exception e) { ExceptionMessage.Message("png load error!", e); } return(null); }
public static async Task MainAsync(string[] args) { var dispatcher = ServiceProvider.GetService <IDispatcher>(); // Command - Exception var createFaultedCustomerCommand = new CreateCustomer(); var faultedResult = await dispatcher.Command(createFaultedCustomerCommand); // Command Create var createCustomerCommand = new CreateCustomer(); createCustomerCommand.FirstName = "Louis"; createCustomerCommand.LastName = "Lewis"; createCustomerCommand.UserName = "******"; var createResult = await dispatcher.Command(createCustomerCommand); var createdCustomerId = Guid.Parse(((CommandResult)createResult).RecordId); // Query Paged var queryPage = new QueryPage(); var queryPagedResult = await dispatcher.Query <QueryPage, GenericResultsList <CustomerLite> >(queryPage); // Query Single Lite var getCustomerQuery = new GetCustomer(id: createdCustomerId); var customerLite = await dispatcher.Query <GetCustomer, CustomerLite>(getCustomerQuery); // Query Single Detail var customerDetail = await dispatcher.Query <GetCustomer, CustomerDetail>(getCustomerQuery); // Command Delete var deleteCommand = new DeleteCustomer(id: createdCustomerId); var deleteResult = await dispatcher.Command(deleteCommand); // Message var exception = new NotImplementedException("Lets throw an exception"); var exceptionMessage = new ExceptionMessage { Exception = exception }; await dispatcher.Message(exceptionMessage); }
void Onrecebetarifa(object source, string tarifa) { if (tarifa == "Tarifa Simples") { try { Model.CalculoElecSimples(ContagemVazio, ContagemFora); } catch (ErroConversaoRecebe) { ExceptionMessage.Message(message); } } else if (tarifa == "Tarifa Bi-Horária") { try { Model.CalculoElecBi(ContagemVazio, ContagemFora); } catch (ErroConversaoRecebe) { ExceptionMessage.Message(message); } } else if (tarifa == "Tarifa Tri-Horária") { try { Model.CalculoElecTri(ContagemVazio, ContagemFora); } catch (ErroConversaoRecebe) { ExceptionMessage.Message(message); } } }
/// <summary>コンストラクタ</summary> public TrivectorDeconvolution1D(Shape outshape, Shape kernelshape, int stride, bool gradmode) : base(inputs: 2, outputs: 1, allow_resubstitution: false) { if (outshape.Type != ShapeType.Map || outshape.Ndim != 3) { throw new ArgumentException(ExceptionMessage.TensorElements(outshape, ("Ndim", 3), ("Type", ShapeType.Map))); } if (kernelshape.Type != ShapeType.Kernel || kernelshape.Ndim != 3) { throw new ArgumentException(ExceptionMessage.TensorElements(kernelshape, ("Ndim", 3), ("Type", ShapeType.Kernel))); } if (outshape.Channels % 3 != 0) { throw new AggregateException(ExceptionMessage.TensorLengthMultiple("Channels", outshape, outshape.Channels, 3)); } if (kernelshape.InChannels % 4 != 0) { throw new AggregateException(ExceptionMessage.TensorLengthMultiple("InChannels", kernelshape, kernelshape.Channels, 4)); } if (outshape.Channels / 3 * 4 != kernelshape.InChannels) { throw new ArgumentException(ExceptionMessage.TensorElements(kernelshape, ("InChannels", outshape.Channels / 3 * 4))); } if (stride < 1) { throw new ArgumentException(nameof(stride)); } int inwidth = (outshape.Width - kernelshape.Width) / stride + 1; this.InShape = Shape.Map1D(kernelshape.OutChannels * 3, inwidth, outshape.Batch); this.OutShape = outshape; this.KernelShape = kernelshape; this.Stride = stride; this.GradMode = gradmode; }
/// <summary> /// On save clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Save_Click(object sender, RoutedEventArgs e) { //update or save the tester try { _tester.Address = AddressTextBox.Address; if (_update) { _blimp.UpdateTester(_tester); } else { _blimp.AddTester(_tester); } Close(); } catch (Exception ex) { ExceptionMessage.Show(ex.Message, ex.ToString()); } }
/// <summary> /// On login click open tester window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TesterLoginButton_Click(object sender, EventArgs e) { try { Hide(); //open window var win = new TesterWin(int.Parse(TesterIDTestBox.Text)); win.ShowDialog(); Show(); //clean text boxes TesterIDTestBox.Text = ""; TesterIDTestBox.BorderBrush = Brushes.LightGray; TesterIDTestBox.Focus(); } catch { ExceptionMessage.Show("Tester doesn't exist please contact the administrator."); Show(); } }
public void Validate_ODataRequestOptions_Throws_ODataException_If_ODataVersion_BelowMinSupported() { var odataRequestOptions = new ODataRequestOptions( new Uri("https://services.odata.org/OData"), ODataIsolationLevel.None, ODataMetadataLevel.Minimal, ODataVersion.Parse("3.0"), // symantically this makes no sense but the scenario is needed for the test case. ODataVersion.OData40); var odataServiceOptions = new ODataServiceOptions( ODataVersion.MinVersion, ODataVersion.MaxVersion, new[] { ODataIsolationLevel.None }, new[] { "application/json" }); ODataException odataException = Assert.Throws <ODataException>(() => odataServiceOptions.Validate(odataRequestOptions)); Assert.Equal(ExceptionMessage.ODataVersionNotSupported(odataRequestOptions.ODataVersion, odataServiceOptions.MinVersion, odataServiceOptions.MaxVersion), odataException.Message); Assert.Equal(HttpStatusCode.BadRequest, odataException.StatusCode); Assert.Equal(ODataRequestHeaderNames.ODataVersion, odataException.Target); }
/// <summary> /// On login Click open administrator window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AdminLoginButton_Click(object sender, EventArgs e) { if (AdminUsernameTextBox.Text == Configuration.AdminUser && AdminPasswordTextBox.Password == Configuration.AdminPassword) { //clean text boxes AdminUsernameTextBox.Text = ""; AdminPasswordTextBox.Password = ""; AdminUsernameTextBox.Focus(); Hide(); //open window var win = new Administrator(); win.ShowDialog(); Show(); } else { ExceptionMessage.Show("Wrong Password or UserName."); } }
/// <summary> /// Remove selected trainee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveTestClick(object sender, RoutedEventArgs e) { try { var test = TestGrid.SelectedItem as Test; //validate delete if (!ValidationMessage.Show("Are you sure you want to delete test number " + test?.Id + " ?")) { return; } _bL.RemoveTest(test); RefreshData(); } catch (Exception ex) { if (ex.Message != "Object reference not set to an instance of an object.") { ExceptionMessage.Show(ex.Message, ex.ToString()); } } }
public static MessageBoxIcon getMessageIcon(ExceptionMessage msg) { MessageBoxIcon icon; switch (msg) { case ExceptionMessage.ERROR_NO_SPACE_TO_SPLIT: case ExceptionMessage.ERROR_OPENING_FILE: case ExceptionMessage.ERROR_CREATING_FILE: case ExceptionMessage.ERROR_FILESYSTEM_NOTALLOW_SIZE: case ExceptionMessage.ERROR_MINIMUN_PART_SIZE: case ExceptionMessage.ERROR_TOTALSIZE_NOTEQUALS: icon = MessageBoxIcon.Error; break; default: icon = MessageBoxIcon.Information; break; } return(icon); }
/// <summary> /// Called when exception happens in a GUI routine /// </summary> private void OnGuiUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { bool userLevel; string message = ExceptionMessage.GetUserMessage(e.Exception, out userLevel); if (userLevel) { // TODO FIX NOW would really like to find the window with focus, and not always use the main window... MainWindow.Focus(); MainWindow.StatusBar.LogError(message); e.Handled = true; } else { var feedbackSent = AppLog.SendFeedback("Unhandled Exception in GUI\r\n" + e.Exception.ToString(), true); var dialog = new PerfView.Dialogs.UnhandledExceptionDialog(MainWindow, e.Exception, feedbackSent); var ret = dialog.ShowDialog(); // If it returns, it means that the user has opted to continue. e.Handled = true; } }
public void Validate_ODataRequestOptions_Throws_ODataException_If_MetadataLevel_NotSupported() { var odataRequestOptions = new ODataRequestOptions( new Uri("https://services.odata.org/OData"), ODataIsolationLevel.None, ODataMetadataLevel.Full, ODataVersion.OData40, ODataVersion.OData40); var odataServiceOptions = new ODataServiceOptions( ODataVersion.MinVersion, ODataVersion.MaxVersion, new[] { ODataIsolationLevel.None }, new[] { "application/json" }); ODataException odataException = Assert.Throws <ODataException>(() => odataServiceOptions.Validate(odataRequestOptions)); Assert.Equal(ExceptionMessage.ODataMetadataLevelNotSupported("full", new[] { "none", "minimal" }), odataException.Message); Assert.Equal(HttpStatusCode.BadRequest, odataException.StatusCode); Assert.Equal("odata.metadata", odataException.Target); }
public void Validate_ODataRequestOptions_Throws_ODataException_If_IsolationLevel_NotSupported() { var odataRequestOptions = new ODataRequestOptions( new Uri("https://services.odata.org/OData"), ODataIsolationLevel.Snapshot, ODataMetadataLevel.Minimal, ODataVersion.OData40, ODataVersion.OData40); var odataServiceOptions = new ODataServiceOptions( ODataVersion.MinVersion, ODataVersion.MaxVersion, new[] { ODataIsolationLevel.None }, new[] { "application/json" }); ODataException odataException = Assert.Throws <ODataException>(() => odataServiceOptions.Validate(odataRequestOptions)); Assert.Equal(ExceptionMessage.ODataIsolationLevelNotSupported("Snapshot"), odataException.Message); Assert.Equal(HttpStatusCode.PreconditionFailed, odataException.StatusCode); Assert.Equal(ODataRequestHeaderNames.ODataIsolation, odataException.Target); }
public void Validate_ODataRequestOptions_Throws_ODataException_If_ODataMaxVersion_AboveMaxSupported() { var odataRequestOptions = new ODataRequestOptions( new Uri("https://services.odata.org/OData"), ODataIsolationLevel.None, ODataMetadataLevel.Minimal, ODataVersion.OData40, ODataVersion.Parse("5.0")); var odataServiceOptions = new ODataServiceOptions( ODataVersion.MinVersion, ODataVersion.MaxVersion, new[] { ODataIsolationLevel.None }, new[] { "application/json" }); ODataException odataException = Assert.Throws <ODataException>(() => odataServiceOptions.Validate(odataRequestOptions)); Assert.Equal(ExceptionMessage.ODataMaxVersionNotSupported(odataRequestOptions.ODataMaxVersion, odataServiceOptions.MinVersion, odataServiceOptions.MaxVersion), odataException.Message); Assert.Equal(HttpStatusCode.BadRequest, odataException.StatusCode); Assert.Equal(ODataRequestHeaderNames.ODataMaxVersion, odataException.Target); }
/// <summary> /// This method is called by NodeClickLogic if the mode is set to 1 /// the method is called two times: when user clicks first node and when user clicks second node /// to create an edge between them. /// first time it only store the node ID, second time it check if there is already an edge between those /// node. If there is no edge then it will add new edge to the graph. /// </summary> /// <param name="NodeID"></param> private void _CreateEdge(int NodeID) { if (_Counter == 0) { _FistNodeID = NodeID; _Counter++; } else if (_Counter == 1) { int from = 0, to = 0; int count = Graph.VertexCount; _Mode = 0; _Counter = 0; for (int i = 0; i < count; i++) { if (Graph.Vertices.ElementAt(i).ID == _FistNodeID) { from = i; } if (Graph.Vertices.ElementAt(i).ID == NodeID) { to = i; } } if (from != to) { try { if (!Graph.ContainsEdge(Graph.Vertices.ElementAt(from), Graph.Vertices.ElementAt(to))) { _AddNewGraphEdge(Graph.Vertices.ElementAt(from), Graph.Vertices.ElementAt(to)); } } catch (Exception ex) { ExceptionMessage.Show("Exception when creating edge: " + ex.ToString()); } } } }
/// <summary>收到数据流</summary> /// <param name="session"></param> /// <param name="stream"></param> protected virtual void OnReceive(ISocketSession session, Stream stream) { try { Process(stream, session, session.Remote); //// 如果还有剩下,写入数据流,供下次使用 //if (stream.Position < stream.Length) //{ // var ms = new MemoryStream(); // stream.CopyTo(ms); // ms.Position = 0; // session.Stream = ms; //} //else // session.Stream = null; } catch (Exception ex) { if (NetHelper.Debug) { NetHelper.WriteLog(ex.ToString()); } // 去掉内部异常,以免过大 if (ex.InnerException != null) { ex.SetValue("_innerException", null); } var msg = new ExceptionMessage() { Value = ex }; //session.Send(msg.GetStream()); OnSend(msg.GetStream()); //// 出错后清空数据流,避免连锁反应 //session.Stream = null; } }
private void _OpenNetworkXGraph() { string[] lines = null; // Create an open file dialog box and only show *.grf files. try { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "Text File |*.doc;*.txt;*.grf"; //read all lines of file if (true == openDlg.ShowDialog()) { lines = File.ReadAllLines(openDlg.FileName); this._openedFileName = openDlg.FileName; this._DrawGraphWithCommodities(lines); } } catch (IOException ex) { ExceptionMessage.Show("Could not open file\n" + ex.ToString()); } }
static public byte[] ReadAllBytes(string path) { try { byte[] buf; // バイナリオープン using (FileStream file = new System.IO.FileStream(path, FileMode.Open, FileAccess.Read)) using (BinaryReader reader = new System.IO.BinaryReader(file)) { buf = reader.ReadBytes((int)reader.BaseStream.Length); } return(buf); } catch (System.Exception e) { ExceptionMessage.Message("file error", e); } return(null); }
public override void CheckInputShapes(params Shape[] inshapes) { base.CheckInputShapes(inshapes); if (inshapes[0].Ndim <= 0) { throw new ArgumentException(ExceptionMessage.Shape("Ndim", inshapes[0])); } if (inshapes[0] != inshapes[1]) { throw new ArgumentException(ExceptionMessage.Shape(inshapes[1], inshapes[0])); } if (inshapes[0] != inshapes[2]) { throw new ArgumentException(ExceptionMessage.Shape(inshapes[2], inshapes[0])); } if (inshapes[0] != inshapes[3]) { throw new ArgumentException(ExceptionMessage.Shape(inshapes[3], inshapes[0])); } }
public virtual MainViewModel <T> SearchDetail(T SearchContext) { var message = new ExceptionMessage("Enter->" + MethodBase.GetCurrentMethod()); T results = null; if (NotValidIdentity()) { SessionExpired(message); } else { try { results = GetRecordDetail(SearchContext, message); } catch (Exception ex) { LogBaseControllerMessage(ex, message); } } return(new MainViewModel <T>(results, message)); }
/// <summary>形状を調整する</summary> public static VariableNode AdjectShape(VariableNode node, Shape shape) { if (shape != node.Shape) { if (shape.Ndim == 0 && node.Shape.Ndim > 0) { node = Sum(node, keepdims: false); } else if (shape.Ndim == 1 && node.Shape.Ndim > 1 && shape[0] == node.Shape[0]) { int[] axes = (new int[node.Shape.Ndim - 1]).Select((_, idx) => idx + 1).ToArray(); node = Sum(node, axes, keepdims: false); } else { throw new ArgumentException(ExceptionMessage.Broadcast(node.Shape, shape)); } } return(node); }
/// <summary>コンストラクタ</summary> public QuaternionKernelProductDense(int inchannels, int outchannels, bool transpose = false, int batch = 1) { if (inchannels % 4 != 0) { throw new ArgumentException(ExceptionMessage.ArgumentMultiple(nameof(inchannels), inchannels, 4)); } if (outchannels % 4 != 0) { throw new ArgumentException(ExceptionMessage.ArgumentMultiple(nameof(outchannels), outchannels, 4)); } this.arguments = new List <(ArgumentType type, Shape shape)> { (ArgumentType.In, Shape.Map0D(inchannels, batch)), (ArgumentType.In, Shape.Map0D(outchannels, batch)), (ArgumentType.Out, Shape.Kernel0D(inchannels, outchannels / 4)) }; this.InChannels = inchannels; this.OutChannels = outchannels; this.Transpose = transpose; this.Batch = batch; }
/// <summary>コンストラクタ</summary> public ComplexDense(int inchannels, int outchannels, bool gradmode = false, int batch = 1) { if (inchannels % 2 != 0) { throw new ArgumentException(ExceptionMessage.ArgumentMultiple(nameof(inchannels), inchannels, 2)); } if (outchannels % 2 != 0) { throw new ArgumentException(ExceptionMessage.ArgumentMultiple(nameof(outchannels), outchannels, 2)); } this.arguments = new List <(ArgumentType type, Shape shape)> { (ArgumentType.In, Shape.Map0D(inchannels, batch)), (ArgumentType.In, Shape.Kernel0D(inchannels, outchannels / 2)), (ArgumentType.Out, Shape.Map0D(outchannels, batch)), }; this.InChannels = inchannels; this.OutChannels = outchannels; this.GradMode = gradmode; this.Batch = batch; }
private async Task HandleUnhandledExceptionAsync(HttpContext context, Exception exception) { //_logger.LogError(exception, exception.Message); if (!context.Response.HasStarted) { int statusCode = (int)HttpStatusCode.InternalServerError; // 500 string message = string.Empty; #if DEBUG message = exception.Message; #else message = "An unhandled exception has occurred"; #endif context.Response.Clear(); context.Response.ContentType = "application/json"; context.Response.StatusCode = statusCode; var result = new ExceptionMessage(message).ToString(); await context.Response.WriteAsync(result); } }
public override int GetHashCode() { int hash = 1; if (user_ != null) { hash ^= User.GetHashCode(); } if (ExceptionMessage.Length != 0) { hash ^= ExceptionMessage.GetHashCode(); } if (ExceptionId.Length != 0) { hash ^= ExceptionId.GetHashCode(); } if (JWToken.Length != 0) { hash ^= JWToken.GetHashCode(); } return(hash); }
/// <summary>コンストラクタ</summary> public PointwiseConvolution(Shape inshape, Shape kernelshape) : base(inputs: 2, outputs: 1, allow_resubstitution: false) { if (inshape.Type != ShapeType.Map || inshape.Ndim != 4) { throw new ArgumentException(ExceptionMessage.TensorElements(inshape, ("Ndim", 4), ("Type", ShapeType.Map))); } if (kernelshape.Type != ShapeType.Kernel || kernelshape.Ndim != 2) { throw new ArgumentException(ExceptionMessage.TensorElements(kernelshape, ("Ndim", 2), ("Type", ShapeType.Kernel))); } if (inshape.Channels != kernelshape.InChannels) { throw new ArgumentException(ExceptionMessage.TensorElements(kernelshape, ("InChannels", inshape.Channels))); } this.InShape = inshape; this.OutShape = Shape.Map2D(kernelshape.OutChannels, inshape.Width, inshape.Height, inshape.Batch); this.KernelShape = kernelshape; }
/// <summary> /// Remove selected trainee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveTraineeClick(object sender, RoutedEventArgs e) { try { var trainee = TraineeGrid.SelectedItem as Trainee; //validate delete if (!ValidationMessage.Show("Are you sure you want to delete " + trainee?.FirstName + " " + trainee?.LastName + "?")) { return; } _bL.RemoveTrainee(trainee); RefreshData(); } catch (Exception ex) { if (ex.Message != "Object reference not set to an instance of an object.") { ExceptionMessage.Show(ex.Message, ex.ToString()); } } }
/// <summary> /// 发生异常事件 /// </summary> /// <param name="context">方法元数据</param> /// <param name="exception">异常实例</param> protected virtual void OnException(MethodAdviceContext context, Exception exception) { if (!context.TargetMethod.IsDefined(typeof(SkipExceptionAttribute), true)) { //初始化异常日志 this._exceptionLog.BuildBasicInfo(context); this._exceptionLog.BuildMethodArgsInfo(context); this._exceptionLog.BuildExceptionInfo(exception); //无需事务 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled)) { //插入数据库 Guid newId = LogMediator.Write(this._exceptionLog); scope.Complete(); //初始化异常消息 this._exceptionMessage = new ExceptionMessage(exception.Message, newId); } } }
/// <summary> /// Launch Split Message event /// </summary> /// <param name="msg"></param> /// <param name="type"></param> private void onMessage(ExceptionMessage msg, params Object[] parameters) { if (message != null) { message(this, new MessageArgs(msg, parameters)); } }
public void SendException(ExceptionMessage exception) { Clients.All.displayException(exception); }
public ExceptionBase(ExceptionMessage exceptionMessage) : base(exceptionMessage.ToString()) { }
public ExceptionBase(ExceptionMessage exceptionMessage, System.Exception innerException) : base(exceptionMessage.ToString(), innerException) { }
public virtual void Log(ExceptionMessage msg) { Email email = CreateEmail(); email.Body = msg.Value; ServiceManager.Get<IEmailService>().Send(email); }
public virtual void Log(ExceptionMessage msg) { MessageBox.Show(msg.Value, "Logger", MessageBoxButtons.OK, MessageBoxIcon.Error); }
public virtual void Log(ExceptionMessage msg) { Console.WriteLine(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss EXCEPTION : ") + msg.Value); }
private static void AddException(string exception) { var ex = new ExceptionMessage(exception); if (!Exceptions.Contains(ex)) { Exceptions.Add(ex); } else { var oldEx = Exceptions.IndexOf(ex); if (oldEx >= 0) { ex.Count += Exceptions[oldEx].Count; Exceptions.RemoveAt(oldEx); } Exceptions.Add(ex); } }
/// <summary> /// Constructor for the message /// </summary> /// <param name="message"></param> /// <param name="type"></param> public MessageArgs(ExceptionMessage message, Object[] parameters) { this.Message = message; this.Parameters = parameters; }
public bool Equals(ExceptionMessage other) { return string.Equals(Message, other.Message); }
public void SetContent(ExceptionMessage message) { Message.text = message.Message + " (" + message.Count + ")" ; Date.text = message.Occurance.ToString(); }
public string GetBacktrace(ExceptionMessage e) { var q = from pair in e.DataList where pair.Key == "backtrace" select pair.Value; return (q.FirstOrDefault() ?? string.Empty); }
static void Main(string[] args) { Random randomCountry = new Random(); var bus = Configure.With() .Log4Net() .DefaultBuilder() .MsmqTransport() .MsmqSubscriptionStorage() .XmlSerializer() .DisableRavenInstall() .DisableTimeoutManager() .UnicastBus() .SendOnly(); Console.WriteLine("Please select an option:"); Console.WriteLine("Type 1: For exception testing"); Console.WriteLine("Type 2: For admin testing"); while (true) { string line = Console.ReadLine(); if (line == "exit") { break; } if (line == "1") { try { throw new ArgumentException("Some exception happened!" + line); } catch (Exception exception) { var message = new ExceptionMessage() { Message = exception.Message, Country = (Country) randomCountry.Next(0, 3), //Country = Country.Uk, StackTrace = exception.StackTrace, TimeOccurred = DateTime.Now, Type = (ExceptionType) randomCountry.Next(0, 2), }; bus.Send(message); } } if (line == "2") { Console.WriteLine("Enter test message"); var message = Console.ReadLine(); var adminMessage = new AdminNotificationMessage() { Country = Country.Uk, Message = message, TimeOccurred = DateTime.Now, Type = NotificationType.Verification }; bus.Send(adminMessage); } } }
public void Log(ExceptionMessage msg) { UdpPaperTrail.SendUdpMessage("<22>" + DateTime.Now.ToString("MMM d H:mm:ss") + key.Spaced() + ": " + msg.Value); }