Exemplo n.º 1
0
    public void SetTag(UserTag tag)
    {
        if (tag == UserTag.None)
        {
            return;
        }

        string text;
        Color  bgColor   = bClolor;
        Color  textColor = Color.white;

        if (tag == UserTag.SmallBlind)
        {
            text = "小盲";
        }
        else if (tag == UserTag.BigBlind)
        {
            text = "大盲";
        }
        else
        {
            text      = "D";
            bgColor   = Color.white;
            textColor = Color.black;
        }

        Tag.SetActive(true);
        Tag.GetComponent <ProceduralImage>().color = bgColor;
        var UText = Tag.transform.Find("Text").GetComponent <Text>();

        UText.text  = text;
        UText.color = textColor;
    }
Exemplo n.º 2
0
        public async Task <IActionResult> PutUserTag(int id, UserTag userTag)
        {
            if (id != userTag.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(userTag).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserTagExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public void RemoveTag(int tagID, int customerID)
        {
            Customer customer = _repository.Load <Customer>(customerID);

            if (customer == null)
            {
                throw new TagServicesException("Customer not found");
            }

            UserTag tag = _repository.Get <UserTag>(tagID);

            if (tag == null)
            {
                throw new TagServicesException("Tag not found");
            }

            customer.Tags.Remove(tag);

            using (TransactionScope scope = new TransactionScope())
            {
                _repository.Update(customer);
                _repository.Flush();
                scope.Complete();
            }
        }
Exemplo n.º 4
0
        public async Task CreateUserTagAsync(Guid tagId)
        {
            Tag tag = await _tagRepository.Select.Where(r => r.Id == tagId).ToOneAsync();

            if (tag == null)
            {
                throw new LinCmsException("该标签不存在");
            }

            if (!tag.Status)
            {
                throw new LinCmsException("该标签已被拉黑");
            }

            bool any = await _userTagRepository.Select.AnyAsync(r =>
                                                                r.CreateUserId == CurrentUser.Id && r.TagId == tagId);

            if (any)
            {
                throw new LinCmsException("您已关注该标签");
            }

            UserTag userTag = new UserTag()
            {
                TagId = tagId
            };
            await _userTagRepository.InsertAsync(userTag);

            await _tagService.UpdateSubscribersCountAsync(tagId, 1);
        }
        public ActionResult EditUserTag(UserTag userTag)
        {
            db.UserTags.FirstOrDefault(u => u.Id == userTag.Id).UserName = userTag.UserName;
            db.SaveChanges();

            return(RedirectToAction("Watch", "Videos", new { id = userTag.VideoId }));
        }
Exemplo n.º 6
0
        /// <summary>
        /// the method that will check if the user has the selected tag
        /// </summary>
        /// <param name="id">the tag id</param>
        /// <returns>returns true if the user has the selected tag</returns>
        public bool UserHasTag(int id)
        {
            // gets current user id
            string userID = User.Identity.GetUserId();

            //creates the tag to be added/removed
            UserTag ut = new UserTag();

            ut.TagID  = id;
            ut.UserID = userID;

            // gets all the users with the current tag
            IList <string> userTags = (from tag in db.UsersTags where (tag.TagID == id) select tag.UserID).ToList();

            // if it doesnt exit any user with that tag
            if (!userTags.Count.Equals(0))
            {
                // checks if the current user is one of those who has the tag
                if (userTags.Contains(userID))
                {
                    return(true);
                }
            }
            // only option is to add it
            return(false);
        }
Exemplo n.º 7
0
        private SearchableTag Map(UserTag tag)
        {
            var searchableTag = tag.Map <SearchableTag>();

            searchableTag.Url = _searchUmbracoHelper.GetSearchPage().Url.AddQueryParameter(tag.Text).ToLinkModel();
            return(searchableTag);
        }
Exemplo n.º 8
0
        public void GetUserTagIdsTest(int userId, int[] expectedTags)
        {
            //Arrange
            var userTag1 = new UserTag
            {
                TagId  = 1,
                UserId = 1
            };

            var userTag2 = new UserTag
            {
                TagId  = 3,
                UserId = 1
            };

            var userTag3 = new UserTag
            {
                TagId  = 5,
                UserId = 1
            };

            var userTag4 = new UserTag
            {
                TagId  = 2,
                UserId = 2
            };

            var userTag5 = new UserTag
            {
                TagId  = 4,
                UserId = 2
            };

            var userTag6 = new UserTag
            {
                TagId  = 5,
                UserId = 2
            };

            _userTagRepository.SetupRepositoryMock(options =>
            {
                options.Insert(userTag1);
                options.Insert(userTag2);
                options.Insert(userTag3);
                options.Insert(userTag4);
                options.Insert(userTag5);
                options.Insert(userTag6);
            });

            var userService = new UserService(null, _userTagRepository.Object, null, null);

            //Act
            var result = userService.GetUserTagIds(userId);

            var firstNotSecond = result.Except(expectedTags).ToList();
            var secondNotFirst = expectedTags.Except(result).ToList();

            //Assert
            Assert.True(!firstNotSecond.Any() && !secondNotFirst.Any());
        }
Exemplo n.º 9
0
        /// <summary>
        /// 更新用户标签
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> UpdateUserTags([FromBody] List <string> Tags)
        {
            //删除当前用户的标签,
            var userId   = UserIdentity.UserId;
            var userTags = await userContext.UserTag.Where(x => x.UserId == userId).ToListAsync();

            if (userTags != null || userTags.Count != 0)
            {
                userContext.UserTag.RemoveRange(userTags);
                await userContext.SaveChangesAsync();
            }
            List <UserTag> newUserTags = new List <UserTag>();

            Tags.ForEach((x) =>
            {
                var userTag = new UserTag {
                    UserId = userId, Tag = x, CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                };
                newUserTags.Add(userTag);
            });
            userContext.UserTag.AddRange(newUserTags);
            await userContext.SaveChangesAsync();

            return(Ok(newUserTags));
        }
Exemplo n.º 10
0
 public long InsertByContrib(UserTag entity)
 {
     using (MySqlConnection connection = new MySqlConnection(_conncetionString))
     {
         return(connection.Insert(entity));
     }
 }
Exemplo n.º 11
0
 public bool UpdateByContrib(UserTag entity)
 {
     using (MySqlConnection connection = new MySqlConnection(_conncetionString))
     {
         return(connection.Update(entity));
     }
 }
Exemplo n.º 12
0
        public async Task <bool> SubscribeToTag(UserTag userTag)
        {
            this.knowledgeHubDataBaseContext.UserTag.Add(userTag);
            var userTagAddedCount = await this.knowledgeHubDataBaseContext.SaveChangesAsync();

            return(userTagAddedCount == 1);
        }
Exemplo n.º 13
0
        public void Post(Guid tagId)
        {
            Tag tag = _tagRepository.Select.Where(r => r.Id == tagId).ToOne();

            if (tag == null)
            {
                throw new LinCmsException("该标签不存在");
            }

            if (!tag.Status)
            {
                throw new LinCmsException("该标签已被拉黑");
            }

            bool any = _userTagRepository.Select.Any(r =>
                                                     r.CreateUserId == _currentUser.Id && r.TagId == tagId);

            if (any)
            {
                throw new LinCmsException("您已关注该标签");
            }

            UserTag userTag = new UserTag()
            {
                TagId = tagId
            };

            _userTagRepository.Insert(userTag);

            _tagService.UpdateSubscribersCount(tagId, 1);
        }
Exemplo n.º 14
0
    protected void MyInitForUpdate()
    {
        using (SqlConnection conn = new DB().GetConnection())
        {
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select * from UserTags where classify=0 order by ID asc";
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            UserTag.DataSource     = rd;
            UserTag.DataTextField  = "TagName";
            UserTag.DataValueField = "ID";
            UserTag.DataBind();
            rd.Close();


            cmd.CommandText = "Select * from Articles where RandomID = '" + RandomID.Text + "'";
            rd = cmd.ExecuteReader();
            if (rd.Read())
            {
                IDLabel.Text        = rd["ID"].ToString();
                Title.Text          = rd["Title"].ToString();
                CoverPhoto.ImageUrl = rd["CoverImageURL"].ToString();
                Orders.Text         = rd["Orders"].ToString();
                UserName.Text       = rd["Author"].ToString();
            }
            rd.Close();
        }
    }
Exemplo n.º 15
0
        public async Task <ActionResult <UserTag> > PostUserTag(UserTag userTag)
        {
            _context.UserTags.Add(userTag);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUserTag", new { id = userTag.UserTagID }, userTag));
        }
Exemplo n.º 16
0
        private void OnTagCheckedChanged(object sender, RoutedEventArgs e)
        {
            CheckBox checkBox = (CheckBox)sender;
            UserTag  userTag  = (UserTag)checkBox.Tag;

            TagStateChanged.NullSafeInvoke(userTag, checkBox.IsChecked);
        }
Exemplo n.º 17
0
        public async Task <ActionResult> AddOrRemoveTag(int id)
        {
            // gets current user id
            string userID = User.Identity.GetUserId();

            //creates the tag to be added/removed
            UserTag ut = new UserTag();

            ut.TagID  = id;
            ut.UserID = userID;

            // checks if the current user is one of those who has the tag
            bool userHasThisTag = UserHasTag(id);

            // if he has the tag, removes it
            if (userHasThisTag)
            {
                IQueryable <UserTag> remTagQuery = (from remTag in db.UsersTags where remTag.TagID == id && remTag.UserID == userID select remTag);
                db.UsersTags.Remove(remTagQuery.First());
            }
            // if he doesnt, adds it
            else
            {
                db.UsersTags.Add(ut);
            }

            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 18
0
        public void SaveTags( String tagList, int viewerId, User owner )
        {
            String[] arrTags = tagList.Split( new char[] { ',', ',', '、' } );

            foreach (String tag in arrTags) {

                if (strUtil.IsNullOrEmpty( tag )) continue;

                String name = strUtil.SqlClean( tag.Trim(), 10 );

                UserTag ut = GetTagByName( name );
                if (ut == null) {
                    ut = new UserTag();
                    ut.CreatorId = viewerId;
                    ut.Name = strUtil.SubString( tag.Trim(), 10 );
                    ut.insert();
                }

                UserTagShip uts = UserTagShip.find( "UserId=" + owner.Id + " and TagId=" + ut.Id ).first();
                if (uts != null) continue;

                uts = new UserTagShip();
                uts.User = owner;
                uts.Tag = ut;
                uts.insert();

                ut.UserCount++;
                ut.update();

            }
        }
Exemplo n.º 19
0
        //根据数据库保存的默认值,设置控件DataShow2的值
        private void resetTag(UserControls.DataShow2 dataShow, int iIndex)
        {
            try
            {
                if (null == AppDrill.UserTag || AppDrill.UserTag.Count <= 0)
                {
                    return;
                }

                UserTag data = null;
                data = AppDrill.UserTag.Find(o => o.Form == fname && o.Group == group && o.Order == iIndex);

                if (data != null)
                {
                    var taglist = listTag.Where(o => o.Tag == data.Tag).FirstOrDefault();
                    if (taglist != null)
                    {
                        dataShow.DTag      = data.Tag;
                        dataShow.DSCaptial = Transformation(data.Tag);
                        setDataShowUnit(dataShow, taglist.Unit);
                        dataShow.Value.Text = "###";
                        dataShow.SetTag();
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 20
0
 private UserTagViewModel MapToViewModel(UserTag tag, string url)
 {
     return(new UserTagViewModel()
     {
         Text = tag.Text,
         SearchUrl = url.AddQueryParameter(tag.Text)
     });
 }
Exemplo n.º 21
0
        public async Task <bool> UnSubscribeTag(int userTagId)
        {
            UserTag userTagToRemove = await this.knowledgeHubDataBaseContext.UserTag.FindAsync(userTagId);

            this.knowledgeHubDataBaseContext.UserTag.Remove(userTagToRemove);
            var userTagAddedCount = await this.knowledgeHubDataBaseContext.SaveChangesAsync();

            return(userTagAddedCount == 1);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Update_Click(object sender, EventArgs e)
        {
            try
            {
                //考虑到用户可能会什么都不操作直接update测点
                for (int i = 0; i < btnlist.Count; i++)
                {
                    if (btnlist[i].BackColor == Color.Red)
                    {
                        if (Decimal.Parse(txt_From.Text) >= Decimal.Parse(txt_TO.Text))
                        {
                            rlbl_error.Text = list_error[0];
                            return;
                        }
                        var tag = TagList.Where(o => o.Tag == btnlist[i].Tag.ToString()).FirstOrDefault();
                        if (tag != null)
                        {
                            //设置需要传递的数据
                            this.Captial = Transformation(tag.Tag);
                            this.From    = Decimal.Parse(txt_From.Text);
                            this.To      = Decimal.Parse(txt_TO.Text);
                            this.Tags    = tag.Tag;
                            this.Unit    = tag.Unit;

                            var model = UserTag.Where(o => o.Tag == btnlist[i].Tag.ToString()).FirstOrDefault();
                            if (model != null)
                            {
                                model.VFrom = this.From;
                                model.VTo   = this.To;
                            }
                            else
                            {
                                UserTag UTModel = new UserTag();
                                UTModel.Tag   = this.Tags;
                                UTModel.VFrom = this.From;
                                UTModel.VTo   = this.To;
                                UserTag.Add(UTModel);
                            }
                            if (UserTagRef != null)
                            {
                                UserTagRef.JsonTag     = new JavaScriptSerializer().Serialize(UserTag);
                                UserTagRef.dataUpdPGM  = "SeleteTagForm";
                                UserTagRef.dataUpdTime = DateTime.Now;
                                UserTagRef.dataUpdUser = AppDrill.username;
                            }
                            db.SaveChanges();
                            break;
                        }
                    }
                }
                this.Close();
            }
            catch
            {
                rlbl_error.Text = list_error[1];
            }
        }
Exemplo n.º 23
0
        public void DeleteUserTag(int userTagId)
        {
            UserTag targetUserTag = context.UserTags.Find(userTagId);

            if (targetUserTag != null)
            {
                context.UserTags.Remove(targetUserTag);
            }
        }
Exemplo n.º 24
0
        public int Insert(UserTag entity)
        {
            string sql = $"insert into UsersTags ({nameof(UserTag.Name)},{nameof(UserTag.FriendId)},{nameof(UserTag.UserId)}) values (@Name,@FriendId,@UserId)";

            using (MySqlConnection connection = new MySqlConnection(_conncetionString))
            {
                return(connection.Execute(sql, entity));
            }
        }
Exemplo n.º 25
0
 public UserTagView(UserTag tag)
 {
     Name             = tag.Name;
     Priority         = tag.Priority;
     Font             = (FontDescriptorView)tag.Font;
     Foreground       = tag.Foreground;
     Background       = tag.Background;
     LocationBindable = tag.LocationBindable;
     MessageBindable  = tag.MessageBindable;
 }
Exemplo n.º 26
0
 public long CreateUserTag(UserTag userTag)
 {
     DbParameter[] parms =
     {
         DbHelper.MakeInParam("@TagName", (DbType)SqlDbType.NVarChar, 50, userTag.TagName),
         DbHelper.MakeInParam("@UID",     (DbType)SqlDbType.BigInt,    8, userTag.UID),
         DbHelper.MakeInParam("@TagID",   (DbType)SqlDbType.BigInt,    8, userTag.TagID)
     };
     return(TypeConverter.ObjectToLong(DbHelper.ExecuteScalar(CommandType.StoredProcedure, "CreateUserTag", parms), -1));
 }
Exemplo n.º 27
0
        public UserTag GetTagByName(string tName)
        {
            if (strUtil.IsNullOrEmpty(tName))
            {
                return(null);
            }

            tName = strUtil.SqlClean(tName, 10);
            return(UserTag.find("Name=:name").set("name", tName).first());
        }
Exemplo n.º 28
0
        //http update
        public static async Task <HttpStatusCode> UpdateUserTagAsync(UserTag pUserItem, String pPath)
        {
            HttpResponseMessage response = await httpClient.PutAsJsonAsync(pPath + $"{pUserItem.UsertagId}", pUserItem);

            response.EnsureSuccessStatusCode();

            // Deserialize the updated product from the response body.
            //pClient = await response.Content.ReadAsAsync<Client>();
            return(response.StatusCode);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 添加 Push 标签方法
        /// </summary>
        /// <param name="userTag">用户标签</param>
        public async Task <CodeSuccessReslut> setUserPushTag(UserTag userTag)
        {
            if (userTag == null)
            {
                throw new ArgumentNullException(nameof(userTag));
            }

            string postStr = userTag.ToString();

            return(JsonConvert.DeserializeObject <CodeSuccessReslut>(await RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/tag/set.json", postStr, "application/json")));
        }
Exemplo n.º 30
0
        /**
         * 添加 Push 标签方法
         *
         * @param  userTag:用户标签。
         *
         * @return CodeSuccessReslut
         **/
        public CodeSuccessReslut setUserPushTag(UserTag userTag)
        {
            if (userTag == null)
            {
                throw new ArgumentNullException("Paramer 'userTag' is required");
            }

            String postStr = "";

            postStr = JsonConvert.SerializeObject(userTag);
            return((CodeSuccessReslut)RongJsonUtil.JsonStringToObj <CodeSuccessReslut>(RongHttpClient.ExecutePost(appKey, appSecret, RongCloud.RONGCLOUDURI + "/user/tag/set.json", postStr, "application/json")));
        }
        public IActionResult BeginQuestions()
        {
            var questions = _context.Questions.Where(q => q.DefaultQuestion == true).ToList();

            //Get current page state
            int state = 0;

            byte[] outVal;
            if (HttpContext.Session.TryGetValue("State", out outVal))
            {
                state = BitConverter.ToInt32(outVal, 0);
            }
            else
            {
                HttpContext.Session.Set("State", BitConverter.GetBytes(state));
            }


            //If an answer was submitted add it to the user
            int answerNumber;

            if (Int32.TryParse(Request.Form["answer"], out answerNumber))
            {
                //Get get user
                byte[] idOutVal;
                HttpContext.Session.TryGetValue("UserID", out idOutVal);
                int  userID = BitConverter.ToInt32(idOutVal, 0);
                User user   = _context.Users.SingleOrDefault(u => u.UserID == userID);

                //Create new user tag
                List <QuestionTag> tags = _context.QuestionTags.Where(qt => qt.QuestionID == questions[state - 1].QuestionID).ToList();
                //Ensure we don't get an out of bounds error
                if (answerNumber < tags.Count)
                {
                    UserTag tag = new UserTag {
                        Label = tags[answerNumber].Label, Weight = 80, UserID = userID
                    };
                    _context.UserTags.Add(tag);
                    _context.SaveChanges();

                    //Add user tag to the user
                    user.UserTags.Add(tag);
                    _context.Users.Update(user);
                    _context.SaveChanges();
                }
            }

            HttpContext.Session.Set("State", BitConverter.GetBytes(++state));

            return(View(questions));
        }
Exemplo n.º 32
0
 internal static UserInfoStruct[] ToUserInfoArray(Dictionary<string, object> dic, UserTag userTag)
 {
     try
     {
         JavaScriptSerializer jss = new JavaScriptSerializer();
         var upr = jss.Deserialize<UserInfoStruct[]>(jss.Serialize(dic[userTag.ToString()]));
         return upr;
     }
     catch { }
     return null;
 }