Initial Commit
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Installables.All;
|
||||
using Microsoft.Win32;
|
||||
using Yaulw.Assembly;
|
||||
using System.IO;
|
||||
using Yaulw.Xml;
|
||||
|
||||
namespace Installables.Setup.PlutoServerMSLService
|
||||
{
|
||||
public class InstallComponent : IInstallComponent , ISetup
|
||||
{
|
||||
#region Private Helpers
|
||||
|
||||
public const string BRIDGE_SERVICE_TITLE = Common_MediLytec.MediLytecPoundDef.BRIDGE_SERVICE_TITLE;
|
||||
public const string BRIDGE_SERVICE_ASSEMBLY = Common_MediLytec.MediLytecPoundDef.BRIDGE_SERVICE_ASSEMBLY;
|
||||
public const string BRIDGE_SERVICE_NAME = Common_MediLytec.MediLytecPoundDef.BRIDGE_SERVICE_NAME;
|
||||
|
||||
/// <summary>
|
||||
/// Write Service Configuration to the ImagePath for the Service
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool WriteServiceConfigurationToServiceInRegistry(InstallConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (RegistryKey service = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\services\\" + BRIDGE_SERVICE_TITLE, true))
|
||||
{
|
||||
// # Determine Image Path Parameter
|
||||
string ImagePathParameter = "";
|
||||
switch (config)
|
||||
{
|
||||
case InstallConfig.LytecMD:
|
||||
ImagePathParameter = " /Lytec";
|
||||
break;
|
||||
|
||||
case InstallConfig.MedisoftClinical:
|
||||
ImagePathParameter = " /Medisoft";
|
||||
break;
|
||||
}
|
||||
|
||||
// # Set Image Path Parameter
|
||||
string serviceAssembly = "\"" + AssemblyW.SpecializedAssemblyInfo.GetAssemblyPath(AssemblyW.AssemblyST.Executing) + "\\" + BRIDGE_SERVICE_ASSEMBLY + "\"";
|
||||
service.SetValue("ImagePath", serviceAssembly + ImagePathParameter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception) { /* ignore */ }
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IInstallComponent Members
|
||||
|
||||
public ComponentConfig.Component GetComponent()
|
||||
{
|
||||
return Common.EmbeddedConfig.SetupComponents.GetComponent("BridgeService");
|
||||
}
|
||||
|
||||
public bool BEFORE_INSTALLING_COMPONENT()
|
||||
{
|
||||
// Stop Service BRIDGE_SERVICE_NAME
|
||||
if (!Common.StopService(BRIDGE_SERVICE_NAME))
|
||||
{
|
||||
Common.Log.Error(String.Format("Couldn't stop the {0} Service.", BRIDGE_SERVICE_NAME));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the Service Configuration from the Registry
|
||||
InstallConfig config = Common_MediLytec.RetrieveInstallConfigFromRegistry();
|
||||
if (config == InstallConfig.LytecMD)
|
||||
{
|
||||
bool bSuccess = false;
|
||||
string result = Common.RunCmdLine("netsh firewall set portopening tcp 5000 BridgeService_LytecBridgeIn ENABLE ALL");
|
||||
bSuccess = result.Contains("successfully") || result.Contains("Ok.") || result.Contains("The service has not been started");
|
||||
if (bSuccess)
|
||||
{
|
||||
result = Common.RunCmdLine("netsh firewall set portopening tcp 5001 BridgeService_LytecMirthOut ENABLE ALL");
|
||||
bSuccess = result.Contains("successfully") || result.Contains("Ok.") || result.Contains("The service has not been started");
|
||||
}
|
||||
if (bSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Common.Log.Error(String.Format("Opening up ports for Lytec '{0}' failed", BRIDGE_SERVICE_NAME));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (config == InstallConfig.MedisoftClinical)
|
||||
{
|
||||
bool bSuccess = false;
|
||||
string result = Common.RunCmdLine("netsh firewall set portopening tcp 7000 BridgeService_MedisoftBridgeIn ENABLE ALL");
|
||||
bSuccess = result.Contains("successfully") || result.Contains("Ok.") || result.Contains("The service has not been started");
|
||||
if (bSuccess)
|
||||
{
|
||||
result = Common.RunCmdLine("netsh firewall set portopening tcp 7001 BridgeService_MedisoftMirthOut ENABLE ALL");
|
||||
bSuccess = result.Contains("successfully") || result.Contains("Ok.") || result.Contains("The service has not been started");
|
||||
}
|
||||
if (bSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Common.Log.Error(String.Format("Opening up ports for Medisoft '{0}' failed", BRIDGE_SERVICE_NAME));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool INSTALL_COMPONENT()
|
||||
{
|
||||
// Uninstall Bridge Service, if it exists, and re-install
|
||||
if (Common.ServiceExists(BRIDGE_SERVICE_NAME))
|
||||
UNINSTALL_COMPONENT();
|
||||
|
||||
string installUtil = Common.GetNetFrameworkUtilFileNameNPathFile("installutil.exe");
|
||||
string serviceAssembly = AssemblyW.SpecializedAssemblyInfo.GetAssemblyPath(AssemblyW.AssemblyST.Entry) + "\\" + BRIDGE_SERVICE_ASSEMBLY;
|
||||
if (!String.IsNullOrEmpty(installUtil))
|
||||
{
|
||||
Common.StopService(BRIDGE_SERVICE_NAME);
|
||||
string result = Common.RunCmdLine(installUtil + " \"" + serviceAssembly + "\"");
|
||||
bool bSuccess = !result.Contains("failed");
|
||||
if (bSuccess)
|
||||
{
|
||||
// Write the Service Configuration to the Registry
|
||||
InstallConfig config = Common_MediLytec.RetrieveInstallConfigFromRegistry();
|
||||
bSuccess = WriteServiceConfigurationToServiceInRegistry(config);
|
||||
}
|
||||
if (!bSuccess)
|
||||
{
|
||||
Common.Log.Error(String.Format("Errors Occured installing {0}.", BRIDGE_SERVICE_NAME));
|
||||
}
|
||||
return bSuccess;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AFTER_INSTALLING_COMPONENT()
|
||||
{
|
||||
// Make sure service exists
|
||||
if (!Common.ServiceExists(BRIDGE_SERVICE_NAME))
|
||||
{
|
||||
Common.Log.Error(String.Format("Service {0} does Not Exist. Install Failed", BRIDGE_SERVICE_NAME));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure Service is stopped
|
||||
Common.StopService(BRIDGE_SERVICE_NAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SUPPORTS_UNINSTALL()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool BEFORE_UNINSTALLING_COMPONENT()
|
||||
{
|
||||
// Stop Service BRIDGE_SERVICE_NAME
|
||||
if (!Common.StopService(BRIDGE_SERVICE_NAME))
|
||||
{
|
||||
Common.Log.Error(String.Format("Couldn't stop the {0} Service.", BRIDGE_SERVICE_NAME));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UNINSTALL_COMPONENT()
|
||||
{
|
||||
if (Common.ServiceExists(BRIDGE_SERVICE_NAME))
|
||||
{
|
||||
Common.StopService(BRIDGE_SERVICE_NAME);
|
||||
string installUtil = Common.GetNetFrameworkUtilFileNameNPathFile("installutil.exe");
|
||||
string serviceAssembly = AssemblyW.SpecializedAssemblyInfo.GetAssemblyPath(AssemblyW.AssemblyST.Entry) + "\\" + BRIDGE_SERVICE_ASSEMBLY;
|
||||
if (!String.IsNullOrEmpty(installUtil))
|
||||
{
|
||||
string result = Common.RunCmdLine(installUtil + " /u \"" + serviceAssembly + "\"");
|
||||
bool bSuccess = !result.Contains("failed");
|
||||
if(!bSuccess)
|
||||
Common.Log.Error(String.Format("Errors Occured uninstalling {0}.", BRIDGE_SERVICE_NAME));
|
||||
return bSuccess;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AFTER_UNINSTALLING_COMPONENT()
|
||||
{
|
||||
if (Common.ServiceExists(BRIDGE_SERVICE_NAME))
|
||||
{
|
||||
Common.Log.Error(String.Format("Service {0} Still Exists. Uninstall Failed", BRIDGE_SERVICE_NAME));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISetup Members
|
||||
|
||||
public void ComponentLoaded(ref SetupEvents subscribeToDesiredEvents)
|
||||
{
|
||||
subscribeToDesiredEvents.Before_Install += new SetupEvents.SetupEvent(subscribeToDesiredEvents_Before_Install);
|
||||
subscribeToDesiredEvents.After_Install += new SetupEvents.SetupEvent(subscribeToDesiredEvents_After_Install);
|
||||
subscribeToDesiredEvents.Ending_Setup += new SetupEvents.SetupEvent(subscribeToDesiredEvents_Ending_Setup);
|
||||
}
|
||||
|
||||
void subscribeToDesiredEvents_Ending_Setup()
|
||||
{
|
||||
if (Common.ServiceExists(BRIDGE_SERVICE_NAME))
|
||||
{
|
||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\McKesson\\Bridge\\BridgeConfig.xml";
|
||||
if (File.Exists(path))
|
||||
{
|
||||
XSerializer serialize = new XSerializer();
|
||||
// * Go over this *
|
||||
//XMLConfig config = serialize.ReadFromFile<XMLConfig>(path);
|
||||
//if (config != null)
|
||||
//{
|
||||
// // Read the Service Configuration from the Registry
|
||||
// InstallConfig sconfig = Common_MediLytec.RetrieveInstallConfigFromRegistry();
|
||||
// if (sconfig == InstallConfig.LytecMD && !String.IsNullOrEmpty(config.DefaultMapping.Lytec))
|
||||
// Common.StartService(BRIDGE_SERVICE_NAME);
|
||||
// else if(sconfig == InstallConfig.MedisoftClinical && !String.IsNullOrEmpty(config.DefaultMapping.Medisoft))
|
||||
// Common.StartService(BRIDGE_SERVICE_NAME);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void subscribeToDesiredEvents_Before_Install()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void subscribeToDesiredEvents_After_Install()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F1203E2C-B58B-49A6-9B6E-6F89949A06C5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Installables.Setup.PlutoServerMSLService</RootNamespace>
|
||||
<AssemblyName>Installables.Setup.PlutoServerMSLService</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<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>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Target\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Target\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Yaulw, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\MSLMobile\Components\Yaulw.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="InstallComponent.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory />
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Component.Setup.BridgeService")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Component.Setup.BridgeService")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("53b1ed79-4f04-4cf5-a80f-8d56da25dbfb")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Target\Debug\Installables.Setup.PlutoServerMSLService.dll
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Target\Debug\Installables.Setup.PlutoServerMSLService.pdb
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Installables\Installables.Setup.PlutoServerMSLService\obj\Debug\ResolveAssemblyReference.cache
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Installables\Installables.Setup.PlutoServerMSLService\obj\Debug\Installables.Setup.PlutoServerMSLService.dll
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Installables\Installables.Setup.PlutoServerMSLService\obj\Debug\Installables.Setup.PlutoServerMSLService.pdb
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Installables\Installables.Setup.PlutoServerMSLService\obj\Release\ResolveAssemblyReference.cache
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Target\Release\Installables.Setup.PlutoServerMSLService.dll
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Target\Release\Installables.Setup.PlutoServerMSLService.pdb
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Installables\Installables.Setup.PlutoServerMSLService\obj\Release\Installables.Setup.PlutoServerMSLService.dll
|
||||
C:\Users\Administrator\Projects\Pluto\Server\Installables\Installables.Setup.PlutoServerMSLService\obj\Release\Installables.Setup.PlutoServerMSLService.pdb
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user