Пример #1
0
        private void ContinueButton_Click(object sender, EventArgs e)
        {
            string URL = SiteText.Text;

            if (URL.Length > 8 && URL.Substring(0, 7) != "http://" && URL.Substring(0, 8) != "https://")
            {
                URL = "http://" + URL;
            }
            NetworkManager nm   = new NetworkManager(UsernameText.Text, PasswordText.Text, URL);
            string         user = "";

            try
            {
                user = nm.SendGetUsersRequest(1, 0);
            }
            catch (UriFormatException ex)
            {
                MessageBox.Show("The URL " + SiteText.Text + " is invalid.  Change it and try again", "URL Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    var response = ex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        if ((int)response.StatusCode == 401)
                        {
                            MessageBox.Show("Account info was rejected, change the info and try again.", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Could not complete request, error was " + (int)response.StatusCode + ".", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Something terrible has happened.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            IOfficeHelper.Instance.getAllDatabaseFieldsFromJson(user);

            var excelSelectForm = new ExcelSelectForm();

            excelSelectForm.Location = this.Location;
            excelSelectForm.Size     = this.Size;
            excelSelectForm.Show();
            this.Hide();
        }
Пример #2
0
        static void Main(string[] args)
        {
            bool windows = true;

            if (windows)
            {
                SiteSelectForm initialScreen = new SiteSelectForm();
                //TestForm initialScreen = new TestForm();

                Application.EnableVisualStyles();
                Application.Run(initialScreen);
            }
            else
            {
                string file = @"C:\Users\Ryan\Documents\Code\ExcelToIOffice\test.xlsx";

                ExcelManager em = ExcelManager.Instance;
                em.openFile(file);
                em.SetActiveSheet(1);
                em.setIgnoreFirstRow(true);

                ExcelUserModel um = new ExcelUserModel();
                um.addField("firstName", "a");
                um.addField("lastName", "c");
                um.addField("email", "d");
                um.addField("username", "g");

                JSONBuilder jb = new JSONBuilder(em, um);

                NetworkManager nm = new NetworkManager("training", "FMsite12", "https://clemson.ricohtrac.com");

                /*string json;
                 *
                 * while ((json = jb.getNextUserJson() ) != "NO MORE ROWS"){
                 *  System.Console.WriteLine("Pretending to send this to the network!");
                 *  //nm.SendAddUserRequest("", json);
                 * }*/

                /*string userJson = nm.SendGetUserRequest("62570");
                 * IOfficeUser user = JsonConvert.DeserializeObject<IOfficeUser>(usersJson);
                 * System.Console.WriteLine(user.lastName);
                 * IOfficeUser.UT.field[] fields = user.userType.fields;
                 * foreach(IOfficeUser.UT.field field in fields)
                 * {
                 *  System.Console.WriteLine(field.id + ": " + field.name);
                 * }*/

                Console.WriteLine("about to start network");

                Console.WriteLine("network done, about to get ids into array");

                List <int> ids          = new List <int>(0);
                int        startAt      = 0;
                int        increment    = 50;
                string     allUsersJSON = nm.SendGetUsersRequest(increment, startAt);
                do
                {
                    IOfficeTools.addIdsFromJSON(ids, allUsersJSON);
                    startAt     += increment;
                    allUsersJSON = nm.SendGetUsersRequest(increment, startAt);
                    Console.WriteLine("size is now " + ids.Count());
                } while (allUsersJSON != "[]");

                Console.WriteLine("ids are in array, lets sort");
                ids.Sort();
                Console.WriteLine("ids are done sorting, lets print");

                foreach (int id in ids)
                {
                    Console.WriteLine("id: " + id);
                }

                Console.Read();
            }
        }