Example #1
0
 protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     if (isRefreshRequest || _contentChanged)
     {
         response.Write(GetReference() + ".reset();\n");
         foreach (var item in _items)
         {
             if (item.Value is itemInfo)
             {
                 var i = item.Value as itemInfo;
                 var t = i.Item as qxDotNet.Core.Object;
                 response.Write(GetReference() + ".add(" + t.GetReference() + "," + GetClientValue(i.Label) + ");\n");
             }
             else if (item.Value is buttonInfo)
             {
                 var i = item.Value as buttonInfo;
                 var t = i.button as qxDotNet.Core.Object;
                 response.Write(GetReference() + ".addButton(" + t.GetReference() + ");\n");
             }
             else if (item.Value is groupInfo)
             {
                 var i = item.Value as groupInfo;
                 response.Write(GetReference() + ".addGroupHeader(" + GetClientValue(i.title) + ");\n");
             }
         }
     }
     base.CustomPostRender(response, isRefreshRequest);
 }
Example #2
0
        private static void GetFile(string person_id, char type, System.Web.HttpResponse Response)
        {
            string cmd = "";

            switch (type)
            {
            case 'P':
                cmd = "research_dir_user.profile_views.get_profile_picture";
                break;

            case 'C':
                cmd = "research_dir_user.profile_views.get_profile_cv";
                break;

            default:
                Response.Write("Error:type not defined");
                return;
            }

            using (Oracle.DataAccess.Client.OracleConnection orCN = HealthIS.Apps.Util.getDBConnection())
            {
                orCN.Open();
                OracleCommand orCmd = new OracleCommand(cmd, orCN);
                orCmd.CommandType = System.Data.CommandType.StoredProcedure;

                orCmd.Parameters.Add("p_person_id", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input;
                orCmd.Parameters["p_person_id"].Value = person_id;

                orCmd.Parameters.Add("r_cur", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output;

                OracleDataAdapter   adapt = new OracleDataAdapter(orCmd);
                System.Data.DataSet orDS  = new System.Data.DataSet();

                orCmd.ExecuteNonQuery();
                adapt.Fill(orDS);

                if (orDS.Tables[0].Rows.Count > 0)
                {
                    System.Data.DataRow dr = orDS.Tables[0].Rows[0];
                    byte[] barray          = (byte[])dr["file_binary"];
                    Response.ContentType = (String)dr["file_mimetype"];
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + person_id + "." + dr["file_ext"].ToString() + ";");
                    Response.AddHeader("Content-Length", barray.Length.ToString());
                    Response.OutputStream.Write(barray, 0, barray.Length);
                }
                else
                {
                    Response.Write("Error, no file found for person_id '" + person_id + "'");
                }

                orDS.Dispose();
                adapt.Dispose();
                orCmd.Dispose();
                orCN.Close();
                orCN.Dispose();
            }
        }
Example #3
0
 protected internal virtual void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     if (isRefreshRequest)
     {
         foreach (var item in _appliedMethods.Get())
         {
             response.Write(item.GetExpression(this));
         }
     }
     foreach (var item in _newMethods.Get())
     {
         response.Write(item.GetExpression(this));
     }
 }
Example #4
0
 protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     base.CustomPostRender(response, isRefreshRequest);
     if (_needToActivate)
     {
         response.Write(GetReference() + ".activate();\n");
         _needToActivate = false;
     }
     if (_needToFocus)
     {
         response.Write(GetReference() + ".focus();\n");
         _needToFocus = false;
     }
 }
 protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     base.CustomPostRender(response, isRefreshRequest);
     foreach (var rec in _openURL)
     {
         if (rec.isBlank)
         {
             response.Write("window.open('" + rec.path + "', '_blank');");
         }
         else
         {
             response.Write("window.open('" + rec.path + "');");
         }
     }
     _openURL.Clear();
 }
 protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     if (isRefreshRequest || _form.ContentChanged)
     {
         response.Write(GetReference() + " = new qx.ui.form.renderer.Single(" + _form.GetReference() + ");");
     }
     base.CustomPostRender(response, isRefreshRequest);
 }
