/// <summary>
        /// Generates project files for specified project.
        /// </summary>
        /// <param name="project">Parsed project object.</param>
        /// <returns>Path to main project file.</returns>
        public virtual string GenerateProjectFiles(ProjectCache project)
        {
            var projectDirectoryPath = Path.Combine(project.CachedLocation, "Build");
            Directory.CreateDirectory(projectDirectoryPath);

            return projectDirectoryPath;
        }
Exemple #2
0
        private DataCacheInternal createCacheInternal(
            InternalCacheUpdater cacheUpdater,
            string hostname,
            IHostProperties hostProperties,
            User user,
            SearchQueryCollection queryCollection,
            IModificationNotifier modificationNotifier,
            INetworkOperationStatusListener networkOperationStatusListener,
            bool isApprovalStatusSupported)
        {
            MergeRequestManager mergeRequestManager = new MergeRequestManager(
                _cacheContext, cacheUpdater, hostname, hostProperties, queryCollection, networkOperationStatusListener,
                isApprovalStatusSupported);
            DiscussionManager discussionManager = new DiscussionManager(
                _cacheContext, hostname, hostProperties, user, mergeRequestManager,
                modificationNotifier, networkOperationStatusListener);
            TimeTrackingManager timeTrackingManager = new TimeTrackingManager(
                hostname, hostProperties, user, discussionManager, modificationNotifier, networkOperationStatusListener);

            ProjectCache projectCache = null;

            if (_cacheContext.SupportProjectCache)
            {
                IProjectListLoader loader = new ProjectListLoader(hostname, _operator);
                projectCache = new ProjectCache(loader, _cacheContext, hostname);
            }
            UserCache userCache = null;

            if (_cacheContext.SupportUserCache)
            {
                IUserListLoader userListLoader = new UserListLoader(hostname, _operator);
                userCache = new UserCache(userListLoader, _cacheContext, hostname);
            }
            return(new DataCacheInternal(mergeRequestManager, discussionManager, timeTrackingManager, projectCache, userCache));
        }
Exemple #3
0
        private static IProjectCache SetUp(Mock <IProjectRepository> repository)
        {
            var memoryCache = new MemoryCache(new MemoryCacheOptions());
            var cache       = new ProjectCache(repository.Object, memoryCache);

            return(cache);
        }
Exemple #4
0
        void UpdatePrices()
        {
            var source = dgProjectJournalLinePageGrid.GetVisibleRows() as IEnumerable <ProjectJournalLineLocal>;

            foreach (var rec in source)
            {
                dgProjectJournalLinePageGrid.SetLoadedRow(rec);
                var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                if (pro != null)
                {
                    if (pro._Dim1 != null)
                    {
                        rec.Dimension1 = pro._Dim1;
                    }
                    if (pro._Dim2 != null)
                    {
                        rec.Dimension2 = pro._Dim2;
                    }
                    if (pro._Dim3 != null)
                    {
                        rec.Dimension3 = pro._Dim3;
                    }
                    if (pro._Dim4 != null)
                    {
                        rec.Dimension4 = pro._Dim4;
                    }
                    if (pro._Dim5 != null)
                    {
                        rec.Dimension5 = pro._Dim5;
                    }
                }

                rec.InsidePropChange = true;
                if (rec._Item != null)
                {
                    var cat = rec._PrCategory;
                    SetItem(rec);
                    SetCat(rec, cat);
                }

                getCostAndSales(rec);
                if (rec._Employee != null)
                {
                    TimePriceLookup?.GetEmployeePrice(rec);
                    var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee);
                    if (emp?._PayrollCategory != null)
                    {
                        rec.InsidePropChange = false;
                        rec.PayrollCategory  = emp._PayrollCategory;
                    }
                }
                else if (rec._PayrollCategory != null)
                {
                    PayrollCat(rec, true);
                }

                dgProjectJournalLinePageGrid.SetModifiedRow(rec);
                rec.InsidePropChange = false;
            }
        }
        private void ButtonDashboard_Click(object sender, RoutedEventArgs e)
        {
            TextblockPanelName.Text = "Dashboard";

            RoleCache.GetInstance().Clear();
            EmployeeCache.GetInstance().Clear();
            ResourceCache.GetInstance().Clear();
            CustomerCache.GetInstance().Clear();
            ProcessCache.GetInstance().Clear();
            ProjectCache.GetInstance().Clear();

            List <Resource> recs = ResourceCache.GetInstance().Resources;

            recs = ResourceCache.GetInstance().UpdateAllQSizes();
            recs = recs.OrderByDescending(r => r.QSize).ToList <Resource>();
            var emps = EmployeeCache.GetInstance().Employees;

            emps        = EmployeeCache.GetInstance().UpdateAllQSizes();
            emps        = emps.OrderByDescending(e => e.QSize).ToList <Employee>();
            DataContext = new DashboardViewModel
            {
                Resources        = new ObservableCollection <Resource>(recs),
                SelectedResource = recs[0],
                Employees        = new ObservableCollection <Employee>(emps),
                SelectedEmployee = emps[0]
            };
        }
        private void ProjectViewNewProjectClickHandler(ProjectsViewModel viewModel)
        {
            TextblockPanelName.Text = "Create New Project";

            RoleCache.GetInstance().Clear();
            EmployeeCache.GetInstance().Clear();
            ResourceCache.GetInstance().Clear();
            CustomerCache.GetInstance().Clear();
            ProcessCache.GetInstance().Clear();
            ProjectCache.GetInstance().Clear();
            var resources = ResourceCache.GetInstance().Resources;

            resources = ResourceCache.GetInstance().UpdateAllQSizes();

            DataContext = new AddEditProjectViewModel
            {
                Project = new Project
                {
                    Id          = 0,
                    Processes   = new List <Process>(),
                    StartDate   = DateTimeOffset.UtcNow,
                    PoDate      = DateTimeOffset.UtcNow,
                    Quantity    = 1,
                    OrderStatus = Project.ProjectOrderStatus.WaitingQuote,
                },
                BackClickedHandler = AddEditProjectViewBackClickHandler,
                Customers          = CustomerCache.GetInstance().Customers,
                Processes          = new ObservableCollection <Process>(new List <Process>()),
                Resources          = resources.OrderByDescending(r => r.QSize).ToList <Resource>(),
                Employees          = EmployeeCache.GetInstance().Employees
            };
        }
        //多选下拉列表框
        private static void DropDownListMultiSelects(HtmlHelper helper, SoftProjectAreaEntity data, StringBuilder sbHtml,
                                                     Type type, SoftProjectAreaEntity field, ref PropertyInfo property, ref object value, ref string val, string css = "")
        {
            #region  拉列表框
            property = type.GetProperty(field.name);
            value    = property.GetValue(data, null);
            if (value != null)
            {
                var strval = value.ToString();
                val = strval;
            }

            var dict = field.name;
            if (!string.IsNullOrEmpty(field.Dicts))
            {
                dict = field.Dicts;
            }

            if (ProjectCache.IsExistyCategory(dict))
            {
                var str = HtmlHelpers.DropDownListMultiSelect(helper, "Item." + field.name + "s", ProjectCache.GetByCategory(dict), "DValue", "DText", val, "");
                //var str = HtmlHelpers.DropDownList(helper, "Item." + field.name, ProjectCache.GetByCategory(dict), "DValue", "DText", val, css);
                sbHtml.AppendLine(str.ToString());
            }
            else
            {
                if (ProjectCache.HtmlDropDownListMultiSelects.ContainsKey(field.name))
                {
                    var str = ProjectCache.HtmlDropDownListMultiSelects[field.name](val, field.NameCn, data);
                    sbHtml.AppendLine(str.ToString());
                }
            }
            #endregion
        }
