Ejemplo n.º 1
0
        public clsXMLUpdate.eCheckResponse UpdateCheck(bool silent, ref IMessager iLoadFrm)
        {
            this.mFrm = iLoadFrm;
            this.ShowMessage(silent, ref iLoadFrm);
            this.SetMessage("Checking For Updates...", "");
            clsXMLUpdate.eCheckResponse eCheckResponse;
            if (!this.RequestXMLVersionInfo())
            {
                eCheckResponse = clsXMLUpdate.eCheckResponse.NoUpdates;
            }
            else
            {
                int updateId = -1;
                int num      = this.Updates.Length - 1;
                for (int index = 0; index <= num; index++)
                {
                    clsXMLUpdate.clsXMLItem update = this.Updates[index];
                    if (update.Version > 0f)
                    {
                        switch (update.nType)
                        {
                        case clsXMLUpdate.eUpdateType.AppUpdate:
                            if (update.Version > 1.962f)
                            {
                                updateId = index;
                                goto IL_E3;
                            }
                            break;

                        case clsXMLUpdate.eUpdateType.DBUpdate:
                            if (update.Version > DatabaseAPI.Database.Version)
                            {
                                updateId = index;
                                goto IL_E3;
                            }
                            break;
                        }
                    }
                }
IL_E3:
                if (updateId < 0)
                {
                    this.HideMessage();
                    eCheckResponse = clsXMLUpdate.eCheckResponse.NoUpdates;
                }
                else
                {
                    bool flag = true;
                    clsXMLUpdate.clsXMLItem update2 = this.Updates[updateId];
                    if (update2.DisplayName == "")
                    {
                        flag = false;
                    }
                    if (update2.LocalDest == "")
                    {
                        flag = false;
                    }
                    if (update2.Size < 1)
                    {
                        flag = false;
                    }
                    if (update2.SourceURI == "")
                    {
                        flag = false;
                    }
                    this.HideMessage();
                    if (flag)
                    {
                        string str5 = "An update for the ";
                        switch (this.Updates[updateId].nType)
                        {
                        case clsXMLUpdate.eUpdateType.AppUpdate:
                            str5 += "application";
                            break;

                        case clsXMLUpdate.eUpdateType.DBUpdate:
                            str5 += "database";
                            break;
                        }
                        str5 += " is available.\r\n";
                        clsXMLUpdate.clsXMLItem update3 = this.Updates[updateId];
                        str5 = str5 + "Update: " + update3.DisplayName + "\r\n";
                        str5 = string.Concat(new string[]
                        {
                            str5,
                            "Version: ",
                            Conversions.ToString(update3.Version),
                            " (",
                            Strings.Format(update3.VersionDate, "Short Date"),
                            ")\r\n"
                        });
                        if (!update3.Manual)
                        {
                            str5 = str5 + "Size: " + Strings.Format((double)update3.Size / 1024.0, "###,##0") + " KB\r\n";
                        }
                        str5 = str5 + "Notes: " + update3.Notes + "\r\n";
                        if (update3.Restart & !update3.Manual)
                        {
                            str5 += "\r\nUpdate will require the application to restart.\r\n";
                        }
                        if (update3.Manual)
                        {
                            str5 += "\r\nThis update requires you download and re-install fully. You will be directed to the download page.\r\n\r\nDownload this update now?";
                        }
                        else
                        {
                            str5 += "\r\nDownload and install this update now?";
                        }
                        if (Interaction.MsgBox(str5, MsgBoxStyle.YesNo | MsgBoxStyle.Information, "Automatic Update") == MsgBoxResult.Yes)
                        {
                            if (update3.Manual)
                            {
                                clsXMLUpdate.LaunchBrowser(update3.SourceURI);
                                return(clsXMLUpdate.eCheckResponse.Updates);
                            }
                            this.ShowMessage(silent, ref iLoadFrm);
                            if (this.RequestWithProgress(ref updateId))
                            {
                                this.HideMessage();
                                if (!update3.Restart)
                                {
                                    if (this.ApplyUpdate(ref updateId))
                                    {
                                        this.ShowMessage(silent, ref iLoadFrm);
                                        this.SetMessage("Loading updated data...", "");
                                        frmLoading iFrm = null;
                                        MainModule.MidsController.LoadData(ref iFrm);
                                        this.HideMessage();
                                        Interaction.MsgBox("Update applied!", MsgBoxStyle.Information, "Done.");
                                        return(clsXMLUpdate.eCheckResponse.Updates);
                                    }
                                    Interaction.MsgBox("Update not applied! Something didn't work out.", MsgBoxStyle.Information, "Oops.");
                                    return(clsXMLUpdate.eCheckResponse.FailedWithMessage);
                                }
                                else
                                {
                                    this.RestartNeeded = true;
                                    str5 = "Update package has been downloaded!\r\nYou need to close all other instances of Mids' Hero Designer, and then allow it to re-start for the automatic update to be applied.";
                                    if (!silent)
                                    {
                                        Interaction.MsgBox(str5, MsgBoxStyle.Information, "Update Downloaded");
                                        return(clsXMLUpdate.eCheckResponse.Updates);
                                    }
                                    if (Interaction.MsgBox(str5 + "\r\nQuit now?", MsgBoxStyle.YesNo | MsgBoxStyle.Information, "Update Downloaded") == MsgBoxResult.Yes)
                                    {
                                        clsXMLUpdate.LaunchSelfUpdate();
                                        ProjectData.EndApp();
                                    }
                                }
                            }
                            this.HideMessage();
                            return(clsXMLUpdate.eCheckResponse.FailedWithMessage);
                        }
                    }
                    eCheckResponse = clsXMLUpdate.eCheckResponse.NoUpdates;
                }
            }
            return(eCheckResponse);
        }
