Example #1
0
        public void ModifyPhoto(PhotoObj photoObj)
        {
            using (helper = new SqlHelper())
            {
                helper.BeginTran();

                helper.AddIntParameter("@PhotoID", photoObj.PhotoID);
                helper.AddStringParameter("@Pic", 500, photoObj.Pic);
                helper.AddStringParameter("@Name", 500, photoObj.Name);
                helper.AddTextParameter("@Info", photoObj.Info);

                helper.ExecuteNonQuery("update Photos set Pic=@Pic,Name=@Name,Info=@Info where PhotoID=@PhotoID", CommandType.Text);

                helper.ExecuteNonQuery("delete from LPhotoCate where PhotoID=@PhotoID", CommandType.Text);

                for (int i = 0; i < photoObj.Categories.Count; i++)
                {
                    helper.ClearParameters();
                    helper.AddIntParameter("@PhotoID", photoObj.PhotoID);
                    helper.AddIntParameter("@CategoryID", photoObj.Categories[i]);
                    helper.ExecuteNonQuery("insert into LPhotoCate (PhotoID,CategoryID) values (@PhotoID,@CategoryID)", CommandType.Text);
                }

                helper.CommitTran();
            }
        }
Example #2
0
        public void AddPhoto(PhotoObj photoObj)
        {
            using (helper = new SqlHelper())
            {
                helper.BeginTran();

                var id = helper.AddOutputParameter("@PhotoID");

                helper.AddStringParameter("@Pic", 500, photoObj.Pic);
                helper.AddStringParameter("@Name", 500, photoObj.Name);
                helper.AddTextParameter("@Info", photoObj.Info);

                helper.ExecuteNonQuery("insert into Photos (Pic,Name,Info) values (@Pic,@Name,@Info) select @PhotoID=@@IDENTITY", CommandType.Text);
                photoObj.PhotoID = (int)id.Value;

                for (int i = 0; i < photoObj.Categories.Count; i++)
                {
                    helper.ClearParameters();
                    helper.AddIntParameter("@PhotoID", photoObj.PhotoID);
                    helper.AddIntParameter("@CategoryID", photoObj.Categories[i]);
                    helper.ExecuteNonQuery("insert into LPhotoCate (PhotoID,CategoryID) values (@PhotoID,@CategoryID)", CommandType.Text);
                }

                helper.CommitTran();
            }
        }
Example #3
0
        public ActionResult GetPhotoByID()
        {
            Validation vld      = new Validation();
            int        photoID  = vld.GetInt("id", false, "请传入照片编号");
            PhotoBLL   photoBLL = new PhotoBLL();
            PhotoObj   photoObj = photoBLL.GetPhotoByID(photoID);

            return(Json(new { success = true, data = photoObj }));
        }
Example #4
0
    void SendPictureToServer(string photo)
    {
        //socketService = WebManager.Instance.socket;
        PhotoObj requestObj = new PhotoObj(photo);

        WebManager.Instance.Emit(EventConfig.AR_PHOTO, JsonUtility.ToJson(requestObj));
        //停止拍摄
        webcamTexture.Stop();
        //返回场景
        GlobalManager.LoadScene("WorkFlow");
    }
Example #5
0
 public PhotoObj GetPhotoByID(int photoID)
 {
     using (helper = new SqlHelper())
     {
         helper.AddIntParameter("@PhotoID", photoID);
         PhotoObj      photoObj;
         SqlDataReader dr;
         using (dr = helper.ExecuteReader("select Pic,Name,Info from Photos where PhotoID=@PhotoID", CommandType.Text))
         {
             if (dr.HasRows && dr.Read())
             {
                 photoObj         = new PhotoObj();
                 photoObj.PhotoID = photoID;
                 photoObj.Pic     = dr[0] == DBNull.Value ? null : (string)dr[0];
                 photoObj.Name    = dr[1] == DBNull.Value ? null : (string)dr[1];
                 photoObj.Info    = dr[2] == DBNull.Value ? null : (string)dr[2];
             }
             else
             {
                 photoObj = null;
             }
         }
         if (photoObj != null)
         {
             using (dr = helper.ExecuteReader("select CategoryID from LPhotoCate where PhotoID=@PhotoID", CommandType.Text))
             {
                 if (dr.HasRows)
                 {
                     photoObj.Categories = new List <int>();
                     while (dr.Read())
                     {
                         photoObj.Categories.Add((int)dr[0]);
                     }
                 }
             }
         }
         return(photoObj);
     }
 }
