示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string result = "";

            try {
                if (context.Request.QueryString["id"] != null)
                {
                    string[] id = context.Request.QueryString["id"].Split(',');
                    for (int i = 0; i < id.Length; i++)
                    {
                        Convert.ToDecimal(id[i].ToString());
                    }

                    BLL.BASE_ANNEX bll = new BLL.BASE_ANNEX();
                    DataTable      dt  = new DataTable();

                    string where = string.Format("id in({0})", context.Request.QueryString["id"]);
                    dt           = bll.GetList(where);

                    result = JsonConvert.SerializeObject(dt);
                }
            }
            catch (Exception ex) {
                result = ex.Message;
            }
            finally {
                context.Response.Write(result);
            }
        }
示例#2
0
        private string UploadAnnex()
        {
            string resultAnnex = "";

            BLL.BASE_ANNEX bllAnnex = new BLL.BASE_ANNEX();
            for (int index = 0; index < Request.Files.Count; index++)
            {
                if (!string.IsNullOrEmpty(Request.Files[index].FileName))
                {
                    Entity.BASE_ANNEX annex = new Entity.BASE_ANNEX();
                    annex.SERVERNAME = Guid.NewGuid().ToString();                        //服务器存储文件名
                    annex.SRCNAME    = Path.GetFileName(Request.Files[index].FileName);  //原文件名称
                    annex.EXTENSION  = Path.GetExtension(Request.Files[index].FileName); //文件扩展名
                    annex.STATUS     = 0;                                                //存储状态:0正常
                    annex.UPAUTHOR   = userSession.USERID;                               //上传者用户ID
                    annex.DEPTCODE   = userSession.DEPTID;                               //部门编号
                    annex.UPTIME     = DateTime.Now;                                     //文件上传时间
                    annex.SERVERPATH = string.Format("Document/{0}/", DateTime.Now.ToString("yyyyMMdd"));

                    //判断服务器存储目录路径是否存在
                    if (!Directory.Exists(Server.MapPath("~/") + annex.SERVERPATH))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/") + annex.SERVERPATH);
                    }

                    //保存附件(服务器存储路径)
                    Request.Files[index].SaveAs(Server.MapPath("~/") + annex.SERVERPATH + annex.SERVERNAME + annex.EXTENSION);

                    //加入数据库
                    decimal id = bllAnnex.Add(annex);

                    //公文附件示例:12,56,87,96,56
                    resultAnnex += id.ToString() + ",";
                }
            }

            return(resultAnnex);
        }