Example #7
0
        public static void ResponseExcel <T>(System.Web.HttpResponse response, List <T> items)
        {
            try
            {
                string attachment = "attachment; filename=vauExcel.xls";
                response.ClearContent();
                response.AddHeader("content-disposition", attachment);
                response.ContentType = "application/vnd.ms-excel";
                string tab = string.Empty;

                // Get all the properties
                PropertyInfo[] props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
                foreach (PropertyInfo prop in props)
                {
                    response.Write(tab + prop.Name);
                    tab = "\t";
                }

                response.Write("\n");
                foreach (T item in items)
                {
                    var values = new object[props.Length];
                    for (int i = 0; i < props.Length; i++)
                    {
                        values[i] = props[i].GetValue(item, null);
                        if (values[i] != null)
                        {
                            response.Write(values[i].ToString().Trim() + "\t");
                        }
                        else
                        {
                            response.Write("\t");
                        }
                    }

                    response.Write("\n");
                }

                response.Flush();
                response.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #8
0
 protected internal override void CustomPreRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     if (!WindowClosed && Centered)
     {
         response.Write(GetReference() + ".addListener(\"appear\",function(){this.center();}, " + GetReference() + ");");
     }
     base.CustomPostRender(response, isRefreshRequest);
 }
        public override void Response(System.Web.HttpResponse response)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var output = new StringBuilder();

            serializer.Serialize(_model, output);

            response.ContentType = "application/json";
            response.Write(output.ToString());
        }
Example #10
0
        protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
        {
            var model = _tableModel as qxDotNet.Core.Object;

            if (_tableModel.Modified || isRefreshRequest)
            {
                var sb = new StringBuilder();

                // TableColumnModel
                var tcm = "tcm" + clientId.ToString();
                sb.AppendLine("var " + tcm + "=" + GetReference() + ".getTableColumnModel();");

                foreach (var item in Columns)
                {
                    var id = Columns.IndexOf(item);
                    if (item.Width > 0)
                    {
                        sb.AppendLine(tcm + ".setColumnWidth(" + id + "," + item.Width + ");");
                    }
                    sb.AppendLine(model.GetReference() + ".setColumnEditable(" + id + "," + GetClientValue(item.Editable) + ");");
                    sb.AppendLine(model.GetReference() + ".setColumnSortable(" + id + "," + GetClientValue(item.Sortable) + ");");
                    if (item.CellRenderer != null)
                    {
                        sb.AppendLine(tcm + ".setDataCellRenderer(" + id + "," + item.CellRenderer.GetReference() + ");");
                    }
                    if (item.CellEditor != null)
                    {
                        sb.AppendLine(tcm + ".setCellEditorFactory(" + id + "," + item.CellEditor.GetReference() + ");");
                    }
                }

                response.Write(sb.ToString());
                _tableModel.ResetModified();
            }
            if (_needToRefresh)
            {
                response.Write(model.GetReference() + ".reloadData();\n");
                _needToRefresh = false;
            }
            base.CustomPostRender(response, isRefreshRequest);
        }
Example #11
0
 public static void WriteToResponce(System.Web.HttpResponse httpResponse, string exportWay)
 {
     using (var fs = new FileStream(exportWay, FileMode.Open))
         using (var reader = new StreamReader(fs, Encoding.UTF8))
         {
             string line;
             while ((line = reader.ReadLine()) != null)
             {
                 httpResponse.Write(line);
             }
         }
 }
Example #12
0
 protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     base.CustomPostRender(response, isRefreshRequest);
     if (_titleChanged || isRefreshRequest)
     {
         if (!isRefreshRequest)
         {
             _titleChanged = false;
         }
         response.Write("window.document.title = \"" + _title.EscapeToJS() + "\";");
     }
 }
Example #13
0
        public override void Response(System.Web.HttpResponse response)
        {
#if NET40
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var output = new StringBuilder();
            serializer.Serialize(_model, output);

            response.ContentType = "application/json";
            response.Write(output.ToString());
#else
            throw new NotImplementedException("ToDo: use JSON.NET for <4.0");
#endif
        }
Example #14
0
 /// <summary>
 /// 把DataTable导出为Word文件
 /// </summary>
 /// <param name="page">Page</param>
 /// <param name="fileName">Word文件名(不包括后缀*.doc)</param>
 /// <param name="dtbl">将要被导出的DataTable对象</param>
 /// <returns></returns>
 public static bool DataTableToWord(System.Web.HttpResponse response, string fileName, DataTable dtbl)
 {
     response.Clear();
     response.Buffer  = true;
     response.Charset = "UTF-8";
     response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".doc");
     response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
     response.ContentType     = "application/ms-word";
     //page.EnableViewState = false;
     response.Write(DataTableToHtmlTable(dtbl));
     response.End();
     return(true);
 }
Example #15
0
 protected internal override void CustomPostRender(System.Web.HttpResponse response, bool isRefreshRequest)
 {
     base.CustomPostRender(response, isRefreshRequest);
     if (_closed)
     {
         return;
     }
     if (_needToOpen || isRefreshRequest)
     {
         response.Write(GetReference() + ".open();\n");
         _needToOpen = false;
     }
 }
Example #16
0
        public static void Export(System.Data.DataTable dt, System.Web.HttpResponse response, string filename)
        {
            //first let's clean up the response.object
            response.Clear();
            response.ClearHeaders();
            response.Buffer          = true;
            response.ContentEncoding = System.Text.Encoding.UTF8;
            response.Charset         = "utf-8";
            response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
            //set the response mime type for excel
            response.ContentType = "application/vnd.ms-excel";

            // added to help issue with IE problems with Cache-Control: no-cache
            response.ExpiresAbsolute = DateTime.Now.AddYears(-1);

            //header/footer to support UTF-8 characters
            var header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + Constants.vbLf + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + Constants.vbLf + "<head>" + Constants.vbLf + "<title></title>" + Constants.vbLf + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" + Constants.vbLf + "<style>" + Constants.vbLf + "</style>" + Constants.vbLf + "</head>" + Constants.vbLf + "<body>" + Constants.vbLf;
            var footer = Constants.vbLf + "</body>" + Constants.vbLf + "</html>";

            response.Write(header);

            //create an htmltextwriter which uses the stringwriter
            var htmlWrite = new System.Web.UI.HtmlTextWriter(response.Output);
            //instantiate a datagrid
            var dg = new System.Web.UI.WebControls.DataGrid();

            //set the datagrid datasource to the dataset passed in
            dg.DataSource = dt;
            //bind the datagrid
            dg.DataBind();
            //tell the datagrid to render itself to our htmltextwriter
            dg.RenderControl(htmlWrite);

            response.Write(footer);

            //all that's left is to output the html
            response.End();
        }
Example #17
0
        /// <summary>
        /// Handles a fatal server exception.
        /// </summary>
        public static void HandleFatalServerException()
        {
            System.Web.HttpResponse resp = System.Web.HttpContext.Current.Response;
            resp.ClearContent();
            resp.StatusCode = 400;
            resp.AddHeader("Status", "400 Bad Request");

            // resp.StatusDescription = "Not Found";
            // resp.Write("404 Not Found");
            //resp.Flush();
            resp.Write("<html><body><strong>The page that you requested caused a server error.</strong><p><em>Please try back later, or try visiting our <a href=\"" + CmsContext.ApplicationPath + "\">home page</a>.</em></p></body></html>");

            resp.End();
            return;
        }
Example #18
0
        public override void Execute(System.Web.HttpResponse response)
        {
            var data = new byte[File.Length];

            //TODO: very long files will blow up here
            File.Read(data, 0, (int)File.Length);

            string template = Encoding.UTF8.GetString(data);

            var presenter = RunPresenter(Path);

            var result = RazorEngine.Razor.Parse(template, new { name = presenter.GetType().Name });

            response.Write(result);
        }
