protected void LoadUserData()
        {
            var    credentials = GetCredentialsFrom(User.Identity.Name);
            string path        = string.Format(
                options.AlbaUsersHtmlPath,
                credentials.AlbaAccountId);

            if (io.File.Exists(path))
            {
                io.File.Delete(path);
            }

            var client = AuthClient();

            client.Authenticate(credentials);

            var assignedHtml = client.DownloadString(
                RelativeUrlBuilder.GetTerritoryAssignmentsPage());

            string usersHtml = cuc.DownloadUsers.GetUsersHtml(assignedHtml);

            if (!io.Directory.Exists(io.Path.GetDirectoryName(path)))
            {
                io.Directory.CreateDirectory(io.Path.GetDirectoryName(path));
            }

            io.File.WriteAllText(path, usersHtml);
        }
Пример #2
0
        public void SaveAs(string fileName)
        {
            // Downloads html instead of json Territory Assignments
            var resultString = client.DownloadString(
                RelativeUrlBuilder.GetTerritoryAssignmentsPage());

            List <User> users = GetUsers(GetUsersHtml(resultString));

            using (var writer = new StreamWriter(fileName))
                using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))

                {
                    csv.WriteRecords(users);
                }
        }
        void LoadUserData(Guid albaAccountId)
        {
            string path = string.Format(options.AlbaUsersHtmlPath, albaAccountId);

            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
            }

            // TODO: Get credentials with albaAccountId
            var credentials = albaCredentialService.GetCredentialsFrom(User.Identity.Name);

            var client = AuthorizationClient();

            client.Authenticate(credentials);

            var assignedHtml = client.DownloadString(
                RelativeUrlBuilder.GetTerritoryAssignmentsPage());

            string usersHtml = cuc.DownloadUsers.GetUsersHtml(assignedHtml);

            System.IO.File.WriteAllText(path, usersHtml);
        }