public string GetProjectName(int pageId)
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
            var page = repository.GetPageById(pageId);

            return(page?.Title);
        }
        public int UpdateDatabase(string u, string password)
        {
            var count = 0;

            if (u == "updg0022" && password == "C6MGRkq4AhHutyEeaT3S7bgrxnVUjpzDWwZcKNP9v8fmJ2L5Bs")
            {
                LightSpeedRepository repository =
                    new LightSpeedRepository(ObjectFactory.GetInstance <ApplicationSettings>());

                foreach (var rel in repository.Rels)
                {
                    var user = repository.Users.FirstOrDefault(x => x.Username == rel.username);

                    if (user != null)
                    {
                        if (user.Id != Guid.Empty)
                        {
                            rel.UserId = user.Id;
                            repository.UnitOfWork.SaveChanges();
                            count++;
                        }
                    }
                }
                return(count);
            }

            return(count);
        }
Beispiel #3
0
        public List <Activity> Activity()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());


            IEnumerable <Activity> ActivityList;

            ActivityList = repository.ActivityViewList();

            List <Activity> items = new List <Activity>();

            foreach (Activity act in ActivityList)
            {
                Activity item = new Activity();
                item.id           = act.id;
                item.activityName = act.activityName;
                item.orgName      = act.orgName;
                item.projectName  = act.projectName;
                item.userNames    = act.userNames;

                items.Add(item);
            }

            return(items);
        }
 public void Process(string command, IEnumerable<string> args)
 {
     using (LightSpeedRepository<Question> retreavingitems = new LightSpeedRepository<Question>())
     {
         var incomingQuestions = retreavingitems.GetAll().ElementAt( int.Parse(args.First()));
         Console.WriteLine("Question" + incomingQuestions.QuestionField);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Returns if this user has already added a relationship to this page
        /// </summary>
        public Relationship RelToUserToPage(int pageID)
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            RoadkillContext = ObjectFactory.GetInstance <IUserContext>();

            return(repository.RelToUserToPage(pageID, RoadkillContext.CurrentUsername));
        }
Beispiel #6
0
        public bool IsApprovedContributer(Guid userId)
        {
            LightSpeedRepository       repository = new LightSpeedRepository(GetAppSettings());
            IEnumerable <Relationship> relsList   = repository.GetRelByPageAndUserId(Id, userId);
            var isApproved = relsList.Any(x => x.relTypeId == 4 && x.approved);

            return(isApproved);
        }
        public bool WatchStatus(int projectid)
        {
            var userid = UserContext.CurrentUserId;
            LightSpeedRepository repository =
                new LightSpeedRepository(ObjectFactory.GetInstance <ApplicationSettings>());

            return(repository.Rels.Any(x => x.UserId == userid && x.pageId == projectid && x.relTypeId == 3));
        }
        void IControler.Process(string command, IEnumerable<string> args)
        {
            using (LightSpeedRepository<Question> retreavingitems = new LightSpeedRepository<Question>())
            {
                incomingQuestions = retreavingitems.GetAll.First(o => o.Id == int.Parse(args.First()));
                Console.WriteLine("Question" + incomingQuestions());

            }
        }
Beispiel #9
0
        public int Delete([FromUri] int id)
        {
            var appSettings = AppSettings();
            LightSpeedRepository repository = new LightSpeedRepository(appSettings);

            repository.DeleteStatusUpdate(id);

            return(id);
        }
Beispiel #10
0
        /// <summary>
        /// Returns the organisation name
        /// </summary>
        public string GetRelType(int relTypeID)
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            RelationshipType _reltype;

            _reltype = repository.GetRelTypeByID(relTypeID);

            return(_reltype.relTypeText);
        }
Beispiel #11
0
        /// <summary>
        /// Returns the organisation name
        /// </summary>
        public string GetOrg(int orgID)
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            Organisation _org;

            _org = repository.GetOrgByID(orgID);

            return(_org.OrgName);
        }
Beispiel #12
0
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static Dictionary <string, int> GetPageCountByAgilePhase()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
            var dictionary = new Dictionary <string, int>();

            dictionary["Discovery"] = repository.PageCountByStatus("Discovery");
            dictionary["Alpha"]     = repository.PageCountByStatus("Alpha");
            dictionary["Beta"]      = repository.PageCountByStatus("Beta");
            dictionary["Live"]      = repository.PageCountByStatus("Live");
            return(dictionary);
        }
