예제 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                checkIfFileExist(Application.StartupPath + "\\UpdateExeFile.zip");

                #region download the Update File from server
                Network network = new Network();
                try
                {
                    network.DownloadFile("http://kayakkitchen.com/privateeye/UpdateExeFile.zip", Application.StartupPath + "\\UpdateExeFile.zip");
                }
                catch (Exception ex)
                {
                    ErrorDump er = new ErrorDump();
                    er.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Critical, ex, "Unable to Download the Update File");
                }
                #endregion download the Update File from server

                #region unzip the file
                try
                {
                    ZipFile.ExtractToDirectory(Application.StartupPath + "\\UpdateExeFile.zip", Application.StartupPath);
                }
                catch (Exception ex)
                {
                    ErrorDump er = new ErrorDump();
                    er.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Critical, ex, "Unable to Extract the Update File");
                }
                #endregion unzip the file

                #region writeupdated Version No.
                XmlDocument xml = new XmlDocument();
                xml.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
                Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
                config.AppSettings.Settings.Remove("Version");
                config.AppSettings.Settings.Add("Version", serverVersion);
                config.Save(ConfigurationSaveMode.Minimal);
                xml.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
                ConfigurationManager.RefreshSection("appSettings");
                #endregion writeupdated Version No.

                File.Delete(Application.StartupPath + "\\updateVersionLog\\updateVersionLog.xml");
                File.Delete(Application.StartupPath + "\\UpdateExeFile.zip");
                Process.Start(Application.StartupPath + "\\updateHelper.exe");
                mailUpdateConfirmation(serverVersion);

                Application.Exit();
            }
            catch (Exception ex)
            {
                ErrorDump ed = new ErrorDump();
                ed.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Critical, ex, "Update Failed.");
                MessageBox.Show("Update Failed. Please try Again.", "Secusys - EID Update", MessageBoxButtons.OK);
            }
        }
예제 #2
0
        protected override void btnsave_Click(object sender, EventArgs e)
        {
            UserMasterSaver userMasterSaver = new UserMasterSaver();
            int USPUserid;

            if (string.IsNullOrEmpty(txtUsrname.Text) || string.IsNullOrEmpty(txtPass.Text) || string.IsNullOrEmpty(txtConPass.Text))
            {
                MessageBox.Show("Username and Password are Mandatory." + Environment.NewLine + "Please try again.", "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #region check if pass and con pass match
            if (string.Compare(txtConPass.Text, txtPass.Text) != 0)
            {
                MessageBox.Show("Password and Confirm Password do not match." + Environment.NewLine + "Please try again.", "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPass.Text = string.Empty;
                txtUsrname.Focus();
                txtUsrname.Text = string.Empty;
                txtConPass.Text = string.Empty;
                return;
            }
            #endregion check if pass and con pass match

            #region InsertUserPrivileges
            if (UpdateState != true)
            {
                try
                {

                    userMasterSaver.insertUserPrivileges(txtUsrname.Text, txtPass.Text);
                    USPUserid = userMasterSaver.fetchEmpID(txtUsrname.Text);
                    for (int i = 0; i < this.chklstbx.Items.Count; i++)
                    {
                        userMasterSaver.insertUserAttribute(USPUserid, i, Convert.ToInt16(this.chklstbx.GetItemChecked(i)));
                    }
                }
                catch (Exception ex)
                {
                    ErrorDump ed = new ErrorDump();
                    ed.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Information, ex, "Saving UserMaster Failed. Please try again");
                }
            }
            #endregion InsertUserPrivileges
            else
            #region updateUserPrivilege
            {
                USPUserid = userMasterSaver.fetchEmpID(txtUsrname.Text);
                userMasterSaver.updateUserPrivilege(USPUserid);
                for (int i = 0; i < this.chklstbx.Items.Count; i++)
                {
                    userMasterSaver.updateUserAttribute(USPUserid, Convert.ToInt16(this.chklstbx.GetItemChecked(i)), i);
                    MysqlConn.executeQry(qry);
                }
                txtPass.Enabled = true;
                txtConPass.Enabled = true;
                UpdateState = false;
            }
            #endregion updateUserPrivilege

            updateStatus(this, "Values Saved");

            com.clearAllControl(GrbxNewUser, false);
            LoadUserPrivileges_CheckBox("");
            txtUsrname.Focus();
        }
예제 #3
0
        private void winformUpdate_Load(object sender, EventArgs e)
        {
            try
            {
                checkIfFileExist(Application.StartupPath + "\\UpdateVersionLog.zip");

                #region download the File from server
                Network network = new Network();
                try
                {
                    network.DownloadFile("http://kayakkitchen.com/privateeye/UpdateVersionLog.zip", Application.StartupPath + "\\UpdateVersionLog.zip");
                }
                catch (Exception ex)
                {
                    ErrorDump er = new ErrorDump();
                    er.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Critical, ex, "Unable to Download the UpdateVersionLog File");
                }
                #endregion download the File from server

                string updateVersionLogPath = Application.StartupPath + "\\updateVersionLog";

                #region Create_updateVersionLogPath_Directory_ifNotExist
                if (!Directory.Exists(updateVersionLogPath))
                    Directory.CreateDirectory(updateVersionLogPath);
                #endregion Create_updateVersionLogPath_Directory_ifNotExist

                checkIfFileExist(updateVersionLogPath + "\\updateVersionLog.xml");

                #region unzip the file
                try
                {
                    ZipFile.ExtractToDirectory(Application.StartupPath + "\\UpdateVersionLog.zip", updateVersionLogPath);
                }
                catch (Exception ex)
                {
                    ErrorDump er = new ErrorDump();
                    er.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Critical, ex, "Unable to Extract the UpdateVersionLog File");
                }
                File.Delete(Application.StartupPath + "\\UpdateVersionLog.zip");
                #endregion unzip the file

                #region compare current version are equal to server versions
                string appVersion = ConfigurationManager.AppSettings["Version"];
                lblVersion.Text = "Version: " + appVersion;
                serverVersion = readXmlValue(Application.StartupPath + "\\updateVersionLog\\updateVersionLog.xml");

                if (appVersion == serverVersion)
                {
                    btnUpdate.Enabled = false;
                    btnUpdate.Text = "Secusys-EID is upto date";
                }
                else
                {
                    btnUpdate.Enabled = true;
                    btnUpdate.Text = "Secusys-EID Update is available";
                }
                #endregion
            }
            catch (Exception ex)
            {
                ErrorDump ed = new ErrorDump();
                ed.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Critical, ex, "Update Failed.");
                MessageBox.Show("Something Nasty Happened. Please try Again.", "Secusys - EID Update", MessageBoxButtons.OK);
            }
        }