Example #1
0
        public ActionResult PhotoImport(int id, string path)
        {
            var actDal = new ActDal();
            var act    = actDal.GetModel(id);

            if (act == null)
            {
                return(Json("环节不存在"));
            }

            if (act.Depth != 2)
            {
                return(ReJson(false, "该项目不属于环节"));
            }

            path = Server.MapPath("~/upload/");
            if (!Directory.Exists(path))
            {
                return(ReJson(false, "路径不存在"));
            }

            var folder     = new DirectoryInfo(path);
            var types      = new[] { ".jpg", ".jpeg", ".gif", ".png", ".bmp" };
            var files      = folder.GetFiles().OrderBy(_ => _.Name).ToList();
            int validCount = 0;

            foreach (var file in files)
            {
                if (!types.Contains(file.Extension, StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }

                var stream = file.OpenRead();
                var re     = actDal.UploadPic(stream);
                if (!re.Success)
                {
                    return(ReJson(false, string.Format("照片名为{0}未保存成功,原因{1},可以继续点导入重试", file.Name, re.Info)));
                }

                var photo = new Act {
                    Name = file.Name, ParentFid = id, PhotoUrl = re.Info, Enable = true, OrderIndex = ConvertHelper.StrToInt(file.Name)
                };
                re = actDal.EditAct(photo);
                if (!re.Success)
                {
                    return(ReJson(false, string.Format("照片名为{0}未保存成功,原因{1},可以继续点导入重试", file.Name, re.Info)));
                }
                validCount++;
                stream.Close();
                file.Delete();
            }

            if (validCount == 0)
            {
                return(ReJson(false, "没有文件导入"));
            }

            return(ReJson(false, "全部导入成功"));
        }
Example #2
0
        /// <summary>
        /// 获取照片
        /// </summary>
        /// <param name="fid"></param>
        /// <param name="pn"></param>
        /// <returns></returns>
        public ActionResult Photos(int fid, int pn = 1)
        {
            var act = ActDal.GetModel(fid);

            if (act == null)
            {
                return(Json(null));
            }

            var where = "";
            if (act.Depth == 1)
            {
                where = string.Format("RootFid={0} and Depth=3", fid);
            }
            else
            {
                where = string.Format("ParentFid={0}", fid);
            }

            return(Json(ActDal.GetList(string.Format("Enable=1 and {0}", where), 32, pn, true, "*", "OrderIndex"), JsonRequestBehavior.AllowGet));
        }
Example #3
0
        /// <summary>
        /// 获取环节
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        public ActionResult Steps(int fid)
        {
            var act = ActDal.GetModel(fid);

            if (act == null)
            {
                return(Json(null));
            }

            if (act.Depth == 1)
            {
                fid = act.Id;
            }
            else if (act.Depth == 2)
            {
                fid = act.ParentFid;
            }

            var rootAct = ActDal.GetModel(act.RootFid);

            return(Json(new { steps = ActDal.GetList(string.Format("Enable=1 and ParentFid={0}", fid), 10, 1, true, "*", "OrderIndex"), cover = rootAct == null ? "" : rootAct.PhotoUrl }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
 /// <summary>
 /// 获取照片总数
 /// </summary>
 /// <param name="fid"></param>
 /// <returns></returns>
 public ActionResult PhotosCount(int fid)
 {
     return(Json(ActDal.GetCount(string.Format("Enable=1 and ParentFid={0}", fid)), JsonRequestBehavior.AllowGet));
 }
Example #5
0
 /// <summary>
 /// 获取活动
 /// </summary>
 /// <returns></returns>
 public ActionResult Acts()
 {
     return(Json(ActDal.GetList("Enable=1 and Depth=1", 3, 1, true, "*", "OrderIndex"), JsonRequestBehavior.AllowGet));
 }
Example #6
0
 //查询最新的活动
 public static DataTable newact()
 {
     return(ActDal.newact());
 }
Example #7
0
 //增加活动
 public static int add(ActIvit act)
 {
     return(ActDal.add(act));
 }
Example #8
0
 //更改某个活动
 public static int update(ActIvit act)
 {
     return(ActDal.update(act));
 }
Example #9
0
 //根据ID删除一个活动
 public static int delete(int actid)
 {
     return(ActDal.delete(actid));
 }
Example #10
0
 //根据ID查询一个活动的具体信息
 public static SqlDataReader select(int actid)
 {
     return(ActDal.select(actid));
 }
Example #11
0
 //查询所有活动信息
 public static DataTable allact()
 {
     return(ActDal.allact());
 }