public static string Save(this HttpPostedFileBase file, string name, HttpServerUtilityBase Server) { var nameFile = name + Path.GetExtension(file.FileName); var savePath = Server.MapPath("~/" + Path.Combine(basePath, "download", nameFile)); file.SaveAs(savePath); return(savePath); }
public BotApi(string apiToken, HttpRequestBase request, HttpServerUtilityBase server, bool enableDebug = false) { ApiToken = apiToken; Request = request; Server = server; Debug.Enabled = enableDebug; }
public static void MoveFile(this HttpServerUtilityBase server, string folder , string imageSourceName, string imageDestinationPath) { imageSourceName = server.MapPath(Path.Combine(folder, imageSourceName)); imageDestinationPath = server.MapPath(Path.Combine(folder, imageDestinationPath)); File.Move(imageSourceName, imageDestinationPath); }
public DeleteGalleryCommand(ObjectRepository repository, HttpServerUtilityBase server, string galleryDirectoryPath, int galleryId, string galleryTitle) { _server = server; _targetID = galleryId; itemTitle = galleryTitle; GalleryDirectoryPath = galleryDirectoryPath; Repository = repository; }
public NewsletterRepository(IReadOnlyDictionary <string, string> parameters, HttpServerUtilityBase httpServerUtility, HttpRequestBase request) { Parameters = parameters; MyHttpServerUtility = httpServerUtility; MyRequest = request; EmailRepository = new EmailRepository(); }
public LocalHttpContext(Uri url, string rawUrl, string applicationPath, HttpServerUtility utility, System.Web.Caching.Cache cache) { request = new LocalHttpRequest(url, rawUrl, applicationPath); response = new LocalHttpResponse(); this.cache = cache; this.utility = new HttpServerUtilityWrapper(utility); }
public static string MapServerPath(this HttpServerUtilityBase httpServerUtility, string localPath) { string domainRootLocalPath = httpServerUtility.MapPath("/"); string relativeLocalPath = ExtendedPath.GetRelativePath(domainRootLocalPath, localPath); string serverPath = relativeLocalPath.Replace('\\', '/'); return(serverPath); }
public ImageProcessingService(HttpServerUtilityBase server) { this.server = server; var connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString; this.storage = CloudStorageAccount.Parse(connectionString); }
public static string fileAbsolutePath(Guid id, string FilesDirectory, HttpServerUtilityBase Server) { var p1 = VirtualPathUtility.AppendTrailingSlash(FilesDirectory); var p2 = VirtualPathUtility.Combine(p1, id.ToString()); var p3 = Server.MapPath(p2); return(p3); }
public TestHttpContext(Exception error = null) { _request = new TestHttpRequest(); _response = new TestHttpResponse(); _server = new TestHttpServerUtility(this); _items = new Hashtable(); _error = error; }
internal static string[] GetAppConfigScriptPaths(object namedFormatValues, HttpServerUtilityBase server) { string appRoot = AppRoot.NamedFormat(namedFormatValues); string appConfigPath = server.MapPath(string.Format("{0}/config.js", appRoot)); string[] scriptPaths = GetScriptPathsFromConfigJs(appConfigPath); return(scriptPaths); }
public static ImageMetadata GetImageMetadata(HttpServerUtilityBase server, string imageUrl) { string path = server.MapPath(imageUrl + ".meta"); using (var reader = new StreamReader(path)) { return(new ImageMetadata(imageUrl, reader)); } }
public bool MyAdClose(int adId, string closingOptions, HttpServerUtilityBase server) { // get existing try { ClassifedAdAlias obj = null; switch (closingOptions) { case "Remove": if (PromoManager.IsAdInCart(adId)) { PromoManager.RemoveFromShoppingCart(adId); } obj = CurrentDbContext.ClassifiedDB .Include("Poster") .SingleOrDefault(x => x.Id == adId && x.Status != 1 && x.Status != 2 && x.Status != 3); obj.Status = 3; obj.NeedApproval = true; CurrentDbContext.SaveChanges(); break; case "Sold": obj = CurrentDbContext.ClassifiedDB .Include("Poster") .SingleOrDefault(x => x.Id == adId && x.Status != 1 && x.Status != 2 && x.Status != 3); if (obj == null && obj.Poster != CurrentUser) { return(false); } obj.Status = 1; obj.NeedApproval = true; CurrentDbContext.SaveChanges(); goto default; case "Rented": obj = CurrentDbContext.ClassifiedDB .Include("Poster") .SingleOrDefault(x => x.Id == adId && x.Status != 1 && x.Status != 2 && x.Status != 3); if (obj == null && obj.Poster != CurrentUser) { return(false); } obj.Status = 2; obj.NeedApproval = true; CurrentDbContext.SaveChanges(); goto default; default: //LuceneSearch.AddUpdateLuceneIndex(obj); break; } return(true); } catch (Exception) { return(false); } }
public void QuitarImagen_Servidor(string ruta_para_quitar, HttpServerUtilityBase Server) { string fullPath = Path.Combine(Server.MapPath(ruta_para_quitar)); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } }
public void DeleteDirectory(HttpServerUtilityBase server, string directoryName) { var dirPath = server.MapPath($"~/Pictures/{directoryName}"); if (Directory.Exists(dirPath)) { Directory.Delete(dirPath, true); } }
public byte[] GetFileBytes(string company, string department, string file, HttpServerUtilityBase server) { string path = server.MapPath("~/Files/" + company + "/" + department + "/"); byte[] filebytes = File.ReadAllBytes(server.MapPath("~/Files/" + company + "/" + department + "/" + file)); return(filebytes); //return new FileStream(Directory.GetFiles(path).FirstOrDefault(e => Path.GetFileName(e) == file), FileMode.Open); }
public static string GetResponeText(this HttpServerUtilityBase server, string path) { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); server.Execute("~" + path, sw); sw.Close(); return(sb.ToString()); }
public ServerUtilityPathMapper(HttpServerUtilityBase server) { if (server == null) { throw new ArgumentNullException("server"); } _server = server; }
/// <summary> /// Initializes a new instance of the <see cref="Services.FormatMessage"/> class. /// </summary> /// <param name="serviceLocator"> /// The service locator. /// </param> /// <param name="httpServer"> /// The http server. /// </param> /// <param name="processReplaceRuleFactory"> /// The process replace rule factory. /// </param> public FormatMessage( IServiceLocator serviceLocator, HttpServerUtilityBase httpServer, Func <IEnumerable <bool>, IProcessReplaceRules> processReplaceRuleFactory) { this.ServiceLocator = serviceLocator; this.HttpServer = httpServer; this.ProcessReplaceRuleFactory = processReplaceRuleFactory; }
public int getLastNumberOfFiles(string name, HttpServerUtilityBase server) { string[] fileNames = Directory.GetFiles(server.MapPath(subPath)); List <string> filesx = fileNames.Where(p => p.Split('[')[1].Split(']')[0].Equals(name)).OrderByDescending(p => p).ToList(); string lastFile = filesx.Count() > 0 ? filesx.FirstOrDefault().ToString().Split('.')[0].Last().ToString() : "0"; int lastNumber = Convert.ToInt32(lastFile); return(lastNumber); }
public static string CreateDir(this HttpServerUtilityBase server, string path) { var mapped = server.MapPath(path); if (!Directory.Exists(mapped)) { Directory.CreateDirectory(mapped); } return(mapped); }
public void saveToDatabase(string administrator, HttpServerUtilityBase server, FacebookDatabaseEntities toDataBase) { Album newAlbum = new Album(); newAlbum.date = DateTime.Now; newAlbum.name = name; newAlbum.user_id = administrator; toDataBase.Albums.Add(newAlbum); toDataBase.SaveChanges(); }
public LinqFileSystemProvider(string bd, IContextService context, HttpServerUtilityBase server) : base(ConfigurationManager.AppSettings["FileManagerNodoRaiz"]) { _ficherosService = FService.Instance.GetService(typeof(FicherosGaleriaModel), context) as FicherosService; _carpetasService = FService.Instance.GetService(typeof(CarpetasModel), context) as CarpetasService; _rutaBase = GetRootFolder(server, context.Empresa, bd); _empresa = context.Empresa; _azureblob = context.Azureblob; }
private static HttpContextBase GetContext(HttpServerUtilityBase serverUtility = null) { // simple mocked context - won't reference as long as path starts with 'http' Mock <HttpRequestBase> requestMock = new Mock <HttpRequestBase>(); Mock <HttpContextBase> contextMock = new Mock <HttpContextBase>(); contextMock.Setup(context => context.Request).Returns(requestMock.Object); contextMock.Setup(context => context.Server).Returns(serverUtility); return(contextMock.Object); }
public static bool DeleteFile(HttpServerUtilityBase server, string folderPath, string filePath) { var fi = new FileInfo(server.MapPath(folderPath + filePath)); if (fi.Exists) { fi.Delete(); return(true); } return(false); }
public static dynamic FormatResultToJson(this HttpServerUtilityBase httpServerUtilityBase, UpdateResult result) { return(new { lv = result.State, msg = FormatResult(httpServerUtilityBase, result) }); }
/// <summary>Meant for saving json to <paramref name="folderToSaveTo"/></summary> public FileSystemRepository(HttpServerUtilityBase httpServerUtilityBase, string folderToSaveTo) { if (string.IsNullOrWhiteSpace(folderToSaveTo)) { throw new ArgumentException("Invalid data", nameof(folderToSaveTo)); } FileExtensionsToAvoid = new HashSet <string>(); HttpServerUtilityBase = httpServerUtilityBase; ServerMapPath = InitializeDirectory(folderToSaveTo) ?? throw new Exception(); }
/// <summary>Meant for saving to <see cref="UploadFolder" /></summary> public FileSystemRepository(HttpServerUtilityBase httpServerUtilityBase, HashSet <string> fileExtensionsToAvoid, string folderToSaveTo = UploadFolder) { FileExtensionsToAvoid = fileExtensionsToAvoid == null || fileExtensionsToAvoid.Count == 0 ? new HashSet <string> { ".exe", ".batch", ".bat", ".tmp", ".cmd" } : fileExtensionsToAvoid; HttpServerUtilityBase = httpServerUtilityBase; ServerMapPath = InitializeDirectory(folderToSaveTo) ?? throw new Exception(); }
public static string getDuongDanTapTin(HttpServerUtilityBase server, HRMDB0Entities db, int TaiNguyen_id) { var tn = db.TaiNguyen.Find(TaiNguyen_id); if (tn == null || tn.laThuMuc) { return(String.Empty); } return(Path.Combine(server.MapPath(App_Root), tn.getFolder(), tn.tepDinhKem)); }
private static StringBuilder CreateCommonConfigScriptTags(WebViewPage page, object namedFormatValues) { HttpServerUtilityBase server = page.Context.Server; UrlHelper url = page.Url; string[] scripts = GetCommonConfigScriptPaths(server); StringBuilder scriptTags = CreateScriptTags(url, namedFormatValues, scripts); return(scriptTags); }