Ejemplo n.º 1
0
        /// <summary>
        /// Aggiorna il database, aggiungi/rimuovi elementi in base alle modifiche fatte
        /// </summary>
        /// <returns></returns>
        bool UpdateDatabase()
        {
            var fetch = Keys.Get(DeviceId);
            var grid  = ParseGrid();

            foreach (var key in grid.Keys)
            {
                if (fetch.Keys.ToList().Contains(key) == false)
                {
                    string query = "Insert into keys (id, deviceId, name, key) VALUES ( NULL, '" +
                                   DeviceId + "', '" + key + "', '" + grid[key] + "')";
                    var result = Keys.Insert(query);
                    if (result == false)
                    {
                        return(false);
                    }
                }
            }
            foreach (var key in fetch.Keys)
            {
                if (grid.Keys.ToList().Contains(key) == false)
                {
                    var result = Keys.Insert("delete from keys where deviceId = '" + DeviceId + "' AND name = '" + fetch[key] + "'");
                    if (!result)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        // Inizializza l'AGL dei file presenti sul dispositivo
        void InitAGL()
        {
            var groups = new Dictionary <string, string>();

            if (OwnerMode)
            {
                groups = Keys.Get(DeviceId);
            }

            for (int i = 0; i < dataGrid.Rows.Count; i++)
            {
                var row = dataGrid.Rows[i];

                if (row.Cells[0].Value == null)
                {
                    continue;
                }
                string filename = DevicePath + row.Cells[0].Value.ToString();
                var    agl      = new Services.FileAGLService(filename);

                if (OwnerMode)
                {
                    if (agl.Exists())
                    {
                        foreach (var name in groups.Keys)
                        {
                            string temp    = string.Empty;
                            int    clIndex = GetColumnIndex(name);
                            if (clIndex != -1)
                            {
                                if (agl.Access(groups[name], out temp))
                                {
                                    row.Cells[clIndex].Value = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    // no wner mode
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Popola la tabella utilizzando le informazioni memorizzate nel database
        /// </summary>
        void Init()
        {
            Keys = Database.LiteDatabase.singleton.GetTable("keys") as Database.Tables.Keys;
            var fetch = Keys.Get(DeviceId);

            foreach (var group in fetch.Keys)
            {
                dataGrid.Rows.Add(group, fetch[group]);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Popola la tabella utilizzando le informazioni memorizzate nel database
 /// </summary>
 void Init()
 {
     Keys = Database.LiteDatabase.singleton.GetTable("keys") as Database.Tables.Keys;
     var fetch = Keys.Get(DeviceId);
     foreach(var group in fetch.Keys)
     {
         dataGrid.Rows.Add(group, fetch[group]);
     }
 }