static RepositoryHistoryManager()
        {
            var repositoryStorage = new RepositoryStorage();

            Locals  = new LocalRepositoryManager(repositoryStorage);
            Remotes = new RemoteRepositoryManager(repositoryStorage);
        }
예제 #2
0
파일: Class1.cs 프로젝트: perploug/cshake
        public override void ExecuteTask(Core.IContext ctx)
        {
            try
            {
                Repository source = null;

                using (var rs = new RepositoryStorage())
                {
                    source = rs.GetByAlias(Source);
                }

                var engine = new RevisionPackaging(Revision);
                engine.Source = source;

                engine.StoredItem += new EventHandler<ItemEventArgs>(engine_StoredItem);
                engine.SkippedItem += new EventHandler<ItemEventArgs>(engine_SkippedItem);

                _ctx.Important("Loading manifest...");
                var manifest = RevisionManifest.Load(Manifest);
                engine.AddToQueue(manifest);

                _ctx.Important("Starting packaging...");
                engine.Package();
                engine.Dispose();

                _ctx.Success("All done, yay!");
            }
            catch (Exception ex)
            {
                _ctx.Error(ex);
            }
        }
예제 #3
0
        static RepositoryHistoryManager()
        {
            var repositoryStorage = new RepositoryStorage();

            Locals  = new LocalRepositoryManager(repositoryStorage, new Legacy.RepositoryHistoryMigrator());
            Remotes = new RemoteRepositoryManager(repositoryStorage);
        }
예제 #4
0
파일: Package.cs 프로젝트: jayvin/Courier
        protected override void ExecuteTask()
        {
            Console.WriteLine("Application: " + application);
            Console.WriteLine("Config: " + Config);
            Console.WriteLine("plugins: " + plugins);

            init();

            Repository target = null;
            Repository source = null;

            using (var rs = new RepositoryStorage()){
                source = rs.GetByAlias(Source);

                if (!string.IsNullOrEmpty(Target))
                {
                    target = rs.GetByAlias(Target);
                }
            }

            var engine = new RevisionPackaging(Revision);

            engine.Source = source;


            engine.StoredItem  += new EventHandler <ItemEventArgs>(engine_StoredItem);
            engine.SkippedItem += new EventHandler <ItemEventArgs>(engine_SkippedItem);

            if (target != null)
            {
                Console.WriteLine("Enabling compare....");
                engine.EnableInstantCompare(target);
            }

            Console.WriteLine("Loading manifest...");
            var manifest = RevisionManifest.Load(Manifest);

            engine.AddToQueue(manifest);

            Console.WriteLine("Starting packaging...");
            engine.Package();
            engine.Dispose();

            Console.ResetColor();

            Console.WriteLine("All done, yay!");
        }
예제 #5
0
파일: Package.cs 프로젝트: jayvin/Courier
        protected override void ExecuteTask()
        {
            Console.WriteLine("Application: " + application);
            Console.WriteLine("Config: " + Config);
            Console.WriteLine("plugins: " + plugins);

            init();

            Repository target = null;
            Repository source = null;

            using(var rs = new RepositoryStorage()){
                source = rs.GetByAlias(Source);

                if(!string.IsNullOrEmpty(Target))
                    target = rs.GetByAlias(Target);
            }

            var engine = new RevisionPackaging(Revision);
            engine.Source = source;

            engine.StoredItem += new EventHandler<ItemEventArgs>(engine_StoredItem);
            engine.SkippedItem += new EventHandler<ItemEventArgs>(engine_SkippedItem);

            if (target != null)
            {
                Console.WriteLine("Enabling compare....");
                engine.EnableInstantCompare(target);
            }

            Console.WriteLine("Loading manifest...");
            var manifest = RevisionManifest.Load( Manifest );
            engine.AddToQueue(manifest);

            Console.WriteLine("Starting packaging...");
            engine.Package();
            engine.Dispose();

            Console.ResetColor();

            Console.WriteLine("All done, yay!");
        }
