예제 #1
0
 /// <summary>
 /// 临时图片copy 到正式目录
 /// </summary>
 /// <param name="obj"></param>
 public static void TempToOfficial(this HeadBase obj)
 {
     if (obj.HeadUrl.IsNotNullOrEmpty() && obj.HeadUrl != obj.HeadUrlOld)
     {
         obj.HeadUrl = AnnexHelper.ToValidDirectory(obj.HeadUrl);
     }
 }
예제 #2
0
 /// <summary>
 /// 新建或者修改头像
 /// </summary>
 /// <param name="obj"></param>
 public static void ModifyHeadIcon(this HeadBase obj)
 {
     if (obj.HeadUrl.IsNotNullOrEmpty() && obj.HeadUrl != obj.HeadUrlOld)
     {
         obj.HeadUrl = AnnexHelper.ToValidDirectory(obj.HeadUrl);
     }
 }
예제 #3
0
        /// <summary>
        /// 处理新建附件,并且返回对象集合供更新 (根据MasterType操作)
        /// 逻辑: 将传来的临时URL 转成正式的URL , 并把这些正式的URL和主体(如课程Id)的关系 , 存到 FileInfo表, 这样后面通过课程Id就可以查到他的文件列表了
        /// </summary>
        /// <param name="obj"></param>
        public static List <EntityBase> ModifyFilesByModule(this HeadBase obj, string businessType)
        {
            //删除原来所有附件信息
            var cmd = CommandHelper.CreateText(FetchType.Execute,
                                               text: "DELETE FROM FileInfo WHERE MasterId=@masterId AND MasterType=@masterType");

            cmd.Params.Add("@masterId", obj.Id);
            cmd.Params.Add("@masterType", businessType);

            DbContext.GetInstance().Execute(cmd);

            List <EntityBase> result = new List <EntityBase>();

            foreach (var file in obj.Files)
            {
                if (file.RowState == RowState.Added)
                {
                    //新的文件
                    file.TrySetNewEntity();
                    file.MasterId   = obj.Id;
                    file.MasterType = businessType;
                    file.FilePath   = AnnexHelper.ToValidDirectory(file.FilePath);
                }
                else
                {
                    //以前的文件
                    file.SetRowAdded();
                    file.TrySetNewEntity();
                    file.MasterId   = obj.Id;
                    file.MasterType = businessType;
                }
                result.Add(file);
            }
            return(result);
        }
예제 #4
0
        public Response Execute(string request)
        {
            var      req    = JsonConvert.DeserializeObject <Request <FileInfo> >(request);
            Response result = AnnexHelper.SaveAnnex(req.Entities);

            result.Entities.AddRange(req.Entities);

            return(result);
        }
예제 #5
0
 public static void PrepareAnnex(List <YDL.Model.FileInfo> files)
 {
     foreach (var annex in files)
     {
         if (annex.RowState == RowState.Added)
         {
             annex.FilePath = AnnexHelper.ToValidDirectory(annex.FilePath);
             annex.SetNewId();
             annex.SetCreateDate();
         }
     }
 }
예제 #6
0
        public static void SaveIdCardImage(Coach obj)
        {
            if (obj.IdCardFrontUrl.IsNotNullOrEmpty())
            {
                obj.IdCardFrontUrl = AnnexHelper.ToValidDirectory(obj.IdCardFrontUrl);
            }

            if (obj.IdCardBackUrl.IsNotNullOrEmpty())
            {
                obj.IdCardBackUrl = AnnexHelper.ToValidDirectory(obj.IdCardBackUrl);
            }
        }
예제 #7
0
        public Response UpdateHeadUrl(string HeadUrl, string Id)
        {
            HeadUrl = AnnexHelper.ToValidDirectory(HeadUrl);
            var sql = @"UPDATE dbo.UserAccount SET HeadUrl=@HeadUrl WHERE  Id=@Id";
            var cmd = CommandHelper.CreateText <ClubUser>(FetchType.Execute, sql);

            cmd.Params.Add("@HeadUrl", HeadUrl);
            cmd.Params.Add("@Id", Id);

            var result = DbContext.GetInstance().Execute(cmd);

            return(result);
        }
예제 #8
0
        /// <summary>
        /// 获取附件列表
        /// </summary>
        /// <param name="request">包含AnnexInfo对象,设置属性值MasterId</param>
        /// <returns></returns>
        public Response Execute(string request)
        {
            var req = JsonConvert.DeserializeObject <Request <FileInfo> >(request);

            return(AnnexHelper.GetAnnexList(req.Filter.MasterId));
        }