/// <summary> /// Add conditions to choose from list by given field's values /// </summary> /// <param name="oChooseFromList"></param> /// <param name="fieldAlias"></param> /// <param name="values"></param> public static void AddConditionValues(ChooseFromList oChooseFromList, string fieldAlias, string[] values) { Condition oCondition = null; Conditions oConditions = new Conditions(); try { if (values != null && values.Length > 0) { for (int i = 1; i < values.Length + 1; i++) { oCondition = oConditions.Add(); oCondition.Alias = fieldAlias; oCondition.Operation = BoConditionOperation.co_EQUAL; oCondition.CondVal = values[i - 1]; if (values.Length > i) { oCondition.Relationship = SAPbouiCOM.BoConditionRelationship.cr_OR; } } } else { oCondition = oConditions.Add(); oCondition.Alias = fieldAlias; oCondition.Operation = BoConditionOperation.co_EQUAL; oCondition.CondVal = "none"; } oChooseFromList.SetConditions(oConditions); } catch (Exception ex) { SAPException.Handle(ex, "AddConditionValues"); } }
public static DataTable CreateDataTable(string tableID, Dictionary <string, BoFieldsType> columns, UserFormBase frm) { DataTable dataTable = null; try { frm.UIAPIRawForm.DataSources.DataTables.Add(tableID); dataTable = frm.UIAPIRawForm.DataSources.DataTables.Item(tableID); columns.AsParallel().ForAll(column => { dataTable.Columns.Add("C_" + column.Key, column.Value); }); } catch (Exception ex) { SAPException.Handle(ex, "(Create DataTable)"); } return(dataTable); }
public static void Fill <T>(string tableID, DataTable dataTable, Matrix mtx, List <string> columns, T[] data) { try { if (!Object.ReferenceEquals(data, null)) { dataTable.Rows.Clear(); Parallel.For(0, data.Length, row => { dataTable.Rows.Add(); }); Task.Factory.StartNew(() => { Parallel.For(0, data.Length, row => { dataTable.SetValue("C_#", row, row + 1); }); }); Parallel.ForEach(Partitioner.Create(0, data.Length), (range, state) => { for (int i = range.Item1; i < range.Item2; i++) { Parallel.ForEach(columns.Skip(1), column => { dataTable.SetValue("C_" + column, i, data[i].GetType().GetProperty(column).GetValue(data[i], null)); }); } }); Bind(mtx, tableID, columns); } else { ClearMtx(mtx); } } catch (AggregateException ae) { ae.Handle(e => { SAPException.Handle(e, "(AE)"); return(true); }); } catch (Exception ex) { SAPException.Handle(ex, "(FillMatrix0)"); } }