示例#1
0
        void tsbExit_Click(object sender, EventArgs e)
        {
            this.Hide();
            EpointMethod.UpdateDataLics();

            this.Exit();
        }
示例#2
0
        public static void Main()
        {
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            rkApp.SetValue("AutoMail", Application.ExecutablePath.ToString());
            Common.SetEnvironment();
            Element.sysUser_Id = "SYSTEM";
            if (!Login())
            {
                return;
            }

            Common.InitSystem();
            //frmMain frmmain = new frmMain();
            frmUpdateFile frm = new frmUpdateFile();

            //frm.Load();
            if (!EpointMethod.CheckdataLics())
            {
                Application.Exit();

                EpointMethod.UpdateDataLics();
            }
            else
            {
                frm.Load();
                Application.Run(frm);
            }
        }
示例#3
0
        public bool Backup()
        {
            if (Collection.Parameters["ALLOW_AUTOBACKUP"].ToString() == "0")
            {
                if (!EpointMessage.MsgYes_No(EpointMessage.GetMessage("BACKUP"), "Y"))
                {
                    return(false);
                }
            }

            lock (this)
            {
                //string strCommand = string.Empty,
                //        strBackupName = string.Empty,
                //        strBackupPath = string.Empty;

                //strBackupPath = Collection.Parameters["BACKUP_PATH"].ToString();
                //strBackupName = Element.sysDatabaseName + "_" +
                //                DateTime.Now.Year + "" +
                //                DateTime.Now.Month.ToString().PadLeft(2, '0') + "" +
                //                DateTime.Now.Day.ToString().PadLeft(2, '0') + "_" +
                //                DateTime.Now.Hour.ToString().PadLeft(2, '0') + "h_" +
                //                DateTime.Now.Minute.ToString().PadLeft(2, '0') + "m_" +
                //                DateTime.Now.Second.ToString().PadLeft(2, '0') + "s";

                //strBackupPath = strBackupPath + strBackupName + ".Bak";

                //strCommand = "USE MASTER ;" +
                //                "EXEC Sp_addumpdevice 'disk', '" + strBackupName + "', '" + strBackupPath + "' ;" +
                //                "BACKUP DATABASE " + Element.sysDatabaseName + " TO " + strBackupName + "; " +
                //                "USE " + Element.sysDatabaseName;

                ////                strCommand = @"use Epoint;
                ////                               EXEC [sp_DBBackup] '" + Element.sysDatabaseName + "', '" + strBackupPath + "'";

                //Common.ShowStatus(Languages.GetLanguage("IN_PROCESS") + " backup Database...");

                //if (SQLExec.Execute(strCommand))
                //{
                //    EpointMessage.MsgOk("Dữ liệu đã được backup vào tập tin " + strBackupPath);
                //    return true;
                //}
                //else
                //{
                //    EpointMessage.MsgCancel("Không thể backup được dữ liệu " + strBackupPath);
                //    return false;
                //}

                return(EpointMethod.BackupDatabase());
            }

            return(true);
        }
示例#4
0
        void btOk_Click(object sender, EventArgs e)
        {
            if (txtFile_Name.Text == string.Empty)
            {
                return;
            }
            if (!File.Exists(txtFile_Name.Text))
            {
                EpointMessage.MsgOk(Epoint.Systems.Librarys.Languages.GetLanguage("NotValid_Key", Element.sysLanguage));
            }
            if (EpointMethod.EpointUpdateKey(txtFile_Name.Text))
            {
                EpointMessage.MsgOk(Epoint.Systems.Librarys.Languages.GetLanguage("Valid_Key", Element.sysLanguage));
            }
            else
            {
                EpointMessage.MsgOk(Epoint.Systems.Librarys.Languages.GetLanguage("NotValid_Key", Element.sysLanguage));
            }

            Common.CloseCurrentForm();
            Application.Restart();
        }
