Ejemplo n.º 1
0
    private List <string> UploadImageBySiteService(byte[] imgData)
    {
        string        uploadConfigSize    = Config.GetString("imageUploadConfigSize");
        List <string> abbreviationsConfig = new List <string>();

        abbreviationsConfig.Add(uploadConfigSize);

        List <string> result = UploadServiceClass.UploadImg(imgData, UploadConfig.UploadConfigName, abbreviationsConfig, "jpg");

        return(result);
    }
Ejemplo n.º 2
0
        public ActionResult SiteContentRecommendEdit()
        {
            //内容ID
            string c_id = Request["c_id"] ?? string.Empty;
            //推荐区块ID
            string b_gid = Request["b_gid"] ?? string.Empty;
            //区块页面ID
            string p_gid = Request["p_gid"] ?? string.Empty;

            VideoInfo fInfo = null;
            Site_CMSItem item = null;
            int existCount = 0;
            int successCount = 0;
            int failCount = 0;
            int result = 0;

            Site_CMSBlock b_info = SiteServiceClass.Site_CMSBlock_SelectByb_gid(b_gid);
            string[] c_idArr = c_id.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < c_idArr.Length; i++)
            {
                fInfo = VideoServiceClass.VideoInfo_SelectById(c_idArr[i].ToInt32());
                item = SiteServiceClass.Site_CMSItem_SelectByc_gidAndb_gid(c_idArr[i], b_gid);
                if (item != null)
                {
                    existCount++;
                    continue;
                }

                item = new Site_CMSItem();
                item.i_b_gid = b_gid;
                item.i_intro = fInfo.v_intro;//
                item.i_createTime = DateTime.Now;
                item.i_createUser = SiteHelp.CurrentUserName;
                item.i_c_gid = fInfo.Id.ToString();//唯一Id
                item.i_c_type = fInfo.v_c_id.ToString();//分类ID
                item.i_gid = Guid.NewGuid().ToString().Substring(0, 8);
                item.i_p_gid = p_gid;
                item.i_status = (int)SiteEnum.SiteItemStatus.待审核;
                item.i_subTitle = fInfo.v_timeLength;//时长
                item.i_title = fInfo.v_titile;
                item.i_c_img_src = string.Empty;

                //图片需要根据该区块设置的图片尺寸,缩放该图片,使用原图来进行缩放
                if (!string.IsNullOrEmpty(b_info.b_img_size.Trim()))
                {
                    if (!string.IsNullOrEmpty(fInfo.v_coverImgSrc))
                    {
                        string sourceSrc = fInfo.v_coverImgSrc;

                        string error;
                        byte[] imgData = SiteUntility.GetRemoteImage(sourceSrc, out error);
                        if (imgData != null)
                        {
                            List<string> srcResult = UploadServiceClass.UploadImg(
                                  imgData,
                                  SiteEnum.SiteUploadConfigName.baseUpload.ToString(),
                                  new List<string>() { b_info.b_img_size },
                                  ".jpg", "s", SiteEnum.SiteService.VideoUploadService
                                  );
                            item.i_c_img_src = srcResult[1];
                        }
                    }
                }

                result = SiteServiceClass.Site_CMSItem_Insert(item);
                if (result > 0)
                {
                    successCount++;
                }
                else
                {
                    failCount++;
                }

            }

            if (c_idArr.Length == 1)
            {
                return Json(new { success = true, errors = new { text = "推荐成功" } });
            }
            else
            {
                return Json(new { success = true, errors = new { text = string.Format("推荐成功{0}条,失败{1}条,重复{2}条", successCount, failCount, existCount) } });

            }
        }