Example #19
0
        /// <summary>
        /// Exports dataset into CSV / Excel format
        /// </summary>
        private void ExportForWeb(DataSet exportDataSet, string[] headerList, string[] filedList, ExportFormat formatType, string fileName)
        {
            try
            {
                response.Clear();
                response.Buffer = true;

                if (formatType == ExportFormat.CSV)
                {
                    response.ContentType = "text/csv";
                    response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
                }
                else
                {
                    response.ContentType = "application/vnd.ms-excel";
                    response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
                }

                MemoryStream    memoryStream    = new MemoryStream();
                XmlTextWriter   xmlTextWriter   = new XmlTextWriter(memoryStream, Encoding.UTF8);
                XmlDataDocument xmlDataDocument = new XmlDataDocument(exportDataSet);
                XslTransform    xslTransform    = new XslTransform();
                StringWriter    stringWriter    = new StringWriter();

                CreateStylesheet(xmlTextWriter, headerList, filedList, formatType);
                xmlTextWriter.Flush();
                memoryStream.Seek(0, SeekOrigin.Begin);

                xslTransform.Load(new XmlTextReader(memoryStream), null, null);
                xslTransform.Transform(xmlDataDocument, null, stringWriter, null);

                response.Write(stringWriter.ToString());
                stringWriter.Close();
                xmlTextWriter.Close();
                memoryStream.Close();
                response.End();
            }
            catch (ThreadAbortException ex)
            {
                string ErrMsg = ex.Message;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #20
0
        /// <summary>
        /// Handle PageNotFound (404) errors.
        /// <para>If the useInternal404NotFoundErrorHandler config entry is true, will send the user to the page
        /// specified by Internal404NotFoundErrorHandlerPageUrl config entry.</para>
        /// </summary>
        public static void HandleNotFoundException()
        {
            bool useInternal404NotFoundErrorHandler = CmsConfig.getConfigValue("useInternal404NotFoundErrorHandler", false);

            if (useInternal404NotFoundErrorHandler)
            {
                string defaultUrl = "";
                if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null)
                {
                    defaultUrl = System.Web.HttpContext.Current.Request.Url.PathAndQuery;
                }

                string fromUrl = PageUtils.getFromForm("aspxerrorpath", defaultUrl);
                fromUrl = System.Web.HttpUtility.UrlEncode(fromUrl);

                string Internal404NotFoundErrorHandlerPageUrl = CmsContext.ApplicationPath + "/_internal/error404.aspx?from=" + fromUrl;
                if (CmsConfig.getConfigValue("Internal404NotFoundErrorHandlerPageUrl", "") != "")
                {
                    Internal404NotFoundErrorHandlerPageUrl = String.Format(CmsConfig.getConfigValue("Internal404NotFoundErrorHandlerPageUrl", ""), fromUrl);
                }

                // use Server.Transfer (And not Response.Redirect) to hide the CMS URL from the user.
                System.Web.HttpContext.Current.Server.Transfer(Internal404NotFoundErrorHandlerPageUrl);
                return;
            }
            else
            {
                // <?php header("HTTP/1.1 404 Not Found"); ?>
                // <?php header("Status: 404 Not Found"); ?>

                System.Web.HttpResponse resp = System.Web.HttpContext.Current.Response;
                resp.ClearContent();
                resp.StatusCode = 404;
                resp.AddHeader("Status", "404 Not Found");

                resp.Write("<html><body><strong>The page that you requested does not exist.</strong><p><em>Visit our <a href=\"" + CmsContext.ApplicationPath + "\">home page here</a></em></p></body></html>");
                resp.End();
                return;

                // throw new System.Web.HttpException(404, "File Not Found"); //http://forums.asp.net/t/762031.aspx
            }
        }
Example #21
0
        }   // TODO: Add constructor logic here

        public void ProcessRequest(System.Web.HttpContext context)
        {
            System.Web.HttpResponse response = context.Response;

            response.ClearHeaders();
            response.ClearContent();
            response.Clear();

            response.ContentType     = "text/html";
            response.ContentEncoding = System.Text.Encoding.UTF8;


            // <p id="errorMessage">@error.Type: @error.Message</p>
            // <span>@error.StackTrace</span>
            string res = ResourceHelper.GetResource(typeof(ErrorTemplateHandler), "ErrorTemplate.htm");

            response.Write(res);

            // response.Write("<html><body><h1>Hello 15Seconds   Reader ");
            // response.Write("</body></html>");
        }         // End Sub ProcessRequest
Example #22
0
 internal static void ThrowWmsException(WmsExceptionCode code, string Message)
 {
     System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
     Response.Clear();
     Response.ContentType = "text/xml";
     Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
     Response.Write("<ServiceExceptionReport version=\"1.3.0\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\">\n");
     Response.Write("<ServiceException");
     if (code != WmsExceptionCode.NotApplicable)
     {
         Response.Write(" code=\"" + code.ToString() + "\"");
     }
     Response.Write(">" + Message + "</ServiceException>\n");
     Response.Write("</ServiceExceptionReport>");
     Response.End();
 }