示例#5
0
        public static void Main()
        {
            try
            {
                Common.SetEnvironment();
                EpointMethod.RunSqlScript();
                EpointMethod.DeleteBak("*.bak");
                EpointMethod.DeleteBak("*.pdb");


                if (!Login())
                {
                    return;
                }

                Common.InitSystem();
                EpointMethod.UploadFileNewVersion();

                EpointMethod.UpdateReportFile();

                if (!EpointMethod.CheckdataLics())
                {
                    EpointMethod.UpdateDataLics();
                    Application.Exit();
                }
                else
                {
                    frmMain frmmain = new frmMain();
                    Application.Run(frmmain);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#6
0
        protected override void OnClosed(EventArgs e)
        {
            //if (MessageBox.Show(Element.sysLanguage == enuLanguageType.Vietnamese ? "Bạn có muốn backup dữ liệu không?" : "Would you like to backup database?", "Message",
            //            MessageBoxButtons.YesNoCancel,
            //            MessageBoxIcon.Question,
            //            MessageBoxDefaultButton.Button2) == DialogResult.Cancel) 


            //Backup dữ liệu
            string strSQLExec;

            if (!Collection.Parameters.ContainsKey("LASTBACKUP_DATE"))
            {
                strSQLExec = "INSERT INTO SYSPARAMETER (Parameter_ID, Parameter_Value, Parameter_Type, Visible, Parameter_Desc, Module_ID) " +
                    " VALUES (@Parameter_ID, @Parameter_Value, @Parameter_Type, @Visible, @Parameter_Desc, @Module_ID)";

                Hashtable htPara = new Hashtable();
                htPara.Add("PARAMETER_ID", "LASTBACKUP_DATE");
                htPara.Add("PARAMETER_VALUE", "1/1/1900");
                htPara.Add("PARAMETER_TYPE", "D");
                htPara.Add("VISIBLE", "0");
                htPara.Add("PARAMETER_DESC", "Ngày backup cuối cùng");
                htPara.Add("MODULE_ID", 7001);

                if (SQLExec.Execute(strSQLExec, htPara, CommandType.Text))
                    Collection.Parameters.Add("LASTBACKUP_DATE", "1/1/1900");
            }

            if (!Collection.Parameters.ContainsKey("BACKUP_PERIOD"))
            {
                strSQLExec = "INSERT INTO SYSPARAMETER (Parameter_ID, Parameter_Value, Parameter_Type, Visible, Parameter_Desc, Module_ID) " +
                    " VALUES (@Parameter_ID, @Parameter_Value, @Parameter_Type, @Visible, @Parameter_Desc, @Module_ID)";

                Hashtable htPara = new Hashtable();
                htPara.Add("PARAMETER_ID", "BACKUP_PERIOD");
                htPara.Add("PARAMETER_VALUE", 7);
                htPara.Add("PARAMETER_TYPE", "N");
                htPara.Add("VISIBLE", "1");
                htPara.Add("PARAMETER_DESC", "Kỳ hạn backup");
                htPara.Add("MODULE_ID", 7001);

                if (SQLExec.Execute(strSQLExec, htPara, CommandType.Text))
                    Collection.Parameters.Add("BACKUP_PERIOD", "7");
            }

            if (Collection.Parameters.ContainsKey("LASTBACKUP_DATE") && Collection.Parameters.ContainsKey("BACKUP_PERIOD"))
            {
                object objLastBackupDate = DataTool.SQLGetNameByCode("SYSPARAMETER", "Parameter_ID", "Parameter_Value", "LASTBACKUP_DATE");
                object objBackupPeriod = DataTool.SQLGetNameByCode("SYSPARAMETER", "Parameter_ID", "Parameter_Value", "BACKUP_PERIOD");

                DateTime dLastBackupDate;
                if (!DateTime.TryParse((string)objLastBackupDate, out dLastBackupDate))
                    dLastBackupDate = Convert.ToDateTime("1/1/1900");

                int iBackupPeriod;
                if (!int.TryParse((string)objBackupPeriod, out iBackupPeriod))
                    iBackupPeriod = 7;

                if (iBackupPeriod > 0 && DateTime.Now.Subtract(dLastBackupDate).TotalDays >= iBackupPeriod)
                {
                    if (EpointMethod.BackupDatabase())
                    {
                        SQLExec.Execute("UPDATE SYSPARAMETER SET Parameter_Value = '" + Library.DateToStr(DateTime.Now) + "' WHERE Parameter_ID = 'LASTBACKUP_DATE'");
                    }
                }
            }

            base.OnClosed(e);
        }