コード例 #1
0
        private void CheckLastUpdateDate()
        {
            toolStripLblLastBackupDays.Visible = false;
            if (File.Exists(jsonMailUpdateDataPath) && new FileInfo(jsonMailUpdateDataPath).Length > 0)
            {
                List <UpdateMail> updateMails = new List <UpdateMail>();
                updateMails = DataListing.ReadBackupInfo(jsonMailUpdateDataPath, updateMails);
                var lastUpdate    = updateMails[0].LastUpdateDate.Value;
                var updateDate    = updateMails[0].UpdateDate.ToString();
                var nowDate       = DateTime.Parse(DateTime.Now.ToString("dd-MM-yyyy"));
                var remainingDate = (nowDate - lastUpdate).TotalDays;
                if (remainingDate > 0)
                {
                    toolStripLblLastBackupDays.Text      = "Son Yedekleme " + remainingDate + " Gün Önce Yapıldı.";
                    ıconToolStripBtnBackupManual.Visible = true;
                    toolStripLblLastBackupDays.Visible   = true;
                }

                if (remainingDate > 7 && CheckInternetControl() && Hakediş.Properties.Settings.Default.isAnyUpdate == false && lastUpdate != null)
                {
                    DialogResult dialog = new DialogResult();
                    dialog = MessageBox.Show($"Verileriniz En Son {remainingDate} Gün Önce Yedeklendi. \rVerilerinizi Yedeklemek İstersiniz ?", "Veri Yedeklemesi", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialog == DialogResult.Yes)
                    {
                        BackupData(updateDate);
                    }
                    else
                    {
                        toolStripBtnBackup.Visible = true;
                    }
                }
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
コード例 #2
0
 private void BackUpDataFileItem()
 {
     if (File.Exists(jsonMailUpdateDataPath) && new FileInfo(jsonMailUpdateDataPath).Length > 0)
     {
         List <UpdateMail> updateMails = new List <UpdateMail>();
         updateMails = DataListing.ReadBackupInfo(jsonMailUpdateDataPath, updateMails);
         comboBoxSelectUpdateDay.SelectedItem = updateMails[0].UpdateDate;
         maskedtxtUsername.Text = updateMails[0].UserName;
         maskedTxtPass.Text     = updateMails[0].Password;
         maskedTxtToEmail.Text  = updateMails[0].ToEmail;
     }
     else
     {
         btnAutoUpdate.PerformClick();
     }
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
コード例 #3
0
 private void ManualBackupData()
 {
     try
     {
         List <UpdateMail> updateMails = new List <UpdateMail>();
         updateMails = DataListing.ReadBackupInfo(jsonMailUpdateDataPath, updateMails);
         var date = updateMails[0].UpdateDate.ToString();
         toolStripProgressBarBackup.Visible = true;
         timerBackupStat.Enabled            = true;
         BackupData(date);
     }
     catch (Exception)
     {
         throw;
     }
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
コード例 #4
0
 public void BackupData(string DateNow)
 {
     try
     {
         if (CheckInternetControl() && File.Exists(jsonMailUpdateDataPath) && new FileInfo(jsonMailUpdateDataPath).Length > 0)
         {
             List <UpdateMail> updateMails = new List <UpdateMail>();
             updateMails = DataListing.ReadBackupInfo(jsonMailUpdateDataPath, updateMails);
             var      date           = updateMails[0].UpdateDate.ToString();
             DateTime?lastUpdateDate = updateMails[0].LastUpdateDate.Value;
             var      nowDate        = DateTime.Parse(DateTime.Now.ToString("dd-MM-yyyy"));
             if (DateNow == date && Hakediş.Properties.Settings.Default.isAnyUpdate == false && lastUpdateDate != nowDate)
             {
                 var toEmail = updateMails[0].ToEmail;//Göndermek İstediğin Email Girişi
                 var email   = updateMails[0].UserName;
                 var pass    = updateMails[0].Password;
                 var body    = DateTime.Now.ToString() + " Yedeklemesi " + Environment.NewLine + Application.CompanyName + " " + Application.ProductName + " App";
                 var subject = "Hakediş " + DateTime.Now.ToString() + " Yedek Veri Güncellemesi";
                 if (ConnectAndSendMail.Email_Send(toEmail, body, subject, email, pass, jsonWorkOrderDataPath, jsonPaymentsDataPath))
                 {
                     Hakediş.Properties.Settings.Default.isAnyUpdate = true;
                     updateMails[0].LastUpdateDate = DateTime.Parse(DateTime.Now.ToString("dd-MM-yyyy"));
                     var json = Newtonsoft.Json.JsonConvert.SerializeObject(updateMails);
                     File.WriteAllText(jsonMailUpdateDataPath, json);
                     ıconToolStripBtnBackupManual.Visible = false;
                     toolStripLblLastBackupDays.Visible   = false;
                 }
             }
             else
             {
                 Hakediş.Properties.Settings.Default.isAnyUpdate = false;
                 Hakediş.Properties.Settings.Default.Save();
                 Hakediş.Properties.Settings.Default.Reload();
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }