public void CanGetTortoiseProcPathFromRegistry() { var path = PathConfiguration.GetTortoiseGitPathFromRegistry(); Assert.NotNull(path); Assert.EndsWith("TortoiseGitProc.exe", path, StringComparison.InvariantCultureIgnoreCase); }
public void Get_solution_folder_traverses_parents_till_git_folder_found() { var solution = GetOpenSolution(); var solutionPath = PathConfiguration.GetSolutionPath(solution); Assert.True(Directory.Exists(Path.Combine(solutionPath, ".git")), "Returned solution path is not the repository root."); }
static void Main(string[] args) { var db = new MongoClient("mongodb://127.0.0.1:27017/").GetDatabase("wikidata"); var triplets = db.GetCollection <Triplet>("triplet"); _config = new PathConfiguration(); _asyncSaver = new AsyncSaver(triplets); _count = GetLinesCount(_config.PositionsPath, _config.GetPath(CountFilePath)); _offset = GetOffset(_config.GetPath(OffsetFilePath)); _startOffset = _offset; _timer = new Stopwatch(); using (var wikiFile = new WikidumpReader(_config.WikipediaPath)) { var algo = new AlgoInMemory(_asyncSaver, wikiFile, triplets, _config.PositionsPath); _timer.Start(); algo.OnProcessed += algo_OnProcessed; algo.Process(_offset); } _asyncSaver.Join(); Task.WaitAll(); Console.ReadKey(); }
public IActionResult ProductDetail(int?id) { //Get Top ProductVM productVM; productVM = new ProductVM() { UnitList = _unitOfWork.Unit.GetUnitListForDropDown(), CategoryList = _unitOfWork.Category.GetCategoryListForDropDown(), PicFileNames = String.Empty, ErrorMessage = String.Empty, MaxUploadFileNumber = HCConstant.MAX_PRODUCT_UPLOAD_FILES, }; if (id == null) { return(NotFound()); } else { productVM.Product = _unitOfWork.Product.Get(id.GetValueOrDefault()); if (productVM.Product == null) { return(NotFound()); } productVM.ImagePath = PathConfiguration.GetProductImgStoreFolder(); productVM.Images = _unitOfWork.ProductImage.GetByProduct(id.GetValueOrDefault()); } return(View(productVM)); }
private static bool GetGogDir(string gogName, out IAbsoluteDirectoryPath gogDir) { // TODO: Find the GOG Games folder var gog = @"C:\GOG Games".ToAbsoluteDirectoryPath(); if (gog.Exists) { var gogSB = gog.GetChildDirectoryWithName(gogName); if (gogSB.Exists) { gogDir = gogSB; return(true); } } // TODO: Find galaxy client var galaxy = PathConfiguration.GetFolderPath(EnvironmentSpecial.SpecialFolder.ProgramFilesX86) .ToAbsoluteDirectoryPath() .GetChildDirectoryWithName(@"GalaxyClient") .GetChildDirectoryWithName("Games"); if (galaxy.Exists) { var gogSB = galaxy.GetChildDirectoryWithName(gogName); if (gogSB.Exists) { gogDir = gogSB; return(true); } } gogDir = null; return(false); }
public IActionResult Index() { //Get Top var homeviewMD = new HomeView(); homeviewMD.ProductImagePath = PathConfiguration.GetProductImgStoreFolder(); homeviewMD.AvatarPath = PathConfiguration.GetAvatarStoreFolder(); homeviewMD.BestProducts = _unitOfWork.SP.ReturnList <ProductSimpleView>(SP.SelectTop4Product); homeviewMD.CategoryList = _unitOfWork.Category.GetAll(); homeviewMD.NewProducts = _unitOfWork.SP.ReturnList <ProductSimpleView>(SP.SelectTop4NewProduct); homeviewMD.BestSuppliers = _unitOfWork.SP.ReturnList <AppUserView>(SP.SelectTop10Seller); //Check pics if not existed , replaced by default pic foreach (ProductSimpleView p in homeviewMD.BestProducts) { SetDefaultValueForProductAvatar(p); } foreach (ProductSimpleView p in homeviewMD.NewProducts) { SetDefaultValueForProductAvatar(p); } foreach (AppUserView s in homeviewMD.BestSuppliers) { var filePath = PathConfiguration.GetAvatarStoreFolder(_hostEnvironment) + "\\" + s.AvartarUrl; FileInfo file = new FileInfo(filePath); if (!file.Exists)//check file exsit or not { //p.FileName = s.AvartarUrl = PathConfiguration.GetDefaultSupplierImg(_configuration); } } return(View(homeviewMD)); }
public void CanGetGitBashPathFromRegistry() { var path = PathConfiguration.GetGitBashPathFromRegistry(); Assert.NotNull(path); Assert.EndsWith("sh.exe", path, StringComparison.InvariantCultureIgnoreCase); }
public IActionResult Upsert(ProductVM productVM) { if (ModelState.IsValid) { SaveProductInfo(productVM); bool isSucces = SaveProductImages(productVM); if (!isSucces) { return(View(productVM)); } _unitOfWork.Save(); return(RedirectToAction(nameof(Index))); } else { productVM.ErrorMessage = ""; productVM.UnitList = _unitOfWork.Unit.GetUnitListForDropDown(); productVM.CategoryList = _unitOfWork.Category.GetCategoryListForDropDown(); productVM.ImagePath = PathConfiguration.GetProductImgStoreFolder(); productVM.Images = _unitOfWork.ProductImage.GetByProduct(productVM.Product.Id); return(View(productVM)); } }
static IAbsoluteDirectoryPath GetDefaultRockstarDirectory() { IAbsoluteDirectoryPath dir; var pf64 = GetProgramFiles64(); if (pf64 != null) { dir = pf64 .GetChildDirectoryWithName("Rockstar Games") .GetChildDirectoryWithName("Grand Theft Auto V"); if (dir.Exists) { return(dir); } } dir = PathConfiguration.GetFolderPath(EnvironmentSpecial.SpecialFolder.ProgramFilesX86) .ToAbsoluteDirectoryPath() .GetChildDirectoryWithName("Rockstar Games") .GetChildDirectoryWithName("Grand Theft Auto V"); if (dir.Exists) { return(dir); } return(null); }
private static string GetExpectedCommand(ToolbarCommand toolbarCommand) { switch (toolbarCommand) { case ToolbarCommand.Commit: case ToolbarCommand.Log: case ToolbarCommand.Pull: case ToolbarCommand.Push: case ToolbarCommand.Resolve: case ToolbarCommand.Switch: case ToolbarCommand.Cleanup: case ToolbarCommand.Fetch: case ToolbarCommand.Revert: case ToolbarCommand.Sync: case ToolbarCommand.Merge: case ToolbarCommand.StashSave: case ToolbarCommand.StashPop: case ToolbarCommand.StashList: case ToolbarCommand.Rebase: case ToolbarCommand.FileLog: case ToolbarCommand.FileDiff: case ToolbarCommand.FileBlame: return(PathConfiguration.GetTortoiseGitPath()); case ToolbarCommand.Bash: case ToolbarCommand.RebaseContinue: return(PathConfiguration.GetGitBashPath()); } throw new InvalidOperationException($"You need to define an expected test process command result for {toolbarCommand}."); }
public SettingsForm(ApplicationConfiguration applicationConfiguration, XgminerConfiguration minerConfiguration, PathConfiguration pathConfiguration) { InitializeComponent(); this.minerConfiguration = minerConfiguration; this.applicationConfiguration = applicationConfiguration; this.pathConfiguration = pathConfiguration; }
public LocalFileResourceManager( string fileResourceLocation, PathConfiguration pathConfiguration, ILogger logger, ITranslator translator, IMapper mapper, IPaginationConfiguration paginationConfiguration ) : base(logger, translator, mapper, paginationConfiguration) { m_fileResourceLocation = fileResourceLocation; m_pathConfiguration = pathConfiguration; }
public void Setup() { _processManager = A.Fake <IProcessManager>(); _pathConfiguration = new PathConfiguration(); CommonBase.AssemblyLoader = SharedSupport.GetAssemblyLoader(); _pathConfiguration.SetPaths(); _tempRsyncExe = _pathConfiguration.ToolCygwinBinPath.GetChildFileWithName("rsync.exe"); _launcher = new RsyncLauncher(_processManager, _pathConfiguration, new RsyncOutputParser()); }
/* * One product has at max 3 pics & the first one must be the Default one. */ private bool SaveProductImages(ProductVM productVM) { int countProductImg = 0; IEnumerable <ProductImage> pImgs = _unitOfWork.ProductImage.GetByProduct(productVM.Product.Id); foreach (var imag in pImgs) { countProductImg++; } String[] deletedImgIds = null; String[] picNames = null; if (productVM.UploadedImgIdBeRemoved != null && productVM.Product.Id > 0 && productVM.UploadedImgIdBeRemoved.Trim().Length > 0) { deletedImgIds = productVM.UploadedImgIdBeRemoved.Split(";"); countProductImg = countProductImg - deletedImgIds.Length; } if (productVM.PicFileNames != null && productVM.PicFileNames.Trim().Length > 0) { picNames = productVM.PicFileNames.Split(";"); countProductImg = countProductImg + picNames.Length; } if (countProductImg > HCConstant.MAX_PRODUCT_UPLOAD_FILES) { productVM.UnitList = _unitOfWork.Unit.GetUnitListForDropDown(); productVM.CategoryList = _unitOfWork.Category.GetCategoryListForDropDown(); productVM.ErrorMessage = "Only 3 images are uploaded for each product."; productVM.ImagePath = PathConfiguration.GetProductImgStoreFolder(); productVM.Images = pImgs; return(false); } else { if (deletedImgIds != null) { DeleteProductPics(productVM.Product.Id, deletedImgIds); } if (picNames != null) { CreateProductImages(picNames, productVM.Product); } //Set IsDefault for the first one pic IEnumerable <ProductImage> productImgs = _unitOfWork.ProductImage.GetByProduct(productVM.Product.Id); Boolean defaultImg = true; foreach (ProductImage pImg in productImgs) { pImg.IsDefault = defaultImg; defaultImg = false; _unitOfWork.ProductImage.Update(pImg); } } return(true); }
private PathConfiguration PathField(string label, PathConfiguration path) { PathConfiguration temp = path; EditorGUILayout.BeginHorizontal(); temp.Location = EditorGUILayout.TextField(label, temp.Location); temp.SkipPackageStructure = EditorGUILayout.Toggle("Skip Package structure?", temp.SkipPackageStructure, GUILayout.Width(180f)); temp.SkipPackageStructureSpecified = temp.SkipPackageStructure == true; EditorGUILayout.EndHorizontal(); return(temp); }
public void Launch_git_bash(bool solutionOpen) { var solution = solutionOpen ? GetOpenSolution() : GetClosedSolution(); var tortoiseGitLauncherService = Substitute.For <TortoiseGitLauncherService>(_processManagerService, solution); const ToolbarCommand command = ToolbarCommand.Bash; tortoiseGitLauncherService.ExecuteTortoiseProc(command); _processManagerService.Received().GetProcess( GetExpectedCommand(command), GetExpectedParameters(command), PathConfiguration.GetSolutionPath(solution) ); }
public void Launch_rebase_continue_in_git_bash() { var solution = GetOpenSolution(); var tortoiseGitLauncherService = Substitute.For <TortoiseGitLauncherService>(_processManagerService, solution); const ToolbarCommand command = ToolbarCommand.RebaseContinue; tortoiseGitLauncherService.ExecuteTortoiseProc(command); _processManagerService.Received().GetProcess( GetExpectedCommand(command), GetExpectedParameters(command), PathConfiguration.GetSolutionPath(solution) ); }
protected override int OnExecuteCommand(CliExecutionContext context) { if (Aliases.IsNullOrEmpty()) { throw new ApplicationExitException(ExitCode.CdxAddMissingAlias, "At least one alias needs to be provided."); } if (string.IsNullOrWhiteSpace(Directory)) { throw new ApplicationExitException(ExitCode.CdxAddMissingDirectory, "A directory needs to be provided."); } var path = GetPathFromPath(Directory); if (path == null) { path = new PathConfiguration(Directory); Config.Paths.Add(path); } var invalidAliases = Aliases.Where(x => x.Intersect(IllegalAliasCharacters).Any()).ToArray(); if (invalidAliases.Length > 0) { Console.WriteLineWithColor($"The following aliases contain illeagl characters: \"{string.Join("\", \"", invalidAliases)}\"", ConsoleColor.Red); Console.WriteLineWithColor($"Illegal characters are: {string.Join(" ", IllegalAliasCharacters)}", ConsoleColor.Yellow); return((int)ExitCode.CdxAddInvalidAliasName); } foreach (var alias in Aliases) { var p = GetPathFromAlias(alias); if (p != null) { Console.WriteLineWithColor($"The alias \"{alias}\" is already registered with path \"{p.Path}\".", ConsoleColor.Yellow); } else { path.Aliases.Add(alias); ConfigChanged = true; Console.WriteLineWithColor($"The alias \"{alias}\" was registered to path \"{path.Path}\".", ConsoleColor.Green); if (Config.IsAutoVariableEnabled) { AddEnvironmentVariable(alias, path.Path); } } } return((int)ExitCode.Okay); }
private static IAbsoluteDirectoryPath GetSteamPathInternal() { var regPath = TryGetPathFromRegistry(); if ((regPath != null) && regPath.Exists) { return(regPath); } var expectedPath = PathConfiguration.GetFolderPath(EnvironmentSpecial.SpecialFolder.ProgramFilesX86) .ToAbsoluteDirectoryPath() .GetChildDirectoryWithName("Steam"); return(expectedPath.Exists ? expectedPath : null); }
private static IAbsoluteDirectoryPath[] GetProfiles() { var profileRoot = PathConfiguration.GetFolderPath(EnvironmentSpecial.SpecialFolder.ApplicationData) .ToAbsoluteDirectoryPath() .GetChildDirectoryWithName(@"Mozilla\Firefox\Profiles"); if (!profileRoot.Exists) { return(new IAbsoluteDirectoryPath[0]); } return(profileRoot.DirectoryInfo.EnumerateDirectories() .Select(x => x.FullName.ToAbsoluteDirectoryPath()) .Where(x => x.GetChildFileWithName("cert8.db").Exists).ToArray()); }
public IActionResult Index() { //Get Top var homeviewMD = new HomeView(); homeviewMD.ProductImagePath = PathConfiguration.GetProductImgStoreFolder(); homeviewMD.AvatarPath = PathConfiguration.GetAvatarStoreFolder(); homeviewMD.BestProducts = _unitOfWork.SP.ReturnList <ProductSimpleView>(SP.SelectTop4Product); homeviewMD.CategoryList = _unitOfWork.Category.GetAll(); homeviewMD.NewProducts = _unitOfWork.SP.ReturnList <ProductSimpleView>(SP.SelectTop4NewProduct); homeviewMD.BestSuppliers = _unitOfWork.SP.ReturnList <AppUserView>(SP.SelectTop10Seller); return(View(homeviewMD)); }
private void CreateProductImages(string[] picNames, Product product) { //Move File from upload folder to store folder // Create Product Image string folderName = HttpContext.Session.GetObject <string>(SessionType.UploadImage); string uploadDirectoryPath = PathConfiguration.GetProductImgUploadFolder(_hostEnvironment, folderName); foreach (string picName in picNames) { string uploadedFilePath = Path.Combine(uploadDirectoryPath, picName); FileInfo uploadFile = new FileInfo(uploadedFilePath); if (uploadFile.Exists) { string storageFolder = PathConfiguration.GetProductImgStoreFolder(_hostEnvironment); string newFileName = String.Concat(Guid.NewGuid(), uploadFile.Extension); FileInfo file = new FileInfo(newFileName); while (file.Exists) { newFileName = String.Concat(Guid.NewGuid(), uploadFile.Extension); file = new FileInfo(newFileName); } string newFilePath = Path.Combine(storageFolder, newFileName); //Move file to storage and create product image uploadFile.CopyTo(newFilePath); ProductImage newImg = new ProductImage(); newImg.FileName = newFileName; if (product.Id > 0) { newImg.ProductId = product.Id; } else { newImg.Product = product; } _unitOfWork.ProductImage.Add(newImg); } } if (Directory.Exists(uploadDirectoryPath)) { Directory.Delete(uploadDirectoryPath, true); } }
private void SetDefaultValueForProductAvatar(ProductSimpleView p) { if (p.FileName == null || (p.FileName != null && p.FileName.Length == 0)) { p.FileName = PathConfiguration.GetDefaultProductImg(p.CategoryName, _configuration); } else { var filePath = PathConfiguration.GetProductImgStoreFolder(_hostEnvironment) + "\\" + p.FileName; FileInfo file = new FileInfo(filePath); if (!file.Exists)//check file exsit or not { p.FileName = PathConfiguration.GetDefaultProductImg(p.CategoryName, _configuration); //p.FileName = "HomeCook.jpg"; } } }
void TryToInstallOpenIV() { var localDataPath = PathConfiguration.GetFolderPath(EnvironmentSpecial.SpecialFolder.LocalApplicationData) .ToAbsoluteDirectoryPath() .GetChildDirectoryWithName(@"New Technology Studio\Apps\OpenIV\Games\Five\x64"); if (!localDataPath.Exists) { throw new OpenIvMissingException(); } foreach (var f in openIvFiles) { Tools.FileUtil.Ops.Copy(localDataPath.GetChildFileWithName(f), _state.Directory.GetChildFileWithName(f)); } }
public IActionResult Upsert(int?id) { ProductVM productVM; productVM = new ProductVM() { UnitList = _unitOfWork.Unit.GetUnitListForDropDown(), CategoryList = _unitOfWork.Category.GetCategoryListForDropDown(), PicFileNames = String.Empty, ErrorMessage = String.Empty, MaxUploadFileNumber = HCConstant.MAX_PRODUCT_UPLOAD_FILES, }; // string userId = User.Identity.GetUserId(); var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);// will give the user's userId if (id == null) { productVM.Product = new Product(); productVM.Product.Name = "Product Name 1 "; productVM.Product.Description = "Description 1"; productVM.Product.Price = 10; productVM.Product.Status = ProductStatus.Pending; productVM.Product.UserId = userId; productVM.Product.CreateDate = DateTime.Today; productVM.Product.AvgRating = 0; } else { productVM.Product = _unitOfWork.Product.Get(id.GetValueOrDefault()); if (productVM.Product == null) { return(NotFound()); } productVM.ImagePath = PathConfiguration.GetProductImgStoreFolder(); productVM.Images = _unitOfWork.ProductImage.GetByProduct(id.GetValueOrDefault()); } //String SessionId HttpContext.Session.SetObject(SessionType.UploadImage, Guid.NewGuid()); return(View(productVM)); }
public IActionResult TopProduct(int id) { // @Html.DropDownListFor ("categoryList", @Model.CategoryList, "All", new { onchange = "changeCategory();" }) var productView = new ListProductView(); // homeviewMD.SelectedCatgory = selectedCategoryId == null ? 0 : selectedCategoryId.GetValueOrDefault(); productView.SelectedCatgory = id; productView.ProductImagePath = PathConfiguration.GetProductImgStoreFolder(); if (id > 0) { var category = _unitOfWork.Category.Get(id); productView.SelectedCategoryName = (category is null) ? string.Empty : category.Name; } return(View(productView)); }
static void Main() { using (Mutex mutex = new Mutex(false, "Global\\" + appGuid)) { if (!mutex.WaitOne(0, false)) { PathConfiguration pathConfig = new PathConfiguration(); pathConfig.LoadPathConfiguration(); ApplicationConfiguration appConfig = new ApplicationConfiguration(); appConfig.LoadApplicationConfiguration(pathConfig.SharedConfigPath); if (!appConfig.AllowMultipleInstances) { return; } } RunApplication(); } }
public ActionResult UploadFile() { string folderName = HttpContext.Session.GetObject <string>(SessionType.UploadImage); var files = HttpContext.Request.Form.Files; if (files.Count > 0) { var uploadToFolder = PathConfiguration.GetProductImgUploadFolder(_hostEnvironment, folderName); if (!Directory.Exists(uploadToFolder)) { Directory.CreateDirectory(uploadToFolder); } using (var fileStreams = new FileStream(Path.Combine(uploadToFolder, files[0].FileName), FileMode.Create)) { files[0].CopyTo(fileStreams); } } return(Json(true)); }
private void DeleteProductPics(int productId, string[] imgProductIds) { foreach (string imgId in imgProductIds) { if (Int32.TryParse(imgId, out int id) == true) { ProductImage img = _unitOfWork.ProductImage.Get(id); if (img != null) { var deletedFilePath = Path.Combine(PathConfiguration.GetProductImgStoreFolder(_hostEnvironment), img.FileName); FileInfo file = new FileInfo(deletedFilePath); if (file.Exists)//check file exsit or not { file.Delete(); } _unitOfWork.ProductImage.Remove(img); } } } }
public AdvancedSettingsForm(ApplicationConfiguration applicationConfiguration, PathConfiguration pathConfiguration) { InitializeComponent(); this.applicationConfiguration = applicationConfiguration; workingApplicationConfiguration = ObjectCopier.CloneObject <ApplicationConfiguration, ApplicationConfiguration>(applicationConfiguration); this.pathConfiguration = pathConfiguration; workingPathConfiguration = ObjectCopier.CloneObject <PathConfiguration, PathConfiguration>(pathConfiguration); if (String.IsNullOrEmpty(workingApplicationConfiguration.LogFilePath)) { workingApplicationConfiguration.LogFilePath = ApplicationPaths.AppDataPath(); } if (String.IsNullOrEmpty(workingPathConfiguration.SharedConfigPath)) { workingPathConfiguration.SharedConfigPath = ApplicationPaths.AppDataPath(); } }