Ejemplo n.º 1
0
        /// <summary>
        /// This function continues the initialization process by picking up where InitStepTwo_LoginCompleted() left off.
        /// Namely, we assume that we've gone through the login process and have just received word if the local copy of
        /// OSBIDE is up to date.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void InitStepThree_CheckServiceVersionComplete(object sender, LibraryVersionNumberCompletedEventArgs e)
        {
            string remoteVersionNumber = "";

            try
            {
                if (e != null)
                {
                    if (e.Result != null)
                    {
                        remoteVersionNumber = e.Result;
                    }
                }
            }
            catch (Exception ex)
            {
                _errorLogger.WriteToLog("Web service error: " + ex.Message, LogPriority.HighPriority);
                _hasStartupErrors = true;
                return;
            }

            //if we have a version mismatch, stop sending data to the server & delete localDb
            if (StringConstants.LibraryVersion.CompareTo(remoteVersionNumber) != 0)
            {
                _isOsbideUpToDate = false;

                //download updated library version
                WebClient web = new WebClient();
                web.DownloadFileCompleted += web_DownloadFileCompleted;
                web.Headers.Add(HttpRequestHeader.UserAgent, "OSBIDE");
                if (File.Exists(StringConstants.LocalUpdatePath) == true)
                {
                    try
                    {
                        File.Delete(StringConstants.LocalUpdatePath);
                    }
                    catch (Exception)
                    {
                    }
                }
                try
                {
                    web.DownloadFileAsync(new Uri(StringConstants.UpdateUrl), StringConstants.LocalUpdatePath);
                }
                catch (Exception)
                {
                }
            }

            //if we're all up to date and had no startup errors, then we can start sending logs to the server
            if (_isOsbideUpToDate == true && _hasStartupErrors == false)
            {
                _client.StartSending();
                ShowActivityFeedTool(this, EventArgs.Empty);
                _webServiceClient.GetMostRecentWhatsNewItemAsync();
            }
        }