public static List <UniqueProc> PIDlookup(string[] PIDarray) { List <UniqueProc> uniqueProcs = new List <UniqueProc>(); try { ManagementClass MgmtClass = new ManagementClass("Win32_Process"); for (int c = 0; c < PIDarray.Length - 1;) { foreach (ManagementObject mo in MgmtClass.GetInstances()) { if (mo["ProcessId"].ToString() == PIDarray[c]) { uniqueProcs.Add(new UniqueProc { Name = mo["Name"].ToString().Replace(".exe", ""), ProcessId = mo["ProcessId"].ToString(), Handle = mo["Handle"].ToString() }); } } c++; } } catch (Exception ex) { SimpleLog.Log(ex); } return(uniqueProcs); }
private static void SetUser(DataRowView drFile) { try { if (!string.IsNullOrEmpty(drFile["user"].ToString())) { return; } var user = SPTools.getFileLastModifiedUser(_config.SharePointURL, drFile["Fichier"].ToString()); drFile["user"] = user.login; var dr = _dset.Tables[1].NewRow(); dr["login"] = user.login; dr["email"] = user.mail; dr["title"] = user.title; DataTools.DataTools.ImportRowIfNotExists(_dset.Tables[1], dr, "login"); } catch (Exception uex) { if (_config.EnableLog) { SimpleLog.Log("Error setting user file :" + drFile["Fichier"] + " or " + drFile["Fichier"]); SimpleLog.Log(uex); } } }
/// <summary> /// Log an exception message at specified level /// </summary> /// <param name="level">level to log</param> /// <param name="debugMessage">message to log</param> /// <param name="exception">The exception to log</param> public void Log(LogLevel level, string debugMessage, Exception exception) { var messageToLog = String.Format("{0}|{1}", level, debugMessage); SimpleLog.Error(messageToLog); SimpleLog.Log(exception); }
public static void Main() { // Setup logger Settings.SetupLogger(); SimpleLog.Check(String.Format("{0} {1} {2}", Settings.ProgramName, Settings.ProgramVersion, "started")); // Load Settings Settings.LoadSettings(); // Open MainWindow App app = new App(); try { app.InitializeComponent(); MainWindow window = new MainWindow(); app.Run(window); } catch (Exception e) { SimpleLog.Log(e); } app.Shutdown(); SimpleLog.Info(String.Format("{0} {1} {2}", Settings.ProgramName, Settings.ProgramVersion, "closed")); SimpleLog.Flush(); SimpleLog.StopLogging(); }
private void EndAnalyse(bool canceled) { SimpleLog.Log("End analyse deleteing old file"); if (Analyser.Config.Bdd && !canceled) { DataTools.DataTools.Command("Delete From analyse Where Status=0;", Analyser.Config.ConnectionString);//remove all file taged as deleted } SimpleLog.Log("End analyse file deleted"); _dvDoublons = Analyser.Config.Bdd ? new DataView(Analyser.Dset.Tables[0], "isDuplicate = 1", "Hash asc", DataViewRowState.CurrentRows) : new DataView(Analyser.Dset.Tables[0], "isDuplicate = 1", "Hash asc", DataViewRowState.Added); SimpleLog.Log("Build stat"); Analyser.Stats.NumberOfDuplicateFile = Analyser.Dset.Tables[0].Rows.Count; Analyser.Stats.EndDate = DateTime.Now; Analyser.Stats.NumberOfDuplicateFile = _dvDoublons.Count; Analyser.Stats.TotalFileSize.Size = Analyser.Dset.Tables[0].Rows.Count == 0 ? 0 : (long)Analyser.Dset.Tables[0].Compute("Sum(Taille)", ""); toolStripStatusLabel1.Text = string.Format(Resources.Languages.Resources.Txt_Repertoire_Analyses, Analyser.Stats.NumberOfDir, Analyser.Stats.NumberOfFile, TimeSpan.FromSeconds(Analyser.Stats.Duration).ToReadableString());//_analyseDuration.ToReadableString() }
private void FrameworkOnUpdate(Framework framework) { if (t++ < 20) { return; } t = 0; if (Service.ClientState.LocalPlayer == null) { currentClassJob = 0; return; } var cj = Service.ClientState.LocalPlayer.ClassJob.Id; if (cj == currentClassJob) { return; } if (currentClassJob != 0 && crafterJobs.Contains(currentClassJob)) { SimpleLog.Log($"Switched Job from {currentClassJob}"); PerformCrafterBarSync(currentClassJob); } currentClassJob = cj; }
private void initDataBase() { try { ControlState(false); InitWorker(dbLoad, genericBackgroundWorkerEnd); _wf = new Waiting { label = { Text = Resources.Languages.Resources.Txt_Chargement_des_données }, progressBar = { Style = ProgressBarStyle.Marquee }, Wr = _gbw }; _gbw.RunWorkerAsync(); _wf.ShowDialog(); } catch (Exception e) { MessageBox.Show(Resources.Languages.Resources.Txt_LA_Base_est_inaccessible); Analyser.Config.Bdd = false; SimpleLog.Log("Database connection error :" + e.Message, SimpleLog.Severity.Error); } }
public static void casoError(Exception ex, string strSQL) { Globals.lastSQL = strSQL; SimpleLog.Log(ex); LoadingScreen.cerrarLoading(); MessageBox.Show(ex.Message + "\n" + strSQL); }
private async void GenerateWikiCodeButton_Click(object sender, RoutedEventArgs e) { Settings.LogButtonClicked(sender as Button); SimpleLog.Info(String.Format("Generate Wikicode, LeagueSize={0}, Table={1}, Qual1Count={2}, Qual2Count={3}, Results={4}, Template={5}", League.TeamCount, TableCheckBox.IsChecked, Qual1PlacesComboBox.SelectedIndex, Qual2PlacesComboBox.SelectedIndex, ResultsCheckBox.IsChecked, (WikiTemplateComboBox.SelectedItem as LeagueWikiTemplate).Name)); WikiCodeTextBox.Text = String.Empty; if (TableCheckBox.IsChecked == true) { try { await League.CalculateTableAsync(); WikiCodeTextBox.Text += await WikiHelper.GenerateTableCodeAsync(League, Qual1PlacesComboBox.SelectedIndex, Qual2PlacesComboBox.SelectedIndex); } catch (Exception ex) { SimpleLog.Log(ex); } } if (ResultsCheckBox.IsChecked == true && WikiTemplateComboBox.SelectedIndex >= 0) { try { WikiCodeTextBox.Text += await WikiHelper.GenerateResultsCodeAsync(League, WikiTemplateComboBox.SelectedItem as LeagueWikiTemplate); } catch (Exception ex) { SimpleLog.Log(ex); } } }
static bool Prefix_TryCreateDialogForVersionMismatchWarnings(ref bool __result, Action confirmedAction) { SimpleLog.Log("Checking mod mismatch"); bool isModListSame = ScribeMetaHeaderUtility.LoadedModsMatchesActiveMods(out _, out _); bool useVersionCompare = ModMismatchFormatter.useVersionCompare; if (isModListSame) { SimpleLog.Log("ModList are same"); if (useVersionCompare) { SimpleLog.Log("use version checking"); bool isVersionSame = MetaHeaderUtility.isVersionSame(ModContentPackExtension.GetModsFromSave(useVersionCompare), ModContentPackExtension.GetModsFromActive(useVersionCompare)); if (!isVersionSame) { SimpleLog.Log("Version is different..."); string warningMessage = "Checking mismatch for mod and mod versions... please wait"; Messages.Message(warningMessage, MessageTypeDefOf.SilentInput, false); CreateModMismatchWindow(confirmedAction, useVersionCompare); __result = true; return(false); } } __result = false; return(true); } else { SimpleLog.Log("Mod mismatch!"); CreateModMismatchWindow(confirmedAction, useVersionCompare); __result = true; return(false); } }
private bool FreeExclusiveDraw() { // Undoing the cursed shit requires a little more of the same cursed shit if (originalHandler == null) { return(true); } SimpleLog.Log($"Free Exclusive Draw"); var dalamud = (Dalamud.Dalamud)Plugin.PluginInterface.GetType().GetField("dalamud", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(Plugin.PluginInterface); if (dalamud == null) { return(false); } var interfaceManager = typeof(Dalamud.Dalamud).GetProperty("InterfaceManager", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(dalamud); if (interfaceManager == null) { return(false); } var eventField = interfaceManager.GetType().GetField("OnDraw", BindingFlags.Instance | BindingFlags.NonPublic); if (eventField == null) { return(false); } eventField.SetValue(interfaceManager, originalHandler); originalHandler = null; return(true); }
private void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { try { if (e.Value == null) { return; } var dataPropertyName = ((DataGridView)sender).Columns[e.ColumnIndex].DataPropertyName; if (dataPropertyName == "Taille") { e.Value = new FileSize((long)e.Value); return; } if (dataPropertyName == "Status") { e.Value = (Analyser.status)(Convert.ToInt32(e.Value)); } } catch (Exception ex) { if (Analyser.Config.EnableLog) { SimpleLog.Log(ex); } } }
private bool connectNetWorkDrive(string driveLetter, string path) { SimpleLog.Log("Création d'un lecteur réseau " + driveLetter, SimpleLog.Severity.Info); var process = new Process() { StartInfo = new ProcessStartInfo() { FileName = "Net", Arguments = string.Format("use {0}: {1} /persistent:no", driveLetter, path), RedirectStandardError = true, StandardErrorEncoding = Console.OutputEncoding,//Encoding.UTF8, UseShellExecute = false } }; process.Start(); process.WaitForExit(); int result = process.ExitCode; string stderr = process.StandardError.ReadToEnd(); if (result == 0) { return(true); } SimpleLog.Log(Resources.Languages.Resources.Error_Network_Drive + "\n" + stderr, SimpleLog.Severity.Warning); return(false); }
/// <summary> method fillTree /// <para>This method is used to initially fill the treeView control with a list /// of available drives from which you can search for the desired folder.</para> /// </summary> private void fillTree() { DirectoryInfo directory; string sCurPath = ""; // clear out the old values treeView1.Nodes.Clear(); // loop through the drive letters and find the available drives. foreach (char c in driveLetters) { sCurPath = c + ":\\"; try { // get the directory informaiton for this path. directory = new DirectoryInfo(sCurPath); // if the retrieved directory information points to a valid // directory or drive in this case, add it to the root of the // treeView. if (directory.Exists == true) { TreeNode newNode = new TreeNode(directory.FullName); treeView1.Nodes.Add(newNode); // add the new node to the root level. getSubDirs(newNode); // scan for any sub folders on this drive. } } catch (Exception doh) { SimpleLog.Log(doh.Message); } } }
public MainForm(string[] args) { InitializeComponent(); string job = null; if (args.Length > 0) { automaticMode = true; job = Config.DefaultJobPath + "\\" + args[0] + ".conf"; SimpleLog.Log("Automatic mode job id:" + args[0]); _jobId = new Guid(args[0]); } InitConfig(job); SimpleLog.Log("Config loaded"); SimpleLog.LogLevel = (SimpleLog.Severity)Analyser.Config.VerboseLevel; //SimpleLog.LogLevel = SimpleLog.Severity.Info; if (automaticMode) { if (!string.IsNullOrEmpty(Analyser.Config.SharePointDisk) && !string.IsNullOrEmpty(Analyser.Config.SharePointURL)) { connectNetWorkDrive(Analyser.Config.SharePointDisk, Analyser.Config.SharePointURL); } startAnalyse(); } }
/// <summary> /// Simuliert alle Spiele in der Liga /// </summary> public void Simulate() { SimpleLog.Log(String.Format("Simulate Matches in Football League ID={0}", ID)); foreach (var match in Matches) { match.Simulate(); } }
public static int Main() { ////Debugger.Launch(); var arguments = GetArguments(); GetAssemblyData(out var executingAssemblyLocation, out var executingAssemblyFileName); Configure(executingAssemblyFileName); SimpleLog.Info($"Full Commandline: {Environment.CommandLine}"); SimpleLog.Info($"Detected Attributes: {arguments}"); SimpleLog.Info($"RunHiddenConsole Executing Assembly FullName: {executingAssemblyFileName}"); var targetExecutablePath = GetTargetExecutablePath(executingAssemblyLocation, executingAssemblyFileName); if (targetExecutablePath == null) { SimpleLog.Error("Unable to find target executable name in own executable name."); return(-7001); } var startInfo = new ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = Directory.GetCurrentDirectory(), Arguments = arguments, FileName = targetExecutablePath, }; try { var proc = Process.Start(startInfo); if (proc == null) { SimpleLog.Error("Unable to start the target process."); return(-7002); } // process will close as soon as its waiting for interactive input. proc.StandardInput.Close(); proc.WaitForExit(); return(proc.ExitCode); } catch (Exception ex) { SimpleLog.Error("Starting target process threw an unknown Exception: " + ex); SimpleLog.Log(ex); return(-7003); } }
public override void Setup() { examineIsValidPtr = PluginInterface.TargetModuleScanner.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 C7 43 ?? ?? ?? ?? ??"); examineUpdatedAddress = PluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 89 04 9F"); SimpleLog.Log($"ExamineIsValidPtr: {examineIsValidPtr.ToInt64():X}"); Ready = true; }
/// <summary> /// Erstellt den Spielplan der Liga /// </summary> public void CreateMatches() { Matches.Clear(); switch (RoundMode) { case ELeagueRoundMode.SingleRound: int id = 0; for (int i = 0; i < Teams.Count; i++) { for (int j = i + 1; j < Teams.Count; j++) { Matches.Add(new FootballMatch(id++, Teams[i], Teams[j])); } } break; case ELeagueRoundMode.DoubleRound: foreach (var teamA in Teams) { foreach (var teamB in Teams) { if (teamA != teamB) { Matches.Add(new FootballMatch(Matches.Count, teamA, teamB)); } } } break; case ELeagueRoundMode.QuadrupleRound: foreach (var teamA in Teams) { foreach (var teamB in Teams) { if (teamA != teamB) { Matches.Add(new FootballMatch(Matches.Count, teamA, teamB)); } } } foreach (var teamA in Teams) { foreach (var teamB in Teams) { if (teamA != teamB) { Matches.Add(new FootballMatch(Matches.Count, teamA, teamB)); } } } break; } SimpleLog.Log(String.Format("Matches Created in Football League ID={0}", ID)); }
/// <summary> /// calculate for qualifier the note for a given file /// if force is set to true old value are replaced /// </summary> /// <param name="dr"></param> /// <param name="fi"></param> /// <param name="force"></param> private static void buildQualifierNote(DataRow dr, FileInfo fi, bool force = false) { var st = DateTime.Now; if (_qualifiers.Count == 0) { return; } if (!Qualifier.Qualifier.AllowedExtension.Contains(fi.Extension.ToLower()))//allowed extension { dr["q"] = -1; return; } if (fi.Length == 0 || fi.Length < _config.QualifierMini) { return; } var sum = 0; SimpleLog.Log($"Start qualifier file :" + fi.FullName, SimpleLog.Severity.Warning); var txt = ""; if (ContentHash.isOfficeFile(fi.Extension)) { txt = OfficeContentExtractor.GetContent(fi); } else { using (var sr = new StreamReader(fi.FullName)) { txt = sr.ReadToEnd(); } } if (txt != null)//content could be analysed { foreach (var q in _qualifiers) { if (dr[q.ColumnName] == DBNull.Value || force) //qulifier is not set or force is used { var r = q.Note(txt, fi); //get qualifier value dr[q.ColumnName] = r; //store in result table } sum += (int)dr[q.ColumnName]; //calculated aggregated qualifier value } dr["q"] = sum;//store sum in result table } Stats.AddQualifierDuration(DateTime.Now - st); //dr["debug"] = fi.FullName;//for debug purpose }
static void Prefix_SaveGame(string fileName) { SimpleLog.Log("Caching last saved file path"); bool WriteMeta = ModMismatchFormatter.writeMetaToSave; if (WriteMeta) { MetaHeaderUtility.StoreLastSavedFilePath(fileName); } }
public static void InitSettings() { try { // User Defined Globals: if (Properties.Settings.Default.logDir != "") { Globals.logDir = Properties.Settings.Default.logDir; } else { Properties.Settings.Default.logDir = Directory.GetCurrentDirectory().ToString(); Globals.logDir = Properties.Settings.Default.logDir; } Globals.blackList = Properties.Settings.Default.blackList; Globals.stealthMode = Properties.Settings.Default.stealthMode; if (Properties.Settings.Default.autoKill.ToString() != "") { Globals.autoKill = Properties.Settings.Default.autoKill; } // SQL Server Location: if (Properties.Settings.Default.databaseSvr != null) { Globals.databaseSvr = Properties.Settings.Default.databaseSvr; } if (Properties.Settings.Default.database != null) { Globals.database = Properties.Settings.Default.database; } if (Properties.Settings.Default.databaseTbl != null) { Globals.databaseTbl = Properties.Settings.Default.databaseTbl; } // SQL Server Authentication: if (Properties.Settings.Default.authMethod.ToString() != "") { Globals.authMethod = Properties.Settings.Default.authMethod; } Globals.sqlUser = Properties.Settings.Default.sqlUser; Globals.sqlPass = Properties.Settings.Default.sqlPass; Globals.connectionStringWinAuth = @"Data Source=" + Globals.databaseSvr + ";Initial Catalog=" + Globals.database + ";Integrated Security=True;"; Globals.connectionStringSQLAuth = @"Data Source=" + Globals.databaseSvr + ";Initial Catalog=" + Globals.database + ";User ID=(" + Globals.sqlUser + ");Password=(" + Globals.sqlPass + ");"; } catch (Exception ex) { SimpleLog.Log(ex); // Write any exception to Log file. } }
private void Update() { if (Input.GetKeyDown(KeyCode.Q)) { _log.StampType = StampType; _log.Log("请求退出"); _mgr.Quit(); } _mgr.Update(); }
public override void Setup() { if (Ready) { return; } try { processChatInputAddress = PluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? FE 86 ?? ?? ?? ?? C7 86 ?? ?? ?? ?? ?? ?? ?? ??"); Ready = true; } catch { SimpleLog.Log("Failed to find address for ProcessChatInput"); } }
public override void Setup() { if (Ready) { return; } try { processChatInputAddress = Service.SigScanner.ScanText("E8 ?? ?? ?? ?? FE 86 ?? ?? ?? ?? C7 86 ?? ?? ?? ?? ?? ?? ?? ??"); Ready = true; } catch { SimpleLog.Log("Failed to find address for ProcessChatInput"); } }
private void btnClear_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Are you sure you would like to Clear the Database?", "Clear Database", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { if (Program.Globals.authMethod == 1) { try { string query = "TRUNCATE TABLE " + Program.Globals.databaseTbl; using (SqlConnection connection = new SqlConnection(Program.Globals.connectionStringWinAuth)) { SqlCommand command = new SqlCommand(query, connection); command.Connection.Open(); command.ExecuteNonQuery(); command.Connection.Close(); } SimpleLog.Info("Cleared Database."); } catch (Exception ex) { SimpleLog.Log(ex); } } else { try { string query = "TRUNCATE TABLE " + Program.Globals.databaseTbl; // Defines the SQL query inline. // Defines the connection with the Windows Authentication connection string. using (SqlConnection connection = new SqlConnection(Program.Globals.connectionStringWinAuth)) { SqlCommand command = new SqlCommand(query, connection); command.Connection.Open(); // Opens the connection to the SQL Server command.ExecuteNonQuery(); // Executes the inline SQL query against the specified database. command.Connection.Close(); // Closes the the connection. } SimpleLog.Info("Cleared Database."); } catch (Exception ex) { SimpleLog.Log(ex); } } } }
private List <AddonResult> GetAtkUnitBaseAtPosition(Vector2 position) { SimpleLog.Log($">> GetAtkUnitBaseAtPosition"); var list = new List <AddonResult>(); var stage = AtkStage.GetSingleton(); var unitManagers = &stage->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList; for (var i = 0; i < UnitListCount; i++) { var unitManager = &unitManagers[i]; var unitBaseArray = &(unitManager->AtkUnitEntries); for (var j = 0; j < unitManager->Count; j++) { var unitBase = unitBaseArray[j]; if (unitBase->RootNode == null) { continue; } if (!(unitBase->IsVisible && unitBase->RootNode->IsVisible)) { continue; } var addonResult = new AddonResult() { UnitBase = unitBase }; if (list.Contains(addonResult)) { continue; } if (unitBase->X > position.X || unitBase->Y > position.Y) { continue; } if (unitBase->X + unitBase->RootNode->Width < position.X) { continue; } if (unitBase->Y + unitBase->RootNode->Height < position.Y) { continue; } addonResult.Nodes = GetAtkResNodeAtPosition(unitBase->UldManager, position); list.Add(addonResult); } } SimpleLog.Log($"<< GetAtkUnitBaseAtPosition"); return(list); }
/// <summary> /// Erstellt eine neue Fußballliga /// </summary> /// <param name="id">ID der Liga</param> /// <param name="name">Name der Liga</param> /// <param name="roundMode">Rundenmodus der Liga</param> /// <param name="teams">Teams der Liga</param> public FootballLeague(int id, string name, ELeagueRoundMode roundMode, FootballTeamCollection teams) : base(id, name) { RoundMode = roundMode; Teams = teams; SimpleLog.Log(String.Format("Create Football League: {0}", ToString())); Matches = new ObservableCollection <FootballMatch>(); CreateMatches(); CreateTable(); SimpleLog.Log(String.Format("Football League created with ID={0}", ID)); }
public static int[] TakeCurrent() { int[] pids = { }; try { pids = ProcessValidation.ListAllProcessIds(); } catch (Exception ex) { SimpleLog.Log(ex); } return(pids); }
public static void cerrar() { try { if (connection != null) { connection.Close(); } } catch (Exception ex) { SimpleLog.Log(ex); } try { if (connection != null) { connection.Dispose(); } } catch (Exception ex) { SimpleLog.Log(ex); } try { if (reader != null) { reader.Dispose(); } } catch (Exception ex) { SimpleLog.Log(ex); } try { if (command != null) { command.Dispose(); } } catch (Exception ex) { SimpleLog.Log(ex); } }