-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUtils.cs
More file actions
83 lines (63 loc) · 2.69 KB
/
Utils.cs
File metadata and controls
83 lines (63 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using log4net;
namespace Misc
{
class Utils
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const string TAG = "Utils: ";
public static void ExceptionHandleMsg(String TAGSent, String ErrorMessage, Exception exception)
{
try
{
Log.Error(TAGSent + ErrorMessage);
Log.Error("Exception message: " + exception.Message);
Log.Error("Exception Source: " + exception.Message);
Log.Error("Exception StackTrace: " + exception.StackTrace);
}
catch (Exception ex)
{
Log.Error(TAG + "Exception handling :" + ErrorMessage + exception.Message);
Log.Error(TAGSent + "Exception message: " + ex.Message);
Log.Error("Exception Source: " + ex.Message);
Log.Error("Exception StackTrace: " + ex.StackTrace);
}
}
public static void ErrorBox(string errormsg)
{
MessageBox.Show(errormsg, AnyConvertVM.Properties.Resources.AppTitle , MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static void ErrorBox(string errormsg,Exception ex)
{
MessageBox.Show(errormsg+"\nException messaage: "+ex, AnyConvertVM.Properties.Resources.AppTitle,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static void StartProcess(string args,string ProcessLocationFile,string workingDir)
{
try
{
Process BGprocess = new Process();
BGprocess.StartInfo.CreateNoWindow = true;
BGprocess.EnableRaisingEvents = true;
BGprocess.StartInfo.Arguments = args;
BGprocess.StartInfo.FileName = ProcessLocationFile; //@"./OpenVPN/openvpn.exe";
BGprocess.StartInfo.WorkingDirectory = workingDir; //@"./OpenVPN/";
BGprocess.StartInfo.UseShellExecute = false;
BGprocess.StartInfo.RedirectStandardOutput = true;
BGprocess.StartInfo.RedirectStandardError = true;
BGprocess.Start();
var std_out_error_reader = BGprocess.StandardError;
var std_out_data_reader = BGprocess.StandardOutput;
BGprocess.WaitForExit();
}
catch (Exception ex)
{
ExceptionHandleMsg(TAG, "Failed to load the Disk image.", ex);
}
}
}
}