Пример #1
0
    public ZhongXin()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools      = ToolsFactory.CreateTools();
        MyBLL      = ZhongXinFactory.Create();
        MySupplier = SupplierFactory.CreateSupplier();
        DBHelper   = SQLHelperFactory.CreateSQLHelper();

        pub          = new Public_Class();
        sendmessages = new ZhongXinUtil.SendMessages();

        //Supplier_ID = tools.CheckInt(Session["supplier_id"].ToString());
        //佣金
        CommissionAccNo = System.Configuration.ConfigurationManager.AppSettings["zhongxin_commissionaccno"];
        CommissionAccNm = System.Configuration.ConfigurationManager.AppSettings["zhongxin_commissionaccnm"];
        //交易保证金
        GuaranteeAccNo = System.Configuration.ConfigurationManager.AppSettings["zhongxin_dealguaranteeaccno"];
        GuaranteeAccNm = System.Configuration.ConfigurationManager.AppSettings["zhongxin_dealguaranteeaccnm"];
    }
Пример #2
0
        public void GetCertificate(HttpContext context)
        {
            string    employeeID = context.Request.QueryString["empID"];
            Cerficate cerficate  = new CerficateBLL().GetModelList(" employeeID = '" + employeeID + "' AND isMain = 1 ").FirstOrDefault();

            if (cerficate != null)
            {
                System.Web.HttpServerUtility server = System.Web.HttpContext.Current.Server;
                string filePath          = server.MapPath(string.Format("~/{0}/{1}", Convert.ToString(ConfigurationManager.AppSettings["fileSavePath"]), cerficate.FILEPATH));
                System.Drawing.Image img = new Bitmap(filePath, true);
                //aFile.Close();
                System.Drawing.Image img2 = new ImageHelper().GetHvtThumbnail(img, 400, 0);


                //将Image转换成流数据,并保存为byte[]

                MemoryStream mstream = new MemoryStream();
                img2.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] byData = new Byte[mstream.Length];
                mstream.Position = 0;
                mstream.Read(byData, 0, byData.Length); mstream.Close();
                if (byData.Length > 0)
                {
                    MemoryStream ms = new MemoryStream(byData);
                    context.Response.Clear();
                    context.Response.ContentType = "image/jpg";
                    context.Response.OutputStream.Write(byData, 0, byData.Length);
                    context.Response.End();
                }
            }
        }
Пример #3
0
 public ContextResponse(HttpContext context)
 {
     if (context == null)
         throw new ArgumentNullException("context");
     _response = context.Response;
     _server = context.Server;
 }
        /// <summary>
        /// Returns true if the tildeFilePath corresponds to a file that
        /// exists and is a text file.
        /// 
        /// In that case, the filePath and info parameters are initialized.
        /// </summary>
        /// <param name="server">The server to convert to real file paths</param>
        /// <param name="tildeFilePath">The tilde file path</param>
        /// <param name="filePath">The real file path</param>
        /// <param name="info">The FileInfo object</param>
        public static bool TildeFilePathExistsAndIsText
            (HttpServerUtility server,
             string tildeFilePath,
             ref string filePath,
             ref FileInfo info)
        {
            bool error = StringTools.IsTrivial(tildeFilePath);

            if (!error)
            {
                error = !tildeFilePath.StartsWith("~/");
            }

            if (!error)
            {
                int category = FileTools.GetFileCategory(tildeFilePath);
                error = category != FileTools.TEXT;
            }

            if (!error)
            {
                try
                {
                    filePath = server.MapPath(tildeFilePath);
                    info = new FileInfo(filePath);
                    long bytes = info.Length;
                }
                catch
                {
                    error = true;
                }
            }

            return !error;
        }
Пример #5
0
        const string Token = "youotech"; //定义一个局部变量不可以被修改,这里定义的变量要与接口配置信息中填写的Token一致

        #endregion Fields

        #region Methods

        /// <summary>
        /// 写日志(用于跟踪),可以将想打印出的内容计入一个文本文件里面,便于测试
        /// </summary>
        public static void WriteLog(string strMemo, HttpServerUtility server)
        {
            string filename = server.MapPath("/log/log.txt");//在网站项目中建立一个文件夹命名logs(然后在文件夹中随便建立一个web页面文件,避免网站在发布到服务器之后看不到预定文件)
            if (!Directory.Exists(server.MapPath("//log//")))
                Directory.CreateDirectory("//log//");
            StreamWriter sr = null;
            try
            {
                if (!File.Exists(filename))
                {
                    sr = File.CreateText(filename);
                }
                else
                {
                    sr = File.AppendText(filename);
                }
                sr.WriteLine(strMemo);
            }
            catch
            {
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }
        }
Пример #6
0
		public CCUtility(object parent){
			Session=HttpContext.Current.Session;
			Server=HttpContext.Current.Server;
			Request=HttpContext.Current.Request;
			Response=HttpContext.Current.Response;
			DBOpen();
		} 
Пример #7
0
 public Handler(System.Web.HttpContext context)
 {
     this.Request  = context.Request;
     this.Response = context.Response;
     this.Context  = context;
     this.Server   = context.Server;
 }
