Exemplo n.º 1
0
 public void Setup()
 {
     var p = GetProjectsRepository();
     projectsRepository = p.Item1;
     var projectsRepositoryTestSupport = p.Item2;
     projectId = Guid.NewGuid().ToString();
     projectsRepositoryTestSupport.WipeBucket();
 }
Exemplo n.º 2
0
 public ProjectsFactory(IUnityContainer container, ProjectsRepository projectsRepository)
 {
     this.container = container;
     this.projectsRepository = projectsRepository;
     hierarchy = new List<Type[]>(new[] {
         new[] { typeof(ProjectViewModel), typeof(Project) },
         new[] { typeof(ScenarioViewModel), typeof(Scenario) },
         new[] { typeof(TestViewModel), typeof(Test) },
         new[] { typeof(StepViewModel), typeof(Step) }
     });
 }
        public void Can_save_project()
        {
            var project = new Project()
            {
                Name = "Sample Project",
                Id = Guid.NewGuid(),
                BrowseUrl = "Click to resolve",
                Created = DateTime.Now,
                Version = "1.0.0.0"
            };

            project.Location = new ProjectLocation() { LocalPath = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2", Type = LocationType.FileSystem, Url = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2" };

            // serialize
            var xml = XmlSerializationService<Project>.Serialize(project);


            var repository = new ProjectsRepository();
            repository.Add(project);
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 1);


            var project2 = new Project()
            {
                Name = "Sample Project 2",
                Id = Guid.NewGuid(),
                BrowseUrl = "Click to resolve",
                Created = DateTime.Now,
                Version = "1.0.0.0"
            };

            project2.Location = new ProjectLocation() { LocalPath = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2", Type = LocationType.FileSystem, Url = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2" };

            repository.Add(project2);
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 2);

            repository.Remove(repository.Projects.ElementAt(0));
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 1);
        }
        public void SaveGetTest()
        {
            var repository = new ProjectsRepository();
            repository.SaveProjects(
                new[]
                    {
                        new Project
                            {
                                InputPlugin =
                                    new PluginConfiguration
                                        {
                                            PluginId = Guid.NewGuid(),
                                            Configuration =
                                                new FooConfig
                                                    {
                                                        Name = "Name 1"
                                                    }
                                        },
                                OutputPlugins =
                                    new List<PluginConfiguration>
                                        {
                                            new PluginConfiguration
                                                {
                                                    PluginId = Guid.NewGuid(),
                                                    Configuration =
                                                        new FooConfig
                                                            {
                                                                Name =
                                                                    "Name 2"
                                                            }
                                                }
                                        }
                            }
                    });

            repository = new ProjectsRepository();
            var actual = repository.GetProjects().ToArray();

            Assert.AreEqual(1, actual.Length);

            var configuration = actual[0].InputPlugin.Configuration as FooConfig;
            Assert.AreEqual("Name 1", configuration.Name);

            configuration = actual[0].OutputPlugins[0].Configuration as FooConfig;
            Assert.AreEqual("Name 2", configuration.Name);
        }
Exemplo n.º 5
0
 public ResultsController(FilesService filesService, ProjectsRepository projectsRepository, IHttpContextAccessor accessor)
 {
     _filesService       = filesService;
     _projectsRepository = projectsRepository;
     _accessor           = accessor;
 }
Exemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!(String.IsNullOrEmpty(editor1.Text) ||
                  String.IsNullOrEmpty(title.Text) ||
                  String.IsNullOrEmpty(Abstract.Text) ||
                  String.IsNullOrEmpty(Tags.Text) ||
                  String.IsNullOrEmpty(KeyWords.Text) || SelectedSubGroups.Items.Count == 0 || Abstract.Text.Count() < 130))
            {
                if (Session["ProjectIDForEdit"] != null)
                {
                    int id = Session["ProjectIDForEdit"].ToString().ToInt();
                    //Session.Remove("newProjectIDForEdit");
                    ProjectsRepository repArt = new ProjectsRepository();
                    GroupsRepository   repo   = new GroupsRepository();
                    Project            art    = repArt.FindeProjectByID(id);

                    art.Title   = title.Text;
                    art.Content = editor1.Text;

                    if (FileUpload1.HasFile)
                    {
                        if (FileUpload1.FileBytes.Length > 1024 * 1024)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حجم فایل بارگذاری شده بیشتر از 1 مگابایت است!')", true);

                            return;
                        }
                        string ext = Path.GetExtension(FileUpload1.FileName).ToLower();
                        if ((ext != ".jpg") && (ext != ".png"))
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('فرمت فایل بارگذاری شده باید .jpg  یا .png  باشد!')", true);

                            return;
                        }

                        string filename = Path.GetFileName(FileUpload1.FileName);
                        string rand     = DBManager.CurrentTimeWithoutColons() + DBManager.CurrentPersianDateWithoutSlash();
                        filename = rand + filename;
                        string ps = Server.MapPath(@"~\img\") + filename;
                        FileUpload1.SaveAs(ps);
                        FileStream fStream  = File.OpenRead(ps);
                        byte[]     contents = new byte[fStream.Length];
                        fStream.Read(contents, 0, (int)fStream.Length);
                        fStream.Close();
                        FileInfo fi = new FileInfo(Server.MapPath(@"~\img\") + art.Image.Substring(5));
                        fi.Delete();
                        FileInfo fil = new FileInfo(Server.MapPath(@"~\img\") + art.ImgFisrtPage.Substring(5));
                        fil.Delete();

                        art.Image = "/img/" + filename;
                        System.Drawing.Image img   = imgResize.ToImage(contents);
                        System.Drawing.Image image = imgResize.Resize(img, 466, 466);
                        string stream = Server.MapPath(@"~\img\") + "s" + filename;
                        switch (FileUpload1.FileName.Substring(FileUpload1.FileName.IndexOf('.') + 1).ToLower())
                        {
                        case "jpg":
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            break;

                        case "jpeg":
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                            break;

                        case "png":
                            image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                            break;
                        }

                        art.ImgFisrtPage = "/img/" + "s" + filename;
                    }



                    art.Abstract = Abstract.Text;
                    art.Tags     = Tags.Text;
                    art.KeyWords = KeyWords.Text;

                    ProjectConRepository pcr = new ProjectConRepository();
                    pcr.deleteByProjectID(Session["ProjectIDForEdit"].ToString().ToInt());

                    ProjectsRepository ARTRep = new ProjectsRepository();
                    if (ARTRep.SaveProject(art))
                    {
                        bool result = true;
                        ProjectConRepository GRConRepo = new ProjectConRepository();
                        GRConRepo.DeletProjectConnections(id);
                        List <int> SelectedSubGroupsList = new List <int>();

                        int lastid = id;
                        int count  = SelectedSubGroups.Items.Count;
                        if (count > 0)
                        {
                            for (int i = 0; i < count; i++)
                            {
                                ProjectConnection GC = new ProjectConnection();
                                GC.ProjectID = lastid;
                                GC.GroupID   = SelectedSubGroups.Items[i].Value.ToInt();
                                if (!GRConRepo.SaveProjectCon(GC))
                                {
                                    result = false;
                                }
                            }

                            Session.Add("ProjectLastIDForEmployeeFilterEdit", id);
                            Response.Redirect("AddProject/AddEmployeeToProjectEdit");
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('هیچ زیر گروهی انتخاب نشده است!')", true);
                        }

                        if (!result)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی در زمان ثبت به وجود آمد،لطفا دوباره سعی کنید یا با پشتیبانی تماس بگیرید ! ');window.location ='/Admin/ManageProjects'", true);
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ثبت با موفقیت انجام شد!');window.location ='/Admin/ManageBlogs'", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('مشکلی در زمان ثبت به وجود آمد،لطفا دوباره سعی کنید یا با پشتیبانی تماس بگیرید ! ');window.location ='/Admin/ManageProjects'", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' مشکلی در زمان لود کردن به وجود آمد دوباره سعی کنید ! ');window.location ='/Admin/ManageProjects'", true);
                }
            }
        }
Exemplo n.º 7
0
 public static void SetUp(TestContext _context)
 {
     repo = new ProjectsRepository();
     repo.Clear();
 }
Exemplo n.º 8
0
        protected void gvPosts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            diverror.InnerHtml = "";

            if (e.CommandName == "Edit")
            {
                // Retrieve the row index stored in the
                // CommandArgument property.
                int index = Convert.ToInt32(e.CommandArgument);

                // Retrieve the row that contains the button
                // from the Rows collection.
                GridViewRow row = gvPosts.Rows[index];
                Session.Add("ProjectIDForEdit", row.Cells[0].Text);

                Response.Redirect("/Admin/EditProject");//edit
            }
            if (e.CommandName == "Show")
            {
                // Retrieve the row index stored in the
                // CommandArgument property.
                int index = Convert.ToInt32(e.CommandArgument);

                // Retrieve the row that contains the button
                // from the Rows collection.
                GridViewRow row = gvPosts.Rows[index];

                string id = row.Cells[0].Text;

                Response.Redirect("/Projects/" + id + "/" + row.Cells[1].Text.Replace(' ', '-'));//show
            }
            if (e.CommandName == "Delet")
            {
                // Retrieve the row index stored in the
                // CommandArgument property.
                int index = Convert.ToInt32(e.CommandArgument);

                // Retrieve the row that contains the button
                // from the Rows collection.
                GridViewRow          row      = gvPosts.Rows[index];
                int                  id       = row.Cells[0].Text.ToInt();
                ProjectsRepository   repart   = new ProjectsRepository();
                ProjectConRepository repgpCon = new ProjectConRepository();
                string               img      = "";
                string               fimg     = "";

                Project pr = repart.FindeProjectByID(id);
                if (pr != null)
                {
                    img  = pr.Image;
                    fimg = pr.ImgFisrtPage;
                }
                if (repgpCon.DeletProjectConnections(id) && repart.DeletProjectByID(id))
                {
                    subgroup();
                    FileInfo fi = new FileInfo(Server.MapPath(@"~\img\") + img.Substring(5));
                    fi.Delete();
                    FileInfo fil = new FileInfo(Server.MapPath(@"~\img\") + fimg.Substring(5));
                    fil.Delete();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با موفقیت انجام شد ');", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با خطا مواجه شد ، بعدا سعی کنید یا با پشتیبانی تماس بگیرید!');", true);
                }
            }
        }
Exemplo n.º 9
0
        // vbe is the com coclass interface from the interop assembly.
        // There is no shared interface between VBA and VB6 types, hence object.
        internal Parser(object vbe) : this()
        {
            if (_parser != null)
            {
                throw new InvalidOperationException("ParserState is already initialized.");
            }

            _vbe       = RootComWrapperFactory.GetVbeWrapper(vbe);
            _vbeEvents = VBEEvents.Initialize(_vbe);
            var declarationFinderFactory = new ConcurrentlyConstructedDeclarationFinderFactory();
            var projectRepository        = new ProjectsRepository(_vbe);

            _state = new RubberduckParserState(_vbe, projectRepository, declarationFinderFactory, _vbeEvents);
            _state.StateChanged += _state_StateChanged;
            var vbeVersion = double.Parse(_vbe.Version, CultureInfo.InvariantCulture);
            var predefinedCompilationConstants = new VBAPredefinedCompilationConstants(vbeVersion);
            var typeLibProvider = new TypeLibWrapperProvider(projectRepository);
            var compilationArgumentsProvider     = new CompilationArgumentsProvider(typeLibProvider, _dispatcher, predefinedCompilationConstants);
            var compilationsArgumentsCache       = new CompilationArgumentsCache(compilationArgumentsProvider);
            var preprocessorErrorListenerFactory = new PreprocessingParseErrorListenerFactory();
            var preprocessorParser              = new VBAPreprocessorParser(preprocessorErrorListenerFactory, preprocessorErrorListenerFactory);
            var preprocessor                    = new VBAPreprocessor(preprocessorParser, compilationsArgumentsCache);
            var mainParseErrorListenerFactory   = new MainParseErrorListenerFactory();
            var mainTokenStreamParser           = new VBATokenStreamParser(mainParseErrorListenerFactory, mainParseErrorListenerFactory);
            var tokenStreamProvider             = new SimpleVBAModuleTokenStreamProvider();
            var stringParser                    = new TokenStreamParserStringParserAdapterWithPreprocessing(tokenStreamProvider, mainTokenStreamParser, preprocessor);
            var projectManager                  = new RepositoryProjectManager(projectRepository);
            var moduleToModuleReferenceManager  = new ModuleToModuleReferenceManager();
            var parserStateManager              = new ParserStateManager(_state);
            var referenceRemover                = new ReferenceRemover(_state, moduleToModuleReferenceManager);
            var supertypeClearer                = new SupertypeClearer(_state);
            var comLibraryProvider              = new ComLibraryProvider();
            var referencedDeclarationsCollector = new LibraryReferencedDeclarationsCollector(comLibraryProvider);
            var comSynchronizer                 = new COMReferenceSynchronizer(_state, parserStateManager, projectRepository, referencedDeclarationsCollector);
            var builtInDeclarationLoader        = new BuiltInDeclarationLoader(
                _state,
                new List <ICustomDeclarationLoader>
            {
                new DebugDeclarations(_state),
                new SpecialFormDeclarations(_state),
                new FormEventDeclarations(_state),
                new AliasDeclarations(_state),
                //new RubberduckApiDeclarations(_state)
            }
                );
            var codePaneSourceCodeHandler   = new CodePaneSourceCodeHandler(projectRepository);
            var sourceFileHandler           = _vbe.TempSourceFileHandler;
            var attributesSourceCodeHandler = new SourceFileHandlerSourceCodeHandlerAdapter(sourceFileHandler, projectRepository);
            var moduleParser = new ModuleParser(
                codePaneSourceCodeHandler,
                attributesSourceCodeHandler,
                stringParser);
            var parseRunner = new ParseRunner(
                _state,
                parserStateManager,
                moduleParser);
            var declarationResolveRunner = new DeclarationResolveRunner(
                _state,
                parserStateManager,
                comSynchronizer);
            var referenceResolveRunner = new ReferenceResolveRunner(
                _state,
                parserStateManager,
                moduleToModuleReferenceManager,
                referenceRemover);
            var parsingStageService = new ParsingStageService(
                comSynchronizer,
                builtInDeclarationLoader,
                parseRunner,
                declarationResolveRunner,
                referenceResolveRunner
                );
            var parsingCacheService = new ParsingCacheService(
                _state,
                moduleToModuleReferenceManager,
                referenceRemover,
                supertypeClearer,
                compilationsArgumentsCache
                );

            _parser = new SynchronousParseCoordinator(
                _state,
                parsingStageService,
                parsingCacheService,
                projectManager,
                parserStateManager
                );
        }
 public ProjectsController()
 {
     repository = new ProjectsRepository();
 }
Exemplo n.º 11
0
 public ProjectsService(ProjectsRepository repository)
 {
     this.repository = repository;
 }
Exemplo n.º 12
0
 public MainWindowController()
 {
     ProjectRepository      = RepositoryHelper.GetProjectsRepository(database);
     ManufacturerRepository = RepositoryHelper.GetManufacturersRepository(database);
 }
Exemplo n.º 13
0
 public ProjectsController(ProjectsRepository projectsRepository, IMapper mapper)
 {
     _repository = projectsRepository;
     _mapper     = mapper;
 }
Exemplo n.º 14
0
        protected void group()
        {
            diverror.InnerHtml = "";
            if (ddlGroups.SelectedValue != "-2")
            {
                GroupsRepository Groupsrepo = new GroupsRepository();
                DataTable        DT         = new DataTable();
                DT = Groupsrepo.LoadSubGroup(ddlGroups.SelectedValue.ToInt());

                if ((DT.Rows.Count > 0))
                {
                    ddlSubGroups.Enabled = true;

                    ddlSubGroups.DataSource     = DT;
                    ddlSubGroups.DataTextField  = "Title";
                    ddlSubGroups.DataValueField = "GroupID";
                    ddlSubGroups.DataBind();
                    ddlSubGroups.Items.Insert(0, new ListItem("همه زیر گروه ها", "-2"));
                }
                else
                {
                    ddlSubGroups.Enabled = false;
                    ddlSubGroups.Items.Clear();
                    ddlSubGroups.Items.Insert(0, new ListItem("گروه : " + ddlGroups.SelectedItem.ToString(), ddlGroups.SelectedValue.ToString()));
                }
                //load posts
                List <int>         subgroupsid = Groupsrepo.getSubGroupsIDByFatherID(ddlGroups.SelectedValue.ToInt());
                ProjectsRepository artrep      = new ProjectsRepository();
                List <Project>     articles    = artrep.ReturnProjectsByCategory(subgroupsid);
                if (articles.Count != 0)
                {
                    gvPosts.DataSource = null;
                    gvPosts.DataSource = OnlineTools.ToDataTable(articles);
                    gvPosts.DataBind();
                }
                else
                {
                    gvPosts.DataSource = null;
                    gvPosts.DataBind();
                    diverror.InnerHtml         = " در این بخش مقاله ای وجود ندارد! ";
                    ddlSubGroups.SelectedIndex = 0;
                    ddlSubGroups.Enabled       = false;
                }
            }
            else
            {
                ProjectsRepository artRep = new ProjectsRepository();
                DataTable          DT     = new DataTable();
                DT = OnlineTools.ToDataTable(artRep.AllProjects());
                if (DT.Rows.Count != 0)
                {
                    gvPosts.DataSource = DT;
                    gvPosts.DataBind();
                    ddlSubGroups.SelectedIndex = 0;
                    ddlSubGroups.Enabled       = false;
                }
                else
                {
                    diverror.InnerHtml = " در این بخش مقاله ای وجود ندارد! ";
                    gvPosts.DataSource = null;
                    gvPosts.DataBind();
                }
            }
        }
Exemplo n.º 15
0
 public ProjectsBusiness(SqlConnection sqlConnection)
 {
     ProjectsRep = new ProjectsRepository(sqlConnection);
 }
Exemplo n.º 16
0
 public ProjectsController()
 {
     projectsRepository    = new ProjectsRepository(db);
     coursesRepository     = new CoursesRepository(db);
     submissionsRepository = new SubmissionsRepository(db);
 }
Exemplo n.º 17
0
 protected override void DisposeCore()
 {
     lock (_lockObject)
     {
         _connectionDbRepository = null;
         _projectsRepository = null;
         _projectsShareRepository = null;
         _queriesRepository = null;
         _usersRepository = null;
     }
     QueryBuilderContext.Dispose();
 }
Exemplo n.º 18
0
 public ProjectsController(ProjectsRepository repo)
 {
     _repo = repo;
 }