Here are the examples of the csharp api System.Data.DataTable.NewRow() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
564 Examples
19
Source : ResultsInterpreter.cs
with MIT License
from ABN-SFLookupTechnicalSupport
with MIT License
from ABN-SFLookupTechnicalSupport
public static DataTable DisplayNamesInGrid(ServiceReferenceAbnLookupRpc.Payload payload) {
DataRow MatchingName;
DataTable MatchingNames = CreateNewNamesDataTable();
int NameIndex = 0;
ServiceReferenceAbnLookupRpc.ResponseSearchResultsList Names = (ServiceReferenceAbnLookupRpc.ResponseSearchResultsList)payload.Response.ResponseBody;
try {
while (NameIndex < Names.NumberOfRecords) {
ServiceReferenceAbnLookupRpc.SearchResultsRecord Name = Names.SearchResultsRecord[NameIndex];
MatchingName = MatchingNames.NewRow();
MatchingName["ABN"] = Name.ABN[0].IdentifierValue;
ServiceReferenceAbnLookupRpc.OrganisationSimpleName SimpleName = (ServiceReferenceAbnLookupRpc.OrganisationSimpleName)Name.Name[0];
MatchingName["Enreplacedy Name"] = SimpleName.OrganisationName;
MatchingName["Score"] = SimpleName.Score;
MatchingName["State"] = Name.MainBusinessPhysicalAddress[0].StateCode;
MatchingName["Postcode"] = Name.MainBusinessPhysicalAddress[0].Postcode;
MatchingNames.Rows.Add(MatchingName);
NameIndex++;
}
return MatchingNames;
}
catch {
throw;
}
}
19
Source : ResultsInterpreter.cs
with MIT License
from ABN-SFLookupTechnicalSupport
with MIT License
from ABN-SFLookupTechnicalSupport
public static DataTable DisplayNamesInGrid(ServiceReferenceAbnLookup.Payload payload) {
DataRow MatchingName;
DataTable MatchingNames = CreateNewNamesDataTable();
int NameIndex = 0;
ServiceReferenceAbnLookup.ResponseBody ReponseBody = (ServiceReferenceAbnLookup.ResponseBody)payload.response.Item;
ServiceReferenceAbnLookup.ResponseSearchResultsList Names = (ServiceReferenceAbnLookup.ResponseSearchResultsList)ReponseBody;
try {
while (NameIndex < Names.numberOfRecords) {
ServiceReferenceAbnLookup.SearchResultsRecord Name = Names.searchResultsRecord[NameIndex];
MatchingName = MatchingNames.NewRow();
MatchingName["ABN"] = Name.ABN[0].identifierValue;
if (Name.Items != null) {
ServiceReferenceAbnLookup.OrganisationSimpleName SimpleName = (ServiceReferenceAbnLookup.OrganisationSimpleName)Name.Items[0];
MatchingName["Enreplacedy Name"] = SimpleName.organisationName;
MatchingName["Score"] = SimpleName.score;
}
if (Name.mainBusinessPhysicalAddress != null) {
MatchingName["State"] = Name.mainBusinessPhysicalAddress[0].stateCode;
MatchingName["Postcode"] = Name.mainBusinessPhysicalAddress[0].postcode;
}
MatchingNames.Rows.Add(MatchingName);
NameIndex++;
}
return MatchingNames;
}
catch {
throw;
}
}
19
Source : XmlMessageParser.cs
with MIT License
from ABN-SFLookupTechnicalSupport
with MIT License
from ABN-SFLookupTechnicalSupport
public static DataTable GetNames(string xml) {
DataTable MatchingNames = CreateNewNamesDataTable();
XmlDoreplacedent XmlDoc = LoadXml(xml);
XmlNamespaceManager NamespaceManager = initialiseNamespace(XmlDoc);
try {
if (!IsException(XmlDoc, NamespaceManager)) {
XmlNodeList Names = XmlDoc.SelectNodes(AbnLookupXpath.LocationSoap(AbnLookupXpath.Path.CommonRoot), NamespaceManager);
foreach (System.Xml.XmlNode Name in Names) {
DataRow MatchingName = MatchingNames.NewRow();
MatchingName["ABN"] = getNodeValue(Name, AbnLookupXpath.LocationSoap(AbnLookupXpath.Path.AbnValue), NamespaceManager);
MatchingName["Enreplacedy Name"] = getNodeValue(Name, AbnLookupXpath.LocationSoap(AbnLookupXpath.Path.Name), NamespaceManager);
MatchingName["State"] = getNodeValue(Name, AbnLookupXpath.LocationSoap(AbnLookupXpath.Path.State), NamespaceManager);
MatchingName["Postcode"] = getNodeValue(Name, AbnLookupXpath.LocationSoap(AbnLookupXpath.Path.Postcode), NamespaceManager);
MatchingName["Score"] = getNodeValue(Name, AbnLookupXpath.LocationSoap(AbnLookupXpath.Path.Score), NamespaceManager);
MatchingNames.Rows.Add(MatchingName);
}
}
else {
throw new System.Exception("Exception from Soap Search");
}
}
catch {
throw;
}
return MatchingNames;
}
19
Source : EnumerableExtensions.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
private static void AddDataToTable(IEnumerable<Enreplacedy> enreplacedies, DataTable table, bool autogenerateColumns, string dateTimeFormat = null, IFormatProvider dateTimeFormatProvider = null)
{
foreach (var enreplacedy in enreplacedies)
{
var row = table.NewRow();
foreach (var attribute in enreplacedy.Attributes)
{
if (!table.Columns.Contains(attribute.Key) && autogenerateColumns)
{
table.Columns.Add(attribute.Key);
}
if (table.Columns.Contains(attribute.Key))
{
var aliasedValue = attribute.Value as AliasedValue;
object value = aliasedValue != null ? aliasedValue.Value : attribute.Value;
var enreplacedyReference = value as EnreplacedyReference;
if (enreplacedyReference != null)
{
row[attribute.Key] = enreplacedyReference.Name ??
enreplacedyReference.Id.ToString();
}
else
{
var dateTime = value as DateTime?;
if (dateTimeFormat != null && dateTime != null)
{
row[attribute.Key] = dateTimeFormatProvider == null
? dateTime.Value.ToString(dateTimeFormat)
: dateTime.Value.ToString(dateTimeFormat, dateTimeFormatProvider);
}
else
{
row[attribute.Key] = enreplacedy.FormattedValues.Contains(attribute.Key)
? enreplacedy.FormattedValues[attribute.Key]
: value ?? DBNull.Value;
}
}
}
}
table.Rows.Add(row);
}
}
19
Source : EnumerableExtensions.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
private static void AddDataToTable(IEnumerable<Enreplacedy> enreplacedies, DataTable table, bool autogenerateColumns)
{
foreach (var enreplacedy in enreplacedies)
{
var row = table.NewRow();
foreach (var attribute in enreplacedy.Attributes)
{
if (!table.Columns.Contains(attribute.Key) && autogenerateColumns)
{
table.Columns.Add(attribute.Key);
}
if (table.Columns.Contains(attribute.Key))
{
var enreplacedyReference = attribute.Value as EnreplacedyReference;
if (enreplacedyReference != null)
{
row[attribute.Key] = enreplacedyReference.Name ??
enreplacedyReference.Id.ToString();
}
else
{
row[attribute.Key] = enreplacedy.FormattedValues.Contains(attribute.Key)
? enreplacedy.FormattedValues[attribute.Key]
: attribute.Value ?? DBNull.Value;
}
}
}
table.Rows.Add(row);
}
}
19
Source : DataTable.cs
with Mozilla Public License 2.0
from ahyahy
with Mozilla Public License 2.0
from ahyahy
public osf.DataRow NewRow()
{
return new DataRow(M_DataTable.NewRow());
}
19
Source : AuditGetLastUpdate.cs
with MIT License
from akaskela
with MIT License
from akaskela
protected DataTable BuildDataTable(CodeActivityContext context, IWorkflowContext workflowContext, IOrganizationService service)
{
DataTable table = new DataTable() { TableName = workflowContext.PrimaryEnreplacedyName };
table.Columns.AddRange(new DataColumn[] { new DataColumn("Attribute"), new DataColumn("Old Value"), new DataColumn("New Value") });
RetrieveRecordChangeHistoryRequest request = new RetrieveRecordChangeHistoryRequest()
{
Target = new EnreplacedyReference(workflowContext.PrimaryEnreplacedyName, workflowContext.PrimaryEnreplacedyId),
PagingInfo = new PagingInfo() { Count = 100, PageNumber = 1 }
};
RetrieveRecordChangeHistoryResponse response = service.Execute(request) as RetrieveRecordChangeHistoryResponse;
if (response != null && response.AuditDetailCollection.Count > 0)
{
string onlyIfField = LastUpdateWithThisField.Get(context);
AttributeAuditDetail detail = null;
for (int i = 0; i < response.AuditDetailCollection.Count; i++)
{
AttributeAuditDetail thisDetail = response.AuditDetailCollection[i] as AttributeAuditDetail;
if (thisDetail != null && (String.IsNullOrEmpty(onlyIfField) ||
(thisDetail.OldValue.Attributes.Keys.Contains(onlyIfField) ||
thisDetail.NewValue.Attributes.Keys.Contains(onlyIfField))))
{
detail = thisDetail;
break;
}
}
if (detail != null && detail.NewValue != null && detail.OldValue != null)
{
Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyRequest retrieveEnreplacedyRequest = new Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyRequest()
{
EnreplacedyFilters = EnreplacedyFilters.Attributes,
LogicalName = workflowContext.PrimaryEnreplacedyName
};
Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyResponse retrieveEnreplacedyResponse = service.Execute(retrieveEnreplacedyRequest) as Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyResponse;
EnreplacedyMetadata metadata = retrieveEnreplacedyResponse.EnreplacedyMetadata;
var details = detail.NewValue.Attributes.Keys.Union(detail.OldValue.Attributes.Keys)
.Distinct()
.Select(a => new
{
AttributeName = a,
DisplayName = this.GetDisplayLabel(metadata, a),
OldValue = String.Empty,
NewValue = String.Empty
})
.OrderBy(a => a.DisplayName);
foreach (var item in details)
{
DataRow newRow = table.NewRow();
newRow["Attribute"] = item.DisplayName;
newRow["Old Value"] = GetDisplayValue(detail.OldValue, item.AttributeName);
newRow["New Value"] = GetDisplayValue(detail.NewValue, item.AttributeName);
table.Rows.Add(newRow);
}
}
}
return table;
}
19
Source : AuditGetRecentUpdates.cs
with MIT License
from akaskela
with MIT License
from akaskela
protected DataTable BuildDataTable(CodeActivityContext context, IWorkflowContext workflowContext, IOrganizationService service)
{
TimeZoneSummary timeZone = StaticMethods.CalculateTimeZoneToUse(this.TimeZoneOption.Get(context), workflowContext, service);
DataTable table = new DataTable() { TableName = workflowContext.PrimaryEnreplacedyName };
table.Columns.AddRange(new DataColumn[] { new DataColumn("Date"), new DataColumn("User"), new DataColumn("Attribute"), new DataColumn("Old Value"), new DataColumn("New Value") });
DateTime oldestUpdate = DateTime.MinValue;
if (this.Units != null && this.Number != null && this.Number.Get<int>(context) != 0)
{
OptionSetValue value = this.Units.Get<OptionSetValue>(context);
if (value != null)
{
switch (value.Value)
{
case 222540000:
oldestUpdate = DateTime.Now.AddYears(this.Number.Get<int>(context) * -1);
break;
case 222540001:
oldestUpdate = DateTime.Now.AddMonths(this.Number.Get<int>(context) * -1);
break;
case 222540002:
oldestUpdate = DateTime.Now.AddDays(this.Number.Get<int>(context) * -7);
break;
case 222540003:
oldestUpdate = DateTime.Now.AddDays(this.Number.Get<int>(context) * -1);
break;
case 222540004:
oldestUpdate = DateTime.Now.AddHours(this.Number.Get<int>(context) * -1);
break;
default:
oldestUpdate = DateTime.Now.AddMinutes(this.Number.Get<int>(context) * -1);
break;
}
}
}
int maxUpdates = this.MaxAuditLogs.Get(context) > 100 || this.MaxAuditLogs.Get(context) < 1 ? 100 : this.MaxAuditLogs.Get(context);
RetrieveRecordChangeHistoryRequest request = new RetrieveRecordChangeHistoryRequest()
{
Target = new EnreplacedyReference(workflowContext.PrimaryEnreplacedyName, workflowContext.PrimaryEnreplacedyId),
PagingInfo = new PagingInfo() { Count = maxUpdates, PageNumber = 1 }
};
RetrieveRecordChangeHistoryResponse response = service.Execute(request) as RetrieveRecordChangeHistoryResponse;
var detailsToInclude = response.AuditDetailCollection.AuditDetails
.Where(ad => ad is AttributeAuditDetail && ad.AuditRecord.Contains("createdon") && ((DateTime)ad.AuditRecord["createdon"]) > oldestUpdate)
.OrderByDescending(ad => ((DateTime)ad.AuditRecord["createdon"]))
.ToList();
if (detailsToInclude.Any())
{
Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyRequest retrieveEnreplacedyRequest = new Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyRequest()
{
EnreplacedyFilters = EnreplacedyFilters.Attributes,
LogicalName = workflowContext.PrimaryEnreplacedyName
};
Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyResponse retrieveEnreplacedyResponse = service.Execute(retrieveEnreplacedyRequest) as Microsoft.Xrm.Sdk.Messages.RetrieveEnreplacedyResponse;
EnreplacedyMetadata metadata = retrieveEnreplacedyResponse.EnreplacedyMetadata;
foreach (var detail in detailsToInclude.Select(d => d as AttributeAuditDetail).Where(d => d.NewValue != null && d.OldValue != null))
{
DateTime dateToModify = (DateTime)detail.AuditRecord["createdon"];
if (dateToModify.Kind != DateTimeKind.Utc)
{
dateToModify = dateToModify.ToUniversalTime();
}
LocalTimeFromUtcTimeRequest timeZoneChangeRequest = new LocalTimeFromUtcTimeRequest() { UtcTime = dateToModify, TimeZoneCode = timeZone.MicrosoftIndex };
LocalTimeFromUtcTimeResponse timeZoneResponse = service.Execute(timeZoneChangeRequest) as LocalTimeFromUtcTimeResponse;
DateTime timeZoneSpecificDateTime = timeZoneResponse.LocalTime;
var details = detail.NewValue.Attributes.Keys.Union(detail.OldValue.Attributes.Keys)
.Distinct()
.Select(a =>
new {
AttributeName = a,
DisplayName = GetDisplayLabel(metadata, a)
})
.OrderBy(a => a.DisplayName);
foreach (var item in details)
{
DataRow newRow = table.NewRow();
newRow["User"] = GetDisplayValue(detail.AuditRecord, "userid");
newRow["Date"] = timeZoneSpecificDateTime.ToString("MM/dd/yyyy h:mm tt");
newRow["Attribute"] = item.DisplayName;
newRow["Old Value"] = GetDisplayValue(detail.OldValue, item.AttributeName);
newRow["New Value"] = GetDisplayValue(detail.NewValue, item.AttributeName);
table.Rows.Add(newRow);
}
}
}
return table;
}
19
Source : WorkflowQueryBase.cs
with MIT License
from akaskela
with MIT License
from akaskela
protected DataTable ExecuteQuery(CodeActivityContext context)
{
if (this.SavedQuery.Get(context) == null && this.UserQuery.Get(context) == null && String.IsNullOrEmpty(this.FetchXml.Get(context)))
{
throw new ArgumentNullException("You need to either a pick System View, a Personal View, or specify FetchXML for the query");
}
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.InitiatingUserId);
string layoutXml = String.Empty;
string fetchXml = this.FetchXml.Get(context);
if (this.UserQuery.Get(context) != null)
{
Enreplacedy queryEnreplacedy = service.Retrieve("userquery", this.UserQuery.Get(context).Id, new Microsoft.Xrm.Sdk.Query.ColumnSet("fetchxml", "layoutxml"));
fetchXml = queryEnreplacedy.Contains("fetchxml") ? queryEnreplacedy["fetchxml"].ToString() : String.Empty;
layoutXml = queryEnreplacedy.Contains("layoutxml") ? queryEnreplacedy["layoutxml"].ToString() : String.Empty;
}
else if (this.SavedQuery.Get(context) != null)
{
Enreplacedy queryEnreplacedy = service.Retrieve("savedquery", this.SavedQuery.Get(context).Id, new Microsoft.Xrm.Sdk.Query.ColumnSet("fetchxml", "layoutxml"));
fetchXml = queryEnreplacedy.Contains("fetchxml") ? queryEnreplacedy["fetchxml"].ToString() : String.Empty;
layoutXml = queryEnreplacedy.Contains("layoutxml") ? queryEnreplacedy["layoutxml"].ToString() : String.Empty;
}
this.LimitQueryToCurrentRecord(service, ref fetchXml, workflowContext.PrimaryEnreplacedyName, workflowContext.PrimaryEnreplacedyId);
List<ColumnInformation> tableColumns = this.BuildTableInformation(service, fetchXml, layoutXml);
EnreplacedyCollection ec = null;
try
{
FetchExpression fe = new FetchExpression(fetchXml);
ec = service.RetrieveMultiple(fe);
}
catch (System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
{
throw new ArgumentException("There was an error executing the query. Message: " + ex.Message);
}
catch (Exception ex)
{
throw ex;
}
DataTable table = new DataTable() { TableName = ec.EnreplacedyName };
table.Columns.AddRange(tableColumns.Select(c => new DataColumn(c.Header)).ToArray());
foreach (var enreplacedy in ec.Enreplacedies)
{
DataRow newRow = table.NewRow();
foreach (ColumnInformation c in tableColumns.Where(c => !c.Header.Contains("_Metadata_")))
{
if (enreplacedy.Contains(c.QueryResultAlias))
{
object itemToEvaluate = enreplacedy[c.QueryResultAlias];
if (itemToEvaluate is AliasedValue)
{
itemToEvaluate = ((AliasedValue)enreplacedy[c.QueryResultAlias]).Value;
}
if (itemToEvaluate is EnreplacedyReference)
{
newRow[c.Header] = ((EnreplacedyReference)itemToEvaluate).Name;
newRow[String.Format(MetadataHeaderFormat, c.Header, "RawValue")] = ((EnreplacedyReference)itemToEvaluate).Id.ToString();
}
else if (itemToEvaluate is string)
{
newRow[c.Header] = itemToEvaluate.ToString();
newRow[String.Format(MetadataHeaderFormat, c.Header, "RawValue")] = itemToEvaluate.ToString();
}
else if (enreplacedy.FormattedValues.Contains(c.QueryResultAlias))
{
newRow[c.Header] = enreplacedy.FormattedValues[c.QueryResultAlias];
if (itemToEvaluate is Money)
{
newRow[String.Format(MetadataHeaderFormat, c.Header, "RawValue")] = ((Money)itemToEvaluate).Value;
}
else
{
newRow[String.Format(MetadataHeaderFormat, c.Header, "RawValue")] = enreplacedy.FormattedValues[c.QueryResultAlias];
}
}
else if (itemToEvaluate is EnreplacedyCollection)
{
var enreplacedies = itemToEvaluate as EnreplacedyCollection;
if (enreplacedies.Enreplacedies.Any() && enreplacedies.Enreplacedies.First().LogicalName.Equals("activityparty"))
{
newRow[c.Header] = string.Join("; ", enreplacedies.Enreplacedies
.Where(e => e.FormattedValues.ContainsKey("partyid"))
.Select(e => e.FormattedValues["partyid"]));
}
}
else if (itemToEvaluate is Guid)
{
newRow[c.Header] = (Guid)itemToEvaluate;
}
}
else
{
newRow[c.Header] = String.Empty;
newRow[String.Format(MetadataHeaderFormat, c.Header, "RawValue")] = String.Empty;
}
}
table.Rows.Add(newRow);
}
return table;
}
19
Source : DataTableConverter.cs
with MIT License
from akaskela
with MIT License
from akaskela
private static void CreateRow(JsonReader reader, DataTable dt, JsonSerializer serializer)
{
DataRow dr = dt.NewRow();
reader.ReadAndreplacedert();
while (reader.TokenType == JsonToken.PropertyName)
{
string columnName = (string)reader.Value;
reader.ReadAndreplacedert();
DataColumn column = dt.Columns[columnName];
if (column == null)
{
Type columnType = GetColumnDataType(reader);
column = new DataColumn(columnName, columnType);
dt.Columns.Add(column);
}
if (column.DataType == typeof(DataTable))
{
if (reader.TokenType == JsonToken.StartArray)
{
reader.ReadAndreplacedert();
}
DataTable nestedDt = new DataTable();
while (reader.TokenType != JsonToken.EndArray)
{
CreateRow(reader, nestedDt, serializer);
reader.ReadAndreplacedert();
}
dr[columnName] = nestedDt;
}
else if (column.DataType.IsArray && column.DataType != typeof(byte[]))
{
if (reader.TokenType == JsonToken.StartArray)
{
reader.ReadAndreplacedert();
}
List<object> o = new List<object>();
while (reader.TokenType != JsonToken.EndArray)
{
o.Add(reader.Value);
reader.ReadAndreplacedert();
}
Array destinationArray = Array.CreateInstance(column.DataType.GetElementType(), o.Count);
Array.Copy(o.ToArray(), destinationArray, o.Count);
dr[columnName] = destinationArray;
}
else
{
dr[columnName] = (reader.Value != null) ? serializer.Deserialize(reader, column.DataType) : DBNull.Value;
}
reader.ReadAndreplacedert();
}
dr.EndEdit();
dt.Rows.Add(dr);
}
19
Source : LightDataTableRow.cs
with MIT License
from AlenToma
with MIT License
from AlenToma
public DataRow ToDataRow(DataTable parentTable)
{
var row = parentTable.NewRow();
foreach (var item in Columns.Values)
if (parentTable.Columns.Contains(item.ColumnName))
{
var v = this[item.ColumnName];
TypeValidation(ref v, parentTable.Columns[item.ColumnName].DataType, true);
if (row != null && row[item.ColumnName] != v)
row[item.ColumnName] = v;
}
return row;
}
19
Source : MKMDatabaseManager.cs
with GNU Affero General Public License v3.0
from alexander-pick
with GNU Affero General Public License v3.0
from alexander-pick
private bool updateInventoryDatabaseFile()
{
try
{
MainView.Instance.LogMainWindow("Updating MKM inventory database...");
// build inventory
var doc = MKMInteract.RequestHelper.MakeRequest("https://api.cardmarket.com/ws/v2.0/productlist", "GET");
var node = doc.GetElementsByTagName("response");
var data = Convert.FromBase64String(node.Item(0)["productsfile"].InnerText);
var aDecompressed = GzDecompress(data);
var downloadedProducts = ConvertCSVtoDataTable(aDecompressed);
// only join the downloaded with the current version, so that we don't overwrite other
// data we cache into the Inventory (Rarity) that is not present in the productlist
// the productList is sorted by productid, so just read the last few that we don't have yet
// this replacedumes the previous rows never change, which is the case only if there is no error in them...
for (int i = inventory.Rows.Count; i < downloadedProducts.Rows.Count; i++)
{
var insertRow = inventory.NewRow();
foreach (DataColumn col2 in downloadedProducts.Columns)
{
insertRow[col2.ColumnName] = downloadedProducts.Rows[i][col2.ColumnName];
}
inventory.Rows.Add(insertRow);
}
WriteTableAsCSV(@".\\mkminventory.csv", inventory);
inventory.AcceptChanges();
buildSinglesDatabase();
MainView.Instance.LogMainWindow("MKM inventory database updated.");
}
catch (Exception eError)
{
LogError("downloading MKM inventory", eError.Message, true);
return false;
}
return true;
}
19
Source : MKMDatabaseManager.cs
with GNU Affero General Public License v3.0
from alexander-pick
with GNU Affero General Public License v3.0
from alexander-pick
public static DataTable JoinDataTables(DataTable t1, DataTable t2, params Func<DataRow, DataRow, bool>[] joinOn)
{
var result = new DataTable();
foreach (DataColumn col in t1.Columns)
if (result.Columns[col.ColumnName] == null)
result.Columns.Add(col.ColumnName, col.DataType);
foreach (DataColumn col in t2.Columns)
if (result.Columns[col.ColumnName] == null)
result.Columns.Add(col.ColumnName, col.DataType);
foreach (DataRow row1 in t1.Rows)
{
var joinRows = t2.AsEnumerable().Where(row2 =>
{
foreach (var parameter in joinOn)
if (!parameter(row1, row2)) return false;
return true;
});
foreach (var fromRow in joinRows)
{
var insertRow = result.NewRow();
foreach (DataColumn col1 in t1.Columns)
insertRow[col1.ColumnName] = row1[col1.ColumnName];
foreach (DataColumn col2 in t2.Columns)
insertRow[col2.ColumnName] = fromRow[col2.ColumnName];
result.Rows.Add(insertRow);
}
}
return result;
}
19
Source : MKMCsvUtils.cs
with GNU Affero General Public License v3.0
from alexander-pick
with GNU Affero General Public License v3.0
from alexander-pick
public static DataTable ConvertCSVtoDataTable(StreamReader sr)
{
DataTable dt = new DataTable();
char separator = ',';
try
{
// detect the separator - this replacedumes it's ether semicolon or comma and that semicolon cannot be part of column names
string firstLine = sr.ReadLine();
if (firstLine.Contains(';'))
separator = ';';
List<string> headers = parseCSVRow(firstLine, separator);
foreach (string header in headers)
dt.Columns.Add(header);
}
catch (Exception eError)
{
throw new FormatException("Wrong format of the header of CSV file: " + eError.Message);
}
while (!sr.EndOfStream)
{
try
{
List<string> row = parseCSVRow(sr.ReadLine(), separator);
DataRow dr = dt.NewRow();
for (int i = 0; i < row.Count; i++)
dr[i] = row[i];
dt.Rows.Add(dr);
}
catch (Exception eError)
{
// technically it is the (dt.Rows.Count + 1)th row, but in the file the first row is the header so this should
// give the user the number of the row in the actual file
throw new FormatException("Wrong format of the CSV file on row " + (dt.Rows.Count + 2) + ": " + eError.Message);
}
}
return dt;
}
19
Source : Issues.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
[TestMethod]
public void Issue15123()
{
var p = new ExcelPackage();
var ws = p.Workbook.Worksheets.Add("t");
using (var dt = new DataTable())
{
dt.Columns.Add("String", typeof(string));
dt.Columns.Add("Int", typeof(int));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Double", typeof(double));
dt.Columns.Add("Date", typeof(DateTime));
var dr = dt.NewRow();
dr[0] = "Row1";
dr[1] = 1;
dr[2] = true;
dr[3] = 1.5;
dr[4] = new DateTime(2014, 12, 30);
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Row2";
dr[1] = 2;
dr[2] = false;
dr[3] = 2.25;
dr[4] = new DateTime(2014, 12, 31);
dt.Rows.Add(dr);
ws.Cells["A1"].LoadFromDataTable(dt, true);
ws.Cells["D2:D3"].Style.Numberformat.Format = "(* #,##0.00);_(* (#,##0.00);_(* \"-\"??_);(@)";
ws.Cells["E2:E3"].Style.Numberformat.Format = "mm/dd/yyyy";
ws.Cells.AutoFitColumns();
replacedert.AreNotEqual(ws.Cells[2, 5].Text, "");
}
}
19
Source : WorkSheet.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
public void LoadDataTable()
{
if (_pck == null) _pck = new ExcelPackage();
var ws = _pck.Workbook.Worksheets.Add("Loaded DataTable");
var dt = new DataTable();
dt.Columns.Add("String", typeof(string));
dt.Columns.Add("Int", typeof(int));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Double", typeof(double));
var dr = dt.NewRow();
dr[0] = "Row1";
dr[1] = 1;
dr[2] = true;
dr[3] = 1.5;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Row2";
dr[1] = 2;
dr[2] = false;
dr[3] = 2.25;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Row3";
dr[1] = 3;
dr[2] = true;
dr[3] = 3.125;
dt.Rows.Add(dr);
ws.Cells["A1"].LoadFromDataTable(dt, true, OfficeOpenXml.Table.TableStyles.Medium5);
//worksheet.Cells[startRow, 7, worksheet.Dimension.End.Row, 7].FormulaR1C1 = "=IF(RC[-2]=0,0,RC[-1]/RC[-2])";
ws.Tables[0].Columns[1].TotalsRowFunction = OfficeOpenXml.Table.RowFunctions.Sum;
ws.Tables[0].ShowTotal = true;
}
19
Source : WorkSheet.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
public void LoadDataReader()
{
if (_pck == null) _pck = new ExcelPackage();
var ws = _pck.Workbook.Worksheets.Add("Loaded DataReader");
ExcelRangeBase range;
using (var dt = new DataTable())
{
dt.Columns.Add("String", typeof(string));
dt.Columns.Add("Int", typeof(int));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Double", typeof(double));
var dr = dt.NewRow();
dr[0] = "Row1";
dr[1] = 1;
dr[2] = true;
dr[3] = 1.5;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "Row2";
dr[1] = 2;
dr[2] = false;
dr[3] = 2.25;
dt.Rows.Add(dr);
//dr = dt.NewRow();
//dr[0] = "Row3";
//dr[1] = 3;
//dr[2] = true;
//dr[3] = 3.125;
//dt.Rows.Add(dr);
using (var reader = dt.CreateDataReader())
{
range = ws.Cells["A1"].LoadFromDataReader(reader, true, "My_Table",
OfficeOpenXml.Table.TableStyles.Medium5);
}
replacedert.AreEqual(1, range.Start.Column);
replacedert.AreEqual(4, range.End.Column);
replacedert.AreEqual(1, range.Start.Row);
replacedert.AreEqual(3, range.End.Row);
using (var reader = dt.CreateDataReader())
{
range = ws.Cells["A5"].LoadFromDataReader(reader, false, "My_Table2",
OfficeOpenXml.Table.TableStyles.Medium5);
}
replacedert.AreEqual(1, range.Start.Column);
replacedert.AreEqual(4, range.End.Column);
replacedert.AreEqual(5, range.Start.Row);
replacedert.AreEqual(6, range.End.Row);
}
}
19
Source : Sample13.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
private static DataTable GetDataTable(DirectoryInfo dir)
{
DataTable dt = new DataTable("RootDir");
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Size", typeof(long));
dt.Columns.Add("Created", typeof(DateTime));
dt.Columns.Add("Modified", typeof(DateTime));
foreach (var item in dir.GetDirectories())
{
var row = dt.NewRow();
row["Name"] = item.Name;
row["Created"] = item.CreationTime;
row["Modified"] = item.LastWriteTime;
dt.Rows.Add(row);
}
foreach (var item in dir.GetFiles())
{
var row = dt.NewRow();
row["Name"] = item.Name;
row["Size"] = item.Length;
row["Created"] = item.CreationTime;
row["Modified"] = item.LastWriteTime;
dt.Rows.Add(row);
}
return dt;
}
19
Source : HomeController.cs
with Apache License 2.0
from Appdynamics
with Apache License 2.0
from Appdynamics
public IActionResult DataTableReport()
{
var dataTable = new DataTable("Users");
dataTable.Columns.Add("Name", typeof(string));
dataTable.Columns.Add("Age", typeof(int));
var rnd = new Random();
for (var i = 0; i < 100; i++)
{
var row = dataTable.NewRow();
row["Name"] = $"User {i}";
row["Age"] = rnd.Next(20, 100);
dataTable.Rows.Add(row);
}
using (var package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Excel Test");
worksheet.Cells["A1"].LoadFromDataTable(dataTable, PrintHeaders: true);
for (var col = 1; col < dataTable.Columns.Count + 1; col++)
{
worksheet.Column(col).AutoFit();
}
return File(package.GetAsByteArray(), XlsxContentType, "report.xlsx");
}
}
19
Source : NpoiHelper.cs
with MIT License
from aprilyush
with MIT License
from aprilyush
public static DataTable GetExcelDt(string filepath, int startRow)
{
DataTable dataTable = null;
FileStream fs = null;
IWorkbook workbook = null;
ISheet sheet = null;
IRow row = null;
ICell cell = null;
try
{
fs = File.OpenRead(filepath);
// 2007版本
if (filepath.IndexOf(".xlsx") > 0)
{
workbook = new XSSFWorkbook(fs);
}
else if (filepath.IndexOf(".xls") > 0)
{// 2003版本
workbook = new HSSFWorkbook(fs);
}
if (workbook != null)
{
sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
dataTable = new DataTable();
if (sheet != null)
{
int rowCount = sheet.LastRowNum; //总行数
if (rowCount > 0)
{
int replacedleIndex = startRow - 1;
IRow firstRow = sheet.GetRow(replacedleIndex); //第一行
int cellCount = firstRow.LastCellNum; //列数
int firstCellNum = firstRow.FirstCellNum;
for (int i = 1; i <= cellCount; i++)
{
dataTable.Columns.Add(new DataColumn("column" + i));
}
int contentIndex = replacedleIndex + 1;
//int newRowCount = rowCount - startRowIndex;
for (int i = contentIndex; i <= rowCount; i++)
{
row = sheet.GetRow(i);
if (row == null) continue;
var dataRow = dataTable.NewRow();
for (int j = firstCellNum; j < cellCount; j++)
{
cell = row.GetCell(j);
if (cell == null)
{
dataRow[j] = string.Empty;
}
else
{
dataRow[j] = cell.ToString();
}
}
dataTable.Rows.Add(dataRow);
}
}
}
}
fs.Close();
}
catch
{
throw;
}
finally
{
if (fs != null)
{
fs.Dispose();
}
}
return dataTable;
}
19
Source : DBRead.cs
with Apache License 2.0
from aryice
with Apache License 2.0
from aryice
public DataTable GetList(SqlBaseItemXml basemodel,ConditionFieldModel condition, ref long sqlnum)
{
sqlnum = 0;
long getmaxnum = 500;
long getrowcount = 0;
DataTable dt = new DataTable();
DBRule serverrule = new DBRule();
List<MatchServerList> serverlist = serverrule.GetMatchServer(basemodel, condition);
if (serverlist != null && serverlist.Count > 0)
{
List<TaskDataParam> taskdataparam = new List<TaskDataParam>();
foreach (var item in serverlist)
{
var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, item.ServerNumber);
if (servermodel != null)
{
TaskDataParam tempparam = new TaskDataParam();
tempparam.servername = servermodel.ServerName;
tempparam.dbtype = servermodel.DBType;
tempparam.connstr = DBProxyAction.GetConnStr(basemodel,servermodel);
tempparam.sqlstr = DBProxyAction.GetSqlList(servermodel, item, condition, getmaxnum);
taskdataparam.Add(tempparam);
}
}
Console.WriteLine("满足条件的数据库表:" + taskdataparam.Count);
foreach (var itemparam in taskdataparam)
{
Console.WriteLine("访问服务器:"+itemparam.servername);
var dttemp =DBProxy.GetDBHelper(itemparam.dbtype).GetDataDable(itemparam.connstr, itemparam.sqlstr);
sqlnum++;
if (dttemp != null && dttemp.Rows.Count>0)
{
var dttempcount = dttemp.Rows.Count;
if (getrowcount>0)
{
foreach (DataRow dtrow in dttemp.Rows)
{
if (getrowcount >= getmaxnum)
{
return dt;
}
getrowcount++;
DataRow r = dt.NewRow();
r.ItemArray = dtrow.ItemArray;
dt.Rows.Add(r);
}
}
else
{
getrowcount = dttemp.Rows.Count;
dt = dttemp;
}
}
if (getrowcount >= getmaxnum)
{
return dt;
}
}
}
return dt;
}
19
Source : DBAction.cs
with Apache License 2.0
from aryice
with Apache License 2.0
from aryice
public DataTable testBulkRowData(SqlBaseItemXml basemodel,string tablename)
{
DataTable bulkdata = DBConfig.GetTableStruct(basemodel, tablename);
Random random = new Random();
long rowmin = 0;
long rowcurrent = 0;
long rowmax = 0;
int rownum = 10000;
long rowidrrr = DBConfig.GetRowId(basemodel.Number);
DBConfig.UpdateRowId(basemodel.Number,rownum);
rowmin = rowidrrr + 1;
rowmax = rowmin + rownum;
rowcurrent = rowmin;
for (int i = 0; i < rownum; i++)
{
DataRow newRow;
newRow = bulkdata.NewRow();
#region
newRow["id"] = rowcurrent++;
newRow["num1"] = rowcurrent / 100000;
newRow["num2"] = random.Next(10000);
newRow["num3"] = random.NextDouble();
newRow["str11"] = tablename + i;
#endregion
bulkdata.Rows.Add(newRow);
}
return bulkdata;
}
19
Source : Save_Load.cs
with MIT License
from Asixa
with MIT License
from Asixa
public static void SaveData()
{
System.Data.DataSet ds = new System.Data.DataSet("SteamworkGUI");
System.Data.DataTable table = new System.Data.DataTable("Data");
ds.Tables.Add(table);
table.Columns.Add("account", typeof(string));
table.Columns.Add("appid", typeof(int));
table.Columns.Add("language", typeof(string));
System.Data.DataRow row = table.NewRow();
row[0] = MainWindow._instance.user_name;
row[1] = MainWindow._instance.Appid;
row[2] = MainWindow._instance.LanguagePack;
ds.Tables["Data"].Rows.Add(row);
string path = Environment.CurrentDirectory+"/data.xml";
try
{
ds.WriteXml(path);
}
catch
{
}
}
19
Source : HTMLTagsInsideTable.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
public static void Run()
{
// ExStart:1
// The path to the doreplacedents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
DataTable dt = new DataTable("Employee");
dt.Columns.Add("data", System.Type.GetType("System.String"));
DataRow dr = dt.NewRow();
dr[0] = "<li>Department of Emergency Medicine: 3400 Spruce Street Ground Silverstein Bldg Philadelphia PA 19104-4206</li>";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "<li>Penn Observation Medicine Service: 3400 Spruce Street Ground Floor Donner Philadelphia PA 19104-4206</li>";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "<li>UPHS/Presbyterian - Dept. of Emergency Medicine: 51 N. 39th Street . Philadelphia PA 19104-2640</li>";
dt.Rows.Add(dr);
Doreplacedent doc = new Doreplacedent();
doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table tableProvider = new Aspose.Pdf.Table();
//Set column widths of the table
tableProvider.ColumnWidths = "400 50 ";
// Set the table border color as LightGray
tableProvider.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.5F, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// Set the border for table cells
tableProvider.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.5F, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
margin.Top = 2.5F;
margin.Left = 2.5F;
margin.Bottom = 1.0F;
tableProvider.DefaultCellPadding = margin;
tableProvider.ImportDataTable(dt, false, 0, 0, 3, 1, true);
doc.Pages[1].Paragraphs.Add(tableProvider);
doc.Save(dataDir + "HTMLInsideTableCell_out.pdf");
// ExEnd:1
}
19
Source : IntegrateWithDatabase.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
public static void Run()
{
// ExStart:IntegrateWithDatabase
// The path to the doreplacedents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
DataTable dt = new DataTable("Employee");
dt.Columns.Add("Employee_ID", typeof(Int32));
dt.Columns.Add("Employee_Name", typeof(string));
dt.Columns.Add("Gender", typeof(string));
// Add 2 rows into the DataTable object programmatically
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = "John Smith";
dr[2] = "Male";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "Mary Miller";
dr[2] = "Female";
dt.Rows.Add(dr);
// Create Doreplacedent instance
Doreplacedent doc = new Doreplacedent();
doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
// Set column widths of the table
table.ColumnWidths = "40 100 100 100";
// Set the table border color as LightGray
table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// Set the border for table cells
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
table.ImportDataTable(dt, true, 0, 1, 3, 3);
// Add table object to first page of input doreplacedent
doc.Pages[1].Paragraphs.Add(table);
dataDir = dataDir + "DataIntegrated_out.pdf";
// Save updated doreplacedent containing table object
doc.Save(dataDir);
// ExEnd:IntegrateWithDatabase
Console.WriteLine("\nDatabase integrated successfully.\nFile saved at " + dataDir);
}
19
Source : Default.aspx.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private void BindGrid()
{
DataTable dataTable = new DataTable("Products");
dataTable.Columns.Add("Product ID", typeof(Int32));
dataTable.Columns.Add("Product Name", typeof(string));
dataTable.Columns.Add("Units In Stock", typeof(Int32));
for (int index = 0; index < 50; index++)
{
DataRow dr = dataTable.NewRow();
dr[0] = index;
dr[1] = dr[0] + " - Name";
dr[2] = index + 5;
dataTable.Rows.Add(dr);
}
ExportGridViewToPdf1.ExportDataSource = dataTable;
ExportGridViewToPdf1.DataSource = dataTable;
ExportGridViewToPdf1.DataBind();
}
19
Source : DimensionHealthCheck.cs
with MIT License
from ASStoredProcedures
with MIT License
from ASStoredProcedures
[AdomdServer.SafeToPrepare(true)]
public static DataTable ListDimensionErrors(string DimensionName)
{
DataTable tableReturn = new DataTable();
tableReturn.Columns.Add("Dimension");
tableReturn.Columns.Add("ErrorNumber", typeof(int));
tableReturn.Columns.Add("ErrorDescription");
tableReturn.Columns.Add("NumColumns", typeof(int));
int iNumPriorColumns = tableReturn.Columns.Count;
int iMaxNumColumns = 9;
for (int i = 1; i <= iMaxNumColumns; i++)
{
tableReturn.Columns.Add("Column" + i + "Name");
tableReturn.Columns.Add("Column" + i);
}
if (AdomdServer.Context.ExecuteForPrepare) return tableReturn;
Server server = new Server();
server.Connect("*");
Dimension d = server.Databases.GetByName(AdomdServer.Context.CurrentDatabaseName).Dimensions.GetByName(DimensionName);
DimensionError[] errors = Check(d);
server.Disconnect();
for (int i = 0; i < errors.Length; i++)
{
DimensionError error = errors[i];
if (error.ErrorTable == null || (error.ErrorTable != null && error.ErrorTable.Rows.Count == 0))
{
DataRow row = tableReturn.NewRow();
row["Dimension"] = d.Name;
row["ErrorNumber"] = i + 1;
row["ErrorDescription"] = error.ErrorDescription;
row["NumColumns"] = 0;
tableReturn.Rows.Add(row);
}
else
{
foreach (DataRow errorRow in error.ErrorTable.Rows)
{
DataRow row = tableReturn.NewRow();
row["Dimension"] = d.Name;
row["ErrorNumber"] = i + 1;
row["ErrorDescription"] = error.ErrorDescription;
row["NumColumns"] = error.ErrorTable.Columns.Count;
if (iMaxNumColumns < error.ErrorTable.Columns.Count)
throw new Exception("Dimension error dataset contained more than " + iMaxNumColumns + " columns which is not allowed with the current code. Change the code of the sproc to allow more, refresh the report dataset, and change the report layout to allow more.");
for (int j = 0; j < error.ErrorTable.Columns.Count; j++)
{
row[j * 2 + iNumPriorColumns] = error.ErrorTable.Columns[j].ColumnName;
if (!Convert.IsDBNull(errorRow[j]))
row[j * 2 + iNumPriorColumns + 1] = errorRow[j].ToString();
}
tableReturn.Rows.Add(row);
}
}
}
return tableReturn;
}
19
Source : XmlaDiscoverParser.cs
with MIT License
from ASStoredProcedures
with MIT License
from ASStoredProcedures
public DataTable Parse(XmlDoreplacedent doc, string filter, bool prepareOnly, string whereClause)
{
DiscoverQuery dq;
DataTable dt = new DataTable();
string[] elements;
elements = filter.Split((@"\").ToCharArray());
dq = new DiscoverQuery(elements);
XmlNodeList e;
// We basically grab all the elements that match the last
// item type in the path. So if you ask for '\Database\Dimensions\Dimension'
// we get all the 'Dimension' elements and then in the next step we
// spin through them to see if they are under the appropriate
// parent elements.
//e = doc.GetElementsByTagName(elements[elements.Length - 1]);
e = doc.GetElementsByTagName(dq.Elements.Last.Value.Name);
/*
* Get elements matching last item in the filter
* work up the parentNode properties, making sure
* that they match the path.
*/
List<XmlNode> finalList = new List<XmlNode>();
for (int i = 0; i < e.Count; i++)
{
Context.CheckCancelled();
XmlNode node = e.Item(i);
XmlNode parentNode = node;
xmlaElement xe = dq.Elements.Last.Value;
while (xe != null)
{
parentNode = parentNode.ParentNode;
if (xe.Previous != null
&& string.Compare(parentNode.Name, xe.Previous.Name, true) != 0) // Case insensitive compare
{
break;
}
else if (xe.Previous == null)
{
finalList.Add(node);
}
xe = xe.Previous;
}
}
// Now we generate the data table based on the data in one of the nodes
bool tableBuilt = false;
foreach (XmlNode n in finalList)
{
if (!tableBuilt)
{
// Only build the table based on this node if it is not empty
// or if it is the last node in the collection
if ((n.HasChildNodes) || (finalList.IndexOf(n) == finalList.Count))
{
foreach (XmlNode fld in n.ChildNodes)
{
Context.CheckCancelled();
//TODO - replacedverting the .Contains call to BinarySearch would
// allow for the injection of a custom implementation of IComparer
// in order to do a case insensitive search.
if (fld.NodeType == XmlNodeType.Element
&& (!fld.HasChildNodes
|| (fld.HasChildNodes
&& (fld.ChildNodes.Count == 1)
&& (fld.FirstChild.NodeType == XmlNodeType.Text)
)
)
&& (!dt.Columns.Contains(fld.Name)))
{
// Only add nodes that are elements and have 0 or 1 children (do not add collections)
dt.Columns.Add(new DataColumn(fld.Name));
}
}
// Add attributes from last node
if (n.Attributes.Count > 0)
{
foreach (XmlAttribute xa in n.Attributes)
{
dt.Columns.Add(n.LocalName + "." + xa.LocalName);
}
}
addParentIdColumns(dq, dt, n);
EnsureExplicitLeafColumnsExist(dq, dt, n);
tableBuilt = true;
// If this is a prepare call, we only need to return an empty table
//if (prepareOnly)
//{
// return dt;
//}
}
}
}
// loop throught the collection of nodes again to populate the table
foreach (XmlNode n in finalList)
{
DataRow dr = dt.NewRow();
string[] data = new string[dr.ItemArray.Length];
foreach (XmlNode fld in n.ChildNodes)
{
Context.CheckCancelled();
if ((dr.Table.Columns.IndexOf(fld.Name) >= 0)
&& (fld.HasChildNodes && fld.ChildNodes.Count == 1))
{
data[dr.Table.Columns.IndexOf(fld.Name)] = fld.FirstChild.InnerText;
}
addParentIdValues(dq, dt, data, fld);
}
if (!n.HasChildNodes)
{
// we have found a empty node, just add any ancestor fields
addParentIdValues(dq, dt, data, n);
}
// Extract Attributes
if (n.Attributes.Count > 0)
{
foreach (XmlAttribute xa in n.Attributes)
{
data[dr.Table.Columns.IndexOf(n.LocalName + "." + xa.LocalName)] = xa.Value;
}
}
dr.ItemArray = data;
dt.Rows.Add(dr);
}
if (whereClause.Length > 0)
{
dt.DefaultView.RowFilter = whereClause;
dt = dt.DefaultView.ToTable();
}
return dt;
}
19
Source : ListFunctions.cs
with MIT License
from ASStoredProcedures
with MIT License
from ASStoredProcedures
private DataTable getFunctionList(replacedemblyCollection replacedColl)
{
Context.TraceEvent(100, 0, "ListFunctions: Starting");
// build the structure for the datatable which is returned
DataTable dtFuncs = new DataTable("dtFunctions");
dtFuncs.Columns.Add("replacedembly", typeof(String));
dtFuncs.Columns.Add("Clreplaced", typeof(String));
dtFuncs.Columns.Add("Method", typeof(String));
dtFuncs.Columns.Add("ReturnType", typeof(String));
dtFuncs.Columns.Add("Parameters", typeof(String));
if (Context.ExecuteForPrepare)
{
// we can exit after building the table function if this is only
// being executed for a prepare.
Context.TraceEvent(100, 0, "ListFunctions: Finished (ExecuteForPrepare)");
return dtFuncs;
}
foreach (Microsoft.replacedysisServices.replacedembly replaced in replacedColl)
{
Context.CheckCancelled();
if (replaced is Clrreplacedembly) // we can only use reflection against .Net replacedemblies
{
Type t = replaced.GetType();
Clrreplacedembly clrreplaced = (Clrreplacedembly)replaced;
Context.TraceEvent(100, 0, "ListFunctions: Processing the " + clrreplaced.Name + " replacedembly");
foreach (ClrreplacedemblyFile f in clrreplaced.Files) // an replacedembly can have multiple files
{
Context.CheckCancelled();
// We only want to get the "main" asembly file and only files which have data
// (Some of the system replacedemblies appear to be registrations only and do not
// have any data.
if (f.Data.Count > 0 && f.Type == ClrreplacedemblyFileType.Main)
{
// replacedembly the replacedembly back into a single byte from the blocks of base64 strings
byte[] rawreplaced = new byte[0];
int iPos = 0;
byte[] buff = new byte[0];
foreach (string block in f.Data)
{
Context.CheckCancelled();
buff = System.Convert.FromBase64String(block);
System.Array.Resize(ref rawreplaced, rawreplaced.Length + buff.Length);
buff.CopyTo(rawreplaced, iPos);
iPos += buff.Length;
}
// use reflection to extract the public types and methods from the
// re-replacedembled replacedembly.
Context.TraceEvent(100, 0, "ListFunctions: Starting reflection against " + f.Name);
System.Reflection.replacedembly asreplaced = System.Reflection.replacedembly.Load(rawreplaced);
Type[] replacedTypes = asreplaced.GetTypes();
for (int i = 0; i < replacedTypes.Length; i++)
{
Type t2 = replacedTypes[i];
if (t2.IsPublic)
{
MethodInfo[] methods;
methods = t2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
int paramCnt = 0;
foreach (MethodInfo meth in methods)
{
Context.CheckCancelled();
// build the parameter signature as a string
ParameterInfo[] Params = meth.GetParameters();
System.Text.StringBuilder paramList = new System.Text.StringBuilder();
paramCnt = Params.Length;
string[] paramArray = new string[paramCnt];
// add the first parameter
if (paramCnt > 0)
{
paramList.Append(Params[0].Name);
paramList.Append(" as ");
paramList.Append(StripNamespace(Params[0].ParameterType.ToString()));
}
// add subsequent parameters, inserting a comma before each new one.
for (int j = 1; j < paramCnt; j++)
{
paramList.Append(", ");
paramList.Append(Params[j].Name);
paramList.Append(" as ");
paramList.Append(StripNamespace(Params[j].ParameterType.ToString()));
}
DataRow rowFunc = dtFuncs.NewRow();
Object[] items = new Object[5];
items[0] = replaced.Name;
items[1] = t2.Name;
items[2] = meth.Name;
items[3] = StripNamespace(meth.ReturnType.ToString());
items[4] = paramList.ToString();
rowFunc.ItemArray = items;
dtFuncs.Rows.Add(rowFunc);
rowFunc.AcceptChanges();
} // foreach meth
} // if t2.IsPublic
} // replacedTypes.Length
Context.TraceEvent(100, 0, "ListFunctions: Finished reflecting against " + f.Name);
} // if f.data.count > 0 && f.Type == main
} // foreach f
} // if replaced is clrreplacedembly
} // foreach replaced
dtFuncs.AcceptChanges();
Context.TraceEvent(100, dtFuncs.Rows.Count, "ListFunctions: Finished (" + dtFuncs.Rows.Count.ToString() + " function signatures)");
return dtFuncs;
}
19
Source : XmlaDiscover.cs
with MIT License
from ASStoredProcedures
with MIT License
from ASStoredProcedures
private void addTableRow(DataTable dt, XmlNode n)
{
DataRow dr = dt.NewRow();
foreach (XmlNode e in n.ChildNodes)
{
Context.CheckCancelled(); // Check if the user has cancelled
if (dt.Columns.Contains(e.LocalName))
{
dr[e.LocalName] = getNodeText(e);
}
}
dt.Rows.Add(dr);
}
19
Source : CSVDataReader.cs
with MIT License
from Autodesk
with MIT License
from Autodesk
public static DataTable ReadFile(string fileName)
{
DataTable result = new DataTable();
using (StreamReader reader = new StreamReader(fileName, Encoding))
{
string line;
int lineIndex = 0;
while (null != (line = reader.ReadLine()))
{
List<string> values = ParseLine(line);
if (lineIndex == 0)
{
foreach (string value in values)
{
string columnName = value;
if (true == result.Columns.Contains(columnName))
{
columnName = columnName + "_1";
}
DataColumn col = new DataColumn(columnName, typeof(string));
result.Columns.Add(col);
}
}
else
{
DataRow row = result.NewRow();
int colIndex = 0;
foreach (string value in values)
{
if (colIndex < result.Columns.Count)
{
row[colIndex++] = value;
}
}
result.Rows.Add(row);
}
lineIndex++;
}
}
return result;
}
19
Source : CsvReader.cs
with MIT License
from Autodesk-Forge
with MIT License
from Autodesk-Forge
internal static DataTable ReadFile(string filePath)
{
DataTable result = new DataTable();
Log.Info("Reading file: " + filePath);
using (StreamReader reader = new StreamReader(filePath, Encoding))
{
string line;
int lineIndex = 0;
while (null != (line = reader.ReadLine()))
{
List<string> values = ParseLine(line);
if(values == null || values.Count == 0)
{
continue;
}
if (lineIndex == 0)
{
foreach (string value in values)
{
string columnName = value;
if (true == result.Columns.Contains(columnName))
{
columnName = columnName + "_1";
}
DataColumn col = new DataColumn(columnName, typeof(string));
result.Columns.Add(col);
}
}
else
{
DataRow row = result.NewRow();
int colIndex = 0;
foreach (string value in values)
{
if (colIndex < result.Columns.Count)
{
row[colIndex++] = value;
}
}
result.Rows.Add(row);
}
lineIndex++;
}
Log.Info("- total lines read from the csv file: " + (lineIndex - 1).ToString());
}
return result;
}
19
Source : LogAnalyticsClientBase.cs
with MIT License
from Azure
with MIT License
from Azure
private DataTable ResultAsDataTable(QueryResults results)
{
DataTable dataTable = new DataTable("results");
dataTable.Clear();
dataTable.Columns.AddRange(results.Tables[0].Columns.Select(s => new DataColumn(s.Name, TypeConverter.StringToType(s.Type))).ToArray());
var rows = results.Tables[0].Rows.Select(s => dataTable.NewRow().ItemArray = s.ToArray());
foreach (var i in rows)
{
dataTable.Rows.Add(MakeRow(i, dataTable).ToArray());
}
return dataTable;
}
19
Source : MockLogAnalyticsClient.cs
with MIT License
from Azure
with MIT License
from Azure
private DataTable ResultAsDataTable(QueryResults results)
{
DataTable dataTable = new DataTable("results");
dataTable.Clear();
dataTable.Columns.AddRange(results.Tables[0].Columns.Select(s => new DataColumn(s.Name)).ToArray());
var rows = results.Tables[0].Rows.Select(s => dataTable.NewRow().ItemArray = s.ToArray());
foreach (var i in rows) { dataTable.Rows.Add(i); }
return dataTable;
}
19
Source : KeystoneComponent.cs
with MIT License
from Azure
with MIT License
from Azure
public static DiagnosticData AddKeystoneComponent(this Response response, KeystoneInsight keystoneInsight)
{
try
{
if (keystoneInsight.Status == null || string.IsNullOrWhiteSpace(keystoneInsight.replacedle) || string.IsNullOrWhiteSpace(keystoneInsight.Description))
{
throw new Exception("Required attributes Status, replacedle, and Description cannot be null or empty for KeystoneInsight.");
}
if (DateTime.Compare(keystoneInsight.ExpiryDate, DateTime.UtcNow) <= 0)
{
throw new Exception("Invalid ExpiryDate, ExpiryDate should be greater than current UTC datetime.");
}
var table = new DataTable();
table.Columns.Add("Content", typeof(string));
DataRow newRow = table.NewRow();
newRow["Content"] = JsonConvert.SerializeObject(keystoneInsight);
table.Rows.Add(newRow);
var diagData = new DiagnosticData()
{
Table = table,
RenderingProperties = new Rendering(RenderingType.KeystoneComponent)
};
response.Dataset.Add(diagData);
return diagData;
}
catch (Exception ex)
{
throw new Exception("Keystone Insight validation failed: " + ex.ToString());
}
}
19
Source : SearchComponent.cs
with MIT License
from Azure
with MIT License
from Azure
public static DiagnosticData AddSearch(this Response response, string customQueryString = null, bool detectorSearchEnabled=true, bool webSearchEnabled=true, DetectorSearchConfiguration detectorSearchConfiguration=null, WebSearchConfiguration webSearchConfiguration=null)
{
var table = new DataTable();
table.Columns.Add("DetectorSearchEnabled", typeof(bool));
table.Columns.Add("WebSearchEnabled", typeof(bool));
table.Columns.Add("DetectorSearchConfiguration", typeof(string));
table.Columns.Add("WebSearchConfiguration", typeof(string));
table.Columns.Add("CustomQueryString", typeof(string));
DataRow newRow = table.NewRow();
newRow["DetectorSearchEnabled"] = detectorSearchEnabled;
newRow["WebSearchEnabled"] = webSearchEnabled;
newRow["DetectorSearchConfiguration"] = detectorSearchConfiguration != null? JsonConvert.SerializeObject(detectorSearchConfiguration): JsonConvert.SerializeObject(new DetectorSearchConfiguration());
newRow["WebSearchConfiguration"] = webSearchConfiguration != null? JsonConvert.SerializeObject(webSearchConfiguration): JsonConvert.SerializeObject(new WebSearchConfiguration());
newRow["CustomQueryString"] = customQueryString;
table.Rows.Add(newRow);
var diagData = new DiagnosticData()
{
Table = table,
RenderingProperties = new Rendering(RenderingType.SearchComponent)
};
response.Dataset.Add(diagData);
return diagData;
}
19
Source : SummaryCard.cs
with MIT License
from Azure
with MIT License
from Azure
public static DiagnosticData AddSummaryCards(this Response response, List<SummaryCard> summaryCards)
{
if (summaryCards == null || !summaryCards.Any())
{
throw new ArgumentException("Paramter List<SummaryCard> is null or contains no elements.");
}
var table = new DataTable();
table.Columns.Add("Status", typeof(string));
table.Columns.Add("replacedle", typeof(string));
table.Columns.Add("Message", typeof(string));
table.Columns.Add("Description", typeof(string));
table.Columns.Add("Link", typeof(string));
table.Columns.Add("ActionType", typeof(string));
foreach (var summaryCard in summaryCards)
{
DataRow nr = table.NewRow();
nr["Status"] = summaryCard.Status;
nr["replacedle"] = summaryCard.replacedle;
nr["Message"] = summaryCard.Message;
nr["Description"] = summaryCard.Description;
nr["Link"] = summaryCard.OnClickActionLink;
nr["ActionType"] = summaryCard.OnClickActionType;
table.Rows.Add(nr);
//table.Rows.Add(summaryCard.Status,summaryCard.replacedle,summaryCard.Message,summaryCard.Description);
}
var diagData = new DiagnosticData()
{
Table = table,
RenderingProperties = new Rendering(RenderingType.SummaryCard)
};
response.Dataset.Add(diagData);
return diagData;
}
19
Source : DataTableResponseObject.cs
with MIT License
from Azure
with MIT License
from Azure
public static DataTable ToDataTable(this DataTableResponseObject dataTableResponse)
{
if (dataTableResponse == null)
{
throw new ArgumentNullException("dataTableResponse");
}
var dataTable = new DataTable(dataTableResponse.TableName);
dataTable.Columns.AddRange(dataTableResponse.Columns.Select(column => new DataColumn(column.ColumnName, GetColumnType(column.DataType))).ToArray());
for (int i = 0; i < dataTableResponse.Rows.GetLength(0); i++)
{
var row = dataTable.NewRow();
for (int j = 0; j < dataTable.Columns.Count; j++)
{
row[j] = dataTableResponse.Rows[i, j] ?? DBNull.Value;
}
dataTable.Rows.Add(row);
}
return dataTable;
}
19
Source : DataTableResponseObject.cs
with MIT License
from Azure
with MIT License
from Azure
public static DataTable ToAppInsightsDataTable(this AppInsightsDataTableResponseObject appInsightsDataTableResponse)
{
if (appInsightsDataTableResponse == null)
{
throw new ArgumentNullException("appInsightsDataTableResponse");
}
var dataTable = new DataTable(appInsightsDataTableResponse.Name);
dataTable.Columns.AddRange(appInsightsDataTableResponse.Columns.Select(column => new DataColumn(column.Name, GetColumnType(column.Type))).ToArray());
for (int i = 0; i < appInsightsDataTableResponse.Rows.GetLength(0); i++)
{
var row = dataTable.NewRow();
for (int j = 0; j < dataTable.Columns.Count; j++)
{
row[j] = MaskPII(appInsightsDataTableResponse.Rows[i, j]) ?? DBNull.Value;
}
dataTable.Rows.Add(row);
}
return dataTable;
}
19
Source : ReportGenerator.cs
with MIT License
from Azure
with MIT License
from Azure
public DataRow GenerateFluidLevelTestReport() {
lock (_dataset) {
var row = _dataset.Tables[0].NewRow();
row[0] = Guid.NewGuid().ToString();
row[1] = DateTime.UtcNow;
var index = GetRandom(0, kWellUIDs.Length - 1);
row[2] = kWellNames[index];
row[3] = kWellUIDs[index];
row[4] = DateTime.UtcNow.AddHours(-GetRandom(0, 10));
row[5] = GetRandom(kTestReasons);
row[6] = GetRandom(0, 1000);
row[7] = GetRandom(kUnitLengths);
row[8] = GetRandom(kTesters);
_dataset.Tables[0].Rows.Add(row);
_dataset.AcceptChanges();
return row;
}
}
19
Source : ReportGenerator.cs
with MIT License
from Azure
with MIT License
from Azure
public DataRow GenerateInjectionTestReport() {
lock (_dataset) {
var row = _dataset.Tables[1].NewRow();
row[0] = Guid.NewGuid().ToString();
row[1] = DateTime.UtcNow;
var index = GetRandom(0, kWellUIDs.Length - 1);
row[2] = kWellNames[index];
row[3] = kWellUIDs[index];
row[4] = DateTime.UtcNow.AddHours(-GetRandom(0, 10));
row[5] = GetRandom(kTestReasons);
row[6] = GetRandom(0, 1000);
row[7] = GetRandom(kUnitTimes);
row[8] = GetRandom(kInjectionFluids);
_dataset.Tables[1].Rows.Add(row);
_dataset.AcceptChanges();
return row;
}
}
19
Source : DataFileReader.cs
with MIT License
from Azure
with MIT License
from Azure
private DataSet LoadData(ISystemContext context, DateTime baseline, StreamReader reader) {
var dataset = CreateDataSet();
var messageContext = new ServiceMessageContext();
if (context != null) {
messageContext.NamespaceUris = context.NamespaceUris;
messageContext.ServerUris = context.ServerUris;
messageContext.Factory = context.EncodeableFactory;
}
else {
messageContext.NamespaceUris = ServiceMessageContext.GlobalContext.NamespaceUris;
messageContext.ServerUris = ServiceMessageContext.GlobalContext.ServerUris;
messageContext.Factory = ServiceMessageContext.GlobalContext.Factory;
}
var sourceTimeOffset = 0;
var serverTimeOffset = 0;
StatusCode status = StatusCodes.Good;
var recordType = 0;
var modificationTimeOffet = 0;
var modificationUser = string.Empty;
var valueType = BuiltInType.String;
var value = Variant.Null;
var annotationTimeOffet = 0;
var annotationUser = string.Empty;
var annotationMessage = string.Empty;
var lineCount = 0;
while (!reader.EndOfStream) {
var line = reader.ReadLine();
// check for end or error.
if (line == null) {
break;
}
// ignore blank lines.
line = line.Trim();
lineCount++;
if (string.IsNullOrEmpty(line)) {
continue;
}
// ignore commented out lines.
if (line.StartsWith("//", StringComparison.CurrentCulture)) {
continue;
}
// get source time.
if (!ExtractField(lineCount, ref line, out sourceTimeOffset)) {
continue;
}
// get server time.
if (!ExtractField(lineCount, ref line, out serverTimeOffset)) {
continue;
}
// get status code.
if (!ExtractField(lineCount, ref line, out status)) {
continue;
}
// get modification type.
if (!ExtractField(lineCount, ref line, out recordType)) {
continue;
}
// get modification time.
if (!ExtractField(lineCount, ref line, out modificationTimeOffet)) {
continue;
}
// get modification user.
if (!ExtractField(lineCount, ref line, out modificationUser)) {
continue;
}
if (recordType >= 0) {
// get value type.
if (!ExtractField(lineCount, ref line, out valueType)) {
continue;
}
// get value.
if (!ExtractField(lineCount, ref line, messageContext, valueType, out value)) {
continue;
}
}
else {
// get annotation time.
if (!ExtractField(lineCount, ref line, out annotationTimeOffet)) {
continue;
}
// get annotation user.
if (!ExtractField(lineCount, ref line, out annotationUser)) {
continue;
}
// get annotation message.
if (!ExtractField(lineCount, ref line, out annotationMessage)) {
continue;
}
}
// add values to data table.
var dataValue = new DataValue {
WrappedValue = value,
SourceTimestamp = baseline.AddMilliseconds(sourceTimeOffset),
ServerTimestamp = baseline.AddMilliseconds(serverTimeOffset),
StatusCode = status
};
DataRow row = null;
if (recordType == 0) {
row = dataset.Tables[0].NewRow();
row[0] = dataValue.SourceTimestamp;
row[1] = dataValue.ServerTimestamp;
row[2] = dataValue;
row[3] = valueType;
row[4] = (value.TypeInfo != null) ? value.TypeInfo.ValueRank : ValueRanks.Any;
dataset.Tables[0].Rows.Add(row);
}
else if (recordType > 0) {
row = dataset.Tables[1].NewRow();
row[0] = dataValue.SourceTimestamp;
row[1] = dataValue.ServerTimestamp;
row[2] = dataValue;
row[3] = valueType;
row[4] = (value.TypeInfo != null) ? value.TypeInfo.ValueRank : ValueRanks.Any;
row[5] = recordType;
var info = new ModificationInfo {
UpdateType = (HistoryUpdateType)recordType,
ModificationTime = baseline.AddMilliseconds(modificationTimeOffet),
UserName = modificationUser
};
row[6] = info;
dataset.Tables[1].Rows.Add(row);
}
else if (recordType < 0) {
row = dataset.Tables[2].NewRow();
var annotation = new Annotation {
AnnotationTime = baseline.AddMilliseconds(annotationTimeOffet),
UserName = annotationUser,
Message = annotationMessage
};
dataValue.WrappedValue = new ExtensionObject(annotation);
row[0] = dataValue.SourceTimestamp;
row[1] = dataValue.ServerTimestamp;
row[2] = dataValue;
row[3] = valueType;
row[4] = (value.TypeInfo != null) ? value.TypeInfo.ValueRank : ValueRanks.Any;
row[5] = annotation;
dataset.Tables[2].Rows.Add(row);
}
dataset.AcceptChanges();
}
return dataset;
}
19
Source : ReferenceServerUtils.cs
with MIT License
from Azure
with MIT License
from Azure
public static DataSet EmptyQueue(DataSet dataset) {
if (dataset == null) {
dataset = new DataSet();
dataset.Tables.Add("MonitoredItems");
dataset.Tables[0].Columns.Add("Id", typeof(uint));
dataset.Tables[0].Columns.Add("Timestamp", typeof(string));
dataset.Tables[0].Columns.Add("EventType", typeof(string));
dataset.Tables[0].Columns.Add("NodeId", typeof(NodeId));
dataset.Tables[0].Columns.Add("MonitoringMode", typeof(MonitoringMode));
dataset.Tables[0].Columns.Add("SamplingInterval", typeof(double));
dataset.Tables[0].Columns.Add("QueueSize", typeof(uint));
dataset.Tables[0].Columns.Add("DiscardOldest", typeof(bool));
dataset.Tables[0].Columns.Add("Filter", typeof(string));
dataset.Tables[0].Columns.Add("Value", typeof(Variant));
dataset.Tables[0].Columns.Add("StatusCode", typeof(StatusCode));
dataset.Tables[0].Columns.Add("SourceTimestamp", typeof(string));
dataset.Tables[0].Columns.Add("ServerTimestamp", typeof(string));
dataset.Tables[0].DefaultView.Sort = "Timestamp";
}
lock (_events) {
while (_events.Count > 0) {
var e = _events.Dequeue();
var row = dataset.Tables[0].NewRow();
row[0] = e.ServerHandle;
row[1] = e.Timestamp.ToLocalTime().ToString("HH:mm:ss.ffffff");
row[2] = e.EventType.ToString();
row[3] = e.NodeId;
if (e.Parameters != null) {
row[4] = e.MonitoringMode;
row[5] = e.Parameters.SamplingInterval;
row[6] = e.Parameters.QueueSize;
row[7] = e.Parameters.DiscardOldest;
if (e.Parameters.Filter != null) {
row[8] = e.Parameters.Filter.ToString();
}
}
if (e.Value != null) {
row[9] = e.Value.WrappedValue;
row[10] = e.Value.StatusCode;
row[11] = e.Value.ServerTimestamp.ToLocalTime().ToString("HH:mm:ss.fff");
row[12] = e.Value.ServerTimestamp.ToLocalTime().ToString("HH:mm:ss.fff");
}
dataset.Tables[0].Rows.Add(row);
}
}
dataset.AcceptChanges();
return dataset;
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
private void AddItem(object sender, RoutedEventArgs args)
{
DataRow row = ds.Tables["Mountains"].NewRow();
row["Mountain_ID"] = 4;
row["Mountain_Name"] = "Big White";
ds.Tables["Mountains"].Rows.Add(row);
add.IsEnabled = false;
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
private void AddItem(object sender, RoutedEventArgs args)
{
DataRow row = ds.Tables["Mountains"].NewRow();
row["Mountain_ID"] = 4;
row["Mountain_Name"] = "Big White";
ds.Tables["Mountains"].Rows.Add(row);
add.IsEnabled = false;
}
19
Source : DataTableFill.cs
with MIT License
from Cankirism
with MIT License
from Cankirism
public DataTable FillDataTable(IEnumerable<UsersProperties> usersDataList)
{
try
{
List<UsersProperties> userData = usersDataList.ToList();
_dataTable = new DataTable();
_dataTable.Columns.Add("Kayıt No", typeof(int));
_dataTable.Columns.Add("İsim", typeof(string));
_dataTable.Columns.Add("Kullanıcı Adı", typeof(string));
_dataTable.Columns.Add("Kullanıcı Aktif Kodu", typeof(string));
_dataTable.Columns.Add("Kullanıcı Durumu", typeof(string));
_dataTable.Columns.Add("Son Bağlantı", typeof(string));
_dataTable.Columns.Add("Katılma Tarihi", typeof(string));
_dataTable.Columns.Add("Parola Değiştirme", typeof(string));
for (int i = 0, j = 1; i < userData.Count && j <= userData.Count; i++, j++)
{
_dataTable.NewRow();
UsersProperties users = userData[i];
_dataTable.Rows.Add(j, users.cannonicalName, users.samAccountName, users.userAccountControlCode, users.userAccountControl, users.lastLogon, users.whenCreated, users.pwdLastSet);
}
}
catch (Exception ex)
{
ErrorMessage = ex.Message;
_dataTable = null;
}
return _dataTable;
}
19
Source : DataTableFill.cs
with MIT License
from Cankirism
with MIT License
from Cankirism
public DataTable FillDataTableWithComputers(List<ComputersProperties> computerList)
{
List<ComputersProperties> _computerList = computerList;
DataTable computerDt = new DataTable();
computerDt.Columns.Add("Kayıt No", typeof(int));
computerDt.Columns.Add("Pc Adı", typeof(string));
computerDt.Columns.Add("Sid", typeof(string));
computerDt.Columns.Add("İp Adresi", typeof(string));
computerDt.Columns.Add("Son Parola Oluşturma", typeof(string));
computerDt.Columns.Add("Son Başarısız Parola Giriş", typeof(string));
for (int i = 0, j = 1; i < _computerList.Count && j <= _computerList.Count; i++, j++)
{
computerDt.NewRow();
ComputersProperties computerPro = _computerList[i];
computerDt.Rows.Add(j, computerPro.computerName, computerPro.computerSID, computerPro.ipAdress, computerPro.lastPreplacedSet, computerPro.lastBadAttempt);
}
return computerDt;
}
19
Source : CBL.cs
with GNU Lesser General Public License v3.0
from ccbpm
with GNU Lesser General Public License v3.0
from ccbpm
public DataTable SaveSelectedItemValToTableOID()
{
DataTable dt =new DataTable();
dt.Columns.Add(new DataColumn("OID",typeof(int)) );
foreach(Lisreplacedem li in this.Items)
{
if (li.Selected)
{
DataRow dr = dt.NewRow();
dr["OID"]=li.Value;
dt.Rows.Add(dr);
}
}
return dt;
}
19
Source : CBL.cs
with GNU Lesser General Public License v3.0
from ccbpm
with GNU Lesser General Public License v3.0
from ccbpm
public DataTable SaveSelectedItemValToTableNo()
{
DataTable dt =new DataTable();
dt.Columns.Add(new DataColumn("No",typeof(string)) );
foreach(Lisreplacedem li in this.Items)
{
if (li.Selected)
{
DataRow dr = dt.NewRow();
dr["No"]=li.Value;
dt.Rows.Add(dr);
}
}
return dt;
}
19
Source : GloEntity.cs
with GNU Lesser General Public License v3.0
from ccbpm
with GNU Lesser General Public License v3.0
from ccbpm
private static DataTable ToTable0(Enreplacedy en)
{
string nameOfEnterInfo = en.EnDesc;
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("输入项目", typeof(string)));
dt.Columns.Add(new DataColumn(nameOfEnterInfo, typeof(string)));
dt.Columns.Add(new DataColumn("信息输入要求", typeof(string)));
foreach (Attr attr in en.EnMap.Attrs)
{
DataRow dr = dt.NewRow();
dr["输入项目"] = attr.Desc;
dr[nameOfEnterInfo] = en.GetValByKey(attr.Key);
dr["信息输入要求"] = attr.EnterDesc;
dt.Rows.Add(dr);
}
// 如果实体需要附件。
if (en.EnMap.AdjunctType != AdjunctType.None)
{
// 加入附件信息。
DataRow dr1 = dt.NewRow();
dr1["输入项目"] = "附件";
dr1[nameOfEnterInfo] = "";
dr1["信息输入要求"] = "编辑附件";
dt.Rows.Add(dr1);
}
// 明细
foreach (EnDtl dtl in en.EnMap.Dtls)
{
DataRow dr = dt.NewRow();
dr["输入项目"] = dtl.Desc;
dr[nameOfEnterInfo] = "EnsName_" + dtl.Ens.ToString() + "_RefKey_" + dtl.RefKey;
dr["信息输入要求"] = "请进入编辑明细";
dt.Rows.Add(dr);
}
foreach (AttrOfOneVSM attr in en.EnMap.AttrsOfOneVSM)
{
DataRow dr = dt.NewRow();
dr["输入项目"] = attr.Desc;
dr[nameOfEnterInfo] = "OneVSM" + attr.EnsOfMM.ToString();
dr["信息输入要求"] = "请进入编辑多选";
dt.Rows.Add(dr);
}
return dt;
}
See More Examples