示例#1
0
        private FileData ReadFileData(int fileRegisterIndex, Helper.Semantics semantics)
        {
            // gets latest version
            LatestVersion latestVersion = ReadVersion(fileRegisterIndex, semantics);

            // requests file data to dataServer with latest version
            List <string> dataServersIds = latestVersion.DataServerIds;

            // loops until  we get something from a read from any dataServer
            while (true)
            {
                foreach (string id in dataServersIds)
                {
                    string location      = fileRegister.FileMetadataAt(fileRegisterIndex).Locations[id];
                    string localFilename = fileRegister.FileMetadataAt(fileRegisterIndex).LocalFilenames[id];

                    IDataServerToClient dataServer = (IDataServerToClient)Activator.GetObject(
                        typeof(IDataServerToClient),
                        location);

                    try
                    {
                        FileData fileData = dataServer.Read(localFilename);

                        // update file registers
                        fileRegister.SetFileDataAt(fileRegisterIndex, fileData);
                        return(fileData);
                    }
                    catch (ProcessFailedException) { }
                    catch (ProcessFreezedException) { }
                }
            }
        }
示例#2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CpeUri.Length != 0)
            {
                hash ^= CpeUri.GetHashCode();
            }
            if (Architecture != 0)
            {
                hash ^= Architecture.GetHashCode();
            }
            if (latestVersion_ != null)
            {
                hash ^= LatestVersion.GetHashCode();
            }
            if (Maintainer.Length != 0)
            {
                hash ^= Maintainer.GetHashCode();
            }
            if (Url.Length != 0)
            {
                hash ^= Url.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#3
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((LatestVersion?.GetHashCode() ?? 0) * 397) ^ (Versions?.GetHashCode() ?? 0));
     }
 }
示例#4
0
        public void DoVersionTextUpdate()
        {
            string strLatestVersion = LatestVersion.Trim().TrimStart("Nightly-v");

            lblUpdaterStatus.Left = lblUpdaterStatusLabel.Left + lblUpdaterStatusLabel.Width + 6;
            if (strLatestVersion == LanguageManager.GetString("String_No_Update_Found").Trim())
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("Warning_Update_CouldNotConnect");
                cmdUpdate.Enabled     = false;
                return;
            }
            Version.TryParse(strLatestVersion, out Version objLatestVersion);
            int intResult = objLatestVersion?.CompareTo(_objCurrentVersion) ?? 0;

            if (intResult > 0)
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Update_Available").Replace("{0}", strLatestVersion).Replace("{1}", _strCurrentVersion);
            }
            else
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Up_To_Date").Replace("{0}", _strCurrentVersion).Replace("{1}", LanguageManager.GetString(_blnPreferNightly ? "String_Nightly" : "String_Stable")).Replace("{2}", strLatestVersion);
                if (intResult < 0)
                {
                    cmdRestart.Text    = LanguageManager.GetString("Button_Up_To_Date");
                    cmdRestart.Enabled = false;
                }
                cmdUpdate.Text = LanguageManager.GetString("Button_Redownload");
            }
            if (_blnPreferNightly)
            {
                lblUpdaterStatus.Text += " " + LanguageManager.GetString("String_Nightly_Changelog_Warning");
            }
        }
        private void LoadIncludes(Ini config)
        {
            { // check version
                Version ver = new Version(config.ReadSetting("csPublish", "Version"));
                if (LatestVersion.VersionIsNewer(ver, AssemblyVersionInfo.Program.AssemblyVersion))
                {
                    throw new Exception("Newer csPublish version required!");
                }
            }

            string[] includes = config.ReadSection("include", true);
            if (includes.Length > 0)
            {
                config.RemoveSection("include");
                foreach (string inc in includes)
                {
                    Ini sub = new Ini(inc);
                    LoadIncludes(sub);
                    foreach (string section in sub.GetSectionNames())
                    {
                        if (config.HasSection(section))
                        {
                            throw new NotSupportedException(string.Format("Main configuration and included {0} contains a section with the name {1}.", Path.GetFileName(sub.Name), section));
                        }

                        config.WriteSection(section, sub.ReadSection(section));
                    }
                }
            }
        }
