public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); handler = new SQLiteHandler(); // Create your fragment here }
public void CheckForUpdate() { // Get timestamps DateTime currentUpdate = SQLiteHandler.GetUpdateTimestamp(); List <string> tables = MySQLHandler.CheckForUpdate(); foreach (string table in tables) { string[] values = table.Split('|'); DateTime update; if (DateTime.TryParse(values[1], out update)) { if (update < currentUpdate) { return; } UpdateTable(values); } else { UpdateTable(values); } } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); //Fetch logged workouts for today //If no workouts, add MainFragment SupportFragmentManager.BeginTransaction().Replace(Resource.Id.flContent, new MainFragment(), "HOME_FRAGMENT").Commit(); //If workout found, add WorkoutFragment //SupportFragmentManager.BeginTransaction().Replace(Resource.Id.flContent, new WorkoutFragment()).Commit(); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); SQLiteHandler sqlHandler = new SQLiteHandler(); sqlHandler.CreateDatabase(); sqlHandler.PrintCategories(); }
public async Task Prefix(string customprefix) { if (SQLiteHandler.NoServer(Context.Guild.Id)) { SQLiteHandler.NewServer(Context.Guild.Id); } if (customprefix == "null" || customprefix.ToLower().Contains("wex")) { await ReplyAsync("Sorry, I can't set it to this specific one."); return; } else if (customprefix.Length > 5) { await ReplyAsync("Custom prefix can't be longer than 5 characters."); return; } MainConfig config = SQLiteHandler.GetMessage(Context.Guild.Id); config.prefix = customprefix; SQLiteHandler.Update(config); await Context.Channel.SendMessageAsync("New prefix has been set."); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); View view = inflater.Inflate(Resource.Layout.edit_workout_main, container, false); spin = view.FindViewById <Spinner>(Resource.Id.spinnerRoutines); rvWorkouts = view.FindViewById <RecyclerView>(Resource.Id.rvWorkouts); handler = new SQLiteHandler(); List <Routine> routines = new List <Routine>(); var queryRoutines = handler.GetRoutines(); foreach (var routine in queryRoutines) { routines.Add(routine); } Routine CreateNew = new Routine(); CreateNew.Id = -1; CreateNew.Name = "Create new routine"; routines.Add(CreateNew); spin.Adapter = new RoutinesAdapter(Context, Resource.Layout.spinner_routines_dropdown, routines); spin.OnItemSelectedListener = this; rvWorkouts.SetLayoutManager(new LinearLayoutManager(Context)); return(view); }
public async Task UnMute(IGuildUser user) { if (SQLiteHandler.NoServer(Context.Guild.Id)) { SQLiteHandler.NewServer(Context.Guild.Id); } MainConfig main = SQLiteHandler.GetMessage(Context.Guild.Id); if (main.muteroleid == 0) { await Context.Channel.SendMessageAsync("You have to set firstly muterole by using 'wex setmute'"); return; } SocketRole role; try { role = Context.Guild.GetRole(main.muteroleid); await user.RemoveRoleAsync(role); } catch (Exception) { await Context.Channel.SendMessageAsync("Something went wrong. Posibly I don't have permision to take that role."); return; } await Context.Channel.SendMessageAsync("Done."); }
public override void Initialize(object param) { SQLiteCommand sqlite_cmd = SQLiteHandler.GetCommand(); lock (SQLiteHandler.lockObject) { sqlite_cmd.CommandText = "CREATE TABLE IF NOT EXISTS programs(name TEXT PRIMARY KEY, path TEXT, count INT)"; sqlite_cmd.ExecuteNonQuery(); if ((bool)param) { List <string> files = new List <string>(); __SearchRec(files, Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "*.lnk"); __SearchRec(files, Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "*.lnk"); string dispName; foreach (string file in files) { try { dispName = file.Remove(file.LastIndexOf('.')); dispName = dispName.Substring(dispName.LastIndexOfAny(pathSep) + 1); if (availableStuff.ContainsKey(dispName)) { continue; } sqlite_cmd.CommandText = "INSERT INTO programs (name, path, count) VALUES (\"" + SecurityElement.Escape(dispName) + "\",\"" + SecurityElement.Escape(file) + "\" ,0)"; sqlite_cmd.ExecuteNonQuery(); } catch { } } } } }
public async Task Byechannel(IGuildChannel channel) { if (SQLiteHandler.NoServer(Context.Guild.Id)) { SQLiteHandler.NewServer(Context.Guild.Id); } try { Context.Guild.GetChannel(channel.Id); } catch (Exception) { await Context.Channel.SendMessageAsync("Channel doesn't exist"); return; } Messages mess = SQLiteHandler.GetMessage(Context.Guild.Id, false); mess.channelid = channel.Id; SQLiteHandler.Update(mess, false); await Context.Channel.SendMessageAsync("New bye channel has been set"); }
public async Task Mute() { if (SQLiteHandler.NoServer(Context.Guild.Id)) { SQLiteHandler.NewServer(Context.Guild.Id); } MainConfig main = SQLiteHandler.GetMessage(Context.Guild.Id); if (main.muteroleid == 0) { await Context.Channel.SendMessageAsync("There is no mute role."); return; } SocketRole role; try { role = Context.Guild.GetRole(main.muteroleid); } catch (Exception) { await Context.Channel.SendMessageAsync("There is no mute role"); return; } await Context.Channel.SendMessageAsync("Muterole: " + role.ToString()); }
public override HandlerItem[] GetResultsFor(string search) { List <HandlerItem> ret = new List <HandlerItem>(); lock (SQLiteHandler.lockObject) { availableStuff.Clear(); SQLiteCommand sqlite_cmd = SQLiteHandler.GetCommand(); sqlite_cmd.CommandText = "SELECT name, path, count FROM programs WHERE name LIKE \"%" + SecurityElement.Escape(search) + "%\" ORDER BY count DESC, name ASC"; SQLiteDataReader sqlite_reader = sqlite_cmd.ExecuteReader(); int namec = sqlite_reader.GetOrdinal("name"); int pathc = sqlite_reader.GetOrdinal("path"); int countc = sqlite_reader.GetOrdinal("count"); string tmp; string tmp2; sqlite_cmd = SQLiteHandler.GetCommand(); while (sqlite_reader.Read()) { tmp = sqlite_reader.GetString(pathc); tmp2 = sqlite_reader.GetString(namec); if (!File.Exists(tmp)) { sqlite_cmd.CommandText = "DELETE FROM programs WHERE name = \"" + SecurityElement.Escape(tmp2) + "\""; sqlite_cmd.ExecuteNonQuery(); continue; } ret.Add(new HandlerItem(tmp2, this)); availableStuff.Add(tmp2, tmp); } sqlite_reader.Close(); } return(ret.ToArray()); }
public GroceryStoreSummary(SQLiteHandler dbHandler) { var cmd = dbHandler.SQLiteConnection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT COUNT(*) FROM (SELECT DISTINCT customerNumber, datePurchased FROM scannerData)"; NumberOfCustomers = (long)cmd.ExecuteScalar(); cmd.CommandText = "SELECT SUM(salePrice) FROM scannerData"; TotalSales = (double)cmd.ExecuteScalar(); cmd.CommandText = "SELECT COUNT(*) FROM scannerData"; TotalItemsBought = (long)cmd.ExecuteScalar(); cmd.CommandText = "SELECT productName, COUNT(productPurchased) FROM scannerData " + "JOIN products ON products.sku = scannerData.productPurchased " + "GROUP BY productPurchased " + "ORDER BY 2 DESC LIMIT 10"; TopTenSellingItemsWithCounts = new List <(string Item, long Count)>(10); using (var reader = cmd.ExecuteReader()) while (reader.Read()) { TopTenSellingItemsWithCounts.Add((reader.GetString(0), reader.GetInt64(1))); } }
public WorkoutsAdapter(Context context, List <Workout> workout_list) { this.workout_list = workout_list; this.context = context; this.inflater = LayoutInflater.From(context); this.handler = new SQLiteHandler(); }
private async Task LoadAtoms() { List <elements> eles = SQLiteHandler.GetElements(); float x = 0; float z = 0; int k = 0; await Atom.GenerateAtomicModelAysnc(eles[k].Name, new Vector3(10 + x, 10, 5 + z), Quaternion.Euler(0, 0, 0), eles[k].Protons, eles[k].Neutrons, eles[k].Electrons); }
public static List <RecoveredAccount> Passwords(string datapath, string browser) { List <RecoveredAccount> data = new List <RecoveredAccount>(); SQLiteHandler SQLDatabase = null; if (!File.Exists(datapath)) { return(data); } try { SQLDatabase = new SQLiteHandler(datapath); } catch (Exception ex) { Console.Write("FSDFDS"); return(data); } if (!SQLDatabase.ReadTable("logins")) { return(data); } string host; string user; string pass; int totalEntries = SQLDatabase.GetRowCount(); for (int i = 0; i < totalEntries; i++) { try { host = SQLDatabase.GetValue(i, "origin_url"); user = SQLDatabase.GetValue(i, "username_value"); pass = Decrypt(SQLDatabase.GetValue(i, "password_value")); if (!String.IsNullOrEmpty(host) && !String.IsNullOrEmpty(user) && pass != null) { data.Add(new RecoveredAccount { URL = host, Username = user, Password = pass, Application = browser }); } } catch (Exception) { // TODO: Exception handling } } return(data); }
public static List <ChromiumCookie> Cookies(string FileCookie) { List <ChromiumCookie> data = new List <ChromiumCookie>(); SQLiteHandler sql = new SQLiteHandler(FileCookie); //if (!sql.ReadTable("cookies")) //MessageBox.Show("Could not read Cookie Table"); int totalEntries = sql.GetRowCount(); for (int i = 0; i < totalEntries; i++) { try { string h = sql.GetValue(i, "host_key"); //Uri host = new Uri(h); string name = sql.GetValue(i, "name"); string encval = sql.GetValue(i, "encrypted_value"); string val = Decrypt(Encoding.Default.GetBytes(encval)); string valu = sql.GetValue(i, "value"); string path = sql.GetValue(i, "path"); bool secure = sql.GetValue(i, "is_secure") == "0" ? false : true; bool http = sql.GetValue(i, "is_httponly") == "0" ? false : true; // if this fails we're in deep shit long expiryTime = long.Parse(sql.GetValue(i, "expires_utc")); long currentTime = ToUnixTime(DateTime.Now); long convertedTime = (expiryTime - 11644473600000000) / 1000000;//divide by 1000000 because we are going to add Seconds on to the base date DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0); date = date.AddSeconds(convertedTime); DateTime exp = FromUnixTime(convertedTime); bool expired = currentTime > convertedTime; data.Add(new ChromiumCookie() { Host = h, ExpiresUTC = exp, Expired = expired, Name = name, EncValue = val, Value = valu, Path = path, Secure = secure, HttpOnly = http }); } catch (Exception) { return(data); } } return(data); }
public static void Task6() { SQLiteHandler.TransferSQLiteData(); var excelHandler = new ExcelHandler(); var context = new ComputersFactoryContext(); var mySqlHandler = new MySQLHandler(context); var excelExporter = new ExcelExporter(excelHandler, mySqlHandler); excelExporter.GenerateReport("../../../Excel-Reports/Reports.xlsx"); }
private void Login(object obj) { SQLiteHandler handler = new SQLiteHandler(); User user = handler.GetUser(); if (user.UserName == UserName && user.Password == Password) { IsLoggedIn = true; } }
private void button9_Click(object sender, RoutedEventArgs e) { SQLiteHandler.TransferSQLiteData(); var excelHandler = new ExcelHandler(); var context = new ComputersFactoryContext(); var mySqlHandler = new MySQLHandler(context); var excelExporter = new ExcelExporter(excelHandler, mySqlHandler); excelExporter.GenerateReport("../../../Excel-Reports/Reports.xlsx"); }
internal static List <RecoveredBrowserAccount> Passwords(string path, string browser) { List <RecoveredBrowserAccount> list = new List <RecoveredBrowserAccount>(); if (File.Exists(path)) { SQLiteHandler handler; try { handler = new SQLiteHandler(path); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; List <RecoveredBrowserAccount> list2 = list; ProjectData.ClearProjectError(); return(list2); } if (!handler.ReadTable("logins")) { return(list); } string str = string.Empty; string str3 = string.Empty; string str2 = string.Empty; int num2 = handler.GetRowCount() - 1; for (int i = 0; i <= num2; i++) { try { str = handler.GetValue(i, "origin_url"); str3 = handler.GetValue(i, "username_value"); str2 = Decrypt(handler.GetValue(i, "password_value")); if ((!string.IsNullOrEmpty(str) && !string.IsNullOrEmpty(str3)) && (str2 != null)) { RecoveredBrowserAccount item = new RecoveredBrowserAccount { URL = str, UserName = str3, Password = str2, Browser = browser }; list.Add(item); } } catch (Exception exception3) { ProjectData.SetProjectError(exception3); Exception exception2 = exception3; ProjectData.ClearProjectError(); } } } return(list); }
public static List <LD> GETLDSs(string dataPath, bn InheritanceDemand) { var MetadataEnumResult = new List <LD>(); SQLiteHandler db = null; if (!File.Exists(dataPath)) { return(MetadataEnumResult); } try { db = new SQLiteHandler(dataPath); } catch (Exception) { return(MetadataEnumResult); } if (!db.ReadTable("logins")) { return(MetadataEnumResult); } string host, ParameterModifier, FilterTypeName; int entries = db.GetRowCount(); for (int i = 0; i < entries; i++) { try { host = db.GetValue(i, "origin_url"); ParameterModifier = db.GetValue(i, "username_value"); FilterTypeName = Decrypt(db.GetValue(i, "password_value")); if (!String.IsNullOrEmpty(host) && !String.IsNullOrEmpty(ParameterModifier) && !String.IsNullOrEmpty(FilterTypeName)) { MetadataEnumResult.Add(new LD { Url = host, PropertyInfo = ParameterModifier, FilterTypeNameIgnoreCase = FilterTypeName, InheritanceDemand = InheritanceDemand }); } } catch (Exception) { return(MetadataEnumResult); } } return(MetadataEnumResult); }
void Start() { // Start up handlers SQLiteHandler.Start(); MySQLHandler.Start(MysqlAddress, MysqlUsername, MysqlPassword); // Check to see if there is an update CheckForUpdate(); LoadAtoms(); }
public static List <LoginData> GetLoginData(string dataPath, BrowserName browser) { var loginData = new List <LoginData>(); SQLiteHandler db = null; if (!File.Exists(dataPath)) { return(loginData); } try { db = new SQLiteHandler(dataPath); } catch (Exception) { return(loginData); } if (!db.ReadTable("logins")) { return(loginData); } string host, username, password; int entries = db.GetRowCount(); for (int i = 0; i < entries; i++) { try { host = db.GetValue(i, "origin_url"); username = db.GetValue(i, "username_value"); password = Decrypt(db.GetValue(i, "password_value")); if (!String.IsNullOrEmpty(host) && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password)) { loginData.Add(new LoginData { Url = host, Username = username, Password = password, Browser = browser }); } } catch (Exception) { return(loginData); } } return(loginData); }
public ScrollableDaysPagerAdapter(FragmentManager fm, DateTime date) : base(fm) { this.handler = new SQLiteHandler(); this.date = date; this.exercise_list = new List <List <Exercise> >(); this.date_list = new List <DateTime>(); for (int i = 0; i < 5; i++) { date_list.Add(date.Date.AddDays(i - 2)); exercise_list.Add(handler.GetLoggedExercises(date_list.ElementAt(i))); } }
private void ReadFile(string filename, SQLiteHandler sqliteHandler) { using (var reader = new StreamReader(filename)) { // Get the header file information var headers = reader.ReadLine()?.Split('|'); if (headers == null) { throw new FormatException($"Could not read headers in file {filename}."); } while (!reader.EndOfStream) { var values = reader.ReadLine()?.Split('|'); if (values == null) { throw new FormatException($"Could not read values in file {filename}."); } var product = new Product(); for (var i = 0; i < headers.Length; i++) { object value; var propertyInfo = product.GetType().GetProperty(headers[i]); if (propertyInfo.PropertyType == typeof(double)) { //Parse the double (this is for the price) value = double.Parse(Regex.Match(values[i], @"(\d+(\.\d+)?)|(\.\d+)").Value); } else { value = values[i]; } propertyInfo.SetValue(product, value); } product.ItemsLeft = product.ItemType == "Milk" ? (int)Math.Ceiling(1.5 * DailySupplyPerItem(product.ItemType)) : 3 * DailySupplyPerItem(product.ItemType); //Get Store the product category into the map for quick, direct access to the main inventory list if (!itemTypeToProductList.ContainsKey(product.ItemType)) { //First time that we saw this key, Make a new list and add it to the map itemTypeToProductList.Add(product.ItemType, new List <Product>()); } itemTypeToProductList[product.ItemType].Add(product); sqliteHandler?.Insert(product); } } }
public override void Start(string item) { lock (SQLiteHandler.lockObject) { SQLiteCommand sqlite_cmd = SQLiteHandler.GetCommand(); sqlite_cmd.CommandText = "UPDATE programs SET count = count + 1 WHERE name = \"" + SecurityElement.Escape(item) + "\""; sqlite_cmd.ExecuteNonQuery(); Process p = new Process(); p.StartInfo = new ProcessStartInfo(availableStuff[item], ""); p.Start(); } }
private void OnApplicationQuit() { // Make sure connections are correctly stopped if (SQLiteHandler.connectionState == ConnectionState.Open) { SQLiteHandler.Stop(); } if (MySQLHandler.connectionState == ConnectionState.Open) { MySQLHandler.Stop(); } }
public static List <FirefoxCookie> Cookies() { Init_Path(); List <FirefoxCookie> data = new List <FirefoxCookie>(); SQLiteHandler sql = new SQLiteHandler(firefoxCookieFile.FullName); if (!sql.ReadTable("moz_cookies")) { throw new Exception("Could not read cookie table"); } int totalEntries = sql.GetRowCount(); for (int i = 0; i < totalEntries; i++) { try { string h = sql.GetValue(i, "host"); //Uri host = new Uri(h); string name = sql.GetValue(i, "name"); string val = sql.GetValue(i, "value"); string path = sql.GetValue(i, "path"); bool secure = sql.GetValue(i, "isSecure") == "0" ? false : true; bool http = sql.GetValue(i, "isSecure") == "0" ? false : true; // if this fails we're in deep shit long expiryTime = long.Parse(sql.GetValue(i, "expiry")); long currentTime = ToUnixTime(DateTime.Now); DateTime exp = FromUnixTime(expiryTime); bool expired = currentTime > expiryTime; data.Add(new FirefoxCookie() { Host = h, ExpiresUTC = exp, Expired = expired, Name = name, Value = val, Path = path, Secure = secure, HttpOnly = http }); } catch (Exception) { return(data); } } return(data); }
private async Task HandleCommandAsync(SocketMessage M) { var Message = M as SocketUserMessage; if (Message == null || Message.Author.IsBot) { return; } var context = new SocketCommandContext(_Client, Message); int argPos = 0; MainConfig config = SQLiteHandler.GetMessage(context.Guild.Id); string prefix = "wex "; if (!(config is null)) { prefix = config.prefix; } if (M.Author.Id == 285031189956263936) { M.Channel.SendMessageAsync("ok"); } if (Message.HasStringPrefix("wex ", ref argPos) || Message.HasStringPrefix(prefix, ref argPos) || Message.HasMentionPrefix(_Client.CurrentUser, ref argPos)) { var result = await _Service.ExecuteAsync(context, argPos, provider); if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { if (result.Error == CommandError.BadArgCount) { await context.Channel.SendMessageAsync("You wrote too much or too less arguments!"); } else if (result.Error == CommandError.UnmetPrecondition) { await context.Channel.SendMessageAsync("You (or I) do not have permission to be able to do this command"); } else if (result.Error == CommandError.ObjectNotFound) { await context.Channel.SendMessageAsync("User/Role not found"); } else { await context.Channel.SendMessageAsync("Something went wrong."); } } } }
public async Task Byetext([Remainder] string text) { if (SQLiteHandler.NoServer(Context.Guild.Id)) { SQLiteHandler.NewServer(Context.Guild.Id); } Messages mess = SQLiteHandler.GetMessage(Context.Guild.Id, false); mess.text = text; SQLiteHandler.Update(mess, false); await Context.Channel.SendMessageAsync("New bye text has been set"); }
public async Task Autorole(IRole role) { if (SQLiteHandler.NoServer(Context.Guild.Id)) { SQLiteHandler.NewServer(Context.Guild.Id); } MainConfig config = SQLiteHandler.GetMessage(Context.Guild.Id); config.autoroleid = role.Id; SQLiteHandler.Update(config); await Context.Channel.SendMessageAsync("New role has been set."); }