Beispiel #1
0
    private void button1_Click(object sender, EventArgs e)
    {
        string name     = textBox1.Text;
        string password = textBox2.Text;

        if (name != null && password != null)
        {
            string port = Client.getClientTCPAddressPort();
            Console.WriteLine("[Client]Port: " + port);

            /*
             * Pede ao servidor que lhe crie uma instancia
             */
            self = server.AddNewClient(name, password, port);
            if (self != null)
            {
                Console.WriteLine("[Client]: Joined! (Id=" + self.Id.ToString() + ", Name=" + self.Name + ")");
                Client.port = port;
                Client.name = name;
                Client.self = self;

                /*
                 * Fecha form atual e abre novo
                 */
                this.Hide();
                var onlineList = new OnlineList(server, self);
                onlineList.Closed += (s, args) => this.Close();
                onlineList.Show();
            }
            else
            {
                label3.Visible = true;
            }
        }
    }
Beispiel #2
0
        protected void DataGrid_Update(object sender, DataGridCommandEventArgs E)
        {
            int groupid = this.DataGrid1.DataKeys[E.Item.ItemIndex].ToString().ToInt(0);
            int num     = ((TextBox)E.Item.Cells[2].Controls[0]).Text.ToInt(0);

            if (num < 0)
            {
                num = 0;
            }

            string text          = ((TextBox)E.Item.Cells[3].Controls[0]).Text;
            string selectedValue = ((DropDownList)E.Item.FindControl("imgdropdownlist")).SelectedValue;

            AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "在线列表定制", text);
            try
            {
                //UserGroups.UpdateOnlineList(groupid, num, selectedValue, text);
                var gp = OnlineList.FindByGroupID(groupid);
                gp.DisplayOrder = num;
                gp.Title        = text;
                gp.Img          = selectedValue;
                gp.Update();

                this.BindData();
                //XCache.Remove(CacheKeys.FORUM_UI_ONLINE_ICON_LIST);
                base.RegisterStartupScript("PAGE", "window.location.href='global_onlinelistgrid.aspx';");
            }
            catch
            {
                base.RegisterStartupScript("", "<script>alert('无法更新数据库');window.location.href='global_onlinelistgrid.aspx';</script>");
            }
        }
Beispiel #3
0
        public bool Remove(string name, bool isTemporary = false)
        {
            OnlineList.Remove(name);

            return(isTemporary
                ? TemporaryAdd.Remove(name) || TemporaryRemove.Add(name)
                : List.Remove(name));
        }
Beispiel #4
0
        public bool IsOnList(string name, bool onlineOnly = false)
        {
            var isOnList = onlineOnly
                ? OnlineList.Contains(name)
                : List.Contains(name) || TemporaryAdd.Contains(name);

            return(isOnList && !TemporaryRemove.Contains(name));
        }
Beispiel #5
0
        private DataSet LoadDataInfo()
        {
            DataSet dataSet = new DataSet();
            //DataTable onlineList = UserGroups.GetOnlineList();
            DataTable onlineList = OnlineList.FindAllWithCache().ToDataTable(false);

            dataSet.Tables.Add(onlineList.Clone());
            foreach (DataRow row in onlineList.Rows)
            {
                dataSet.Tables[0].ImportRow(row);
            }
            dataSet.Tables[0].Columns.Add("newdisplayorder");
            dataSet.Tables[0].Rows[0]["Title"] = "普通用户";
            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                if (!Utils.IsNumeric(dataRow["displayorder"].ToString()) || dataRow["displayorder"].ToString() == "0")
                {
                    dataRow["newdisplayorder"] = "不显示";
                }
                else
                {
                    dataRow["newdisplayorder"] = dataRow["displayorder"].ToString();
                }
            }
            DataTable dataTable = new DataTable("img");

            dataTable.Columns.Add("imgfile", typeof(String));
            DataRow dataRow2 = dataTable.NewRow();

            dataRow2["imgfile"] = "";
            dataTable.Rows.Add(dataRow2);
            try
            {
                DirectoryInfo    directoryInfo   = new DirectoryInfo(base.Server.MapPath("../../images/groupicons"));
                FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos();
                for (int i = 0; i < fileSystemInfos.Length; i++)
                {
                    FileSystemInfo fileSystemInfo = fileSystemInfos[i];
                    if (fileSystemInfo != null && fileSystemInfo.Extension != "")
                    {
                        dataRow2 = dataTable.NewRow();
                        if (!(fileSystemInfo.Name.ToLower() == "thumbs.db"))
                        {
                            dataRow2["imgfile"] = fileSystemInfo.Name;
                            dataTable.Rows.Add(dataRow2);
                        }
                    }
                }
                dataSet.Tables.Add(dataTable);
                dataSet.Relations.Add(dataTable.Columns["imgfile"], dataSet.Tables[0].Columns["img"]);
            }
            catch
            {
            }
            return(dataSet);
        }
