Ejemplo n.º 1
0
 public static OnlineCommands InsertOnlineCommand(System.Net.EndPoint endPoint, string com, int hashcode)
 {
     try
     {
         using (var db = new LiteDatabase(Environment.CurrentDirectory + "/data.db"))
         {
             var col     = db.GetCollection <OnlineCommands>("onlinecommands");
             var command = new OnlineCommands
             {
                 IP       = endPoint.ToString().Split(':')[0],
                 Port     = endPoint.ToString().Split(':')[1],
                 HashCode = hashcode,
                 Command  = com,
                 Result   = string.Empty,
                 Error    = string.Empty,
                 Status   = false
             };
             col.Insert(command);
             return(command);
         }
     }
     catch (Exception ex) {
         return(null);
     }
 }
Ejemplo n.º 2
0
 public static OnlineCommands GetOnlineCommand(System.Net.EndPoint endPoint, string com, int hashcode)
 {
     try
     {
         OnlineCommands commands = null;
         using (var db = new LiteDatabase(Environment.CurrentDirectory + "/data.db"))
         {
             var col  = db.GetCollection <OnlineCommands>("onlinecommands");
             var coms = col.FindAll().AsQueryable()
                        .Where(x => x.IP == endPoint.ToString().Split(':')[0] &&
                               x.Port == endPoint.ToString().Split(':')[1] &&
                               x.HashCode == hashcode &&
                               x.Command == com)
                        .Select(x => x).ToList();
             if (coms.Count() > 0)
             {
                 commands = coms[coms.Count() - 1];
             }
             return(commands);
         }
     }
     catch (Exception) {
         return(null);
     }
 }
Ejemplo n.º 3
0
 public static void UpdateOnlineCommand(OnlineCommands onlineCommands)
 {
     try
     {
         using (var db = new LiteDatabase(Environment.CurrentDirectory + "/data.db"))
         {
             var col = db.GetCollection <OnlineCommands>("onlinecommands");
             col.Update(onlineCommands);
         }
     }
     catch (Exception)
     {
     }
 }