Ejemplo n.º 2
0
        bool ReadXMLString(ref clsXMLUpdate.clsXMLItem item, string xmlString)
        {
            bool flag;

            try
            {
                StringReader  input         = new StringReader(xmlString);
                XmlTextReader xmlTextReader = new XmlTextReader(input);
                if (xmlTextReader.IsStartElement("Planner"))
                {
                    xmlTextReader.MoveToAttribute("Version");
                    if (xmlTextReader.ReadAttributeValue())
                    {
                        Conversion.Val(xmlTextReader.Value);
                    }
                }
                int num = 0;
                do
                {
                    xmlTextReader.Read();
                    if (!(xmlTextReader.Name != item.NodeName))
                    {
                        break;
                    }
                    num++;
                }while (num <= 50);
                xmlTextReader.ReadStartElement(item.NodeName);
                xmlTextReader.ReadStartElement("Name");
                item.DisplayName = xmlTextReader.ReadString();
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("URI");
                item.SourceURI = xmlTextReader.ReadString();
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("LocalDest");
                item.LocalDest = FileIO.AddSlash(MyProject.Application.Info.DirectoryPath) + xmlTextReader.ReadString();
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("Size");
                item.Size = (int)Math.Round(Conversion.Val(xmlTextReader.ReadString().Replace(",", "").Replace(".", "")));
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("Version");
                item.Version = (float)Conversion.Val(xmlTextReader.ReadString());
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("Date");
                string[] strArray = xmlTextReader.ReadString().Split("/".ToCharArray());
                if (strArray[2].Length == 2)
                {
                    strArray[2] = "20" + strArray[2];
                }
                item.VersionDate = new DateTime(Conversions.ToInteger(strArray[2]), Conversions.ToInteger(strArray[1]), Conversions.ToInteger(strArray[0]));
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("Restart");
                string str = xmlTextReader.ReadString();
                item.Restart = (str == "YES" | str == "1");
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("Manual");
                string str2 = xmlTextReader.ReadString();
                item.Manual = (str2 == "YES" | str2 == "1");
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadStartElement("Notes");
                item.Notes = xmlTextReader.ReadString().Replace("^", "\r\n");
                xmlTextReader.ReadEndElement();
                xmlTextReader.ReadEndElement();
                xmlTextReader.Close();
                flag = true;
            }
            catch (Exception ex)
            {
                flag = false;
            }
            return(flag);
        }