public ServerResponse Get(GetParms parm)
        {
            var url = string.Format("{0}{1}{2}", _domain, parm.EndPoint, parm.QueryString);

            var request = (HttpWebRequest) WebRequest.Create(url);
            if(parm.TabId > 0) request.Headers["TabID"] = parm.TabId.ToString();
            if(parm.TabId > 0) request.Headers["ModuleID"] = parm.ModuleId.ToString();
            request.Method = "GET";
            request.KeepAlive = false;
            request.CookieContainer = _sessionCookiesContainer;
            request.ReadWriteTimeout = 90;
            var response = new ServerResponse();
            using (var httpResponse = (HttpWebResponse) request.GetResponse())
            {
                response.Status = httpResponse.StatusCode;
                using (var s = httpResponse.GetResponseStream())
                {
                    if (s != null)
                        using (var sr = new StreamReader(s, Encoding.UTF8))
                    {
                        response.Data = sr.ReadToEnd();
                    }
                }
            }

            return response;
        }
Exemplo n.º 2
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     DnnWebApiClientController.Instance.Login(txtSite.Text, txtUser.Text, txtPassword.Text);
     var parm = new GetParms {EndPoint = "DesktopModules/MemberDirectory/API/MemberDirectory/AdvancedSearch",
         QueryString = "?userId=1&groupId=-1&pageIndex=0&pageSize=20&searchTerm1=&searchTerm2=&searchTerm3=&searchTerm4=",
         TabId = 96, ModuleId = 484 };
     var response = DnnWebApiClientController.Instance.Get(parm);
     if (response.Status == HttpStatusCode.OK)
     {
         var users = JsonConvert.DeserializeObject<IList<User>>(response.Data);
         gvMembers.DataSource = users;
     }
     foreach (DataGridViewRow dgvr in gvMembers.Rows)
     {
         var userName = dgvr.Cells["UserName"].Value;
         if(userName == txtUser.Text) continue;
         var friendStatus = dgvr.Cells["FriendStatus"].Value;
         switch ((RelationshipStatus) friendStatus)
         {
             case RelationshipStatus.None:
                 dgvr.Cells[0].Value = "Add Friend";
                 break;
             case RelationshipStatus.Pending:
                 dgvr.Cells[0].Value = "Pending";
                 break;
             case RelationshipStatus.Accepted:
                 dgvr.Cells[0].Value = "Remove Friend";
                 break;
         }
     }
 }
        public ServerResponse Get(GetParms parm)
        {
            var url = string.Format("{0}{1}{2}", _domain, parm.EndPoint, parm.QueryString);

            var request = (HttpWebRequest)WebRequest.Create(url);

            if (parm.TabId > 0)
            {
                request.Headers["TabID"] = parm.TabId.ToString();
            }
            if (parm.TabId > 0)
            {
                request.Headers["ModuleID"] = parm.ModuleId.ToString();
            }
            request.Method           = "GET";
            request.KeepAlive        = false;
            request.CookieContainer  = _sessionCookiesContainer;
            request.ReadWriteTimeout = 90;
            var response = new ServerResponse();

            using (var httpResponse = (HttpWebResponse)request.GetResponse())
            {
                response.Status = httpResponse.StatusCode;
                using (var s = httpResponse.GetResponseStream())
                {
                    if (s != null)
                    {
                        using (var sr = new StreamReader(s, Encoding.UTF8))
                        {
                            response.Data = sr.ReadToEnd();
                        }
                    }
                }
            }

            return(response);
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create your application here
            SetContentView (Resource.Layout.Members);

            //var gridview = FindViewById<GridView> (Resource.Id.gridMembers);

            var parm = new GetParms {EndPoint = "DesktopModules/MemberDirectory/API/MemberDirectory/AdvancedSearch",
                QueryString = "?userId=1&groupId=-1&pageIndex=0&pageSize=20&searchTerm1=&searchTerm2=&searchTerm3=&searchTerm4=",
                TabId = 96, ModuleId = 484 };
            var response = DnnWebApiClientController.Instance.Get(parm);
            if (response.Status == HttpStatusCode.OK) {
                var users = JsonConvert.DeserializeObject<IList<User>>(response.Data);

                // create our adapter
                var userList = new Adapters.UserListAdapter(this, users);

                var listMembers = FindViewById<ListView> (Resource.Id.listMembers);
                //Hook up our adapter to our ListView
                listMembers.Adapter = userList;
            }
        }