Пример #8
0
        public ResponseResult PostSentence(dynamic sentenceObj)
        {
            try
            {
                string _sentence = Convert.ToString(sentenceObj.sentence);
                if (string.IsNullOrEmpty(_sentence))
                {
                    return(new ResponseResult {
                        Code = 4002, Message = "内容不能为空!"
                    });
                }

                System.Web.HttpServerUtility Server = System.Web.HttpContext.Current.Server;
                string all_path = Server.MapPath("~/Upload");
                if (Directory.Exists(all_path))
                {
                    WriteTxt(all_path + "/Sentence.txt", _sentence, true);
                }
                else
                {
                    Directory.CreateDirectory(all_path);
                    WriteTxt(all_path + "/Sentence.txt", _sentence, true);
                }
                return(new ResponseResult {
                    Code = 2000, Message = "操作成功!"
                });
            }
            catch (Exception ex)
            {
                return(new ResponseResult {
                    Code = 4004, Message = ex.Message
                });
            }
        }
Пример #9
0
    public Cart()
    {
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools         = ToolsFactory.CreateTools();
        encrypt       = EncryptFactory.CreateEncrypt();
        MyOrders      = OrdersFactory.CreateOrders();
        MyCart        = OrdersGoodsTmpFactory.CreateOrdersGoodsTmp();
        MyProduct     = ProductFactory.CreateProduct();
        MyMem         = MemberFactory.CreateMember();
        Mypackage     = PackageFactory.CreatePackage();
        MyAddr        = MemberAddressFactory.CreateMemberAddress();
        MyDelivery    = DeliveryWayFactory.CreateDeliveryWay();
        MyPayway      = PayWayFactory.CreatePayWay();
        Mydelierytime = DeliveryTimeFactory.CreateDeliveryTime();
        MyInvioce     = OrdersInvoiceFactory.CreateOrdersInvoice();
        MyFavorFee    = PromotionFavorFeeFactory.CreatePromotionFavorFee();
        MyCoupon      = PromotionFavorCouponFactory.CreatePromotionFavorCoupon();
        MyPolicy      = PromotionFavorPolicyFactory.CreatePromotionFavorPolicy();
        MyGift        = PromotionFavorGiftFactory.CreatePromotionFavorGift();
        MyCommission  = SupplierCommissionCategoryFactory.CreateSupplierCommissionCategory();
        MySupplier    = SupplierFactory.CreateSupplier();
        MyFavor       = PromotionFavorFactory.CreatePromotionFavor();
        MyLimit       = PromotionLimitFactory.CreatePromotionLimit();
        MyMemberFavor = MemberFavoritesFactory.CreateMemberFavorites();
        pageurl       = new PageURL(int.Parse(Application["Static_IsEnable"].ToString()));
    }
    public void initializeAjaxController(
        System.Web.HttpRequest _request,
        System.Web.SessionState.HttpSessionState _session,
        System.Web.HttpResponse _response,
        System.Web.HttpServerUtility _server)
    {
        try
        {
            this.response = _response;
            this.request  = _request;
            this.session  = _session;
            this.server   = _server;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("nb-NO", false);

            www.fwInitialize("", "", request, session, response);
            ajax.Initialize(www);



            sGlobalAjaxPrefix = ajax.getString("global_session_prefix");
            string sGlobalSessionPrefix = (string)www.fwGetSessionVariable("global_session_prefix");

            // A) NONE Ajax - prefix and NONE session : Just return.
            if (isBlank(sGlobalAjaxPrefix) && isBlank(sGlobalSessionPrefix))
            {
                return;
            }

            // B) Ajax - prefix and NONE session - prefix. SAVE NEW.
            if (!isBlank(sGlobalAjaxPrefix) && isBlank(sGlobalSessionPrefix))
            {
                www.fwSetSessionVariable("global_session_prefix", sGlobalAjaxPrefix);
                ajax.WriteVariable("initiating", "true");

                global = (Global)www.fwGetSessionVariable(sGlobalAjaxPrefix + "_global");
                if (global == null)
                {
                    global = new Global(this);
                    www.fwSetSessionVariable(sGlobalAjaxPrefix + "_global", global);
                    ajax.WriteVariable("initiating", "true");
                    return;
                }


                return;
            }


            // C) session - prefix. Just Go On
            if (!isBlank(sGlobalSessionPrefix))
            {
                global = (Global)www.fwGetSessionVariable(sGlobalSessionPrefix + "_global");
                return;
            }
        }
        catch (Exception)
        {
        }
    }
Пример #11
0
			public override void SetEndOfSendNotification(
				EndOfSendNotification callback_in, 
				object extraData_in
			) {
				base.SetEndOfSendNotification(callback_in, extraData_in);
				server_ = ((HttpContext)extraData_in).Server;
			}
Пример #12
0
        public static string Save(HttpServerUtility server, Stream stream, string fileName) {

            string fileExtension = Path.GetExtension(fileName);
            string relativePath = $"{RootFileName}/{Unknow}/";
            string savePath = server.MapPath($"~/{relativePath}");

            if (!string.IsNullOrEmpty(fileExtension)) {
                //去掉extension的.
                relativePath = $"{RootFileName}/{fileExtension.Substring(1)}/";
                savePath = server.MapPath($"~/{relativePath}/");
            }

            if (!Directory.Exists(savePath)) {
                Directory.CreateDirectory(savePath);
            }

            string newFileName = Guid.NewGuid().ToString("N") + fileExtension;
            string saveFile = Path.Combine(savePath, newFileName);
            bool success = FileHelper.WriteFile(stream, saveFile);
            string retFile = "";
            if (success) {
                retFile = $"{Address}{relativePath}{newFileName}";
            }

            return retFile;
        }
 public HttpServerUtilityWrapper(HttpServerUtility httpServerUtility)
 {
     if (httpServerUtility == null) {
         throw new ArgumentNullException("httpServerUtility");
     }
     _httpServerUtility = httpServerUtility;
 }
