Exemplo n.º 1
0
        /// <summary>
        /// Given a particular application name, cycles through each downloaded file and verifies using IValidator object;
        /// also first validates Manifest;
        /// if even one file fails, it deletes them all;
        /// when complete and if successful, it updates the clienConfig.xml file with new version info based on download.
        /// </summary>
        private void ValidateFilesAndCleanup()
        {
            bool isFileValid = false;


            //  set job status to Validating.  This is its default state until it cycles back through main Run loop.
            _dnldJob.Status = JobStatus.Validating;

            #region File Validation
            //  **
            //  **    VALIDATE ALL FILES        **
            //  **

            isFileValid = ValidateFiles();

            //  NOW that we've validated each file, check if they all passed...loop above BREAK's if one invalid found
            if (isFileValid)
            {
                //  Copy new files from temp dir to version-named dir
                FileUtility.CopyDirectory(
                    _application.Client.TempDir,
                    Path.Combine(_application.Client.BaseDir, _server.AvailableVersion)
                    );

                //  delete manifest + temp files
                RemoveManifestAndTempFiles();

                //  **
                //  **    UPDATE CLIENT FILE        **
                //  **

                ApplicationUpdateManager.TraceWrite("[DownloaderManager.ValidateFilesAndCleanup]", "RES_MESSAGE_UpdatingLocalConfigFile", _application.Client.XmlFile);

                //  serialize Clientappinfo to xml file
                ClientApplicationInfo.Save(
                    _application.Client.XmlFile,
                    Path.Combine(_application.Client.BaseDir, _server.AvailableVersion),
                    _server.AvailableVersion);
                //  **


                //  **
                //  **    RUN POST-PROCESSOR        **
                //  **
                RunPostProcessor();
                //  **


                //  **
                //          all files valid, RAISE EVENT to notify clients (if using validation)
                //  **
                if (_application.UseValidation)
                {
                    this.OnFilesValidated(  );
                }
            }
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method compares the recently downloaded file with the client version.
        /// If the server version is greater compared with the client version, the
        /// return value is <c>true</c>.
        /// </summary>
        /// <returns>true if client version older than server</returns>
        private bool IsClientUpdateNeeded()
        {
            ClientApplicationInfo clientInfo = null;

            //  get client info from its config file
            clientInfo = ClientApplicationInfo.Deserialize(_application.Client.XmlFile);

            ApplicationUpdateManager.TraceWrite("[DownloaderManager.ClientMustBeUpdated]", "RES_MESSAGE_ClientServerVersionCheck", _application.Name, clientInfo.InstalledVersion, _server.AvailableVersion);

            // get both versions, return comparison
            Version clientVersion = null;

            clientVersion = new Version(clientInfo.InstalledVersion);

            Version serverVersion = null;

            serverVersion = new Version(_server.AvailableVersion);

            return(serverVersion > clientVersion);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Uses an XML file as source of data.  Populate a ClientApplicationInfo object and return it.
        /// </summary>
        /// <param name="filePath">The XML file path</param>
        /// <returns></returns>
        public static ClientApplicationInfo Deserialize(string filePath)
        {
            // Cannot use xml-deserialization here
            ApplicationUpdateManager.TraceWrite("[ClientApplicationInfo.Deserialize]", "RES_MESSAGE_DeserializingClientApplicationInfo", filePath);

            //  create xml doc
            XmlDocument           doc           = new XmlDocument();
            XmlNode               node          = null;
            ClientApplicationInfo clientAppInfo = new ClientApplicationInfo();

            try
            {
                //  load it
                doc.Load(filePath);
                //  select the sub-node we want:
                //  NOTE that we are using a regular app.config, specifically AppStart.exe.config;
                //  SO we can't just treat it like a regular xml-deserialization because the serializer doesn't like the extra
                //  nodes.  Therefore just walk the XML to get values for class

                node = doc.SelectSingleNode("configuration/appStart/ClientApplicationInfo");

                //  set values
                clientAppInfo.AppFolderName    = node.SelectSingleNode("appFolderName").InnerText;
                clientAppInfo.AppExeName       = node.SelectSingleNode("appExeName").InnerText;
                clientAppInfo.InstalledVersion = node.SelectSingleNode("installedVersion").InnerText;
            }
            catch (Exception e)
            {
                string error = ApplicationUpdateManager.TraceWrite(e, "[ClientApplicationInfo.Deserialize]", "RES_EXCEPTION_CouldNotDeserializeClientApplicationInfo", e.Message, filePath);

                ExceptionManager.Publish(e);
                throw e;
            }
            //  return it
            return(clientAppInfo);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Uses an XML file as source of data.  Populate a ClientApplicationInfo object and return it.
        /// </summary>
        /// <param name="filePath">The XML file path</param>
        /// <returns></returns>
        public static ClientApplicationInfo Deserialize( string filePath )
        {
            // Cannot use xml-deserialization here
            ApplicationUpdateManager.TraceWrite( "[ClientApplicationInfo.Deserialize]", "RES_MESSAGE_DeserializingClientApplicationInfo", filePath );

            //  create xml doc
            XmlDocument doc = new XmlDocument();
            XmlNode node = null;
            ClientApplicationInfo clientAppInfo = new ClientApplicationInfo();

            try
            {
                //  load it
                doc.Load( filePath );
                //  select the sub-node we want:
                //  NOTE that we are using a regular app.config, specifically AppStart.exe.config;
                //  SO we can't just treat it like a regular xml-deserialization because the serializer doesn't like the extra
                //  nodes.  Therefore just walk the XML to get values for class

                node = doc.SelectSingleNode( "configuration/appStart/ClientApplicationInfo" );

                //  set values
                clientAppInfo.AppFolderName			= node.SelectSingleNode( "appFolderName" ).InnerText ;
                clientAppInfo.AppExeName			= node.SelectSingleNode( "appExeName" ).InnerText ;
                clientAppInfo.InstalledVersion		= node.SelectSingleNode( "installedVersion" ).InnerText ;
            }
            catch( Exception e )
            {

                string error = ApplicationUpdateManager.TraceWrite( e, "[ClientApplicationInfo.Deserialize]", "RES_EXCEPTION_CouldNotDeserializeClientApplicationInfo", e.Message,  filePath );

                ExceptionManager.Publish( e );
                throw e;

            }
            //  return it
            return clientAppInfo;
        }