Beispiel #13
0
        public static Dictionary <string, int> GetPageCountByAgileLifeCycle()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
            var dictionary = new Dictionary <string, int>();

            dictionary["Discover"]  = repository.PageCountByAgileLifeCyclePhase("Discover");
            dictionary["Prototype"] = repository.PageCountByAgileLifeCyclePhase("Prototype");
            dictionary["Build"]     = repository.PageCountByAgileLifeCyclePhase("Build");
            dictionary["Improve"]   = repository.PageCountByAgileLifeCyclePhase("Improve");
            return(dictionary);
        }
Beispiel #14
0
        public IList <StatusUpdateViewModel> Get(int pageId)
        {
            if (pageId == 0)
            {
                return(new List <StatusUpdateViewModel>());
            }


            var appSettings = AppSettings();
            LightSpeedRepository repository = new LightSpeedRepository(appSettings);

            return(repository.GetStatusUpdates(pageId));
        }
        /// <summary>
        /// Returns the organisation name
        /// </summary>
        public string GetOrg(int orgID)
        {
            string _orgname = "unknown";

            try
            {
                LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
                Organisation         _org;
                _org     = repository.GetOrgByID(orgID);
                _orgname = _org.OrgName;
            }
            catch { }

            return(_orgname);
        }
        /// <summary>
        /// Returns the user name
        /// </summary>
        public string GetUser(string username)
        {
            string _usernames = "unknown";

            try
            {
                LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
                User _user;
                _user      = repository.GetUserByUsername(username);
                _usernames = _user.Firstname + " " + _user.Lastname;
            }
            catch { }

            return(_usernames);
        }
Beispiel #17
0
        protected IRepository GetRepository()
        {
            ApplicationSettings appSettings = new ApplicationSettings();

            appSettings.DataStoreType    = DataStoreType.SqlServer2012;
            appSettings.ConnectionString = SqlServerSetup.ConnectionString;
            appSettings.LoggingTypes     = "none";
            appSettings.UseBrowserCache  = false;
            Log.ConfigureLogging(appSettings);

            LightSpeedRepository repository = new LightSpeedRepository(appSettings);

            repository.Startup(appSettings.DataStoreType, appSettings.ConnectionString, false);
            return(repository);
        }
        public bool RequestContribute(int projectid)
        {
            var userId = UserContext.CurrentUserId;

            LightSpeedRepository repository =
                new LightSpeedRepository(ObjectFactory.GetInstance <ApplicationSettings>());

            var organisation = repository.GetOrgByUser(userId);

            if (!repository.IsContributePending(projectid, userId))
            {
                repository.SetPendingApprovedInProject(projectid, userId, organisation?.Id ?? 0);
            }

            return(repository.IsContributePending(projectid, userId));
        }
        public bool ApproveContribute(int projectid, int relid)
        {
            if (UserContext.IsAdmin)
            {
                LightSpeedRepository repository =
                    new LightSpeedRepository(ObjectFactory.GetInstance <ApplicationSettings>());

                if (!repository.IsContributeApproved(projectid, relid))
                {
                    repository.SetContributeApprovedInProject(projectid, relid);
                }

                return(true);
            }

            return(false);
        }
        public List <string> OrganisationSearch(string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                return(new List <string>());
            }

            ApplicationSettings appSettings = new ApplicationSettings();

            appSettings.DataStoreType    = DataStoreType.Sqlite;
            appSettings.ConnectionString = "Data Source=|DataDirectory|\roadkill.sqlite;";
            appSettings.LoggingTypes     = "none";
            appSettings.UseBrowserCache  = false;

            LightSpeedRepository repository = new LightSpeedRepository(appSettings);

            return(repository.Orgs.Where(x => x.OrgName.StartsWith(query)).Select(x => x.OrgName).ToList());
        }
        public void Should_Import_Files_In_Attachments_Folder()
        {
            // Arrange
            ApplicationSettings applicationSettings = new ApplicationSettings();

            applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScrewturnImport");

            if (Directory.Exists(applicationSettings.AttachmentsFolder))
            {
                Directory.Delete(applicationSettings.AttachmentsFolder, true);
            }

            Directory.CreateDirectory(applicationSettings.AttachmentsFolder);

            applicationSettings.ConnectionString = _connectionString;
            applicationSettings.DataStoreType    = DataStoreType.SqlServer2012;

            IRepository repository = new LightSpeedRepository(applicationSettings);

            repository.Startup(applicationSettings.DataStoreType,
                               applicationSettings.ConnectionString,
                               false);

            // Clear the database
            repository.Install(applicationSettings.DataStoreType,
                               applicationSettings.ConnectionString,
                               false);
            ScrewTurnImporter importer = new ScrewTurnImporter(applicationSettings, repository);

            // Act
            importer.ImportFromSqlServer(_connectionString);

            // Assert
            string   file1     = Path.Combine(applicationSettings.AttachmentsFolder, "atextfile.txt");
            string   file2     = Path.Combine(applicationSettings.AttachmentsFolder, "screwdriver1.jpg");
            FileInfo fileInfo1 = new FileInfo(file1);
            FileInfo fileInfo2 = new FileInfo(file2);

            Assert.True(fileInfo1.Exists);
            Assert.True(fileInfo2.Exists);

            Assert.That(fileInfo1.Length, Is.GreaterThan(0));
            Assert.That(fileInfo2.Length, Is.GreaterThan(0));
        }
        public bool RequestWatch(int projectid)
        {
            var userId = UserContext.CurrentUserId;
            LightSpeedRepository repository =
                new LightSpeedRepository(ObjectFactory.GetInstance <ApplicationSettings>());

            var organisation = repository.GetOrgByUser(userId);

            if (repository.IsWatched(projectid, userId))
            {
                repository.UnWatchProject(projectid, userId);
            }
            else
            {
                repository.WatchProject(projectid, userId, organisation?.Id ?? 0);
            }

            return(repository.IsWatched(projectid, userId));
        }
