/// <summary>
        /// Delete a query from the stored service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <returns>
        /// True if the delete query method is successful.
        /// </returns>
        public bool DeleteQuery(IGbdxComms comms, NetObject netObject)
        {
            try
            {
                // Login in prior to sending a delete
                if (!comms.AuthenticateNetworkObject(ref netObject))
                {
                    return false;
                }

                // Send the delete request to the service.
                var output = comms.DeleteRequest(netObject);

                // Check the response status code
                if (output.ResponseStatusCode != HttpStatusCode.NoContent && output.ResponseStatusCode != HttpStatusCode.OK)
                {
                    return false;
                }
            }
            catch
            {
                // Any errors occur return false.
                return false;
            }

            // Everything is all good.
            return true;
        }
示例#2
0
        /// <summary>
        /// Delete a query from the stored service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <returns>
        /// True if the delete query method is successful.
        /// </returns>
        public bool DeleteQuery(IGbdxComms comms, NetObject netObject)
        {
            try
            {
                // Login in prior to sending a delete
                if (!comms.AuthenticateNetworkObject(ref netObject))
                {
                    return(false);
                }

                // Send the delete request to the service.
                var output = comms.DeleteRequest(netObject);

                // Check the response status code
                if (output.ResponseStatusCode != HttpStatusCode.NoContent && output.ResponseStatusCode != HttpStatusCode.OK)
                {
                    return(false);
                }
            }
            catch
            {
                // Any errors occur return false.
                return(false);
            }

            // Everything is all good.
            return(true);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormConfiguration"/> class.
        /// </summary>
        public FormConfiguration()
        {
            this.InitializeComponent();

            // Events for when the text box gets and loses focus
            this.apiKeyRichTextBox.LostFocus   += this.ApiKeyRichTextBoxLostFocus;
            this.apiKeyRichTextBox.TextChanged += this.ApiKeyRichTextBoxTextChanged;
            this.apiKeyRichTextBox.LinkClicked += this.ApiKeyRichTextBoxLinkClicked;

            // If the setting is not set default to my documents otherwise load the setting
            if (string.IsNullOrEmpty(Settings.Default.geoDatabase))
            {
                Settings.Default.geoDatabase      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                this.fileGdbDirectoryTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }
            else
            {
                this.fileGdbDirectoryTextBox.Text = Settings.Default.geoDatabase;
            }


            if (string.IsNullOrEmpty(Settings.Default.AuthBase))
            {
                this.authTextBox.Text = Settings.Default.DefaultAuthBase;
            }
            else
            {
                this.authTextBox.Text = Settings.Default.AuthBase;
            }

            if (string.IsNullOrEmpty(Settings.Default.apiKey))
            {
                // setup api key textbox text and initial color
                this.apiKeyRichTextBox.Text      = GbdxResources.whereToGetApiKey;
                this.apiKeyRichTextBox.ForeColor = Color.DarkGray;
            }
            else
            {
                this.apiKeyRichTextBox.Text = Settings.Default.apiKey;
            }

            this.UserNameTextBox.Text = Settings.Default["username"].ToString();

            var tempPassword = string.Empty;

            if (Aes.Instance.Decrypt128(Settings.Default["password"].ToString(), out tempPassword))
            {
                this.PasswordTextBox.Text = tempPassword;
            }

            // Set the base url text box.
            this.urlTextBox.Text = string.IsNullOrEmpty(Settings.Default.baseUrl) ? Settings.Default.DefaultBaseUrl : Settings.Default.baseUrl;

            this.comms = new GbdxComms();
        }
示例#4
0
        /// <summary>
        /// Get the queries stored in the stored query service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <returns>
        /// List of queries stored in the service.
        /// </returns>
        public List <SavedQuery> GetQueries(IGbdxComms comms, NetObject netObject)
        {
            var output = comms.Request(netObject);

            // Request was good but no data was found.
            if (output.ResponseStatusCode == HttpStatusCode.NoContent || output.ErrorOccurred)
            {
                return(null);
            }

            var queries = JsonConvert.DeserializeObject <List <SavedQuery> >(output.Result);

            queries.ForEach(item => item.SetDateTime());
            return(queries);
        }
示例#5
0
        /// <summary>
        /// Add/Update a query with the stored query service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <param name="itemToAddUpdate">
        /// The item to add update.
        /// </param>
        /// <returns>
        /// True if the update/add was successful.
        /// </returns>
        public bool UpdateQuery(IGbdxComms comms, NetObject netObject, SavedQuery itemToAddUpdate)
        {
            try
            {
                // Serialize the workspace
                var serializedWorkspace = JsonConvert.SerializeObject(itemToAddUpdate, Formatting.None);

                // Send the request to the stored query service.
                var response = comms.PushRequest(netObject, serializedWorkspace);

                // Check to see if the response object is null.
                if (response == null)
                {
                    return(false);
                }

                // Return the status of the update to the user.
                return(response.ResponseStatusCode == HttpStatusCode.OK);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormConfiguration"/> class.
        /// </summary>
        public FormConfiguration()
        {
            this.InitializeComponent();

            // Events for when the text box gets and loses focus
            this.apiKeyRichTextBox.LostFocus += this.ApiKeyRichTextBoxLostFocus;
            this.apiKeyRichTextBox.TextChanged += this.ApiKeyRichTextBoxTextChanged;
            this.apiKeyRichTextBox.LinkClicked += this.ApiKeyRichTextBoxLinkClicked;

            // If the setting is not set default to my documents otherwise load the setting
            if (string.IsNullOrEmpty(Settings.Default.geoDatabase))
            {
                Settings.Default.geoDatabase = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                this.fileGdbDirectoryTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }
            else
            {
                this.fileGdbDirectoryTextBox.Text = Settings.Default.geoDatabase;
            }

            if (string.IsNullOrEmpty(Settings.Default.AuthBase))
            {
                this.authTextBox.Text = Settings.Default.DefaultAuthBase;
            }
            else
            {
                this.authTextBox.Text = Settings.Default.AuthBase;
            }

            if (string.IsNullOrEmpty(Settings.Default.apiKey))
            {
                // setup api key textbox text and initial color
                this.apiKeyRichTextBox.Text = GbdxResources.whereToGetApiKey;
                this.apiKeyRichTextBox.ForeColor = Color.DarkGray;
            }
            else
            {
                this.apiKeyRichTextBox.Text = Settings.Default.apiKey;
            }

            this.UserNameTextBox.Text = Settings.Default["username"].ToString();

            var tempPassword = string.Empty;

            if (Aes.Instance.Decrypt128(Settings.Default["password"].ToString(), out tempPassword))
            {
                this.PasswordTextBox.Text = tempPassword;
            }

            // Set the base url text box.
            this.urlTextBox.Text = string.IsNullOrEmpty(Settings.Default.baseUrl) ? Settings.Default.DefaultBaseUrl : Settings.Default.baseUrl;

            this.comms = new GbdxComms();
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoredQuery"/> class.
 /// </summary>
 public StoredQuery()
 {
     this.cloudComms = new GbdxComms();
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoredQuery"/> class.
 /// </summary>
 /// <param name="comms">
 /// Interface that defines how to talk with GBDX Cloud services. <see cref="IGbdxComms"/>
 /// </param>
 public StoredQuery(IGbdxComms comms)
 {
     this.cloudComms = comms;
 }
 public VectorUpload()
 {
     this.comms = new GbdxComms(Jarvis.LogFile, false);
     this.logger = new Logger(Jarvis.LogFile, false);
 }
示例#10
0
 public VectorUpload()
 {
     this.comms  = new GbdxComms(Jarvis.LogFile, false);
     this.logger = new Logger(Jarvis.LogFile, false);
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="GbdDockableWindow" /> class.
        /// </summary>
        /// <param name="hook">
        ///     The hook.
        /// </param>
        public GbdDockableWindow(object hook)
        {
            // Check to make sure there are credentials for GBD account.
            if (string.IsNullOrEmpty(Settings.Default.username) || string.IsNullOrEmpty(Settings.Default.password))
            {
                MessageBox.Show(GbdxResources.InvalidUserPass);
                return;
            }

            string pass;
            var result = Aes.Instance.Decrypt128(Settings.Default.password, out pass);
            if (result)
            {
                this.token = GetAccessToken(Settings.Default.apiKey, Settings.Default.username, pass);
            }
            else
            {
                MessageBox.Show("Problem decrypting password");
            }

            // Initialize GBD Communications and authorize with GBD authentication.
            this.comms = new GbdxComms(Jarvis.LogFile, false);

            this.InitializeComponent();
            this.VisibleChanged += this.GbdDockableWindowVisibleChanged;
            this.Hook = hook;
            GbdRelay.Instance.AoiHasBeenDrawn += this.InstanceAoiHasBeenDrawn;

            this.localDatatable = this.CreateDataTable();

            this.dataGridView1.CellFormatting += this.EventHandlerCellFormatting;

            this.workQueue = Queue.Synchronized(new Queue());
            this.dataView = new DataView(this.localDatatable);

            this.dataGridView1.DataSource = this.dataView;

            var dataGridViewColumnHeaderStyle = new DataGridViewCellStyle();
            dataGridViewColumnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewColumnHeaderStyle;

            var dataGridViewColumn = this.dataGridView1.Columns["Pan"];
            if (dataGridViewColumn != null)
            {
                dataGridViewColumn.CellTemplate = new DataGridViewDisableCheckBoxCell();
            }

            var dataGridViewColumnMs = this.dataGridView1.Columns["MS"];
            if (dataGridViewColumnMs != null)
            {
                dataGridViewColumnMs.CellTemplate = new DataGridViewDisableCheckBoxCell();
            }
            // Set the current DateTime to last year
            this.fromDateTimePicker.Value = DateTime.Now.AddMonths(-1);
            this.startTime = DateTime.Now.AddMonths(-1);
            this.toDateTimePicker.Value = DateTime.Now;
            this.endTime = DateTime.Now;

            this.dataGridView1.CellClick += this.DataGridView1SelectionChanged;
            this.allResults = new Dictionary<string, Properties>();

            this.thumbnailPictureBox.LoadCompleted += this.ThumbnailPictureBoxLoadCompleted;
            this.cachedImages = new Dictionary<string, Image>();
            this.thumbnailPictureBox.InitialImage = new Bitmap(GbdxResources.PleaseStandBy, new Size(309, 376));

            this.displayAllPolgons = false;

            // Initialize the hashset and dictionary required for displaying mass polygons.
            this.userSelectedPolygons = new HashSet<string>();

            this.dataGridView1.CellContentClick += this.EventHandlerCellContentClick;
            this.usedIdahoIds = new Dictionary<string, string>();
            try
            {
                this.cbHeader = new DataGridViewCheckBoxHeaderCell();

                if (this.dataGridView1.Columns["Selected"] != null)
                {
                    this.dataGridView1.Columns["Selected"].HeaderCell = this.cbHeader;

                    // Change the column width to something more reasonable.
                    this.dataGridView1.Columns["Selected"].Width = 29;
                }
            }
            catch (Exception error)
            {
                Jarvis.Logger.Error(error);
            }

            this.exportButton.Text = Settings.Default.baseUrl.Equals(Settings.Default.DefaultBaseUrl)
                                         ? "Export"
                                         : "Order";

            this.dataView.RowFilter = this.FilterSetup();
            this.SetupOrderStatusTable();

            // Allocate the memory for the object even if we don't have orders yet
            this.gbdOrderList = new List<GbdOrder>();

            // If we have orders saved then lets load them up
            if (File.Exists(this.filePath))
            {
                this.gbdOrderList = this.LoadGbdOrdersFromFile(this.filePath);
                UpdateOrderTable(this.gbdOrderList, ref this.orderTable);
            }

            this.MouseLeave += this.GbdDockableWindowMouseLeave;
            this.dataGridView1.MouseLeave += this.GbdDockableWindowMouseLeave;
        }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoredQuery"/> class.
 /// </summary>
 public StoredQuery()
 {
     this.cloudComms = new GbdxComms();
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoredQuery"/> class.
 /// </summary>
 /// <param name="comms">
 /// Interface that defines how to talk with GBDX Cloud services. <see cref="IGbdxComms"/> 
 /// </param>
 public StoredQuery(IGbdxComms comms)
 {
     this.cloudComms = comms;
 }
示例#14
0
        /// <summary>
        /// Add/Update a query with the stored query service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <param name="itemToAddUpdate">
        /// The item to add update.
        /// </param>
        /// <returns>
        /// True if the update/add was successful.
        /// </returns>
        public bool UpdateQuery(IGbdxComms comms, NetObject netObject, SavedQuery itemToAddUpdate)
        {
            try
            {
                // Serialize the workspace
                var serializedWorkspace = JsonConvert.SerializeObject(itemToAddUpdate,Formatting.None);

                // Send the request to the stored query service.
                var response = comms.PushRequest(netObject, serializedWorkspace);

                // Check to see if the response object is null.
                if (response == null)
                {
                    return false;
                }

                // Return the status of the update to the user.
                return response.ResponseStatusCode == HttpStatusCode.OK;
            }
            catch (Exception)
            {
                return false;
            }
        }
示例#15
0
        /// <summary>
        /// Get the queries stored in the stored query service.
        /// </summary>
        /// <param name="comms">
        /// <see cref="IGbdxComms"/> used for communicating with the stored query service.
        /// </param>
        /// <param name="netObject">
        /// the network object to be used in communicating with stored query service
        /// </param>
        /// <returns>
        /// List of queries stored in the service.
        /// </returns>
        public List<SavedQuery> GetQueries(IGbdxComms comms, NetObject netObject)
        {
            var output = comms.Request(netObject);

            // Request was good but no data was found.
            if (output.ResponseStatusCode == HttpStatusCode.NoContent || output.ErrorOccurred)
            {
                return null;
            }

            var queries = JsonConvert.DeserializeObject<List<SavedQuery>>(output.Result);
            queries.ForEach(item => item.SetDateTime());
            return queries;
        }