示例#6
0
文件: GUIMod.cs 项目: yadenisyur/CKAN
 /// <summary>
 /// Initialize a GUIMod based on an InstalledModule
 /// </summary>
 /// <param name="instMod">The installed module to represent</param>
 /// <param name="registry">CKAN registry object for current game instance</param>
 /// <param name="current_ksp_version">Current game version</param>
 /// <param name="incompatible">If true, mark this module as incompatible</param>
 public GUIMod(InstalledModule instMod, IRegistryQuerier registry, KspVersionCriteria current_ksp_version, bool incompatible = false)
     : this(instMod.Module, registry, current_ksp_version, incompatible)
 {
     IsInstalled      = true;
     IsInstallChecked = true;
     InstallDate      = instMod.InstallTime;
     InstalledVersion = instMod.Module.version.ToString();
     if (LatestVersion == null || LatestVersion.Equals("-"))
     {
         LatestVersion = InstalledVersion;
     }
 }
示例#7
0
        static public LatestVersion GetVersion()
        {
            LatestVersion version = new LatestVersion();

            version.Major         = VersionMajor.ToString();
            version.Minor         = VersionMinor.ToString();
            version.Security      = VersionSecurity.ToString();
            version.Found         = true;
            version.LocalPath     = InstallationPath;
            version.VersionString = VersionString;

            return(version);
        }
示例#8
0
        public override string ToEncodedString()
        {
            const string filterPattern =
                @"{{""type"":""SingleColumnValueFilter"",""op"":""{0}"",""family"":""{1}"",""qualifier"":""{2}"",""ifMissing"":{3},""latestVersion"":{4},""comparator"":{{{5}}}}}";

            return(string.Format(
                       CultureInfo.InvariantCulture,
                       filterPattern,
                       CompareOperation.ToCodeName(),
                       Convert.ToBase64String(Family),
                       Convert.ToBase64String(Qualifier),
                       FilterIfMissing.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(),
                       LatestVersion.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(),
                       Comparator.ToEncodedString()));
        }
示例#9
0
文件: GUIMod.cs 项目: zxasqwsss/CKAN
 /// <summary>
 /// Initialize a GUIMod based on an InstalledModule
 /// </summary>
 /// <param name="instMod">The installed module to represent</param>
 /// <param name="registry">CKAN registry object for current game instance</param>
 /// <param name="current_game_version">Current game version</param>
 /// <param name="incompatible">If true, mark this module as incompatible</param>
 public GUIMod(InstalledModule instMod, IRegistryQuerier registry, GameVersionCriteria current_game_version, bool?incompatible = null)
     : this(instMod.Module, registry, current_game_version, incompatible)
 {
     IsInstalled      = true;
     IsInstallChecked = true;
     InstalledMod     = instMod;
     selectedMod      = instMod.Module;
     IsAutoInstalled  = instMod.AutoInstalled;
     InstallDate      = instMod.InstallTime;
     InstalledVersion = instMod.Module.version.ToString();
     if (LatestVersion == null || LatestVersion.Equals("-"))
     {
         LatestVersion = InstalledVersion;
     }
 }
示例#10
0
 public static void StartCheckVersion()
 {
     CheckVersionThread = new Thread(delegate()
     {
         if (!IsLatestVersion(out string description))
         {
             NewVersionFound?.Invoke(description);
         }
         else
         {
             LatestVersion?.Invoke();
         }
     });
     CheckVersionThread.Start();
 }
