示例#1
0
        private static void SetTsStatus(string strText)
        {
            if (strText == null)
            {
                Debug.Assert(false); return;
            }
            if (m_tsResultsViewer == null)
            {
                Debug.Assert(false); return;
            }

            try
            {
                ToolStrip pParent = m_tsResultsViewer.Owner;
                if ((pParent != null) && pParent.InvokeRequired)
                {
                    pParent.Invoke(new Priv_CfuSsd(CheckForUpdate.SetTsStatusDirect),
                                   new object[] { strText });
                }
                else
                {
                    CheckForUpdate.SetTsStatusDirect(strText);
                }
            }
            catch (Exception) { Debug.Assert(false); }
        }
示例#2
0
        private static void StructureFail()
        {
            Debug.Assert(false);

            if (m_tsResultsViewer == null)
            {
                MessageService.ShowWarning(KPRes.InvalidFileStructure);
            }
            else
            {
                CheckForUpdate.SetTsStatus(KPRes.ChkForUpdGotLatest + " " +
                                           KPRes.InvalidFileStructure);
            }
        }
示例#3
0
 private static void ReportStatusEx(string strLongText, string strShortText,
                                    bool bIsWarning)
 {
     if (m_tsResultsViewer == null)
     {
         if (bIsWarning)
         {
             MessageService.ShowWarning(strLongText);
         }
         else
         {
             MessageService.ShowInfo(strLongText);
         }
     }
     else
     {
         CheckForUpdate.SetTsStatus(strShortText);
     }
 }
示例#4
0
        private static void OnDownloadCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            string strXmlFile = NetUtil.GZipUtf8ResultToString(e);

            if (strXmlFile == null)
            {
                if (e.Error != null)
                {
                    if (m_tsResultsViewer == null)
                    {
                        MessageService.ShowWarning(KPRes.UpdateCheckingFailed, e.Error);
                    }
                    else if (e.Error.Message != null)
                    {
                        CheckForUpdate.SetTsStatus(KPRes.UpdateCheckingFailed + " " +
                                                   e.Error.Message);
                    }
                }
                else
                {
                    ReportStatusEx(KPRes.UpdateCheckingFailed, true);
                }

                return;
            }

            XmlDocument xmlDoc = new XmlDocument();

            try { xmlDoc.LoadXml(strXmlFile); }
            catch (Exception)
            {
                StructureFail();
                return;
            }

            XmlElement xmlRoot = xmlDoc.DocumentElement;

            if (xmlRoot == null)
            {
                StructureFail(); return;
            }
            if (xmlRoot.Name != ElemRoot)
            {
                StructureFail(); return;
            }

            uint uVersion = 0;

            foreach (XmlNode xmlChild in xmlRoot.ChildNodes)
            {
                if (xmlChild.Name == ElemVersionU)
                {
                    uint.TryParse(xmlChild.InnerText, out uVersion);
                }
                else if (xmlChild.Name == ElemVersionStr)
                {
                    // strVersion = xmlChild.InnerText;
                }
            }

            if (uVersion > PwDefs.Version32)
            {
                if (m_tsResultsViewer == null)
                {
                    if (MessageService.AskYesNo(KPRes.ChkForUpdNewVersion +
                                                MessageService.NewParagraph + KPRes.HomepageVisitQuestion))
                    {
                        WinUtil.OpenUrl(PwDefs.HomepageUrl, null);
                    }
                }
                else
                {
                    CheckForUpdate.SetTsStatus(KPRes.ChkForUpdNewVersion);
                }
            }
            else if (uVersion == PwDefs.Version32)
            {
                ReportStatusEx(KPRes.ChkForUpdGotLatest, false);
            }
            else
            {
                ReportStatusEx(KPRes.UnknownFileVersion, true);
            }
        }