public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection) { bool status = true; SQLExpression userID = null; status &= BqlCommand.AppendExpression <UserID>(ref userID, graph, info, selection, ref _operand); if (graph == null || !info.BuildExpression) { return(status); } SimpleTable epEmployee = new SimpleTable <EPEmployee>(EMPLOYEERALIAS); exp = exp.In(new Query() .Select <EPWingman.employeeID>().From <EPWingman>() .InnerJoin(epEmployee) .On(new Column <EPEmployee.bAccountID>(epEmployee).EQ(new Column(typeof(EPWingman.wingmanID))) .And(new Column <EPEmployee.userID>(epEmployee).EQ(userID))) .Where(new SQLConst(1) .EQ(new SQLConst(1)))); return(status); }
public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection) { bool status = true; SQLExpression userID = null; status &= BqlCommand.AppendExpression <UserID>(ref userID, graph, info, selection, ref _operand); if (graph == null) { return(status); } exp.VerifyComparisonExpression(); SimpleTable epEmployee = new SimpleTable <EPEmployee>(EMPLOYEERALIAS); exp.SetOper(SQLExpression.Operation.IN); exp = exp.LExpr().In(new Query() .Select <EPWingman.employeeID>().From <EPWingman>() .InnerJoin(epEmployee) .On(new Column <EPEmployee.bAccountID>(epEmployee).Equal(new Column(typeof(EPWingman.wingmanID))) .And(new Column <EPEmployee.userID>(epEmployee).Equal(userID))) .Where(PX.Data.SQLTree.Constant.SQLConstant(1) .Equal(PX.Data.SQLTree.Constant.SQLConstant(1)))); return(status); }
public void TestAssigmentFromDifferentInstance() { string text = "Foobar"; string text2 = "Hello world"; SimpleTable row = new SimpleTable(); row.Field = text; row.Property = text; Assert.IsTrue(row.Save()); SimpleTable row2 = new SimpleTable(); row2.Field = row.Property; row2.Property = row.Field; Assert.IsTrue(row2.Save()); Assert.AreEqual(row.Field, row2.Field); Assert.AreEqual(row.Property, row2.Property); row2.Field = text2; row2.Property = text2; Assert.IsTrue(row2.Save()); Assert.AreNotEqual(row.Field, row2.Field); Assert.AreNotEqual(row.Property, row2.Property); }
private SimpleTable SerializeAndParse(FlatBufferSerializerOptions options, out WeakReference <byte[]> buffer) { SimpleTable table = new SimpleTable { String = "hi", Struct = new SimpleStruct { Byte = 1, Long = 2, Uint = 3 }, StructVector = new List <SimpleStruct> { new SimpleStruct { Byte = 4, Long = 5, Uint = 6 } }, }; var serializer = new FlatBufferSerializer(options); var rawBuffer = new byte[1024]; serializer.Serialize(table, rawBuffer); buffer = new WeakReference <byte[]>(rawBuffer); string csharp = serializer.Compile <SimpleTable>().CSharp; return(serializer.Parse <SimpleTable>(rawBuffer)); }
public static StandardResult <bool> Execute(SimpleTable sourceTable) { foreach (var row in sourceTable) { var message = new MailMessage(row["Mail-From"], row["Mail-To"]) { Subject = row["Mail-Subject"], Body = row["Mail-Body"] }; if (sourceTable.ContainColumn("Mail-CC")) { var cc = row["Mail-CC"]; if (!string.IsNullOrWhiteSpace(cc)) { message.CC.Add(cc); } } message.IsBodyHtml = true; var result = SendEMail.Execute(message); if (result.HasError) { return(result); } } return(StandardResult <bool> .ReturnResult(true)); }
public void TableWithStructAndString() { SimpleTable table = new SimpleTable { String = "hi", Struct = new SimpleStruct { Byte = 1, Long = 2, Uint = 3 } }; byte[] buffer = new byte[1024]; byte[] expectedData = { 4, 0, 0,0, // uoffset to table start 228, 255, 255,255, // soffet to vtable (4 - x = 24 => x = -20) 32, 0, 0,0, // uoffset to string 0, 0, 0,0, // padding 2, 0, 0,0, 0, 0, 0, 0, // struct.long 1, // struct.byte 0, 0, 0, // padding 3, 0, 0,0, // struct.uint 8, 0, // vtable length 28, 0, // table length 4, 0, // index 0 offset 12, 0, // Index 1 offset 2, 0, 0,0, // string length 104, 105, 0, // hi + null terminator }; int bytesWritten = FlatBufferSerializer.Default.Serialize(table, buffer); Assert.IsTrue(expectedData.AsSpan().SequenceEqual(buffer.AsSpan().Slice(0, bytesWritten))); }
public void TableWithStruct() { SimpleTable table = new SimpleTable { Struct = new SimpleStruct { Byte = 1, Long = 2, Uint = 3 } }; byte[] buffer = new byte[1024]; byte[] expectedData = { 4, 0, 0,0, // uoffset to table start 236, 255, 255,255, // soffet to vtable (4 - x = 24 => x = -20) 2, 0, 0,0, 0, 0, 0, 0, // struct.long 1, // struct.byte 0, 0, 0, // padding 3, 0, 0,0, // struct.uint 8, 0, // vtable length 20, 0, // table length 0, 0, // index 0 offset 4, 0, // Index 1 offset }; int bytesWritten = FlatBufferSerializer.Default.Serialize(table, buffer); Assert.IsTrue(expectedData.AsSpan().SequenceEqual(buffer.AsSpan().Slice(0, bytesWritten))); }
public void Test() { SimpleTable table = new SimpleTable("something"); //table.Select().AllColumns().AddEqualClauses(); HttpClient client = new HttpClient(); }
public void SaveXml(string SavePath) { XmlWriterSettings settings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true }; FileStream stream = new FileStream(SavePath, FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter streamWriter = new StreamWriter(stream, Encoding.UTF8); using (XmlWriter writer = XmlWriter.Create(streamWriter, settings)) { SimpleTable table = GetTable(); writer.WriteStartElement("Conversation"); writer.WriteStartElement("Params"); writer.WriteElementString("Name", _name); writer.WriteEndElement(); writer.WriteStartElement("Messages"); for (int i = 0; i < table.data.Count; ++i) { writer.WriteStartElement("Message"); writer.WriteElementString("User", table.data[i][0]); writer.WriteElementString("DateTime", table.data[i][1]); writer.WriteElementString("Text", XmlConvert.EncodeName(table.data[i][2])); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } }
public static StandardResult <string> Execute(SimpleTable table, bool escape = true) { var sb = new StringBuilder(); foreach (var column in table.ColumnNames) { sb.Append(column); sb.Append('\t'); } sb.Length = sb.Length - 1; sb.AppendLine(); foreach (var row in table) { for (int i = 0; i < row.ColumnCount; i++) { var value = row[i]; if (escape) { value = Escape(value); } sb.Append(value); sb.Append('\t'); } sb.Length = sb.Length - 1; sb.AppendLine(); } return(StandardResult <string> .ReturnResult(sb.ToString())); }
public ActionResult SimpleTable() { var p = new SimpleTable(); p.Main(); return(Ok()); }
/** * Gets a table based on the styleattributes. * * @param attributes * @param styleattributes * @return an iText Table */ private IElement RetrieveTable(Properties attributes, Properties styleattributes) { SimpleTable table = new SimpleTable(); ApplyBordersColors(table, attributes, styleattributes); return(table); }
public static StandardResult <SimpleTable> Execute(SimpleTable sourceTable, SimpleTable expandTable) { if (sourceTable == null) { return(StandardResult <SimpleTable> .ReturnError("ExpandTable() error: source table null")); } if (expandTable == null) { return(StandardResult <SimpleTable> .ReturnError("ExpandTable() error: aggregate table null")); } var newTable = sourceTable.Copy(); // create columns foreach (var map in expandTable) { var source = map["source"]; var destination = map["destination"]; newTable.AddColumnName(destination); var expression = ExpressionCache.Compile(source); if (expression == null) { return(StandardResult <SimpleTable> .ReturnError("AggregateTable() error: evaluator returns null", "Source: " + source)); } } var fieldSource = new FieldDataSource(); foreach (var newRow in newTable) { fieldSource.Row = newRow; foreach (var map in expandTable) { var source = map["source"]; var destination = map["destination"]; var expression = ExpressionCache.Compile(source); var result = expression.Evaluate(new Context() { FieldSource = fieldSource }); if (result.IsError) { return(StandardResult <SimpleTable> .ReturnError("ExpandTable() error: occurred during evaluating: " + expression.Parser.Tokenizer.Expression, result.String)); } newRow[destination] = ToString(result); } } return(StandardResult <SimpleTable> .ReturnResult(newTable)); }
public static StandardResult <SimpleTable> Execute(string data, string newRow, char delimiter = '=', IList <string> columns = null) { var lines = data.Split(new string[] { "\r\n" }, StringSplitOptions.None); var table = new SimpleTable(); if (columns != null) { for (int i = 0; i < columns.Count; i++) { table.SetColumnName(i, columns[i]); } } SimpleTableRow row = null; foreach (var line in lines) { if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("#")) { continue; } if (line == newRow) { row = table.CreateRow(); continue; } int pos = line.IndexOf(delimiter); if (pos < 0) { continue; } string name = line.Substring(0, pos); string value = line.Substring(pos + 1); if (columns == null && !table.ContainColumn(name)) { table.SetColumnName(table.ColumnNames.Count, name); } if (table.ContainColumn(name)) { row.SetField(name, value); } } return(StandardResult <SimpleTable> .ReturnResult(table)); }
public static StandardResult <SimpleTable> Execute(SimpleTable sourceTable, string sourceKeyField, string mergeField, SimpleTable lookupTable, string lookupKeyField, string lookupDataField, bool overwrite, bool caseInsensitive = true) { if (!sourceTable.ColumnNames.Contains(sourceKeyField)) { return(StandardResult <SimpleTable> .ReturnError("LookupUpdateTable() error: source key field does not exists: " + sourceKeyField)); } if (!sourceTable.ColumnNames.Contains(mergeField)) { return(StandardResult <SimpleTable> .ReturnError("LookupUpdateTable() error: merge field does not exists: " + mergeField)); } var newTable = new SimpleTable(); foreach (var column in sourceTable.ColumnNames) { newTable.AddColumnName(column); } foreach (var sourceRow in sourceTable) { var newRow = newTable.CreateRow(); for (int i = 0; i < sourceRow.ColumnCount; i++) { var value = sourceRow[i]; if (value == null) { continue; } newRow[i] = value; } } foreach (var row in newTable) { string key = row[sourceKeyField]; if (!overwrite && !string.IsNullOrWhiteSpace(row[mergeField])) { continue; } if (caseInsensitive) { key = key.ToLower(); } string lookup = Lookup(lookupTable, key, lookupKeyField, lookupDataField); row[mergeField] = lookup; } return(StandardResult <SimpleTable> .ReturnResult(newTable)); }
public SimpleTable GetTable() { if (messages != null) { Data = new SimpleTable(messages); return(Data); } return(null); }
public static StandardResult <SimpleTable> Execute(string data, bool containsHeader = true, bool mapHeaderNames = true, bool unespace = true) { var lines = data.Split(new string[] { "\r\n" }, StringSplitOptions.None); var start = 0; var table = new SimpleTable(); if (containsHeader) { start = 1; if (mapHeaderNames) { var parts = lines[0].Split('\t'); for (int i = 0; i < parts.Length; i++) { var value = parts[i]; if (string.IsNullOrWhiteSpace(value)) { continue; } table.SetColumnName(i, value); } } } for (int index = start; index < lines.Length; index++) { var line = lines[index]; if (index + 1 == lines.Length && string.IsNullOrWhiteSpace(line)) { continue; } var parts = line.Split('\t'); var row = table.CreateRow(); for (int i = 0; i < parts.Length; i++) { var part = parts[i]; if (unespace) { part = Unescape(part); } row.SetField(i, part); } } return(StandardResult <SimpleTable> .ReturnResult(table)); }
public void Union_2Items_StringAndTable_RoundTrip() { var expectedString = "foobar"; var expectedInt = 123; var expectedTable = new SimpleTable { Int = expectedInt }; Assert.AreEqual(expectedString, CreateAndDeserialize1(expectedString, expectedTable)); Assert.AreEqual(expectedInt, CreateAndDeserialize2(expectedString, expectedTable).Int); }
public void SimpleTable_FindTableWithinElement_SameOutComeAsFromWebDriver() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElementFromWebDriver = simpleTable.ColspanTableElement; var tableElementFromElement = simpleTable.TableParent.FindTableElement(By.XPath("./thead/tr/th"), By.XPath("./tbody/tr")); tableElementFromElement.Should().BeEquivalentTo(tableElementFromWebDriver, options => options.Excluding(x => x.SelectedMemberPath.EndsWith("Id"))); }
public void SimpleTable_ReturnsITableElementAndITableRowElements() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElement = simpleTable.ColspanTableElement; tableElement.Should().BeAssignableTo <ITableElement>(); tableElement.TableRowElements.Should().BeAssignableTo <ReadOnlyCollection <ITableRowElement> >(); }
public void SimpleTable_HasRowsAndHeaders() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElement = simpleTable.ColspanTableElement; tableElement.TableHeaderValues.Should().HaveCount(3); tableElement.TableRowElements.Should().HaveCount(2); }
public void SimpleTable_HeaderValueNotFound_ThrowsNoSuchElementException() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElement = simpleTable.ColspanTableElement; Action act = () => tableElement.TableRowElements.First().GetColumn("NotExistingHeaderError"); act.Should().Throw <NoSuchElementException>().WithMessage("Header 'NotExistingHeaderError' does not exist, available headers:\nFirst name\nLast name\nDate of birth"); }
public void SimpleTable_MatchHeaderWithColumn() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElement = simpleTable.ColspanTableElement; var tableRowElement = tableElement.TableRowElements.Single(x => x.GetColumn("First name").Text == "Beta"); tableRowElement.GetColumn("Last name").Text.Should().Be("Bit"); tableRowElement.GetColumn("Date of birth").Text.Should().Be("01-10-2002"); }
public void SimpleTable_TableRowElementWithoutColumnSelector() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableRowElement = simpleTable.SingleTableRowWithoutColumnSelector; tableRowElement.GetColumn(0).Text.Should().Be("Ronald"); tableRowElement.GetColumn("Last name").Text.Should().Be("Veth"); tableRowElement.GetColumn("Date of birth").Text.Should().Be("22-12-1987"); }
public override void OnInspectorGUI() { DrawDefaultInspector(); _ctr = (SimpleTable)target; GUILayout.Space(20); if (GUILayout.Button("Fresh", GUILayout.Height(30))) { _ctr.Fresh(); } }
/// <summary> /// Binds a DataSource to this GuiGrid. Binding supports SimpleTables, DataTables, DataViews, and other IEnumerable classes. /// </summary> /// <param name="dataSource">The data source object to bind.</param> public void BindData(object dataSource) { #if !HTML_HELP if (dataSource is SimpleTable) { this.DataSource = dataSource as SimpleTable; } else { this.DataSource = SimpleTableTools.ConvertToSimpleTable(dataSource); } #endif }
public void SimpleTable_FindTableElement_UseCollectionOfHeaderElementsAndRowElements() { var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElementFromWebDriver = simpleTable.ColspanTableElement; var tableHeaderCollection = simpleTable.TableHeaders; var tableRowCollection = simpleTable.TableRows; var tableElementFromElement = _webDriver.FindTableElement(tableHeaderCollection, tableRowCollection); tableElementFromElement.Should().BeEquivalentTo(tableElementFromWebDriver, options => options.Excluding(x => x.SelectedMemberPath.EndsWith("Id"))); }
public void SimpleTable_HeaderValues() { var expectedHeaders = new List <string>() { "First name", "Last name", "Date of birth" }; var simpleTable = new SimpleTable(_webDriver); simpleTable.Open(); var tableElement = simpleTable.ColspanTableElement; tableElement.TableHeaderValues.Should().BeEquivalentTo(expectedHeaders, options => options.WithStrictOrdering()); tableElement.TableRowElements.First().TableHeaderValues.Should().BeEquivalentTo(expectedHeaders, options => options.WithStrictOrdering()); }
private void BuildWidgets() { HBox split_box = new HBox(); VBox content_box = new VBox(); content_box.BorderWidth = 5; title = new Label(); SetTitleText(dap.Name); title.Xalign = 0.0f; // Define custom preference widgetry var hbox = new HBox(); table = new SimpleTable <DapLibrarySync> (); dap.Sync.LibraryAdded += l => AddLibrary(l); dap.Sync.LibraryRemoved += l => RemoveLibrary(l); foreach (var sync in dap.Sync.Libraries) { AddLibrary(sync); } hbox.PackStart(table, false, false, 0); hbox.ShowAll(); dap.Preferences["sync"]["library-options"].DisplayWidget = hbox; var properties = new Banshee.Preferences.Gui.NotebookPage(dap.Preferences) { BorderWidth = 0 }; content_box.PackStart(title, false, false, 0); content_box.PackStart(properties, false, false, 0); var image = new Image(LargeIcon) { Yalign = 0.0f }; split_box.PackStart(image, false, true, 0); split_box.PackEnd(content_box, true, true, 0); Add(split_box); ShowAll(); }
public void Union_2Items_TableAndStruct_RoundTrip() { var expectedStruct = new SimpleStruct { Long = 123 }; var expectedTable = new SimpleTable { Int = 456 }; var testStruct = CreateAndDeserialize1(expectedStruct, expectedTable); Assert.AreEqual(testStruct.Long, 123); var testTable = CreateAndDeserialize2(expectedStruct, expectedTable); Assert.AreEqual(testTable.Int, 456); }
private void btnCreate_Click(object sender, EventArgs e) { string CONN = Path.Combine(Application.StartupPath, "test.db3"); DbConnection.Initialise("Data Source=" + CONN, Assembly.GetExecutingAssembly()); DbConnection.SqlListeners += DbConnection_SqlListeners; using (DbConnection conn = new DbConnection()) { //// CREATE //SimpleTable simple = new SimpleTable() { Id = 5, Test = "Hello", When = DateTime.UtcNow }; //simple.Save(); //Console.WriteLine("Simple[5]: Test='" + SimpleTable.Read(5).Test + "'"); //// UPDATE //simple.Test = "Updated"; //simple.Save(); //Console.WriteLine("Simple[5]: Test='" + SimpleTable.Read(5).Test + "'"); //// DELETE //SimpleTable.Delete(5); //Console.WriteLine("Simple[5]: " + (SimpleTable.Read(5) == null ? "null" : "not null")); ////using (DbTransaction tran = DbTransaction.BeginTransaction()) ////{ //// simple = new SimpleTable() { Id = 9, Test = "Hello" }; //// simple.Save(); //// tran.Commit(); ////} //Console.WriteLine("Simple[9]: " + (SimpleTable.Read(9) == null ? "null" : "not null")); List<SimpleTable> simList = new List<SimpleTable>(); for (int i = 2; i < 4; i++) { var item = new SimpleTable() { Id = i, Test = "Hello", When = DateTime.UtcNow }; simList.Add(item); } //SimpleTable simple = new SimpleTable() { Id = 2, Test = "Hello", When = DateTime.UtcNow }; //using (BaseDal<SimpleTable> adapter = BaseDal<SimpleTable>.Open()) //{ // adapter.Insert(simList); //} SimpleTable simple = new SimpleTable() { Id = 2, Test = "SSS", When = DateTime.UtcNow }; using (BaseDal<SimpleTable> adapter = BaseDal<SimpleTable>.Open()) { adapter.Update(simple); } ////-- //SimpleEntityDemo(); //BigListRowSelect(); //ParameterizedTableNameDemo(); //// AnonymousTableDemo(); //ExpressionTreeDemo(); //RolesPermissionsDemo(); } }
private void BuildWidgets() { HBox split_box = new HBox (); VBox content_box = new VBox (); content_box.BorderWidth = 5; title = new Label (); SetTitleText (dap.Name); title.Xalign = 0.0f; // Define custom preference widgetry var hbox = new HBox (); table = new SimpleTable<DapLibrarySync> (); dap.Sync.LibraryAdded += l => AddLibrary (l); dap.Sync.LibraryRemoved += l => RemoveLibrary (l); foreach (var sync in dap.Sync.Libraries) { AddLibrary (sync); } hbox.PackStart (table, false, false, 0); hbox.ShowAll (); dap.Preferences["sync"]["library-options"].DisplayWidget = hbox; var properties = new Banshee.Preferences.Gui.NotebookPage (dap.Preferences) { BorderWidth = 0 }; content_box.PackStart (title, false, false, 0); content_box.PackStart (properties, false, false, 0); var image = new Image (LargeIcon) { Yalign = 0.0f }; split_box.PackStart (image, false, true, 0); split_box.PackEnd (content_box, true, true, 0); Add (split_box); ShowAll (); }
private void OnMerge (object o, EventArgs a) { var discs = library.BooksModel.SelectedItems.OrderBy (d => d.Title).ToList (); var author = DatabaseArtistInfo.Provider.FetchSingle ((discs[0] as DatabaseAlbumInfo).ArtistId); var dialog = new HigMessageDialog ( ServiceManager.Get<GtkElementsService> ().PrimaryWindow, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, String.Format (Catalog.GetPluralString ( "Merge the {0} selected discs into one book?", "Merge the {0} selected discs into one book?", discs.Count), discs.Count), Catalog.GetString ( "This will ensure the disc numbers are all " + "set properly, and then set the author and book title for all tracks " + "on all these discs to the values below") ); var table = new SimpleTable<int> (); var author_entry = new Entry () { Text = discs[0].ArtistName }; table.AddRow (0, new Label (Catalog.GetString ("Author:")) { Xalign = 0 }, author_entry ); var trimmings = new char [] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '-' }; var title_entry = new Entry () { Text = discs[0].Title.Trim (trimmings) }; table.AddRow (1, new Label (Catalog.GetString ("Book Title:")) { Xalign = 0 }, title_entry ); dialog.LabelVBox.PackStart (table, false, false, 0); dialog.ShowAll (); var response = dialog.Run (); string title = title_entry.Text; string author_name = author_entry.Text; dialog.Destroy (); if (response == (int)Gtk.ResponseType.Ok && !String.IsNullOrEmpty (title)) { if (author_name != author.Name) { author = DatabaseArtistInfo.FindOrCreate (author_name, null); } var book = DatabaseAlbumInfo.FindOrCreate (author, title, null, false); int disc_num = 1; foreach (DatabaseAlbumInfo disc in discs) { // Update the disc num/count field for all tracks on this 'book' (actually just one disc of a book) ServiceManager.DbConnection.Execute ( @"UPDATE CoreTracks SET AlbumID = ?, Disc = ?, DiscCount = ?, DateUpdatedStamp = ? WHERE PrimarySourceID = ? AND AlbumID = ?", book.DbId, disc_num++, discs.Count, DateTime.Now, library.DbId, disc.DbId ); } // Update the MetadataHash for all those tracks DatabaseTrackInfo.UpdateMetadataHash ( book.Title, author.Name, String.Format ("PrimarySourceId = {0} AND AlbumID = {1}", library.DbId, book.DbId) ); library.NotifyTracksChanged (); } }