コード例 #1
0
        public void UpdateTitleBarTeamStats()
        {
            int    licensed    = 0;
            int    provisioned = 0;
            string name        = string.Empty;

            //do a call to get team info
            IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion);

            service.GetInfoUrl       = ApplicationResource.ActionGetInfo;
            service.UserAgentVersion = ApplicationResource.UserAgent;
            string AccessToken = ApplicationResource.DefaultAccessToken;

            IDataResponse response = service.GetInfo(AccessToken);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                if (response.Data != null)
                {
                    string  data     = response.Data.ToString();
                    dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data);

                    name        = jsonData["name"];
                    licensed    = jsonData["num_licensed_users"];
                    provisioned = jsonData["num_provisioned_users"];
                }
            }
            //get toolkit version and build title text
            string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            this.Text = "Dropbox Business Admin Toolkit v" + version + "            Team: " + name + "       Licensed Users: " + licensed.ToString() + "       Provisioned Users: " + provisioned.ToString();
            this.Update();
            this.Refresh();
        }
コード例 #2
0
        public void UpdateTitleBarTeamStats()
        {
            int licensed = 0;
            int provisioned = 0;
            string name = string.Empty;

            //do a call to get team info
            IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion);
            service.GetInfoUrl = ApplicationResource.ActionGetInfo;
            service.UserAgentVersion = ApplicationResource.UserAgent;
            string AccessToken = ApplicationResource.DefaultAccessToken;

            IDataResponse response = service.GetInfo(AccessToken);
            if (response.StatusCode == HttpStatusCode.OK)
            {
                if (response.Data != null)
                {
                    string data = response.Data.ToString();
                    dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data);

                    name = jsonData["name"];
                    licensed = jsonData["num_licensed_users"];
                    provisioned = jsonData["num_provisioned_users"];
                }
            }
            //get toolkit version and build title text
            string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            this.Text = "Dropbox Business Admin Toolkit v" + version + "            Team: " + name + "       Licensed Users: " + licensed.ToString() + "       Provisioned Users: " + provisioned.ToString();
            this.Update();
            this.Refresh();
        }
