Пример #1
0
        public ActionResult Image(string id)
        {
            SOSOshop.BLL.MongoHelper <MongoDB.Bson.BsonDocument> db = new SOSOshop.BLL.MongoHelper <MongoDB.Bson.BsonDocument>();
            var file = db._gridFS.FindOne(id);

            if (file != null)
            {
                if (Library.Lang.DataValidator.IsDateTime(Request.Headers.Get("If-Modified-Since")))
                {
                    if (DateTime.Parse(Request.Headers.Get("If-Modified-Since")).ToString("yyyy-MM-dd mm:ss") == file.UploadDate.ToLocalTime().ToString("yyyy-MM-dd mm:ss"))
                    {
                        Response.Status     = "304 Not Modified";
                        Response.StatusCode = 304;
                        return(Content(""));
                    }
                }
                byte[] bs = new byte[file.Length];
                using (var s = file.OpenRead())
                {
                    s.Read(bs, 0, bs.Length);
                    Response.Cache.SetLastModified(file.UploadDate);
                    SOSOshop.BLL.Report.DrugTestingReport bll = new SOSOshop.BLL.Report.DrugTestingReport();
                    bll.Inc(id);
                    return(File(bs, "image/jpg"));
                }
            }
            return(Content(""));
        }
        //分页数据初始化
        protected override void StartLoad(int PageIndex, string strWhere)
        {
            int recordCount, pageCount;

            AspNetPager1.PageSize = 10;
            System.Text.StringBuilder sb = new StringBuilder();
            if (!string.IsNullOrEmpty(TextBox1.Text))
            {
                sb.AppendFormat(" and Product_Name like('%{0}%')", Library.Lang.Input.Filter(TextBox1.Text));
            }
            if (!string.IsNullOrEmpty(TextBox2.Text))
            {
                sb.AppendFormat(" and DrugsBase_Manufacturer like('%{0}%')", Library.Lang.Input.Filter(TextBox2.Text));
            }
            if (!string.IsNullOrEmpty(TextBox3.Text))
            {
                sb.AppendFormat(" and DrugsBase_ApprovalNumber like('%{0}%')", Library.Lang.Input.Filter(TextBox3.Text));
            }
            if (DropDownList1.SelectedValue == "1")
            {
                sb.Append(" and Product_ID in (SELECT Product_ID FROM dbo.product_online_v)");
            }
            else if (DropDownList1.SelectedValue == "2")
            {
                sb.Append(" and Product_ID not in (SELECT Product_ID FROM dbo.product_online_v)");
            }

            SOSOshop.BLL.Report.DrugTestingReport blldtr = new SOSOshop.BLL.Report.DrugTestingReport();
            if (DropDownList2.SelectedValue == "1")
            {
                string ids = blldtr.GetProducts_Id();
                if (ids == "")
                {
                    ids = "-1";
                }
                sb.AppendFormat(" and Product_ID in ({0})", ids);
            }
            else if (DropDownList2.SelectedValue == "2")
            {
                string ids = blldtr.GetProducts_Id();
                if (ids == "")
                {
                    ids = "-1";
                }
                sb.AppendFormat(" and Product_ID not in ({0})", ids);
            }
            var dt = bll.GetListByPage("Product", "*,0 is_ZYC", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "Product_id desc", sb.ToString(), out recordCount, out pageCount);

            tablist.DataSource       = dt;
            AspNetPager1.RecordCount = recordCount;
            tablist.DataBind();
        }
Пример #3
0
 public void ProcessRequest(HttpContext context)
 {
     if (context.Request.QueryString["file"].EndsWith("rar") || context.Request.QueryString["file"].EndsWith("zip"))
     {
         context.Response.ContentType = "application/x-rar-compressed";
         context.Response.AddHeader(
             "content-disposition", string.Format("attachment; filename={0}", context.Request.QueryString["file"]));
     }
     else
     {
         context.Response.ContentType = "image/jpg";
     }
     SOSOshop.BLL.Report.DrugTestingReport bll = new SOSOshop.BLL.Report.DrugTestingReport();
     using (var fileStream = bll.GetFile(context.Request.QueryString["file"]))
     {
         long   fileSize   = fileStream.Length;
         byte[] fileBuffer = new byte[fileSize];
         fileStream.Read(fileBuffer, 0, (int)fileSize);
         context.Response.BinaryWrite(fileBuffer);
     }
 }