Exemple #8
0
        public RoslynDocument CreateExcessDocument(string text, DocumentId document)
        {
            ProjectCache cache;

            if (!_projects.TryGetValue(document.ProjectId, out cache))
            {
                ensureNuget();

                cache = new ProjectCache(_workspace, document.ProjectId, _nuget, _nugetEvents);
                _projects[document.ProjectId] = cache;
            }

            //td: we need the using list in order to deduct the extensions
            //however, we don't need to parse the whole document.
            //We must optimize this (maybe a custom using parser?)
            var compilationUnit = CSharp.ParseCompilationUnit(text);
            var extensions      = new List <UsingDirectiveSyntax>(compilationUnit.Usings);
            var keywords        = null as IEnumerable <string>;
            var compiler        = cache.GetCompiler(document, extensions, out keywords);

            //build a new document
            var result = new RoslynDocument(compiler.Scope, text);

            result.Mapper = new MappingService();
            compiler.apply(result);

            var scanner = null as Scanner;

            if (keywords != null && keywords.Any() && _scannerCache.TryGetValue(document, out scanner))
            {
                scanner.Keywords = XSKeywords.Values.Union(keywords);
            }

            return(result);
        }
Exemple #9
0
        protected virtual bool BuildManifest()
        {
            BuildDir = Path.GetDirectoryName(Project.FullName) + "\\bin\\" + SolutionBuild.ActiveConfiguration.Name +
                       "\\";
            string cacheDir = Common.GetHostDir() + "\\_Projects\\" + Project.FullName.MD5() + "\\project.xml";

            CacheHelper = new CacheHelper <ProjectCache>();
            try
            {
                ProjectCache = CacheHelper.Get(cacheDir);
            }
            catch
            {
                ProjectCache = new ProjectCache();
            }

            if (_productToRelease == null)
            {
                _productToRelease = ProjectUtil.GetProductInfo(Project);
            }
            List <FileListItem> files = GatherFiles(BuildDir);
            ////string releaseFileName = Path.GetDirectoryName(prj.FullName) + "\\" + Common.ManifestFileName;

            string releaseFileName = Path.GetDirectoryName(Project.FullName) + "\\bin\\" + Common.ManifestFileName;

            if (File.Exists(releaseFileName))
            {
                Manifest = FileUtil.ReadManifest(releaseFileName);
            }
            if (Manifest == null)
            {
                string[] icons = Directory.GetFiles(BuildDir, "*.ico");
                Manifest = new Manifest
                {
                    AppName      = _productToRelease.Name,
                    Company      = _productToRelease.CompanyName,
                    EntryPoint   = Common.GetAssemblyName(Project) + ".exe",
                    ShortcutIcon = icons.Length > 0 ? Path.GetFileName(icons[0]) : ""
                };
            }
            Manifest.ReleaseVersion = _productToRelease.Version;
            Manifest.MinVersion     = _productToRelease.Version;

            var f = new ReleaseForm(BuildDir, files, Manifest);

            f.ZipOnly = ZipOnly;
            if (f.ShowDialog() == DialogResult.OK)
            {
                if (ProjectCache == null)
                {
                    ProjectCache = new ProjectCache();
                }
                ProjectCache.ExcludeFiles   = f.GetExcludedFiles().ToList();
                ProjectCache.ExcludeFolders = f.GetExcludedFolders().ToList();
                CacheHelper.Save(ProjectCache, cacheDir);
                return(true);
            }
            return(false);
        }
        public void Update(ProjectConfiguration projConfig, Project proj, MonoDevelopWorkspace.ProjectDataMap projectMap,
                           ImmutableArray <ProjectFile> files,
                           ImmutableArray <FilePath> analyzers,
                           ImmutableArray <MonoDevelopMetadataReference> metadataReferences,
                           ImmutableArray <Microsoft.CodeAnalysis.ProjectReference> projectReferences)
        {
            if (!enabled)
            {
                return;
            }

            var paths   = new string [files.Length];
            var actions = new string [files.Length];

            for (int i = 0; i < files.Length; ++i)
            {
                paths [i]   = files [i].FilePath;
                actions [i] = files [i].BuildAction;
            }

            var projectRefs = new ReferenceItem [projectReferences.Length];

            for (int i = 0; i < projectReferences.Length; ++i)
            {
                var pr        = projectReferences [i];
                var mdProject = projectMap.GetMonoProject(pr.ProjectId);
                projectRefs [i] = new ReferenceItem {
                    FilePath = mdProject.FileName,
                    Aliases  = pr.Aliases.ToArray(),
                };
            }

            var item = new ProjectCache {
                Format             = format,
                Analyzers          = analyzers.Select(x => (string)x).ToArray(),
                Files              = paths,
                BuildActions       = actions,
                TimeStamp          = File.GetLastWriteTimeUtc(proj.FileName),
                MetadataReferences = metadataReferences.Select(x => {
                    var ri = new ReferenceItem {
                        FilePath = x.FilePath,
                        Aliases  = x.Properties.Aliases.ToArray(),
                    };
                    return(ri);
                }).ToArray(),
                ProjectReferences = projectRefs,
            };

            var cacheFile = GetProjectCacheFile(proj, projConfig.Id);

            var serializer = new JsonSerializer();

            using (var fs = File.Open(cacheFile, FileMode.Create))
                using (var sw = new StreamWriter(fs)) {
                    serializer.Serialize(sw, item);
                }
        }
