/// <summary> /// full constructor takes both items of information passed by this EventArgs derivative. /// </summary> /// <param name="serverInformation">server information</param> /// <param name="appName">name of the application being Updated</param> public UpdaterActionEventArgs( ServerApplicationInfo serverInformation , string appName ) { // node may be null depending on raiser. _serverInformation = serverInformation; // string app name _appName = appName; }
/// <summary> /// full constructor takes both items of information passed by this EventArgs derivative. /// </summary> /// <param name="serverInformation">server information</param> /// <param name="appName">name of the application being Updated</param> public UpdaterActionEventArgs(ServerApplicationInfo serverInformation, string appName) { // node may be null depending on raiser. _serverInformation = serverInformation; // string app name _appName = appName; }
/// <summary> /// Deserializes the configuration in an XML file /// </summary> /// <param name="filePath">The XML file path</param> /// <returns>ServerApplicationInfo object</returns> public static ServerApplicationInfo Deserialize(string filePath) { ServerApplicationInfo serverInfo = null; XmlSerializer _serializer = new XmlSerializer(typeof(ServerApplicationInfo)); ApplicationUpdateManager.TraceWrite("[ServerApplicationInfo.Deserialize]", "RES_MESSAGE_DeserializeServerApplicationInfo", filePath); try { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { serverInfo = (ServerApplicationInfo)_serializer.Deserialize(new XmlTextReader(fs)); } // return it return(serverInfo); } catch (Exception e) { ApplicationUpdateManager.TraceWrite(e, "[ServerApplicationInfo.Deserialize]", "RES_EXCEPTION_CouldNotDeserializeServerApplicationInfo", e.Message, filePath); ExceptionManager.Publish(e); throw e; } }
/// <summary> /// constructor accepting just ServerApplicationInfo /// </summary> /// <param name="serverInformation">server information</param> public UpdaterActionEventArgs(ServerApplicationInfo serverInformation) : this(serverInformation, "") { }
/// <summary> /// Download the metadata from the server using the synchronous method /// from the IDownloader interface. /// </summary> /// <returns>true if the manifest downloaded and exists as a file at the correct path</returns> private bool IsServerManifestDownloaded() { bool isManifestValid = false; bool isManifestPresent = false; ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_DownloadManifestStarted", _application.Name, DateTime.Now.ToString(Resource.ResourceManager["RESX_DateTimeToStringFormat"], CultureInfo.CurrentCulture)); ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_SourceFileName", _application.Server.ServerManifestFile); ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_DestFileName", _application.Server.ServerManifestFileDestination); // wrap; we don't want to fall through if synch download of manifest fails, we want to wait for next poll time try { //Get the server metadata file (server manifest, commonly called "ServerConfig.xml") _downloader.Download( _application.Server.ServerManifestFile, _application.Server.ServerManifestFileDestination, TimeSpan.FromMilliseconds(_application.Server.MaxWaitXmlFile)); // ** // *** HERE WE POPULATE OUR _server OBJECT TO ENCAPSULATE MANIFEST INFO *** // ** // load the _server (ServerApplicationInfo) object w/ manifest data--THIS IS THE ONLY PLACE WE NEED POPULATE THIS _server = ServerApplicationInfo.Deserialize(_application.Server.ServerManifestFileDestination); } catch (Exception e) { // if exception during manifest download, log it but swallow here; // we don't want to drop out of main loop and end up restarting, we want to wait full interval string message = ApplicationUpdateManager.TraceWrite(e, "[DownloaderManager.IsServerManifestDownloaded]", "RES_EXCEPTION_MetadataCantBeDownloadedOrNotValid", _application.Name); Exception ex = new Exception(message, e); ExceptionManager.Publish(ex); // return false to alert that manifest download NOT successful return(false); } // ** FIRE MANIFEST DOWNLOADED EVENT ** ApplicationUpdateManager.TraceWrite("[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_DownloadManifestCompleted", _application.Server.ServerManifestFileDestination); this.OnServerManifestDownloaded( ); // ** // ** VALIDATE MANIFEST FILE ** // ** isManifestValid = ValidateManifestFile(); // check if it's still present isManifestPresent = File.Exists(_application.Server.ServerManifestFileDestination); return(isManifestPresent && isManifestValid); }
/// <summary> /// Download the metadata from the server using the synchronous method /// from the IDownloader interface. /// </summary> /// <returns>true if the manifest downloaded and exists as a file at the correct path</returns> private bool IsServerManifestDownloaded() { bool isManifestValid = false; bool isManifestPresent = false; ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_DownloadManifestStarted", _application.Name, DateTime.Now.ToString( Resource.ResourceManager[ "RESX_DateTimeToStringFormat" ], CultureInfo.CurrentCulture ) ); ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_SourceFileName", _application.Server.ServerManifestFile ); ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_DestFileName", _application.Server.ServerManifestFileDestination ); // wrap; we don't want to fall through if synch download of manifest fails, we want to wait for next poll time try { //Get the server metadata file (server manifest, commonly called "ServerConfig.xml") _downloader.Download( _application.Server.ServerManifestFile, _application.Server.ServerManifestFileDestination, TimeSpan.FromMilliseconds( _application.Server.MaxWaitXmlFile ) ); // ** // *** HERE WE POPULATE OUR _server OBJECT TO ENCAPSULATE MANIFEST INFO *** // ** // load the _server (ServerApplicationInfo) object w/ manifest data--THIS IS THE ONLY PLACE WE NEED POPULATE THIS _server = ServerApplicationInfo.Deserialize( _application.Server.ServerManifestFileDestination ); } catch( Exception e ) { // if exception during manifest download, log it but swallow here; // we don't want to drop out of main loop and end up restarting, we want to wait full interval string message = ApplicationUpdateManager.TraceWrite( e, "[DownloaderManager.IsServerManifestDownloaded]", "RES_EXCEPTION_MetadataCantBeDownloadedOrNotValid", _application.Name ); Exception ex = new Exception( message, e ); ExceptionManager.Publish( ex ); // return false to alert that manifest download NOT successful return false; } // ** FIRE MANIFEST DOWNLOADED EVENT ** ApplicationUpdateManager.TraceWrite( "[DownloaderManager.IsServerManifestDownloaded]", "RES_MESSAGE_DownloadManifestCompleted", _application.Server.ServerManifestFileDestination ); this.OnServerManifestDownloaded( ); // ** // ** VALIDATE MANIFEST FILE ** // ** isManifestValid = ValidateManifestFile(); // check if it's still present isManifestPresent = File.Exists( _application.Server.ServerManifestFileDestination ); return ( isManifestPresent && isManifestValid ); }
/// <summary> /// constructor accepting just ServerApplicationInfo /// </summary> /// <param name="serverInformation">server information</param> public UpdaterActionEventArgs( ServerApplicationInfo serverInformation ) : this(serverInformation, "") { }