示例#11
0
 /// <summary>
 /// Initialize a GUIMod based on an InstalledModule
 /// </summary>
 /// <param name="instMod">The installed module to represent</param>
 /// <param name="registry">CKAN registry object for current game instance</param>
 /// <param name="current_game_version">Current game version</param>
 /// <param name="incompatible">If true, mark this module as incompatible</param>
 public GUIMod(InstalledModule instMod, IRegistryQuerier registry, GameVersionCriteria current_game_version, bool?incompatible = null)
     : this(instMod.Module, registry, current_game_version, incompatible)
 {
     IsInstalled      = true;
     IsInstallChecked = true;
     InstalledMod     = instMod;
     selectedMod      = instMod.Module;
     IsAutoInstalled  = instMod.AutoInstalled;
     InstallDate      = instMod.InstallTime;
     InstalledVersion = instMod.Module.version.ToString();
     if (LatestVersion == null || LatestVersion.Equals("-"))
     {
         LatestVersion = InstalledVersion;
     }
     // For mods not known to the registry LatestCompatibleMod is null, however the installed module might be compatible
     IsIncompatible = incompatible ?? LatestCompatibleMod == null && !instMod.Module.IsCompatibleKSP(current_game_version);
 }
示例#12
0
        private LatestVersion ParseVersion(string pageOutput)
        {
            LatestVersion latestVersion;

            if (Environment.Is64BitProcess) // if 64 bit process (not OS) then return x64 version else x86 version
            {
                int    x64Start       = pageOutput.IndexOf("Latest Version:x64");
                string x64VersionCode = pageOutput.Substring(x64Start, (pageOutput.IndexOf(":EOV", x64Start) - x64Start + 4));
                latestVersion = new LatestVersion(x64VersionCode);
            }
            else
            {
                int    x86Start       = pageOutput.IndexOf("Latest Version:x86");
                string x86VersionCode = pageOutput.Substring(x86Start, (pageOutput.IndexOf(":EOV", x86Start) - x86Start + 4));
                latestVersion = new LatestVersion(x86VersionCode);
            }

            return(latestVersion);
        }