Пример #14
0
 public ContextRequest(HttpContext context)
 {
     if (context == null)
         throw new ArgumentNullException("context");
     _request = context.Request;
     _server = context.Server;
 }
        public static void AddErrorLog(string strSql, string exStr)
        {
            try
            {
                StreamWriter sw;
                DateTime     Date = DateTime.Now;
                if (!Directory.Exists(HttpContext.Current.Server.MapPath("../log/")))
                {
                    Directory.CreateDirectory(HttpContext.Current.Server.MapPath("../log/"));
                }
                System.Web.HttpServerUtility Server = System.Web.HttpContext.Current.Server;
                string   fileName = DateTime.Now.ToString("yyyyMMdd") + ".txt";
                FileInfo fi       = new FileInfo(Server.MapPath("../log" + "/" + fileName));

                if (fi.Exists)
                {
                    sw = File.AppendText(Server.MapPath("../log" + "/" + fileName));
                }
                else
                {
                    File.Create(Server.MapPath("../log") + "/" + fileName).Close();
                    sw = File.AppendText(Server.MapPath("../log" + "/" + fileName));
                }
                sw.WriteLine("*----------------------------------------------------------");
                sw.WriteLine("err_Time:" + Date.ToString("yyyy-MM-dd HH:mm:ss") + "");
                sw.WriteLine("err_SqlStr:" + strSql + "");
                sw.WriteLine("err_ExStr:" + exStr);
                sw.WriteLine("----------------------------------------------------------*");
                sw.Flush();
                sw.Close();
            }
            finally
            {
            }
        }
Пример #16
0
        public static void Init(HttpServerUtility server)
        {
            string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);
            DefaultConfigPath = server.MapPath(configPath);

            //By default if there's no config let's create a sqlite db.
            string defaultConfigPath = DefaultConfigPath;

            string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);
            sqlitePath = server.MapPath(sqlitePath);

            if (!File.Exists(defaultConfigPath))
            {
                ConfigFile file = new ConfigFile(defaultConfigPath);

                file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                file.Save();

                CurrentConfigFile = file;
            }
            else
            {
                CurrentConfigFile = new ConfigFile(defaultConfigPath);
                CurrentConfigFile.Load();
            }

            CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
        }
Пример #17
0
		/**
		 * Transfers control to the Error page using Server.Transfer, and displays some error information.
		 * 
		 * header: The error page header, ex. "Page not found". HTML in the string is not escaped.
		 * description: A description of the error, ex. "Path /foo/bar.txt not found". HTML in the string is not escaped.
		 * code: The response code of the page, ex. 404.
		 */
		public static void transferToError(HttpServerUtility server, HttpContext context, string header, string description, int code) {
			context.Items.Clear ();
			context.Items ["ErrorPage_title"] = header;
			context.Items ["ErrorPage_desc"] = description;
			context.Items ["ErrorPage_code"] = code;
			server.Transfer ("~/ErrorPage.aspx", false);
		}
Пример #18
0
    public Orders()
    {
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools           = ToolsFactory.CreateTools();
        encrypt         = EncryptFactory.CreateEncrypt();
        MyOrders        = OrdersFactory.CreateOrders();
        Mylog           = OrdersLogFactory.CreateOrdersLog();
        MyDelivery      = DeliveryWayFactory.CreateDeliveryWay();
        MyPayway        = PayWayFactory.CreatePayWay();
        MyProduct       = ProductFactory.CreateProduct();
        Mypackage       = PackageFactory.CreatePackage();
        Myorderdelivery = OrdersDeliveryFactory.CreateOrdersDelivery();
        MyFavorFee      = PromotionFavorFeeFactory.CreatePromotionFavorFee();
        MyCoupon        = PromotionFavorCouponFactory.CreatePromotionFavorCoupon();
        MyBack          = OrdersBackApplyFactory.CreateOrdersBackApply();
        MyPolicy        = PromotionFavorPolicyFactory.CreatePromotionFavorPolicy();
        MySupplier      = SupplierFactory.CreateSupplier();
        Mydelierytime   = DeliveryTimeFactory.CreateDeliveryTime();
        MyMember        = MemberFactory.CreateMember();
        MyConsumption   = MemberConsumptionFactory.CreateMemberConsumption();
        pageurl         = new PageURL(int.Parse(Application["Static_IsEnable"].ToString()));
        MyAccountLog    = MemberAccountLogFactory.CreateMemberAccountLog();
        MyFavor         = PromotionFavorFactory.CreatePromotionFavor();
        MyCouponRule    = PromotionCouponRuleFactory.CreatePromotionFavorCoupon();
        MyInvoice       = OrdersInvoiceFactory.CreateOrdersInvoice();
    }
Пример #19
0
        /// <summary>
        /// Creates a template file if it does not already exists, and uses a default text to insert. Returns the new path
        /// </summary>
        public string CreateTemplateFileIfNotExists(string name, string type, string location, HttpServerUtility server, string contents = "")
        {
            if (type == RazorC)
            {
                if (!name.StartsWith("_"))
                    name = "_" + name;
                if (Path.GetExtension(name) != ".cshtml")
                    name += ".cshtml";
            }
            else if (type == RazorVb)
            {
                if (!name.StartsWith("_"))
                    name = "_" + name;
                if (Path.GetExtension(name) != ".vbhtml")
                    name += ".vbhtml";
            }
            else if (type == TokenReplace)
            {
                if (Path.GetExtension(name) != ".html")
                    name += ".html";
            }

            var templatePath = Regex.Replace(name, @"[?:\/*""<>|]", "");
            var absolutePath = server.MapPath(Path.Combine(GetTemplatePathRoot(location, App), templatePath));

            if (!File.Exists(absolutePath))
            {
                var stream = new StreamWriter(File.Create(absolutePath));
                stream.Write(contents);
                stream.Flush();
                stream.Close();
            }

            return templatePath;
        }
