Exemplo n.º 1
0
        private void populateDfBMembers(DfBTeam dfbTeam)
        {
            int totalMembers = dfbTeam.members.Count;

            for (int i = 0; i < totalMembers; i++)
            {
                string fullname = dfbTeam.members[i].profile.given_name + " " + dfbTeam.members[i].profile.surname;
                if (fullname != " ")
                {
                    if (dfbTeam.members[i].profile.status == "active")
                    {
                        TreeNode treeNode = new TreeNode(fullname);
                        treeViewUsers.Nodes.Add(treeNode);
                    }
                    else
                    {
                        //lets nots show inactives yet.
                    }
                }
                else
                {
                    fullname = "None Provided";
                    if (dfbTeam.members[i].profile.status == "active")
                    {
                        TreeNode treeNode = new TreeNode(fullname);
                        treeViewUsers.Nodes.Add(treeNode);
                    }
                    else
                    {
                        //lets not show inactives yet.
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            // Set cursor as hourglass
            Cursor.Current = Cursors.WaitCursor;

            //obtain basic api information
            BasicTeamInformation teamInformation = dfbBasicTeamInfo();
            //obtain team information
            DfBTeam dfbTeam = dfb_members_list();

            //if we connect to the api successfully:
            if (teamInformation.num_licenced_users >= 0)
            {
                labelTeamName.Text           = "Connected to: " + teamInformation.name;
                pictureBoxConnected.SizeMode = PictureBoxSizeMode.Zoom;
                pictureBoxConnected.Image    = imageList2.Images[1];
                //populate the global object for use throughout the app.
                gbl_TeamObject = dfbTeam;
                populateDfBMembers(gbl_TeamObject);
            }

            // Set cursor as default arrow
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 3
0
        private DfBTeam dfb_members_list()
        {
            String     page    = "https://api.dropbox.com/1/team/members/list";
            WebRequest request = WebRequest.Create(page);

            request.Method      = "POST";
            request.ContentType = "application/json";
            String authheader = "Authorization:Bearer " + txtToken.Text;

            request.Headers.Add(authheader);

            // Create POST data and convert it to a byte array.
            string postData = "{}";

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;

            // Get the request stream.
            Stream ds = request.GetRequestStream();

            // Write the data to the request stream.
            ds.Write(byteArray, 0, byteArray.Length);

            // Close the Stream object.
            ds.Close();

            // Get the response.
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream();

                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);

                // Read the content.
                string responseFromServer = reader.ReadToEnd();

                // Cleanup the streams and the response.
                reader.Close();
                dataStream.Close();
                response.Close();

                //serialise the json so we can send back a BasicTeamInformation object
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DfBTeam));
                MemoryStream stream            = new MemoryStream(Encoding.UTF8.GetBytes(responseFromServer));
                DfBTeam      teamObj           = (DfBTeam)ser.ReadObject(stream);

                return(teamObj);
            }

            catch (WebException error)
            {
                DfBTeam failedObj = new DfBTeam();
                failedObj.cursor = error.Message;
                return(failedObj);
            }
        }
Exemplo n.º 4
0
 private void populateDfBMembers(DfBTeam dfbTeam)
 {
     int totalMembers = dfbTeam.members.Count;
     for (int i = 0; i < totalMembers; i++)
     {
         string fullname = dfbTeam.members[i].profile.given_name + " " + dfbTeam.members[i].profile.surname;
         if (fullname != " ")
         {
             if (dfbTeam.members[i].profile.status == "active")
             {
                 TreeNode treeNode = new TreeNode(fullname);
                 treeViewUsers.Nodes.Add(treeNode);
             }
             else
             {
                 //lets nots show inactives yet.
             }
         }
         else
         {
             fullname = "None Provided";
             if (dfbTeam.members[i].profile.status == "active")
             {
                 TreeNode treeNode = new TreeNode(fullname);
                 treeViewUsers.Nodes.Add(treeNode);
             }
             else
             {
                 //lets not show inactives yet.
             }
         }
     }
 }
Exemplo n.º 5
0
        private DfBTeam dfb_members_list()
        {
            String page = "https://api.dropbox.com/1/team/members/list";
            WebRequest request = WebRequest.Create(page);

            request.Method = "POST";
            request.ContentType = "application/json";
            String authheader = "Authorization:Bearer " + txtToken.Text;
            request.Headers.Add(authheader);

            // Create POST data and convert it to a byte array.
            string postData = "{}";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;

            // Get the request stream.
            Stream ds = request.GetRequestStream();

            // Write the data to the request stream.
            ds.Write(byteArray, 0, byteArray.Length);

            // Close the Stream object.
            ds.Close();

            // Get the response.
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream();

                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);

                // Read the content.
                string responseFromServer = reader.ReadToEnd();

                // Cleanup the streams and the response.
                reader.Close();
                dataStream.Close();
                response.Close();

                //serialise the json so we can send back a BasicTeamInformation object
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DfBTeam));
                MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(responseFromServer));
                DfBTeam teamObj = (DfBTeam)ser.ReadObject(stream);

                return teamObj;
            }

            catch (WebException error)
            {
                DfBTeam failedObj = new DfBTeam();
                failedObj.cursor = error.Message;
                return failedObj;
            }
        }
Exemplo n.º 6
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            // Set cursor as hourglass
            Cursor.Current = Cursors.WaitCursor;

            //obtain basic api information
            BasicTeamInformation teamInformation = dfbBasicTeamInfo();
            //obtain team information
            DfBTeam dfbTeam = dfb_members_list();

            //if we connect to the api successfully:
            if (teamInformation.num_licenced_users >= 0)
            {
                labelTeamName.Text = "Connected to: " + teamInformation.name;
                pictureBoxConnected.SizeMode = PictureBoxSizeMode.Zoom;
                pictureBoxConnected.Image = imageList2.Images[1];
                //populate the global object for use throughout the app.
                gbl_TeamObject = dfbTeam;
                populateDfBMembers(gbl_TeamObject);
            }

            // Set cursor as default arrow
            Cursor.Current = Cursors.Default;
        }