private SpareResourceTypeEntity ReadBind(IDataReader dataReader)
        {
            SpareResourceTypeEntity model = new SpareResourceTypeEntity();

            model.Id        = CommonDBCheck.ToInt(dataReader["id"]);
            model.Name      = CommonDBCheck.ToString(dataReader["name"]);
            model.Directory = CommonDBCheck.ToString(dataReader["directory"]);
            return(model);
        }
        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);
        }
Example #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ResourceDetailEntity model)
 {
     try
     {
         string strSql = AddSql(model);
         return(CommonDBCheck.ToInt(ExecuteScalar(strSql)));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 /// <summary>
 /// 检测该分类是否已经被使用
 /// </summary>
 /// <param name="id"></param>
 /// <returns>true 正在使用</returns>
 public bool IsExit(int id)
 {
     try
     {
         string str = "select count(*) from dbo.t_resource_detail where  type_id='" + id + "'";
         if (CommonDBCheck.ToInt(ExecuteScalar(str)) > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw;
     }
 }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string mode = context.Request["mode"].ToLower();


                ResourceTypeManager typeManager = new ResourceTypeManager();
                //ResourceDetailEntity entity=new ResourceDetailEntity();
                string dir  = context.Request["dir"];
                string name = context.Request["name"];
                string peo  = context.Request["peo"];
                string memo = context.Request["memo"];
                string id   = context.Request["id"];
                ResourceDetailEntity entity = new ResourceDetailEntity();
                entity.Memo = memo;
                entity.Name = name;
                entity.Type = new SpareResourceTypeEntity()
                {
                    Id        = CommonDBCheck.ToInt(dir),
                    Name      = typeManager.GetInfo(CommonDBCheck.ToInt(dir)).Name,
                    Directory = typeManager.GetInfo(CommonDBCheck.ToInt(dir)).Directory
                };

                entity.UploadPeople = peo;
                entity.Url          = ConfigurationSettings.AppSettings["UploadFilePath"];
                entity.insert_user  = entity.update_user = context.Session["user"] as UserEntity;

                switch (mode)
                {
                case "add":
                    context.Response.Write(Add(entity));
                    break;

                case "update":
                    entity.Id = CommonDBCheck.ToInt(id);
                    context.Response.Write(Update(entity));
                    break;
                }
            }
            catch (Exception e)
            {
                context.Response.Write("error");
            }
        }
Example #6
0
        private ResourceDetailEntity ReadBind(IDataReader dataReader)
        {
            ResourceDetailEntity model = new ResourceDetailEntity();

            model.Id   = CommonDBCheck.ToInt(dataReader["id"]);
            model.Name = CommonDBCheck.ToString(dataReader["name"]);
            if (model.Type == null)
            {
                model.Type = new SpareResourceTypeEntity();
            }
            model.Type.Id      = CommonDBCheck.ToInt(dataReader["type_id"]);
            model.Type.Name    = CommonDBCheck.ToString(dataReader["type"]);
            model.Url          = CommonDBCheck.ToString(dataReader["url"]);
            model.Memo         = CommonDBCheck.ToString(dataReader["memo"]);
            model.UploadPeople = CommonDBCheck.ToString(dataReader["upload_people"]);
            return(model);
        }
        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");
            }
        }