Пример #1
0
        public PlanService(OpCore core)
        {
            Core     = core;
            Network  = core.Network;
            Protocol = Network.Protocol;
            Store    = Network.Store;
            Trust    = Core.Trust;

            if (Core.Sim != null)
            {
                SaveInterval = 30;
            }

            Core.SecondTimerEvent += Core_SecondTimer;

            Cache = new VersionedCache(Network, ServiceID, DataTypeFile, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            if (!PlanMap.SafeContainsKey(Core.UserID))
            {
                LocalPlan = new OpPlan(new OpVersionedFile(Core.User.Settings.KeyPublic));
                LocalPlan.Init();
                LocalPlan.Loaded = true;
                PlanMap.SafeAdd(Core.UserID, LocalPlan);
            }
        }
Пример #2
0
 static TagStructure()
 {
     lock (VersionedCaches)
         foreach (var version in Enum.GetValues(typeof(CacheVersion)) as CacheVersion[])
         {
             VersionedCaches[version] = new VersionedCache(version);
         }
 }
Пример #3
0
 public VersionedCacheTests()
 {
     _schemaVersionResolver = Substitute.For <ISchemaVersionResolver>();
     _versionedCache        = new VersionedCache <IVersioned>(
         _schemaVersionResolver,
         new List <IVersioned> {
         new Example1(), new Example2()
     });
 }
Пример #4
0
        public BuddyService(OpCore core)
        {
            Core         = core;
            Network      = Core.Network;
            Core.Buddies = this;

            Network.CoreStatusChange  += new StatusChange(Network_StatusChange);
            Core.KeepDataCore         += new KeepDataHandler(Core_KeepData);
            Core.Locations.KnowOnline += new KnowOnlineHandler(Location_KnowOnline);
            Core.MinuteTimerEvent     += Core_MinuteTimer;
            Cache = new VersionedCache(Network, ServiceID, 0, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.Load();

            if (!BuddyList.SafeContainsKey(Core.UserID))
            {
                AddBuddy(Core.User.Settings.UserName, Core.User.Settings.KeyPublic);
            }

            BuddyList.SafeTryGetValue(Core.UserID, out LocalBuddy);
        }
Пример #5
0
        public ProfileService(OpCore core)
        {
            Core     = core;
            Network  = core.Network;
            Protocol = Network.Protocol;
            Store    = Network.Store;
            Trust    = Core.Trust;

            ExtractPath = Core.User.RootPath + Path.DirectorySeparatorChar +
                          "Data" + Path.DirectorySeparatorChar +
                          ServiceID.ToString() + Path.DirectorySeparatorChar +
                          DataTypeExtracted.ToString();

            Cache = new VersionedCache(Network, ServiceID, DataTypeFile, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();

            if (!ProfileMap.SafeContainsKey(Core.UserID))
            {
                SaveLocal(DefaultTemplate, null, null);
            }
        }
Пример #6
0
 public SqlChangeFeedStore(VersionedCache <ISqlChangeFeedStore> cache)
 => _cache = EnsureArg.IsNotNull(cache, nameof(cache));
Пример #7
0
        public StorageService(OpCore core)
        {
            Core     = core;
            Network  = core.Network;
            Protocol = Network.Protocol;
            Store    = Network.Store;
            Trust    = Core.Trust;

            Core.SecondTimerEvent += Core_SecondTimer;
            Core.MinuteTimerEvent += Core_MinuteTimer;

            Network.CoreStatusChange += new StatusChange(Network_StatusChange);

            Core.Transfers.FileSearch[ServiceID, FileTypeData]  += new FileSearchHandler(Transfers_DataFileSearch);
            Core.Transfers.FileRequest[ServiceID, FileTypeData] += new FileRequestHandler(Transfers_DataFileRequest);

            Core.Trust.LinkUpdate += new LinkUpdateHandler(Trust_Update);

            LocalFileKey  = Core.User.Settings.FileKey;
            FileCrypt.Key = LocalFileKey;
            FileCrypt.IV  = new byte[FileCrypt.IV.Length];

            string rootpath = Core.User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + ServiceID.ToString() + Path.DirectorySeparatorChar;

            DataPath     = rootpath + FileTypeData.ToString();
            WorkingPath  = rootpath + FileTypeWorking.ToString();
            ResourcePath = rootpath + FileTypeResource.ToString();

            Directory.CreateDirectory(DataPath);
            Directory.CreateDirectory(WorkingPath);

            // clear resource files so that updates of these files work
            if (Directory.Exists(ResourcePath))
            {
                Directory.Delete(ResourcePath, true);
            }

            Cache = new VersionedCache(Network, ServiceID, FileTypeCache, false);

            Cache.FileAquired += new FileAquiredHandler(Cache_FileAquired);
            Cache.FileRemoved += new FileRemovedHandler(Cache_FileRemoved);
            Cache.Load();


            // load working headers
            OpStorage local = GetStorage(Core.UserID);

            foreach (uint project in Trust.LocalTrust.Links.Keys)
            {
                if (local != null)
                {
                    LoadHeaderFile(GetWorkingPath(project), local, false, true);
                }

                Working[project] = new WorkingStorage(this, project);

                bool doSave = false;
                foreach (ulong higher in Trust.GetAutoInheritIDs(Core.UserID, project))
                {
                    if (Working[project].RefreshHigherChanges(higher))
                    {
                        doSave = true;
                    }
                }

                Working[project].AutoIntegrate(doSave);
            }

            foreach (string testPath in Directory.GetFiles(DataPath))
            {
                if (!ReferencedPaths.Contains(testPath))
                {
                    try { File.Delete(testPath); }
                    catch { }
                }
            }

            ReferencedPaths.Clear();
            Loading = false;
        }
Пример #8
0
 public SqlIndexDataStore(VersionedCache <ISqlIndexDataStore> cache)
 => _cache = EnsureArg.IsNotNull(cache, nameof(cache));
 public SqlExtendedQueryTagErrorStore(VersionedCache <ISqlExtendedQueryTagErrorStore> cache)
 => _cache = EnsureArg.IsNotNull(cache, nameof(cache));
Пример #10
0
 public SqlPartitionStore(VersionedCache <ISqlPartitionStore> cache)
 => _cache = EnsureArg.IsNotNull(cache, nameof(cache));