Пример #20
0
    public Member()
    {
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools         = ToolsFactory.CreateTools();
        MyMember      = MemberFactory.CreateMember();
        Mygrade       = MemberGradeFactory.CreateMemberGrade();
        MyMemLog      = MemberLogFactory.CreateMemberLog();
        encrypt       = EncryptFactory.CreateEncrypt();
        MyConsumption = MemberConsumptionFactory.CreateMemberConsumption();
        MyFavor       = MemberFavoritesFactory.CreateMemberFavorites();
        MyProduct     = ProductFactory.CreateProduct();
        MyPackage     = PackageFactory.CreatePackage();
        MyReview      = ProductReviewFactory.CreateProductReview();
        MyFeedback    = FeedBackFactory.CreateFeedBack();
        MyAddr        = MemberAddressFactory.CreateMemberAddress();
        MyCart        = OrdersGoodsTmpFactory.CreateOrdersGoodsTmp();
        MyCoupon      = PromotionFavorCouponFactory.CreatePromotionFavorCoupon();
        // MyEmail = U_EmailNotifyRequestFactory.CreateU_EmailNotifyRequest();
        MyAccountLog = MemberAccountLogFactory.CreateMemberAccountLog();
        MyShop       = SupplierShopFactory.CreateSupplierShop();

        pageurl = new PageURL(int.Parse(Application["Static_IsEnable"].ToString()));
    }
Пример #21
0
    //考生提交实践题答案
    public int StuPutPracAns(string sId, string examId, string path)
    {
        try
        {
            StuPaper stuPaper = db.StuPaper.First(t => t.StudentId == sId && t.ExamId == decimal.Parse(examId));
            if (stuPaper.stuAnsPath != null)
            {
                System.Web.HttpServerUtility server = System.Web.HttpContext.Current.Server;
                string phth = server.MapPath(@stuPaper.stuAnsPath);

                if (File.Exists(server.MapPath(@stuPaper.stuAnsPath)))
                {
                    File.Delete(server.MapPath(stuPaper.stuAnsPath));
                }
            }

            stuPaper.stuAnsPath = path;
            db.SubmitChanges();

            return(1);
        }
        catch
        {
            return(-1);
        }
    }
Пример #22
0
 protected Handler(HttpContext context)
 {
     Request = context.Request;
     Response = context.Response;
     Context = context;
     Server = context.Server;
 }
Пример #23
0
        private void PrepareData()
        {
            MapInfo.Data.Table mdbTable   = MapInfo.Engine.Session.Current.Catalog[SampleConstants.EWorldAlias];
            MapInfo.Data.Table worldTable = MapInfo.Engine.Session.Current.Catalog[SampleConstants.ThemeTableAlias];
            // worldTable is loaded by preloaded mapinfo workspace file specified in web.config.
            // and MS Access table in this sample is loaded manually.
            // we are not going to re-load it again once it got loaded because its content is not going to change in this sample.
            // we will get performance gain if we use Pooled MapInfo Session.
            // Note: It's better to put this MS Access table into pre-loaded workspace file,
            //       so we don't need to do below code.
            //       We manually load this MS Access in this sample for demonstration purpose.
            if (mdbTable == null)
            {
                System.Web.HttpServerUtility util = HttpContext.Current.Server;
                string dataPath = util.MapPath("");
                mdbTable = MapInfo.Engine.Session.Current.Catalog.OpenTable(System.IO.Path.Combine(dataPath, SampleConstants.EWorldTabFileName));

                string[] colAlias = SampleConstants.BoundDataColumns;
                // DateBinding columns
                Column col0 = MapInfo.Data.ColumnFactory.CreateDoubleColumn(colAlias[0]);
                col0.ColumnExpression = mdbTable.Alias + "." + colAlias[0];
                Column col1 = MapInfo.Data.ColumnFactory.CreateIntColumn(colAlias[1]);
                col1.ColumnExpression = mdbTable.Alias + "." + colAlias[1];
                Column col2 = MapInfo.Data.ColumnFactory.CreateIntColumn(colAlias[2]);
                col2.ColumnExpression = mdbTable.Alias + "." + colAlias[2];

                Columns cols = new Columns();
                cols.Add(col0);
                cols.Add(col1);
                cols.Add(col2);

                // Databind MS Access table data to existing worldTable.
                worldTable.AddColumns(cols, BindType.DynamicCopy, mdbTable, SampleConstants.SouceMatchColumn, Operator.Equal, SampleConstants.TableMatchColumn);
            }
        }
        /// <summary>
        /// Returns a string for an HTML table with
        ///     number of bytes
        ///     number of lines
        ///     creation date,
        ///     last modification date
        /// for the file with the given tildeFilePath.
        /// </summary>
        /// <param name="server">The server to convert to real file paths</param>
        /// <param name="tildeFilePath">The tilde file path</param>

        public static string TextFileStatistics(HttpServerUtility server, string tildeFilePath)
        {
            StringBuilder builder = new StringBuilder();
            string filePath = null;
            FileInfo info = null;

            if (TildeFilePathExistsAndIsText(server, tildeFilePath, ref filePath, ref info))
            {
                long bytes = info.Length;
                DateTime created = info.CreationTime;
                DateTime modified = info.LastWriteTime;

                long lines = 0;

                using (StreamReader reader = new StreamReader(filePath))
                {
                    while (!reader.EndOfStream)
                    {
                        string foobar = reader.ReadLine();
                        lines++;
                    }
                }

                TildeFilePathStatisticsTable(builder, bytes, lines, created, modified);
            }
            else
            {
                TildeFilePathErrorMessage(builder);
            }

            return builder.ToString();
        }
