MapPath() public method

public MapPath ( string virtualPath ) : string
virtualPath string
return string
Esempio n. 1
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());
        }
Esempio n. 2
0
		public static string[] GetThemeNames(Page page)
		{
			if(page == null)
				throw new ArgumentNullException("page");

			return GetThemeNames(page.MapPath("~/themes"));
		}
Esempio n. 3
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);
        }
Esempio n. 4
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());
        }
Esempio n. 5
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());
        }
Esempio n. 6
0
        /// <summary>
        /// Loads the Javascript file contents onto the page
        /// using the given url which must refer to this site.
        /// 
        /// If the url starts with "http://" or "https://"
        /// then this method calls LoadFileReference instead.
        /// </summary>
        /// <param name="page">The page on which to load</param>
        /// <param name="url">The url of the file</param>
        /// <param name="addScriptTag">If true then add script tags</param>
        public static void LoadFileContents(Page page, string url, bool addScriptTag)
        {
            if (url.StartsWith(FileTools.httpStart))
            {
                LoadFileReference(page, url);
                return;
            }

            if (url.StartsWith(FileTools.httpsStart))
            {
                LoadFileReference(page, url);
                return;
            }

            ClientScriptManager clientscriptmanager = page.ClientScript;
            Type type = page.GetType();

            if (!clientscriptmanager.IsClientScriptBlockRegistered(type, url))
            {
                string filepath = page.MapPath(url);
                string contents = FileTools.GetFileAsText(filepath);
                LoadScriptString(page, url, contents, addScriptTag);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Returns a list of lines in a file.
 /// 
 /// If trim is true then all lines are trimmed and any lines
 /// that then have length 0 are discarded.
 /// 
 /// If trim is false then all lines are added unchanged.
 /// 
 /// The file name may be given by a web file relative path
 /// to the given page or by a tilde file path.
 /// 
 /// This method is a generalization of a method originally
 /// in the Teaching Preferences web application.
 /// 
 /// If an exception occurs, a list with 0 items will be
 /// returned.
 /// </summary>
 /// <param name="page">The page calling this method</param>
 /// <param name="filename">The web page relative file name</param>
 /// <returns>The list of the non-empty lines</returns>
 public static List<string> FileData(Page page, string filename, bool trim)
 {
     return FileDataAbsolutePath(page.MapPath(filename), trim);
 }
Esempio n. 8
0
        public string ColumnChart(Column column, Page page)
        {
            //创建图表空间
            ChartSpace mychartSpace = new ChartSpace();

            //在图表空间内添加一个图表对象
            ChChart mychart = mychartSpace.Charts.Add(0);
            mychartSpace.Border.Color = column.ChartBorderColor;
            //设置图表类型,本例使用柱形
            mychart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;
            //设置图表的一些属性
            //是否需要图例
            mychart.HasLegend = true;
            //是否需要主题
            mychart.HasTitle = true;
            //主题内容
            mychart.Title.Caption = column.ChartTitle;
            mychart.Title.Font.Size = column.ChartTitleSize;
            mychart.Title.Font.Bold = column.ChartTitleBold;

            switch (column.LegendPosition)
            {
                case LegendPosition.Top:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionTop;
                    break;
                case LegendPosition.Bottom:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
                    break;
                case LegendPosition.Left:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionLeft;
                    break;
                case LegendPosition.Right:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionRight;
                    break;
                default:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionRight;
                    break;
            }
            mychart.Legend.Interior.Color = column.LegendBgColor;
            mychart.Legend.Font.Size = column.LegendFontSize;
            mychart.Legend.Border.Color = column.LegendBorderColor;

            //设置x,y坐标

            mychart.Axes[1].HasTitle = column.ShowYAxes;
            mychart.Axes[1].Title.Caption = column.YAxesCaption;
            mychart.Axes[1].Title.Font.Size = 10;

            mychart.Axes[0].HasTitle = column.ShowXAxes;
            mychart.Axes[0].Title.Caption = column.XAxesCaption;
            mychart.Axes[0].Font.Name = "宋体";
            mychart.Axes[0].Font.Size = 10;

            string seriesName = "";
            string strValue = "";
            string category = "";

            for (int i = 0; i < column.SeriesNames.Length; i++)
            {
                seriesName = column.SeriesNames[i];
                strValue = "";
                category = "";
                for (int j = 0; j < column.Values[i].Length; j++)
                {
                    strValue += column.Values[i][j].ToString() + "\t";
                }

                for (int j = 0; j < column.Categorys.Length; j++)
                {
                    category += column.Categorys[j] + "\t";
                }
                mychart.SeriesCollection.Add(i);
                mychart.SeriesCollection[i].SetData(ChartDimensionsEnum.chDimSeriesNames, (int)ChartSpecialDataSourcesEnum.chDataLiteral, seriesName);
                mychart.SeriesCollection[i].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, category);
                mychart.SeriesCollection[i].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strValue);
                mychart.SeriesCollection[i].DataLabelsCollection.Add();
                mychart.SeriesCollection[i].DataLabelsCollection[0].HasValue = true;
                //mychart.SeriesCollection.Add(1);

                //if (column.DataColor != null)
                //{
                //    mychart.SeriesCollection[i].Points[0].Interior.Color = column.DataColor[i].ToString();
                //}
            }

            //生成图片
            //劉宏哲修改,先删除文件再创建文件。解决第一次生成图片以后,再次生成报错。时间:2010-04-21 9:44。

            string path = page.MapPath(".") + @"\" + column.PicName + ".gif";
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            mychartSpace.ExportPicture(path, "gif", column.ChartWidth, column.ChartHeight);

            //返回图片路径
            return column.PicName + ".gif" + "?temp=" + System.DateTime.Now.Ticks.ToString() + "";
        }
