Initial Commit
This commit is contained in:
87
TomcatServer/AutoUpdater/AutoUpdater.csproj
Normal file
87
TomcatServer/AutoUpdater/AutoUpdater.csproj
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{BCEBDBDD-70F3-4FF4-A110-6C42DD905BA9}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AutoUpdater</RootNamespace>
|
||||
<AssemblyName>AutoUpdater</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\Target\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\Target\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="RemObjects.InternetPack, Version=7.0.63.1055, Culture=neutral, PublicKeyToken=3df3cad1b7aa5098, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\3rdParty\RemObjects\Server\RemObjects.InternetPack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RemObjects.SDK, Version=7.0.63.1055, Culture=neutral, PublicKeyToken=3df3cad1b7aa5098, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\3rdParty\RemObjects\Server\RemObjects.SDK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RemObjects.SDK.ZLib, Version=7.0.63.1055, Culture=neutral, PublicKeyToken=3df3cad1b7aa5098, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\3rdParty\RemObjects\Server\RemObjects.SDK.ZLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Yaulw, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\3rdParty\Sdaleo\Yaulw.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RegistrationWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pluto.MSL.Api\Pluto.MSL.Api.csproj">
|
||||
<Project>{B794609D-A93E-41E3-9291-84FC73412347}</Project>
|
||||
<Name>Pluto.MSL.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\RegistrationAPI\RegistrationAPI.csproj">
|
||||
<Project>{D8974253-F538-4AA6-B567-48B7CD574888}</Project>
|
||||
<Name>RegistrationAPI</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
36
TomcatServer/AutoUpdater/Program.cs
Normal file
36
TomcatServer/AutoUpdater/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Pluto.Registration;
|
||||
using Pluto.MSL.Api;
|
||||
|
||||
namespace AutoUpdater
|
||||
{
|
||||
class Program
|
||||
{
|
||||
const int SLEEP_INTERVAL_AFTER_EACH_UPDATE_CALL_TO_NOT_OVERLOAD_SERVER_IN_MS = 2000;
|
||||
const int NUMBER_OF_TIMES_TO_RUN_THRU_UPDATE_LOOP_TO_MAKE_SURE_WE_UPDATED_ALL = 3;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Client[] clients = RegistrationWrapper.GetClients();
|
||||
if (clients != null)
|
||||
{
|
||||
for (int i = 0; i < NUMBER_OF_TIMES_TO_RUN_THRU_UPDATE_LOOP_TO_MAKE_SURE_WE_UPDATED_ALL; ++i)
|
||||
{
|
||||
foreach (Client client in clients)
|
||||
{
|
||||
bool bCanConnect = Yaulw.Net.IPHostHelper.HasConnectivity(client.host.host, (uint)client.host.port, 0);
|
||||
if (bCanConnect)
|
||||
{
|
||||
API.SetNetworkSettings(client.host.host, (uint)client.host.port);
|
||||
API.UpdateServiceIfNeeded();
|
||||
System.Threading.Thread.Sleep(SLEEP_INTERVAL_AFTER_EACH_UPDATE_CALL_TO_NOT_OVERLOAD_SERVER_IN_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
TomcatServer/AutoUpdater/Properties/AssemblyInfo.cs
Normal file
36
TomcatServer/AutoUpdater/Properties/AssemblyInfo.cs
Normal file
@@ -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("AutoUpdater")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AutoUpdater")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[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("ca1b91d5-c929-4a11-af60-ac3c17e07083")]
|
||||
|
||||
// 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")]
|
||||
141
TomcatServer/AutoUpdater/RegistrationWrapper.cs
Normal file
141
TomcatServer/AutoUpdater/RegistrationWrapper.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Pluto.Api;
|
||||
using System.Net;
|
||||
using Pluto.Registration;
|
||||
|
||||
namespace AutoUpdater
|
||||
{
|
||||
internal static class RegistrationWrapper
|
||||
{
|
||||
// Allow the Registration wrapper to let the Service enter into a different 'disconnected' state
|
||||
internal static int HasConnectivityErrorCountInARow = 0;
|
||||
internal static int HasConnectivityErrorCountMaxBeforeStateChange = 10;
|
||||
internal static string RegistrationHOST = "";
|
||||
internal static uint RegistrationPORT = 0;
|
||||
|
||||
private const string DEFAULT_REGISTRATION_HOST_N_PORT_URL = "http://ppsmobile.mckesson.com/mobile1/REGURL.htm";
|
||||
private const string DEFAULT_REGISTRATION_HOST_URL = "ppsmobile.mckesson.com";
|
||||
private const int DEFAULT_REGISTRATION_CHANNEL_PORT = 443;
|
||||
|
||||
#region Connectivity
|
||||
|
||||
/// <summary>
|
||||
/// Check to make sure we can communicate with the Registration Service.
|
||||
/// Check the Server's ip & port for connectivity as well as that this
|
||||
/// computer has connectivity.
|
||||
/// This way we won't throw any connectivity errors, which is good.
|
||||
/// </summary>
|
||||
/// <returns>true, if successfully can connect, false otherwise</returns>
|
||||
private static bool HasConnectivity()
|
||||
{
|
||||
try
|
||||
{
|
||||
bool bCanConnect = false;
|
||||
bool bUseConfiguration = true;
|
||||
|
||||
// Try the overwritten Registration Host and Port first, if exists
|
||||
if (RegistrationHOST != "" && RegistrationPORT > 0)
|
||||
{
|
||||
bCanConnect = Yaulw.Net.IPHostHelper.HasConnectivity(RegistrationHOST, RegistrationPORT, 0);
|
||||
if (bCanConnect)
|
||||
bUseConfiguration = false;
|
||||
}
|
||||
|
||||
// Else, fall-back on the configuration, if we couldn't connect
|
||||
if (!bCanConnect)
|
||||
{
|
||||
bCanConnect = Yaulw.Net.IPHostHelper.HasConnectivity(DEFAULT_REGISTRATION_HOST_URL, (uint)DEFAULT_REGISTRATION_CHANNEL_PORT, 0);
|
||||
if (bCanConnect)
|
||||
bUseConfiguration = true;
|
||||
}
|
||||
|
||||
if (bCanConnect)
|
||||
{
|
||||
if (bUseConfiguration)
|
||||
{
|
||||
IPAddress ip = Yaulw.Net.IPHostHelper.GetIpForHost(DEFAULT_REGISTRATION_HOST_URL);
|
||||
RegistrationAPI.API.SetNetworkSettings(ip.ToString(), (uint)DEFAULT_REGISTRATION_CHANNEL_PORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPAddress ip = Yaulw.Net.IPHostHelper.GetIpForHost(RegistrationHOST);
|
||||
RegistrationAPI.API.SetNetworkSettings(ip.ToString(), RegistrationPORT);
|
||||
}
|
||||
HasConnectivityErrorCountInARow = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to retrieve the latest Host and Port Setting online
|
||||
try
|
||||
{
|
||||
string HostNPortSetOnline = Yaulw.Net.WCHelper.ScreenScrapeFromURL(DEFAULT_REGISTRATION_HOST_N_PORT_URL);
|
||||
if (!String.IsNullOrEmpty(HostNPortSetOnline))
|
||||
{
|
||||
RegistrationHOST = HostNPortSetOnline.Split(';')[0];
|
||||
RegistrationPORT = uint.Parse(HostNPortSetOnline.Split(';')[1]);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
// Try to connection one more time
|
||||
if (RegistrationHOST != "" && RegistrationPORT > 0)
|
||||
bCanConnect = Yaulw.Net.IPHostHelper.HasConnectivity(RegistrationHOST, RegistrationPORT, 0);
|
||||
|
||||
// if we can connect, we are Golden
|
||||
if (bCanConnect)
|
||||
{
|
||||
IPAddress ip = Yaulw.Net.IPHostHelper.GetIpForHost(RegistrationHOST);
|
||||
RegistrationAPI.API.SetNetworkSettings(ip.ToString(), RegistrationPORT);
|
||||
HasConnectivityErrorCountInARow = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Connectivity Errors too plentiful - Change the state of the service to reflect that
|
||||
if (HasConnectivityErrorCountInARow >= HasConnectivityErrorCountMaxBeforeStateChange)
|
||||
{
|
||||
//PlutoService.state = HostGUIDstate.no_connectivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
HasConnectivityErrorCountInARow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bCanConnect;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AutoUpdate / Client / Server Calls
|
||||
|
||||
public static Client[] GetClients()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HasConnectivity())
|
||||
{
|
||||
Client[] clients = RegistrationAPI.API.GetExternalClients();
|
||||
return clients;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
TomcatServer/AutoUpdater/app.config
Normal file
3
TomcatServer/AutoUpdater/app.config
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
|
||||
Reference in New Issue
Block a user