Exemple #11
0
        private void Task_GotFocus(object sender, RoutedEventArgs e)
        {
            var selectedItem = dgProjectJournalLinePageGrid.SelectedItem as ProjectJournalLineLocal;

            if (selectedItem?._Project != null)
            {
                setTask((Uniconta.DataModel.Project)ProjectCache.Get(selectedItem._Project), selectedItem);
            }
        }
 private void ButtonManageProjects_Click(object sender, RoutedEventArgs e)
 {
     TextblockPanelName.Text = "Manage Projects";
     DataContext             = new ProjectsViewModel
     {
         ProjectsToDisplay       = new ObservableCollection <Project>(ProjectCache.GetInstance().Projects),
         NewProjectClickHandler  = ProjectViewNewProjectClickHandler,
         ProjectOpenClickHandler = ProjectViewOpenProectClickHandler
     };
 }
Exemple #13
0
        /// <inheritdoc />
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:Jfevia.ProductivityShell.Vsix.Solutions.SolutionProxy" /> class.
        /// </summary>
        /// <param name="vsProxy">The Visual Studio proxy.</param>
        /// <param name="target">The Productivity Shell solution.</param>
        public SolutionProxy(ShellProxy vsProxy, SolutionModel.Solution target)
            : base(vsProxy)
        {
            _configurationFileTrackers = new List <ConfigurationFileTracker>();
            _projectCache = new ProjectCache();
            Source        = VsProxy.VsSolution;
            Target        = target;

            Initialize();
        }
Exemple #14
0
        private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var rec = (ProjectInvoiceProjectLineLocal)sender;

            switch (e.PropertyName)
            {
            case "Item":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    SetItem(rec);
                    getCostAndSales(rec);
                    rec.InsidePropChange = false;
                }
                break;

            case "Project":
                var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                if (pro != null)
                {
                    if (pro._Dim1 != null)
                    {
                        rec.Dimension1 = pro._Dim1;
                    }
                    if (pro._Dim2 != null)
                    {
                        rec.Dimension2 = pro._Dim2;
                    }
                    if (pro._Dim3 != null)
                    {
                        rec.Dimension3 = pro._Dim3;
                    }
                    if (pro._Dim4 != null)
                    {
                        rec.Dimension4 = pro._Dim4;
                    }
                    if (pro._Dim5 != null)
                    {
                        rec.Dimension5 = pro._Dim5;
                    }
                    getCostAndSales(rec);
                }
                break;

            case "PrCategory":
                getCostAndSales(rec);
                break;

            case "Qty":
                UpdatePrice(rec);
                break;
            }
            RecalculateAmount();
        }
Exemple #15
0
        /// <summary>
        /// Get project by name
        /// </summary>
        /// <param name="name">name of project</param>
        /// <returns>default project if empty string, new project object if new project name, existing project if already there</returns>
        public Project GetProject(string name)
        {
            Project project = ProjectCache.GetInstance().GetProjectByName(name);

            if (project == null)
            {
                project      = new Project();
                project.ID   = -1;
                project.Name = name;
            }
            return(project);
        }
Exemple #16
0
 public Project SyncProject(Project p)
 {
     if (ProjectCache.GetInstance().GetProjectById(p.ID) == null)
     {
         InsertNewProject(p);
     }
     else
     {
         ProjectCache.GetInstance().UpdateProject(p);
     }
     return(GetProject(p.Name));
 }
        public void ProjectValidateAttribute_Invalid_Value_Throws()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._values);
            ProjectCache.Cache.Shell = ps;
            ProjectCache.Invalidate();

            // Act
            // Assert
            Assert.ThrowsException <ValidationMetadataException>(() => this.Validate("Test", null));
        }