Пример #25
0
        /// <summary>
        /// First converts tildeDirectoryPath to lowercase.
        /// 
        /// Then uses the server to convert tildeDirectoryPath
        /// to an absolute base directory path.
        /// 
        /// Then produces the list of absolute directory paths
        /// whose tree roots itself at this base path.
        /// 
        /// If there is an error then may return an empty list.
        /// </summary>
        public static List<string> AbsoluteDirectoryPathList(HttpServerUtility server, string tildeDirectoryPath)
        {
            List<string> list = new List<string>();

            string path = tildeDirectoryPath.ToLower();

            if (StringTools.IsTrivial(path))
                goto returnstatement;

            if (path[0] != '~')
                goto returnstatement;

            int n = path.Length;

            if (path[n - 1] != '/')
                path = path + '/';

            if (!SourceTools.OKtoServe(path, true))
                goto returnstatement;

            try
            {
                string directoryPath = server.MapPath(path);
                AbsoluteDirectoryPathListHelper(list, directoryPath);
            }
            catch { }

            returnstatement:

            return list;
        }
Пример #26
0
        internal static void LoadDiskCache(HttpServerUtility server)
        {
            var cache = server.MapPath("~/App_Data/api_start2.json");
            if(!File.Exists(cache)) return;

            start2Content = File.ReadAllText(cache);
            start2Timestamp = (long)((File.GetLastWriteTimeUtc(cache) - Utils.UnixTimestamp.Epoch.UtcDateTime).TotalMilliseconds);
        }
Пример #27
0
    public static void Start(HttpServerUtility server)
    {
      DeNSo.Configuration.BasePath = server.MapPath("~/App_Data");
      DeNSo.Configuration.EnableJournaling = true;

      Session.DefaultDataBase = "densodb_webapp";
      Session.Start();
    }
 public ICalProducer(List<CalendarEntry> entries, string location, HttpServerUtility server, string personelNumber, string kardexNumber)
 {
     _entries = entries;
     _location = location;
     _server = server;
     _personelNumber = personelNumber;
     _kardexNumber = kardexNumber;
 }
        public HtmlTextTranslator(ITextTranslator translator) {
            
            _translator = translator;

            if (HttpContext.Current != null) {
                _util = HttpContext.Current.Server;
            }
        }
