Skip to content

Commit

Permalink
Added core functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MrX13415 committed Feb 28, 2018
1 parent 3de9576 commit d1d89eb
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 24 deletions.
Binary file added Ressources/imageres_29.ico
Binary file not shown.
6 changes: 3 additions & 3 deletions Startup/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
</configuration>
15 changes: 0 additions & 15 deletions Startup/Program.cs

This file was deleted.

8 changes: 4 additions & 4 deletions Startup/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("Startup")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Service startup handler")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Startup")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © 2018 icelane.net")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
59 changes: 57 additions & 2 deletions Startup/Startup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,25 @@
<OutputType>Exe</OutputType>
<RootNamespace>Startup</RootNamespace>
<AssemblyName>Startup</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>2.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -30,23 +46,62 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>imageres_29.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Startup.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="VirtualDesktop, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\VirtualDesktop.2.0.0-beta3\lib\net46\VirtualDesktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Startup\Handler\ErrorInfo.cs" />
<Compile Include="Startup\Extentions\ProcessExtensions.cs" />
<Compile Include="Startup\Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Startup\Handler\StartupElement.cs" />
<Compile Include="Startup\Handler\StartupHandler.cs" />
<Compile Include="Windows\User32.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="imageres_29.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
26 changes: 26 additions & 0 deletions Startup/Startup/Extentions/ProcessExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;

namespace Startup.Extensions
{
public static class ProcessExtensions
{
public static IEnumerable<Process> GetChildProcesses(this Process process)
{
List<Process> children = new List<Process>();
ManagementObjectSearcher mos = new ManagementObjectSearcher(String.Format("Select * From Win32_Process Where ParentProcessID={0}", process.Id));

foreach (ManagementObject mo in mos.Get())
{
children.Add(Process.GetProcessById(Convert.ToInt32(mo["ProcessID"])));
}

return children;
}
}
}
28 changes: 28 additions & 0 deletions Startup/Startup/Handler/ErrorInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Startup.Handler
{
class ErrorInfo
{
public enum ErrorType
{
UnKnown,
ConfigFolderNotFound,
UnabelToMoveWindow
}

public ErrorType Type { get; private set; }

public String Message { get; private set; }

public ErrorInfo(ErrorType type, String message)
{
this.Type = type;
this.Message = message;
}
}
}
66 changes: 66 additions & 0 deletions Startup/Startup/Handler/StartupElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Startup.Handler
{
class StartupElement
{
public enum StartupStatus
{
Disabled,
Queue,
Delay,
Starting,
Done
}

public const string FileNameFormatRegex = @"(?<disabled>!?)?(?<index>\d+)\.(?<group>\d+) - (?<name>.+)(?:\.lnk)";

public FileInfo File { get; private set; }

public StartupStatus Status { get; internal set; }

public double Delay { get; internal set; }
public double TimeLeft { get; internal set; }

public bool Result { get; internal set; }
public ErrorInfo Error { get; internal set; }

public string ServiceName { get; internal set; }
public int StartIndex { get; internal set; }
public int GroupID { get; internal set; }

public StartupElement(string fileStr)
{
this.Delay = 5;
this.File = new FileInfo(fileStr);
this.Status = StartupStatus.Queue;

processFile();
}

private void processFile()
{
Regex r = new Regex(FileNameFormatRegex);
Match m = r.Match(File.Name);

if (m.Success)
{
var d = m.Groups["disabled"];
var i = m.Groups["index"];
var g = m.Groups["group"];
var n = m.Groups["name"];
if (d.Length > 0) this.Status = StartupStatus.Disabled;
StartIndex = int.Parse (i.Value);
GroupID = int.Parse(g.Value);
ServiceName = n.Value;
}
}

}
}
Loading

0 comments on commit d1d89eb

Please sign in to comment.