Exemple #18
0
        async void getCostAndSales(ProjectJournalLineLocal rec)
        {
            var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);

            if (proj == null)
            {
                return;
            }

            var Categories = proj.Categories ?? await proj.LoadCategories(api);

            rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d;
            if (Categories == null)
            {
                return;
            }

            var Category = rec._PrCategory;
            var projCat  = (from ct in Categories where ct._PrCategory == Category select ct).FirstOrDefault();

            if (projCat != null)
            {
                rec.costPct     = projCat._CostPctCharge;
                rec.salesPct    = projCat._SalesPctCharge;
                rec.costAmount  = projCat._CostAmountCharge;
                rec.salesAmount = projCat._SalesAmountCharge;
            }
            else
            {
                var prstd = (PrStandard)PrStandardCache.Get(proj._PrStandard);
                if (prstd == null)
                {
                    return;
                }
                var PrCategories = prstd.Categories ?? await prstd.LoadCategories(api);

                if (PrCategories == null)
                {
                    return;
                }

                var prCat = (from ct in PrCategories where ct._PrCategory == Category select ct).FirstOrDefault();
                if (prCat != null)
                {
                    rec.costPct     = prCat._CostPctCharge;
                    rec.salesPct    = prCat._SalesPctCharge;
                    rec.costAmount  = prCat._CostAmountCharge;
                    rec.salesAmount = prCat._SalesAmountCharge;
                }
            }
        }
        public void Update(ProjectConfiguration projConfig, string framework, Project proj, MonoDevelopWorkspace.ProjectDataMap projectMap, ProjectCacheInfo info)
        {
            if (!loaded)
            {
                return;
            }

            var paths   = new string [info.SourceFiles.Length];
            var actions = new string [info.SourceFiles.Length];

            for (int i = 0; i < info.SourceFiles.Length; ++i)
            {
                paths [i]   = info.SourceFiles [i].FilePath;
                actions [i] = info.SourceFiles [i].BuildAction;
            }

            var projectRefs = new ReferenceItem [info.ProjectReferences.Length];

            for (int i = 0; i < info.ProjectReferences.Length; ++i)
            {
                var pr = info.ProjectReferences [i];
                (Project mdProject, string projectReferenceFramework) = projectMap.GetMonoProjectAndFramework(pr.ProjectId);
                projectRefs [i] = new ReferenceItem {
                    FilePath  = mdProject.FileName,
                    Aliases   = pr.Aliases.ToArray(),
                    Framework = projectReferenceFramework
                };
            }

            var item = new ProjectCache {
                Format             = format,
                AdditionalFiles    = info.AdditionalFiles.Select(x => (string)x).ToArray(),
                Analyzers          = info.AnalyzerFiles.Select(x => (string)x).ToArray(),
                EditorConfigFiles  = info.EditorConfigFiles.Select(x => (string)x).ToArray(),
                Files              = paths,
                BuildActions       = actions,
                MetadataReferences = info.References.Select(x => {
                    var ri = new ReferenceItem {
                        FilePath = x.FilePath,
                        Aliases  = x.Properties.Aliases.ToArray(),
                    };
                    return(ri);
                }).ToArray(),
                ProjectReferences = projectRefs,
            };

            string configId  = GetConfigId(projConfig);
            var    cacheFile = GetProjectCacheFile(proj, configId, framework);

            WriteCacheFile(item, cacheFile);
        }