Beispiel #6
0
 public void CloseSession(ITcpSession sesseion)
 {
     if (OnDisConnect != null)
     {
         OnDisConnect(this, sesseion);
     }
     sesseion.Clear();//自清理
     sessionPool.Push(sesseion);
     OnlineList.TryRemove(sesseion.SessionId, out sesseion);
 }
Beispiel #7
0
        public void Set(IEnumerable <string> collection)
        {
            List.Clear();
            OnlineList.Clear();

            if (collection != null)
            {
                List.UnionWith(collection);
            }
        }
Beispiel #8
0
        private IEnumerator AddToShoppingListRoutine()
        {
            ConfirmDialog dialog = FindObjectOfType <ConfirmDialog>();

            dialog.ApplyColours();
            dialog.Show();
            dialog.SetNone();
            dialog.SetInfoMessage("Add all ingredients from each recipe to the shopping list?");

            while (dialog.IsNone())
            {
                yield return(null);
            }

            if (dialog.IsNo())
            {
                dialog.Hide();
                dialog.SetNone();
                yield break;
            }

            if (dialog.IsYes())
            {
                TMP_Text addButtonText = addButton.GetComponentInChildren <TMP_Text>();
                addButtonText.text     = "Please wait...";
                addButton.interactable = false;

                dialog.Hide();

                OnlineList      shoppingList = FindObjectsOfType <OnlineList>().Where(x => x.GetListType().Equals(TodoistList.shoppingList)).First();
                UnityWebRequest request      = Postman.CreateGetRequest(Endpoints.instance.SHOPPING_LIST());
                yield return(request.SendWebRequest());

                JSONArray json = JSON.Parse(request.downloadHandler.text).AsArray;
                foreach (KeyValuePair <string, JSONNode> obj in json)
                {
                    string item = obj.Value.Value;
                    yield return(StartCoroutine(shoppingList.AddItemRoutine(item)));
                }

                shoppingList.Refresh();
                dialog.SetNone();

                addButton.interactable = true;
                addButtonText.text     = "Add To Shopping List";

                yield break;
            }
        }
Beispiel #9
0
        public void UpdateOnlineList(OnlineList list)
        {
            var builder = new StringBuilder();

            for (int i = 0; i < list.Count; i++)
            {
                builder.Append(list[i]);
                builder.Append(Environment.NewLine);
            }

            OnlineTextBox.Text = builder.ToString();
            //OnlineTextBox.Update();

            OnlineLabel.Text = $"Users online: {list.Count}";
            OnlineLabel.Update();
        }
Beispiel #10
0
        protected void BroadcastInfo()
        {
            var list = new List <string>();

            foreach (var onlineUser in usersOnline)
            {
                list.Add(onlineUser.Name);
            }

            //Оборачиваем список перед сериализацией
            var message = new OnlineList(list);

            foreach (var user in usersOnline)
            {
                user.SendMessage(message);
            }
        }
Beispiel #11
0
        private void ProcessAccept(SocketAsyncEventArgs acceptEventArgs)
        {
            ITcpSession session = sessionPool.Pop();

            if (session != null)
            {
                session.Server = this;
                OnlineList.TryAdd(session.SessionId, session);
                session.ConnectSocket   = acceptEventArgs.AcceptSocket;
                session.ConnectDateTime = DateTime.Now;
                session.ActiveDateTime  = session.ConnectDateTime;
                if (OnConnected != null)
                {
                    OnConnected(this, session); //启动连接请求通过事件
                }
                session.StartReceiveAsync();    //开始接收数据
            }
            StartAccept(acceptEventArgs);       //把当前异步事件释放,等待下次连接
        }