예제 #6
0
        protected override void ExecuteTask()
        {
            Console.WriteLine("Application: " + application);
            Console.WriteLine("Config: " + Config);
            Console.WriteLine("plugins: " + plugins);

            init();

            RepositoryStorage rs = new RepositoryStorage();
            var r = rs.GetByAlias(Target);

            rs.Dispose();

            var engine = new RevisionExtraction(Revision);

            engine.Destination    = r;
            engine.ExtractedItem += new EventHandler <ItemEventArgs>(engine_ExtractedItem);
            engine.Extract();

            engine.Dispose();

            Console.WriteLine("All done, yay!");
        }
예제 #7
0
 public async Task <List <T> > FindAsync(Expression <Func <T, bool> > predicate, Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(await iRepository.FindAsync(predicate, identityWorkID : identityWorkId, objectsToInclude : objectsToInclude));
 }
예제 #8
0
파일: Extract.cs 프로젝트: jayvin/Courier
        protected override void ExecuteTask()
        {
            Console.WriteLine("Application: " + application);
            Console.WriteLine("Config: " + Config);
            Console.WriteLine("plugins: " + plugins);

            init();

            RepositoryStorage rs = new RepositoryStorage();
            var r = rs.GetByAlias(Target);
            rs.Dispose();

            var engine = new RevisionExtraction(Revision);
            engine.Destination = r;
            engine.ExtractedItem += new EventHandler<ItemEventArgs>(engine_ExtractedItem);
            engine.Extract();

            engine.Dispose();

            Console.WriteLine("All done, yay!");
        }
예제 #9
0
        public void Ctor_RelativePath()
        {
            var storage = new RepositoryStorage("fakepath", false);

            Assert.Equal(storage.Path, "fakepath");
        }
예제 #10
0
파일: DataSource.cs 프로젝트: fbmnds/GitMe
        public static async Task LoadDenormalizeNotificationsAsync()
        {
            if (notificationStore == null)
            {
                notificationStore = new NotificationStorage();
            }
            if (repositoryStore == null)
            {
                repositoryStore = new RepositoryStorage();
            }
            if (userStore == null)
            {
                userStore = new UserStorage();
            }

            //await GetStorageFileAsync("Repositories");
            //await GetStorageFileAsync("Users");
            await GetStorageFileAsync("Notifications");

            if (notificationStore == null)
            {
                notificationStore = new NotificationStorage();
                return;
            }

            if (notificationStore.Count == 0)
            {
                return;
            }

            var dict = new UpdatableDictionary <int, DenormalizedNotification>();

            if (_notes.Count > 0)
            {
                foreach (var item in _notes)
                {
                    var _item = item as DenormalizedNotification;
                    dict.UpdateOrInsert(_item.Id, _item);
                }
            }

            foreach (var note in notificationStore.Values)
            {
                string imagePath = await GetImagePath(note.UserId.ToString(), Constants.AvatarSize);

                try
                {
                    var denormalizedNote = new DenormalizedNotification(note.Id,
                                                                        note.HtmlUrl,
                                                                        note.UserLogin,
                                                                        note.RepoFullName,
                                                                        note.SubjectTitle,
                                                                        imagePath,
                                                                        DateTimeHelper.ParsedOrDefaultDateTime(note.TimeStamp),
                                                                        note.Body);
                    dict.UpdateOrInsert(denormalizedNote.Id, denormalizedNote);
                }
                catch
                {
                    //ignore
                }
            }

            _notes = new ObservableCollection <IDataItem>();
            var list = dict.Values.OrderByDescending(i => i.UpdatedAt).Take(Constants.NotificationStorageMaxSize);

            foreach (var value in list)
            {
                _notes.Add(value);
            }
        }
예제 #11
0
 public void Setup()
 {
     _repositoryCategorySerialiser = Substitute.For <Current.IRepositorySerialiser <RepositoryCategory> >();
     _repositoryStorage            = new RepositoryStorage(_repositoryCategorySerialiser);
 }
예제 #12
0
 public ContainerService(TriggrContext context, IProviderFactory providerFactory, RepositoryStorage storage)
 {
     _context         = context;
     _providerFactory = providerFactory;
     _storage         = storage;
 }
예제 #13
0
 public async Task <int> CountAsync(string predicate, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(await iRepository.GetCountAsync(predicate, identityWorkID : identityWorkId));
 }
