private void bSearch_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                IGeGeekRpc proxy = XmlRpcProxyGen.Create <IGeGeekRpc>();
                m_LastLoadedApplications          = proxy.GetApplications(this.txtSearchSubject.Text);
                m_LastSearchText                  = this.txtSearchSubject.Text;
                this.Applications                 = m_LastLoadedApplications;
                this.olvApplications.EmptyListMsg = "No applications found";
            }
            catch (XmlRpcException ex)
            {
                MessageBox.Show(this, "An error occured while accessing the online database: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (WebException ex)
            {
                MessageBox.Show(this, "Could not connect to the online database: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#2
0
        /// <summary>
        /// Checks for which of the given applications updates
        /// are available. Fires an event when finished.
        /// </summary>
        private void CheckForOnlineUpdates(object argument)
        {
            ApplicationJob[] jobs = argument as ApplicationJob[];

            // Build an array containing all GUIDs and dates
            List <RpcAppGuidAndDate> sendInfo = new List <RpcAppGuidAndDate>();

            foreach (ApplicationJob job in jobs.Where(job => !job.CanBeShared))
            {
                sendInfo.Add(new RpcAppGuidAndDate(job.Guid, job.DownloadDate));
            }

            if (sendInfo.Count == 0)
            {
                // Nothing to do
                return;
            }

            try
            {
                IGeGeekRpc proxy       = XmlRpcProxyGen.Create <IGeGeekRpc>();
                string[]   updatedApps = proxy.GetUpdatedApplications(sendInfo.ToArray());
                OnUpdatesFound(updatedApps);
            }
            catch (Exception ex)
            {
                // If updating fails, it does not hurt and should not annoy anyone.
                // Just write a log entry, just in case
                LogDialog.Log("Failed checking for online database updates", ex);
            }
        }
        private void bTop50_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                IGeGeekRpc proxy = XmlRpcProxyGen.Create <IGeGeekRpc>();
                m_LastLoadedApplications = proxy.GetMostDownloadedApplications();
                m_LastSearchText         = string.Empty;
                this.olvApplications.Sort(this.colUseCount);
                this.Applications = m_LastLoadedApplications;
            }
            catch (XmlRpcException ex)
            {
                MessageBox.Show(this, "An error occured while accessing the online database: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (WebException ex)
            {
                MessageBox.Show(this, "Could not connect to the online database: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        /// <summary>
        /// Uploads an application to the online database (as background thread).
        /// </summary>
        /// <param name="argument">The ApplicationJob which is to be uploaded</param>
        private static void ShareOnline(object argument)
        {
            ApplicationJob job = argument as ApplicationJob;

            if (job == null)
            {
                return;
            }

            try
            {
                IGeGeekRpc proxy = XmlRpcProxyGen.Create <IGeGeekRpc>();
                proxy.Timeout = 10000;

                proxy.SaveApplication(job.GetXmlWithoutGlobalVariables(), Settings.GetValue("AuthorGuid") as string);
            }
            catch (XmlRpcFaultException ex)
            {
                LogDialog.Log("Could not submit '" + job.Name + "' to the online database: " + ex.FaultString);
            }
            catch (Exception)
            {
                // No internet, server down, whatever. We don't have to care.
            }
        }
示例#5
0
        private void cmnuProperties_Click(object sender, EventArgs e)
        {
            if (olvApplications.SelectedObject == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            try
            {
                RpcApplication app = (RpcApplication)olvApplications.SelectedObject;

                IGeGeekRpc     proxy     = XmlRpcProxyGen.Create <IGeGeekRpc>();
                string         xml       = proxy.GetApplication(app.ShareId);
                ApplicationJob resultJob = ApplicationJob.LoadOneFromXml(xml);

                using (ApplicationJobDialog dialog = new ApplicationJobDialog())
                {
                    dialog.ApplicationJob = resultJob;
                    dialog.ReadOnly       = true;
                    dialog.ShowDialog(this);
                }
            }
            catch (XmlRpcException)
            {
                MessageBox.Show(this, "Failed loading the selected application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (WebException)
            {
                MessageBox.Show(this, "Failed loading the selected application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
        private void bOK_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                foreach (RpcApplication app in this.olvApplications.SelectedObjects)
                {
                    IGeGeekRpc     proxy     = XmlRpcProxyGen.Create <IGeGeekRpc>();
                    string         xml       = proxy.GetApplication(app.ShareId);
                    ApplicationJob resultJob = ApplicationJob.LoadOneFromXml(xml);
                    // For security reasons, we remove some of the properties
                    // if it's not the users own job
                    if (!DbManager.ApplicationExists(resultJob.Guid))
                    {
                        resultJob.CanBeShared = false;
                    }

                    resultJob.Save();
                    this.ImportedApplications.Add(resultJob);

                    // Real value is determined while saving
                    if (!resultJob.CanBeShared)
                    {
                        resultJob.DownloadDate      = app.UpdatedAtDate;
                        resultJob.ExecuteCommand    = string.Empty;
                        resultJob.ExecutePreCommand = string.Empty;
                        resultJob.TargetPath        = string.Empty;
                        resultJob.PreviousLocation  = string.Empty;

                        // If possible, determine some values based on the default
                        // values for a new application.
                        string defaultXml = Settings.GetValue("DefaultApplication", "") as string;
                        if (!string.IsNullOrEmpty(defaultXml))
                        {
                            ApplicationJob defaultApp = ApplicationJob.LoadOneFromXml(defaultXml);
                            if (defaultApp != null)
                            {
                                resultJob.TargetPath        = defaultApp.TargetPath;
                                resultJob.ExecuteCommand    = defaultApp.ExecuteCommand;
                                resultJob.ExecutePreCommand = defaultApp.ExecutePreCommand;
                            }
                        }

                        resultJob.Save();
                    }
                }
            }
            catch (XmlRpcException ex)
            {
                MessageBox.Show(this, "An error occured while importing applications: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
            }
            catch (WebException ex)
            {
                MessageBox.Show(this, "Could not connect to the online database: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void bOK_Click(object sender, EventArgs e)
        {
            // Check that name is not empty
            if (string.IsNullOrEmpty(this.txtApplicationName.Text))
            {
                MessageBox.Show(this, "The application name must not be empty.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
                return;
            }

            // Check for valid URL
            if (this.rbFixedUrl.Checked && string.IsNullOrEmpty(this.txtFixedUrl.Text))
            {
                MessageBox.Show(this, "You did not enter a download URL. The application will not be downloaded as long as no URL is specified.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                // Check that a target location is given
                if (string.IsNullOrEmpty(this.txtTarget.Text))
                {
                    MessageBox.Show(this, "You did not specify a target location.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.DialogResult = DialogResult.None;
                    return;
                }
            }

            if (this.rbFileHippo.Checked && String.IsNullOrEmpty(this.txtFileHippoId.Text))
            {
                MessageBox.Show(this, "You did not specify a FileHippo ID.\r\nYou can paste the desired URL from the FileHippo.com website, the ID will be extracted automatically.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
                return;
            }

            this.WriteApplication();

            // All good. If necessary, now start a thread
            // which is going to share the application online.
            ApplicationJob job = this.ApplicationJob;

            if (job.ShareApplication)
            {
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    IGeGeekRpc proxy = XmlRpcProxyGen.Create <IGeGeekRpc>();
                    proxy.Timeout = 10000;

                    RpcApplication[] existingApps = proxy.GetSimilarApplications(job.Name, job.Guid.ToString());
                    if (existingApps.Length > 0)
                    {
                        // Prevent similar entries by asking the author
                        // to reconsider his choice of name.
                        SimilarApplicationsDialog dialog = new SimilarApplicationsDialog
                        {
                            ApplicationJob = job,
                            Applications   = existingApps
                        };
                        if (dialog.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }
                    }

                    // Everything is fine, upload now.
                    Thread thread = new Thread(ShareOnline)
                    {
                        IsBackground = true
                    };
                    thread.Start(job);
                }
                catch (WebException ex)
                {
                    MessageBox.Show(this, "Your application could not be submitted to the online database because of an connection error: " + ex.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }

            // Required for non modal call
            this.Close();
        }