Beispiel #12
0
        //public static UserGroupInfo AdminGetUserGroupInfo(int groupid)
        //{
        //    return UserGroup.FindByID(groupid);
        //}

        //public static AdminGroup AdminGetAdminGroupInfo(int groupid)
        //{
        //    //return AdminGroups.GetAdminGroupInfo(groupid);
        //    return AdminGroup.FindByID(groupid);
        //}

        public static bool AddUserGroupInfo(UserGroup userGroupInfo)
        {
            bool result;

            try
            {
                int       creditshigher = userGroupInfo.Creditshigher;
                int       creditslower  = userGroupInfo.Creditslower;
                DataTable userGroupByCreditsHigherAndLower = BBX.Data.UserGroups.GetUserGroupByCreditsHigherAndLower(creditshigher, creditslower);
                if (userGroupByCreditsHigherAndLower.Rows.Count > 0)
                {
                    result = false;
                }
                else
                {
                    if (!userGroupInfo.Is管理团队 && !SystemCheckCredits("add", ref creditshigher, ref creditslower, 0))
                    {
                        result = false;
                    }
                    else
                    {
                        userGroupInfo.Creditshigher = creditshigher;
                        userGroupInfo.Creditslower  = creditslower;
                        //BBX.Data.UserGroups.CreateUserGroup(userGroupInfo);
                        userGroupInfo.Save();
                        //BBX.Data.OnlineUsers.AddOnlineList(userGroupInfo.GroupTitle);
                        OnlineList.Add(userGroupInfo.ID, userGroupInfo.GroupTitle);
                        //Caches.ReSetAdminGroupList();
                        Caches.ReSetUserGroupList();
                        result = true;
                    }
                }
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Beispiel #13
0
        public static OnlineList Insert(OnlineList entity)
        {
            DataCommand command = DataCommandManager.GetDataCommand("InsertOnlineList");

            command.SetParameterValue("@OnlineListlocationSysNo", entity.OnlineLocationSysNo);
            command.SetParameterValue("@ProductID", entity.ProductID);
            command.SetParameterValue("@Priority", entity.Priority);
            command.SetParameterValue("@BeginDate", DateTime.Now);
            command.SetParameterValue("@EndDate", DateTime.Now.AddDays(1));
            command.SetParameterValue("@InDate", DateTime.Now);
            command.SetParameterValue("@InUser", "System");
            command.SetParameterValue("@EditDate", DateTime.Now);
            command.SetParameterValue("@EditUser", "System");
            command.SetParameterValue("@Status", "A");
            command.SetParameterValue("@CompanyCode", ConfigurationManager.AppSettings["CompanyCode"]);
            command.SetParameterValue("@LanguageCode", ConfigurationManager.AppSettings["LanguageCode"]);
            command.SetParameterValue("@StoreCompanyCode", ConfigurationManager.AppSettings["CompanyCode"]);

            command.ExecuteNonQuery();
            entity.SysNo = (int)command.GetParameterValue("@SysNo");
            return(entity);
        }
Beispiel #14
0
 public void SetOnlineList(OnlineList list)
 {
     this.list = list;
 }
Beispiel #15
0
        protected override void ShowPage()
        {
            this.pagetitle = "首页";
            if (this.userid > 0 && this.useradminid > 0)
            {
                var adminGroupInfo = AdminGroup.FindByID(this.usergroupid);
                if (adminGroupInfo != null)
                {
                    this.disablepostctrl = adminGroupInfo.DisablePostctrl;
                }
            }
            int num = DNTRequest.GetInt("f", 1);

            if (num == 0)
            {
                ForumUtils.WriteCookie("isframe", "1");
            }
            else
            {
                num = ForumUtils.GetCookie("isframe").ToInt(-1);
                if (num == -1)
                {
                    num = this.config.Isframeshow;
                }
            }
            if (num == 2)
            {
                HttpContext.Current.Response.Redirect(BaseConfigs.GetForumPath + "frame.aspx");
                HttpContext.Current.Response.End();
                return;
            }
            if (this.config.Rssstatus == 1)
            {
                base.AddLinkRss("tools/rss.aspx", "最新主题");
            }
            Online.UpdateAction(this.olid, UserAction.IndexShow, 0, this.config.Onlinetimeout);
            if (this.userid != -1)
            {
                this.userinfo = BBX.Entity.User.FindByID(this.userid);
                if (this.userinfo == null)
                {
                    this.userid = -1;
                    ForumUtils.ClearUserCookie();
                }
                else
                {
                    //this.newpmcount = !userinfo.Newpm ? 0 : this.newpmcount;
                    if (!userinfo.Newpm)
                    {
                        newpmcount = 0;
                    }
                    this.lastvisit  = this.userinfo.LastVisit.ToString();
                    this.showpmhint = (this.userinfo.NewsLetter.ToInt() > 4);
                }
            }
            this.navhomemenu    = Caches.GetForumListMenuDivCache(this.usergroupid, this.userid, this.config.Extname);
            this.forumlist      = Forums.GetForumIndexCollection(this.config.Hideprivate, this.usergroupid, this.config.Moddisplay, out this.totaltopic, out this.totalpost, out this.todayposts);
            this.forumlinkcount = this.forumlinklist.Rows.Count;
            //if (this.config.Enablespace == 1)
            //{
            //    this.GetSpacePerm();
            //}
            this.totalusers       = Statistic.Current.TotalUsers;
            this.lastusername     = Statistic.Current.LastUserName + "";
            this.lastuserid       = Statistic.Current.LastUserID;
            this.yesterdayposts   = Statistic.Current.YesterdayPosts;
            this.highestposts     = Statistic.Current.HighestPosts;
            this.highestpostsdate = Statistic.Current.HighestPostsDate + "";
            if (this.todayposts > this.highestposts)
            {
                this.highestposts     = this.todayposts;
                this.highestpostsdate = DateTime.Now.ToString("yyyy-M-d");
            }
            this.totalonline     = this.onlineusercount;
            this.showforumonline = false;
            this.onlineiconlist  = OnlineList.GetOnlineGroupIconList();
            if (this.totalonline < this.config.Maxonlinelist || DNTRequest.GetString("showonline") == "yes")
            {
                this.showforumonline = true;
                var list = Online.GetList(0, Online._.UserID, true);
                // 根据活跃时间降序
                list.Sort(Online._.LastActivity, true);
                this.onlineuserlist = list;

                var st = Online.GetStat();
                this.totalonline              = st.Total;
                this.totalonlineuser          = st.User;
                this.totalonlineinvisibleuser = st.Invisible;
                this.totalonlineguest         = st.Guest;
            }
            if (DNTRequest.GetString("showonline") == "no")
            {
                this.showforumonline = false;
            }
            this.highestonlineusercount = Statistic.Current.HighestOnlineUserCount + "";
            this.highestonlineusertime  = Statistic.Current.HighestOnlineUserTime.ToString("yyyy-MM-dd HH:mm");
            //this.announcementlist = Announcements.GetSimplifiedAnnouncementList(this.nowdatetime, "2999-01-01 00:00:00");
            announcementlist       = Announcement.GetAvailableList();
            this.announcementcount = this.announcementlist != null ? this.announcementlist.Count : 0;
            var fs = new List <IXForum>();

            foreach (var current in this.forumlist)
            {
                current.Description = UBB.ParseSimpleUBB(current.Description);
                if (current.Layer == 0)
                {
                    fs.Add(current);
                }
            }
            this.taglist    = config.Enabletag ? Tag.GetHotForumTags(config.Hottagcount).ToArray() : new Tag[0];
            this.headerad   = Advertisement.GetOneHeaderAd("indexad", 0);
            this.footerad   = Advertisement.GetOneFooterAd("indexad", 0);
            this.inforumad  = Advertisement.GetInForumAd("indexad", 0, fs, this.templatepath);
            this.pagewordad = Advertisement.GetPageWordAd("indexad", 0);
            this.doublead   = Advertisement.GetDoubleAd("indexad", 0);
            this.floatad    = Advertisement.GetFloatAd("indexad", 0);
            this.mediaad    = Advertisement.GetMediaAd(this.templatepath, "indexad", 0);
            this.pagead     = Advertisement.GetPageAd("indexad", 0);
            if (this.userid > 0 && this.oluserinfo.Newpms < 0)
            {
                Users.UpdateUserNewPMCount(this.userid, this.olid);
            }
        }
Beispiel #16
0
 public bool SignOn(string name)
 {
     return(IsOnList(name) &&
            OnlineList.Add(name));
 }
Beispiel #17
0
 public bool SignOff(string name)
 {
     return(OnlineList.Remove(name));
 }