예제 #14
0
 public async Task CreateorUpdateAsync(List <T> objectsToCreate, Guid identityWorkID)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     await iRepository.CreateorUpdateAsync(objectsToCreate, identityWorkID);
 }
예제 #15
0
 public List <T> GetAll(Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(iRepository.FindAll(identityWorkID: identityWorkId).ToList());
 }
예제 #16
0
파일: JsonHelper.cs 프로젝트: fbmnds/GitMe
        public static dynamic DeserializeToStorage(string storageType, string storageText)
        {
            JsonObject storageJsonObject;
            JsonArray  storageJsonArray;

            dynamic jsonStore;

            switch (storageType)
            {
            case "Notifications":
                jsonStore = new NotificationStorage();
                break;

            case "Repositories":
                jsonStore = new RepositoryStorage();
                break;

            case "Users":
                jsonStore = new UserStorage();
                break;

            default:
                throw new System.ArgumentException(storageType);
            }

            try
            {
                storageJsonObject = JsonObject.Parse(storageText);
                storageJsonArray  = storageJsonObject[storageType].GetArray();
            }
            catch
            {
                return(jsonStore);
            }

            foreach (JsonValue storageValue in storageJsonArray)
            {
                try
                {
                    dynamic storageItem;

                    switch (storageType)
                    {
                    case "Notifications":
                        storageItem = Serializer.DeserializeToNotification(storageValue.Stringify());
                        storageItem.SubjectTitle = DecodeBase64(storageItem.SubjectTitle);
                        storageItem.Body         = DecodeBase64(storageItem.Body);
                        jsonStore.UpdateOrInsert(storageItem.Id, storageItem);
                        break;

                    case "Repositories":
                        storageItem = Serializer.DeserializeToRepository(storageValue.Stringify());
                        jsonStore.UpdateOrInsert(storageItem.Id, storageItem);
                        break;

                    case "Users":
                        storageItem = Serializer.DeserializeToUser(storageValue.Stringify());
                        jsonStore.UpdateOrInsert(storageItem.Id, storageItem);
                        break;

                    default:
                        throw new System.ArgumentException(storageType);
                    }
                }
                catch
                {
                    throw;
                }
            }
            return(jsonStore);
        }
 public void Setup()
 {
     _repositorySerialiser = Substitute.For <IRepositorySerialiser>();
     _repositoryStorage    = new RepositoryStorage(_repositorySerialiser);
 }
예제 #18
0
 public GitProvider(RepositoryStorage storage, IScriptExecutor scriptExecutor, LibGit2SharpWrapper git)
 {
     _git            = git;
     _storage        = storage;
     _scriptExecutor = scriptExecutor;
 }