コード例 #3
0
        private void RefreshHealth(ITeamHealthModel model, IMainPresenter presenter)
        {
            string fileAccessToken = ApplicationResource.DefaultAccessToken;
            //set default values so we have something
            int    licensed                = 0;
            int    provisioned             = 0;
            string name                    = string.Empty;
            string activityStartDate       = string.Empty;
            int    adds                    = 0;
            int    edits                   = 0;
            int    deletes                 = 0;
            int    activeSharedFolders7Day = 0;
            int    activeUsers7Day         = 0;
            string devicesStartDate        = string.Empty;
            int    windows                 = 0;
            int    macos                   = 0;
            int    linux                   = 0;
            int    ios              = 0;
            int    android          = 0;
            int    other            = 0;
            int    total            = 0;
            string storageStartDate = string.Empty;
            UInt64 totalStorage     = 0;
            UInt64 sharedStorage    = 0;
            UInt64 unsharedStorage  = 0;
            int    sharedFolders    = 0;

            IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion);

            service.GetInfoUrl       = ApplicationResource.ActionGetInfo;
            service.UserAgentVersion = ApplicationResource.UserAgent;
            IDataResponse response = service.GetInfo(fileAccessToken);

            IMemberServices serviceActivity = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion);

            serviceActivity.GetActivityUrl   = ApplicationResource.ActionGetActivity;
            serviceActivity.UserAgentVersion = ApplicationResource.UserAgent;
            IDataResponse responseActivity = serviceActivity.GetActivity(fileAccessToken);

            IMemberServices serviceDevices = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion);

            serviceDevices.GetDevicesReportUrl = ApplicationResource.ActionGetDevices;
            serviceDevices.UserAgentVersion    = ApplicationResource.UserAgent;
            IDataResponse responseDevices = serviceDevices.GetDevicesReport(fileAccessToken);

            IMemberServices serviceStorage = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion);

            serviceStorage.GetStorageUrl    = ApplicationResource.ActionGetStorage;
            serviceStorage.UserAgentVersion = ApplicationResource.UserAgent;
            IDataResponse responseStorage = serviceStorage.GetStorage(fileAccessToken);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                if (response.Data != null)
                {
                    string  data     = response.Data.ToString();
                    dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data);

                    name                   = jsonData["name"];
                    licensed               = jsonData["num_licensed_users"];
                    provisioned            = jsonData["num_provisioned_users"];
                    model.TeamName         = name;
                    model.LicensedUsers    = licensed.ToString();
                    model.ProvisionedUsers = provisioned.ToString();
                }
            }
            if (responseActivity.StatusCode == HttpStatusCode.OK)
            {
                if (responseActivity.Data != null)
                {
                    string  data     = responseActivity.Data.ToString();
                    dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data);

                    activityStartDate = jsonData["start_date"];
                    if (jsonData["adds"][0] != null)
                    {
                        try
                        {
                            int  availableData = 1;
                            bool complete      = false;
                            while (!complete)
                            {
                                if (((jsonData["adds"].Count) - availableData) != null)
                                {
                                    int addsCount = (jsonData["adds"].Count) - availableData;
                                    if (jsonData["adds"][addsCount] != null)
                                    {
                                        adds     = jsonData["adds"][addsCount];
                                        complete = true;
                                    }
                                }
                                availableData++;
                            }
                        }
                        catch
                        {
                            adds = 0;
                        }
                    }
                    if (jsonData["edits"][0] != null)
                    {
                        try
                        {
                            int  availableData = 1;
                            bool complete      = false;
                            while (!complete)
                            {
                                if (((jsonData["edits"].Count) - availableData) != null)
                                {
                                    int editsCount = (jsonData["edits"].Count) - availableData;
                                    if (jsonData["edits"][editsCount] != null)
                                    {
                                        edits = jsonData["edits"][editsCount];
                                    }
                                    complete = true;
                                }
                                availableData++;
                            }
                        }
                        catch
                        {
                            edits = 0;
                        }
                    }
                    if (jsonData["deletes"][0] != null)
                    {
                        try
                        {
                            int  availableData = 1;
                            bool complete      = false;
                            while (!complete)
                            {
                                if (((jsonData["deletes"].Count) - availableData) != null)
                                {
                                    int deletesCount = (jsonData["deletes"].Count) - availableData;
                                    if (jsonData["deletes"][deletesCount] != null)
                                    {
                                        deletes = jsonData["deletes"][deletesCount];
                                    }
                                    complete = true;
                                }
                                availableData++;
                            }
                        }
                        catch
                        {
                            deletes = 0;
                        }
                    }
                    if (jsonData["active_shared_folders_7_day"][0] != null)
                    {
                        try
                        {
                            int  availableData = 1;
                            bool complete      = false;
                            while (!complete)
                            {
                                if (((jsonData["active_shared_folders_7_day"].Count) - availableData) != null)
                                {
                                    int activeSharedCount = (jsonData["active_shared_folders_7_day"].Count) - availableData;
                                    if (jsonData["active_shared_folders_7_day"][activeSharedCount] != null)
                                    {
                                        activeSharedFolders7Day = jsonData["active_shared_folders_7_day"][activeSharedCount];
                                    }
                                    complete = true;
                                }
                                availableData++;
                            }
                        }
                        catch
                        {
                            activeSharedFolders7Day = 0;
                        }
                    }
                    if (jsonData["active_users_7_day"][0] != null)
                    {
                        try
                        {
                            int  availableData = 1;
                            bool complete      = false;
                            while (!complete)
                            {
                                if (((jsonData["active_users_7_day"].Count) - availableData) != null)
                                {
                                    int activeUsers = (jsonData["active_users_7_day"].Count) - availableData;
                                    if (jsonData["active_users_7_day"][activeUsers] != null)
                                    {
                                        activeUsers7Day = jsonData["active_users_7_day"][activeUsers];
                                    }
                                    complete = true;
                                }
                                availableData++;
                            }
                        }
                        catch
                        {
                            activeUsers7Day = 0;
                        }
                    }
                    model.Adds    = adds.ToString();
                    model.Edits   = edits.ToString();
                    model.Deletes = deletes.ToString();
                    model.ActiveSharedFolders7Day = activeSharedFolders7Day.ToString();
                    model.ActiveUsers7Day         = activeUsers7Day.ToString();
                }
            }
            if (responseDevices.StatusCode == HttpStatusCode.OK)
            {
                if (responseDevices.Data != null)
                {
                    string  data     = responseDevices.Data.ToString();
                    dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data);

                    devicesStartDate = jsonData["start_date"];
                    if (jsonData["active_7_day"] != null)
                    {
                        if (jsonData["active_7_day"]["windows"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["windows"].Count) - availableData) != null)
                                    {
                                        int windowsUsers = (jsonData["active_7_day"]["windows"].Count) - availableData;
                                        if (jsonData["active_7_day"]["windows"][windowsUsers] != null)
                                        {
                                            windows = jsonData["active_7_day"]["windows"][windowsUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                windows = 0;
                            }
                        }
                        if (jsonData["active_7_day"]["macos"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["macos"].Count) - availableData) != null)
                                    {
                                        int macosUsers = (jsonData["active_7_day"]["macos"].Count) - availableData;
                                        if (jsonData["active_7_day"]["macos"][macosUsers] != null)
                                        {
                                            macos = jsonData["active_7_day"]["macos"][macosUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                macos = 0;
                            }
                        }
                        if (jsonData["active_7_day"]["linux"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["linux"].Count) - availableData) != null)
                                    {
                                        int linuxUsers = (jsonData["active_7_day"]["linux"].Count) - availableData;
                                        if (jsonData["active_7_day"]["linux"][linuxUsers] != null)
                                        {
                                            linux = jsonData["active_7_day"]["linux"][linuxUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                linux = 0;
                            }
                        }
                        if (jsonData["active_7_day"]["ios"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["ios"].Count) - availableData) != null)
                                    {
                                        int iosUsers = (jsonData["active_7_day"]["ios"].Count) - availableData;
                                        if (jsonData["active_7_day"]["ios"][iosUsers] != null)
                                        {
                                            ios = jsonData["active_7_day"]["ios"][iosUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                ios = 0;
                            }
                        }
                        if (jsonData["active_7_day"]["android"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["android"].Count) - availableData) != null)
                                    {
                                        int androidUsers = (jsonData["active_7_day"]["android"].Count) - availableData;
                                        if (jsonData["active_7_day"]["android"][androidUsers] != null)
                                        {
                                            android = jsonData["active_7_day"]["android"][androidUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                android = 0;
                            }
                        }
                        if (jsonData["active_7_day"]["other"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["other"].Count) - availableData) != null)
                                    {
                                        int otherUsers = (jsonData["active_7_day"]["other"].Count) - availableData;
                                        if (jsonData["active_7_day"]["other"][otherUsers] != null)
                                        {
                                            other = jsonData["active_7_day"]["other"][otherUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                other = 0;
                            }
                        }
                        if (jsonData["active_7_day"]["total"][0] != null)
                        {
                            try
                            {
                                int  availableData = 1;
                                bool complete      = false;
                                while (!complete)
                                {
                                    if (((jsonData["active_7_day"]["total"].Count) - availableData) != null)
                                    {
                                        int totalUsers = (jsonData["active_7_day"]["total"].Count) - availableData;
                                        if (jsonData["active_7_day"]["total"][totalUsers] != null)
                                        {
                                            total = jsonData["active_7_day"]["total"][totalUsers];
                                        }
                                        complete = true;
                                    }
                                    availableData++;
                                }
                            }
                            catch
                            {
                                total = 0;
                            }
                        }
                    }
                    model.windows = windows.ToString();
                    model.macos   = macos.ToString();
                    model.linux   = linux.ToString();
                    model.ios     = ios.ToString();
                    model.android = android.ToString();
                    model.other   = other.ToString();
                    model.total   = total.ToString();
                }
            }
            if (responseStorage.StatusCode == HttpStatusCode.OK)
            {
                if (responseStorage.Data != null)
                {
                    string  data     = responseStorage.Data.ToString();
                    dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data);

                    storageStartDate = jsonData["start_date"];
                    if (jsonData["total_usage"][0] != null)
                    {
                        int  availableData = 1;
                        bool complete      = false;
                        while (!complete)
                        {
                            if (((jsonData["total_usage"].Count) - availableData) != null)
                            {
                                int totalCount = (jsonData["total_usage"].Count) - availableData;
                                if (jsonData["total_usage"][totalCount] != null)
                                {
                                    totalStorage = jsonData["total_usage"][totalCount];
                                    double totalStorageDec = FileUtil.FormatFileSizeTB(totalStorage);
                                    model.TotalUsage = totalStorageDec.ToString() + " TB";
                                    complete         = true;
                                }
                            }
                            availableData++;
                        }
                    }
                    if (jsonData["shared_usage"][0] != null)
                    {
                        int  availableData = 1;
                        bool complete      = false;
                        while (!complete)
                        {
                            if (((jsonData["shared_usage"].Count) - availableData) != null)
                            {
                                int sharedCount = (jsonData["shared_usage"].Count) - availableData;
                                if (jsonData["shared_usage"][sharedCount] != null)
                                {
                                    sharedStorage = jsonData["shared_usage"][sharedCount];
                                    double sharedStorageDec = FileUtil.FormatFileSizeTB(sharedStorage);
                                    model.SharedUsage = sharedStorageDec.ToString() + " TB";
                                    complete          = true;
                                }
                            }
                            availableData++;
                        }
                    }
                    if (jsonData["unshared_usage"][0] != null)
                    {
                        int  availableData = 1;
                        bool complete      = false;
                        while (!complete)
                        {
                            if (((jsonData["unshared_usage"].Count) - availableData) != null)
                            {
                                int unsharedCount = (jsonData["unshared_usage"].Count) - availableData;
                                if (jsonData["unshared_usage"][unsharedCount] != null)
                                {
                                    unsharedStorage = jsonData["unshared_usage"][unsharedCount];
                                    double unsharedStorageDec = FileUtil.FormatFileSizeTB(unsharedStorage);
                                    model.UnsharedUsage = unsharedStorageDec.ToString() + " TB";
                                    complete            = true;
                                }
                            }
                            availableData++;
                        }
                    }
                    if (jsonData["shared_folders"][0] != null)
                    {
                        int  availableData = 1;
                        bool complete      = false;
                        while (!complete)
                        {
                            if (((jsonData["shared_usage"].Count) - availableData) != null)
                            {
                                int sharedFolderCount = (jsonData["shared_folders"].Count) - availableData;
                                if (jsonData["shared_folders"][sharedFolderCount] != null)
                                {
                                    sharedFolders       = jsonData["shared_folders"][sharedFolderCount];
                                    model.SharedFolders = sharedFolders.ToString();
                                    complete            = true;
                                }
                            }
                            availableData++;
                        }
                    }
                }
            }
            if (responseStorage.StatusCode != HttpStatusCode.OK)
            {
                //if Dropbox gives back Internal Server error, bug filed from engineering on this
                model.TotalUsage    = "N/A";
                model.SharedUsage   = "N/A";
                model.UnsharedUsage = "N/A";
                model.SharedFolders = "N/A";
            }
            model.RefreshDateTime = DateTime.Now;
        }