Skip to content

Commit 9727754

Browse files
Release V1.0
1 parent 522a253 commit 9727754

11 files changed

Lines changed: 1217 additions & 175 deletions

File tree

AnyConvertVM-Installer/AnyConvertVM-Installer.vdproj

Lines changed: 811 additions & 0 deletions
Large diffs are not rendered by default.

AnyConvertVM.csproj

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,29 @@
1313
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1414
<WarningLevel>4</WarningLevel>
1515
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<PublishUrl>publish\</PublishUrl>
17+
<Install>true</Install>
18+
<InstallFrom>Disk</InstallFrom>
19+
<UpdateEnabled>false</UpdateEnabled>
20+
<UpdateMode>Foreground</UpdateMode>
21+
<UpdateInterval>7</UpdateInterval>
22+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
23+
<UpdatePeriodically>false</UpdatePeriodically>
24+
<UpdateRequired>false</UpdateRequired>
25+
<MapFileExtensions>true</MapFileExtensions>
26+
<ApplicationRevision>0</ApplicationRevision>
27+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
28+
<IsWebBootstrapper>false</IsWebBootstrapper>
29+
<UseApplicationTrust>false</UseApplicationTrust>
30+
<BootstrapperEnabled>true</BootstrapperEnabled>
1631
</PropertyGroup>
1732
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1833
<PlatformTarget>AnyCPU</PlatformTarget>
1934
<DebugSymbols>true</DebugSymbols>
2035
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
36+
<Optimize>true</Optimize>
2237
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
38+
<DefineConstants>TRACE</DefineConstants>
2439
<ErrorReport>prompt</ErrorReport>
2540
<WarningLevel>4</WarningLevel>
2641
</PropertyGroup>
@@ -33,12 +48,29 @@
3348
<ErrorReport>prompt</ErrorReport>
3449
<WarningLevel>4</WarningLevel>
3550
</PropertyGroup>
51+
<PropertyGroup>
52+
<StartupObject>AnyConvertVM.App</StartupObject>
53+
</PropertyGroup>
54+
<PropertyGroup>
55+
<ApplicationIcon>Symbol.ico</ApplicationIcon>
56+
</PropertyGroup>
57+
<PropertyGroup>
58+
<SignManifests>true</SignManifests>
59+
</PropertyGroup>
60+
<PropertyGroup>
61+
<ManifestCertificateThumbprint>4ECF7634D37FF17EDD0AB56AE9677A65610AA063</ManifestCertificateThumbprint>
62+
</PropertyGroup>
63+
<PropertyGroup>
64+
<SignAssembly>false</SignAssembly>
65+
</PropertyGroup>
3666
<ItemGroup>
3767
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
3868
<HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
3969
</Reference>
4070
<Reference Include="System" />
71+
<Reference Include="System.Configuration" />
4172
<Reference Include="System.Data" />
73+
<Reference Include="System.Web.Extensions" />
4274
<Reference Include="System.Windows.Forms" />
4375
<Reference Include="System.Xml" />
4476
<Reference Include="Microsoft.CSharp" />
@@ -127,5 +159,20 @@
127159
<Resource Include="Assets\Images\logo.png" />
128160
<Resource Include="Assets\Symbol.png" />
129161
</ItemGroup>
162+
<ItemGroup>
163+
<Resource Include="Symbol.ico" />
164+
</ItemGroup>
165+
<ItemGroup>
166+
<BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
167+
<Visible>False</Visible>
168+
<ProductName>Microsoft .NET Framework 4.6.2 %28x86 and x64%29</ProductName>
169+
<Install>true</Install>
170+
</BootstrapperPackage>
171+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
172+
<Visible>False</Visible>
173+
<ProductName>.NET Framework 3.5 SP1</ProductName>
174+
<Install>false</Install>
175+
</BootstrapperPackage>
176+
</ItemGroup>
130177
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
131178
</Project>

