Exemplo n.º 1
0
        public HttpResponseMessage CheckOnlineDevice([FromBody] CheckModel data)
        {
            DpOperations db     = new DpOperations();
            var          device = db.Device.GetApiAccessAndSecretKeyDevice(data.apiAccessKey, data.apiSecretKey);

            if (device != null)
            {
                if (String.IsNullOrEmpty(device.CpuId) || String.IsNullOrEmpty(device.MacAddress) || String.IsNullOrEmpty(device.DiskSeriNo))
                {
                    data.deviceId = device.Id;
                    db.Device.UpdateDeviceInformation(data);
                    DevicePlanLog lg = new DevicePlanLog()
                    {
                        CreatedDate    = DateTime.Now,
                        Description    = "Cihaz ekleme başarılı bir şekilde gerçekleşmiştir. Cihaz aktif",
                        DeviceId       = device.Id,
                        OrganizationId = device.OrganizationId
                    };
                    db.Log.InsertLog(lg);

                    HangfireProvider.ScheduleRecurringCheckOnline(DateTime.Now, device.Id, "0 */3 * * *", device.OrganizationId);
                    //HangfireProvider.ScheduleRecurringFileList(DateTime.Now, device.Id, "0 */12 * * *", device.OrganizationId);
                    //HangfireProvider.InsertJobOneTimeFileList(DateTime.Now, device.Id, device.OrganizationId);
                    HangfireProvider.InsertJobOneTimeCheckOnline(DateTime.Now, device.Id, device.OrganizationId);
                }
                else
                {
                    if (data.updateData)
                    {
                        data.deviceId = device.Id;
                        db.Device.UpdateDeviceInformation(data);
                        DevicePlanLog lg = new DevicePlanLog()
                        {
                            CreatedDate    = DateTime.Now,
                            Description    = "Cihaz ekleme başarılı bir şekilde gerçekleşmiştir. Cihaz aktif",
                            DeviceId       = device.Id,
                            OrganizationId = device.OrganizationId
                        };
                        db.Log.InsertLog(lg);
                    }
                    else
                    {
                        DevicePlanLog lg = new DevicePlanLog()
                        {
                            CreatedDate    = DateTime.Now,
                            Description    = "Cihaz kontrolü başarılı bir şekilde gerçekleşmiştir. Cihaz aktif",
                            DeviceId       = device.Id,
                            OrganizationId = device.OrganizationId
                        };
                        db.Log.InsertLog(lg);
                    }
                }
                return(new HttpResponseMessage(System.Net.HttpStatusCode.OK));
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.Unauthorized));
            }
        }
Exemplo n.º 2
0
        public void InsertLog(DevicePlanLog log)
        {
            string sql = "insert into public.\"DevicePlanLog\"(\"Description\",\"DevicePlanId\",\"OrganizationId\",\"DeviceId\",\"Detail\",\"CreatedDate\") " +
                         " values(@Description, @DevicePlanId, @OrganizationId, @DeviceId, @Detail, @CreatedDate)";
            object data = new { Description    = log.Description,
                                DevicePlanId   = log.DevicePlanId,
                                OrganizationId = log.OrganizationId,
                                DeviceId       = log.DeviceId,
                                Detail         = log.Detail,
                                CreatedDate    = DateTime.Now };

            _connection.Execute(sql, data);
        }