示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(EtNet_Models.JobFlowFile model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into JobFlowFile(");
            strSql.Append("filename,fileload,jobflowid,filesize,createtime)");
            strSql.Append(" values (");
            strSql.Append("@filename,@fileload,@jobflowid,@filesize,@createtime)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@filename",   SqlDbType.VarChar,  50),
                new SqlParameter("@fileload",   SqlDbType.VarChar, 200),
                new SqlParameter("@jobflowid",  SqlDbType.Int,       4),
                new SqlParameter("@filesize",   SqlDbType.Int,       4),
                new SqlParameter("@createtime", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.filename;
            parameters[1].Value = model.fileload;
            parameters[2].Value = model.jobflowid;
            parameters[3].Value = model.filesize;
            parameters[4].Value = model.createtime;

            int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 private void DownloadFile()
 {
     if (Request.Params["id"] != null)
     {
         EtNet_Models.JobFlowFile model = EtNet_BLL.JobFlowFileManager.GetModel(int.Parse(Request.Params["id"]));
         if (model != null)
         {
             string path = model.fileload;
             Response.Clear();
             Response.Buffer = false;
             string filename = "";
             if (model.filename.IndexOf('.') != -1)
             {
                 filename = model.filename;
             }
             else
             {
                 filename = model.filename + path.Substring(path.LastIndexOf('.'));
             }
             if (Request.Browser.Browser == "IE")
             {
                 filename = Server.UrlEncode(filename);
             }
             Response.ContentEncoding = System.Text.Encoding.UTF8; //注意编码
             Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
             //设置输出流HttpMiME类型(导出文件格式)
             Response.ContentType = "application/octet-stream"; //image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
             Response.WriteFile(Server.MapPath(path));
         }
     }
 }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static EtNet_Models.JobFlowFile GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from JobFlowFile ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            EtNet_Models.JobFlowFile model = new EtNet_Models.JobFlowFile();
            DataTable tbl = EtNet_DAL.DBHelper.GetDataSet(strSql.ToString(), parameters);

            if (tbl.Rows.Count > 0)
            {
                model.id         = int.Parse(tbl.Rows[0]["id"].ToString());
                model.filename   = tbl.Rows[0]["filename"].ToString();
                model.fileload   = tbl.Rows[0]["fileload"].ToString();
                model.jobflowid  = int.Parse(tbl.Rows[0]["jobflowid"].ToString());
                model.filesize   = int.Parse(tbl.Rows[0]["filesize"].ToString());
                model.createtime = tbl.Rows[0]["createtime"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 删除工作流关联的附件
        /// </summary>
        private void DelJobFile(HttpContext context)
        {
            int fileid = int.Parse(context.Request.Params["fileid"]);

            EtNet_Models.JobFlowFile model = EtNet_BLL.JobFlowFileManager.GetModel(fileid);
            if (model != null)
            {
                //删除服务器上的相应的文件
                File.Delete(context.Server.MapPath(model.fileload));
                EtNet_BLL.JobFlowFileManager.DeleteId(fileid);
                context.Response.Write("删除成功_1");
            }
            else
            {
                context.Response.Write("删除失败_0");
            }
        }
示例#5
0
        /// <summary>
        /// 保存附件的路径
        /// </summary>
        /// <param name="filelist">附件的路径的列表</param>
        /// <param name="jobflowid">工作流的id值</param>
        private void CreateJobFlowFile(string[] filelist, int jobflowid)
        {
            EtNet_Models.JobFlowFile model = null;

            for (int i = 1; i < 6; i++)
            {
                if (filelist[i] != "")
                {
                    model            = new EtNet_Models.JobFlowFile();
                    model.createtime = DateTime.Now.ToString();
                    model.fileload   = filelist[i].Substring(0, filelist[i].IndexOf("|"));
                    model.filesize   = int.Parse(filelist[i].Split('|')[1]);
                    model.filename   = filelist[i].Split('|')[2];
                    model.jobflowid  = jobflowid;
                    EtNet_BLL.JobFlowFileManager.Add(model);
                }
            }
        }
示例#6
0
        /// <summary>
        /// 保存附件的路径
        /// </summary>
        /// <param name="filelist">附件的路径的列表</param>
        /// <param name="jobflowid">工作流的id值</param>
        private void CreateJobFlowFile(string[] filelist, int jobflowid)
        {
            EtNet_Models.JobFlowFile model = null;

            for (int i = 1; i < 6; i++)
            {
                if (filelist[i] != "")
                {
                    model            = new EtNet_Models.JobFlowFile();
                    model.createtime = DateTime.Now.ToString();
                    model.fileload   = filelist[i].Substring(0, filelist[i].IndexOf("|"));
                    int startindex = filelist[i].LastIndexOf("/");
                    int endindex   = filelist[i].LastIndexOf(".");
                    model.filename  = filelist[i].Substring(startindex + 1, endindex - startindex - 1);
                    model.filesize  = int.Parse(filelist[i].Substring(filelist[i].LastIndexOf("|") + 1));
                    model.jobflowid = jobflowid;
                    EtNet_BLL.JobFlowFileManager.Add(model);
                }
            }
        }
示例#7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(EtNet_Models.JobFlowFile model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update JobFlowFile set ");
            strSql.Append("filename=@filename,");
            strSql.Append("fileload=@fileload,");
            strSql.Append("jobflowid=@jobflowid,");
            strSql.Append("filesize=@filesize,");
            strSql.Append("createtime=@createtime");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@filename",   SqlDbType.VarChar,  50),
                new SqlParameter("@fileload",   SqlDbType.VarChar, 200),
                new SqlParameter("@jobflowid",  SqlDbType.Int,       4),
                new SqlParameter("@filesize",   SqlDbType.Int,       4),
                new SqlParameter("@createtime", SqlDbType.VarChar,  50),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.filename;
            parameters[1].Value = model.fileload;
            parameters[2].Value = model.jobflowid;
            parameters[3].Value = model.filesize;
            parameters[4].Value = model.createtime;
            parameters[5].Value = model.id;

            int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static bool Update(EtNet_Models.JobFlowFile model)
 {
     return(EtNet_DAL.JobFlowFileService.Update(model));
 }
示例#9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static bool Add(EtNet_Models.JobFlowFile model)
 {
     return(EtNet_DAL.JobFlowFileService.Add(model));
 }