Example #23
0
        protected internal override void CustomPreRender(System.Web.HttpResponse response, bool isRefreshRequest)
        {
            Common.TableState.Instance.RegisterModel(_tableModel);
            var model = _tableModel as qxDotNet.Core.Object;

            if (_tableModel.Modified || isRefreshRequest)
            {
                var sb = new StringBuilder();

                sb.AppendLine(model.GetReference() + "._id_=" + model.clientId + ";");

                // setColumns
                sb.Append(model.GetReference() + ".setColumns([");
                var f = false;
                foreach (var item in Columns)
                {
                    if (f)
                    {
                        sb.Append(",");
                    }
                    sb.Append("\"" + item.Name.EscapeToJS() + "\"");
                    f = true;
                }
                sb.Append("],[");
                f = false;
                for (int i = 0; i < Columns.Count; i++)
                {
                    if (f)
                    {
                        sb.Append(",");
                    }
                    sb.Append("\"c" + i.ToString() + "\"");
                    f = true;
                }
                sb.AppendLine("]);");

                response.Write(sb.ToString());
            }
        }
Example #24
0
            /// <summary>
            /// Initialization event.
            /// </summary>
            /// <param name="e"></param>
            protected override void OnInit(EventArgs e)
            {
                System.Web.HttpRequest  request  = Context.Request;
                System.Web.HttpResponse response = Context.Response;
                if (request.Params["PlotSurface2D_" + this.ClientID] != null)
                {
                    // retrieve the bitmap and display
                    response.Clear();
                    try
                    {
                        response.ContentType = "Image/Png";
                        System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)Context.Session[prefix() + "PNG"];

                        // don't ask why, but if I write directly to the response
                        // I have a GDI+ error, if I first write to a MemoryStream and
                        // then to the response.OutputStream I don't get an error.
                        System.IO.MemoryStream s = new System.IO.MemoryStream();
                        bmp.Save(s, System.Drawing.Imaging.ImageFormat.Png);
                        s.WriteTo(response.OutputStream);
                        Context.Session.Remove(prefix() + "PNG");
                    }
                    catch (Exception ex)
                    {
                        response.ContentType = "Text/HTML";
                        response.Write(ex.Message);
                    }
                    finally
                    {
                        response.Flush();
                        response.End();
                    }
                }

                this.plotUrl = this.buildPlotURL();
                base.OnInit(e);
            }