Esempio n. 9
0
        public string PieChart(Pie pie, Page page)
        {
            //创建X坐标的值
            string[] str = pie.DataNames;

            //创建Y坐标的值,表示销售额
            double[] count = pie.DataValues;
            string strDataName = "";
            string strData = "";

            //创建图表空间
            ChartSpace mychartSpace = new ChartSpace();
            mychartSpace.Border.Color = pie.ChartBorderColor;

            //在图表空间内添加一个图表对象
            ChChart mychart = mychartSpace.Charts.Add(0);

            //设置每块饼的数据
            for (int i = 0; i < count.Length; i++)
            {
                strDataName += str[i].ToString() + "\t";
                strData += count[i].ToString() + "\t";
            }
            strDataName = strDataName.Substring(0, strDataName.Length - 1);
            strData = strData.Substring(0, strData.Length - 1);

            //设置图表类型,本例使用饼
            switch (pie.PicChartType)
            {
                case PieType.Pie:
                    mychart.Type = ChartChartTypeEnum.chChartTypePie;
                    break;
                case PieType.Pie3D:
                    mychart.Type = ChartChartTypeEnum.chChartTypePie3D;
                    break;
                case PieType.Exploded:
                    mychart.Type = ChartChartTypeEnum.chChartTypePieExploded;
                    break;
                case PieType.Exploded3D:
                    mychart.Type = ChartChartTypeEnum.chChartTypePieExploded3D;
                    break;
                default:
                    mychart.Type = ChartChartTypeEnum.chChartTypePie;
                    break;
            }

            //设置图表的一些属性
            //是否需要图例
            mychart.HasLegend = true;
            //是否需要主题
            mychart.HasTitle = true;

            //主题内容
            mychart.Title.Caption = pie.ChartTitle;
            mychart.Title.Font.Size = pie.ChartTitleSize;
            mychart.Title.Font.Bold = pie.ChartTitleBold;
            mychart.Title.Font.Color = pie.ChartTitleColor;
            switch (pie.LegendPosition)
            {
                case LegendPosition.Top:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionTop;
                    break;
                case LegendPosition.Bottom:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
                    break;
                case LegendPosition.Left:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionLeft;
                    break;
                case LegendPosition.Right:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionRight;
                    break;
                default:
                    mychart.Legend.Position = ChartLegendPositionEnum.chLegendPositionRight;
                    break;
            }

            mychart.Legend.Interior.Color = pie.LegendBgColor;
            mychart.Legend.Font.Bold = pie.LegenFontBold;
            mychart.Legend.Font.Size = pie.LegendFontSize;
            mychart.Legend.Border.Color = pie.LegendBorderColor;

            //添加图表块
            mychart.SeriesCollection.Add(0);
            //设置图表块的属性
            //分类属性
            mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories,
            (int)ChartSpecialDataSourcesEnum.chDataLiteral, strDataName);
            //mychart.SeriesCollection[0].Interior.Color = "#C1DBEE";
            //mychart.SeriesCollection[1].Interior.Color = "#D1A00B";

            //值属性
            mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues,
            (int)ChartSpecialDataSourcesEnum.chDataLiteral, strData);
            for (int j = 0; j < mychart.SeriesCollection[0].Points.Count; j++)
            {
                mychart.SeriesCollection[0].Points[j].Border.Color = pie.SeriesCollectionBorderColor;
                if (pie.DataColor != null)
                {
                    mychart.SeriesCollection[0].Points[j].Interior.Color = pie.DataColor[j].ToString();
                }
            }

            //显示百分比
            ChDataLabels mytb = mychart.SeriesCollection[0].DataLabelsCollection.Add();
            mytb.HasPercentage = pie.HasPercentage;
            mytb.Font.Color = pie.DataFontColor;
            mytb.Font.Size = pie.DataFontSize;
            mytb.HasValue = true;
            //生成图片
            //劉宏哲修改,先删除文件再创建文件。解决第一次生成图片以后,再次生成报错。时间:2010-04-21 9:44。
            string path = page.MapPath(".") + @"\" + pie.PicName + ".gif";
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            mychartSpace.ExportPicture(path, "gif", pie.ChartWidth, pie.ChartHeight);

            //返回图片路径
            return pie.PicName + ".gif" + "?temp=" + System.DateTime.Now.Ticks.ToString() + "";
        }
Esempio n. 10
0
 static public String GetReportSourceFileName(System.Web.UI.Page page)
 {
     return(page.MapPath("~/Reports/CommonTasks.xml"));
 }
Esempio n. 11
0
        public static bool sendMail(string body, string subject, string toUser, Page page, string fileAttachment, MemoryStream stream)
        {
            // mail parameters
            string fromEmail = "*****@*****.**";
            if (BusinessLogicLayer.Common.FromEmail != null)
                fromEmail = BusinessLogicLayer.Common.FromEmail.ToString();

            string MailServer = "smtp.gmail.com";
            MailServer = BusinessLogicLayer.Common.MailServer;

            SmtpClient client = new SmtpClient(MailServer);
            NetworkCredential cred = new NetworkCredential(BusinessLogicLayer.Common.FromEmail, BusinessLogicLayer.Common.MailPassowrd);
            client.EnableSsl = BusinessLogicLayer.Common.EnableSSL.ToString().ToLowerInvariant() == "true" ? true : false;
            // Add credentials if the SMTP server requires them.
            if (!BusinessLogicLayer.Common.MailPort.ToString().Equals(""))
                client.Port = Convert.ToInt32(BusinessLogicLayer.Common.MailPort.ToString());

            client.UseDefaultCredentials = false;
            client.Credentials = cred;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            MailMessage message = new MailMessage();
            message.From = new MailAddress(fromEmail);
            message.Subject = subject;
            //message.Body = body;
            message.IsBodyHtml = true;

            //if (MyValidation.isEmail(toUser))
            message.To.Add(toUser);
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
            //LinkedResource logo = new LinkedResource(page.MapPath("~/images/bg-top_email.jpg"));
            LinkedResource logo = new LinkedResource(page.MapPath("~/images/bg-top_email.jpg"));
            logo.ContentId = "conferencelogo";
            htmlView.LinkedResources.Add(logo);
            message.AlternateViews.Add(htmlView);
            //if(stream != null)
            //{

            //    Attachment a = new Attachment(stream, "application/pdf");
            //    a.ContentId = "Abstract Submission";
            //    message.Attachments.Add(a);
            //}
            //message.Bcc.Add(toUser);
            // Create a message and set up the recipients.

            try
            {
                // Thread t = new Thread();
                client.Send(message);
            }
            catch (Exception ex)
            {
                // error loading template file
                //throw new ErrorException(ex.Message);
                return false;
            }

            // also send internal msg
            //UserMsg msg = new UserMsg();
            //msg.FromUserID = SManager.getUserID(currentPage);
            //msg.MsgTopic = MyMsgTopic.TermEval;
            //msg.Msg = body;
            //try
            //{
            //    MsgManager.sendBroadCastMsg(usrList, msg);
            //}
            //catch (Exception ex)
            //{
            //    // error loading template file
            //    //throw new ErrorException(string.Format("Can't send message to ({0})", msg.ToUserID));
            //}
            return true;
        }
