示例#1
0
        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);
        }
示例#2
0
        public BotApi(string apiToken, HttpRequestBase request, HttpServerUtilityBase server, bool enableDebug = false)
        {
            ApiToken = apiToken;
            Request  = request;
            Server   = server;

            Debug.Enabled = enableDebug;
        }
示例#3
0
        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);
        }
示例#4
0
 public DeleteGalleryCommand(ObjectRepository repository, HttpServerUtilityBase server, string galleryDirectoryPath, int galleryId, string galleryTitle)
 {
     _server              = server;
     _targetID            = galleryId;
     itemTitle            = galleryTitle;
     GalleryDirectoryPath = galleryDirectoryPath;
     Repository           = repository;
 }
示例#5
0
        public NewsletterRepository(IReadOnlyDictionary <string, string> parameters, HttpServerUtilityBase httpServerUtility, HttpRequestBase request)
        {
            Parameters          = parameters;
            MyHttpServerUtility = httpServerUtility;
            MyRequest           = request;

            EmailRepository = new EmailRepository();
        }
示例#6
0
            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);
        }
示例#8
0
        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;
 }
示例#11
0
        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);
        }
示例#12
0
        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));
            }
        }
示例#13
0
        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);
            }
        }
示例#14
0
        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);
            }
        }
示例#16
0
        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);
        }
示例#17
0
        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());
        }
示例#18
0
        public ServerUtilityPathMapper(HttpServerUtilityBase server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            _server = server;
        }
示例#19
0
 /// <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;
 }
示例#20
0
        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);
        }
示例#21
0
        public static string CreateDir(this HttpServerUtilityBase server, string path)
        {
            var mapped = server.MapPath(path);

            if (!Directory.Exists(mapped))
            {
                Directory.CreateDirectory(mapped);
            }
            return(mapped);
        }
示例#22
0
        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();
        }
示例#23
0
        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;
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
 public static dynamic FormatResultToJson(this HttpServerUtilityBase httpServerUtilityBase,
                                          UpdateResult result)
 {
     return(new
     {
         lv = result.State,
         msg = FormatResult(httpServerUtilityBase,
                            result)
     });
 }
示例#27
0
 /// <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();
 }
示例#28
0
 /// <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();
 }
示例#29
0
        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));
        }
示例#30
0
文件: Bam.cs 项目: ThreeHeadz/Bam.Net
        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);
        }