Example #25
0
        /// <summary>
        /// 显示模板信息到页面
        /// </summary>
        public static void PrintTemplatesInfo()
        {
            string        templateContent = Embed.SysTemplatePage;
            StringBuilder sb = new StringBuilder();

            sb.Append(@"<style type=""text/css"">
                          table{width:100%;background:#eee;margin:0 auto;line-height:25px;color:#222;cursor:pointer}
                          table td{background:white;padding:0 8px;}
                          table th{background:#006699;color:white;}
                          table tr.hover td{background:#222;color:white;}
                          table tr.even td{}
                        </style>
                        <script type=""text/javascript"">
                             function dynamicTable(table) {
                                if (table && table.nodeName === 'TABLE') {
                                    var rows = table.getElementsByTagName('tr');
                                    for (var i = 0; i < rows.length; i++) {
                                    if (i % 2 == 1) if (!rows[i].className) rows[i].className = 'even';
                                    rows[i].onmouseover = function () {
                                        this.className = this.className.indexOf('even') != -1 ? 'hover even' : 'hover';
                                    };
                                    rows[i].onmouseout = function () {
                                        this.className = this.className.indexOf('even') == -1 ? '' : 'even';
                                    };
                                 }
                               }
                            }</script>

                        <table cellspacing=""1"" id=""templates"">
                            <tr>
                                <th style=""width:50px;""></th><th style=""width:150px;"">模板编号</th><th style=""width:80px;"">模板类型</th><th>文件名</th><th>模板注释</th><th>文件路径</th></tr>
				<!--
                <tr><td colspan=""6"" align=""center"" style=""background:#c20000;color:white"">扩展名为“.phtml”表示为一个部分视图;部分视图只能使用ID命名</td></tr>
                -->"        );

            Template tpl;
            string   tplFileName, tplContent; //模板文件名,内容
            int      i = 0;

            foreach (string key in TemplateCache.templateDictionary.Keys)
            {
                tpl         = TemplateCache.templateDictionary[key];
                tplFileName =
                    new Regex("templates(/|\\\\)+#*(.+?)$", RegexOptions.IgnoreCase).Match(tpl.FilePath).Groups[2].Value
                    .Replace("\\", "/");
                tplContent = tpl.Content;

                sb.Append("<tr><td class=\"center\">").Append((++i).ToString()).Append("</td><td class=\"center\">")
                .Append(key.ToLower()).Append("</td><td class=\"center\">")
                .Append(

                    //RegexUtility.partialRegex.IsMatch(tplContent) && tplContent.IndexOf("<title>") != -1
                    !tpl.FilePath.EndsWith(".phtml")
                            ? "<span style=\"color:#333\">模板页面</span>"
                            : "<span style=\"color:#006699\">部分视图</span>")
                .Append("</td><td>/").Append(tplFileName).Append("</td><td>").Append(tpl.Comment)
                .Append("</td><td>").Append(tpl.FilePath).Append("</td></tr>");
            }

            sb.Append(@"<tr><td colspan=""6"" align=""center"" style=""background:#f0f0f0;color:#333"">
						部分视图扩展名为“.phtml”,可允许格式如:
						&nbsp;&nbsp;A:${partial:""inc/header.phtml""}
						&nbsp;&nbsp;B:${partial:""/tmpdir/inc/header.phtml""}
						&nbsp;&nbsp;C:${partial:""../../inc/header.phtml""}
						</td></tr>"                        );

            sb.Append(
                "</table><script type=\"text/javascript\">dynamicTable(document.getElementsByTagName('table')[0]);</script>");

            templateContent = TemplateRegexUtility.Replace(templateContent, match =>
            {
                switch (match.Groups[1].Value)
                {
                case "title":
                    return("模板信息");

                case "content":
                    return(sb.ToString());

                case "year":
                    return(DateTime.Now.Year.ToString());
                }
                return(String.Empty);
            });

            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.Write(TemplateUtility.CompressHtml(templateContent));
            response.End();
        }
Example #26
0
        //#region 获取上传文件自动生成的文件名
        //public static string GetFileName(string str, string eve)
        //{
        //    try
        //    {

        //        string name = str.ToLower().Substring(str.LastIndexOf(".") + 1);
        //        if (eve.IndexOf(name) != -1)
        //        {
        //            System.Random rd = new Random();

        //            string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + DateTime.Now.Millisecond.ToString() + rd.Next(1111, 9999).ToString() + "." + name;
        //            return filename;
        //        }
        //        else
        //        {
        //            JS.MsgBox("上传文件格式错误");
        //            JS.Back();
        //            System.Web.HttpContext.Current.Response.End();
        //        }
        //    }
        //    catch
        //    {
        //        JS.MsgBox("上传文件出错");
        //        JS.Back();
        //        System.Web.HttpContext.Current.Response.End();
        //        return "";
        //    }
        //    return "";
        //}
        //#endregion

        #region 防SQL注入式攻击


        public static void ModSQL()
        {
            System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
            System.Web.HttpRequest  Request  = System.Web.HttpContext.Current.Request;
            foreach (string i in Request.Form)
            {
                if (i == "__VIEWSTATE")
                {
                    continue;
                }
                if (!modSQL(Request.Form[i].ToString()))
                {
                    //string tmpPath = System.Web.HttpContext.Current.Server.MapPath("~/log.js");
                    //FileInfo fi = new FileInfo(tmpPath);
                    //StreamWriter sw = fi.CreateText();
                    //sw.Write("IP operation:" + Request.UserHostAddress);
                    //sw.Write("Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    //sw.Write("Page:" + Request.Url.ToString());
                    //sw.Write("Parameters:" + i + "");
                    //sw.Write("Data:" + Request.QueryString[i]);
                    //sw.Flush();
                    //sw.Close();
                    Response.Write("<table width=80% align='center' cellpadding='0' cellspacing='0'>");
                    Response.Write("<tr><td><BR><BR><BR><BR>hackers : Please do not try to inject attack site, the site has implemented safety control, lawless elements will crack down!</td></tr>");
                    Response.Write("<tr><td>Keep your system has been operational records law:<br></td></tr>");
                    Response.Write("<tr><td><br>IP operation:" + Request.UserHostAddress + "<br></td></tr>");
                    Response.Write("<tr><td>Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "<br></td></tr>");
                    Response.Write("<tr><td>Page:" + Request.Url.ToString() + "<br></td></tr>");
                    Response.Write("<tr><td>Submit Type:POST<br></td></tr>");
                    Response.Write("<tr><td>Parameters:" + i + "<br></td></tr>");
                    Response.Write("<tr><td>Data:" + Request.Form[i]);
                    Response.Write("</td></tr></table>");
                    Response.End();
                }
            }
            foreach (string i in Request.QueryString)
            {
                if (!modSQL(Request.QueryString[i].ToString()))
                {
                    Response.Write("<table width=80% align='center' cellpadding='0' cellspacing='0'>");
                    Response.Write("<tr><td><BR><BR><BR><BR>hackers : Please do not try to inject attack site, the site has implemented safety control, lawless elements will crack down!</td></tr>");
                    Response.Write("<tr><td>Keep your system has been operational records law:<br></td></tr>");
                    Response.Write("<tr><td><br>IP operation:" + Request.UserHostAddress + "<br></td></tr>");
                    Response.Write("<tr><td>Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "<br></td></tr>");
                    Response.Write("<tr><td>Page:" + Request.Url.ToString() + "<br></td></tr>");
                    Response.Write("<tr><td>Sumbit Type:GET<br></td></tr>");
                    Response.Write("<tr><td>Parameters:" + i + "<br></td></tr>");
                    Response.Write("<tr><td>Data:" + Request.QueryString[i]);
                    Response.Write("</td></tr></table>");
                    Response.End();
                }
            }
        }
Example #27
0
 public static void ShowMessage(
     System.Web.HttpResponse response,
     string Msg)
 {
     response.Write("<script language='javascript'> \n window.alert('" + Msg + "');\n</script>\n");
 }
Example #28
0
 public override void Execute(System.Web.HttpResponse response)
 {
     response.Write("xml");
 }
Example #29
0
 public static void ShowMessage(
     System.Web.HttpResponse response,
     string Msg)
 {
     response.Write("<script>alert('" + Msg + "');</script>");
 }
Example #30
0
        }   // TODO: Add constructor logic here

        public void ProcessRequest(System.Web.HttpContext context)
        {
            System.Web.HttpResponse response = context.Response;

            response.ClearHeaders();
            response.ClearContent();
            response.Clear();

            response.ContentType     = "text/html";
            response.ContentEncoding = System.Text.Encoding.UTF8;

            string html = @"<!DOCTYPE html>
<html xmlns=""http://www.w3.org/1999/xhtml"" lang=""en"">
<head>
    <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1"" />

    <meta http-equiv=""cache-control"" content=""max-age=0"" />
    <meta http-equiv=""cache-control"" content=""no-cache"" />
    <meta http-equiv=""expires"" content=""0"" />
    <meta http-equiv=""expires"" content=""Tue, 01 Jan 1980 1:00:00 GMT"" />
    <meta http-equiv=""pragma"" content=""no-cache"" />

    <meta charset=""utf-8"" />
    <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />

    <meta http-equiv=""Content-Language"" content=""en"" />
    <meta name=""viewport"" content=""width=device-width,initial-scale=1"" />


    <!--
    <meta name=""author"" content=""name"" />
    <meta name=""description"" content=""description here"" />
    <meta name=""keywords"" content=""keywords,here"" />

    <link rel=""shortcut icon"" href=""favicon.ico"" type=""image/vnd.microsoft.icon"" />
    <link rel=""stylesheet"" href=""stylesheet.css"" type=""text/css"" />
    -->

    <title>Title</title>

    <style type=""text/css"" media=""all"">
        body
        {
            background-color: #0c70b4;
            color: #546775;
            font: normal 400 18px ""PT Sans"", sans-serif;
            -webkit-font-smoothing: antialiased;
        }
    </style>


    <script type=""text/javascript"">
        
    </script>
    
</head>
<body>
    <h1>Hello 15Seconds Reader</h1>
</body>
</html>
";

            html = ResourceHelper.GetResource(typeof(InjectionBlockHandler), "BlackErrorTemplate_Injection_DE.htm");
            response.Write(html);

            context.ApplicationInstance.CompleteRequest();
        }         // End Sub ProcessRequest