Esempio n. 12
0
        /// <summary>
        /// Create the HTML markup to make a file list with Download
        /// buttons for facilitating the download of muliple files.
        /// 
        /// The method requires the tilde file path of an XML file
        /// that is structured along the lines of:
        /// 
        ///     ~/app_data/download_template.xml
        /// 
        /// The XML file should normally be in ~/app_data or in
        /// some subdirectory thereof.
        /// 
        /// All tilde paths within the XML file
        /// must refer to publically accessible directories.
        /// 
        /// Precondition: The page that calls this method must:
        /// 
        /// Have executed the call
        /// 
        ///     SourceTools.LoadCSSandJavascript(this);
        ///      
        /// or the equivalent pair of calls
        ///      
        ///     SourceTools.LoadCSS(this);
        ///     SourceTools.LoadJavascript(this);
        ///        
        /// during the initial call to PageLoad. 
        /// </summary>
        /// <param name="page">
        ///     The page that will use the markup</param>
        /// <param name="xmlTildeFilePath">
        ///     The tilde path for the XML file
        ///     with the download file list information</param>
        public static string DownloadFileListMarkup(Page page, string xmlTildeFilePath)
        {
            try
            {
                string xmlPath = page.MapPath(xmlTildeFilePath);
                string xmlString = FileTools.GetFileAsText(xmlPath);

                return DownloadFileListMarkupUsingXmlString(page, xmlString);
            }
            catch (Exception)
            {
                return DownloadFileListError;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Returns the markup from the search 
        /// of a directory given its tilde path.
        /// 
        /// Preconditions: The page that calls this method must:
        /// 
        ///   1. Have executed the call
        /// 
        ///        SourceTools.LoadCSSandJavascript(this);
        ///     
        ///      during the initial call to PageLoad. 
        /// 
        ///   2. Be able to guarantee that the directory is OK to serve
        ///      in context.
        /// </summary>
        /// <param name="page">
        ///     The page calling this method</param>
        /// <param name="tildeDirectoryPath">
        ///     The directory to search</param>
        /// <param name="pattern">
        ///     The search pattern</param>
        /// <param name="isRegex">
        ///     Is the pattern a regular expression?</param>
        /// <param name="ignoreCase">
        ///     Ignore case in the search?</param>
        /// <param name="statistics">
        ///     Include file statistics markup?</param>
        /// <param name="download">
        ///     Include download button markup?</param>
        /// <param name="onlyPublic">
        ///     Whether or not to restrict to public directories</param>
        public static string SearchDirectoryMarkup(Page page,
            string tildeDirectoryPath,
            string pattern,
            bool isRegex,
            bool ignoreCase,
            bool statistics,
            bool download,
            bool onlyPublic)
        {
            int n = tildeDirectoryPath.Length;

            if (tildeDirectoryPath[n - 1] != SourceTools.slash)
                tildeDirectoryPath = tildeDirectoryPath + SourceTools.slash;

            StringBuilder builder = new StringBuilder();

            string directoryPath = page.MapPath(tildeDirectoryPath);

            DirectoryInfo directory = new DirectoryInfo(directoryPath);

            FileInfo[] files = directory.GetFiles();

            int m = files.Length;

            for (int i = 0; i < m; i++)
            {
                string tildeFilePath = tildeDirectoryPath + files[i].Name;

                string markup = SearchFileMarkup(page, tildeFilePath, pattern,
                    isRegex, ignoreCase, statistics, download, false, onlyPublic);

                if (!StringTools.IsTrivial(markup))
                {
                    builder.Append(markup);
                    builder.Append("<hr />\n");
                }
            }

            return builder.ToString();
        }
Esempio n. 14
0
        /// <summary>
        /// Create the HTML markup to supply
        ///   * a file header line with optional file view link
        ///   * the file statistics
        ///   * the download button
        ///   * optional comment markup
        /// 
        /// If headerLine is true, the markup opens with the tilde
        /// file path or with the provided markup text.
        /// 
        /// The optional markup text is the tilde file path with
        /// HTML markup to be used in the headerLine.
        /// 
        /// Moreover, if the file is viewable and makeFileViewLink
        /// is true, then this header line provides a link to view
        /// the file.
        /// 
        /// If statistics is true, the markup shows a table with
        /// the file statistics.
        /// 
        /// If download is true, the markup for a download button
        /// is created.
        /// 
        /// If the string comment is not trivial then it is added
        /// to the markup at the end.
        /// 
        /// 
        /// The out statistics parameters are always computed.
        /// 
        /// If the caller wishes to simply obtain the statistics
        /// parameters then set the following bool parameters to
        /// false:
        ///   headerLine
        ///   makeFileViewLink
        ///   statistics
        ///   download
        /// Also, set the comment string to null.  Then no work
        /// will be done on markup and the return value will be
        /// the empty string.
        /// 
        /// 
        /// Preconditions: For nice markup to occur, the page that
        /// calls this method must:
        /// 
        ///   1. Have executed the call
        /// 
        ///          SourceTools.LoadCSS(this);
        ///     
        ///      during the initial call to PageLoad
        ///      or during an override to OnPreRender.
        /// 
        ///   2. If the download parameter is true, then
        ///      have executed the call
        /// 
        ///          SourceTools.LoadJavascript(this);
        ///     
        ///      during the initial call to PageLoad
        ///      or during an override to OnPreRender.
        /// 
        /// In addition, the page must:
        /// 
        ///   3. Be able to guarantee that the file is OK to serve
        ///      in context.
        /// </summary>
        /// <param name="page">
        ///     The page that will use the markup</param>
        /// <param name="tildeFilePath">
        ///     The tilde file path</param>
        /// <param name="markupText">
        ///     The optional markup text is the tilde file path
        ///     with HTML markup</param>
        /// <param name="onlyPublic">
        ///     Whether or not to restrict to public directories</param>
        /// <param name="headerLine">
        ///     Whether or not to show the header line</param>
        /// <param name="makeFileViewLink">
        ///     Whether or not to make a file view link in the header line</param>
        /// <param name="statistics">
        ///     Whether or not to show file statistics</param>
        /// <param name="download">
        ///     Whether or not to create a download button</param>
        /// <param name="comment">
        ///     Optional HTML markup to be appended to the
        ///     auto-generated markup constructed by this method</param>
        /// <param name="bytes">
        ///     out: Bytes in the file</param>
        /// <param name="created">
        ///     out: File created DateTime</param>
        /// <param name="modified">
        ///     out: File modified DateTime</param>
        public static string StatisticsMarkup(Page page,
            string tildeFilePath,
            string markupText,
            bool onlyPublic,
            bool headerLine,
            bool makeFileViewLink,
            bool statistics,
            bool download,
            string comment,
            out long bytes,
            out DateTime? created,
            out DateTime? modified)
        {
            // Get file info parameters
            string filePath = page.MapPath(tildeFilePath);

            FileInfo info = new FileInfo(filePath);

            bytes = info.Length;
            created = info.CreationTime;
            modified = info.LastWriteTime;

            // Check to see if markup is to be created
            bool appendComment = !StringTools.IsTrivial(comment);

            bool createMarkup =
                headerLine || statistics || download || appendComment;

            if (!createMarkup)
                return "";

            // Create markup
            StringBuilder builder = new StringBuilder();

            if (headerLine)
            {
                builder.Append
                    (HeaderLineMarkup
                        (page, tildeFilePath, markupText,
                         onlyPublic, makeFileViewLink));
            }

            if (statistics)
            {
                string a = "";
                string b = "";

                builder.Append("<table class='filedata'>\n");

                a = bytes.ToString();
                HTML_Tools.AppendTableRow(builder, "Bytes", a);

                a = created.Value.ToShortDateString();
                b = created.Value.ToLongTimeString();

                HTML_Tools.AppendTableRow(builder, "Created", a, b);

                a = modified.Value.ToShortDateString();
                b = modified.Value.ToLongTimeString();

                HTML_Tools.AppendTableRow(builder, "Modified", a, b);

                int category = FileTools.GetFileCategory(tildeFilePath);

                if (category == FileTools.IMAGE)
                {
                    int width = 0;
                    int height = 0;

                    if (category == FileTools.IMAGE)
                    {
                        using (FileStream stream =
                            new FileStream(filePath, FileMode.Open, FileAccess.Read))
                        {
                            Bitmap bitmap = new Bitmap(stream);
                            width = bitmap.Width;
                            height = bitmap.Height;
                        }
                    }

                    a = "" + width + " &times; " + height;

                    HTML_Tools.AppendTableRow(builder, "Dimensions", a);
                }

                builder.Append("</table>\n");
            }

            if (download && onlyPublic)
            {
                builder.Append(Download1);
                builder.Append(tildeFilePath);
                builder.Append(Download2);
            }

            if (appendComment)
            {
                builder.Append("\n<div>");
                builder.Append(comment);
                builder.Append("</div>\n");
            }

            return builder.ToString();
        }
Esempio n. 15
0
        /// <summary>
        /// Returns the statistics markup for an entire directory.
        /// 
        /// The tilde directory path will be truncated if need be
        /// to obtain a path that ends in slash.
        /// 
        /// The fileType is one of
        ///   FileTools.TEXT
        ///   FileTools.IMAGE
        ///   FileTools.OTHER
        /// or an arithmetic-or combination of these constants,
        /// for example,
        ///   FileTools.VISIBLE
        ///   FileTools.ALL
        /// 
        /// This function may be used to obtain data about the
        /// files in the directory without creating markup.
        /// 
        /// The individual file markup will be created only if
        /// showfiles is true.
        /// 
        /// The summary markup will be created only if summarize
        /// is true.
        /// </summary>
        /// <param name="page">
        ///     The page that will use the markup</param>
        /// <param name="tildeDirectoryPath">
        ///     The tilde directory path</param>
        /// <param name="onlyPublic">
        ///     Whether or not to restrict to public directories</param>
        /// <param name="fileType">
        ///     One of
        ///         FileTools.TEXT
        ///         FileTools.IMAGE
        ///         FileTools.OTHER",
        ///     or an arithmetic-or combination such as
        ///         FileTools.VISIBLE
        ///         FileTools.ALL
        /// </param>
        /// <param name="showfiles">
        ///     If true create individual file markup</param>
        /// <param name="summarize">
        ///     If true create summary statistics markup</param>
        /// <param name="fileCount">
        ///     out: The count of files in the directory</param>
        /// <param name="totalBytes">
        ///     out: The total bytes in all files in the directory</param>
        /// <param name="createdFirst">
        ///     out: The earliest creation date</param>
        /// <param name="createdLast">
        ///     out: The most recent creation date</param>
        /// <param name="modifiedFirst">
        ///     out: The earliest modification date</param>
        /// <param name="modifiedLast">
        ///     out: The most recent modification date</param>
        public static string StatisticsMarkupForDirectory(Page page,
            string tildeDirectoryPath,
            bool onlyPublic,
            int fileType,
            bool showfiles,
            bool summarize,
            out int fileCount,
            out long totalBytes,
            out DateTime? createdFirst,
            out DateTime? createdLast,
            out DateTime? modifiedFirst,
            out DateTime? modifiedLast)
        {
            // Initialize out parameters
            fileCount = 0;
            totalBytes = 0;

            createdFirst = null;
            createdLast = null;

            modifiedFirst = null;
            modifiedLast = null;

            // Trivial returns
            if (page == null)
                return NoFile;

            if (StringTools.IsTrivial(tildeDirectoryPath))
                return NoFile;

            if (!tildeDirectoryPath.StartsWith(tildeStart))
                return NoFile;

            // Make sure tilde directory path ends in slash
            int n = tildeDirectoryPath.Length;
            int m = n - 1;

            while (tildeDirectoryPath[m] != slash)
                --m;

            if (m < (n - 1))
            {
                tildeDirectoryPath = tildeDirectoryPath.Substring(0, m + 1);
            }

            // Attempt to extract files in the directory

            List<string> fileNameList = null;

            try
            {
                string directoryPath = page.MapPath(tildeDirectoryPath);
                fileNameList = MakeFileList(directoryPath, fileType);
            }
            catch (Exception)
            {
                return NoFile;
            }

            fileCount = fileNameList.Count;

            if (fileCount == 0)
                return NoFile;

            StringBuilder builder = new StringBuilder();
            StringBuilder summarybuilder = new StringBuilder();

            // Traverse files
            //
            // If showfiles is true
            //     create and append statistics markup for each file
            //
            // In all cases, accumulate summary data

            foreach (string fileName in fileNameList)
            {
                string tildeFilePath = tildeDirectoryPath + fileName;

                long bytes = 0;

                DateTime? created = null;
                DateTime? modified = null;

                // Find file information
                // If showfiles is true then create markup
                string markup =
                    SourceTools.StatisticsMarkup
                        (page,
                            tildeFilePath,
                            null,
                            onlyPublic,
                            showfiles,
                            showfiles,
                            showfiles,
                            showfiles,
                            null,
                            out bytes,
                            out created,
                            out modified);

                // If showfiles is true then append markup
                if (showfiles)
                {
                    builder.Append(markup);

                    builder.Append(HTML_Tools.hr);
                }

                // Accumulate file information in summary parameters
                if (bytes > 0)
                {
                    totalBytes += bytes;

                    if (createdFirst.HasValue)
                    {
                        if (created.Value.CompareTo(createdFirst.Value) < 0)
                            createdFirst = created;

                        if (created.Value.CompareTo(createdLast.Value) > 0)
                            createdLast = created;

                        if (modified.Value.CompareTo(modifiedFirst.Value) < 0)
                            modifiedFirst = modified;

                        if (modified.Value.CompareTo(modifiedLast.Value) > 0)
                            modifiedLast = modified;
                    }
                    else
                    {
                        createdFirst = created;
                        createdLast = created;

                        modifiedFirst = modified;
                        modifiedLast = modified;
                    }
                }
            }

            // If summarize is true then append summary markup
            // to summarybuilder
            if (summarize)
            {
                AppendStatisticsSummary(
                    summarybuilder,
                    fileCount,
                    totalBytes,
                    createdFirst,
                    createdLast,
                    modifiedFirst,
                    modifiedLast);
            }

            // Show summary before details
            return summarybuilder.ToString() + builder.ToString();
        }
Esempio n. 16
0
        public void LancementDuProgramme(bool premiereFois, XHtmlParametresLancement parametresRecus, Page page, object sender, System.EventArgs e)
        {
            PageWeb = page;
            if (page == null)
            {
                string message = "page null dans XWebPageLoad";
                throw new NullReferenceException(message);
            }

            string parametres = null;
            //	on recupere la session
            SessionWeb = (int)page.Session["SessionDivaltoWeb"];
            //	la première fois

            if (page.Session == null)
            {
                string message = "page.Session null dans XWebPageLoad";
                throw new NullReferenceException(message);
            }
            if (PageWeb.Request == null)
            {
                string message = "PageWeb.Request null dans XWebPageLoad";
                throw new NullReferenceException(message);
            }

            //			if (page.Session.IsNewSession)
            if (premiereFois)
            {
                //	on recupere les paramètres dans la page générique
                Label cparametres = (Label)page.FindControl("parametres");

                if (cparametres != null)
                    parametres = cparametres.Text +
                                     "<BrowserName>" + PageWeb.Request.Browser.Browser +
                                     "<BrowserVersion>" + PageWeb.Request.Browser.Version +
                                     "<HomeDirectory>" + page.MapPath(page.TemplateSourceDirectory) +  // bh23052006
                                     "<HostName>" + page.Request.UserHostName +							// bh24052007
                                     "<HostAddress>" + page.Request.UserHostAddress +						// bh24052007
                                     "<UserAgent>" + page.Request.UserAgent;								// bh24052007

                foreach (string lang in page.Request.UserLanguages)
                    parametres += ("<Language>" + lang);

                //	ajout de l'url
                parametres += this.CreerHmpQueryString(PageWeb.Request);

                //	ajout des cookies
                parametres += ("<cookies>" + this.CreerHmpCookies(PageWeb.Request));

                //	on lance le programme et on attend la reponse
                //				DialogueX2Y.WebRunProgram(SessionWeb, parametres, out codeecran);

                /////////////////////////////////////////////////
                // Parametres en dur, en attendant mieux
                {
                    ushort numeroExecutable = 0;
                    string domaine = "";
                    string utilisateur = "hao";
                    string motDePasse = "hao";
                    string utilisateurHarmony = "root";
                    string motDePasseHarmony = "hao";
                    string programme = parametresRecus.program; //  "tablohtml5.dhop";  // "testhtml5.dhop";
                    string fenetreMere = "";
                    string autres = "";
                    string numeroMachine = "123456";
                    string Environnement = "";
                    string CodeLangueEcran = "";
                    string CodeLangueImprimante = "";
                    string HARMONY_PARAMetAutres = "";
                    int UserPointExclamation = 0;
                    string messageErreur;

                    {
                        //						DVBuffer bufferReception;
                        //						byte[] reception;
                        messageErreur = "";
                        string mpw = "";
                        string mph = "";

                        if (DialogueX2Y.VerifierSiServeurArrete(utilisateurHarmony) == false)
                        {
                            //!!!!!!!!!!!!!!!!!!! a finaliser
                            messageErreur = "Le service DhsTerminalServer est arrêté";
                            SessionWeb = -1;
                            return;
                        }

                        //SessionWeb = DialogueX2Y.WebOpenSession(); deja fait dans Session_Start

                        // A revoir !!!!!!!!!!!!!!!!!!!!!!!!!
                        mpw = motDePasse;
                        mph = motDePasseHarmony;
                        //if (motDePasse != "")
                        //	mpw = DVCrypt.Decrypter(motDePasse, DVCrypt.CalculerCle(utilisateur));
                        //if (motDePasseHarmony != "")
                        //	mph = DVCrypt.Decrypter(motDePasseHarmony, DVCrypt.CalculerCle(utilisateurHarmony));

                        // je considère que seul le transport local positionne ce flag
                        // cela permet de tester les autres transports en réel meme dans une seule machine
                        //----------------------------------------------------------------------------------
                        //			bool isLocal = false; //  this.Context.Request.IsLocal;			// dit que la cx est locale

                        parametres += "<program>" + programme + "<user>" + utilisateur + "<pw>" + mpw +
                                            "<userharmony>" + utilisateurHarmony + "<pwHarmony>" + mph + "<transport>serviceweb<pid>0" +
                                            "<hwndFen>" + fenetreMere + "<domaine>" + domaine + "<numeromachine>" + numeroMachine;

                        if (autres.Length > 0)
                            parametres += "<other>" + autres;

                        if (UserPointExclamation == 1)
                            parametres += "<UserPointExclamation>1";

                        if (Environnement.Length > 0)
                            parametres += "<environnement>" + Environnement;

                        if (CodeLangueEcran.Length > 0)
                            parametres += "<codelangueecran>" + CodeLangueEcran;

                        if (CodeLangueImprimante.Length > 0)
                            parametres += "<codelangueimprimante>" + CodeLangueImprimante;

                        if (HARMONY_PARAMetAutres.Length > 0)
                            parametres += HARMONY_PARAMetAutres;

                        DialogueX2Y.WebRunClientLegerHtml(SessionWeb, numeroExecutable, parametres, out DonneesRecuesDeYwpf);
                        //						DialogueX2Y.WebRunClientLegerViaServiceWeb(SessionWeb, numeroExecutable, parametres, out codeecran);
                    }
                }
            }
            else
            {
                ////	on récupère la réponse du navigateur pour la mettre dans un DVBuffer
                //DVBuffer Reponse = new DVBuffer();
                //Reponse.Put(Proprietes.ECRAN_DEBUT);
                //foreach (string id in page.Request.Form)
                //{
                //   // bh22122009 Si c'est une variable indicée je retourne les différentes valeurs

                //   if (id != "__VIEWSTATE")
                //   {
                //      string[] valeurs = page.Request.Form.GetValues(id);
                //      if (valeurs.Length == 1)
                //      {
                //         Reponse.Put(Proprietes.VALEUR_SAISIE);
                //         Reponse.Put(id);
                //         string val = page.Request.Form[id];
                //         Reponse.Put(val);
                //      }
                //      else
                //      {
                //         for (int cpt = 0; cpt < valeurs.Length; cpt++)
                //         {
                //            Reponse.Put(Proprietes.VALEUR_SAISIE);
                //            Reponse.Put(id.Substring(0, id.Length - 1) + (cpt + 1).ToString() + "]");
                //            string val = valeurs[cpt];
                //            Reponse.Put(val);
                //         }
                //      }
                //   }
                //}
                //{																								//JS5 : récup de __YWEBCTRLBYPASS
                //   string id = "__YWEBCTRLBYPASS";
                //   string val = page.Request.QueryString[id];
                //   if (val != null)
                //   {
                //      Reponse.Put(Proprietes.VALEUR_SAISIE);
                //      Reponse.Put(id);
                //      Reponse.Put(val);
                //   }
                //}

                //if (HttpContext.Current == null || HttpContext.Current.Request == null)
                //{
                //   string message = "HttpContext.Current.Request null dans XWebPageLoad";
                //   throw new NullReferenceException(message);
                //}

                //this.AjouterFichiersJoints(Reponse, HttpContext.Current.Request.Files); // bhficjoint

                //Reponse.Put(Proprietes.VALEUR_SAISIE);
                //Reponse.Put("__YWEBCOOKIES");
                //string valc = this.CreerHmpCookies(PageWeb.Request);
                //Reponse.Put(valc);

                //Reponse.Put(Proprietes.ECRAN_FIN);
                ////	on l'envoie à Yweb et on attend le nouvel écran

                //DialogueX2Y.WebSendDataAndWaitResponse(SessionWeb, Reponse.LeBuffer, out DonneesRecuesDuNavigateur);
            }

            //	dans tous les cas on crée un DVBuffer avec le code de la page
            if (DonneesRecuesDeYwpf == null)
            {
                string message = "codeecran null dans XWebPageLoad";
                throw new NullReferenceException(message);
            }

            //	On recherche le formulaire par défaut "form1" dans la page
            //	Les objets de la page seront ajoutés dans ce formulaire
            //FormulaireWeb = page.FindControl("form1");
            //if (FormulaireWeb == null)
            //{
            //   string message = "FormulaireWeb null dans XWebPageLoad";
            //   throw new NullReferenceException(message);
            //}
            //FormulaireWeb.EnableViewState = false;				//JS5 : corrige le problème "Failed to load Viewstate"

            // La génération des objets a lieu dans la fonction XWebOnPreRender ci dessous

            //	ATTENTION : ici DotNet va restaurer les valeurs saisies et publiées au coup d'avant par l'utilisateur !!
            //					il faut charger les nouvelles valeurs fournies par le pg Diva plus tard
            //					(au OnLoadComplete ou au OnPreRender ; éventuellement aussi dans une procédure de trt d'un
            //					 événement exécutée côté serveur car celle-ci s'exécute après le OnLoad et avant le OnLoadComplete)
        }
Esempio n. 17
0
		/// <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( Page pageCurrent , string ShowProgbarScript ) {
			StreamReader sr = new StreamReader( pageCurrent.MapPath( ShowProgbarScript ) , 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();
		}
        /// <summary>
        /// This single argument helper operation retrieves the base dictionary
        /// input file and fills and sets the maximum word length.
        /// </summary>
        /// <param name="refPage">Reference to the calling ASP.NET System.Web.UI.Page</param>
        /// <param name="dictionaryNum">Specifies which dictionary to use.</param>
        private void GetDictionaryFile( Page refPage, int dictionaryNum )
        {
            usedWords = new SortedList();
            for(int x = 'a'; x < (int)('z' + 1); x++ )
                usedWords.Add( (char)x, 0 );
            dictionarySize = 0;
            nextWord = "";

            pageRef = refPage;
            if( file == null )
            {	/* This will successfully access the input files if the IIS web server
                 * is running frontpage server extensions on thepuzzler_3dstyle web folder.
                 */
                file = new string [] { "base_dictionary#1.txt", "base_dictionary#2.txt",
                                       "base_dictionary#3.txt", "base_dictionary#4.txt" };

                string path = Path.GetFullPath( string.Concat( refPage.MapPath( "~" ), @"\", file[dictionaryNum - 1] ) );
                //try
                //{
                //    reader = new StreamReader( path );
                //    file = null;
                //}
                //catch( DirectoryNotFoundException ) {}
                if( reader == null )
                {
                    try
                    {
                        //file = new string []
                        //{	/* This will successfully access the input files if the IIS web server
                        //    * is running file share access on thepuzzler_3dstyle web folder.
                        //    */
                        //    @"\\localhost\thepuzzler_3dstyle\base_dictionary#1.txt",
                        //    @"\\localhost\thepuzzler_3dstyle\base_dictionary#2.txt",
                        //    @"\\localhost\thepuzzler_3dstyle\base_dictionary#3.txt",
                        //    @"\\localhost\thepuzzler_3dstyle\base_dictionary#4.txt"
                        //};
                        //reader = new StreamReader( file[dictionaryNum - 1] );
                        reader = new StreamReader( path );
                        file = null;
                    }
                    catch( System.IO.FileNotFoundException error )
                    {
                        Trace.WriteLine( "You must make absolutely sure that the files base_dictionary#1.txt," +
                            "base_dictionary#2.txt, base_dictionary#3.txt, and base_dictionary#4.txt are " +
                            "in the web folder http://<YourServersName>/thepuzzler_3dstyle/ !!" +
                            "\nMessage:\n" + error.ToString() );
                    }
                }
            }
            if( puzzle.GetUpperBound(0) + 1 > puzzle.GetUpperBound(1) + 1 &&
                puzzle.GetUpperBound(0) + 1 > puzzle.GetUpperBound(2) + 1 )
                maximumWordLength = puzzle.GetUpperBound(0) + 1;
            else if( puzzle.GetUpperBound(1) + 1 > puzzle.GetUpperBound(0) + 1 &&
                puzzle.GetUpperBound(1) + 1 > puzzle.GetUpperBound(2) + 1)
                maximumWordLength = puzzle.GetUpperBound(1) + 1;
            else
                maximumWordLength = puzzle.GetUpperBound(2) + 1;
        }
Esempio n. 19
0
        /// <summary>
        /// Returns the root directory of the web site
        /// that contains this Page object.
        /// 
        /// Returns an empty string if an error occurs.
        /// </summary>
        /// <param name="page">A web site Page object</param>
        /// <returns>The root directory</returns>
        public static string GetRoot(Page page)
        {
            if (page == null)
                return "";

            return page.MapPath(tildeStart);
        }
Esempio n. 20
0
        /// <summary>
        /// Returns the markup from the search 
        /// of either the public directories
        /// or all directories that start at
        /// tildeDirectoryPath.
        /// </summary>
        /// <param name="page">
        ///     The page calling this method</param>
        /// <param name="tildeDirectoryPath">
        ///     The root of the directory tree to search</param>
        /// <param name="pattern">
        ///     The search pattern</param>
        /// <param name="isRegex">
        ///     Is the pattern a regular expression?</param>
        /// <param name="ignoreCase">
        ///     Ignore case in the search?</param>
        /// <param name="statistics">
        ///     Include file statistics markup?</param>
        /// <param name="download">
        ///     Include download button markup?</param>
        /// <param name="onlyPublic">
        ///     Whether or not to restrict to public directories</param>
        public static string SearchTreeMarkup(Page page,
            string tildeDirectoryPath,
            string pattern,
            bool isRegex,
            bool ignoreCase,
            bool statistics,
            bool download,
            bool onlyPublic)
        {
            StringBuilder builder = new StringBuilder();

            int n = tildeDirectoryPath.Length;

            if (tildeDirectoryPath[n - 1] != SourceTools.slash)
                tildeDirectoryPath = tildeDirectoryPath + SourceTools.slash;

            string directoryPath = page.MapPath(tildeDirectoryPath);

            string rootPath = FileTools.GetRoot(page);

            List<string> directoryList =
                SourceTools.MakeDirectoryList(directoryPath, onlyPublic);

            List<string> tildeDirectoryList =
                FileTools.GetTildePaths(rootPath, directoryList);

            foreach (string tdp in tildeDirectoryList)
            {
                string markup =
                    SearchDirectoryMarkup(page, tdp, pattern,
                        isRegex, ignoreCase, statistics, download, onlyPublic);

                if (!StringTools.IsTrivial(markup))
                    builder.Append(markup);
            }

            return builder.ToString();
        }
Esempio n. 21
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( 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();
		}
Esempio n. 22
0
		/// <summary>
		/// 写入图像水印
		/// </summary>
		/// <param name="str">水印字符串</param>
		/// <param name="filePath">原图片位置</param>
		/// <param name="savePath">水印加入后的位置</param>
		/// <returns></returns>
		public static string CreateBackImage( Page pageCurrent , string str , string filePath , string savePath , int x ,
									  int y ) {
			Image img = 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 ) , ImageFormat.Jpeg );
			return savePath;
		}
Esempio n. 23
0
        /// <summary>
        /// Create the HTML markup to view the file if possible.
        /// 
        /// If the file is a text file then
        /// the markup will be enclosed in pre tags.
        /// 
        /// Precondition: The page that calls this method must:
        /// 
        ///   Be able to guarantee that the file is OK to serve
        ///   in context.
        /// </summary>
        /// <param name="page">
        ///     The page that will use the markup</param>
        /// <param name="tildeFilePath">
        ///     The tilde file path</param>
        /// <param name="numberLines">
        ///     Whether or not to number lines in a text file</param>
        public static string FileViewMarkup(Page page, string tildeFilePath, bool numberLines)
        {
            int category = FileTools.GetFileCategory(tildeFilePath);

            if (category == FileTools.OTHER)
                return NotViewable;

            StringBuilder builder = new StringBuilder();

            if (category == FileTools.TEXT)
            {
                string filePath = page.MapPath(tildeFilePath);
                string text = FileTools.GetFileAsText(filePath);
                string html = HTML_Tools.TextToHTML(text, 4, numberLines);
                builder.Append(HTML_Tools.open_pre);
                builder.Append(html);
                builder.Append(HTML_Tools.shut_pre);
            }
            else
            {
                string imageURL = FileTools.GetRelativePath(page, tildeFilePath);

                builder.Append("<img src='");
                builder.Append(imageURL);
                builder.Append("' alt='");
                builder.Append(tildeFilePath);
                builder.Append("' title='");
                builder.Append(tildeFilePath);
                builder.Append("' />\n");
            }

            return builder.ToString();
        }
Esempio n. 24
0
        public static bool DownloadFile(Page page, HttpResponse response, HttpSessionState userSession)
        {
            Regex RE = new Regex(@"[,]+");
            string[] tImagePathDef = RE.Split((string)userSession[IGSMRequest.IGSMREQUEST_PARAM_LISTPATH]);

            string sImageFileName = Path.GetFileName(tImagePathDef[0]);
            string sFilePath = page.MapPath(tImagePathDef[0]);
            response.ContentType = "application/octet-stream";
            response.AddHeader("Content-Disposition", "attachment; filename=" + sImageFileName);
            response.WriteFile(sFilePath);
            userSession.Remove(IGSMRequest.IGSMREQUEST_PARAM_LISTPATH);
            return true;
        }
Esempio n. 25
0
        /// <summary>
        /// Returns a list of Range objects representing
        /// the matches of the pattern in the content of
        /// a text file with the given tilde file path.
        /// 
        /// If successful, returns a reference to the
        /// text file content via an out parameter.
        /// 
        /// If isRegex is true,
        /// uses regular expression matching,
        /// otherwise uses plain text matching.
        /// 
        /// Ignores case if ignoreCase is true.
        /// 
        /// Returns null if the file is not a text file.
        /// 
        /// Precondition: The page that calls this method must:
        /// 
        ///   Be able to guarantee that the file is OK to serve
        ///   in context.
        /// </summary>
        /// <param name="page">
        ///     The page object that uses this method</param>
        /// <param name="tildeFilePath">
        ///     The tilde file path</param>
        /// <param name="pattern">
        ///     The search pattern</param>
        /// <param name="isRegex">
        ///     If true use regex matching</param>
        /// <param name="ignoreCase">
        ///     If true ignore case</param>
        /// <param name="content">
        ///     Out param: If the file is a text file
        ///     then returns a reference to its content;
        ///     otherwise returns null.</param>
        public static List<Range> SearchFileContent(Page page,
            string tildeFilePath,
            string pattern,
            bool isRegex,
            bool ignoreCase,
            out string content)
        {
            content = null;

            int category = FileTools.GetFileCategory(tildeFilePath);

            if (category != FileTools.TEXT)
                return null;

            string filePath = page.MapPath(tildeFilePath);
            content = FileTools.GetFileAsText(filePath);

            return Search(content, pattern, 0, isRegex, ignoreCase);
        }
Esempio n. 26
0
		public static bool GenerateTheme(Page page, string themeName)
		{
			if(page == null || string.IsNullOrWhiteSpace(themeName))
				return false;

			var resolver = Zongsoft.Web.Themes.ThemeResolver.GetResolver(page.MapPath("~/themes"));

			if(resolver == null)
				return false;

			var theme = resolver.Resolve(themeName);

			if(theme == null)
				return false;

			try
			{
				foreach(var include in theme.Includes)
				{
					GenerateComponent(include.Target, page);
				}

				page.Response.SetCookie(new HttpCookie(ThemeName, themeName));

				//返回成功
				return true;
			}
			finally
			{
				HashSet<string> temp;
				_pageLinks.TryRemove(page, out temp);
			}
		}
        private void SetConfigFilePath(Page page)
        {
            string strPath = page.MapPath("");
            if (strPath.EndsWith("Forms"))
            {
                this.ConfigFile = strPath + @"\Config\Template.config";
            }
            else if (strPath.EndsWith("Management"))
            {

                this.ConfigFile = strPath.Substring(0, strPath.LastIndexOfAny(@"\Management".ToCharArray()) - @"\Management".Length + 1) + @"\Templates\Template.config";
            }
            else
            {
                // this.ConfigFile = page.MapPath("") + @"\Template.config";
                this.ConfigFile = HttpContext.Current.Server.MapPath(@"/Config/Template.config");
            }
        }
Esempio n. 28
0
		/// <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( 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();
		}