public void LargeTableHandling() { InitConnection(); IQTable orderTable = qbApp.GetTable(qbSettings["qbBigTable"]); Query qry = new Query(); QueryStrings lstQry = new QueryStrings(1, ComparisonOperator.IR, "last 60 d", LogicalOperator.NONE); qry.Add(lstQry); int maxRec = 100000; orderTable.Query(qry, string.Format("skp-10.num-{0}", maxRec)); Assert.AreEqual(maxRec, orderTable.Records.Count); HashSet <string> idLst = new HashSet <string>(); foreach (QRecord rec in orderTable.Records) { string id = (string)rec["Record ID#"]; if (idLst.Contains(id)) { Assert.Fail("Duplicate ID found!"); } else { idLst.Add(id); } } }
// Constructors internal QRecord(IQApplication application, IQTable table, QColumnCollection columns) { Application = application; Table = table; Columns = columns; this._fields = new List <QField>(); }
// Constructors internal QRecord(IQApplication application, IQTable table, QColumnCollection columns) { Application = application; Table = table; Columns = columns; _fields = new List<QField>(); }
public void UntestedTest() { InitConnection(); List <GrantedAppsInfo> appsLst = qbApp.GrantedDBs(); IQTable testTab = null; foreach (var app in appsLst) { foreach (var tab in app.GrantedTables) { if (tab.Name == "APITestApp: APIUntested") { testTab = qbApp.GetTable(tab.Dbid); break; } } if (testTab != null) { break; } } testTab.Query(); IQRecord rec = testTab.Records[0]; var htmlStr = rec["RichText"]; var multiText = rec["MultiLine"]; var mselect = rec["MultiSelect"]; }
public void LargeDeleteHandling() { InitConnection(); List <GrantedAppsInfo> appsLst = qbApp.GrantedDBs(); foreach (var app in appsLst) { foreach (var tab in app.GrantedTables) { if (tab.Name == "APITestApp: APIBigDelTestTable") { IQTable tbl = qbApp.GetTable(tab.Dbid); qbApp.DeleteTable(tbl); break; } } } IQTable testTable = qbApp.NewTable("APIBigDelTestTable", "dummyRec"); testTable.Columns.Add(new QColumn("NumberValue", FieldType.@float)); testTable.Columns.Add(new QColumn("TextValue", FieldType.text)); for (int i = 0; i < 500; i++) { IQRecord newRec = testTable.NewRecord(); newRec["NumberValue"] = i; newRec["TextValue"] = "Record " + i; testTable.Records.Add(newRec); } testTable.AcceptChanges(); List <int> delList = new List <int> { 5, 6, 7, 8, 9, 10 }; Random rndSrc = new Random(); while (delList.Count < 120) { int addVal = rndSrc.Next(500); if (!delList.Contains(addVal)) { delList.Add(addVal); } } foreach (int i in delList.OrderByDescending(x => x)) { testTable.Records.RemoveAt(i); } testTable.AcceptChanges(); testTable.Query(); Assert.AreEqual(testTable.Records.Count, 380, "Big Record deletion fails"); }
public int GetUserIDByUserName(String userName) { int uID = -1; table = application.GetTable(GetTableID("Users")); table.Query(); IQRecord tempUser = table.Records.Where(x => x[1] == userName).SingleOrDefault(); if (tempUser != null) { Int32.TryParse(tempUser[0], out uID); } return(uID); }
public Pitch GrabPitch(int pitchID) { Pitch pitch = null; table = application.GetTable(GetTableID("Pitches")); table.Query(); IQRecord pitchRecord = table.Records.Where(x => x[0] == pitchID.ToString()).SingleOrDefault(); if (pitchRecord != null) { pitch = new Pitch(pitchID, pitchRecord[1], pitchRecord[2]); } return(pitch); }
public void DeleteTable(IQTable table) { var tableId = table.TableId; if (!_qbDataTables.ContainsKey(tableId)) { throw new TableDoesNotExistInQuickBase("Table does not exist in this instance of QApplication."); } var deleteTbl = new DeleteDatabase(Client.Ticket, Token, Client.AccountDomain, tableId); deleteTbl.Post(); _qbDataTables.Remove(tableId); }
public void TestDuration() { InitConnection(); IQTable testTable = qbApp.GetTable("bnrmadvx3"); TimeSpan tstVal = new TimeSpan(1, 23, 55, 11); IQRecord newRec = testTable.NewRecord(); newRec["DurationTest"] = tstVal; testTable.Records.Add(newRec); testTable.AcceptChanges(); testTable.Query(); IQRecord loopRec = testTable.Records[0]; Assert.AreEqual(tstVal, loopRec["DurationTest"], "Duration doesn't round trip"); }
public Recording GetRecording(int userID, int RecordingID) { Recording record = null; table = application.GetTable(GetTableID("Recordings")); table.Query(); IQRecord recording = table.Records.Where(x => x[1] == userID.ToString() && x[0] == RecordingID.ToString()).SingleOrDefault(); recording.DownloadFile("Recording", HttpContext.Current.Server.MapPath("/DataHolding/"), 1); FileStream fs = File.Create(HttpContext.Current.Server.MapPath("/DataHolding/") + recording[3]); int id; if (Int32.TryParse(recording[0], out id)) { record = new Recording(id, recording[2]); } return(record); }
public List <Pitch> GrabPitches() { List <Pitch> pitches = new List <Pitch>(); table = application.GetTable(GetTableID("Pitches")); table.Query(); QRecordCollection pitchesCollection = table.Records; for (int j = 0; j < pitchesCollection.Count; j++) { int id; if (Int32.TryParse(pitchesCollection.ElementAt(j)[0], out id)) { pitches.Add(new Pitch(id, pitchesCollection.ElementAt(j)[1], pitchesCollection.ElementAt(j)[2])); } } return(pitches.OrderBy(x => x.PitchID).ToList()); }
private int curUserID;//handles the current UserID for the database public DBhandler() { client = QuickBase.Login("*****@*****.**", "Crescendo1", "johnpriem.quickbase.com"); application = client.Connect("bms24ys95", "duzpt2fcvsybbgkrkup4bjurh8b"); table = application.GetTable(GetTableID("Users")); //setCurUserID(); //GrabPitch(0); //GrabPitches(); //GetRecording(0,0); //GrabRecordings(0); /*Pulls all users and prints their information * foreach(IQRecord record in table.Records) * { * Console.WriteLine(record[0] + "- " + record[1] + ":" + record[2]); * }*/ //CreateUser("Jack", "Priem"); }
public List <Recording> GrabRecordings(int userID) { List <Recording> recordings = new List <Recording>(); table = application.GetTable(GetTableID("Recordings")); table.Query(); QRecordCollection records = table.Records; for (int j = 0; j < records.Count; j++) { if (records.ElementAt(j)[1] == userID.ToString()) { int id; if (Int32.TryParse(records.ElementAt(j)[1], out id)) { recordings.Add(new Recording(id, records.ElementAt(j)[2])); } } } return(recordings); }
public bool CreateUser(String userName, String password) { table = application.GetTable(GetTableID("Users")); //check the passwords before calling method table.Query(); bool userCreated = false; IQRecord tempUser = table.Records.Where(x => x[1] == userName).SingleOrDefault(); if (tempUser == null) { tempUser = table.NewRecord(); tempUser[0] = curUserID.ToString(); tempUser[1] = userName; tempUser[2] = password; table.Records.Add(tempUser); table.AcceptChanges(); userCreated = true; } else { //Error username exists } return(userCreated); }
public bool SignIn(String userName, String password) { table = application.GetTable(GetTableID("Users")); table.Query(); bool userLoggedIn = false; IQRecord prevUser = table.Records.Where(x => x[1] == userName).SingleOrDefault(); if (prevUser != null) { if (prevUser[2] == password) { userLoggedIn = true; } else { //User found wrong password } } else { //User not found, make sure that person entered their name correctly } return(userLoggedIn); }
internal override IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns) { return(new QRecord(application, table, columns)); }
internal abstract IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns);
internal abstract IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns, XPathNavigator recordNode);
internal abstract IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns);
internal abstract IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns, XPathNavigator recordNode);
internal override IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns, XPathNavigator recordNode) { return new QRecord(application, table, columns, recordNode); }
internal QRecord(IQApplication application, IQTable table, QColumnCollection columns, XPathNavigator recordNode) : this(application, table, columns) { FillRecord(recordNode); }
internal QRecord(IQApplication application, IQTable table, QColumnCollection columns, XPathNavigator recordNode) : this(application, table, columns) { FillRecord(recordNode); }
public QColumnCollection(IQApplication application, IQTable table) { Application = application; Table = table; }
internal override IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns) { return new QRecord(application, table, columns); }
internal override IQRecord CreateInstance(IQApplication application, IQTable table, QColumnCollection columns, XPathNavigator recordNode) { return(new QRecord(application, table, columns, recordNode)); }
public QRecordCollection(IQApplication application, IQTable table) { Application = application; Table = table; }
public void DeletionTest() { InitConnection(); List <GrantedAppsInfo> appsLst = qbApp.GrantedDBs(); foreach (var app in appsLst) { foreach (var tab in app.GrantedTables) { if (tab.Name == "APITestApp: APIDelTestTable") { IQTable tbl = qbApp.GetTable(tab.Dbid); qbApp.DeleteTable(tbl); break; } } } IQTable testTable = qbApp.NewTable("APIDelTestTable", "dummyRec"); testTable.Columns.Add(new QColumn("NumberValue", FieldType.@float)); testTable.Columns.Add(new QColumn("TextValue", FieldType.text)); IQRecord newRec = testTable.NewRecord(); newRec["NumberValue"] = 0; newRec["TextValue"] = "Zeroeth"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 1; newRec["TextValue"] = "First"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 2; newRec["TextValue"] = "Second"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 3; newRec["TextValue"] = "Third"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 4; newRec["TextValue"] = "Fourth"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 5; newRec["TextValue"] = "Fifth"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 6; newRec["TextValue"] = "Sixth"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 7; newRec["TextValue"] = "Seventh"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 8; newRec["TextValue"] = "Eighth"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 9; newRec["TextValue"] = "Ninth"; testTable.Records.Add(newRec); newRec = testTable.NewRecord(); newRec["NumberValue"] = 10; newRec["TextValue"] = "Tenth"; testTable.Records.Add(newRec); testTable.AcceptChanges(); testTable.Records.RemoveAt(10); testTable.Records.RemoveAt(8); testTable.Records.RemoveAt(7); testTable.Records.RemoveAt(6); testTable.Records.RemoveAt(3); testTable.Records.RemoveAt(1); testTable.AcceptChanges(); testTable.Query(); Assert.AreEqual(testTable.Records.Count, 5, "Record deletion fails"); }
internal QRecord(IQApplication application, IQTable table, QColumnCollection columns, XElement recordNode) : this(application, table, columns) { FillRecord(recordNode); }
public void DeleteTable(IQTable table) { var tableId = table.TableId; if (!_qbDataTables.ContainsKey(tableId)) { throw new TableDoesNotExistInQuickBase("Table does not exist in this instance of QApplication."); } var deleteTbl = new DeleteDatabase(Client.Ticket, Token, Client.AccountDomain, tableId); deleteTbl.Post(); _qbDataTables.Remove(tableId); }
public void BasicCreationAndRoundTripTest() { InitConnection(); List <GrantedAppsInfo> appsLst = qbApp.GrantedDBs(); foreach (var app in appsLst) { foreach (var tab in app.GrantedTables) { if (tab.Name == "APITestApp: APITestTable") { IQTable tbl = qbApp.GetTable(tab.Dbid); qbApp.DeleteTable(tbl); break; } } } IQTable testTable = qbApp.NewTable("APITestTable", "dummyRec"); testTable.Columns.Add(new QColumn("TextTest", FieldType.text)); testTable.Columns.Add(new QColumn("FloatTest", FieldType.@float)); testTable.Columns.Add(new QColumn("CheckboxTest", FieldType.checkbox)); testTable.Columns.Add(new QColumn("DateTest", FieldType.date)); testTable.Columns.Add(new QColumn("TimeStampTest", FieldType.timestamp)); testTable.Columns.Add(new QColumn("TimeOfDayTest", FieldType.timeofday)); testTable.Columns.Add(new QColumn("DurationTest", FieldType.duration)); testTable.Columns.Add(new QColumn("CurrencyTest", FieldType.currency)); testTable.Columns.Add(new QColumn("PercentTest", FieldType.percent)); testTable.Columns.Add(new QColumn("EmailTest", FieldType.email)); testTable.Columns.Add(new QColumn("PhoneTest", FieldType.phone)); testTable.Columns.Add(new QColumn("UrlTest", FieldType.url)); testTable.Columns.Add(new QColumn("MultiTextTest", FieldType.multitext)); testTable.Columns.Add(new QColumn("RatingTest", FieldType.rating)); testTable.Columns.Add(new QColumn("FileTest", FieldType.file)); foreach (string val in multiTextOptions) { testTable.Columns["MultiTextTest"].AddChoice(val); } TestRecord exemplar = new TestRecord(); exemplar.SetupTestValues(); IQRecord inRec = testTable.NewRecord(); inRec["TextTest"] = exemplar.textVal; inRec["FloatTest"] = exemplar.floatVal; inRec["CheckboxTest"] = exemplar.checkboxVal; inRec["DateTest"] = exemplar.dateVal; inRec["TimeStampTest"] = exemplar.timeStampVal; inRec["TimeOfDayTest"] = exemplar.timeOfDayVal; inRec["DurationTest"] = exemplar.durationVal; inRec["CurrencyTest"] = exemplar.currencyVal; inRec["PercentTest"] = exemplar.percentVal; inRec["EmailTest"] = exemplar.emailVal; inRec["PhoneTest"] = exemplar.phoneVal; inRec["UrlTest"] = exemplar.urlVal; inRec["MultiTextTest"] = exemplar.multiTextVal; inRec["RatingTest"] = exemplar.ratingVal; Assert.AreEqual(exemplar.textVal, inRec["TextTest"], "Strings setter fails"); Assert.AreEqual(exemplar.floatVal, inRec["FloatTest"], "Floats setter fails"); Assert.AreEqual(exemplar.checkboxVal, inRec["CheckboxTest"], "Checkboxes setter fails"); Assert.AreEqual(exemplar.dateVal, inRec["DateTest"], "Dates setter fails"); Assert.AreEqual(exemplar.timeStampVal, inRec["TimeStampTest"], "TimeStamps setter fails"); Assert.AreEqual(exemplar.timeOfDayVal, inRec["TimeOfDayTest"], "TimeOfDays setter fails"); Assert.AreEqual(exemplar.durationVal, inRec["DurationTest"], "Durations setter fails"); Assert.AreEqual(exemplar.currencyVal, inRec["CurrencyTest"], "Currency setter fails"); Assert.AreEqual(exemplar.percentVal, inRec["PercentTest"], "Percent setter fails"); Assert.AreEqual(exemplar.emailVal, inRec["EmailTest"], "Email setter fails"); Assert.AreEqual(exemplar.phoneVal, inRec["PhoneTest"], "Phone setter fails"); Assert.AreEqual(exemplar.urlVal, inRec["UrlTest"], "Url setter fails"); Assert.AreEqual(exemplar.multiTextVal, inRec["MultiTextTest"], "MultiTextSetter fails"); Assert.AreEqual(exemplar.ratingVal, inRec["RatingTest"], "RatingSetter fails"); testTable.Records.Add(inRec); testTable.AcceptChanges(); Assert.AreEqual(exemplar.textVal, inRec["TextTest"], "Strings wrong post upload"); Assert.AreEqual(exemplar.floatVal, inRec["FloatTest"], "Floats wrong post upload"); Assert.AreEqual(exemplar.checkboxVal, inRec["CheckboxTest"], "Checkboxes wrong post upload"); Assert.AreEqual(exemplar.dateVal, inRec["DateTest"], "Dates wrong post upload"); Assert.AreEqual(exemplar.timeStampVal, inRec["TimeStampTest"], "TimeStamps wrong post upload"); Assert.AreEqual(exemplar.timeOfDayVal, inRec["TimeOfDayTest"], "TimeOfDays wrong post upload"); Assert.AreEqual(exemplar.durationVal, inRec["DurationTest"], "Durations wrong post upload"); Assert.AreEqual(exemplar.currencyVal, inRec["CurrencyTest"], "Currency wrong post upload"); Assert.AreEqual(exemplar.percentVal, inRec["PercentTest"], "Percent wrong post upload"); Assert.AreEqual(exemplar.emailVal, inRec["EmailTest"], "Email wrong post upload"); Assert.AreEqual(exemplar.phoneVal, inRec["PhoneTest"], "Phone wrong post upload"); Assert.AreEqual(exemplar.urlVal, inRec["UrlTest"], "Url wrong post upload"); Assert.IsTrue(exemplar.multiTextVal.SetEquals((HashSet <int>)inRec["MultiTextTest"]), "MultiText wrong post upload"); Assert.AreEqual(exemplar.ratingVal, inRec["RatingTest"], "Rating wrong post upload"); testTable.Records.Clear(); testTable.Query(); IQRecord outRec = testTable.Records[0]; Assert.AreEqual(exemplar.textVal, outRec["TextTest"], "Strings roundtrip fail"); Assert.AreEqual(exemplar.floatVal, outRec["FloatTest"], "Floats roundtrip fail"); Assert.AreEqual(exemplar.checkboxVal, outRec["CheckboxTest"], "Checkboxes roundtrip fail"); Assert.AreEqual(exemplar.dateVal, outRec["DateTest"], "Dates roundtrip fail"); Assert.AreEqual(exemplar.timeStampVal, outRec["TimeStampTest"], "TimeStamps roundtrip fail"); Assert.AreEqual(exemplar.timeOfDayVal, outRec["TimeOfDayTest"], "TimeOfDays roundtrip fail"); Assert.AreEqual(exemplar.durationVal, outRec["DurationTest"], "Durations roundtrip fail"); Assert.AreEqual(exemplar.currencyVal, outRec["CurrencyTest"], "Currencies roundtrip fail"); Assert.AreEqual(exemplar.percentVal, outRec["PercentTest"], "Percents roundtrip fail"); Assert.AreEqual(exemplar.emailVal, outRec["EmailTest"], "Emails roundtrip fail"); Assert.AreEqual(exemplar.phoneVal, outRec["PhoneTest"], "Phones roundtrip fail"); Assert.AreEqual(exemplar.urlVal, outRec["UrlTest"], "Url roundtrip fail"); Assert.IsTrue(exemplar.multiTextVal.SetEquals((HashSet <int>)outRec["MultiTextTest"]), "MultiText roundtrip fail"); Assert.AreEqual(exemplar.ratingVal, outRec["RatingTest"], "Rating roundtrip fail"); exemplar.Setup2ndValues(); outRec["TextTest"] = exemplar.textVal; outRec["FloatTest"] = exemplar.floatVal; outRec["CheckboxTest"] = exemplar.checkboxVal; outRec["DateTest"] = exemplar.dateVal; outRec["TimeStampTest"] = exemplar.timeStampVal; outRec["TimeOfDayTest"] = exemplar.timeOfDayVal; outRec["DurationTest"] = exemplar.durationVal; outRec["CurrencyTest"] = exemplar.currencyVal; outRec["PercentTest"] = exemplar.percentVal; outRec["EmailTest"] = exemplar.emailVal; outRec["PhoneTest"] = exemplar.phoneVal; outRec["UrlTest"] = exemplar.urlVal; outRec["MultiTextTest"] = exemplar.multiTextVal; outRec["RatingTest"] = exemplar.ratingVal; testTable.AcceptChanges(); testTable.Query(); IQRecord outRec2 = testTable.Records[0]; Assert.AreEqual(exemplar.textVal, outRec2["TextTest"], "Strings update fail"); Assert.AreEqual(exemplar.floatVal, outRec2["FloatTest"], "Floats update fail"); Assert.AreEqual(exemplar.checkboxVal, outRec2["CheckboxTest"], "Checkboxes update fail"); Assert.AreEqual(exemplar.dateVal, outRec2["DateTest"], "Dates update fail"); Assert.AreEqual(exemplar.timeStampVal, outRec2["TimeStampTest"], "TimeStamps update fail"); Assert.AreEqual(exemplar.timeOfDayVal, outRec2["TimeOfDayTest"], "TimeOfDays update fail"); Assert.AreEqual(exemplar.durationVal, outRec2["DurationTest"], "Durations update fail"); Assert.AreEqual(exemplar.currencyVal, outRec2["CurrencyTest"], "Currencies update fail"); Assert.AreEqual(exemplar.percentVal, outRec2["PercentTest"], "Percents update fail"); Assert.AreEqual(exemplar.emailVal, outRec2["EmailTest"], "Emails update fail"); Assert.AreEqual(exemplar.phoneVal, outRec2["PhoneTest"], "Phones update fail"); Assert.AreEqual(exemplar.urlVal, outRec2["UrlTest"], "Url update fail"); Assert.IsTrue(exemplar.multiTextVal.SetEquals((HashSet <int>)outRec2["MultiTextTest"]), "MultiText update fail"); Assert.AreEqual(exemplar.ratingVal, outRec2["RatingTest"], "Rating update fail"); }