Exemple #20
0
        void UpdatePrices()
        {
            var source = dgDebtorOrderProjectLineGrid.GetVisibleRows() as IEnumerable <DebtorOrderProjectLineLocal>;

            foreach (var rec in source)
            {
                dgDebtorOrderProjectLineGrid.SetLoadedRow(rec);
                var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                if (pro != null)
                {
                    if (pro._Dim1 != null)
                    {
                        rec.Dimension1 = pro._Dim1;
                    }
                    if (pro._Dim2 != null)
                    {
                        rec.Dimension2 = pro._Dim2;
                    }
                    if (pro._Dim3 != null)
                    {
                        rec.Dimension3 = pro._Dim3;
                    }
                    if (pro._Dim4 != null)
                    {
                        rec.Dimension4 = pro._Dim4;
                    }
                    if (pro._Dim5 != null)
                    {
                        rec.Dimension5 = pro._Dim5;
                    }
                }

                rec.InsidePropChange = true;
                if (rec._Item != null)
                {
                    var cat = rec._PrCategory;
                    SetItem(rec);
                    if (cat != null)
                    {
                        rec.PrCategory = cat;
                    }
                }
                else
                {
                    getCostAndSales(rec);
                }

                dgDebtorOrderProjectLineGrid.SetModifiedRow(rec);
                rec.InsidePropChange = false;
            }
        }
Exemple #21
0
        async void getCostAndSales(ProjectInvoiceProjectLineLocal rec)
        {
            var project = rec._Project;

            if (project == null)
            {
                return;
            }
            var proj       = (Uniconta.DataModel.Project)ProjectCache.Get(project);
            var Categories = proj.Categories ?? await proj.LoadCategories(api);

            rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d;

            var Category = rec._PrCategory;

            var prcategory = (Uniconta.DataModel.PrCategory)CategoryCache.Get(Category);

            if (prcategory != null && prcategory._Forward)
            {
                rec.ProjectForward = invoiceProposal._Project;
            }

            var projCat = (from ct in Categories where ct._PrCategory == Category select ct).FirstOrDefault();

            if (projCat != null)
            {
                rec.costPct     = projCat._CostPctCharge;
                rec.salesPct    = projCat._SalesPctCharge;
                rec.costAmount  = projCat._CostAmountCharge;
                rec.salesAmount = projCat._SalesAmountCharge;
            }
            else
            {
                var prstd = (PrStandard)PrStandardCache.Get(proj._PrStandard);
                if (prstd == null)
                {
                    return;
                }
                var PrCategories = prstd.Categories ?? await prstd.LoadCategories(api);

                var prCat = (from ct in PrCategories where ct._PrCategory == Category select ct).FirstOrDefault();
                if (prCat != null)
                {
                    rec.costPct     = prCat._CostPctCharge;
                    rec.salesPct    = prCat._SalesPctCharge;
                    rec.costAmount  = prCat._CostAmountCharge;
                    rec.salesAmount = prCat._SalesAmountCharge;
                }
            }
            RecalculateAmount();
        }
        public void ProjectValidateAttribute_Valid_Value_Wrong_Case_Does_Not_Throw()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._values);
            ProjectCache.Cache.Shell = ps;
            ProjectCache.Invalidate();

            // Act
            this.Validate("project2", null);

            // Assert
        }
Exemple #23
0
 public List <Project> RetrieveAllProjects()
 {
     if (ProjectCache.GetInstance().GetProjectByName(string.Empty) == null)
     {
         Project noProject = new Project();
         noProject.Name      = string.Empty;
         noProject.Status    = Project.ProjectStatus.InProgress;
         noProject.StartDate = new DateTime(2000, 1, 1);
         noProject.EndDate   = new DateTime(2099, 1, 1);
         noProject.Comment   = string.Empty;
         ProjectCache.GetInstance().InsertProject(noProject);
     }
     return(ProjectCache.GetInstance().Projects);
 }
        public void ProjectValidateAttribute_Empty_Cache_Does_Not_Throw()
        {
            // Arrange
            var ps = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._empty);
            ProjectCache.Cache.Shell = ps;
            ProjectCache.Invalidate();

            // Act
            this.Validate("Project1", null);

            // Assert
        }
Exemple #25
0
        public void ProjectCache_Update_Returns_Null()
        {
            // Arrange
            var expected = 0;
            var ps       = BaseTests.PrepPowerShell();

            ProjectCache.Cache.Shell = ps;

            // Act
            ProjectCache.Update(null);

            // Assert
            Assert.AreEqual(expected, ProjectCache.Cache.Values.Count);
        }
