コード例 #1
0
        /// <summary>
        /// Retrieves list of ChatUser objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of ChatUser objects</returns>
        private ChatUserList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //ChatUser list
            ChatUserList list = new ChatUserList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    ChatUser chatUserObject = new ChatUser();
                    FillObject(chatUserObject, reader);

                    list.Add(chatUserObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            try
            {
                base.ViewDidLoad();

                NoMatch.Text   = LangEnglish.NoMatch;
                NoMatch.Hidden = true;

                c.AddViews(Snackbar, Snackbar.SnackText, Snackbar.SnackButton);

                MenuList.TouchUpInside += MenuList_Click;
                MenuList.TouchDown     += MenuList_Touch;

                tap = new CustomTap(this, ChatUserList);
                ChatUserList.AddGestureRecognizer(tap);

                RoundBottom_Base           = RoundBottom;
                Snackbar_Base              = Snackbar;
                BottomConstraint_Base      = BottomConstraint;
                SnackTopConstraint_Base    = SnackTopConstraint;
                SnackBottomConstraint_Base = SnackBottomConstraint;
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
コード例 #3
0
        public void AddMatchItem(MatchItem item)
        {
            matchList.Insert(0, item);
            ChatUserListAdapter adapter = new ChatUserListAdapter(matchList);

            ChatUserList.Source = adapter;
            ChatUserList.ReloadData();
            ChatUserList.RowHeight = 101;
            ChatUserList.Delegate  = this;

            NoMatch.Hidden   = true;
            NoofMatches.Text = (matchList.Count == 1) ? "1 " + LangEnglish.ChatListMatch : matchList.Count + " " + LangEnglish.ChatListMatches;
        }
コード例 #4
0
        public void UpdateMatchItem(int matchID, bool active, long?unmatchDate)
        {
            for (int i = 0; i < matchList.Count; i++)
            {
                if (matchList[i].MatchID == matchID)
                {
                    matchList[i].Active      = active;
                    matchList[i].UnmatchDate = unmatchDate;
                }
            }
            ChatUserListAdapter adapter = new ChatUserListAdapter(matchList);

            ChatUserList.Source = adapter;
            ChatUserList.ReloadData();
        }
コード例 #5
0
        /// <summary>
        /// Retrieves all ChatUser objects by PageRequest
        /// </summary>
        /// <returns>A list of ChatUser objects</returns>
        public ChatUserList GetPaged(PagedRequest request)
        {
            using (SqlCommand cmd = GetSPCommand(GETPAGEDCHATUSER))
            {
                AddParameter(cmd, pInt32Out("TotalRows"));
                AddParameter(cmd, pInt32("PageIndex", request.PageIndex));
                AddParameter(cmd, pInt32("RowPerPage", request.RowPerPage));
                AddParameter(cmd, pNVarChar("WhereClause", 4000, request.WhereClause));
                AddParameter(cmd, pNVarChar("SortColumn", 128, request.SortColumn));
                AddParameter(cmd, pNVarChar("SortOrder", 4, request.SortOrder));

                ChatUserList _ChatUserList = GetList(cmd, ALL_AVAILABLE_RECORDS);
                request.TotalRows = Convert.ToInt32(GetOutParameter(cmd, "TotalRows"));
                return(_ChatUserList);
            }
        }
コード例 #6
0
        /// <summary>
        /// Retrieve list of ChatUser.
        /// </summary>
        /// <param name="fillChild"></param>
        /// <returns>List of ChatUser</returns>
        public ChatUserList GetAll(bool fillChild)
        {
            ChatUserList chatUserList = new ChatUserList();

            using (ChatUserDataAccess data = new ChatUserDataAccess(ClientContext))
            {
                chatUserList = data.GetAll();
            }
            if (fillChild)
            {
                foreach (ChatUser chatUserObject in chatUserList)
                {
                    FillChatUserWithChilds(chatUserObject, fillChild);
                }
            }
            return(chatUserList);
        }
コード例 #7
0
        public override async void ViewWillAppear(bool animated)
        {
            try
            {
                base.ViewWillAppear(animated);

                string responseString = await c.MakeRequest("action=loadmessagelist&ID=" + Session.ID + "&SessionID=" + Session.SessionID);

                if (responseString.Substring(0, 2) == "OK")
                {
                    responseString = responseString.Substring(3);
                    if (responseString != "")
                    {
                        NoMatch.Hidden = true;
                        ServerParser <MatchItem> parser = new ServerParser <MatchItem>(responseString);
                        matchList           = parser.returnCollection;
                        adapter             = new ChatUserListAdapter(matchList);
                        ChatUserList.Source = adapter;
                        NoofMatches.Text    = (matchList.Count == 1) ? "1 " + LangEnglish.ChatListMatch : matchList.Count + " " + LangEnglish.ChatListMatches;
                    }
                    else
                    {
                        matchList           = new List <MatchItem>();
                        adapter             = new ChatUserListAdapter(matchList);
                        ChatUserList.Source = adapter;
                        NoMatch.Hidden      = false;
                        NoofMatches.Text    = "";
                    }
                    ChatUserList.ReloadData();
                }
                else
                {
                    c.ReportError(responseString);
                }

                ChatUserList.RowHeight = 101;  //If the delegate is set before setting the Source, row height is gotten from the adapter allright. Otherwise the first row is about 20, and the subsequent rows are about 70.
                ChatUserList.Delegate  = this; //must be called after setting the Source, otherwise the Scrolled event is not fired.
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
コード例 #8
0
        void IChatCallbacks.ChatChannelUserChangeCallback(ChatUserList joinList, ChatUserList leaveList, ChatUserList userInfoList)
        {
            for (int i = 0; i < leaveList.List.Length; ++i)
            {
                int index = m_ChannelUsers.IndexOf(leaveList.List[i]);
                if (index >= 0)
                {
                    m_ChannelUsers.RemoveAt(index);
                }
            }

            for (int i = 0; i < userInfoList.List.Length; ++i)
            {
                // this will find the existing user with the same name
                int index = m_ChannelUsers.IndexOf(userInfoList.List[i]);
                if (index >= 0)
                {
                    m_ChannelUsers.RemoveAt(index);
                }

                m_ChannelUsers.Add(userInfoList.List[i]);
            }

            for (int i = 0; i < joinList.List.Length; ++i)
            {
                m_ChannelUsers.Add(joinList.List[i]);
            }

            try
            {
                if (UsersChanged != null)
                {
                    this.UsersChanged(joinList.List, leaveList.List, userInfoList.List);
                }
            }
            catch
            {
            }
        }
コード例 #9
0
        public void InsertMessage(string meta, string body)
        {
            long unixTimestamp = c.Now();

            int sep1Pos = meta.IndexOf('|');
            int sep2Pos = meta.IndexOf('|', sep1Pos + 1);
            int sep3Pos = meta.IndexOf('|', sep2Pos + 1);

            int  messageID = int.Parse(meta.Substring(0, sep1Pos));
            int  senderID  = int.Parse(meta.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1));
            long sentTime  = long.Parse(meta.Substring(sep2Pos + 1, sep3Pos - sep2Pos - 1));
            long seenTime  = unixTimestamp;
            long readTime  = 0;

            for (int i = 0; i < matchList.Count; i++)
            {
                if (matchList[i].TargetID == senderID)
                {
                    if (matchList[i].Chat.Length == 3)
                    {
                        matchList[i].Chat[0] = matchList[i].Chat[1];
                        matchList[i].Chat[1] = matchList[i].Chat[2];
                        matchList[i].Chat[2] = messageID + "|" + senderID + "|" + sentTime + "|" + seenTime + "|" + readTime + "|" + body;
                    }
                    else
                    {
                        List <string> chatList = new List <string>(matchList[i].Chat);
                        chatList.Add(messageID + "|" + senderID + "|" + sentTime + "|" + seenTime + "|" + readTime + "|" + body);
                        matchList[i].Chat = chatList.ToArray();
                    }

                    ChatUserListAdapter adapter = new ChatUserListAdapter(matchList);
                    ChatUserList.Source = adapter;
                    ChatUserList.ReloadData();
                    c.MakeRequest("action=messagedelivered&ID=" + Session.ID + "&SessionID=" + Session.SessionID + "&MatchID=" + matchList[i].MatchID + "&MessageID=" + messageID + "&Status=Seen");
                }
            }
        }
コード例 #10
0
ファイル: ChatController.cs プロジェクト: RELO4D3D/sdk-dist
 void IChatCallbacks.ChatQueryChannelUsersCallback(ChatUserList userList)
 {
     // listening for incremental changes so no need for full query
 }
コード例 #11
0
ファイル: ChatController.cs プロジェクト: RELO4D3D/sdk-dist
        void IChatCallbacks.ChatChannelUserChangeCallback(ChatUserList joinList, ChatUserList leaveList, ChatUserList userInfoList)
        {
            for (int i=0; i<leaveList.List.Length; ++i)
            {
                int index = m_ChannelUsers.IndexOf(leaveList.List[i]);
                if (index >= 0)
                {
                    m_ChannelUsers.RemoveAt(index);
                }
            }

            for (int i=0; i<userInfoList.List.Length; ++i)
            {
                // this will find the existing user with the same name
                int index = m_ChannelUsers.IndexOf(userInfoList.List[i]);
                if (index >= 0)
                {
                    m_ChannelUsers.RemoveAt(index);
                }

                m_ChannelUsers.Add(userInfoList.List[i]);
            }

            for (int i=0; i<joinList.List.Length; ++i)
            {
                m_ChannelUsers.Add(joinList.List[i]);
            }

            try
            {
                if (UsersChanged != null)
                {
                    this.UsersChanged(joinList.List, leaveList.List, userInfoList.List);
                }
            }
            catch
            {
            }
        }
コード例 #12
0
        private async void List_Clicked(object sender, EventArgs e)
        {
            var page = new ChatUserList(UserList);

            await PopupNavigation.Instance.PushAsync(page);

            return;


            //var layout = new StackLayout
            //{
            //    WidthRequest = App.Current.MainPage.Width / 3,
            //    HeightRequest = App.Current.MainPage.Height,
            //    BackgroundColor = Color.White,
            //    HorizontalOptions = LayoutOptions.End,
            //    VerticalOptions = LayoutOptions.CenterAndExpand

            //};

            //{
            //    var DataTemplate = new DataTemplate(() =>
            //    {
            //        var grid = new Grid();
            //        var nameLabel = new Label { FontAttributes = FontAttributes.Bold ,TextColor = Color.Black};
            //        var ageLabel = new Label();
            //        var locationLabel = new Label { HorizontalTextAlignment = TextAlignment.End };

            //      // nameLabel.SetBinding(Label.TextProperty, "Name");
            //       // ageLabel.SetBinding(Label.TextProperty, "Age");
            //       // locationLabel.SetBinding(Label.TextProperty, "Location");

            //        grid.Children.Add(nameLabel);
            //       // grid.Children.Add(ageLabel, 1, 0);
            //      //  grid.Children.Add(locationLabel, 2, 0);

            //        return new ViewCell { View = grid };
            //    });

            //    var listview = new ListView();
            //    listview.ItemsSource = UserList;
            //  //  listview.ItemTemplate = DataTemplate;
            //    listview.Margin = new Thickness(20, 50, 20, 20);

            //    layout.Children.Add(listview);

            //  }


            ////close button
            //{
            //    var closebutton = new Button();
            //    closebutton.BackgroundColor = Color.White;
            //    closebutton.TextColor = Color.Black;
            //    closebutton.Text = "Close";
            //    closebutton.Clicked += async (s, args) => await App.Current.MainPage.Navigation.PopModalAsync();
            //    layout.Children.Add(closebutton);
            //}



            //await App.Current.MainPage.Navigation.PushModalAsync(
            //    new ContentPage
            //    {
            //        BackgroundColor = Color.Transparent,
            //        Content = layout,
            //    });


            //     var cameraPage = new CameraPage();
            //    Application.Current.MainPage.Navigation.PushModalAsync(cameraPage);
        }
コード例 #13
0
        void ReleaseDesignerOutlets()
        {
            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (ChatListBottomSeparator != null)
            {
                ChatListBottomSeparator.Dispose();
                ChatListBottomSeparator = null;
            }

            if (ChatUserList != null)
            {
                ChatUserList.Dispose();
                ChatUserList = null;
            }

            if (MenuList != null)
            {
                MenuList.Dispose();
                MenuList = null;
            }

            if (MenuListBg != null)
            {
                MenuListBg.Dispose();
                MenuListBg = null;
            }

            if (MenuListBgCorner != null)
            {
                MenuListBgCorner.Dispose();
                MenuListBgCorner = null;
            }

            if (NoMatch != null)
            {
                NoMatch.Dispose();
                NoMatch = null;
            }

            if (NoofMatches != null)
            {
                NoofMatches.Dispose();
                NoofMatches = null;
            }

            if (RippleChatList != null)
            {
                RippleChatList.Dispose();
                RippleChatList = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }
        }
コード例 #14
0
 void IChatCallbacks.ChatQueryChannelUsersCallback(ChatUserList userList)
 {
     // listening for incremental changes so no need for full query
 }