Example #6
0
        public ActionResult DeletePhoto()
        {
            if (!AppData.IsManagerLogin)
            {
                return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1003))
            {
                return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
            }

            Validation vld      = new Validation();
            int        photoID  = vld.GetInt("id", false, "请传入照片编号");
            PhotoBLL   photoBLL = new PhotoBLL();
            PhotoObj   photoObj = photoBLL.GetPhotoByID(photoID);

            System.IO.File.Delete(Config.MediaPath + photoObj.Pic.Replace("/", "\\"));

            JsonArray points = photoBLL.GetPhotoPoints(photoID);

            if (points != null)
            {
                string pic;
                for (int i = 0; i < points.Count; i++)
                {
                    if (points[i]["Pic"] != null)
                    {
                        pic = (string)points[i]["Pic"];
                        System.IO.File.Delete(Config.MediaPath + pic.Replace("/", "\\"));
                    }
                }
            }

            photoBLL.DeletePhoto(photoID);

            return(Json(new { success = true }));
        }
Example #7
0
 public void ModifyPhoto(PhotoObj photoObj)
 {
     dal.ModifyPhoto(photoObj);
 }
Example #8
0
 public void AddPhoto(PhotoObj photoObj)
 {
     dal.AddPhoto(photoObj);
 }
Example #9
0
        public ActionResult AddPhoto()
        {
            if (Request.HttpMethod == "POST")
            {
                if (!AppData.IsManagerLogin)
                {
                    return(HandleResult(false, "您未登录后台或会话已过期"));
                }
                if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1001))
                {
                    return(HandleResult(false, "您没有执行该操作的权限"));
                }

                Validation vld      = new Validation();
                PhotoObj   photoObj = new PhotoObj();
                photoObj.Name = vld.Get("name", false, "请填写照片名称");
                photoObj.Info = vld.Get("info");
                string      sCategoryIDs = vld.Get("categoryIDs", false, "请至少选择一个类别", regex: @"^\d+(,\d+)*$", regexText: "类别参数错误");
                IList <int> categoryIDs;
                if (string.IsNullOrEmpty(sCategoryIDs))
                {
                    categoryIDs = null;
                }
                else
                {
                    string[] aCategoryIDs = sCategoryIDs.Split(',');
                    categoryIDs = new List <int>();
                    for (int i = 0; i < aCategoryIDs.Length; i++)
                    {
                        categoryIDs.Add(int.Parse(aCategoryIDs[i]));
                    }
                }
                HttpPostedFileBase pic = Request.Files.Count == 0 ? null : Request.Files[0];
                if (pic == null || pic.ContentLength == 0)
                {
                    return(HandleResult(false, "请选择一张照片"));
                }

                if (vld.HasError)
                {
                    return(HandleResult(false, vld.GetError()));
                }

                photoObj.Categories = categoryIDs;

                string ext = Path.GetExtension(pic.FileName);
                if (!Regex.IsMatch(ext, @"^\.(gif|jpg|jpeg|png)$", RegexOptions.IgnoreCase))
                {
                    return(HandleResult(false, "上传的图片格式不合要求,请上传gif,png,jpg格式的图片"));
                }

                string path    = DateTime.Now.ToString("yyyyMMdd");
                string dirPath = Config.MediaPath + @"\Package\" + path;
                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff") + ext;
                string savePath    = Path.Combine(dirPath, newFileName);

                pic.SaveAs(savePath);
                photoObj.Pic = "/Package/" + path + "/" + newFileName;

                PhotoBLL photoBLL = new PhotoBLL();
                photoBLL.AddPhoto(photoObj);

                return(HandleResult(true, photoObj.PhotoID.ToString()));
            }
            else
            {
                if (!AppData.IsManagerLogin)
                {
                    return(Redirect("/Manage/Error/1.html"));
                }
                if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1001))
                {
                    return(Redirect("/Manage/Error/2.html"));
                }

                return(View());
            }
        }