Exemple #26
0
        public void ProjectCache_Update_With_Empty_List()
        {
            // Arrange
            var expected = 0;
            var ps       = BaseTests.PrepPowerShell();

            ProjectCache.Cache.Shell = ps;

            // Act
            ProjectCache.Update(new List <string>());

            // Assert
            Assert.AreEqual(expected, ProjectCache.Cache.Values.Count);
        }
Exemple #27
0
        public void ProjectCache_Update_With_Null_List()
        {
            // Arrange
            var expected = 2;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._templates);
            ProjectCache.Cache.Shell = ps;

            // Act
            ProjectCache.Update(null);

            // Assert
            Assert.AreEqual(expected, ProjectCache.Cache.Values.Count);
        }
Exemple #28
0
        public void DeleteProject(int p)
        {
            TransactionManager tm = new TransactionManager();
            //find all transactions under the project to be deleted
            List <Transaction> transactions = tm.GetTransactionsByProjectId(p);

            //replace the project of all the above transactions with the default project
            foreach (Transaction t in transactions)
            {
                t.ParentProject = GetProject(string.Empty);
                tm.SyncTransaction(t);
            }
            //now delete the project from db and cache
            ProjectCache.GetInstance().DeleteProject(p);
        }
        internal void WriteCacheFile(ProjectCache item, string cacheFile)
        {
            FileLock fileLock = AcquireWriteLock(cacheFile);

            try {
                lock (fileLock) {
                    var serializer = new JsonSerializer();
                    using (var fs = File.Open(cacheFile, FileMode.Create))
                        using (var sw = new StreamWriter(fs)) {
                            serializer.Serialize(sw, item);
                        }
                }
            } finally {
                ReleaseWriteLock(cacheFile, fileLock);
            }
        }
Exemple #30
0
        public void ProjectCache_GetCurrent()
        {
            // Arrange
            var expected = 2;
            var ps       = BaseTests.PrepPowerShell();

            ps.Invoke <string>().Returns(this._templates);
            ProjectCache.Cache.Shell = ps;
            ProjectCache.Invalidate();

            // Act
            var actual = ProjectCache.GetCurrent(false);

            // Assert
            Assert.AreEqual(expected, actual.Count());
        }
