Esempio n. 1
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for (int i = 0; i < testItems; i++)
     {
         UploadConfig item = new UploadConfig();
         _testRepo._items.Add(item);
     }
 }
Esempio n. 2
0
 public override bool Equals(object obj)
 {
     if (obj.GetType() == typeof(UploadConfig))
     {
         UploadConfig compare = (UploadConfig)obj;
         return(compare.KeyValue() == this.KeyValue());
     }
     else
     {
         return(base.Equals(obj));
     }
 }
Esempio n. 3
0
        public static UploadConfig SingleOrDefault(Expression <Func <UploadConfig, bool> > expression, string connectionString, string providerName)
        {
            var          repo    = GetRepo(connectionString, providerName);
            var          results = repo.Find(expression);
            UploadConfig single  = null;

            if (results.Count() > 0)
            {
                single = results.ToList()[0];
            }

            return(single);
        }
Esempio n. 4
0
        public static UploadConfig SingleOrDefault(Expression <Func <UploadConfig, bool> > expression)
        {
            var          repo    = GetRepo();
            var          results = repo.Find(expression);
            UploadConfig single  = null;

            if (results.Count() > 0)
            {
                single = results.ToList()[0];
                single.OnLoaded();
                single.SetIsLoaded(true);
                single.SetIsNew(false);
            }

            return(single);
        }
Esempio n. 5
0
 void Init()
 {
     TestMode      = this._db.DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase);
     _dirtyColumns = new List <IColumn>();
     if (TestMode)
     {
         UploadConfig.SetTestRepo();
         _repo = _testRepo;
     }
     else
     {
         _repo = new SubSonicRepository <UploadConfig>(_db);
     }
     tbl = _repo.GetTable();
     SetIsNew(true);
     OnCreated();
 }
Esempio n. 6
0
        internal static IRepository <UploadConfig> GetRepo(string connectionString, string providerName)
        {
            Solution.DataAccess.DataModel.SolutionDataBaseDB db;
            if (String.IsNullOrEmpty(connectionString))
            {
                db = new Solution.DataAccess.DataModel.SolutionDataBaseDB();
            }
            else
            {
                db = new Solution.DataAccess.DataModel.SolutionDataBaseDB(connectionString, providerName);
            }
            IRepository <UploadConfig> _repo;

            if (db.TestMode)
            {
                UploadConfig.SetTestRepo();
                _repo = _testRepo;
            }
            else
            {
                _repo = new SubSonicRepository <UploadConfig>(db);
            }
            return(_repo);
        }
Esempio n. 7
0
        /// <summary>
        /// 将UploadConfig记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.UploadConfig)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.UploadConfig</returns>
        public DataAccess.Model.UploadConfig Transform(UploadConfig model)
        {
            if (model == null)
                return null;

            return new DataAccess.Model.UploadConfig
            {
                Id = model.Id,
                Name = model.Name,
                JoinName = model.JoinName,
                UserType = model.UserType,
                UploadType_Id = model.UploadType_Id,
                UploadType_Name = model.UploadType_Name,
                UploadType_TypeKey = model.UploadType_TypeKey,
                PicSize = model.PicSize,
                FileSize = model.FileSize,
                SaveDir = model.SaveDir,
                IsPost = model.IsPost,
                IsSwf = model.IsSwf,
                IsChkSrcPost = model.IsChkSrcPost,
                IsFixPic = model.IsFixPic,
                CutType = model.CutType,
                PicWidth = model.PicWidth,
                PicHeight = model.PicHeight,
                PicQuality = model.PicQuality,
                IsEditor = model.IsEditor,
                IsBigPic = model.IsBigPic,
                BigWidth = model.BigWidth,
                BigHeight = model.BigHeight,
                BigQuality = model.BigQuality,
                IsMidPic = model.IsMidPic,
                MidWidth = model.MidWidth,
                MidHeight = model.MidHeight,
                MidQuality = model.MidQuality,
                IsMinPic = model.IsMinPic,
                MinWidth = model.MinWidth,
                MinHeight = model.MinHeight,
                MinQuality = model.MinQuality,
                IsHotPic = model.IsHotPic,
                HotWidth = model.HotWidth,
                HotHeight = model.HotHeight,
                HotQuality = model.HotQuality,
                IsWaterPic = model.IsWaterPic,
                Manager_Id = model.Manager_Id,
                Manager_CName = model.Manager_CName,
                UpdateDate = model.UpdateDate,
            };
        }
