コード例 #1
0
        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);
        }
コード例 #2
0
        public void UpdateDevice(DeviceInsertModel model, int organizationId)
        {
            string sql  = "update public.\"Device\" set \"Name\" = @name , \"Description\" = @description where \"OrganizationId\" = @organizationId and \"Id\" = @id";
            object data = new { name = model.DeviceName, description = model.DeviceDescription, organizationId = organizationId, id = model.DeviceId };

            _connection.Execute(sql, data);
        }
コード例 #3
0
        public IActionResult New(string id)
        {
            int realId = WebUtilities.DecryptId(id, GetUserName(), GetOrganizationId());

            if (realId > 0)
            {
                DeviceInsertModel model = operations.Device.GetDeviceById(GetOrganizationId(), realId);
                model.HashedDeviceId = WebUtilities.EncryptId(model.DeviceId, GetUserName(), GetOrganizationId());
                return(View(model));
            }
            else
            {
                DeviceInsertModel model = new DeviceInsertModel();
                return(View(model));
            }
        }
コード例 #4
0
        public IActionResult New(DeviceInsertModel model)
        {
            model.CloseModal = false;
            if (String.IsNullOrEmpty(model.DeviceName) || String.IsNullOrEmpty(model.DeviceDescription))
            {
                TempData["Notification"] = WebUtilities.InsertNotification("Cihaz ismi ve açıklaması boş geçilemez.");
                return(View(model));
            }
            if (String.IsNullOrEmpty(model.HashedDeviceId))
            {
                int returnValue = operations.Device.InsertJob(GetOrganizationId(), model.DeviceName, model.DeviceDescription);

                if (returnValue > 0)
                {
                    model.HashedDeviceId     = WebUtilities.EncryptId(returnValue, GetUserName(), GetOrganizationId());
                    TempData["Notification"] = WebUtilities.InsertNotification("Cihaz 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.HashedDeviceId), GetUserName(), GetOrganizationId());
                if (realId > 0)
                {
                    model.CloseModal = true;
                    model.DeviceId   = realId;
                    operations.Device.UpdateDevice(model, GetOrganizationId());
                    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();
        }