Esempio n. 1
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (txtDiskName.Text == "")
            {
                lblDiskName.ForeColor = System.Drawing.Color.Red;
                return;
            }

            using (StoragesDB _db = new StoragesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from STORAGES where STORAGENAME=`" + txtDiskName.Text + "`");
                if (_dt.Rows.Count != 0)
                {
                    lblDiskNameExists.Text = MMUtils.GetString("newnetworkdiskdlg.lblDiskNameExists.text");
                    return;
                }

                _db.ExecuteNonQuery("insert into STORAGES values(" +
                                    "`" + txtDiskName.Text + "`," +
                                    "`" + "networkdisk" + "`," +
                                    "``, ``, ``, ``, 0, 0)");
            }

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            // Storage name is empty
            if (txtNewStorageName.Text == "")
            {
                lblNewStorageName.ForeColor = System.Drawing.Color.Red;
                return;
            }

            // Process field is empty
            if (txtProcess.Text == "")
            {
                lblProcess.ForeColor = System.Drawing.Color.Red;
                return;
            }

            // Site url is empty
            if (txtSiteUrl.Text == "")
            {
                lblSiteUrl.ForeColor = System.Drawing.Color.Red;
                return;
            }

            string aProcess     = txtProcess.Text;
            string aStorageName = txtNewStorageName.Text;

            if (aProcess.Length > 4 && aProcess.Substring(aProcess.Length - 4) == ".exe")
            {
                aProcess = aProcess.Substring(0, aProcess.Length - 4);
            }

            // If Storage with this name exists
            using (StoragesDB _db = new StoragesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from STORAGES where STORAGENAME=`" + aStorageName + "`");
                if (_dt.Rows.Count != 0)
                {
                    lblNameExists.Text = MMUtils.GetString("newcloudstoragedlg.lblNameExists.text");
                    return;
                }
            }

            // Storage App verification failed
            if (!System.Diagnostics.Process.GetProcessesByName(aProcess).Any())
            {
                MessageBox.Show(
                    String.Format(MMUtils.GetString("newcloudstoragedlg.messagebox.text"), aStorageName),
                    MMUtils.GetString("newcloudstoragedlg.messagebox.caption"),
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Verify website
            using (SiteVerificationDlg _dlg = new SiteVerificationDlg(txtSiteUrl.Text))
            {
                if (_dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd)) == DialogResult.Cancel)
                {
                    return;
                }
            }

            using (StoragesDB _db = new StoragesDB())
            {
                string _type = "cloud";
                _db.ExecuteNonQuery("INSERT INTO STORAGES VALUES(" +
                                    "`" + aStorageName + "`," +
                                    "`" + aProcess + "`," +
                                    "`" + txtSiteUrl.Text + "`," +
                                    "`" + _type + "`, ``, ``, 0, 0)");
            }

            this.DialogResult = DialogResult.OK;
        }