Esempio n. 8
0
 /// <summary>
 /// 更新IIS缓存中指定Id记录
 /// </summary>
 /// <param name="model">记录实体</param>
 public void SetModelForCache(UploadConfig model)
 {
     SetModelForCache(Transform(model));
 }
Esempio n. 9
0
        /// <summary>
        /// 添加与编辑UploadConfig记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">UploadConfig表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, UploadConfig model, string content = null, bool isCache = true, bool isAddUseLog = true)
        {
            try {
                //保存
                model.Save();

                //判断是否启用缓存
                if (CommonBll.IsUseCache() && isCache)
                {
                    SetModelForCache(model);
                }

                if (isAddUseLog)
                {
                    if (string.IsNullOrEmpty(content))
                    {
                        content = "{0}" + (model.Id == 0 ? "添加" : "编辑") + "UploadConfig记录成功,ID为【" + model.Id + "】";
                    }

                    //添加用户访问记录
                    UseLogBll.GetInstence().Save(page, content);
                }
            }
            catch (Exception e) {
                var result = "执行UploadConfigBll.Save()函数出错!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;
            int id = ConvertHelper.Cint0(hidId.Text);

            try
            {
                #region 数据验证

                if (string.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    return txtName.Label + "不能为空!";
                }
                var sName = StringHelper.Left(txtName.Text, 20);
                if (UploadConfigBll.GetInstence().Exist(x => x.Name == sName && x.Id != id))
                {
                    return txtName.Label + "已存在!请重新输入!";
                }
                if (string.IsNullOrEmpty(txtJoinName.Text.Trim()))
                {
                    return txtJoinName.Label + "不能为空!";
                }
                if (ddlUploadTypeId.SelectedValue == "0")
                {
                    return ddlUploadTypeId.Label + "为必选项,请选择后再保存!";
                }
                if (string.IsNullOrEmpty(txtPicSize.Text.Trim()))
                {
                    return txtPicSize.Label + "不能为空!";
                }
                if (string.IsNullOrEmpty(txtFileSize.Text.Trim()))
                {
                    return txtFileSize.Label + "不能为空!";
                }
                if (string.IsNullOrEmpty(txtSaveDir.Text.Trim()))
                {
                    return txtSaveDir.Label + "不能为空!";
                }
                #endregion

                #region 赋值
                //获取实体
                var model = new UploadConfig(x => x.Id == id);

                model.Name = sName;
                model.JoinName = StringHelper.Left(txtJoinName.Text, 30);
                model.UserType = (byte)ConvertHelper.Cint1(rblUserType.SelectedValue);
                //读取上传类型
                model.UploadType_Id = ConvertHelper.Cint0(ddlUploadTypeId.SelectedValue);
                var uploadTypeModel = UploadTypeBll.GetInstence().GetModelForCache(model.UploadType_Id);
                if (uploadTypeModel != null)
                {
                    model.UploadType_Name = uploadTypeModel.Name;
                    model.UploadType_TypeKey = uploadTypeModel.TypeKey;
                }

                //上传限制
                model.PicSize = ConvertHelper.Cint0(txtPicSize.Text);
                model.FileSize = ConvertHelper.Cint0(txtFileSize.Text);

                model.SaveDir = StringHelper.Left(txtSaveDir.Text, 50);
                model.IsPost = ConvertHelper.Ctinyint(rblIsPost.SelectedValue);
                model.IsEditor = ConvertHelper.Ctinyint(rblIsEditor.SelectedValue);
                model.IsSwf = ConvertHelper.Ctinyint(rblIsSwf.SelectedValue);
                model.IsChkSrcPost = ConvertHelper.Ctinyint(brlIsChkSrcPost.SelectedValue);

                //按比例生成
                model.IsFixPic = ConvertHelper.Ctinyint(rblIsFixPic.SelectedValue);
                model.CutType = ConvertHelper.Cint0(ddlCutType.SelectedValue);
                model.PicWidth = ConvertHelper.Cint0(txtPicWidth.Text);
                model.PicHeight = ConvertHelper.Cint0(txtPicHeight.Text);
                model.PicQuality = ConvertHelper.Cint0(txtPicQuality.Text);

                //大图
                model.IsBigPic = ConvertHelper.Ctinyint(rblIsBigPic.SelectedValue);
                model.BigWidth = ConvertHelper.Cint0(txtBigWidth.Text);
                model.BigHeight = ConvertHelper.Cint0(txtBigHeight.Text);
                model.BigQuality = ConvertHelper.Cint0(txtBigQuality.Text);

                //中图
                model.IsMidPic = ConvertHelper.Ctinyint(rblIsMidPic.SelectedValue);
                model.MidWidth = ConvertHelper.Cint0(txtMidWidth.Text);
                model.MidWidth = ConvertHelper.Cint0(txtMidWidth.Text);
                model.MidHeight = ConvertHelper.Cint0(txtMidHeight.Text);

                //小图
                model.IsMinPic = ConvertHelper.Ctinyint(rblIsMinPic.SelectedValue);
                model.MinWidth = ConvertHelper.Cint0(txtMinWidth.Text);
                model.MinWidth = ConvertHelper.Cint0(txtMinWidth.Text);
                model.MinHeight = ConvertHelper.Cint0(txtMinHeight.Text);

                //推荐图
                model.IsHotPic = ConvertHelper.Ctinyint(rblIsHotPic.SelectedValue);
                model.HotWidth = ConvertHelper.Cint0(txtHotWidth.Text);
                model.HotWidth = ConvertHelper.Cint0(txtHotWidth.Text);
                model.HotHeight = ConvertHelper.Cint0(txtHotHeight.Text);

                //加水印
                model.IsWaterPic = ConvertHelper.Ctinyint(rblIsWaterPic.SelectedValue);

                //修改时间与管理员
                model.UpdateDate = DateTime.Now;
                model.Manager_Id = OnlineUsersBll.GetInstence().GetManagerId();
                model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName();

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                UploadConfigBll.GetInstence().Save(this, model);

            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return result;
        }
Esempio n. 11
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for(int i=0;i<testItems;i++){
         UploadConfig item=new UploadConfig();
         _testRepo._items.Add(item);
     }
 }
Esempio n. 12
0
 public static void Setup(UploadConfig item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Esempio n. 13
0
 public static void Setup(UploadConfig item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Esempio n. 14
0
        /// <summary>根据UploadConfig的单一缩放</summary>
        /// <param name="picImg">图片地址(没有任何扩展后缀,比如后台没有:"b","m","s","b")</param>
        /// <param name="mC">根据vid查得的 UploadConfig配置</param>
        public static void OneMakeThumbImage(string picImg, UploadConfig mC)
        {
            string bigImg = DirFileHelper.GetFilePathPostfix(picImg, "b");
            string midImg = DirFileHelper.GetFilePathPostfix(picImg, "m");
            string minImg = DirFileHelper.GetFilePathPostfix(picImg, "s");
            string hotImg = DirFileHelper.GetFilePathPostfix(picImg, "h");
            string orgImg = DirFileHelper.GetFilePathPostfix(picImg, "o");

            //--------------------------------------------------
            //big
            DirFileHelper.DeleteFile(bigImg);
            if (mC.IsBigPic == 1)
            {
                if (mC.BigWidth > 0 && mC.BigHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, bigImg,
                                   ConvertHelper.Cint0(mC.BigWidth),
                                   ConvertHelper.Cint0(mC.BigHeight),
                                   ConvertHelper.Cint0(mC.BigQuality),
                                   ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, bigImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(bigImg);
                }
            }

            //--------------------------------------------------
            //mid
            DirFileHelper.DeleteFile(midImg);
            if (mC.IsMidPic == 1)
            {
                if (mC.MidWidth > 0 && mC.MidHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, midImg,
                                            ConvertHelper.Cint0(mC.MidWidth),
                                            ConvertHelper.Cint0(mC.MidHeight),
                                            ConvertHelper.Cint0(mC.MidQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, midImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(midImg);
                }
            }

            //--------------------------------------------------
            //hot
            DirFileHelper.DeleteFile(hotImg);
            if (mC.IsHotPic == 1)
            {
                if (mC.HotWidth > 0 && mC.HotHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, hotImg,
                                            ConvertHelper.Cint0(mC.HotWidth),
                                            ConvertHelper.Cint0(mC.HotHeight),
                                            ConvertHelper.Cint0(mC.HotQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, hotImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(hotImg);
                }
            }

            //--------------------------------------------------
            //min
            DirFileHelper.DeleteFile(minImg);
            if (mC.IsMinPic == 1)
            {
                if (mC.IsMinPic > 0 && mC.MinHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, minImg,
                                            ConvertHelper.Cint0(mC.MinWidth),
                                            ConvertHelper.Cint0(mC.MinHeight),
                                            ConvertHelper.Cint0(mC.MinQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, minImg);
                }

                //微型图不用加水印
            }

            //--------------------------------------------------
            //pic
            DirFileHelper.DeleteFile(picImg);
            if (mC.IsFixPic == 1)
            {
                if (mC.PicWidth > 0 && mC.PicHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, picImg,
                                            ConvertHelper.Cint0(mC.PicWidth),
                                            ConvertHelper.Cint0(mC.PicHeight),
                                            ConvertHelper.Cint0(mC.PicQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, picImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(picImg);
                }
            }
        }
Esempio n. 15
0
        /// <summary>生成一条配置记录的图片</summary>
        /// <param name="vid"></param>
        /// <returns></returns>
        public string fix_PicSize(int vid)
        {
            //---------------------------------------------------
            UploadConfig mC = new UploadConfig(x => x.Id == vid);
            if (mC.Id != vid)
            {
                return "缺少参数:Id!";
            }

            StringBuilder sb = new StringBuilder();
            //只修改关联的图片
            //string sql = "select Path from UploadFile where Id=" + vid + " and JoinId>0 order by Id";

            //修改全部图片(包含非关联)
            //string sql = "select Path from UploadFile where UploadConfig_Id=" + vid + " order by Id";

            //定义要查询出来的列
            var list = new List<string>();
            list.Add(UploadFileTable.Path);
            //定义查询条件
            var wheres = new List<ConditionHelper.SqlqueryCondition>();
            wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, UploadFileTable.UploadConfig_Id, Comparison.Equals, vid));
            //定义排序
            var sort = new List<string>();
            sort.Add(UploadFileTable.Id);

            string[] rs1 = DataTableHelper.GetArrayString(GetDataTable(false, 0, list, 0, 0, wheres, sort), UploadFileTable.Path);
            if (rs1 != null && rs1.Length > 0)
            {
                int ti = rs1.Length;
                for (int i = 0; i < ti; i++)
                {
                    string picImg = rs1[i];
                    string sExt = DirFileHelper.GetFileExtension(picImg).ToLower();
                    if (picImg.Length > 4 && (sExt == "jpg" || sExt == "png" || sExt == "gif"))
                    {
                        string orgImg = DirFileHelper.GetFilePathPostfix(picImg, "o");

                        if (!DirFileHelper.IsExistFile(orgImg))
                        {
                            DirFileHelper.CopyFile(picImg, orgImg);
                        }

                        //原始图存在的情况下,才能生成其它size
                        if (DirFileHelper.IsExistFile(orgImg))
                        {
                            OneMakeThumbImage(picImg, mC);
                        }
                        else
                        {
                            sb.AppendFormat("原始文件不存在={0}<br />", picImg);
                        }
                    }
                }
            }
            return sb.ToString();
        }