private static void CriarTabelaSql() { if (!VerificarExisteTabela.ExisteColunaNaTabela("Versao_Migration", "ChaveVersao")) { using (var cmd = FactoryConnection.NewCommand()) { try { cmd.CommandText = @"CREATE TABLE `Versao_Migration`( `ChaveVersao` BIGINT NOT NULL AUTO_INCREMENT, `Data` datetime NOT NULL, `Versao` BIGINT NOT NULL, PRIMARY KEY(ChaveVersao))"; cmd.ExecuteNonQuery(); XLog.RegistraLog($"Tabela Versao_Migration.", "ModeloBanco"); } catch (Exception error) { throw new Exception($"Error criação da Tabela Versao_Migration: {error.Message}"); } } } if (!VerificarExisteTabela.ExisteRegistro("Versao_Migration", "versao", "1")) { using (var cmd = FactoryConnection.NewCommand()) { try { cmd.CommandText = @"INSERT INTO VERSAO_MIGRATION (DATA, VERSAO) VALUES(NOW(),'1')"; cmd.ExecuteNonQuery(); } catch (Exception eX) { throw new Exception($"Error preencher versão Versao_Migration: {eX.Message}"); } } } //var M01 = _contexto.Versao_Migration.FirstOrDefault(px => px.Versao == 1); //if (M01 is null) //{ // try // { // _contexto.Versao_Migration.Add(new Versao_Migration { Data = DateTime.Now, Versao = 1 }); // _contexto.SaveChanges(); // } // catch (Exception eX) // { // throw new Exception($"Error 'Versao_Migration': {eX.Message}"); // } //} }
/// <summary> /// 全局导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAllImort_Click(object sender, EventArgs e) { try { if (lstParaData.Count > 0) { DialogResult result = MessageBox.Show("导入会清空当前列表数据,是否继续?", "清空提示", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "PMC文件 (*.PMC)|*.PMC";; fileDialog.RestoreDirectory = true; fileDialog.FilterIndex = 1; if (fileDialog.ShowDialog() == DialogResult.OK) { string strFilePath = fileDialog.FileName; List <ParaData> lstTempParaData = GetParaData(strFilePath); lstAllParaData = lstTempParaData; BindTreeParaData(GetSelParaData()); } XLog.Write("导入成功"); } } else { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "PMC文件 (*.PMC)|*.PMC"; fileDialog.RestoreDirectory = true; fileDialog.FilterIndex = 1; if (fileDialog.ShowDialog() == DialogResult.OK) { string strFilePath = fileDialog.FileName; List <ParaData> lstTempParaData = GetParaData(strFilePath); lstAllParaData = lstTempParaData; BindTreeParaData(GetSelParaData()); } XLog.Write("导入成功"); } } catch { XLog.Write("导入参数文件错误"); MessageBox.Show("导入参数文件错误"); } }
// https://github.com/dotnet/coreclr/blob/master/src/coreclr/hosts/coreconsole/coreconsole.cpp private static int Main(string[] args) { EntryConfiguration configuration = new EntryConfiguration(); var localpath = XAssembliesBase.GetEntryAssemblyLocalPath(); if (localpath == null) { XLogBase.LogCritical("Failed to get the path to the current executable."); XConsole.Api.WaitForAcknowledgement(5000); // https://stackoverflow.com/questions/57615/how-to-add-a-timeout-to-console-readline return(-1); } char[] extension = null; //XIO.GetExtensionAsArray(localpath, Case.Lower); // Case.Default, Case.Unknown, Case.Upper extension[1] = 'd'; extension[2] = 'l'; extension[3] = 'l'; bool verbose = false; bool waitForDebugger; bool helpRequested = false; if (helpRequested) { ShowHelp(); return(-1); } else { if (verbose) { XLog.SetLogLevel(LogLevels.Trace); } ProgramResult result = TryRun(configuration); if (result.Successful) { Console.WriteLine("Execution succeeded"); return(0); } else { Console.WriteLine("Execution failed."); return(-1); } } }
public static void IrAUrl(String url) { try { Driver.GetIntance().Navigate().GoToUrl(url); XLog.Message("Ir a " + url + ", OK"); } catch (System.Exception) { XLog.Message("Ir a " + url + ", KO"); throw new System.Exception("No se pudo ir a " + url); } Driver.TaskPrint(); }
public static void BusquedaEnGoogle(String texto) { try { Text.On(InputDate.BuscadorGoogle(), texto); XLog.Message("Busqueda de " + texto + " en Google, OK"); } catch (System.Exception) { XLog.Message("Busqueda de " + texto + " en Google, KO"); throw new System.Exception("Fallo la busqueda en google."); } Driver.TaskPrint(); }
public static void buscar(String cadena) { try { Click.On(Button.BotonLupa()); Text.On(Button.BotonLupa(), cadena); XLog.Message("Buscar en Clarín, Ok"); } catch (System.Exception) { throw new System.Exception("Falló la busqueda de " + "'" + cadena + "' en Clarín"); } Driver.TaskPrint(); }
/// <summary> /// 删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { string strFloder = strPath + "weightCategory" + "\\" + selNode.Name; if (!System.IO.Directory.Exists(strFloder)) { MessageBox.Show("目录\"" + strFloder + "\"" + "不存在!"); return; } string[] files = System.IO.Directory.GetFiles(strFloder, "*.WEM"); if (files.Length > 0) { DialogResult result = MessageBox.Show("该分类下有算法文件!如果继续将把分类下的所有算法文件一起删除!是否继续?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result != DialogResult.Yes) { return; } else { Directory.Delete(strFloder, true); } } else { DialogResult result = MessageBox.Show("是否删除" + selNode.Name + "?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Directory.Delete(strFloder, true); } else { return; } } WeightSortData tempSortData = selNode.Tag as WeightSortData; if (tempSortData == null) { return; } lstWeightSort.Remove(tempSortData); treeViewWeightSort.Nodes[0].Nodes.Remove(selNode); XLog.Write("删除" + selNode.Name + "成功"); }
public static bool SeMuestraBotonBandejaDeEntrada() { try { XLog.Message("Validacion de Boton Bandeja de entrada, OK"); WaitUntil.ElementIsPresent(Button.BtnBandejaEntrada(), 380); return(Element.On(Button.BtnBandejaEntrada()).Text.Contains("Bandeja de entrada")); } catch (System.Exception) { XLog.Message("Validacion de Boton Bandeja de entrada, KO"); throw new System.Exception("Fallo la validacion del boton Bandejade entrada"); } }
/// <summary> /// Sends a ping packet to the server, keeping the connection alive. /// </summary> /// <returns>Nothing</returns> private void SendPingPacket() { // As long as there is a connection to the game server (sorry for the checks xP) while (m_cGameConnection != null && m_cGameConnection.Socket != null && m_cGameConnection.Socket.Connected) { PacketOut o = new PacketOut(9999); o.FinalizeLengthAndChecksum(); m_cGameConnection.SendTCP(o); XLog.Debug("Ping packet sent."); System.Threading.Thread.Sleep(1000 * 60); } m_tPingThread.Abort(); }
public void Initialize() { LoadSettings(); ProductLabel.Text = $"{Vsix.Author} {Vsix.Name} {Persistence.Edition} {Vsix.Version}"; if (Persistence.ServerState == 1) { StateLabel.Text = "Enabled"; EnableButton.Enabled = false; DisableButton.Enabled = true; ServerIdText.Enabled = false; MarkerText.Enabled = false; ProfileText.Text = ServerManager.GetProfileText(); LogoPicture.Image = IdeX.MainResource.idex_128; } else { StateLabel.Text = "Disabled"; EnableButton.Enabled = true; DisableButton.Enabled = false; ServerIdText.Enabled = true; MarkerText.Enabled = true; ProfileText.Text = ""; LogoPicture.Image = IdeX.MainResource.idex_gray_128; } UpdateLogfileButtons(); UpdateServerIdPicture(); UpdateMarkerPicture(); AutoUpdateCheckbox.Checked = (Persistence.AutoUpdateLogfileControls == 1) ? true : false; Timer = XTimer.CreateStoppedTimer(Timer_IntervalElapsed); Timer.StartMultiEvent(1000, 5000); ServerManager.ServerDisabled += ServerManager_ServerDisabled; ServerManager.ServerEnabled += ServerManager_ServerEnabled; ManualTT.SetToolTip(ServerIdLabel, XString.WrapWords(IdeX.MainResource.ServerIdLabelInfo)); ManualTT.SetToolTip(MarkerLabel, XString.WrapWords(IdeX.MainResource.MarkerLabelInfo)); ManualTT.SetToolTip(ProductCopyLink, XString.WrapWords(IdeX.MainResource.ProductCopyLinkInfo)); ManualTT.SetToolTip(ProfileLabel, XString.WrapWords(IdeX.MainResource.ProfileLabelInfo)); ManualTT.SetToolTip(ProfileCopyLink, XString.WrapWords(IdeX.MainResource.ProfileCopyLinkInfo)); ManualTT.SetToolTip(LogfileCopyLink, XString.WrapWords(IdeX.MainResource.LogfileCopyLinkInfo)); ManualTT.SetToolTip(LogCheckbox, XString.WrapWords(IdeX.MainResource.LogCheckboxInfo)); ManualTT.SetToolTip(AutoUpdateCheckbox, XString.WrapWords(IdeX.MainResource.AutoUpdateCheckboxInfo)); XLog.DeleteLogfileIfTooLarge(); }
public static void EliminarMensaje() { try { Click.On(Texto.MailEnviadoDePrueba()); Click.On(Button.BtnEliminarMail()); XLog.Message("Eliminar mensaje, OK"); } catch (Exception) { XLog.Message("Eliminar mensaje, KO"); throw new Exception("Fallo la eliminacion del mensaje"); } Driver.TaskPrint(); }
public void Print(string format, params object[] output) { if (OutputMode == XLog.OutputMode.Console) { Console.WriteLine(format, output); } else if (OutputMode == XLog.OutputMode.Debugger) { System.Diagnostics.Debug.Print(format, output); } else { XLog.WriteLine(format, output); } }
public override void Update() { base.Update(); foreach (var current in this.m_dicFlyTextManager) { try { current.Value.Update(); } catch (Exception e) { XLog.GetLog <DlgFlyTextSysInfo>().Fatal(e); } } }
protected override void WndProc(ref Message m) { if (m.Msg == WM_COPYDATA) { try { Handle_CopyData(ref m); } catch (Exception e) { XLog.Log($"HandleOnCopyData Exception: {e.Message} {e.StackTrace}"); } } base.WndProc(ref m); }
/// <summary> /// Logs your character into the game /// </summary> /// <param name="nIndex">Selected Character Index</param> /// <returns></returns> public void CreateLoginPacket(int nIndex) { try { PacketOut oLogin = new PacketOut(1); oLogin.FillString(m_iGameCharacterList.nList[nIndex - 1].szName, 61); oLogin.WriteByte((byte)m_iGameCharacterList.nList[nIndex - 1].nRace); oLogin.FinalizeLengthAndChecksum(); m_dHandles.Add(0, m_iGameCharacterList.nList[nIndex - 1].szName); m_cGameConnection.SendTCP(oLogin); XLog.AddMessage("", "", -5); // Clear box } catch (Exception e) { XLog.Log("Error while logging in to the server: {0}", e.Message); } }
public static void BuscarMensaje() { try { Enter.EnviarTexto(InputDate.BuscadorOutlook(), DatosDePrueba.asuntoMailPrueba); Click.On(Button.BtnLupaOutlook()); XLog.Message("Busqueda de mensaje, OK"); } catch (Exception) { XLog.Message("Busqueda de mensaje, KO"); throw new Exception("Fallo la busqueda del mensaje"); } Driver.TaskPrint(); }
public void GetTags() { // no get formats function! #if !DEBUG try { #endif this.Tags = new List <TagInfo>(proxy.getTags(this.User.blogid, this.User.username, this.User.password)); #if !DEBUG } catch (Exception ex) { XLog.Warn("Error", ": Couldn't get tags."); XLog.Warn("Error", ": {0}", ex.ToString()); } #endif OnPropertyChanged("Tags"); }
public static string EntityFromChar(this string input) { string output = HttpUtility.HtmlDecode(input); XLog.Clear(); foreach (KeyValuePair <string, string> k in CharacterEntityConversions.Conversions) { if (input.Contains(k.Key)) { XLog.WriteY("Entity", ": {0} — {1}\n", k.Key, k.Value); } output = output.Replace(k.Key, k.Value); } return(output); }
public static void IrAMensajesEnviados() { try { System.Threading.Thread.Sleep(10000); Click.On(Button.BtnMensajesEnviados()); XLog.Message("Ir a mensajes enviados, OK"); } catch (Exception) { XLog.Message("Ir a mensajes enviados, KO"); throw new Exception("Fallo ir a mensajes enviados"); } Driver.TaskPrint(); }
private void OnDataChanged(DataTable data, BindingList <CellMonitor> items) { if (data == null || data.Rows.Count <= 0 || data.Columns.Count <= 0) { if (items.Count > 0) { OnItemChanged(new CellMonitor[] { }, items); } } else { int rowCount = data.Rows.Count; int columnCount = data.Columns.Count; List <CellMonitor> changedList = new List <CellMonitor>(); List <CellMonitor> removedList = new List <CellMonitor>(); for (int i = 0; i < items.Count; i++) { CellMonitor item = items[i]; if (item == null) { continue; } var row = data.Select($"{PrimaryKey} = {item.PrimaryKeyValue}"); if (row == null || row.Length <= 0 || row.Length >= item.ColumnIndex) { removedList.Add(item); } else { string newValue = row[0].ItemArray[item.ColumnIndex].ToString(); if (!newValue.Equals(item.OriginValue)) { item.NewValue = newValue; changedList.Add((CellMonitor)item.Clone()); item.OriginValue = newValue; } else { XLog.LogLine($"No change of {item.OriginValue} -> {newValue}."); } } } if (changedList.Count > 0 || removedList.Count > 0) { OnItemChanged(changedList, removedList); } } }
static void ListenThreadProc() { try { lsock = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp); System.Net.IPEndPoint ipep = new System.Net.IPEndPoint(System.Net.IPAddress.Any, 55907); for (int i = 0; ; i++) { try { lsock.Bind(ipep); break; } catch (Exception e) { if (i >= 5) { throw; } System.Threading.Thread.Sleep(1000 * 4); continue; } } lsock.Listen(30); XLog.statuslog("Accepting connections on port " + ipep.Port); for (; ; ) { System.Net.Sockets.Socket dllclientSock = lsock.Accept(); System.Threading.Thread cthd = new System.Threading.Thread( new System.Threading.ParameterizedThreadStart(ClientThreadProc)); cthd.Name = "ClientThread" + (++userhit).ToString(); cthd.IsBackground = true; cthd.Start(dllclientSock); } } catch (System.Threading.ThreadAbortException e) { } catch (Exception e) { XLog.errorlog("ListenThreadProc exception: " + e.ToString()); } }
private void EnableButton_Click(object sender, EventArgs e) { Ide.StatusBar_Set("Enable starts..."); if (ServerManager.CanEnable()) { Thread.Sleep(250); XLog.DeleteLogfile(); Thread.Sleep(1250); ServerManager.EnableServer(); Ide.StatusBar_Set("Enable succeeded"); } else { Ide.StatusBar_Set("Enable failed, because the settings are invalid."); } }
protected override void OnStart(string[] args) { try { string service_base_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); System.Environment.CurrentDirectory = service_base_dir; lthd = new System.Threading.Thread(new System.Threading.ThreadStart(ListenThreadProc)); lthd.IsBackground = true; lthd.Start(); } catch (Exception e) { XLog.errorlog("OnStart exception: " + e.ToString()); } }
public XClientAuthEmulator(TCPManager man, Config.ConfigNet conf, string pAccount, string pPassword, XChat.XClientEmulator cBase) { m_szName = pAccount; m_szPassword = pPassword; m_cClientBase = cBase; try { m_cAuthConnection = new TCPConnection(man, null, this, conf); m_cAuthConnection.Start(); m_cAuthConnection.SendTCP(this.CreateVersionPacket()); m_cAuthConnection.SendTCP(this.CreateAESPacket()); } catch { XLog.Log("Can't connect to Authentication Server!"); } }
/// <summary> /// 开始该动作 /// </summary> public void Start() { if (!this.m_bStarted) { this.m_fStartTime = Time.time; this.m_bStarted = true; try { this.Trigger(); } catch (Exception ex) { XLog.GetLog <ActEvent>().Fatal(ex.ToString()); } } }
public static void EliminarSpam() { try { Click.On(Button.BtnCorreoNoDeseado()); Click.On(Button.BtnSeleccionarPrimerMail()); Click.On(Button.BtnEliminarMail()); XLog.Message("Eliminar Mail de Spam, OK"); } catch (Exception) { XLog.Message("Eliminar Mail de Spam, KO"); throw new Exception("Fallo eliminar mail de Spam"); } Driver.TaskPrint(); }
private void RCPViewData_Load(object sender, EventArgs e) { try { log = new XLog(); log.DirName = config.logpath; clWork = new CRcpData(config); param = new STVPRCPData(); param.dtbegin = new DateTime(2020, 07, 11, 1, 0, 0, 0); param.dtend = DateTime.Now; OnPermit("MAINRCP"); } catch (Exception ex) { MessageBox.Show(ex.TargetSite + " " + ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 编辑事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, EventArgs e) { if (selNode == null || selNode.Level != 2) { XLog.Write("请选择参数"); return; } if (selNode.Level == 2) { SettingPageData(); SetingPageButton("edit"); SettingTitle("edit"); strType = "edit"; } }
/// <summary> /// 从重量设计数据库导入数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void memu1FromWeightDesignDBImport_Click(object sender, EventArgs e) { BLLWeightDesignData bllWeightDesign = new BLLWeightDesignData(); List <WeightDesignData> lstWeightDesign = bllWeightDesign.GetListModel(); if (lstWeightDesign.Count == 0) { XLog.Write("数据库没有重量设计数据"); MessageBox.Show("数据库没有重量设计数据"); } strWeightDataType = "data1"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, lstWeightDesign, "weightDB"); form.ShowDialog(); }
/// <summary> /// 导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { if (lstCalculateRatio == null || lstCalculateRatio.Count == 0) { MessageBox.Show("没有修正因子数据不能导出"); return; } SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls"; dlg.OverwritePrompt = true; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.FileName = zedGraphControlPic.GraphPane.Title.Text; if (dlg.ShowDialog() == DialogResult.OK) { string strFilePath = dlg.FileName; if (strFilePath.EndsWith(".xml")) { List <string> lstContent = GetFileContent(lstCalculateRatio); CommonFunction.mWriteListStringToFile(strFilePath, lstContent); } if (strFilePath.EndsWith(".xls")) { DataTable table = GetExcelTable(lstCalculateRatio); int result = XCommon.FileStatus.FileIsOpen(strFilePath); if (result == 1) { MessageBox.Show("请关闭文件" + strFilePath + ",再导出"); } else { CommonExcel commonExcel = new CommonExcel(); commonExcel.lstColumn = GetExcelCloumn(); commonExcel.CreateExcel("example", strFilePath, "sheet1", table); } } XLog.Write("导出文件\"" + strFilePath + "\"成功"); } }
public void TestLog() { XLog log = new XLog(); log.Debug("Test"); }