Example #1
0
        /// <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
            {
                IKetarinRpc proxy = XmlRpcProxyGen.Create <IKetarinRpc>();
                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.
            }
        }
Example #2
0
        private void bSearch_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                IKetarinRpc proxy = XmlRpcProxyGen.Create <IKetarinRpc>();
                m_LastLoadedApplications     = proxy.GetApplications(txtSearchSubject.Text);
                m_LastSearchText             = txtSearchSubject.Text;
                Applications                 = m_LastLoadedApplications;
                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
            {
                Cursor = Cursors.Default;
            }
        }
Example #3
0
        private void bTop50_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                IKetarinRpc proxy = XmlRpcProxyGen.Create <IKetarinRpc>();
                m_LastLoadedApplications = proxy.GetMostDownloadedApplications();
                m_LastSearchText         = string.Empty;
                olvApplications.Sort(colUseCount);
                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
            {
                Cursor = Cursors.Default;
            }
        }
Example #4
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
            {
                IKetarinRpc proxy       = XmlRpcProxyGen.Create <IKetarinRpc>();
                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);
            }
        }
Example #5
0
        private void cmnuProperties_Click(object sender, EventArgs e)
        {
            if (olvApplications.SelectedObject == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

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

                IKetarinRpc    proxy     = XmlRpcProxyGen.Create <IKetarinRpc>();
                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;
            }
        }
Example #6
0
        private void bOK_Click(object sender, EventArgs e)
        {
            // Check that name is not empty
            if (string.IsNullOrEmpty(txtApplicationName.Text))
            {
                MessageBox.Show(this, "The application name must not be empty.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                return;
            }

            // Check for valid URL
            if (rbFixedUrl.Checked && string.IsNullOrEmpty(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(txtTarget.Text))
                {
                    MessageBox.Show(this, "You did not specify a target location.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            if (rbFileHippo.Checked && String.IsNullOrEmpty(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);
                DialogResult = DialogResult.None;
                return;
            }

            WriteApplication();

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

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

                try
                {
                    IKetarinRpc proxy = XmlRpcProxyGen.Create <IKetarinRpc>();
                    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();
                        dialog.ApplicationJob = job;
                        dialog.Applications   = existingApps;
                        if (dialog.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }
                    }

                    // Everything is fine, upload now.
                    Thread thread = new Thread(new ParameterizedThreadStart(ShareOnline));
                    thread.IsBackground = true;
                    thread.Start(job);
                }
                catch (System.Net.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
                {
                    Cursor = Cursors.Default;
                }
            }

            // Required for non modal call
            this.Close();
        }
Example #7
0
        private void bOK_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                foreach (RpcApplication app in olvApplications.SelectedObjects)
                {
                    IKetarinRpc    proxy     = XmlRpcProxyGen.Create <IKetarinRpc>();
                    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();
                    m_ImportedApplication = resultJob;

                    // Real value is determined while saving
                    if (!resultJob.CanBeShared)
                    {
                        resultJob.DownloadDate     = app.UpdatedAtDate;
                        resultJob.ExecuteCommand   = 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);
                DialogResult = DialogResult.None;
            }
            catch (WebException ex)
            {
                MessageBox.Show(this, "Could not connect to the online database: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }