public bool AddLike(AddLike like) { var likes = db.Likes.Include(u => u.UIDs).Where(pid => pid.PostId == like.PostId).FirstOrDefault(); // var users = db.uIDs.Where(l => l.LikeId != null).ToList(); if (likes == null) { Like l = new Like(); l.PostId = like.PostId; UID uID = new UID(); uID.U_ID = like.UserId; l.UIDs.Add(uID); l.TotalCount = 1; return(base.Add(l)); } foreach (var u in likes.UIDs) { if (u.U_ID == like.UserId) { return(false); } } likes.TotalCount = likes.TotalCount + 1; UID ID = new UID(); ID.U_ID = like.UserId; likes.UIDs.Add(ID); return(base.Update(likes)); }
public async Task Handle(AddLike command) { var retrospective = await _store.GetById <Retrospective>(command.RetrospectiveId); retrospective.AddLikeItem(command.Description, command.ParticipantId); await _store.Save(retrospective, retrospective.Version); }
public async Task <IActionResult> CreateLike(Guid retrospectiveId, string participantId, [FromBody] string description) { var retro = await _aggRepo.GetById <Retrospective>(retrospectiveId); var cmd = new AddLike(retrospectiveId, description, participantId); await _cmdSender.Send(cmd); return(RedirectToAction("Get", new { retrospectiveId = retrospectiveId })); }
public IActionResult AddLike(AddLike model) { model.UserId = userService.GetUserId(); bool isLikeAdded = likeManager.AddLike(model); if (isLikeAdded) { return(RedirectToAction("Index", "Posts")); } return(RedirectToAction("Index", "Posts")); }
public bool CreateLike(AddLike model) { var entity = new Like() { Author = _userId, PostId = model.PostId, }; using (var ctx = new ApplicationDbContext()) { ctx.Likes.Add(entity); return(ctx.SaveChanges() == 1); } }
//POST public IHttpActionResult Post(AddLike model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } LikeService service = CreateLikeService(); if (!service.CreateLike(model)) { return(InternalServerError()); } return(Ok()); }
//public string post_text = null; //int post_num=0; // Use this for initialization void Start() { scrollview = GameObject.Find("Scroll View").GetComponent <UIScrollView> (); Loom.RunAsync(() => { var queryP = ParseObject.GetQuery("POST"); queryP.GetAsync(Post_Id).ContinueWith(t => { ParseObject obj = t.Result; PostText = obj["postfield"].ToString(); Loom.QueueOnMainThread(() => { //產出POST GameObject g = (GameObject)Instantiate(Resources.Load("Post")); g.name = "MainPost"; g.transform.parent = GameObject.Find("Scroll View").transform; //得到文字对象 UILabel label = g.GetComponentInChildren <UILabel> (); label.text = PostText; AddLike Like = g.GetComponentInChildren <AddLike> (); Like.Post_Id = Post_Id; AddDislike DisLike = g.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = Post_Id; RetrieveTags Tags = g.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = Post_Id; PostIdSender Sender = g.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = Post_Id; GameObject item = GameObject.Find(g.name); item.transform.localPosition = new Vector3(0, 300, 0); item.transform.localScale = new Vector3(1, 1, 1); scrollview.ResetPosition(); }); }); }); }
void OnClick() { lbl = GetComponentInChildren <UILabel>(); string tag = lbl.text; Debug.Log(tag); scrollview = GameObject.Find("search_view 1").GetComponent <UIScrollView>(); GameObject [] items = GameObject.FindGameObjectsWithTag("Player"); for (var i = 0; i < items.Length; i++) { Destroy(items [i]); } scrollview.ResetPosition(); Loom.RunAsync(() => { ArrayList post_Id = new ArrayList(); var query = ParseObject.GetQuery("POST").WhereEqualTo("Tag1", tag); query.FindAsync().ContinueWith(t => { IEnumerable <ParseObject> results = t.Result; foreach (var objs in results) { string id = objs.ObjectId; Debug.Log("資料庫TAG:" + id); post_Id.Add(id); } var queryT = ParseObject.GetQuery("POST").WhereEqualTo("Tag2", tag); queryT.FindAsync().ContinueWith(t2 => { IEnumerable <ParseObject> result2 = t2.Result; foreach (var obj in result2) { string id2 = obj.ObjectId; post_Id.Add(id2); } var queryY = ParseObject.GetQuery("POST").WhereEqualTo("Tag3", tag); queryT.FindAsync().ContinueWith(t4 => { IEnumerable <ParseObject> result4 = t4.Result; foreach (var ob in result2) { string id3 = ob.ObjectId; post_Id.Add(id3); } for (int ii = 0; ii < post_Id.Count; ii++) { for (int jj = ii + 1; jj < post_Id.Count; jj++) { if (post_Id[ii].Equals(post_Id[jj])) { Debug.Log("del" + post_Id[jj]); post_Id.RemoveAt(jj); jj--; //由于刚刚删除了一个,所以jj要后退一个 } } } ArrayList label_time = new ArrayList(); ArrayList label_list = new ArrayList(); ArrayList post_id = new ArrayList(); ArrayList photo_e = new ArrayList(); ArrayList user = new ArrayList(); ArrayList posttype = new ArrayList(); ArrayList placein = new ArrayList(); var arraypostid = (String[])post_Id.ToArray(typeof(string)); var queryC = ParseObject.GetQuery("POST").WhereContainedIn("objectId", arraypostid); var queryTask = queryC.FindAsync(); IEnumerable <ParseObject> post = queryTask.Result; foreach (var obj1 in post) { string id = obj1.ObjectId; string text1 = obj1["postfield"].ToString(); string post_type = obj1["foo"].ToString(); string usr = obj1["User"].ToString(); string place = obj1["Location"].ToString(); DateTime?updatedAt = obj1.CreatedAt; var imagefile = obj1.Get <ParseFile> ("file"); if (imagefile.Name.Contains("none")) { Debug.Log("none"); photo_e.Add("0"); } else { Debug.Log("have"); photo_e.Add("1"); } string time = updatedAt.ToString(); label_time.Add(time); post_Id.Add(id); label_list.Add(text1); user.Add(usr); posttype.Add(post_type); placein.Add(place); //Debug.Log (updatedAt); } String[] label_text = (String[])label_list.ToArray(typeof(string)); String[] labeltime = (String[])label_time.ToArray(typeof(string)); String[] postId = (String[])post_Id.ToArray(typeof(string)); String[] photo = (String[])photo_e.ToArray(typeof(string)); String[] userId = (String[])user.ToArray(typeof(string)); String[] Posttype = (String[])posttype.ToArray(typeof(string)); String[] place_in = (String[])placein.ToArray(typeof(string)); Loom.QueueOnMainThread(() => { for (i = 0; i < photo.Length; i++) { string type = Posttype[i]; string big = "big_" + type; Debug.Log(big); if (place_in[i] != null) { if (place_in[i] == "Kaohsiung") { place_in[i] = "高雄文"; } else if (place_in[i] == "Taichung") { place_in[i] = "臺中文"; } else if (place_in[i] == "Taipei") { place_in[i] = "臺北文"; } else if (place_in[i] == "NewTaipei") { place_in[i] = "新北文"; } else if (place_in[i] == "Tainan") { place_in[i] = "臺南文"; } else if (place_in[i] == "Taoyuan") { place_in[i] = "桃園文"; } } if (photo[i] == "1") { GameObject o = (GameObject)Instantiate(Resources.Load(big)); //为每个预设设置一个独一无二的名称 o.name = "all" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("search_view 1").transform; UILabel post_text = GameObject.Find("search_view 1/" + o.name + "/PostContent").GetComponent <UILabel>(); //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>(); test1 postid = GameObject.Find("search_view 1/" + o.name + "/photo").GetComponent <test1>(); postid.postid = postId[i]; post_text.text = label_text[i]; UILabel postplace = GameObject.Find("search_view 1/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = place_in[i]; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; ParameterSender PSender = o.GetComponentInChildren <ParameterSender>(); PSender.Post_Id = postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; if (i > 0) { if (photo[i - 1] == "0") { Vector3 temp = new Vector3(0, -0.6f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; //item.transform.position += temp; // Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } else { Vector3 temp = new Vector3(0, -1.3f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; //Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } } else if (i == 0) { Vector3 temp = new Vector3(0, 0, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView //item.transform.position += temp; scrollview.ResetPosition(); count++; } } else { GameObject o = (GameObject)Instantiate(Resources.Load(type)); //为每个预设设置一个独一无二的名称 o.name = "all" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("search_view 1").transform; UILabel post_text = GameObject.Find("search_view 1/" + o.name + "/PostContent").GetComponent <UILabel>(); UILabel postplace = GameObject.Find("search_view 1/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = place_in[i]; //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>(); //test1 postid = GameObject.Find("list View/"+o.name+"/photo").GetComponent<test1>(); //postid.postid =postId[i]; post_text.text = label_text[i]; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; ParameterSender PSender = o.GetComponentInChildren <ParameterSender>(); PSender.Post_Id = postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; if (i > 0) { if (photo[i - 1] == "0") { Vector3 temp = new Vector3(0, -0.57f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; scrollview.ResetPosition(); //Debug.Log(item.transform.position.x+","+item.transform.position.y); count++; } else { Vector3 temp = new Vector3(0, -1.3f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; scrollview.ResetPosition(); //Debug.Log(item.transform.position.x+","+item.transform.position.y); count++; } } else if (i == 0) { Vector3 temp = new Vector3(0, 0, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position += temp; //Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } } } }); }); }); }); }); //}); }
// Update is called once per frame void OnClick() { if (city != null) { if (city == "Kaohsiung") { city_ch = "高雄文"; } else if (city == "Taichung") { city_ch = "臺中文"; } else if (city == "Taipei") { city_ch = "臺北文"; } else if (city == "NewTaipei") { city_ch = "新北文"; } else if (city == "Tainan") { city_ch = "臺南文"; } else if (city == "Taoyuan") { city_ch = "桃園文"; } } GameObject loca = GameObject.Find("place(Clone)"); Destroy(loca); //通过标签名称找到多有对象,前提是给预设起一个tag,这里我叫它player GameObject [] items = GameObject.FindGameObjectsWithTag("Player"); //当预设数量大于 0时 //删除列表的item for (var i = 0; i < items.Length; i++) { Destroy(items[i]); } if (exist == "exist") { GameObject location = (GameObject)Instantiate(Resources.Load("place")); location.transform.parent = GameObject.Find("location").transform; location.transform.localPosition = new Vector3(0, 0, 0); location.transform.localScale = new Vector3(1, 1, 1); location.AddComponent <allpost_loca>(); //xml_test geo = GameObject.Find("city_now").GetComponent<xml_test>(); allpost_loca PostType1 = location.GetComponent <allpost_loca> (); PostType1.city = city; } scrollview.ResetPosition(); Loom.RunAsync(() => { ArrayList label_time = new ArrayList(); ArrayList label_list = new ArrayList(); ArrayList post_Id = new ArrayList(); ArrayList photo_e = new ArrayList(); ArrayList user = new ArrayList(); ArrayList posttype = new ArrayList(); var query = ParseObject.GetQuery("POST").WhereEqualTo("Location", city).WhereDoesNotExist("Post_Geo").OrderByDescending("Sum"); //query = query.Limit(limit); var queryTask = query.FindAsync(); IEnumerable <ParseObject> post = queryTask.Result; foreach (var obj in post) { string id = obj.ObjectId; string text = obj ["postfield"].ToString(); string post_type = obj ["foo"].ToString(); string usr = obj["User"].ToString(); DateTime?updatedAt = obj.CreatedAt; int sum = obj.Get <int> ("Sum"); Debug.Log("資料庫TAG:" + sum); var imagefile = obj.Get <ParseFile> ("file"); if (imagefile.Name.Contains("none")) { Debug.Log("none"); photo_e.Add("0"); } else { Debug.Log("have"); photo_e.Add("1"); } string time = updatedAt.ToString(); label_time.Add(time); post_Id.Add(id); label_list.Add(text); user.Add(usr); posttype.Add(post_type); //Debug.Log (updatedAt); Debug.Log("資料庫傳回:" + text); } String[] label_text = (String[])label_list.ToArray(typeof(string)); String[] labeltime = (String[])label_time.ToArray(typeof(string)); String[] postId = (String[])post_Id.ToArray(typeof(string)); String[] photo = (String[])photo_e.ToArray(typeof(string)); String[] userId = (String[])user.ToArray(typeof(string)); String[] Posttype = (String[])posttype.ToArray(typeof(string)); Loom.QueueOnMainThread(() => { for (i = 0; i < photo.Length; i++) { string type = Posttype[i]; string big = "big_" + type; Debug.Log(big); if (photo[i] == "1") { GameObject o = (GameObject)Instantiate(Resources.Load(big)); //为每个预设设置一个独一无二的名称 o.name = "all" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("list View").transform; UILabel post_text = GameObject.Find("list View/" + o.name + "/PostContent").GetComponent <UILabel>(); //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>(); test1 postid = GameObject.Find("list View/" + o.name + "/photo").GetComponent <test1>(); postid.postid = postId[i]; post_text.text = label_text[i]; UILabel postplace = GameObject.Find("list View/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = city_ch; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; ParameterSender PSender = o.GetComponentInChildren <ParameterSender>(); PSender.Post_Id = postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; if (i > 0) { if (photo[i - 1] == "0") { Vector3 temp = new Vector3(0, -0.95f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; //item.transform.position += temp; // Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } else { Vector3 temp = new Vector3(0, -1.3f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; //Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } } else if (i == 0) { Vector3 temp = new Vector3(0, 0, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView //item.transform.position += temp; scrollview.ResetPosition(); count++; } } else { GameObject o = (GameObject)Instantiate(Resources.Load(type)); //为每个预设设置一个独一无二的名称 o.name = "all" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("list View").transform; UILabel post_text = GameObject.Find("list View/" + o.name + "/PostContent").GetComponent <UILabel>(); UILabel postplace = GameObject.Find("list View/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = city_ch; //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>(); //test1 postid = GameObject.Find("list View/"+o.name+"/photo").GetComponent<test1>(); //postid.postid =postId[i]; post_text.text = label_text[i]; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; ParameterSender PSender = o.GetComponentInChildren <ParameterSender>(); PSender.Post_Id = postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; if (i > 0) { if (photo[i - 1] == "0") { Vector3 temp = new Vector3(0, -0.57f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; scrollview.ResetPosition(); //Debug.Log(item.transform.position.x+","+item.transform.position.y); count++; } else { Vector3 temp = new Vector3(0, -0.95f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; scrollview.ResetPosition(); //Debug.Log(item.transform.position.x+","+item.transform.position.y); count++; } } else if (i == 0) { Vector3 temp = new Vector3(0, 0, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position += temp; //Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } } } }); }); }
public bool AddLike(AddLike like) { return(likeRepository.AddLike(like)); }
void Run() { UIScrollView scrollview = GameObject.Find("Post_view").GetComponent <UIScrollView>(); Loom.RunAsync(() => { ArrayList post_content = new ArrayList(); ArrayList post_type = new ArrayList(); ArrayList postID = new ArrayList(); ArrayList user = new ArrayList(); var query = ParseObject.GetQuery("POST").WhereEqualTo("User", ParseUser.CurrentUser.Username).OrderByDescending("creatAt").Limit(5); query.FindAsync().ContinueWith(t => { IEnumerable <ParseObject> result = t.Result; foreach (var ob in result) { string id = ob.ObjectId; string post_text = ob ["postfield"].ToString(); string type = ob ["foo"].ToString(); string usr = ob["User"].ToString(); post_content.Add(post_text); post_type.Add(type); postID.Add(id); user.Add(usr); } String[] postcontent = (String[])post_content.ToArray(typeof(string)); String[] posttype = (String[])post_type.ToArray(typeof(string)); String[] postId = (String[])postID.ToArray(typeof(string)); String[] userId = (String[])user.ToArray(typeof(string)); Loom.QueueOnMainThread(() => { for (int i = 0; i < posttype.Length; i++) { if (posttype [i] == "q") { GameObject o = (GameObject)Instantiate(Resources.Load("q")); //为每个预设设置一个独一无二的名称 o.name = "q" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("Post_view").transform; GameObject res = o.transform.FindChild("response").gameObject; res.SetActive(false); //得到文字对象 UILabel postplace = GameObject.Find("Post_view/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = city_ch; UILabel label = o.GetComponentInChildren <UILabel> (); //修改文字内容 label.text = postcontent [i]; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; //ParameterSender PSender=o.GetComponentInChildren<ParameterSender>(); //PSender.Post_Id=postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; Vector3 temp = new Vector3(0, -0.46f * count, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 300, 0); item.transform.localScale = new Vector3(0.925f, 0.925f, 1); //列表添加后用于刷新listView item.transform.position += temp; scrollview.ResetPosition(); count++; } else if (posttype [i] == "angel") { GameObject o = (GameObject)Instantiate(Resources.Load("angel")); //为每个预设设置一个独一无二的名称 o.name = "angel" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("Post_view").transform; //得到文字对象 UILabel post_text = GameObject.Find("Post_view/" + o.name + "/PostContent").GetComponent <UILabel>(); //修改文字内容 post_text.text = postcontent [i]; GameObject res = o.transform.FindChild("response").gameObject; res.SetActive(false); UILabel postplace = GameObject.Find("Post_view/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = city_ch; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; //ParameterSender PSender=o.GetComponentInChildren<ParameterSender>(); //PSender.Post_Id=postId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto1 = o.GetComponentInChildren <Getuserphoto>(); userphoto1.UserAccount = userId[i]; Vector3 temp = new Vector3(0, -0.46f * count, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 300, 0); item.transform.localScale = new Vector3(0.925f, 0.925f, 1); //列表添加后用于刷新listView item.transform.position += temp; scrollview.ResetPosition(); count++; } else if (posttype [i] == "devil") { GameObject o = (GameObject)Instantiate(Resources.Load("devil")); //为每个预设设置一个独一无二的名称 o.name = "devil" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("Post_view").transform; //得到文字对象 UILabel label = o.GetComponentInChildren <UILabel> (); //修改文字内容 label.text = postcontent [i]; GameObject res = o.transform.FindChild("response").gameObject; res.SetActive(false); UILabel postplace = GameObject.Find("Post_view/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = city_ch; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; //ParameterSender PSender=o.GetComponentInChildren<ParameterSender>(); //PSender.Post_Id=postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; Vector3 temp = new Vector3(0, -0.46f * count, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 300, 0); item.transform.localScale = new Vector3(0.925f, 0.925f, 1); //列表添加后用于刷新listView item.transform.position += temp; scrollview.ResetPosition(); count++; } else { Debug.Log("error"); } } }); }); }); }
public void OnSubmit() { Debug.Log("2"); // It's a good idea to strip out all symbols as we don't want user input to alter colors, add new lines, etc string text = NGUIText.StripSymbols(mInput.value); if (!string.IsNullOrEmpty(text)) { GameObject [] items = GameObject.FindGameObjectsWithTag("Player"); //当预设数量大于 0时 //删除列表的item for (var i = 0; i < items.Length; i++) { Destroy(items [i]); } //刷新UI scrollview.ResetPosition(); Debug.Log(text); Loom.RunAsync(() => { ArrayList label_time = new ArrayList(); ArrayList label_list = new ArrayList(); ArrayList post_Id = new ArrayList(); ArrayList photo_e = new ArrayList(); ArrayList user = new ArrayList(); ArrayList posttype = new ArrayList(); ArrayList placein = new ArrayList(); var query = ParseObject.GetQuery("POST").WhereContains("postfield", text).OrderByDescending("createdAt"); var queryTask = query.FindAsync(); IEnumerable <ParseObject> post = queryTask.Result; foreach (var obj in post) { string id = obj.ObjectId; string text1 = obj ["postfield"].ToString(); string post_type = obj ["foo"].ToString(); string usr = obj["User"].ToString(); string place = obj["Location"].ToString(); DateTime?updatedAt = obj.CreatedAt; var imagefile = obj.Get <ParseFile> ("file"); if (imagefile.Name.Contains("none")) { Debug.Log("none"); photo_e.Add("0"); } else { Debug.Log("have"); photo_e.Add("1"); } string time = updatedAt.ToString(); label_time.Add(time); post_Id.Add(id); label_list.Add(text1); user.Add(usr); posttype.Add(post_type); placein.Add(place); //Debug.Log (updatedAt); Debug.Log("資料庫傳回:" + text); } String[] label_text = (String[])label_list.ToArray(typeof(string)); String[] labeltime = (String[])label_time.ToArray(typeof(string)); String[] postId = (String[])post_Id.ToArray(typeof(string)); String[] photo = (String[])photo_e.ToArray(typeof(string)); String[] userId = (String[])user.ToArray(typeof(string)); String[] Posttype = (String[])posttype.ToArray(typeof(string)); String[] place_in = (String[])placein.ToArray(typeof(string)); Loom.QueueOnMainThread(() => { for (i = 0; i < photo.Length; i++) { string type = Posttype[i]; string big = "big_" + type; Debug.Log(big); if (place_in[i] != null) { if (place_in[i] == "Kaohsiung") { place_in[i] = "高雄文"; } else if (place_in[i] == "Taichung") { place_in[i] = "臺中文"; } else if (place_in[i] == "Taipei") { place_in[i] = "臺北文"; } else if (place_in[i] == "NewTaipei") { place_in[i] = "新北文"; } else if (place_in[i] == "Tainan") { place_in[i] = "臺南文"; } else if (place_in[i] == "Taoyuan") { place_in[i] = "桃園文"; } } if (photo[i] == "1") { GameObject o = (GameObject)Instantiate(Resources.Load(big)); //为每个预设设置一个独一无二的名称 o.name = "all" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("search_view").transform; UILabel post_text = GameObject.Find("search_view/" + o.name + "/PostContent").GetComponent <UILabel>(); //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>(); test1 postid = GameObject.Find("search_view/" + o.name + "/photo").GetComponent <test1>(); postid.postid = postId[i]; post_text.text = label_text[i]; UILabel postplace = GameObject.Find("search_view/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = place_in[i]; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; ParameterSender PSender = o.GetComponentInChildren <ParameterSender>(); PSender.Post_Id = postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; if (i > 0) { if (photo[i - 1] == "0") { Vector3 temp = new Vector3(0, -0.6f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; //item.transform.position += temp; // Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } else { Vector3 temp = new Vector3(0, -1.3f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; //Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } } else if (i == 0) { Vector3 temp = new Vector3(0, 0, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView //item.transform.position += temp; scrollview.ResetPosition(); count++; } } else { GameObject o = (GameObject)Instantiate(Resources.Load(type)); //为每个预设设置一个独一无二的名称 o.name = "all" + count; //将新预设放在Panel对象下面 o.transform.parent = GameObject.Find("search_view").transform; UILabel post_text = GameObject.Find("search_view/" + o.name + "/PostContent").GetComponent <UILabel>(); UILabel postplace = GameObject.Find("search_view/" + o.name + "/post_place").GetComponent <UILabel>(); postplace.text = place_in[i]; //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>(); //test1 postid = GameObject.Find("list View/"+o.name+"/photo").GetComponent<test1>(); //postid.postid =postId[i]; post_text.text = label_text[i]; AddLike Like = o.GetComponentInChildren <AddLike> (); Like.Post_Id = postId[i]; AddDislike DisLike = o.GetComponentInChildren <AddDislike>(); DisLike.Post_Id = postId[i]; RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>(); Tags.Post_Id = postId[i]; PostIdSender Sender = o.GetComponentInChildren <PostIdSender>(); Sender.Post_Id = postId[i]; ParameterSender PSender = o.GetComponentInChildren <ParameterSender>(); PSender.Post_Id = postId[i]; GetPoster poster = o.GetComponentInChildren <GetPoster>(); poster.UserAccount = userId[i]; Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>(); userphoto.UserAccount = userId[i]; if (i > 0) { if (photo[i - 1] == "0") { Vector3 temp = new Vector3(0, -0.57f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; scrollview.ResetPosition(); //Debug.Log(item.transform.position.x+","+item.transform.position.y); count++; } else { Vector3 temp = new Vector3(0, -1.3f, 0); GameObject item = GameObject.Find(o.name); int ex_position = count - 1; //o.name="Q_list"+ex_position; GameObject ex_item = GameObject.Find("all" + ex_position); Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position = ex_item.transform.position + temp; scrollview.ResetPosition(); //Debug.Log(item.transform.position.x+","+item.transform.position.y); count++; } } else if (i == 0) { Vector3 temp = new Vector3(0, 0, 0); GameObject item = GameObject.Find(o.name); item.transform.localPosition = new Vector3(0, 0, 0); item.transform.localScale = new Vector3(1, 1, 1); //列表添加后用于刷新listView item.transform.position += temp; //Debug.Log(item.transform.position.x+","+item.transform.position.y); scrollview.ResetPosition(); count++; } } } }); }); //}); //mInput.value = ""; mInput.isSelected = false; } }
/// <summary> /// 新增點讚數 /// </summary> /// <param name="data"> 封包資料 </param> /// <returns> 結果 </returns> public string OnAddLike(string data) { string ret = ""; AddLike packet = JsonConvert.DeserializeObject <AddLike>(data); AddLikeResult rData = new AddLikeResult(); PostInfo post = null; try { post = GetSql().Queryable <PostInfo>().With(SqlSugar.SqlWith.RowLock).Where(it => it.PostID == packet.PostID).Single(); //貼文存在 if (post != null) { JArray jsData = JArray.Parse(post.LikeList); List <string> likeList = jsData.ToObject <List <string> >(); if (!likeList.Contains(packet.MemberID)) { likeList.Add(packet.MemberID); JArray jsNew = JArray.FromObject(likeList); // 設定DB 交易的起始點 GetSql().BeginTran(); if (GetSql().Updateable <PostInfo>().SetColumns(it => new PostInfo() { LikeList = jsNew.ToString() }).With(SqlSugar.SqlWith.RowLock).Where(it => it.PostID == packet.PostID).ExecuteCommand() > 0) { rData.Result = (int)AddLikeResult.ResultDefine.emResult_Success; post.LikeList = jsNew.ToString(); SaveLog($"[Info] MessageFcunction::OnAddLike Update Post:{packet.PostID} Like Success"); } else { rData.Result = (int)AddLikeResult.ResultDefine.emResult_Fail; SaveLog($"[Info] MessageFcunction::OnAddLike Update Post:{packet.PostID} Like Fail"); } } else { rData.Result = (int)AddLikeResult.ResultDefine.emResult_Fail; } } else { rData.Result = (int)AddLikeResult.ResultDefine.emResult_Fail; SaveLog($"[Info] MessageFcunction::OnAddLike Can Not Find Post:{packet.PostID}"); } } catch (Exception ex) { rData.Result = (int)AddLikeResult.ResultDefine.emResult_Fail; SaveLog($"[Error] MessageFcunction::OnAddLike Catch Error Msg:{ex.Message}"); } if (rData.Result == (int)AddLikeResult.ResultDefine.emResult_Success) { // DB 交易提交 GetSql().CommitTran(); // 更新Redis 會員貼文 { JObject jsNewPost = new JObject(); jsNewPost.Add("MemberID", post.MemberID); jsNewPost.Add("CreateDate", post.CreateDate); jsNewPost.Add("Place", post.Place); jsNewPost.Add("Photo", post.Photo); jsNewPost.Add("Content", post.Content); jsNewPost.Add("LikeList", post.LikeList); GetRedis((int)Connect.RedisDB.emRedisDB_Post).StringSet($"PostInfo_" + post.PostID, jsNewPost.ToString()); } } else { // DB 交易失敗, 啟動Rollback GetSql().RollbackTran(); } JObject jsMain = new JObject(); jsMain.Add("CmdID", (int)S2C_CmdID.emAddLikeResult); jsMain.Add("Data", JsonConvert.DeserializeObject <JObject>(JsonConvert.SerializeObject(rData))); ret = jsMain.ToString(); return(ret); }