Exemplo n.º 1
0
        public static void DoBackup(string name, BkpMsg bmsg)
        {
            string path = BaseDir + name;

            Directory.CreateDirectory(path);

            if (bmsg.Visible == false)
            {
                bmsg.Visible = true;
                bmsg.Refresh();
            }

            try
            {
                Store(Common.Conf.DbPath, path);
            }
            catch (Exception ex)
            {
                Common.Log(ex);
            }

            Common.Log("Made month's bkp...");
            //bmsg.Close();
        }
Exemplo n.º 2
0
        public static void DoBackupIfNeed(BkpMsg bmsg)
        {
            if (Enable == false)
            {
                Common.LogWar("No backup path: '" + Common.Conf.BkpPath + "'");
                return;
            }

            //string path = BaseDir + DateTime.Now.DayOfWeek.ToString() + "\\";
            string path = BaseDir + GetCurrentDayOfWeek() + "\\";

            if (Common.Conf.BkpWeek &&
                (Common.Conf.BkpWeekDate.Year != DateTime.Now.Year ||
                 Common.Conf.BkpWeekDate.Month != DateTime.Now.Month ||
                 Common.Conf.BkpWeekDate.Day != DateTime.Now.Day ||
                 Directory.Exists(path) == false))
            {
                if (bmsg.Visible == false)
                {
                    bmsg.Visible = true;
                    bmsg.Refresh();
                }

                if (Directory.Exists(path))
                {
                    RemoveDir(path);
                }

                Directory.CreateDirectory(path);

                Store(Common.Conf.DbPath, path);

                Common.Log("Made days bkp...");
                Common.Conf.BkpWeekDate = new DateTime(DateTime.Now.Ticks);
            }

            //path = BaseDir + DateTime.Now.Month.ToString() + "\\";
            path = BaseDir + GetCurrentMonth() + "\\";
            if (Common.Conf.BkpYear &&
                (Common.Conf.BkpYearDate.Year != DateTime.Now.Year ||
                 Common.Conf.BkpYearDate.Month != DateTime.Now.Month ||
                 Directory.Exists(path) == false))
            {
                if (bmsg.Visible == false)
                {
                    bmsg.Visible = true;
                    bmsg.Refresh();
                }

                if (Directory.Exists(path))
                {
                    RemoveDir(path);
                }

                Directory.CreateDirectory(path);

                Store(Common.Conf.DbPath, path);

                Common.Log("Made month's bkp...");
                Common.Conf.BkpYearDate = new DateTime(DateTime.Now.Ticks);
            }

            Common.Conf.Save();
        }