Exemplo n.º 1
0
		/// <summary>
		/// 将序列化的字符串解析为StringTable
		/// </summary>
		/// <param name="value">序列化的字符串</param>
		/// <returns></returns>
		public static StringTable Parse(string value)
		{
			StringTable result = new StringTable();

			result.DoParse(value);

			return result;
		}
Exemplo n.º 2
0
		private void DoParse(string value)
		{
			if (string.IsNullOrEmpty(value))
				return;

			int i = value.IndexOf('|');

			if (i < 3)
				return;

			string[] keyTable = value.Substring(0, i).Split(';');

			i++;

			int j;
			int length;
			StringTable dictionary = new StringTable();

			try
			{
				foreach (string item in keyTable)
				{
					j = item.IndexOf(':');
					if (j != -1)
					{
						length = Convert.ToInt32(item.Substring(j + 1));

                        if (length == -1)
                            this.Add(item.Substring(0, j), null);
                        else
    						this.Add(item.Substring(0, j), value.Substring(i, length));

						i += length;
					}
				}
			}
			catch { }
		}
Exemplo n.º 3
0
        private void UpdateForumsData()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            int[] forumIDs = _Request.GetList<int>("forumIDs", Method.Post, new int[0]);

            if (forumIDs.Length == 0)
            {
                msgDisplay.AddError("您还未选择要更新数据的版块");
                return;
            }

            StringTable tempForumIDs = new StringTable();

            foreach (int forumID in forumIDs)
            {
                tempForumIDs.Add(forumID.ToString(), forumID.ToString());
            }

            if (TaskManager.BeginTask(MyUserID, new UpdateForumDataTask(), tempForumIDs.ToString()))
            {

            }
        }
Exemplo n.º 4
0
        public bool Server_SendNotify(int userID, string typeName, string content, string datas, string keyword, List< NotifyAction> actions,int clientID)
        {
            if (string.IsNullOrEmpty(typeName)) return false;

            NotifyType type = AllNotifyTypes[typeName];
            if (type == null)
                RegisterNotifyType(typeName, true, string.Empty, out type);

            if (!CheckUserNotifySettings(userID, type.TypeID)) //用户通知设置
                return false;

            if (NotifyJumpFlagRegex.IsMatch(content))
            {
                StringTable st = new StringTable();
                string sUrl = string.Empty;

                MatchCollection jumpMatchs = NotifyJumpFlagRegex.Matches(content);
                int i = 0;
                foreach (Match m in jumpMatchs)
                {
                    sUrl += string.Concat(m.Groups[1].Value, "|");
                    content = content.Replace(m.Value, string.Concat("href=\"", Notify.GlobalHandlerUrl + "&ui=" + i++, "\""));
                }
                sUrl = sUrl.Remove(sUrl.Length - 1);
                st.Add("Url", sUrl);
                datas = st.ToString(); //如果有JUMPTO的地址,就会覆盖原来的DATAS
            }

            //int jIndex;
            //do 
            //{
            //    jIndex = content.IndexOf(jumpFlag);
            //    if (jIndex > -1)
            //    {
            //        Notify n = new Notify();
            //        n.Url = "";
            //    }
            //}while(jIndex>-1);

            StringTable actionsTable = new StringTable();
            if (actions != null)
            {
                foreach (NotifyAction na in actions)
                {
                    if (string.IsNullOrEmpty(na.Title) || string.IsNullOrEmpty(na.Url)) continue;
                    actionsTable.Add(na.Title, (na.IsDialog ? "*" : "") + na.Url);
                }
            }

            UnreadNotifies unread;
            bool success =  NotifyDao.Instance.AddNotify(userID, type.TypeID, content, keyword, datas,clientID,actionsTable.ToString() , out unread);

            if (!unread.IsEmpty)
            {
                AuthUser user = UserBO.Instance.GetUserFromCache<AuthUser>(userID);
                if (user != null)
                {
                    user.UnreadNotify = unread;
                }
            }

            RemoveCacheByType(userID, 0);

            if (success && !unread.IsEmpty)
                if (OnUserNotifyCountChanged != null) OnUserNotifyCountChanged(unread);

            return success;
        }