Пример #1
0
        public override void HandleRequest(Request request)
        {
            if (request is MonitoredDrivesRequest)
            {
                MonitoredDrivesRequest md = request as MonitoredDrivesRequest;

                Database db = new Database();
                using (SQLiteConnection conn = db.Connection)
                {
                    conn.Open();

                    string path  = md.MachineName + ".monitored_drives";
                    string value = Configuration.GetValue(path, conn);
                    if (string.IsNullOrEmpty(value) == false)
                    {
                        try
                        {
                            MonitoredDriveManager manager = JsonConvert.DeserializeObject <MonitoredDriveManager>(value);
                            if (manager != null)
                            {
                                md.DriveManager = manager;
                                md.Handled();
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
Пример #2
0
 public DeviceInfo(DeviceType type)
 {
     m_device_id     = new DeviceID(-1, string.Empty);
     this.type       = type;
     ipAddress       = "0.0.0.0";
     username        = password = string.Empty;
     deleted         = false;
     collectors      = CollectorInfo.FromCollectorTypes(type.GetCollectors());
     driveNames      = new Dictionary <string, string>();
     monitoredDrives = new MonitoredDriveManager();
     groupID         = -1;
 }
Пример #3
0
 public DeviceInfo()
 {
     m_device_id     = new DeviceID(-1, string.Empty);
     type            = DeviceType.Unknown;
     ipAddress       = "0.0.0.0";
     username        = password = string.Empty;
     deleted         = false;
     collectors      = new List <CollectorInfo>();
     driveNames      = new Dictionary <string, string>();
     monitoredDrives = new MonitoredDriveManager();
     groupID         = -1;
 }
Пример #4
0
 private static void LoadMonitoredDrives(List <DeviceInfo> devices, SQLiteConnection conn)
 {
     foreach (DeviceInfo device in devices)
     {
         string path  = device.name + ".monitored_drives";
         string value = Configuration.GetValue(path, conn);
         if (string.IsNullOrEmpty(value) == false)
         {
             try
             {
                 MonitoredDriveManager manager = JsonConvert.DeserializeObject <MonitoredDriveManager>(value);
                 if (manager != null)
                 {
                     device.monitoredDrives = manager;
                 }
             }
             catch (Exception)
             {
             }
         }
     }
 }