Beispiel #23
0
        public StatusUpdateViewModel Post([FromBody] StatusUpdateViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var appSettings = AppSettings();

            LightSpeedRepository repository = new LightSpeedRepository(appSettings);

            model.Author = UserContext.CurrentUserFullName;
            var updatedStatus = repository.CreateStatusUpdate(model);


            var pageContents = _pageService.GetById(model.PageId);

            SendUpdate(repository, updatedStatus, model.PageId, model.PageId, pageContents.Title, _projectStatusUpdateEmail);
            return(updatedStatus);
        }
Beispiel #24
0
        /// <summary>
        /// Gets an IEnumerable{SelectListItem} of project statuses, as a default
        /// SelectList doesn't add option value attributes.
        /// </summary>
        public static List <SelectListItem> RelTypesAsNewSelectList()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            IEnumerable <RelationshipType> RelList;

            RelList = repository.FindAllRelTypes();

            List <SelectListItem> items = new List <SelectListItem>();

            foreach (RelationshipType reltype in RelList)
            {
                SelectListItem item = new SelectListItem();
                item.Text  = reltype.relTypeText.ToString();
                item.Value = reltype.Id.ToString();

                items.Add(item);
            }

            items.Sort((x, y) => string.Compare(x.Text, y.Text));

            return(items);
        }
Beispiel #25
0
        public void SendUpdate(LightSpeedRepository repository, StatusUpdateViewModel updatedStatus, int pageId, int projectId, string projectTitle, ProjectStatusUpdateEmail projectStatusUpdateEmail)
        {
            var relationList = _pageService.GetRelationsByPageId(pageId).ToList();
            var emailModels  = new List <EmailProjectStatusUpdateViewModel>();

            var environmentPrefix = string.Empty;

            if (ConfigurationManager.AppSettings.AllKeys.Contains("environment"))
            {
                environmentPrefix = ConfigurationManager.AppSettings["environment"];
                environmentPrefix = $"[{environmentPrefix}] ";
            }

            foreach (var relViewModel in relationList)
            {
                var mod = new EmailProjectStatusUpdateViewModel
                {
                    ProjectName  = projectTitle,
                    ProjectId    = projectId.ToString(),
                    Subject      = $"{environmentPrefix}The status of project [{projectTitle}] has been updated.",
                    Author       = updatedStatus.Author,
                    UpdateDate   = updatedStatus.UpdateDate.ToString("f"),
                    StatusUpdate = updatedStatus.Text
                };

                var user = repository.GetUserById(relViewModel.userId);

                if (user != null)
                {
                    mod.Name      = $"{user.Firstname} {user.Lastname}";
                    mod.ToAddress = user.Email;
                }

                emailModels.Add(mod);
                projectStatusUpdateEmail.Send(mod);
            }
        }
