//form1.DataBinding //form1.Disabled //form1.Disposed //form1.Load //form1.PreRender //form1.Unload protected void form1_DataBinding(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }
public Task HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken) { if (context.Exception is CustomException ce) { AppLog.Info(ce); context.Result = new ResponseMessageResult(new HttpResponseMessage { Content = new StringContent(ce.Message), StatusCode = HttpStatusCode.InternalServerError }); } else { AppLog.Error(context.Exception); context.Result = new ResponseMessageResult(new HttpResponseMessage { Content = new StringContent("对不起发生了错误,请检查日志"), StatusCode = HttpStatusCode.InternalServerError }); } return(Task.FromResult(0)); }
private bool Validate() { AppLog.Info("VALIDATE NOTE - Starting..."); try { if (Title == null) { throw new Exception("Note has not been given a title"); } if (Title.Length > 50) { throw new Exception("Title exceeds 50 characters"); } if (Body == null) { throw new Exception("Note has not been given a body"); } if (Body.Length > 1000) { throw new Exception("Note exceeds 1000 characters"); } } catch (Exception e) { _ErrMsg = e.ToString(); AppLog.Error("VALIDATE NOTE - Validation failed: " + _ErrMsg); return(false); } AppLog.Info("VALIDATE NOTE - Success!"); return(true); }
/// <summary> /// 心跳包监控 /// </summary> /// <param name="obj"></param> async void DanmmuKeepAlive(CancellationToken token) { byte[] aliveMsg = DataToBytes("type@=mrkl/"); await Task.Run(async() => { while (true) { try { if (token.IsCancellationRequested) { return; } AppLog.Info($"弹幕服务器【房间{ROOM_ID}】【发送心跳包】"); DanmuClient.Send(aliveMsg); await Task.Delay(30000); } catch (Exception ex) { //if (DanmuClient == null|| DanmuClient.ReadyState!= WebSocketState.Open) // return; AppLog.Error("心跳异常", ex); //if (!token.IsCancellationRequested) // Reconnect(); return; } } }); }
public void AddListener(string targetAddress) { if (!IsOpen) { throw new Exception("The Endpoint must have an a request processor set up via the Open method in order to receive messages on a listener."); } string t = targetAddress.ToUpper(); if (listeners.ContainsKey(t)) { throw new Exception("The specified targetAddress is already in use."); } Exception ex = null; try { InternalMessageProcessor p = new InternalMessageProcessor(this, targetAddress); inboundHost.RegisterMessageProcessor(targetAddress, p); AppLog.Info($"Listener registered on {targetAddress}"); listeners[t] = p; } catch (Exception exception) { ex = exception; AppLog.Error(ex); } if (ex != null) { throw ex; } }
async void AuthKeepAlive(CancellationToken token) { await Task.Run(async() => { await Task.Delay(5000); while (true) { try { long timeStamp = CCTime.GetTimeStamp(); string str = $"type@=keeplive/vbw@=0/cdn@=cmcc/tick@={timeStamp}/kd@={(kd == null ? "" : await Getkd(kd, ROOM_ID, devid, timeStamp))}/"; byte[] aliveMsg = DataToBytes(str); if (token.IsCancellationRequested) { return; } AppLog.Info($"认证服务器【房间{ROOM_ID}】【发送心跳包】"); AuthClient.Send(aliveMsg); await Task.Delay(20000); } catch (Exception ex) { //if (AuthClient == null || AuthClient.ReadyState != WebSocketState.Open) // return; AppLog.Error("【认证服务器】心跳异常", ex); //if (!token.IsCancellationRequested) // Reconnect(); return; } } }); }
public void AddSource(string sourceAddress) { if (!IsOpen) { throw new Exception("The Endpoint must have an a request processor set up via the Open method in order to receive messages on a listener."); } string s = sourceAddress.ToUpper(); if (sources.ContainsKey(s)) { throw new Exception("The specified sourceAddress is already in use."); } Exception ex = null; try { InternalSourceProcessor p = new InternalSourceProcessor(this, sourceAddress); inboundHost.RegisterMessageSource(sourceAddress, p); AppLog.Info($"Source registered on {sourceAddress}"); sources[s] = p; } catch (Exception exception) { ex = exception; AppLog.Error(ex); } if (ex != null) { throw ex; } }
private void btnSendmsg1_Click(object sender, EventArgs e) { AppLog.Error("test1"); AppLog.Info("test2"); AppLog.Warn("test3"); AppLog.Fatal("test4"); }
protected void btnButton_PreRender(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }
protected void Page_Load(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }
private void InitUIList() { appLog.Info("InitUIList..."); needAddList = new ObservableCollection <SalaryInfo>(); needUpdateList = new ObservableCollection <SalaryInfo>(); //添加雇员选择列表 appLog.Info("Add EmployeeList..."); AlgorithmClass.InitSalarySelectionList(dataManager.AllSalaryList, dataManager.AllEmployeeList, dataManager.AllDepartmentList, AlgorithmClass.GetWorkStatusList()); AllSalaryList = AlgorithmClass.DeepClone <ObservableCollection <SalaryInfo> >(dataManager.AllSalaryList); lcv = new ListCollectionView(AllSalaryList); lcv.GroupDescriptions.Add(new PropertyGroupDescription("DepartmentName")); lcv.Filter = Fitter_TextChanged; lcv.Refresh(); //刷新当前页面上的所有收支 // FlushCurrentViewAllCommission(); AddBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv }); ClearBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); SaveBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); RestoreBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); ViewBSBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); PrintBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); FlushAllBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); SalaryDataGrid.ItemsSource = lcv; }
public static async void StartServer() { await Task.Run(() => { LocalServer = WebApp.Start <Startup>(AppConfig.ServerAddress); AppLog.Info($"WEBAPI服务器启动:{AppConfig.ServerAddress}"); }); }
private void _setStatusFace() { AppLog.Info("Change state Face."); status = AppStatus.face; xtuber.SetActive(false); faceTexture.GetComponent <MeshRenderer>().enabled = true; maker.SetActive(true); }
public static async void StopServer() { await Task.Run(() => { LocalServer?.Dispose(); AppLog.Info("WEBAPI服务器关闭."); }); }
public void CallbackMethod(string message) { AppLog.Info("CallbackMethod: " + message.Length); byte[] bytes = System.Convert.FromBase64String(message); var texture = new Texture2D(1, 1); texture.LoadImage(bytes); image.texture = texture; }
public bool Delete() { AppLog.Info("DELETE ASSIGNEE - Starting..."); AppLog.Info("DELETE ASSIGNEE - Attempting to delete assignee on online database..."); try { using (SqlConnection conn = new SqlConnection(Data.OnlineConnStr)) { AppLog.Info("DELETE ASSIGNEE - Attempting to open connection to online database..."); conn.Open(); AppLog.Info("DELETE ASSIGNEE - Connection to online database opened successfully"); SqlCommand DeleteAssignee = new SqlCommand("DELETE FROM t_Assignees WHERE BugId = @BugId " + "AND UserId = @UserId;", conn); DeleteAssignee.Parameters.Add(new SqlParameter("BugId", _BugId)); DeleteAssignee.Parameters.Add(new SqlParameter("UserId", _UserId)); DeleteAssignee.ExecuteNonQuery(); } AppLog.Info(String.Format("DELETE ASSIGNEE - <Class> {0} deleted from online database successfully", MyUser.Username)); } catch (SqlException e) { _ErrMsg = "Error while deleting assignee from online database"; AppLog.Error("DELETE ASSIGNEE - " + _ErrMsg + ": " + e);; return(false); } /*AppLog.Info("DELETE ASSIGNEE - Attempting to delete assignee on local database..."); * try * { * using (SqlConnection conn = new SqlConnection(Data.LocalConnStr)) * { * AppLog.Info("DELETE ASSIGNEE - Attempting to open connection to local database..."); * conn.Open(); * AppLog.Info("DELETE ASSIGNEE - Connection to local database opened successfully"); * * SqlCommand DeleteAssignee = new SqlCommand("DELETE FROM Assignees WHERE BugId = @BugId AND " + * "UserId = @UserId;", conn); * DeleteAssignee.Parameters.Add(new SqlParameter("BugId", _BugId)); * DeleteAssignee.Parameters.Add(new SqlParameter("UserId", _UserId)); * * DeleteAssignee.ExecuteNonQuery(); * } * AppLog.Info(String.Format("DELETE ASSIGNEE - Assignee {0} deleted from local database successfully", * MyUser.Username)); * } * catch (SqlException e) * { * _ErrMsg = "Error while deleting assignee from local database"; * AppLog.Error("DELETE ASSIGNEE - " + _ErrMsg + ": " + e); ; * return false; * }*/ AppLog.Info("DELETE ASSIGNEE - Success!"); return(true); }
private void OnImageAvailableCallbackFunc(TextureReaderApi.ImageFormatType format, int width, int height, IntPtr pixelBuffer, int bufferSize) { AppLog.Info("OnImageAvailableCallbackFunc"); this.format = format; this.width = width; this.height = height; this.pixelBuffer = pixelBuffer; this.bufferSize = bufferSize; }
protected void Page_PreRenderComplete(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); // Raised after each data bound control whose DataSourceID property is set calls its DataBind method. // For more information, see Data Binding Events for Data-Bound Controls later in this topic. AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }
private async void connectServer() { client = new EasyClient <MyPackageInfo>(); client.Initialize(new MyReceiveFilter()); client.Connected += OnClientConnected; client.NewPackageReceived += OnPackageReceived; client.Error += OnClientError; client.Closed += OnClientClosed; int port = 0; if (!int.TryParse(txtPort.Text.Trim(), out port)) { AppEvents.Instance.OnUpdateScreenRun("端口设置错误"); return; } var connected = await client.ConnectAsync(new IPEndPoint(IPAddress.Parse(txtIP.Text.Trim()), port)); if (connected) { //name 2 length 2 body 6 bit 心跳包 var rs = new List <byte> { 0, 1, 0, 6 }; rs.AddRange(System.Text.Encoding.UTF8.GetBytes(DateTime.Now.ToString("1ssfff"))); AppLog.Info("发送数据:" + DataHelper.ByteToHex(rs.ToArray(), rs.Count)); client.Send(rs.ToArray()); //每5秒发一次心跳 timer = new System.Timers.Timer(200000); timer.Elapsed += new System.Timers.ElapsedEventHandler((s, x) => { if (client.IsConnected && chkTimingHeart.Checked) { rs = new List <byte> { 0, 2, 0, 6 }; rs.AddRange(DateTime.Now.ToString("yy MM dd HH mm ss").Split(' ').Select(m => byte.Parse(m)).ToArray()); AppLog.Info("发送数据:" + DataHelper.ByteToHex(rs.ToArray(), rs.Count)); client.Send(rs.ToArray()); } }); timer.Enabled = true; timer.Start(); } else { AppLog.Info("连接服务器失败"); AppEvents.Instance.OnUpdateScreenRun("连接服务器失败"); } }
public void Open(string cfxHandle, Uri requestUri, X509Certificate2 certificate = null) { IsOpen = false; if (string.IsNullOrEmpty(cfxHandle)) { throw new ArgumentException("You must supply a CFX Handle"); } this.CFXHandle = cfxHandle; RequestUri = requestUri; inboundHost = new ContainerHost(RequestUri); if (!string.IsNullOrWhiteSpace(RequestUri.UserInfo)) { inboundHost = new ContainerHost(new Uri[] { RequestUri }, null, RequestUri.UserInfo); } else { inboundHost = new ContainerHost(RequestUri); } var listener = inboundHost.Listeners[0]; if (string.Compare(requestUri.Scheme, "amqps", true) == 0) { listener.SSL.Certificate = certificate; listener.SSL.ClientCertificateRequired = true; listener.SSL.RemoteCertificateValidationCallback = ValidateServerCertificate; listener.SASL.EnableExternalMechanism = true; } if (string.IsNullOrWhiteSpace(RequestUri.UserInfo)) { listener.SASL.EnableExternalMechanism = false; listener.SASL.EnableAnonymousMechanism = true; } else { listener.SASL.EnableExternalMechanism = true; listener.SASL.EnableAnonymousMechanism = false; //listener.SASL.EnablePlainMechanism(RequestUri.UserInfo.Split(':')[0], RequestUri.UserInfo.Split(':')[1]); } listener.SSL.Certificate = certificate; listener.SSL.ClientCertificateRequired = true; listener.SSL.ClientCertificateRequired = false; listener.SSL.RemoteCertificateValidationCallback = ValidateServerCertificate; inboundHost.Open(); AppLog.Info($"Container host is listening on {RequestUri.Host}:{RequestUri.Port}. User {requestUri.UserInfo}"); inboundHost.RegisterRequestProcessor(RequestHandle, new InternalRequestProcessor(this)); AppLog.Info($"Request processor is registered on {RequestHandle}"); IsOpen = true; }
public void CallAndroidPlugin() { // AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); // AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); // AndroidJavaObject context = activity.Call<AndroidJavaObject>("getApplicationContext"); using (AndroidJavaObject androidJavaClass = new AndroidJavaObject(ANDROID_NATIVE_PLUGIN_CLASS)) { AppLog.Info(androidJavaClass.ToString()); androidJavaClass.CallStatic("execute" /*, context */); } }
/// <summary> /// 加载服务 /// </summary> private void InitServer() { SplashScreenManager.ShowForm(this, typeof(SplashScreenLogin), true, true, false); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); SplashScrennHelper.SetInfo("加载基础信息...", 0, 20, 10, null); stopwatch.Stop(); AppLog.Info(string.Format("加载基础数据所耗时间:{0}毫秒", stopwatch.ElapsedMilliseconds)); }
private void OnDestroy() { if (null != gameObject) { AppLog.Info("OnDestroy {0}", this.gameObject.name); } if (null != resState) { resState.SubRef(); } }
public bool Delete() { AppLog.Info("DELETE PRODUCT - Starting..."); /*AppLog.Info("DELETE PRODUCT - Attempting to delete product from local database..."); * try * { * using (SqlConnection conn = new SqlConnection(Data.LocalConnStr)) * { * AppLog.Info("DELETE PRODUCT - Attempting to open connection to local database..."); * conn.Open(); * AppLog.Info("DELETE PRODUCT - Connection to local database opened successfully"); * * SqlCommand DeleteProduct = new SqlCommand("DELETE FROM Products WHERE Id = @Id;", conn); * DeleteProduct.Parameters.Add(new SqlParameter("Id", _Id)); * * DeleteProduct.ExecuteNonQuery(); * } * AppLog.Info(String.Format("DELETE PRODUCT - Product {0} deleted from local database successfully", * Name)); * } * catch (SqlException e) * { * _ErrMsg = "Error while deleting product from local database"; * AppLog.Error(_ErrMsg + ": " + e); * return false; * }*/ AppLog.Info("DELETE PRODUCT - Attempting to delete product from online database..."); try { using (SqlConnection conn = new SqlConnection(Data.OnlineConnStr)) { AppLog.Info("DELETE PRODUCT - Attempting to open connection to online database..."); conn.Open(); AppLog.Info("DELETE PRODUCT - Connection to online database opened successfully"); SqlCommand DeleteProduct = new SqlCommand("DELETE FROM Products WHERE Id = @Id;", conn); DeleteProduct.Parameters.Add(new SqlParameter("Id", _Id)); DeleteProduct.ExecuteNonQuery(); } AppLog.Info(String.Format("DELETE PRODUCT - Product {0} deleted from online database successfully", Name)); } catch (SqlException e) { _ErrMsg = "Error while deleting product from online database"; AppLog.Error(_ErrMsg + ": " + e); return(false); } AppLog.Info("DELETE PRODUCT - Success!"); return(true); }
protected void Page_PreRender(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); // Use this event for tasks that require that all other controls on the page be loaded. // Raised at the end of the event-handling stage. // Use this event for tasks that require that all other controls on the page be loaded. AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }
protected void Page_Init(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); // Raised after all controls have been initialized and any skin settings have been applied. // The Init event of individual controls occurs before the Init event of the page. // // Use this event to read or initialize control properties. AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }
public bool Delete() { AppLog.Info("DELETE TAG - Starting..."); AppLog.Info("DELETE TAG - Attempting to delete tag from local database..."); /*try * { * using (SqlConnection conn = new SqlConnection(Data.LocalConnStr)) * { * AppLog.Info("DELETE TAG - Attempting to open connection to local database..."); * conn.Open(); * AppLog.Info("DELETE TAG - Connection to <online/local> database opened successfully"); * * SqlCommand DeleteTag = new SqlCommand("DELETE FROM Tags WHERE Id = @Id;", conn); * DeleteTag.Parameters.Add(new SqlParameter("Id", _Id)); * * DeleteTag.ExecuteNonQuery(); * } * AppLog.Info(String.Format("DELETE TAG - Tag {0} deleted from local database successfully", Type.Value)); * } * catch (SqlException e) * { * _ErrMsg = "Error while deleting tag from local database"; * AppLog.Error("DELETE TAG - " + _ErrMsg + ": " + e); * return false; * }*/ AppLog.Info("DELETE TAG - Attempting to delete tag on online database..."); try { using (SqlConnection conn = new SqlConnection(Data.OnlineConnStr)) { AppLog.Info("DELETE TAG - Attempting to open connection to online database..."); conn.Open(); AppLog.Info("DELETE TAG - Connection to <online/local> database opened successfully"); SqlCommand DeleteTag = new SqlCommand("DELETE FROM t_Tags WHERE Id = @Id;", conn); DeleteTag.Parameters.Add(new SqlParameter("Id", _Id)); DeleteTag.ExecuteNonQuery(); } AppLog.Info(String.Format("DELETE TAG - Tag {0} deleted on online database successfully", Type.Value)); } catch (SqlException e) { _ErrMsg = "Error while deleting tag from online database"; AppLog.Error("DELETE TAG - " + _ErrMsg + ": " + e); return(false); } AppLog.Info("DELETE TAG - Success!"); return(true); }
//写入日志 public void writelog(string str) { try { AppLog.Info(str); writeblackbox(str); } catch (Exception e) { AppLog.Error(e.Message); } }
public bool Delete() { AppLog.Info("DELETE NOTE - Starting..."); /*AppLog.Info("DELETE NOTE - Attempting to delete note from local database..."); * try * { * using (SqlConnection conn = new SqlConnection(Data.LocalConnStr)) * { * AppLog.Info("DELETE NOTE - Attempting to open connection to local database..."); * conn.Open(); * AppLog.Info("DELETE NOTE - Connection to local database opened successfully"); * SqlCommand DeleteNote = new SqlCommand("DELETE FROM Notes WHERE Id = @Id;", conn); * DeleteNote.Parameters.Add(new SqlParameter("Id", _Id)); * * DeleteNote.ExecuteNonQuery(); * } * AppLog.Info(String.Format("DELETE NOTE - Note {0} deleted from local database successfully", Title)); * } * catch (SqlException e) * { * _ErrMsg = "Error deleting note from local database"; * AppLog.Error("DELETE NOTE - " + _ErrMsg + ": " + e); * return false; * }*/ AppLog.Info("DELETE NOTE - Attempting to delete note from online database..."); try { AppLog.Info("DELETE NOTE - Attempting to delete note from online database..."); using (SqlConnection conn = new SqlConnection(Data.OnlineConnStr)) { AppLog.Info("DELETE NOTE - Attempting to open connection to online database..."); conn.Open(); AppLog.Info("DELETE NOTE - Connection to online database opened successfully"); SqlCommand DeleteNote = new SqlCommand("DELETE FROM t_Notes WHERE Id = @Id;", conn); DeleteNote.Parameters.Add(new SqlParameter("Id", _Id)); DeleteNote.ExecuteNonQuery(); } AppLog.Info(String.Format("DELETE NOTE - Note {0} deleted from online database successfully", Title)); } catch (SqlException e) { _ErrMsg = "Error deleting note from online database"; AppLog.Error("DELETE NOTE - " + _ErrMsg + ": " + e); return(false); } AppLog.Info("DELETE NOTE - Success!"); return(true); }
protected void Page_Load(object sender, EventArgs e) { long startTicks = AppLog.Info("Enter", LOG_APPNAME, BASE_ERRORNUMBER + 0); txtErrorMessage.Text = (string)HttpContext.Current.Session["ErrorMessage"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat("FilePath ({0})", Request.FilePath); sb.AppendFormat("\nCurrentExecutionFilePath ({0})", Request.CurrentExecutionFilePath); txtInfo.Text = sb.ToString(); AppLog.Info("Exit", LOG_APPNAME, BASE_ERRORNUMBER + 0, startTicks); }