Exemple #31
0
        private void Task_GotFocus(object sender, RoutedEventArgs e)
        {
            var selectedItem = dgCreditorOrderLineGrid.SelectedItem as CreditorOrderLineClient;

            if (selectedItem?._Project != null)
            {
                var selected = (ProjectClient)ProjectCache.Get(selectedItem._Project);
                setTask(selected, selectedItem);
                if (prevTask != null)
                {
                    prevTask.isValidate = false;
                }
                var editor = (CorasauGridLookupEditorClient)sender;
                prevTask          = editor;
                editor.isValidate = true;
            }
        }
        /// <summary>
        /// Generates project files for Visual Studio: '.vcxproj' and '.vcxproj.filter'.
        /// </summary>
        /// <param name="project">Parsed project object.</param>
        /// <returns>Path to Visual Studio's '.vcxproj file'.</returns>
        public override sealed string GenerateProjectFiles(ProjectCache project)
        {
            var vcxProjPath = Path.Combine(base.GenerateProjectFiles(project), project.CachedName) + ".vcxproj";

            try
            {
                // For build tools the best was is to load a GUID from project files: this causes exceptions
                // in Visual Studio when reloading of solution, and all opened tabs would be terminated.
                project.AdditionalCache.GUID = QueryGuidFromProject(vcxProjPath);
            }
            catch (Exception)
            {
                project.AdditionalCache.GUID = CreateMsBuildGuid();
            }

            // ==========================================================================================
            // Generating VCXPROJ files.
            // ==========================================================================================
            using (var vcxProj = new XmlTextWriter(vcxProjPath, null) { Formatting = Formatting.Indented, Indentation = 1, IndentChar = '\t' })
            {
                vcxProj.WriteStartDocument();
                vcxProj.WriteComment("Generated by GoddamnBuildSystem. Please, do not edit this file manually.");
                vcxProj./**/WriteStartElement("Project", c_MsBuild2003Namespace);
                vcxProj./**//**/WriteAttributeString("ToolsVersion", c_ToolsVersion);
                vcxProj./**//**/WriteAttributeString("DefaultTargets", "Build");

                // ------------------------------------------------------------------------------------------
                // Defining list of configurations.
                // ------------------------------------------------------------------------------------------
                vcxProj.WriteStartElement("ItemGroup");
                vcxProj./**/WriteAttributeString("Label", "ProjectConfigurations");
                foreach (var platform in TargetInfo.EnumerateAllPlatforms())
                {
                    var platformString = ConvertPlatformToMsBuildPlatform(platform);
                    foreach (var configuration in TargetInfo.EnumerateAllConfigurations())
                    {
                        var configurationName = string.Concat(configuration, platform);
                        vcxProj./**/WriteStartElement("ProjectConfiguration");
                        vcxProj./**//**/WriteAttributeString("Include", configurationName + '|' + platformString);
                        vcxProj./**//**/WriteElementString("Configuration", configurationName);
                        vcxProj./**//**/WriteElementString("Platform", platformString);
                        vcxProj./**/WriteEndElement();
                    }
                }
                vcxProj.WriteEndElement();

                // ------------------------------------------------------------------------------------------
                // Defining list of source files.
                // ------------------------------------------------------------------------------------------
                vcxProj.WriteStartElement("ItemGroup");
                foreach (var projectSource in project.CachedSourceFiles)
                {
                    vcxProj./**/WriteStartElement(ConvertFileTypeToVcxProjElement(projectSource.FileType));
                    vcxProj./**//**/WriteAttributeString("Include", projectSource.FileName);
                    foreach (var platform in TargetInfo.EnumerateAllPlatforms())
                    {
                        var platformString = ConvertPlatformToMsBuildPlatform(platform);
                        foreach (var configuration in TargetInfo.EnumerateAllConfigurations())
                        {
                            if (projectSource.ShouldBeExcluded(platform, configuration))
                            {
                                var configurationName = string.Concat(configuration, platform);
                                vcxProj./**//**/WriteStartElement("ExcludedFromBuild");
                                vcxProj./**//**//**/WriteAttributeStringFormat("Condition", @"'$(Configuration)|$(Platform)'=='{0}|{1}'", configurationName, platformString);
                                vcxProj./**//**//**/WriteString("true");
                                vcxProj./**//**/WriteEndElement();
                            }
                        }
                    }
                    vcxProj./**/WriteEndElement();
                }
                vcxProj.WriteEndElement();

                // ------------------------------------------------------------------------------------------
                // Overriding global project properties.
                // ------------------------------------------------------------------------------------------
                vcxProj.WriteStartElement("PropertyGroup");
                vcxProj./**/WriteElementString("ProjectGuid", project.AdditionalCache.GUID);
                vcxProj./**/WriteElementString("RootNamespace", project.CachedName);
                vcxProj./**/WriteElementString("MinimumVisualStudioVersion", "14.0");
                vcxProj.WriteEndElement();
                foreach (var platform in TargetInfo.EnumerateAllPlatforms())
                {
                    var platformString = ConvertPlatformToMsBuildPlatform(platform);
                    foreach (var configuration in TargetInfo.EnumerateAllConfigurations())
                    {
                        var configurationName = string.Concat(configuration, platform);
                        vcxProj.WriteStartElement("PropertyGroup");
                        vcxProj./**/WriteAttributeStringFormat("Condition", "'$(Configuration)|$(Platform)'=='{0}|{1}'", configurationName, platformString);
                        vcxProj./**/WriteAttributeString("Label", "Globals");
                        if (TargetInfo.IsMicrosoftPlatform(platform))
                        {
                            //vcxProj./**/WriteElementString("AppContainerApplication", "true");
                            //vcxProj./**/WriteElementString("ApplicationType", "Windows Store");
                            //vcxProj./**/WriteElementString("WindowsTargetPlatformVersion", "10.0.10240.0");
                            //vcxProj./**/WriteElementString("WindowsTargetPlatformMinVersion", "10.0.10240.0");
                            //vcxProj./**/WriteElementString("ApplicationTypeRevision", "10");
                        }
                        vcxProj.WriteEndElement();
                    }