AnyConvertVM.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27703.2018
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyConvertVM", "AnyConvertVM.csproj", "{0516A2BA-A281-43D1-AC89-852AB289CCA3}"
77
EndProject
8+
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "AnyConvertVM-Installer", "..\AnyConvertVM-Installer\AnyConvertVM-Installer.vdproj", "{0C905B41-571C-4A1B-B050-5CA424BFFF36}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,8 @@ Global
1517
{0516A2BA-A281-43D1-AC89-852AB289CCA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{0516A2BA-A281-43D1-AC89-852AB289CCA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{0516A2BA-A281-43D1-AC89-852AB289CCA3}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{0C905B41-571C-4A1B-B050-5CA424BFFF36}.Debug|Any CPU.ActiveCfg = Debug
21+
{0C905B41-571C-4A1B-B050-5CA424BFFF36}.Release|Any CPU.ActiveCfg = Release
1822
EndGlobalSection
1923
GlobalSection(SolutionProperties) = preSolution
2024
HideSolutionNode = FALSE

App.config

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
5-
</startup>
3+
<configSections>
4+
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
5+
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
6+
<section name="ue_windows.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
7+
</sectionGroup>
8+
</configSections>
9+
<log4net>
10+
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
11+
<param name="File" value="AnyConvertVM.log" />
12+
<param name="AppendToFile" value="true" />
13+
<rollingStyle value="Size" />
14+
<maxSizeRollBackups value="10" />
15+
<maximumFileSize value="10MB" />
16+
<staticLogFileName value="true" />
17+
<layout type="log4net.Layout.PatternLayout">
18+
<param name="ConversionPattern" value="%date [%thread] %-5level %message%newline" />
19+
</layout>
20+
</appender>
21+
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
22+
<layout type="log4net.Layout.PatternLayout">
23+
<conversionPattern value="%date [%thread] %-5level %message%newline" />
24+
</layout>
25+
<filter type="log4net.Filter.LevelRangeFilter">
26+
<levelMin value="DEBUG" />
27+
<levelMax value="FATAL" />
28+
</filter>
29+
</appender>
30+
<root>
31+
<level value="DEBUG" />
32+
<appender-ref ref="LogFileAppender" />
33+
<appender-ref ref="ConsoleAppender" />
34+
</root>
35+
</log4net>
36+
<appSettings>
37+
<add key="log4net.Internal.Debug" value="true" />
38+
</appSettings>
39+
<startup>
40+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
41+
</startup>
642
</configuration>

Assets/Symbol.ico

134 KB
Binary file not shown.

ConvertClassActions.cs

Lines changed: 73 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Text;
88
using System.Threading;
99
using System.Threading.Tasks;
10+
using System.Windows.Forms;
1011
using log4net;
1112

1213
namespace AnyConvertVM
@@ -20,91 +21,117 @@ class ConvertClassActions
2021

2122
public enum FormatType { VDI,VHDX,RAW,QCOW2,VMDK,VHD,QED };
2223

23-
public static void ConvertQEMU(FormatType fromFormat, FormatType toFormat, String FromFolderWithFile, String FileName,String SaveFolderPath)
24+
public static bool ErrorFlag = false;
25+
public static int ConvertQEMU(FormatType fromFormat, FormatType toFormat, String FromFolderWithFile, String FileName,String SaveFolderPath)
2426
{
2527

2628
try
2729
{
2830
//qemu-img convert -f raw -O qcow2 image.img image.qcow2
2931
// String args = null;
30-
Console.WriteLine("Will start to convert " + fromFormat + " to " + toFormat);
3132

32-
//string fromFormatTextLower = fromFormat.ToString().ToLower();
33-
34-
//Log.Info(TAG + "Trying to update MTU values :" + Settings.MTU);
33+
Log.Debug(TAG+"Will start to convert " + fromFormat + " to " + toFormat);
3534

3635
string fromFromatArgs = fromFormat.ToString().ToLower();
3736
string toFromatArgs = toFormat.ToString().ToLower();
37+
3838
if (fromFromatArgs.Equals("vhd")) { fromFromatArgs = "vpc"; }
3939
if (toFromatArgs.Equals("vhd")) { toFromatArgs = "vpc"; }
4040

4141
String Arguments = "/c Tools\\qemu-img-win-x64-2_3_0\\qemu-img.exe convert -f " + fromFromatArgs + " -O " + toFromatArgs
42-
+ " "+ @FromFolderWithFile + " " + @SaveFolderPath+@"\"+FileName+"."+ toFormat.ToString().ToLower();
43-
Console.WriteLine("ARGs: " + Arguments);
42+
+ " " +"\""+ FromFolderWithFile +"\"" + " " + "\"" + SaveFolderPath+@"\"+FileName+"."+ toFormat.ToString().ToLower() + "\"";
43+
44+
//Misc.Utils.StartProcess(Arguments,"Tools\\qemu-img-win-x64-2_3_0\\qemu-img.exe");
45+
46+
Log.Debug(TAG+"Command: " + Arguments);
47+
ErrorFlag = false;
4448
var proc = new Process
4549
{
4650
StartInfo = new ProcessStartInfo
4751
{
4852
FileName = "cmd.exe",
4953
Arguments = Arguments,
50-
UseShellExecute = false,
51-
RedirectStandardOutput = false,
52-
CreateNoWindow = false
53-
5454
}
5555
};
56+
57+
proc.StartInfo.UseShellExecute = false;
58+
proc.StartInfo.CreateNoWindow = true;
59+
proc.EnableRaisingEvents = true;
60+
proc.StartInfo.RedirectStandardOutput = true;
61+
proc.StartInfo.RedirectStandardError = true;
5662
proc.Start();
63+
5764
var std_out_error_reader = proc.StandardError;
5865
var std_out_data_reader = proc.StandardOutput;
59-
WriteToLog(std_out_data_reader);
60-
WriteToLog(std_out_error_reader);
66+
WriteToLog(std_out_data_reader, "d");
67+
WriteToLog(std_out_error_reader, "e");
6168

62-
Thread.Sleep(10000);
6369
proc.WaitForExit();
70+
71+
if (ErrorFlag)
72+
{
73+
Log.Error(TAG+ "Failed to convert the disks.");
74+
return 1;
75+
}
76+
else
77+
{
78+
Log.Debug(TAG+ "Converted "+toFormat +" disk from "+fromFormat+". Converted disk saved at :"
79+
+SaveFolderPath + @"\" + FileName + "." + toFormat.ToString().ToLower());
80+
81+
MessageBox.Show("Converted "+toFormat +" disk from "+fromFormat+".Converted disk saved at: "
82+
+ SaveFolderPath + @"\" + FileName + "." + toFormat.ToString().ToLower());
83+
return 0;
84+
}
85+
6486
}
6587
catch (Exception ex)
6688
{
67-
89+
Misc.Utils.ExceptionHandleMsg(TAG, "Could not convert the image.", ex);
90+
Misc.Utils.ErrorBox("Could not convert the image.", ex);
91+
return 1;
6892
}
6993

7094
}
7195

72-
public static void WriteToLog(StreamReader std_out_reader)
96+
97+
public static void WriteToLog(StreamReader std_out_reader, string level)
7398
{
99+
try
100+
{
101+
while (!std_out_reader.EndOfStream)
102+
{
103+
// the point is that the stream does not end until the process has
104+
// finished all of its output.
105+
var nextLine = std_out_reader.ReadLine();
106+
string errorMsg = null;
107+
if (level.Equals("e"))
108+
{
109+
Log.Error(TAG + nextLine);
110+
ErrorFlag = true;
111+
//Misc.Utils.ErrorBox("Failed to convert the disks.");
112+
if ((nextLine.Contains("bad signature")) || (nextLine.Contains("Image not in")))
113+
{
114+
errorMsg = "The selected disk is not in the correct format.";
115+
}
116+
else
117+
errorMsg = "Failed to convert the disks";
118+
119+
Misc.Utils.ErrorBox(errorMsg+"\nError message: " + nextLine);
120+
}
121+
else
122+
Log.Debug(TAG + nextLine);
74123

75-
while (!std_out_reader.EndOfStream)
124+
}
125+
}
126+
catch (Exception ex)
76127
{
77-
// the point is that the stream does not end until the process has
78-
// finished all of its output.
79-
var nextLine = std_out_reader.ReadLine();
80-
81-
Console.WriteLine(nextLine);
82-
//if (level.Equals("e"))
83-
//{
84-
// Log.Error(TAG + nextLine);
85-
//}
86-
//else Log.Debug(TAG + nextLine);
87-
88-
//if (isVpnError(nextLine))
89-
//{
90-
// Connection.UeAgent.Client.onIpsecError(nextLine);
91-
//}
92-
//else
93-
//{
94-
// if (nextLine.Contains(OpenVPN_Parsing.VPN_CONNECTED))
95-
// {
96-
// Connection.UeAgent.Client.onIpsecConnected();
97-
// Thread.Sleep(3000);
98-
// }
99-
//}
100-
101-
102-
103-
104-
//CreateFile failed on TAP device:
128+
Misc.Utils.ExceptionHandleMsg(TAG, "Failed to write to Log", ex);
129+
//Misc.Utils.ErrorBox("Could not convert the image.", ex);
105130
}
106-
// Log.Debug(TAG+ line);
131+
107132
}
133+
134+
108135
}
109136

110137
}

0 commit comments

Comments
 (0)