示例#13
0
        public Update(UpdateType build)
        {
            UpdateType = build;

            Task.Run(() => SetVersion()).Wait();

            switch (UpdateType)
            {
            case UpdateType.MapleSeed:
                CurrentVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
                if (VersionStrings.Length == 2)
                {
                    LatestVersion = VersionStrings[0];
                }
                break;

            case UpdateType.MapleSeed2:
                CurrentVersion = Settings.Version;
                if (VersionStrings.Length == 2)
                {
                    LatestVersion = VersionStrings[1];
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            int currentVersion = int.Parse(CurrentVersion.Replace(".", ""));
            int latestVersion  = int.Parse(LatestVersion.Replace(".", ""));

            if (currentVersion != latestVersion)
            {
                TextLog.MesgLog.WriteLog($"[Version Mismatch] Latest Release: {LatestVersion}", Color.Gray);
            }

            if (currentVersion < latestVersion)
            {
                IsAvailable = true;
            }
        }
示例#14
0
 public void MergeFrom(Distribution other)
 {
     if (other == null)
     {
         return;
     }
     if (other.CpeUri.Length != 0)
     {
         CpeUri = other.CpeUri;
     }
     if (other.Architecture != 0)
     {
         Architecture = other.Architecture;
     }
     if (other.latestVersion_ != null)
     {
         if (latestVersion_ == null)
         {
             latestVersion_ = new global::Grafeas.V1.Version();
         }
         LatestVersion.MergeFrom(other.LatestVersion);
     }
     if (other.Maintainer.Length != 0)
     {
         Maintainer = other.Maintainer;
     }
     if (other.Url.Length != 0)
     {
         Url = other.Url;
     }
     if (other.Description.Length != 0)
     {
         Description = other.Description;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
示例#15
0
        /// <inheritdoc />
        public override string ToString()
        {
            var str = base.ToString();

            if (Id != 0)
            {
                str += $",Id={Id}";
            }

            if (!Name.IsEmpty())
            {
                str += $",Name={Name}";
            }

            if (!Description.IsEmpty())
            {
                str += $",Descr={Description}";
            }

            if (!PackageId.IsEmpty())
            {
                str += $",PackageId={PackageId},Repo={Repository}";
            }

            if (!Tags.IsEmpty())
            {
                str += $",Tags={Tags}";
            }

            if (Author != 0)
            {
                str += $",Author={Author}";
            }

            if (Price != null)
            {
                str += $",Price={Price}";
            }

            if (RenewPrice != null)
            {
                str += $",Renew={RenewPrice}";
            }

            str += $",Downloads={DownloadCount}";

            if (Rating != null)
            {
                str += $",Rating={Rating}";
            }

            if (!DocUrl.IsEmpty())
            {
                str += $",Doc={DocUrl}";
            }

            if (Picture != default)
            {
                str += $",Picture={Picture}";
            }

            str += $",Content={ContentType}";

            if (SupportedPlugins != null)
            {
                str += $",Supported={SupportedPlugins.Value}";
            }

            if (!Extra.IsEmpty())
            {
                str += $",Extra={Extra}";
            }

            if (!LatestVersion.IsEmpty())
            {
                str += $",Ver={LatestVersion}";
            }

            if (!IsApproved)
            {
                str += $",Approved={IsApproved}";
            }

            return(str);
        }
示例#16
0
        public override void Init(Kernel kernel)
        {
            _kernel = kernel;
            //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            Logger.ReportInfo(string.Format("Tyring to load {0} v{1} loaded by {2}.", Name, LatestVersion.ToString(), AppDomain.CurrentDomain.FriendlyName));
            bool isConfigurator = !AppDomain.CurrentDomain.FriendlyName.Contains("ehExtHost");

            if (Settings.ValidateSettings(kernel.ConfigData.InitialFolder, true))
            {
                if (Settings.Instance.LoadiTunesLibrary)
                {
                    if (Settings.ValidateiTunesLibrary(true))
                    {
                        try
                        {
                            BaseItem itunes;
                            string   message = "Refresh iTunes Library is set to true, this will force a rebuild of the iTunes Library, continue?";
                            string   heading = "Rebuild iTunes Library Cache";

                            if (Settings.Instance.ForceRefreshiTunesLibrary && (isConfigurator || Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog(message, heading, DialogButtons.Yes | DialogButtons.No, 60, true) == DialogResult.Yes))
                            {
                                itunes = iTunesLibrary.GetDetailsFromXml(kernel.ItemRepository.RetrieveItem(MusiciTunesGuid) as iTunesMusicLibrary);
                                Settings.Instance.ForceRefreshiTunesLibrary = false;
                                Settings.SaveSettingsFile();
                            }
                            else
                            {
                                itunes = kernel.ItemRepository.RetrieveItem(MusiciTunesGuid) ?? new iTunesLibrary().Library;
                            }
                            if (((iTunesMusicLibrary)itunes).LastUpdate != DateTime.MinValue && (itunes as iTunesMusicLibrary).LastUpdate < new System.IO.FileInfo(Settings.Instance.iTunesLibraryXMLPath).LastWriteTime)
                            {
                                message = "Your iTunes Library might have changed, do you want to rebuild it?";
                                if (isConfigurator || Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog(message, heading, DialogButtons.Yes | DialogButtons.No, 60, true) == DialogResult.Yes)
                                {
                                    itunes = iTunesLibrary.GetDetailsFromXml(kernel.ItemRepository.RetrieveItem(MusiciTunesGuid) as iTunesMusicLibrary);
                                }
                            }

                            itunes.Path = "";
                            itunes.Id   = MusiciTunesGuid;
                            Logger.ReportInfo("Music iTunes id - " + itunes.Id);
                            itunes.Name = Settings.Instance.iTunesLibraryVirtualFolderName;
                            Logger.ReportInfo("Music iTunes vf name - " + itunes.Name);
                            if (!string.IsNullOrEmpty(Settings.Instance.iTunesLibraryIcon))
                            {
                                itunes.PrimaryImagePath = Settings.Instance.iTunesLibraryIcon;
                            }

                            kernel.RootFolder.AddVirtualChild(itunes);
                            kernel.ItemRepository.SaveItem(itunes);
                            //add types to supported types
                            kernel.AddExternalPlayableItem(typeof(iTunesSong));
                            kernel.AddExternalPlayableFolder(typeof(iTunesAlbum));
                        }
                        catch (Exception ex)
                        {
                            Logger.ReportException("Cannot load iTunes Music Library", ex);
                        }
                    }
                }

                if (Settings.Instance.LoadNormalLibrary)
                {
                    if (Settings.ValidateNormalLibrary(true))
                    {
                        BaseItem music;

                        music    = kernel.ItemRepository.RetrieveItem(MusicNormalGuid) ?? new MusicPluginFolder();
                        music.Id = MusicNormalGuid;
                        Logger.ReportInfo("Music normal id - " + music.Id);
                        music.Path = Settings.Instance.NormalLibraryPath;
                        Logger.ReportInfo("Music normal path - " + music.Path);
                        music.Name = Settings.Instance.NormalLibraryVirtualFolderName;
                        Logger.ReportInfo("Music normal name - " + music.Name);
                        if (!string.IsNullOrEmpty(Settings.Instance.NormalLibraryIcon))
                        {
                            music.PrimaryImagePath = Settings.Instance.NormalLibraryIcon;
                        }
                        kernel.RootFolder.AddVirtualChild(music);
                        kernel.ItemRepository.SaveItem(music);
                        //add types to supported types
                        kernel.AddExternalPlayableItem(typeof(Song));
                        kernel.AddExternalPlayableFolder(typeof(ArtistAlbum));
                    }
                }
            }

            //add our music specific menu items
            if (!isConfigurator)
            {
                kernel.AddMenuItem(new MenuItem("Queue All", "resx://MediaBrowser/MediaBrowser.Resources/Lines", this.queue, new List <Type>()
                {
                    typeof(ArtistAlbum)
                }, new List <MenuType>()
                {
                    MenuType.Item, MenuType.Play
                }));
                kernel.AddMenuItem(new MenuItem("Queue", "resx://MediaBrowser/MediaBrowser.Resources/Lines", this.queue, new List <Type>()
                {
                    typeof(Song)
                }, new List <MenuType>()
                {
                    MenuType.Item, MenuType.Play
                }));
            }

            kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new SongResolver());
            kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new ArtistAlbumResolver());
            //kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new AlbumResolver());
            //kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new ArtistResolver());
            PlayableItemFactory.Instance.RegisterType <PlayableMusicFile>();
            PlayableItemFactory.Instance.RegisterType <PlayableMultiFileMusic>();
            //kernel.MetadataProviderFactories.Add(new MetadataProviderFactory(typeof(ArtistAlbumProvider)));
            kernel.PlaybackControllers.Insert(0, new PlaybackControllerMusic());
            MediaBrowser.Library.ItemFactory.Instance.AddFactory(MusicFolderModel.IsOne, typeof(MusicFolderModel));

            if (!Settings.Instance.LoadNormalLibrary && !Settings.Instance.LoadiTunesLibrary)
            {
                Logger.ReportInfo("Music plugin, iTunes nor Normal Music enabled, probably using folder specification (vf files) via configurator, PLEASE DO NOT USE VFs USE PLUGIN CONFIGURATOR.");
            }
        }
示例#17
0
        private LatestVersion ReadVersion(int fileRegisterIndex, Helper.Semantics semantics)
        {
            Console.WriteLine("READ VERSION " + fileRegisterIndex);

            string       filename     = fileRegister.FilenameAt(fileRegisterIndex);
            FileVersion  original     = fileRegister.FileDataAt(fileRegisterIndex).Version;
            FileMetadata fileMetadata = fileRegister.FileMetadataAt(fileRegisterIndex);
            // data server id / file data
            ConcurrentDictionary <string, FileVersion> reads = new ConcurrentDictionary <string, FileVersion>();
            int           requests      = 0;
            LatestVersion quorumVersion = null;


            //QUORUM
            while (true)
            {
                // voting
                ReadQuorum quorum = new ReadQuorum(fileMetadata.ReadQuorum, semantics);
                foreach (var entry in reads)
                {
                    FileVersion vote         = entry.Value;
                    string      dataServerId = entry.Key;

                    quorum.AddVote(vote, dataServerId);
                    if (quorum.CheckQuorum(vote, original))
                    {
                        quorumVersion = new LatestVersion(vote, quorum.DataServersIds(vote));
                        break;
                    }
                }

                // found the quorum file
                if (quorumVersion != null)
                {
                    break;
                }

                // if there are still pending requests
                // dont create new ones
                if (requests > 0)
                {
                    continue;
                }

                // if all the votes arrived at the quorum
                // stops when all requests are counted (requests = 0)
                if (quorum.Count == (requests + quorum.Count))
                {
                    // get possible new fileMetadata locations
                    // possible optimization
                    // check if there are no data servers
                    fileMetadata = OpenFileMetadata(filename);

                    // broadcast to all dataServers that have that file
                    foreach (var entry in fileMetadata.Locations)
                    {
                        string id            = entry.Key;
                        string location      = entry.Value;
                        string localFilename = fileMetadata.LocalFilenames[id];

                        // increment right away so it doesn't request untill its decremented
                        Interlocked.Increment(ref requests);
                        Thread request = new Thread(() =>
                        {
                            IDataServerToClient dataServer = (IDataServerToClient)Activator.GetObject(
                                typeof(IDataServerToClient),
                                location);
                            FileVersion fileVersion = null;
                            try
                            {
                                fileVersion = dataServer.Version(localFilename);
                            }
                            catch (ProcessFailedException) { }
                            catch (ProcessFreezedException) { }
                            finally
                            {
                                reads[id] = fileVersion;
                                Interlocked.Decrement(ref requests);
                            }
                        });
                        request.Start();
                    }
                }
            }

            return(quorumVersion);
        }
示例#18
0
        /// <inheritdoc />
        public override string ToString()
        {
            var str = base.ToString();

            if (Id != 0)
            {
                str += $",Id={Id}";
            }

            if (!Name.IsEmpty())
            {
                str += $",Name={Name}";
            }

            if (!Description.IsEmpty())
            {
                str += $",Descr={Description}";
            }

            if (!PackageId.IsEmpty())
            {
                str += $",PackageId={PackageId},Repo={Repository}";
            }

            if (!Tags.IsEmpty())
            {
                str += $",Tags={Tags}";
            }

            if (Author != 0)
            {
                str += $",Author={Author}";
            }

            if (MonthlyPrice != null || DiscountMonthlyPrice != null || RenewMonthlyPrice != null)
            {
                str += $",Monthly={MonthlyPrice},renew={RenewMonthlyPrice},disc={DiscountMonthlyPrice}";
            }

            if (AnnualPrice != null || DiscountAnnualPrice != null || RenewAnnualPrice != null)
            {
                str += $",Annual={AnnualPrice},renew={RenewAnnualPrice},disc={DiscountAnnualPrice}";
            }

            if (LifetimePrice != null || DiscountLifetimePrice != null)
            {
                str += $",Life={LifetimePrice} (disc={DiscountLifetimePrice})";
            }

            if (RenewPrice != null)
            {
                str += $",Renew={RenewPrice}";
            }

            str += $",Downloads={DownloadCount}";

            if (Rating != null)
            {
                str += $",Rating={Rating}";
            }

            if (!DocUrl.IsEmpty())
            {
                str += $",Doc={DocUrl}";
            }

            if (Picture != default)
            {
                str += $",Picture={Picture}";
            }

            str += $",Content={ContentType}";

            if (SupportedPlugins != null)
            {
                str += $",Supported={SupportedPlugins.Value}";
            }

            if (!Extra.IsEmpty())
            {
                str += $",Extra={Extra}";
            }

            if (!LatestVersion.IsEmpty())
            {
                str += $",Ver={LatestVersion}";
            }

            if (Flags != default)
            {
                str += $",Flags={Flags}";
            }

            if (PurchasedTill != default)
            {
                str += $",Purchased={PurchasedTill}";
            }

            return(str);
        }
示例#19
0
 /// <summary>
 /// 是否需要更新
 /// </summary>
 /// <returns></returns>
 public bool IsNeedUpdate()
 {
     // 最新版本不等于streaming,并且大于,需要更新
     return(!LatestVersion.Equals(StreamVersion) && LatestVersion.IsMax(LocalVersion));
 }
示例#20
0
        private LatestVersion ParseVersion(string pageOutput)
        {
            LatestVersion latestVersion;

            if (Environment.Is64BitProcess) // if 64 bit process (not OS) then return x64 version else x86 version
            {
                int x64Start = pageOutput.IndexOf("Latest Version:x64");
                string x64VersionCode = pageOutput.Substring(x64Start, (pageOutput.IndexOf(":EOV", x64Start) - x64Start + 4));
                latestVersion = new LatestVersion(x64VersionCode);
            }
            else
            {
                int x86Start = pageOutput.IndexOf("Latest Version:x86");
                string x86VersionCode = pageOutput.Substring(x86Start, (pageOutput.IndexOf(":EOV", x86Start) - x86Start + 4));
                latestVersion = new LatestVersion(x86VersionCode);
            }

            return latestVersion;
        }
        public void Apply(IDomainEvent domainEvent)
        {
            Contract.Assume(domainEvent != null);

            _revisions.Add(new DomainEventRevision(CreateRevisionIdentity(), LatestVersion = LatestVersion.Increment(), domainEvent));
        }
        public void Apply(IReadOnlyCollection <IDomainEvent> domainEvents)
        {
            Contract.Assume(domainEvents != null);

            _revisions.Add(new DomainEventRevision(CreateRevisionIdentity(), LatestVersion = LatestVersion.Increment(), domainEvents));
        }
示例#23
0
文件: Client.cs 项目: jfloff/PADI
        private LatestVersion ReadVersion(int fileRegisterIndex, Helper.Semantics semantics)
        {
            Console.WriteLine("READ VERSION " + fileRegisterIndex);

            string filename = fileRegister.FilenameAt(fileRegisterIndex);
            FileVersion original = fileRegister.FileDataAt(fileRegisterIndex).Version;
            FileMetadata fileMetadata = fileRegister.FileMetadataAt(fileRegisterIndex);
            // data server id / file data
            ConcurrentDictionary<string, FileVersion> reads = new ConcurrentDictionary<string, FileVersion>();
            int requests = 0;
            LatestVersion quorumVersion = null;

            //QUORUM
            while (true)
            {
                // voting
                ReadQuorum quorum = new ReadQuorum(fileMetadata.ReadQuorum, semantics);
                foreach (var entry in reads)
                {
                    FileVersion vote = entry.Value;
                    string dataServerId = entry.Key;

                    quorum.AddVote(vote, dataServerId);
                    if (quorum.CheckQuorum(vote, original))
                    {
                        quorumVersion = new LatestVersion(vote, quorum.DataServersIds(vote));
                        break;
                    }
                }

                // found the quorum file
                if (quorumVersion != null) break;

                // if there are still pending requests
                // dont create new ones
                if (requests > 0) continue;

                // if all the votes arrived at the quorum
                // stops when all requests are counted (requests = 0)
                if (quorum.Count == (requests + quorum.Count))
                {
                    // get possible new fileMetadata locations
                    // possible optimization
                    // check if there are no data servers
                    fileMetadata = OpenFileMetadata(filename);

                    // broadcast to all dataServers that have that file
                    foreach (var entry in fileMetadata.Locations)
                    {
                        string id = entry.Key;
                        string location = entry.Value;
                        string localFilename = fileMetadata.LocalFilenames[id];

                        // increment right away so it doesn't request untill its decremented
                        Interlocked.Increment(ref requests);
                        Thread request = new Thread(() =>
                        {
                            IDataServerToClient dataServer = (IDataServerToClient)Activator.GetObject(
                                typeof(IDataServerToClient),
                                location);
                            FileVersion fileVersion = null;
                            try
                            {
                                fileVersion = dataServer.Version(localFilename);
                            }
                            catch (ProcessFailedException) { }
                            catch (ProcessFreezedException) { }
                            finally
                            {
                                reads[id] = fileVersion;
                                Interlocked.Decrement(ref requests);
                            }
                        });
                        request.Start();
                    }
                }
            }

            return quorumVersion;
        }
示例#24
0
        public void DoVersionTextUpdate()
        {
            string strLatestVersion = LatestVersion.Trim();

            lblUpdaterStatus.Left = lblUpdaterStatusLabel.Left + lblUpdaterStatusLabel.Width + 6;
            if (strLatestVersion == LanguageManager.GetString("String_No_Update_Found").Trim())
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("Warning_Update_CouldNotConnect");
                cmdUpdate.Enabled     = false;
                return;
            }

            string strCurrentVersion = CurrentVersion.Trim().TrimStart("Nightly-v");

            string[] strCurrentVersionNumbers = strCurrentVersion.Split('.');
            strLatestVersion = strLatestVersion.TrimStart("Nightly-v");
            string[] strLatestVersionNumbers = strLatestVersion.Split('.');

            bool blnNeedsUpdate = false;
            int  intLatestTemp  = 0;
            int  intCurrentTemp = 0;
            // Note: this value only matters if blnNeedsUpdate is false, otherwise the relevant code will not run anyway
            bool blnDisableDownloadButton = true;

            for (int i = 0; i < strLatestVersionNumbers.Length; ++i)
            {
                if (strCurrentVersion.Length <= i)
                {
                    blnNeedsUpdate = true;
                    break;
                }
                if (int.TryParse(strLatestVersionNumbers[i], out intLatestTemp) && int.TryParse(strCurrentVersionNumbers[i], out intCurrentTemp))
                {
                    if (intLatestTemp != intCurrentTemp)
                    {
                        if (intLatestTemp > intCurrentTemp)
                        {
                            blnNeedsUpdate = true;
                        }
                        else
                        {
                            blnDisableDownloadButton = false;
                        }
                        break;
                    }
                }
            }

            if (blnNeedsUpdate)
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Update_Available").Replace("{0}", strLatestVersion).Replace("{1}", strCurrentVersion);
            }
            else
            {
                lblUpdaterStatus.Text = LanguageManager.GetString("String_Up_To_Date").Replace("{0}", strCurrentVersion).Replace("{1}", LanguageManager.GetString(_blnPreferNightly ? "String_Nightly" : "String_Stable")).Replace("{2}", strLatestVersion);
                if (blnDisableDownloadButton)
                {
                    cmdUpdate.Text    = LanguageManager.GetString("Button_Up_To_Date");
                    cmdUpdate.Enabled = false;
                }
                else
                {
                    cmdUpdate.Text = LanguageManager.GetString("Button_Redownload");
                }
            }
            if (_blnPreferNightly)
            {
                lblUpdaterStatus.Text += " " + LanguageManager.GetString("String_Nightly_Changelog_Warning");
            }
        }
		private void Check(String data) {

			if (String.IsNullOrEmpty(data)) {
				this.Status = UpdateStatus.Problem;
				return;
			}
		
			List<GitHubDownload> downloads = new List<GitHubDownload>();
			JavaScriptSerializer serializer = new JavaScriptSerializer();

			try {
				downloads = serializer.Deserialize<List<GitHubDownload>>(data);
			}
			catch (Exception e) {
				
				this.Status = UpdateStatus.Problem;

				if (Error != null) {
					Error.Invoke(this, new UnhandledExceptionEventArgs(e, false));
				}
			}

			if (downloads.Count == 0) {
				this.Status = UpdateStatus.Problem;
				return;
			}

			GitHubDownload latest = downloads.Where(d => !d.name.Contains("debug")).First();
			FileInfo file = new FileInfo(latest.name);
			String version = file.Name.Replace(this.AppName, String.Empty).Replace(file.Extension, String.Empty);

			Version current = new Version(this.CurrentVersion);
			Version remote = new Version(version);

			this.Latest = new LatestVersion(latest.html_url, latest.name, version);

			if(current < remote){
				this.Status = UpdateStatus.NewVersion;
			}
			else{
				this.Status = UpdateStatus.UpToDate;
			}
		}