示例#1
0
        /// <summary>
        /// 更新一条是数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private int Update(ResourceDetailEntity info)
        {
            try
            {
                //先删除原来的主表数据
                ResourceDetailManager bll = new ResourceDetailManager();
                bll.Delete(info.Id);
                //增加新的数据到主表
                //bll.Add(info);
                //修改剩余的原来的数据
                ResourceUploadBussiness resourceUpload = new ResourceUploadBussiness();
                DataTable dtUpload = resourceUpload.GetInfosByDetailId(info.Id);
                bll.DeleteUpload(0, info.Id);

                ResourceDetailUploadEntity detailEntity = new ResourceDetailUploadEntity();

                int id = bll.Add(info);
                if (dtUpload != null)
                {
                    foreach (DataRow dataRow in dtUpload.Rows)
                    {
                        detailEntity.Files_name         = CommonDBCheck.ToString(dataRow["files_name"]);
                        detailEntity.FilesDir           = CommonDBCheck.ToString(dataRow["files_dir"]);
                        detailEntity.Resource_detail_id = id;
                        resourceUpload.Add(detailEntity);
                    }
                }
                return(id);
            }
            catch (Exception e)
            {
                throw;
            }
        }
        private ResourceDetailUploadEntity ReadBind(IDataReader dataReader)
        {
            ResourceDetailUploadEntity model = new ResourceDetailUploadEntity();

            model.Id = CommonDBCheck.ToInt(dataReader["id"]);
            model.Resource_detail_id = CommonDBCheck.ToInt(dataReader["resource_detail_id"]);
            model.Files_name         = CommonDBCheck.ToString(dataReader["files_name"]);
            return(model);
        }
示例#3
0
 /// <summary>
 /// 增加数据
 /// </summary>
 /// <param name="entity"></param>
 public void Add(ResourceDetailUploadEntity entity)
 {
     try
     {
         DBResourceUpload db = new DBResourceUpload();
         db.Add(entity);
     }
     catch (Exception e)
     {
         throw;
     }
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(ResourceDetailUploadEntity model)
 {
     try
     {
         string strSql = AddSql(model);
         ExecuteNonQuery(strSql.ToString());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        private string AddSql(ResourceDetailUploadEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" insert into dbo.t_resource_detail_upload(");
            strSql.Append("resource_detail_id,");
            strSql.Append("files_dir,");
            strSql.Append("files_name");
            strSql.Append(")values(");
            strSql.Append("'" + model.Resource_detail_id + "',");
            strSql.Append("'" + model.FilesDir + "',");
            strSql.Append("'" + model.Files_name + "'");
            strSql.Append(")");

            return(strSql.ToString());
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";

            HttpPostedFile file = context.Request.Files["Filedata"];
            string         id   = context.Request["id"];
            string         dir  = context.Request["dir"];
            string         name = context.Request["name"];
            string         peo  = context.Request["peo"];


            ResourceTypeManager typeManager = new ResourceTypeManager();

            string uploadPath = HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["UploadFilePath"] + typeManager.GetInfo(CommonDBCheck.ToInt(dir)).Directory + "/");

            // HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\";

            if (file != null)
            {
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }
                string fileName = file.FileName.Substring(0, file.FileName.IndexOf('.')) + "_" + name + "_" + peo + "_" +
                                  DateTime.Now.ToString("yyyyMMddHHmmssfff") +
                                  file.FileName.Substring(file.FileName.IndexOf('.'), file.FileName.Length - file.FileName.IndexOf('.'));
                file.SaveAs(uploadPath + fileName);
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                ResourceDetailUploadEntity uploadEntity = new ResourceDetailUploadEntity();
                uploadEntity.Resource_detail_id = CommonDBCheck.ToInt(id);
                uploadEntity.Files_name         = fileName;
                uploadEntity.FilesDir           = typeManager.GetInfo(CommonDBCheck.ToInt(dir)).Directory;
                ResourceUploadBussiness uploadBussiness = new ResourceUploadBussiness();
                uploadBussiness.Add(uploadEntity);
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }
        /// <summary>
        /// 通过ID取得数据信息
        /// </summary>
        /// <param name="id"></param>
        public ResourceDetailUploadEntity GetInfo(int id)
        {
            ResourceDetailUploadEntity model = new ResourceDetailUploadEntity();

            try
            {
                string strSql = GetInfoSql(id);
                using (IDataReader dataReader = ExecuteReader(strSql))
                {
                    if (dataReader.Read())
                    {
                        model = ReadBind(dataReader);
                    }
                }
                return(model);
            }
            catch (Exception e)
            {
                throw e;
            }
        }