void InsertTesti() { SQLiteDatabase db = new SQLiteDatabase(); Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("UnitName", sanoja[col++]); try { db.Insert("Unit", data); } catch (Exception crap) { MessageBox.Show(crap.Message); } }
private void writeHistory(string url) { if (Properties.Settings.Default.history == 1) { // add to database SQLiteDatabase db = new SQLiteDatabase(); Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("link", url); try { db.Insert("history", data); } catch (Exception crap) { fallyToast.Toaster alertdb = new fallyToast.Toaster(); alertdb.Show("fallyGrab", crap.Message, -1, "Fade", "Up", "", "", "error"); commonFunctions.writeLog(crap.Message, crap.StackTrace); } } }
private void InsertMails(string newSender, string newSubject, string newBody) { SQLiteDatabase db = new SQLiteDatabase(); Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("Sender", newSender); data.Add("Subject", newSubject); data.Add("Body", newBody); //data.Add("Timestamp", cookingTimeTextBox.Text); //data.Add("COOKING_DIRECTIONS", "Placeholder"); try { db.Insert("Mails", data); } catch (Exception e) { //MessageBox.Show(crap.Message); String error = "The following error has occurred:\n\n"; error += e.Message.ToString() + "\n\n"; MessageBox.Show(error); } }
public void ConfigureTVGuide(bool useUPnPStreamUrl = false) { Log("Checking for the source.db and settings.xml files"); if (!System.IO.File.Exists(settings.TVGuidePath)) { Log(" source.db file not found at: " + settings.TVGuidePath); Log("Failed TVGuide configuration"); return; } else { Log(" source.db found at: " + settings.TVGuidePath); } if (!System.IO.File.Exists(settings.TVGuidePath)) { Log(" settings.xml file not found at: " + new FileInfo(settings.TVGuidePath).Directory + @"\settings.xml"); Log("Failed TVGuide configuration"); return; } else { Log(" settings.xml file found at: " + new FileInfo(settings.TVGuidePath).Directory + @"\settings.xml"); } Log("Rewriting TVGuide channels from favorites (including strm file references)"); Log(" Clearing any existing channel configurations"); SQLiteDatabase db = new SQLiteDatabase(settings.TVGuidePath); try { db.ClearTable("CUSTOM_STREAM_URL"); db.ClearTable("CHANNELS"); } catch (Exception crap) { Log(crap.Message); return; } int i = 0; foreach (Channel channel in channels) { if (channel.Checked) { db = new SQLiteDatabase(settings.TVGuidePath); //Channel insert data Dictionary<String, String> channelData = new Dictionary<String, String>(); channelData.Add("ID", channel.Id); channelData.Add("TITLE", channel.VirtualNumber + " " + channel.Callsign); channelData.Add("SOURCE", "xmltv"); channelData.Add("VISIBLE", "1"); channelData.Add("WEIGHT", i.ToString()); //Custom streams insert data Dictionary<String, String> streamData = new Dictionary<String, String>(); streamData.Add("CHANNEL", channel.Id); if (!useUPnPStreamUrl) { streamData.Add("STREAM_URL", StrmDirectory + channel.Filename); } else { string uuid = "missing-uuid-configuration"; try { uuid = settings.HDHRDMS.Split('|')[1]; } catch (Exception){} streamData.Add("STREAM_URL", "upnp://" + uuid + "/CableTV%2fv" + channel.VirtualNumber); } //Sources update Dictionary<String, String> xmltvSourceUpdate = new Dictionary<String, String> { { "CHANNELS_UPDATED", "current_timestamp" } }; db.Update("SOURCES", xmltvSourceUpdate, "ID=\"xmltv\""); try { db.Insert("CHANNELS", channelData); db.Insert("CUSTOM_STREAM_URL", streamData); Log(" Wrote channel: " + channel.VirtualNumber + " - " + channel.Callsign + " With stream path: " + streamData["STREAM_URL"]); } catch (Exception crap) { Log(crap.Message); } i++; } } Log("Updating settings and last updated timestamps"); UpdateTVGuideSettingXML(); //Custom streams insert data DataTable updateMax; String query = "select max(id) + 1 as next_id from UPDATES;"; updateMax = db.GetDataTable(query); string nextId = ""; foreach (DataRow dRow in updateMax.Rows) { nextId = dRow["next_id"].ToString(); } Dictionary<String, String> updatesData = new Dictionary<String, String>(); updatesData.Add("ID", nextId); updatesData.Add("SOURCE", "xmltv"); updatesData.Add("DATE", DateTime.UtcNow.ToString("yyyy-MM-dd")); updatesData.Add("PROGRAMS_UPDATED", "current_timestamp"); db.Insert("UPDATES", updatesData); //Settings update data Dictionary<String, String> sourceSetting = new Dictionary<String, String> { { "VALUE", "XMLTV" } }; db.Update("SETTINGS", sourceSetting, String.Format("KEY = {0}", "\"source\"")); Dictionary<String, String> xmltvFileSetting = new Dictionary<String, String> { { "VALUE", new FileInfo(settings.MC2XMLPath).Directory + @"\xmltv.xml" } }; db.Update("SETTINGS", xmltvFileSetting, String.Format("KEY = {0}", "\"xmltv.file\"")); Log("Done updating TVGuide!"); }
private void InsertMails(string newSender, string newSubject, string newBody, string newDatetime, string newMessageID) { SQLiteDatabase db = new SQLiteDatabase(); Dictionary<String, String> data = new Dictionary<String, String>(); data.Add("Sender", newSender); data.Add("Subject", newSubject); data.Add("Body", newBody); data.Add("Timestamp", newDatetime); data.Add("gmailID", newMessageID); try { db.Insert("Mails", data); } catch (Exception e) { //MessageBox.Show(crap.Message); String error = "The following error has occurred:\n\n"; error += e.Message.ToString() + "\n\n"; MessageBox.Show(error); } }