Пример #30
0
        public static DataSet getDataSetFromExcel(FileUpload FileUpload1, HttpServerUtility Server)
        {
            if (FileUpload1.HasFile)
            {
                string fileName = Path.GetFileName(FileUpload1.FileName);
                string filePath = Server.MapPath("~/Excel/" + fileName);
                string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName);

                try
                {

                    MemoryStream stream = new MemoryStream(FileUpload1.FileBytes);
                    IExcelDataReader excelReader;

                    if (fileExtension == ".xls")
                    {
                        excelReader = ExcelReaderFactory.CreateBinaryReader(stream);

                        excelReader.IsFirstRowAsColumnNames = true;
                        DataSet result = excelReader.AsDataSet();

                        DataTable myTable = result.Tables[0];

                        excelReader.Close();
                        return result;
                    }
                    else if (fileExtension == ".xlsx")
                    {
                        excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                        //excelReader.IsFirstRowAsColumnNames = true;
                        DataSet result = excelReader.AsDataSet();

                        DataTable myTable = result.Tables[0];

                        excelReader.Close();
                        return result;
                    }
                    else if (fileExtension == ".csv")
                    {
                        //Someone else can implement this
                        return null;
                    }
                    else
                    {
                        throw new Exception("Unhandled Filetype");
                    }
                }
                catch
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
Пример #31
0
        public void ProcessRequest(HttpContext context)
        {
            System.Web.HttpRequest       Request  = context.Request;
            System.Web.HttpServerUtility Server   = context.Server;
            System.Web.HttpResponse      Response = context.Response;

            _file = Request.QueryString["file"];

            try
            {
                Type = (DownloadType)Enum.Parse(typeof(DownloadType), Request.QueryString["Type"]);
            }
            catch (Exception Ex)
            {
                Response.Redirect("~/");
            }


            string path = "";

            switch (_Type)
            {
            case DownloadType.News:
                path  = Folders.NewsFile + "/";
                _file = string.Format("{0}/{1}{2}", WebContext.StartDir, path, _file);
                break;

            case DownloadType.Downloads:
                //_file = Server.MapPath(_file);
                break;

            default:
                _file = string.Format("{0}/{1}{2}", WebContext.StartDir, path, _file);
                break;
            }



            FileInfo fi = new FileInfo(Server.MapPath(_file));

            string mimeType = IO.GetMimeType(_file);

            if (mimeType == "")
            {
                mimeType = "application/force-download";
            }

            //Response.AddHeader("Content-Transfer-Encoding", "binary");


            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
            Response.AddHeader("Content-Type", mimeType);
            Response.AddHeader("Content-Length", fi.Length.ToString());
            Response.WriteFile(fi.FullName);
            Response.Flush();
            Response.End();
        }
Пример #32
0
 public static void Register(HttpServerUtility server)
 {
     ConstantManager.LogPath = server.MapPath("~/Areas/Admin/LogFiles/");
     ConstantManager.ConfigPath = server.MapPath("~/Areas/Admin/AdminConfig.xml");
     ConstantManager.SavedPath = server.MapPath("~/Areas/Admin/SavedPages");
     ConstantManager.TrainingFilePath = server.MapPath("~/UploadedExcelFiles/ProductName.txt");
     ConstantManager.DistanceFilePath = server.MapPath("~/CalculateMarketDistance.xml");
     ConstantManager.IsParserRunning = false;
 }
Пример #33
0
 //构建构造函数
 public Verify()
 {
     //初始化ASP.NET内置对象
     Response    = System.Web.HttpContext.Current.Response;
     Request     = System.Web.HttpContext.Current.Request;
     Server      = System.Web.HttpContext.Current.Server;
     Session     = System.Web.HttpContext.Current.Session;
     Application = System.Web.HttpContext.Current.Application;
 }
Пример #34
0
        /// <summary>
        /// Genera l'html con delle info sull'errore
        /// </summary>
        /// <param name="Request"></param>
        /// <param name="Server"></param>
        /// <param name="ex"></param>
        /// <returns></returns>
        public static string GererateReport(System.Web.HttpRequest Request, System.Web.HttpServerUtility Server, Exception ex)
        {
            StringBuilder strMessage = new StringBuilder();

            strMessage.Append("<style type=\"text/css\">");
            strMessage.Append("<!--");
            strMessage.Append(".basix {");
            strMessage.Append("font-family: Verdana, Arial, Helvetica, sans-serif;");
            strMessage.Append("font-size: 12px;");
            strMessage.Append("}");
            strMessage.Append(".header1 {");
            strMessage.Append("font-family: Verdana, Arial, Helvetica, sans-serif;");
            strMessage.Append("font-size: 12px;");
            strMessage.Append("font-weight: bold;");
            strMessage.Append("color: #000099;");
            strMessage.Append("}");
            strMessage.Append(".tlbbkground1 {");
            strMessage.Append("background-color: #000099;");
            strMessage.Append("}");
            strMessage.Append("-->");
            strMessage.Append("</style>");

            strMessage.Append("<table width=\"85%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" class=\"tlbbkground1\">");
            strMessage.Append("<tr bgcolor=\"#eeeeee\">");
            strMessage.Append("<td colspan=\"2\" class=\"header1\">Page Error</td>");
            strMessage.Append("</tr>");
            strMessage.Append("<tr>");
            strMessage.Append("<td width=\"100\" align=\"right\" bgcolor=\"#eeeeee\" class=\"header1\" nowrap>IP Address</td>");
            strMessage.Append("<td bgcolor=\"#FFFFFF\" class=\"basix\">" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "</td>");
            strMessage.Append("</tr>");
            strMessage.Append("<tr>");
            strMessage.Append("<td width=\"100\" align=\"right\" bgcolor=\"#eeeeee\" class=\"header1\" nowrap>User Agent</td>");
            strMessage.Append("<td bgcolor=\"#FFFFFF\" class=\"basix\">" + Request.ServerVariables["HTTP_USER_AGENT"].ToString() + "</td>");
            strMessage.Append("</tr>");
            strMessage.Append("<tr>");
            strMessage.Append("<td width=\"100\" align=\"right\" bgcolor=\"#eeeeee\" class=\"header1\" nowrap>Page</td>");
            strMessage.Append("<td bgcolor=\"#FFFFFF\" class=\"basix\">" + Request.Url.AbsoluteUri + "</td>");
            strMessage.Append("</tr>");
            strMessage.Append("<tr>");
            strMessage.Append("<td width=\"100\" align=\"right\" bgcolor=\"#eeeeee\" class=\"header1\" nowrap>Time</td>");
            strMessage.Append("<td bgcolor=\"#FFFFFF\" class=\"basix\">" + System.DateTime.Now + " EST</td>");
            strMessage.Append("</tr>");
            strMessage.Append("<tr>");
            strMessage.Append("<td width=\"100\" align=\"right\" bgcolor=\"#eeeeee\" class=\"header1\" nowrap>Details</td>");
            if (Server.GetLastError() == null)
            {
                strMessage.Append("<td bgcolor=\"#FFFFFF\" class=\"basix\">" + ex.Message + "</td>");
            }
            else
            {
                strMessage.Append("<td bgcolor=\"#FFFFFF\" class=\"basix\">" + Server.GetLastError().InnerException.ToString() + "</td>");
            }

            strMessage.Append("</tr>");
            strMessage.Append("</table>");
            return(strMessage.ToString());
        }
Пример #35
0
 public DjangoViewEngine()
 {
     base.ViewLocationFormats = new string[] { "~/Views/{1}/{0}.django", "~/Views/Shared/{0}.django" };
     base.AreaViewLocationFormats = new string[] { "~/Areas/{2}/Views/{1}/{0}.django", "~/Areas/{2}/Views/Shared/{0}.django" };
     base.PartialViewLocationFormats = base.ViewLocationFormats;
     base.AreaPartialViewLocationFormats = base.AreaViewLocationFormats;
     server = HttpContext.Current.Server;
     manager_provider = new NDjango.TemplateManagerProvider().WithLoader(this).WithTag("url", new AspMvcUrlTag());
 }
Пример #36
0
        public ApplicationError(HttpServerUtility server, HttpResponse response, HttpContext context)
        {
            HttpServerUtility = server;
            HttpResponse = response;
            HttpContext = context;

            LastException = HttpServerUtility.GetLastError() as HttpException;
            StatusCode = LastException == null ? 500 : LastException.GetHttpCode();
        }
Пример #37
0
        internal ProcessorArgs([NotNull] BootcampCore bootcampCore, HttpServerUtility server, BootcampMode mode, string sitecoreVersion)
        {
            Assert.ArgumentNotNull(bootcampCore, "bootcampCore");
              Assert.ArgumentNotNull(server, "server");

              this.BootcampCore = bootcampCore;
              this.Mode = mode;
              this.Server = server;
              this.SitecoreVersion = sitecoreVersion;
        }
 public static void Configure(HttpServerUtility server)
 {
     Mapper.Initialize(cfg =>
     {
         cfg.AddProfile(new DepartmentProfile(server));
         cfg.AddProfile(new PageProfile());
         cfg.AddProfile(new UserProfile());
         cfg.AddProfile(new RoleProfile());
     });
 }
Пример #39
0
        public static string CheckFileUpLoadDirectory(string applicationPath, System.Web.HttpServerUtility server, UploadFileType type = UploadFileType.File)
        {
            string dic = server.MapPath(applicationPath + "/UploadFile/" + GetFileUpLoadPath(type));

            if (!Directory.Exists(dic))
            {
                Directory.CreateDirectory(dic);
            }
            return(dic);
        }
Пример #40
0
 public UploadImagem(FileUpload arquivo, string path, HttpServerUtility utilitarioHttp, int tamanhoArquivoKB, int largura, int altura)
 {
     this._arquivo = arquivo;
     this._path = path;
     this._utilitarioHttp = utilitarioHttp;
     this._tamanhoArquivoKB = tamanhoArquivoKB * 1024;
     this._largura = largura;
     this._altura = altura;
     this.PreencherExtensoesValidas();
 }
Пример #41
0
		public void PopulateSampleFiles(HttpServerUtility server, string wildcard, DropDownList ddl)
		{
			string sampleDir = server.MapPath("SampleFiles");
			ddl.Items.Add(new ListItem("Choose sample", ""));
			DirectoryInfo di = new DirectoryInfo(sampleDir);
			foreach (FileInfo f in di.GetFiles(wildcard))
			{
				ddl.Items.Add(new ListItem(Path.GetFileNameWithoutExtension(f.Name), f.Name));
			}
		}
Пример #42
0
        private void InitState()
        {
            MapInfo.Mapping.Map myMap = this.GetMapObj();

            // We need to put original state of applicatin into HttpApplicationState.
            if (Application.Get("DataAccessWeb") == null)
            {
                System.Collections.IEnumerator iEnum = MapInfo.Engine.Session.Current.MapFactory.GetEnumerator();
                // Put maps into byte[] objects and keep them in HttpApplicationState
                while (iEnum.MoveNext())
                {
                    MapInfo.Mapping.Map tempMap = iEnum.Current as MapInfo.Mapping.Map;
                    byte[] mapBits = MapInfo.WebControls.ManualSerializer.BinaryStreamFromObject(tempMap);
                    Application.Add(tempMap.Alias, mapBits);
                }

                // Load Named connections into catalog.
                if (MapInfo.Engine.Session.Current.Catalog.NamedConnections.Count == 0)
                {
                    System.Web.HttpServerUtility util = HttpContext.Current.Server;
                    string path     = util.MapPath(string.Format(""));
                    string fileName = System.IO.Path.Combine(path, "namedconnection.xml");
                    MapInfo.Engine.Session.Current.Catalog.NamedConnections.Load(fileName);
                }

                // Put Catalog into a byte[] and keep it in HttpApplicationState
                byte[] catalogBits = MapInfo.WebControls.ManualSerializer.BinaryStreamFromObject(MapInfo.Engine.Session.Current.Catalog);
                Application.Add("Catalog", catalogBits);

                // Put a marker key/value.
                Application.Add("DataAccessWeb", "Here");
            }
            else
            {
                // Apply original Catalog state.
                Object obj = Application.Get("Catalog");
                if (obj != null)
                {
                    Object tempObj = MapInfo.WebControls.ManualSerializer.ObjectFromBinaryStream(obj as byte[]);
                }

                // Apply original Map object state.
                obj = Application.Get(MapControl1.MapAlias);
                if (obj != null)
                {
                    Object tempObj = MapInfo.WebControls.ManualSerializer.ObjectFromBinaryStream(obj as byte[]);
                }
            }

            // Set the initial zoom, center and size of the map
            // This step is needed because you may get a dirty map from mapinfo Session.Current which is retrived from session pool.
            myMap.Zoom   = new MapInfo.Geometry.Distance(25000, DistanceUnit.Mile);
            myMap.Center = new DPoint(27775.805792979896, -147481.33999999985);
            myMap.Size   = new System.Drawing.Size((int)this.MapControl1.Width.Value, (int)this.MapControl1.Height.Value);
        }
Пример #43
0
    public Addr()
    {
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools = ToolsFactory.CreateTools();
        MyBLL = AddrFactory.CreateAddr();
    }
Пример #44
0
        public static Bootstrapper RegisterStandard(this Bootstrapper bootstrapper, HttpServerUtility server)
        {
            FileSystemStorage.StoragePath = server.MapPath("~/Storage");
            FormsCore.Instance.BaseUrl = "http://localhost:36258";

            bootstrapper.UnityContainer
                .RegisterType<IFileStorage, FileSystemStorage>()
                .RegisterType<ILogger, TraceLogger>();

            return bootstrapper;
        }
Пример #45
0
    public Charts()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        statistic = new Statistic();
    }