예제 #19
0
 public async Task UpdateAsync(List <T> lstObjects, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     await iRepository.UpdateAsync(lstObjects, identityWorkId);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="lstGuids"></param>
 /// <param name="identityWorkId"></param>
 /// <returns></returns>
 public List <T> GetByIds(List <Guid> lstGuids, Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraGeneralContext(ConnectionManager.ConfigConnectionStringGeneral);
     using var iRepository = new RepositoryStorage <T, CotorraGeneralContext>(context, true);
     return(iRepository.GetByIds(lstGuids, identityWorkID: identityWorkId, objectsToInclude: objectsToInclude).Select(p => p.Value).ToList());
 }
예제 #21
0
 public int Count(Expression <Func <T, bool> > predicate, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(iRepository.GetCount(predicate, identityWorkID: identityWorkId));
 }
 public List <T> Find(string predicate, Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraGeneralContext(ConnectionManager.ConfigConnectionStringGeneral);
     using var iRepository = new RepositoryStorage <T, CotorraGeneralContext>(context, true);
     return(iRepository.Find(predicate, identityWorkID: identityWorkId, objectsToInclude: objectsToInclude).ToList());
 }
예제 #23
0
 /// <summary>
 /// Delete things
 /// </summary>
 /// <param name="lstObjects"></param>
 /// <param name="identityWorkId"></param>
 public void Delete(List <Guid> lstObjects, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     iRepository.Delete(lstObjects, identityWorkId);
 }
 public async Task DeleteAsync(List <Guid> lstObjects, Guid identityWorkId)
 {
     using var context     = new CotorraGeneralContext(ConnectionManager.ConfigConnectionStringGeneral);
     using var iRepository = new RepositoryStorage <T, CotorraGeneralContext>(context, true);
     await iRepository.DeleteAsync(lstObjects, identityWorkId);
 }
 /// <summary>
 /// Update things
 /// </summary>
 /// <param name="lstObjects"></param>
 /// <param name="identityWorkId"></param>
 public void Update(List <T> lstObjects, Guid identityWorkId)
 {
     using var context     = new CotorraGeneralContext(ConnectionManager.ConfigConnectionStringGeneral);
     using var iRepository = new RepositoryStorage <T, CotorraGeneralContext>(context, true);
     iRepository.Update(lstObjects, identityWorkId);
 }
 public int Count(string predicate, Guid identityWorkId)
 {
     using var context     = new CotorraGeneralContext(ConnectionManager.ConfigConnectionStringGeneral);
     using var iRepository = new RepositoryStorage <T, CotorraGeneralContext>(context, true);
     return(iRepository.GetCount(predicate, identityWorkID: identityWorkId));
 }
예제 #27
0
파일: Program.cs 프로젝트: jayvin/Courier
        static void Deploy(IEnumerable <RevisionSetting> revisions)
        {
            try
            {
                Console.WriteLine("Loading extraction instance");

                ExtractionManager manager = ExtractionManager.Instance;
                RepositoryStorage rs      = new RepositoryStorage();

                manager.ExtractedItem += new EventHandler <ItemEventArgs>(manager_ExtractedItem);
                manager.Extracted     += new EventHandler <ExtractionEventArgs>(manager_Extracted);

                manager.OverwriteExistingDependencies = true;
                manager.OverwriteExistingitems        = true;
                manager.OverwriteExistingResources    = true;

                Console.WriteLine("Deployment manager loaded");


                foreach (var rev in revisions.Where(x => x.Active))
                {
                    string revFolder = Path.GetFullPath(rev.Folder);
                    Console.WriteLine("Loading folder: " + revFolder);

                    Repository r = rs.GetByAlias(rev.Alias);

                    /*
                     * Console.WriteLine("Syncing files");
                     * foreach (var s in rev.Syncs)
                     * {
                     *  string pattern = "*.*";
                     *  if (!string.IsNullOrEmpty(s.Pattern))
                     *      pattern = s.Pattern;
                     *
                     *  var files = System.IO.Directory.GetFiles(s.Target, pattern);
                     * }
                     */


                    Console.WriteLine("Enabling remote deployment for: " + r.Name);
                    manager.EnableRemoteExtraction(r);

                    Console.WriteLine("Loading Contents: " + revFolder);
                    manager.Load(revFolder);

                    Console.WriteLine("Building graph...");
                    manager.BuildGraph();

                    Console.WriteLine(manager.ExtractionGraph.CountUnique() + " Items added to graph");

                    Console.WriteLine("Extraction...");
                    manager.ExtractAll(true, true);

                    Console.WriteLine("Unloading...");
                    manager.Unload();
                }

                Console.WriteLine("DONE...");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
 public async Task <int> CountAsync(Expression <Func <T, bool> > predicate, Guid identityWorkId)
 {
     using var context     = new CotorraGeneralContext(ConnectionManager.ConfigConnectionStringGeneral);
     using var iRepository = new RepositoryStorage <T, CotorraGeneralContext>(context, true);
     return(await iRepository.GetCountAsync(predicate, identityWorkID : identityWorkId));
 }
예제 #29
0
파일: DataSource.cs 프로젝트: fbmnds/GitMe
        /// <summary>
        /// throws exception
        /// </summary>
        /// <param name="page"></param>
        /// <param name="notes"></param>
        /// <returns></returns>
        private async Task ProcessFetchedDataAsync(List <Octokit.Notification> notes)
        {
            if (notificationStore == null)
            {
                notificationStore = new NotificationStorage();
            }
            if (repositoryStore == null)
            {
                repositoryStore = new RepositoryStorage();
            }
            if (userStore == null)
            {
                userStore = new UserStorage();
            }

            var dict = new UpdatableDictionary <int, DenormalizedNotification>();

            if (_notes != null)
            {
                foreach (var item in _notes)
                {
                    var _item = item as DenormalizedNotification;
                    dict.UpdateOrInsert(_item.Id, _item);
                }
            }

            foreach (var note in notes)
            {
                try
                {
                    string responseBuffer = await GetDetailsResponse(note.Subject.LatestCommentUrl);

                    Response details = Serializer.DeserializeToResponse(responseBuffer);

                    int id;
                    if (!Int32.TryParse(note.Id, out id))
                    {
                        throw new ArgumentException();
                    }
                    string userimagepath = await GetImagePath(details.User.Id.ToString(), Constants.AvatarSize);

                    var newNote = new DenormalizedNotification(id,
                                                               details.HtmlUrl,
                                                               details.User.Login,
                                                               note.Repository.FullName,
                                                               note.Subject.Title,
                                                               userimagepath,
                                                               DateTimeHelper.ParsedOrDefaultDateTime(note.UpdatedAt),
                                                               details.Body);

                    dict.UpdateOrInsert(newNote.Id, newNote);

                    notificationStore.UpdateOrInsert(id, note, details);
                    repositoryStore.UpdateOrInsert(id, note, details);
                    userStore.UpdateOrInsert(id, note, details);
                }
                catch
                {
                    // ignore
#if DEBUG
                    throw;
#endif
                }
            }
            _notes = new ObservableCollection <IDataItem>();
            var list = dict.Values.OrderByDescending(i => i.UpdatedAt).Take(Constants.NotificationStorageMaxSize);
            foreach (var value in list)
            {
                _notes.Add(value);
            }
        }
예제 #30
0
 public async Task <List <T> > GetByIdsAsync(List <Guid> lstGuids, Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return((await iRepository.GetByIdsAsync(lstGuids, identityWorkID: identityWorkId, objectsToInclude: objectsToInclude)).Select(p => p.Value).ToList());
 }
예제 #31
0
        public void Ctor_AbsolutePath()
        {
            var storage = new RepositoryStorage("fakepath");

            Assert.Equal(storage.Path, Path.Combine(Environment.CurrentDirectory, "fakepath"));
        }
예제 #32
0
파일: Program.cs 프로젝트: jayvin/Courier
        static void Deploy(IEnumerable<RevisionSetting> revisions)
        {
            try
            {
                Console.WriteLine("Loading extraction instance");

                ExtractionManager manager = ExtractionManager.Instance;
                RepositoryStorage rs = new RepositoryStorage();

                manager.ExtractedItem += new EventHandler<ItemEventArgs>(manager_ExtractedItem);
                manager.Extracted += new EventHandler<ExtractionEventArgs>(manager_Extracted);

                manager.OverwriteExistingDependencies = true;
                manager.OverwriteExistingitems = true;
                manager.OverwriteExistingResources = true;

                Console.WriteLine("Deployment manager loaded");

                foreach (var rev in revisions.Where(x => x.Active))
                {
                    string revFolder = Path.GetFullPath(rev.Folder);
                    Console.WriteLine("Loading folder: " + revFolder);

                    Repository r = rs.GetByAlias(rev.Alias);

                    /*
                    Console.WriteLine("Syncing files");
                    foreach (var s in rev.Syncs)
                    {
                        string pattern = "*.*";
                        if (!string.IsNullOrEmpty(s.Pattern))
                            pattern = s.Pattern;

                        var files = System.IO.Directory.GetFiles(s.Target, pattern);
                    }
                    */

                    Console.WriteLine("Enabling remote deployment for: " + r.Name);
                    manager.EnableRemoteExtraction(r);

                    Console.WriteLine("Loading Contents: " + revFolder);
                    manager.Load(revFolder);

                    Console.WriteLine("Building graph...");
                    manager.BuildGraph();

                    Console.WriteLine(manager.ExtractionGraph.CountUnique() + " Items added to graph");

                    Console.WriteLine("Extraction...");
                    manager.ExtractAll(true, true);

                    Console.WriteLine("Unloading...");
                    manager.Unload();
                }

                Console.WriteLine("DONE...");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }