Ejemplo n.º 1
0
 /// <summary>
 /// 初始化jquery的引用,目地是asp.net从bin目录下拷贝到应用跟目录,获得目录的html访问权限
 /// </summary>
 /// <param name="globalServer">HttpServerUtility对象Server</param>
 /// <param name="ILog1">ILog对象</param>
 public void initJquery(System.Web.HttpServerUtility globalServer, log4net.ILog ILog1)
 {
     string result = moveHTML(globalServer.MapPath("bin/jqueryJs"), globalServer.MapPath("jqueryJs"));
     if (result != null)
     {
         ILog1.Info("jquery初始化失败:" + result);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 写入图像水印
 /// </summary>
 /// <param name="str">水印字符串</param>
 /// <param name="filePath">原图片位置</param>
 /// <param name="savePath">水印加入后的位置</param>
 /// <returns></returns>
 public string CreateBackImage(System.Web.UI.Page pageCurrent, string str, string filePath, string savePath, int x, int y)
 {
     System.Drawing.Image img = System.Drawing.Image.FromFile(pageCurrent.MapPath(filePath));
     //创建图片
     Graphics graphics = Graphics.FromImage(img);
     //指定要绘制的面积
     graphics.DrawImage(img, 0, 0, img.Width, img.Height);
     //定义字段和画笔
     Font font = new Font("黑体", 16);
     Brush brush = new SolidBrush(Color.Yellow);
     graphics.DrawString(str, font, brush, x, y);
     //保存并输出图片
     img.Save(pageCurrent.MapPath(savePath), System.Drawing.Imaging.ImageFormat.Jpeg);
     return savePath;
 }
        public string CreateUserFolder(System.Web.HttpServerUtilityBase server)
        {
            var virtualPath = Path.Combine(rootFolder, Path.Combine("UserFiles", UserID), prettyName);

            var path = server.MapPath(virtualPath);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                foreach (var sourceFolder in foldersToCopy)
                {
                    CopyFolder(server.MapPath(sourceFolder), path);
                }
            }
            return virtualPath;
        }
Ejemplo n.º 4
0
 public string GetJumpUrlToNextPage(System.Web.HttpServerUtility server,string url, string valueKey)
 {
     if (!url.ToLower().Contains(".xml"))
     {
         url += ".xml";
     }
     XmlTextReader objXMLReader = new XmlTextReader(server.MapPath(url));
     string strNodeResult = "";
     while (objXMLReader.Read())
     {
         if (objXMLReader.NodeType.Equals(XmlNodeType.Element))
         {
             if (objXMLReader.AttributeCount > 0)
             {
                 while (objXMLReader.MoveToNextAttribute())
                 {
                     if ("id".Equals(objXMLReader.Name) && valueKey.Equals(objXMLReader.Value))
                     {
                         if (objXMLReader.MoveToNextAttribute())
                         {
                             strNodeResult = objXMLReader.Value;
                         }
                     }
                 }
             }
         }
     }
     return strNodeResult;
 }
Ejemplo n.º 5
0
        public static void BeginWrite(System.Web.UI.Page page)
        {
            string path = page.MapPath(System.Web.HttpRuntime.AppDomainAppVirtualPath) + "/Temp/";

            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            string fileName = System.Guid.NewGuid().ToString() + ".csv";
            strCurFileName = path + fileName;
            oStream = File.Create(path + fileName);
            oWriter = new StreamWriter(oStream, Encoding.GetEncoding("GB2312"));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 以默认的配置App_Data/xml/log4net.xml配置初始化log4net,并返回所有appenderName的log对象
 /// </summary>
 /// <param name="globalServer">log4net的xml配置</param>
 /// <param name="appenderNameList">appenderName的list对象</param>
 /// <returns>返回log4net.ILog对象的list</returns>
 public List<log4net.ILog> initLog4netByMyDefaultConfig(System.Web.HttpServerUtility globalServer, List<string> appenderNameList)
 {
     initLog4net(globalServer.MapPath("App_Data/xml/log4net.xml"));
     List<log4net.ILog> logList = new List<log4net.ILog>();
     foreach (string appenderName in appenderNameList)
     {
         log4net.ILog log = getLogger(appenderName);
         logList.Add(log);
     }
     return logList;
 }
        public string UploadMetadataInFileSystem(
            System.Web.UI.WebControls.FileUpload fileUploader,
            System.Web.HttpServerUtility Server,
            string tableSchema,
            string tableName,
            string columnName,
            string id)
        {
            string _retval = null;
            if (fileUploader.HasFile)
            {
                // Make sure that a PDF has been uploaded
                if (true == Framework.Web.WebFormApplicationUploadFilePathBuilder.ValidateFileName(
                    tableSchema, tableName, columnName, id,
                    fileUploader.FileName))
                {
                    string fileDirectory = Framework.Web.WebFormApplicationUploadFilePathBuilder.BuildFileDirectory(
                        tableSchema, tableName, columnName, id,
                        fileUploader.FileName);
                    string filePath = fileDirectory + "/" + fileUploader.FileName;
                    string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fileUploader.FileName);
                    string fileExtension = System.IO.Path.GetExtension(fileUploader.FileName);
                    int iteration = 1;

                    while (System.IO.File.Exists(Server.MapPath(filePath)))
                    {
                        filePath = string.Concat(fileDirectory, fileNameWithoutExtension, "-", iteration, fileExtension);
                        iteration++;
                    }

                    // Save the file to disk and set the value of the brochurePath parameter
                    fileUploader.SaveAs(Server.MapPath(filePath));
                    _retval = filePath;
                }
            }

            return _retval;
        }
Ejemplo n.º 8
0
 public static string GetSiteSetting(System.Web.HttpServerUtility server, string name)
 {
     ConfigXmlDocument cfxd = new ConfigXmlDocument();
     cfxd.Load(server.MapPath(SiteConfigPath));
     try
     {
         string value = cfxd.GetElementsByTagName(name)[0].InnerText;
         return value;
     }
     catch
     {
         return "";
     }
 }
Ejemplo n.º 9
0
        internal static int Run(System.Web.UI.Page caller)
        {
            var runOnceMarkerPath = caller.MapPath("/" + RunOnceGuid);
            if (!IO.File.Exists(runOnceMarkerPath))
            {
                return 0;
            }
            var runningMarkerPath = caller.MapPath("/779B94A7-7204-45b4-830F-10CC5B5BC0F2");
            lock (_locker)
            {
                if (IO.File.Exists(runningMarkerPath))
                    return 2;
                IO.File.Create(runningMarkerPath).Close();
            }

            var ctdPath = caller.MapPath("/Root/System/Schema/ContentTypes");
            var sourcePath = caller.MapPath("/Root");
            var targetPath = "/Root";
            var asmPath = caller.MapPath("/bin");
            var logPath = caller.MapPath("/install.log");
            var scriptsPath = caller.MapPath("/Scripts");
            var installerUser = HttpContext.Current.Application["SNInstallUser"] as string;

            try
            {
                CreateLog(logPath);
                LoadAssemblies(asmPath);
            }
            catch (Exception e)
            {
                Logger.WriteException(e);

                LogWriteLine();
                LogWriteLine("========================================");
                LogWriteLine("Import ends with error:");
                PrintException(e);

                ImportError = e.Message;
                return 2;
            }

            TotalCount = Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories).Length;

            var runOnce = new RunOnce();
            var importDelegate = new ImportDelegate(runOnce.Import);
            importDelegate.BeginInvoke(ctdPath, sourcePath, targetPath, asmPath, runOnceMarkerPath, runningMarkerPath, scriptsPath, logPath, installerUser, null, null);
            return 1;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 初始化html库的引用,目地是asp.net从bin目录下拷贝到应用跟目录,获得目录的html访问权限
 /// </summary>
 /// <param name="globalServer">HttpServerUtility对象Server</param>
 /// <param name="ILog1">ILog对象</param>
 public void initHtmlLibrary(System.Web.HttpServerUtility globalServer, log4net.ILog ILog1)
 {
     string result = moveHTML(globalServer.MapPath("bin/CSSLibrary"), globalServer.MapPath("CSSLibrary"));
     if (result != null)
     {
         ILog1.Info("HtmlLibrary初始化失败:" + result);
     }
     result = moveHTML(globalServer.MapPath("bin/ImgLibrary"), globalServer.MapPath("ImgLibrary"));
     if (result != null)
     {
         ILog1.Info("HtmlLibrary初始化失败:" + result);
     }
     result = moveHTML(globalServer.MapPath("bin/JSLibrary"), globalServer.MapPath("JSLibrary"));
     if (result != null)
     {
         ILog1.Info("HtmlLibrary初始化失败:" + result);
     }
     result = moveHTML(globalServer.MapPath("bin/fonts"), globalServer.MapPath("fonts"));
     if (result != null)
     {
         ILog1.Info("HtmlLibrary初始化失败:" + result);
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 初始化Bootstrap的引用,目地是asp.net从bin目录下拷贝到应用跟目录,获得目录的html访问权限
 /// </summary>
 /// <param name="globalServer">HttpServerUtility对象Server</param>
 /// <param name="ILog1">ILog对象</param>
 public void initBootstrap(System.Web.HttpServerUtility globalServer,log4net.ILog ILog1)
 {
     string result = moveHTML(globalServer.MapPath("bin/bootstrapCss"), globalServer.MapPath("bootstrapCss"));
     if (result != null) {
         ILog1.Info("Bootstrap初始化失败:" + result);
     }
     result = moveHTML(globalServer.MapPath("bin/bootstrapJs"), globalServer.MapPath("bootstrapJs"));
     if (result != null)
     {
         ILog1.Info("Bootstrap初始化失败:" + result);
     }
     result = moveHTML(globalServer.MapPath("bin/fonts"), globalServer.MapPath("fonts"));
     if (result != null)
     {
         ILog1.Info("Bootstrap初始化失败:" + result);
     }
 }
Ejemplo n.º 12
0
        public static void ExecuteMigrations(System.Web.HttpServerUtilityBase server)
        {
            DirectoryInfo di = new DirectoryInfo(server.MapPath("~\\Migrations"));

            FileInfo[] fi = di.GetFiles("*.sql", SearchOption.TopDirectoryOnly);

            var alphaFiles = fi.OrderBy(p => p.Name);

            StringBuilder sb = new StringBuilder();

            foreach (FileInfo fii in alphaFiles)
            {
                TextReader tr = new StreamReader(fii.FullName);

                sb.Append(tr.ReadToEnd());

                tr.Close();

                ExecuteSqlScript(sb.ToString());

                sb = new StringBuilder();
            }
        }
Ejemplo n.º 13
0
 public static string GetImageFilePath(System.Web.HttpServerUtilityBase srv, Guid id)
 {
     return srv.MapPath("~/upload/" + id + ".jpg");
 }
        public static void ErrorHandler(Exception Ex, string ModuleName, System.Web.HttpServerUtility Server)
        {
            if (Ex == null)
            { return; }

            string Msg = "Error Log: " + ModuleName + ": " + Ex.Message;
            try
            { Msg += " : " + Ex.Source + " : " + Ex.TargetSite.Name; }
            catch { }

            string FilePath = Server.MapPath(Layer01_Constants_Web.CnsLogPath);
            Do_Methods.LogWrite(Msg, FilePath);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 把一个DataView转化为一个CSV文件
        /// </summary>
        /// <param name="dt">DataTable对象</param>
        /// <param name="title">总的标题</param>
        /// <param name="ld">dbColName---->表的标题</param>
        /// <param name="isShowDBColName">是否现实数据库列名称</param>
        /// <param name="page"></param>
        /// <returns></returns>
        public static string DataViewToCSV(DataView dv, string title, ListDictionary ld, bool isShowDBColName, System.Web.UI.Page page)
        {
            string path = page.MapPath(System.Web.HttpRuntime.AppDomainAppVirtualPath) + "/Temp/";

            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            string fileName = System.Guid.NewGuid().ToString() + ".csv";
            FileStream oStream = File.Create(path + fileName);
            StreamWriter oWriter = new StreamWriter(oStream, Encoding.GetEncoding("GB2312"));
            //添加标题
            oWriter.Write(title + ",");
            oWriter.Write(oWriter.NewLine);
            //显示表的标题
            if (ld != null)
            {
                foreach (string name in ld.Values)
                    oWriter.Write(name.Trim() + ",");
                oWriter.Write(oWriter.NewLine);
            }
            if (dv != null)
            {
                //添加Column名称列
                if (isShowDBColName)
                {
                    foreach (string col in ld.Keys)
                        oWriter.Write(col + ",");
                    oWriter.Write(oWriter.NewLine);
                }
                //添加具体数据
                for (int i = 0; i < dv.Count; i++)
                {
                    foreach (string col in ld.Keys)
                    {
                        string str = dv[i][col].ToString().Trim();
                        oWriter.Write(str + ",");
                    }
                    oWriter.Write(oWriter.NewLine);
                }
                /*
                foreach(DataRow row in dt.Rows)
                {
                    foreach(string col in ld.Keys)
                    {
                        string str=row[col].ToString().Trim();
                        oWriter.Write(str+",");
                    }
                    oWriter.Write(oWriter.NewLine);
                }
                */
            }
            oWriter.Flush();
            oWriter.Close();
            oStream.Close();
            return path + fileName;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 把一个DataTable转化为一个CSV文件(商机查询统计专用)
        /// </summary>
        /// <param name="dt">DataTable对象</param>
        /// <param name="dtSales">代理客户表</param>
        /// <param name="title">总的标题</param>
        /// <param name="ld">dbColName---->表的标题</param>
        /// <param name="isShowDBColName">是否现实数据库列名称</param>
        /// <param name="page"></param>
        /// <returns></returns>
        public static string DataTableToCSV(DataTable dt, DataTable dtSales, string title, ListDictionary ld, bool isShowDBColName, System.Web.UI.Page page)
        {
            string path = page.MapPath(System.Web.HttpRuntime.AppDomainAppVirtualPath) + "/Temp/";

            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            string fileName = System.Guid.NewGuid().ToString() + ".csv";
            FileStream oStream = File.Create(path + fileName);
            StreamWriter oWriter = new StreamWriter(oStream, Encoding.GetEncoding("GB2312"));
            //保证不能超出Excel所能承受的最大行数
            if (dt != null && dt.Rows.Count >= 65535)
            {
                oWriter.Write("请增加查询条件,减少导出数据量。Excel最大支持65535行数据!" + ",");
                oWriter.Write(oWriter.NewLine);
                oWriter.Flush();
                oWriter.Close();
                oStream.Close();
                return path + fileName;
            }
            //添加标题
            oWriter.Write(title + ",");
            oWriter.Write(oWriter.NewLine);
            //显示表的标题
            if (ld != null)
            {
                foreach (string name in ld.Values)
                    oWriter.Write(name.Trim() + ",");
                oWriter.Write(oWriter.NewLine);
            }
            if (dt != null)
            {
                //添加Column名称列
                if (isShowDBColName)
                {
                    foreach (string col in ld.Keys)
                        oWriter.Write(col + ",");
                    oWriter.Write(oWriter.NewLine);
                }
                //添加具体数据
                foreach (DataRow row in dt.Rows)
                {
                    int index = 0;

                    foreach (string col in ld.Keys)
                    {
                        if (col.StartsWith("增值伙伴"))
                        {
                            DataRow[] arySales = dtSales.Select("BOID='" + row["BOID"].ToString() + "'");

                            if (arySales.Length > index)
                            {
                                string str = arySales[index]["AgentID"].ToString().Trim().Replace("\"", "").Replace("1900-1-1", "").Replace(" 0:00:00", "").Replace(",", "/").Replace("\r\n", " ");
                                oWriter.Write(str + ",");
                            }
                            else
                            {
                                string str = "";
                                oWriter.Write(str + ",");
                            }
                        }
                        else
                        {
                            if (col.StartsWith("代理名称"))
                            {
                                DataRow[] arySales = dtSales.Select("BOID='" + row["BOID"].ToString() + "'");

                                if (arySales.Length > index)
                                {
                                    string str = arySales[index]["AgentName"].ToString().Trim().Replace("\"", "").Replace("1900-1-1", "").Replace(" 0:00:00", "").Replace(",", "/").Replace("\r\n", " ");
                                    oWriter.Write(str + ",");
                                }
                                else
                                {
                                    string str = "";
                                    oWriter.Write(str + ",");
                                }

                                index++;
                            }
                            else
                            {
                                string str = row[col].ToString().Trim().Replace("\"", "").Replace("1900-1-1", "").Replace(" 0:00:00", "").Replace(",", "/").Replace("\r\n", " ");
                                //string str = row[col].ToString().Trim().Replace(",", "/");
                                oWriter.Write(str + ",");
                            }
                        }
                    }
                    oWriter.Write(oWriter.NewLine);
                }
            }
            oWriter.Flush();
            oWriter.Close();
            oStream.Close();
            return path + fileName;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 把一个DataTable转化为一个CSV文件
        /// </summary>
        /// <param name="dt">DataTable对象</param>
        /// <param name="title">总的标题</param>
        /// <param name="ld">dbColName---->表的标题</param>
        /// <param name="isShowDBColName">是否现实数据库列名称</param>
        /// <param name="page"></param>
        /// <returns></returns>
        public static string DataTableToCSV(DataTable dt, string title, System.Web.UI.Page page)
        {
            string path = page.MapPath(System.Web.HttpRuntime.AppDomainAppVirtualPath) + "/Temp/";

            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            string fileName = System.Guid.NewGuid().ToString() + ".csv";
            FileStream oStream = File.Create(path + fileName);
            StreamWriter oWriter = new StreamWriter(oStream, Encoding.GetEncoding("GB2312"));
            //保证不能超出Excel所能承受的最大行数
            if (dt != null && dt.Rows.Count >= 65535)
            {
                oWriter.Write("请增加查询条件,减少导出数据量。Excel最大支持65535行数据!" + ",");
                oWriter.Write(oWriter.NewLine);
                oWriter.Flush();
                oWriter.Close();
                oStream.Close();
                return path + fileName;
            }
            //添加标题
            if (title != string.Empty)
            {
                oWriter.Write(title + ",");
                //oWriter.Write("本报价单仅供参考,正式产品价格以合同为准!");
                oWriter.Write(oWriter.NewLine);
            }
            foreach (DataColumn dc in dt.Columns)
            {
                oWriter.Write(dc.Caption.Trim() + ",");

            }
            oWriter.Write(oWriter.NewLine);
            if (dt != null)
            {
                //添加具体数据
                foreach (DataRow row in dt.Rows)
                {
                    foreach (DataColumn col in dt.Columns)
                    {
                        string str = row[col].ToString().Trim().Replace("\"", "").Replace("1900-1-1", "").Replace(" 0:00:00", "").Replace(",", "/").Replace("\r\n", " ");
                        oWriter.Write(str + ",");
                    }
                    oWriter.Write(oWriter.NewLine);
                }
            }
            oWriter.Flush();
            oWriter.Close();
            oStream.Close();
            return path + fileName;
        }
Ejemplo n.º 18
0
		/**//// <summary>
		/// 调用Media播放mp3或电影文件
		/// </summary>
		/// <param name="pageCurrent">
		/// 当前的页面对象
		/// </param>
		/// <param name="PlayFilePath">
		/// 播放文件的位置
		/// </param>
		/// <param name="MediajavascriptPath">
		/// Mediajavascript的脚本位置
		/// </param>
		/// <param name="enableContextMenu">
		/// 是否可以使用右键
		/// 指定是否使右键菜单有效
		/// 指定右键是否好用,默认为0不好用
		/// 指定为1时就是好用
		/// </param>
		/// <param name="uiMode">
		/// 播放器的大小显示
		/// None,mini,或full,指定Windows媒体播放器控制如何显示
		/// </param>
		public static string PlayMediaFile(System.Web.UI.Page pageCurrent,
		                                   string PlayFilePath, string MediajavascriptPath,
		                                   string enableContextMenu, string uiMode)
		{
			StreamReader sr = new StreamReader(pageCurrent.MapPath(MediajavascriptPath));
			StringBuilder sb = new StringBuilder();
			string line;
			try
			{
				while ((line = sr.ReadLine()) != null)
				{
					sb.AppendLine(line);

				}
				sr.Close();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			sb.Replace("$URL", pageCurrent.MapPath(PlayFilePath));
			sb.Replace("$enableContextMenu", enableContextMenu);
			sb.Replace("$uiMode", uiMode);
			//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
			//            System.Guid.NewGuid().ToString(), sb.ToString());
			return sb.ToString();
		}
		#endregion

		#region ShowProgBar
		/**//// <summary>
		/// 主要实现进度条的功能,这段代码的调用就要实现进度的调度
		/// 实现主要过程
		/// default.aspx.cs是调用页面
		/// 放入page_load事件中
		///            UIHelper myUI = new UIHelper();
		///            Response.Write(myUI.ShowProgBar(this.Page,"../JS/progressbar.htm"));
		///            Thread thread = new Thread(new ThreadStart(ThreadProc));
		///            thread.Start();
		///            LoadData();//load数据
		///            thread.Join();
		///            Response.Write("OK");
		/// 
		/// 其中ThreadProc方法为
		///     public void ThreadProc()
		///    {
		///    string strScript = "<script>setPgb('pgbMain','{0}');</script>";
		///    for (int i = 0; i <= 100; i++)
		///     {
		///        System.Threading.Thread.Sleep(10);
		///        Response.Write(string.Format(strScript, i));
		///        Response.Flush();
		///     }
		///    }
		/// 其中LoadData()
		///     public void LoadData()
		///        {
		///            for (int m = 0; m < 900; m++)
		///            {
		///                for (int i = 0; i < 900; i++)
		///                {
		///
		///                }
		///            }
		///        }
		/// 
		/// </summary>
		/// <param name="pageCurrent"></param>
		/// <param name="ShowProgbarScript"></param>
		/// <returns></returns>
		public static string ShowProgBar(System.Web.UI.Page pageCurrent, string ShowProgbarScript)
		{
			StreamReader sr = new StreamReader(pageCurrent.MapPath(ShowProgbarScript), System.Text.Encoding.Default);
			StringBuilder sb = new StringBuilder();
			string line;
			try
			{
				while ((line = sr.ReadLine()) != null)
				{
					sb.AppendLine(line);

				}
				sr.Close();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
			//            System.Guid.NewGuid().ToString(), sb.ToString());
			return sb.ToString();
		}
Ejemplo n.º 19
0
		/**//// <summary>
		/// 简单的滚动信息栏
		/// 代码调用
		///         UIHelper.ScrollMessage(this.Page, "滚动的内容");
		/// </summary>
		/// <param name="pageCurrent">
		/// 当前页面
		/// </param>
		/// <param name="strMsg">
		/// 要滚动的信息
		/// </param>
		public static string ScrollMessage(string strMsg)
		{
			//Replace \n
			strMsg = strMsg.Replace("\n", "file://n/");
			//Replace \r
			strMsg = strMsg.Replace("\r", "file://r/");
			//Replace "
			strMsg = strMsg.Replace("\"", "\\\"");
			//Replace '
			strMsg = strMsg.Replace("\'", "\\\'");


			StringBuilder sb = new StringBuilder();
			sb.Append("<MARQUEE>");
			sb.Append(strMsg);
			sb.Append("</MARQUEE>");
			return sb.ToString();
			//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
			//        System.Guid.NewGuid().ToString(),sb.ToString());
		}


		/**//// <summary>
		/// 指定滚动文字的详细方法
		/// 
		/// </summary>
		/// <param name="pageCurrent">
		/// 当前的页面
		/// </param>
		/// <param name="strMsg">
		/// 要滚动的文字
		/// </param>
		/// <param name="aligh">
		/// align:是设定活动字幕的位置,居左、居中、居右、靠上和靠下三种位置
		/// left center  right top bottom
		/// </param>
		/// <param name="bgcolor">
		/// 用于设定活动字幕的背景颜色,一般是十六进制数。如#CCCCCC
		/// </param>
		/// <param name="direction">
		/// 用于设定活动字幕的滚动方向是向左、向右、向上、向下
		/// left|right|up|down
		/// </param>
		/// <param name="behavior">
		/// 用于设定滚动的方式,主要由三种方式:scroll slide和alternate
		/// 
		/// </param>
		/// <param name="height">
		/// 用于设定滚动字幕的高度
		/// 
		/// </param>
		/// <param name="hspace">
		/// 则设定滚动字幕的宽度
		/// </param>
		/// <param name="scrollamount">
		/// 用于设定活动字幕的滚动距离
		/// </param>
		/// <param name="scrolldelay">
		/// 用于设定滚动两次之间的延迟时间
		/// </param>
		/// <param name="width"></param>
		/// <param name="vspace">
		/// 分别用于设定滚动字幕的左右边框和上下边框的宽度
		/// 
		/// </param>
		/// <param name="loop">
		/// 用于设定滚动的次数,当loop=-1表示一直滚动下去,直到页面更新
		/// </param>
		/// <param name="MarqueejavascriptPath">
		/// 脚本的存放位置
		/// </param>
		/// <returns></returns>
		public static string ScrollMessage(System.Web.UI.Page pageCurrent, string strMsg, string aligh, string bgcolor,
		                                   string direction, string behavior, string height, string hspace,
		                                   string scrollamount, string scrolldelay, string width, string vspace, string loop,
		                                   string MarqueejavascriptPath)
		{
			StreamReader sr = new StreamReader(pageCurrent.MapPath(MarqueejavascriptPath));
			StringBuilder sb = new StringBuilder();
			string line;
			try
			{
				while ((line = sr.ReadLine()) != null)
				{
					sb.AppendLine(line);

				}
				sr.Close();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
			sb.Replace("$strMessage", strMsg);
			sb.Replace("$aligh", aligh);
			sb.Replace("$bgcolor", bgcolor);
			sb.Replace("$direction", direction);
			sb.Replace("$behavior", behavior);
			sb.Replace("$height", height);
			sb.Replace("$hspace", hspace);
			sb.Replace("$scrollamount", scrollamount);
			sb.Replace("$scrolldelay", scrolldelay);
			sb.Replace("$width", width);
			sb.Replace("$vspace", vspace);
			sb.Replace("$loop", loop);
			//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
			//            System.Guid.NewGuid().ToString(), sb.ToString());
			return sb.ToString();
		}
Ejemplo n.º 20
0
 /// <summary>
 /// 以默认的配置App_Data/xml/log4net.xml及单一Ilog对象mylog初始化log4net
 /// </summary>
 /// <param name="globalServer">System.Web.HttpServerUtility对象</param>
 /// <returns>返回log4net.ILog对象</returns>
 public log4net.ILog initLog4netByMyDefaultConfig(System.Web.HttpServerUtility globalServer)
 {
     initLog4net(globalServer.MapPath("App_Data/xml/log4net.xml"));
     log4net.ILog log = getLogger("mylog");
     return log;
 }
Ejemplo n.º 21
0
 public static MvcHtmlString GetImagePathServer(this System.Web.Mvc.HtmlHelper htmlHelper, 
     System.Web.HttpServerUtilityBase server, Guid id)
 {
     return new MvcHtmlString(server.MapPath("~/upload/" + id +".jpg"));
 }
Ejemplo n.º 22
0
        /**/
        /// <summary>
        /// 有等待时间的关闭窗体
        /// </summary>
        /// <param name="pageCurrent"></param>
        /// <param name="WaitTime">等待时间,以毫秒为记量单位</param>
        public static void CloseWindows(System.Web.UI.Page pageCurrent, int WaitTime)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\">");
            //加入此行功能后没有提提示功能
            sb.Append("window.opener=null;");
            sb.Append("setTimeout");
            sb.Append("(");
            sb.Append("'");
            sb.Append("window.close()");
            sb.Append("'");

            sb.Append(",");
            sb.Append(WaitTime.ToString());
            sb.Append(")");
            sb.Append("</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                        System.Guid.NewGuid().ToString(), sb.ToString());

        }
        #endregion

        #region  ShowStatusBar
        public static void ShowStatus(System.Web.UI.Page pageCurrent, string StatusString)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\">");
            sb.Append("window.status=");
            sb.Append("\"");
            sb.Append(StatusString);
            sb.Append("\"");
            sb.Append("</script>");
            pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
                System.Guid.NewGuid().ToString(), sb.ToString());
        }
        #endregion

        #region PlayMediaFile
        /**/
        /// <summary>
        /// 调用Media播放mp3或电影文件
        /// </summary>
        /// <param name="pageCurrent">
        /// 当前的页面对象
        /// </param>
        /// <param name="PlayFilePath">
        /// 播放文件的位置
        /// </param>
        /// <param name="MediajavascriptPath">
        /// Mediajavascript的脚本位置
        /// </param>
        /// <param name="enableContextMenu">
        /// 是否可以使用右键
        /// 指定是否使右键菜单有效
        /// 指定右键是否好用,默认为0不好用
        /// 指定为1时就是好用
        /// </param>
        /// <param name="uiMode">
        /// 播放器的大小显示
        /// None,mini,或full,指定Windows媒体播放器控制如何显示
        /// </param>
        public static string PlayMediaFile(System.Web.UI.Page pageCurrent,
                        string PlayFilePath, string MediajavascriptPath,
                        string enableContextMenu, string uiMode)
        {
            StreamReader sr = new StreamReader(pageCurrent.MapPath(MediajavascriptPath));
            StringBuilder sb = new StringBuilder();
            string line;
            try
            {
                while ((line = sr.ReadLine()) != null)
                {
                    sb.AppendLine(line);

                }
                sr.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            sb.Replace("$URL", pageCurrent.MapPath(PlayFilePath));
            sb.Replace("$enableContextMenu", enableContextMenu);
            sb.Replace("$uiMode", uiMode);
            //pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
            //            System.Guid.NewGuid().ToString(), sb.ToString());
            return sb.ToString();
        }