Beispiel #26
0
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static int UsersCount()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            return(repository.AllUsersCount());
        }
        public void Should_Import_All_Pages_Categories_And_Usernames()
        {
            // Arrange
            ApplicationSettings applicationSettings = new ApplicationSettings();

            applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScrewturnImport");

            if (Directory.Exists(applicationSettings.AttachmentsFolder))
            {
                Directory.Delete(applicationSettings.AttachmentsFolder, true);
            }

            Directory.CreateDirectory(applicationSettings.AttachmentsFolder);

            applicationSettings.ConnectionString = _connectionString;
            applicationSettings.DataStoreType    = DataStoreType.SqlServer2012;

            IRepository repository = new LightSpeedRepository(applicationSettings);

            repository.Startup(applicationSettings.DataStoreType,
                               applicationSettings.ConnectionString,
                               false);

            // Clear the database
            repository.Install(applicationSettings.DataStoreType,
                               applicationSettings.ConnectionString,
                               false);
            ScrewTurnImporter importer = new ScrewTurnImporter(applicationSettings, repository);

            // Act
            importer.ImportFromSqlServer(SqlExpressSetup.ConnectionString);

            // Assert
            User user = repository.GetUserByUsername("user2");

            Assert.That(user.Id, Is.Not.EqualTo(Guid.Empty));

            List <Page> pages = repository.AllPages().ToList();

            Assert.That(pages.Count, Is.EqualTo(3));

            Page        page1        = pages.FirstOrDefault(x => x.Title == "Screwturn page 1");
            PageContent pageContent1 = repository.GetLatestPageContent(page1.Id);

            Assert.That(page1.Tags, Is.EqualTo("Category1,"));
            Assert.That(page1.CreatedOn.ToString("u"), Is.EqualTo("2013-08-11 19:05:49Z"));
            Assert.That(page1.ModifiedOn.ToString("u"), Is.EqualTo("2013-08-11 19:05:49Z"));
            Assert.That(page1.CreatedBy, Is.EqualTo("admin"));
            Assert.That(page1.ModifiedBy, Is.EqualTo("admin"));
            Assert.That(pageContent1.Text, Is.EqualTo("This is an amazing Screwturn page."));

            Page        page2        = pages.FirstOrDefault(x => x.Title == "Screwturn page 2");
            PageContent pageContent2 = repository.GetLatestPageContent(page2.Id);

            Assert.That(page2.Tags, Is.EqualTo("Category1,Category2,"));
            Assert.That(page2.CreatedOn.ToString("u"), Is.EqualTo("2013-08-11 19:06:54Z"));
            Assert.That(page2.ModifiedOn.ToString("u"), Is.EqualTo("2013-08-11 19:06:54Z"));
            Assert.That(page2.CreatedBy, Is.EqualTo("user2"));
            Assert.That(page2.ModifiedBy, Is.EqualTo("user2"));
            Assert.That(pageContent2.Text, Is.EqualTo("Amazing screwturn page 2"));
        }
Beispiel #28
0
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static int OrganisationCount()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            return(repository.AllOrgsCount());
        }
Beispiel #29
0
        public List <Relationship> GetRelationshipWithUser()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            return(repository.GetRelByPageAndUserId(Id, ObjectFactory.GetInstance <IUserContext>().CurrentUserId).ToList());
        }
Beispiel #30
0
        public List <Relationship> GetRelationships()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            return(repository.FindPageRelationships(Id));
        }
        /// <summary>
        /// Returns the user name
        /// </summary>
        public User GetUser(Guid userid)
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            return(repository.GetUserById(userid));
        }
Beispiel #32
0
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static IEnumerable <Activity> WhatsHotList()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            return(repository.WhatsHotList());
        }