public int DeleteDevice(string id) { int count = operations.Device.DevicePlanCount(WebUtilities.DecryptId(WebUtility.UrlDecode(id), GetUserName(), GetOrganizationId()), GetOrganizationId()); if (count > 0) { TempData["Notification"] = WebUtilities.InsertNotification("Cihaza bağlı planlar olduğu için silinemez."); return(-1); } DeviceInsertModel model = operations.Device.GetDeviceById(GetOrganizationId(), WebUtilities.DecryptId(WebUtility.UrlDecode(id), GetUserName(), GetOrganizationId())); operations.Device.DeleteDevice(WebUtilities.DecryptId(WebUtility.UrlDecode(id), GetUserName(), GetOrganizationId()), GetOrganizationId()); List <string> stringModel = new List <string>(); if (!String.IsNullOrEmpty(model.BakcupJobId)) { stringModel.Add(model.BakcupJobId); } if (!String.IsNullOrEmpty(model.CheckOnlineJobId)) { stringModel.Add(model.CheckOnlineJobId); } if (!String.IsNullOrEmpty(model.FileListJobId)) { stringModel.Add(model.FileListJobId); } HangfireProvider.DeleteHangFireJobs(stringModel); return(1); }
public bool DeleteDevicePlan(string id) { var model = operations.DevicePlan.GetDevicePlanById(GetOrganizationId(), WebUtilities.DecryptId(WebUtility.UrlDecode(id), GetUserName(), GetOrganizationId())); HangfireProvider.DeleteHangFireJobs(new List <string> { model.BackgroundJobId }); operations.DevicePlan.DeleteDevicePlan(WebUtilities.DecryptId(WebUtility.UrlDecode(id), GetUserName(), GetOrganizationId()), GetOrganizationId()); return(true); }
public IActionResult NewJob(DevicePlanInsertModel model) { SetNewJobViewBag(); model.CloseModal = false; if (String.IsNullOrEmpty(model.Name)) { TempData["Notification"] = WebUtilities.InsertNotification("İsim boş geçilemez"); return(View(model)); } if (String.IsNullOrEmpty(model.Description)) { TempData["Notification"] = WebUtilities.InsertNotification("Açıklama boş geçilemez"); return(View(model)); } if (String.IsNullOrEmpty(model.LocalSource)) { TempData["Notification"] = WebUtilities.InsertNotification("Kaynak bilgisayar boş geçilemez"); return(View(model)); } if (String.IsNullOrEmpty(model.RemoteSource)) { TempData["Notification"] = WebUtilities.InsertNotification("Hedef bilgisayar boş geçilemez"); return(View(model)); } if (String.IsNullOrEmpty(model.BackupStartDate)) { TempData["Notification"] = WebUtilities.InsertNotification("Başlangıç tarihi boş geçilemez"); return(View(model)); } if (String.IsNullOrEmpty(model.BackupStartTime)) { TempData["Notification"] = WebUtilities.InsertNotification("Başlangıç saati boş geçilemez"); return(View(model)); } try { string[] dateArray = model.BackupStartDate.Split('-'); string[] timeArray = model.BackupStartTime.Split(':'); model.RealInsertBackupStartDate = new DateTime(Convert.ToInt32(dateArray[2]), Convert.ToInt32(dateArray[1]), Convert.ToInt32(dateArray[0]), Convert.ToInt32(timeArray[0]), Convert.ToInt32(timeArray[1]), 0); } catch { TempData["Notification"] = WebUtilities.InsertNotification("Lütfen tarih ve saat bilgisini kontrol ediniz."); return(View(model)); } model.PlanId = WebUtilities.DecryptId(WebUtility.UrlDecode(model.HashedPlanId), GetUserName(), GetOrganizationId()); model.DeviceId = WebUtilities.DecryptId(model.DeviceHashedId, GetUserName(), GetOrganizationId()); model.OrganizationId = GetOrganizationId(); if (String.IsNullOrEmpty(model.HashedDevicePlanId)) { int returnValue = operations.DevicePlan.InsertDevicePlan(model); if (returnValue > 0) { model.Id = returnValue; TriggerHangfireJob(model); model.HashedDevicePlanId = WebUtilities.EncryptId(returnValue, GetUserName(), GetOrganizationId()); TempData["Notification"] = WebUtilities.InsertNotification("Cihaz planı başarılı bir şekilde eklenmiştir."); model.CloseModal = true; return(View(model)); } else { TempData["Notification"] = WebUtilities.InsertNotification("Ekleme sırasında bir hata oluştu lütfen sistem yöneticisine başvurunuz."); model.CloseModal = false; return(View(model)); } } else { int realId = WebUtilities.DecryptId(WebUtility.UrlDecode(model.HashedDevicePlanId), GetUserName(), GetOrganizationId()); if (realId > 0) { model.CloseModal = true; model.Id = realId; operations.DevicePlan.UpdateDevicePlan(model, GetOrganizationId()); List <string> list = new List <string>(); list.Add(operations.DevicePlan.GetDevicePlanById(GetOrganizationId(), realId).BackgroundJobId); HangfireProvider.DeleteHangFireJobs(list); TriggerHangfireJob(model); return(View(model)); } else { TempData["Notification"] = WebUtilities.InsertNotification("Hatalı işlem lütfen pencereyi kapatıp tekrar deneyiniz."); model.CloseModal = false; return(View(model)); } } // return View(); }