Пример #46
0
 public static void OutputExcel(System.Web.HttpServerUtility server, System.Web.HttpResponse response, string filename, MemoryStream ms)
 {
     byte[] bytes = ms.GetBuffer();
     response.Charset         = "UTF8";
     response.ContentEncoding = Encoding.UTF8;
     response.AddHeader("Content-Disposition",
                        "attachment; filename=" + server.UrlEncode(filename + ".xls"));
     response.ContentType = "application/vnd.ms-excel";
     response.BinaryWrite(bytes);
     response.End();
 }
Пример #47
0
        public string FullMetadataBannerPath(string baseUrl,
            string programId,
            HttpServerUtility Server)
        {
            Tuple<string, string> bannerPaths = GetBannerPath(programId, Server);

            string bannerImage = !string.IsNullOrEmpty(bannerPaths.Item2)
                ? VirtualPathUtility.ToAbsolute(bannerPaths.Item2)
                : VirtualPathUtility.ToAbsolute(bannerPaths.Item1);
            return string.Format("{0}{1}", baseUrl, bannerImage);
        }
Пример #48
0
        /// <summary>
        /// First converts tildeDirectoryPath to lowercase.
        /// 
        /// Then produces the list of tilde directory paths
        /// whose tree roots itself at this base path.
        /// 
        /// If there is an error then may return an empty list.
        /// </summary>
        public static List<string> TildeDirectoryPathList(HttpServerUtility server, string tildeDirectoryPath)
        {
            List<string> list = AbsoluteDirectoryPathList(server, tildeDirectoryPath);

            if (list.Count == 0)
                return list;

            string root = server.MapPath("~/");

            return FileTools.GetTildePaths(root, list);
        }
Пример #49
0
    public FriendlyLinkCate()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools = ToolsFactory.CreateTools();
        MyBLL = FriendlyLinkFactory.CreateFriendlyLinkCate();
    }
Пример #50
0
    public OrdersLog()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools = ToolsFactory.CreateTools();
        MyBLL = OrdersLogFactory.CreateOrdersLog();
    }
Пример #51
0
    public SCMConfig()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools    = ToolsFactory.CreateTools();
        DBHelper = SQLHelperFactory.CreateSQLHelper();
    }
Пример #52
0
    public ProductAuditReason()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools = ToolsFactory.CreateTools();
        MyBLL = ProductAuditReasonFactory.CreateProductAuditReason();
    }
Пример #53
0
    public Logistics()
    {
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        MyBLL   = LogisticsFactory.CreateLogistics();
        tools   = ToolsFactory.CreateTools();
        encrypt = EncryptFactory.CreateEncrypt();
    }
Пример #54
0
    public SupplierGrade()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools = ToolsFactory.CreateTools();
        MyBLL = SupplierGradeFactory.CreateSupplierGrade();
    }
Пример #55
0
    public Brand()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools         = ToolsFactory.CreateTools();
        brand         = BrandFactory.CreateBrand();
        MyProductType = ProductTypeFactory.CreateProductType();
    }
Пример #56
0
    public Help()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools = ToolsFactory.CreateTools();
        MyBLL = HelpFactory.CreateHelp();
        cate  = new HelpCate();
    }
Пример #57
0
    public RBACResource()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools      = ToolsFactory.CreateTools();
        MyBLL      = RBACResourceFactory.CreateRBACResource();
        MyGroupBLL = RBACResourceFactory.CreateRBACResourceGroup();
    }
Пример #58
0
    public Config()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        tools          = ToolsFactory.CreateTools();
        MyBLL          = ConfigFactory.CreateConfig();
        MyReviewconfig = ProductReviewConfigFactory.CreateProductReviewConfig();
    }
Пример #59
0
    public NetPayClient()
    {
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;

        pub = new Public_Class();
        //pub.SetCurrentSite();
        priKeyPath = System.Configuration.ConfigurationManager.AppSettings["priKeyPath"].ToString();
        pubKeyPath = System.Configuration.ConfigurationManager.AppSettings["pubKeyPath"].ToString();
    }
        public void AddAttachments(
            Project dbtask, 
            List<HttpPostedFileBase> uploadedAttachments, 
            HttpServerUtility server)
        {
            if (uploadedAttachments == null)
            {
                return;
            }

            if (!Directory.Exists(server.MapPath(TasksConstants.MainContentFolder)))
            {
                Directory.CreateDirectory(server.MapPath(TasksConstants.MainContentFolder));
            }

            if (!Directory.Exists(server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.Id)))
            {
                Directory.CreateDirectory(server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.Id));
            }

            foreach (var file in uploadedAttachments)
            {
                var filename = Path.GetFileName(file.FileName);
                file.SaveAs(server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.Id + "\\" + filename));
                dbtask.Attachments.Add(new Attachment() { Name = file.FileName });

                this.Update(dbtask);
            }
        }