public static int ResultsFromCursor(IServerCursor cursor, StringBuilder results) { DAE.Schema.IRowType rowType = ((DAE.Schema.TableType)cursor.Plan.DataType).RowType; ResultColumn[] resultColumns = BuildResultColumns(rowType); int rowCount; try { using (DAE.Runtime.Data.Row row = new DAE.Runtime.Data.Row(cursor.Plan.Process.ValueManager, rowType)) { while (cursor.Next()) { cursor.Select(row); ReadRow(row, resultColumns); } } } finally { // Even if something fails (or aborts) build what we can rowCount = BuildResults(resultColumns, results); } return(rowCount); }
// IWebHandler public virtual bool ProcessRequest(HttpContext context) { if (Session.IsActionLink(context, _moveID)) { string rowIndex = context.Request.QueryString["RowIndex"]; if (rowIndex != null) { if (_movingRow != null) { string posY = context.Request.QueryString["Y"]; if (posY != null) { DAE.Runtime.Data.IRow target = ParentGrid.DataLink.Buffer(Int32.Parse(rowIndex)); SequenceChange(_movingRow, target, Int32.Parse(posY) < 10); } } else { _movingRow = (DAE.Runtime.Data.Row)ParentGrid.DataLink.Buffer(Int32.Parse(rowIndex)).Copy(); return(true); } } CancelMove(); return(true); } else { return(false); } }
private void UpgradesClicked(object sender, EventArgs args) { IWindowsFormInterface form = Dataphoria.FrontendSession.LoadForm ( null, @".Frontend.Form('Frontend', 'UpgradeBrowse')", null ); try { form.HostNode.Open(); Frontend.Client.ISource source = (Frontend.Client.ISource)form.FindNode("Libraries"); using (DAE.Runtime.Data.Row row = new DAE.Runtime.Data.Row(source.DataView.Process.ValueManager, source.DataView.TableType.RowType)) { row["Name"] = LibraryName; source.DataView.FindKey(row); } form.ShowModal(Frontend.Client.FormMode.None); } finally { form.HostNode.Dispose(); } }
private DAE.Runtime.Data.Row CreateSearchRow() { // Determine the last search control with a search value SearchControl pendingIncremental = null; SearchControl control; for (int i = _searchControls.Count - 1; i >= 0; i--) { control = (SearchControl)_searchControls[i]; if (control.Value != null) { pendingIncremental = control; break; } } if (pendingIncremental != null) { // FROM WINDOWS CLIENT // Build a row consisting of order columns up to and including the pending control RowType rowType = new RowType(); foreach (OrderColumn column in _order.Columns) { rowType.Columns.Add(new DAE.Schema.Column(column.Column.Name, column.Column.DataType)); if (column.Column.Name == pendingIncremental.ColumnName) { break; } } DAE.Runtime.Data.Row row = new DAE.Runtime.Data.Row(Source.Process.ValueManager, rowType); try { Source.DataView.InitializeFromMaster(row); foreach (DAE.Schema.Column column in rowType.Columns) { if (!Source.DataView.IsDetailKey(column.Name)) { if (!FindSearchControl(column.Name).ExtractValue(row)) { return(null); } } } return(row); } catch { row.Dispose(); throw; } // END FROM WINDOWS CLIENT } else { return(null); } }
private void CancelMove() { if (_movingRow != null) { _movingRow.Dispose(); _movingRow = null; } }
private void DisposeRow() { if (_internalRow != null) { _internalRow.Dispose(); _internalRow = null; } }
public void BuildTree() { ClearNodes(); if (IsFieldActive() && (Source.DataView.State != DAE.Client.DataSetState.Insert)) { // Open a dynamic navigable browse cursor on the root expression PrepareRootPlan(); IServerCursor cursor = _rootPlan.Open(_rootParams); try { DAE.Runtime.Data.IRow key; int columnIndex; string text; while (cursor.Next()) { key = new DAE.Runtime.Data.Row(_process.ValueManager, new DAE.Schema.RowType(Source.DataView.Order.Columns)); try { using (DAE.Runtime.Data.IRow row = cursor.Select()) { row.CopyTo(key); columnIndex = row.DataType.Columns.IndexOf(ColumnName); if (row.HasValue(columnIndex)) { text = ((DAE.Runtime.Data.Scalar)row.GetValue(columnIndex)).AsDisplayString; } else { text = Strings.Get("NoValue"); } } Nodes.Add(new TreeNode(this, text, key, 0, null)); } catch { key.Dispose(); throw; } } } finally { _rootPlan.Close(cursor); } foreach (TreeNode node in Nodes) { node.BuildChildren(); } SelectNode(Source.DataView.GetKey()); } }
public object GetNativeValue(int index) { DAE.Runtime.Data.Row row = InternalRow; if (!row.HasValue(index)) { return(DBNull.Value); } else { return(row[index]); } }
private void SaveToCache(string document, IServerProcess process, DAE.Runtime.Data.DataValue value, uint cRC32) { using (Stream targetStream = Cache.Freshen(document, cRC32)) { byte[] bytes; using (DAE.Runtime.Data.Row row = new DAE.Runtime.Data.Row(process.ValueManager, GetCacheRowType(process))) { row["Value"] = value; bytes = new byte[row.GetPhysicalSize(true)]; row.WriteToPhysical(bytes, 0, true); } StreamUtility.WriteInteger(targetStream, bytes.Length); targetStream.Write(bytes, 0, bytes.Length); } }
/// <summary> Creates this nodes immediate children. Avoids duplication. </summary> public void BuildChildren() { // Open a dynamic navigable browse cursor on the child expression IServerCursor cursor = Tree.OpenChildCursor(_key); try { DAE.Runtime.Data.Row key; string text; int index = 0; int columnIndex; while (cursor.Next()) { key = new DAE.Runtime.Data.Row(Tree.Process.ValueManager, new RowType(Tree.Source.DataView.Order.Columns)); try { using (DAE.Runtime.Data.IRow row = cursor.Select()) { row.CopyTo(key); columnIndex = row.DataType.Columns.IndexOf(Tree.ColumnName); if (row.HasValue(columnIndex)) { text = ((DAE.Runtime.Data.Scalar)row.GetValue(columnIndex)).AsDisplayString; } else { text = Strings.Get("NoValue"); } } if (FindChild(key) == null) { Nodes.Insert(index, new TreeNode(Tree, text, key, _depth + 1, this)); } index++; } catch { key.Dispose(); throw; } } } finally { Tree.CloseChildCursor(cursor); } }
private IScalar LoadWithCache(string document, IServerProcess process) { IScalar result = null; lock (Cache) { uint cRC32 = Cache.GetCRC32(document); if (cRC32 > 0) { try { result = LoadFromCache(document, process); } catch { result = null; cRC32 = 0; } } using ( DAE.Runtime.Data.Row row = (DAE.Runtime.Data.Row)process.Evaluate ( String.Format ( "LoadIfNecessary('{0}', {1})", document.Replace("'", "''"), ((int)cRC32).ToString() ), null ) ) if (!(bool)row["CRCMatches"]) { using (DAE.Runtime.Data.Scalar value = row.GetValue("Value") as DAE.Runtime.Data.Scalar) { SaveToCache(document, process, value, (uint)(int)row["ActualCRC32"]); result = (DAE.Runtime.Data.Scalar)value.Copy(); } } } return(result); }
protected void BuildParentPath(DAE.Runtime.Data.IRow key, ArrayList path) { foreach (DAE.Runtime.Data.Row localKey in path) { if (KeysEqual(key, localKey)) { throw new WebClientException(WebClientException.Codes.TreeViewInfiniteLoop); } } path.Add(key); IServerCursor cursor = OpenParentCursor(key); try { if (cursor.Next()) { key = new DAE.Runtime.Data.Row(_process.ValueManager, new RowType(Source.DataView.Order.Columns)); using (DAE.Runtime.Data.IRow selected = cursor.Select()) selected.CopyTo(key); } else { key = null; } } finally { CloseParentCursor(cursor); } if (key != null) { if (FindChild(key) == null) { BuildParentPath(key, path); } else { path.Add(key); } } }
public override bool Read() { if (_cursor.Next()) { if (_internalRow == null) { _internalRow = new DAE.Runtime.Data.Row(_cursor.Plan.Process.ValueManager, ((TableType)_cursor.Plan.DataType).RowType); } _cursor.Select(_internalRow); if (!_cursor.EOF()) { _rowCount++; } return(!_cursor.EOF()); } else { return(false); } }
public void AsyncLoad() { try { uint cRC32 = 0; if (System.IO.File.Exists(_fileName)) { // compute the CRC of the existing file using (FileStream stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read)) cRC32 = CRC32Utility.GetCRC32(stream); } using ( DAE.Runtime.Data.Row row = (DAE.Runtime.Data.Row)_process.Evaluate ( String.Format ( "LoadIfNecessary('{0}', {1})", _document.Replace("'", "''"), ((int)cRC32).ToString() ), null ) ) { if (!(bool)row["CRCMatches"]) { Directory.CreateDirectory(Path.GetDirectoryName(_fileName)); using (Stream sourceStream = row.GetValue("Value").OpenStream()) using (FileStream targetStream = new FileStream(_fileName, FileMode.Create, FileAccess.Write)) StreamUtility.CopyStream(sourceStream, targetStream); } } Session.SafelyInvoke(new AsyncFinishHandler(AsyncFinish), new object[] { true }); } catch { Session.SafelyInvoke(new AsyncFinishHandler(AsyncFinish), new object[] { false }); // Don't allow exceptions to go unhandled... the framework will abort the application } }
public bool ExtractValue(DAE.Runtime.Data.Row row) { try { if (_value != null) { ((DAE.Runtime.Data.Scalar)row.GetValue(_columnName)).AsString = _value; } else { ((DAE.Runtime.Data.Scalar)row.GetValue(_columnName)).AsString = String.Empty; // Assume that if we are included in the search, that we are blank } _conversionFailed = false; return(true); } catch { _conversionFailed = true; return(false); } }
private void PerformSearch() { if ((Source != null) && (Source.DataView != null) && !Source.DataView.IsEmpty()) { using (DAE.Runtime.Data.Row row = CreateSearchRow()) { if (row == null) { return; } _searching = true; try { Source.DataView.FindNearest(row); } finally { _searching = false; } } } }
public override string SetApplication(string applicationID, string clientType) { // Reset our current settings _theme = null; DisposeDefaultIcon(); ClearDocumentCache(); ClearImageCache(); int documentCacheSize = CDefaultDocumentCacheSize; int imageCacheSize = CDefaultImageCacheSize; // Optimistically load the settings try { DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams(); paramsValue.Add(DAE.Runtime.DataParam.Create(Pipe.Process, "AApplicationID", applicationID)); using (DAE.Runtime.Data.Row row = (DAE.Runtime.Data.Row)Evaluate(Pipe.Process, SettingsExpression, paramsValue)) { if (row != null) { // Load the theme if (row.HasValue("Theme")) { _theme = (Theme) new BOP.Deserializer().Deserialize((string)row["Theme"], null); } // Load the default form icon if (row.HasValue("IconImage")) { using (Stream iconStream = row.GetValue("IconImage").OpenStream()) { Bitmap bitmap = System.Drawing.Image.FromStream(iconStream) as Bitmap; if (bitmap != null) { _defaultIcon = Icon.FromHandle(bitmap.GetHicon()); // TODO: Should this bitmap be disposed after this? } } } // Load the document cache size if (row.HasValue("DocumentCacheSize")) { documentCacheSize = (int)row["DocumentCacheSize"]; } // Load the image cache size if (row.HasValue("ImageCacheSize")) { imageCacheSize = (int)row["ImageCacheSize"]; } // Load the help file if (row.HasValue("HelpDocument")) { string document = (string)row["HelpDocument"]; if (document != String.Empty) { LoadHelpDocument(document); } } } } } catch (Exception exception) { HandleException(new ClientException(ClientException.Codes.ErrorLoadingSettings, exception)); } finally { if (_theme == null) { _theme = new Theme(); } } // Setup the image cache try { if (imageCacheSize > 0) { Pipe.ImageCache = new FixedSizeCache <string, byte[]>(imageCacheSize); } } catch (Exception exception) { HandleException(exception); // Don't fail, just warn } // Set up the client-side document cache try { if (documentCacheSize > 0) { Pipe.Cache = new DocumentCache ( Path.Combine ( Path.Combine(System.IO.Path.GetTempPath(), CCachePath), @"App" + applicationID.ToString() ), documentCacheSize ); } } #if DEBUG catch (Exception exception) #else catch #endif { #if DEBUG HandleException(exception); // Don't fail if we can't do this and only show something if under debug #endif } return(base.SetApplication(applicationID, clientType)); }
/// <summary> Locates the nearest matching row in one DataSource given another DataSource. </summary> /// <param name="target"> The DataSource to target for the search. </param> /// <param name="targetColumnNames"> The list of columns to search by. </param> /// <param name="source"> A DataSource to pull search values from. </param> /// <param name="sourceColumnNames"> /// Column names corresponding ATargetColumnNames, which map to fields /// within ASource. /// </param> public static void FindNearestRow(DAE.Client.DataSource target, string[] targetColumnNames, DAE.Client.DataSource source, string[] sourceColumnNames) { //Build the row type DAE.Schema.RowType rowType = new DAE.Schema.RowType(); string trimmedName; foreach (string columnName in targetColumnNames) { trimmedName = columnName.Trim(); rowType.Columns.Add(new DAE.Schema.Column(trimmedName, target.DataSet[trimmedName].DataType)); } //Fill in the row values bool find = true; using (DAE.Runtime.Data.Row row = new DAE.Runtime.Data.Row(target.DataSet.Process.ValueManager, rowType)) { for (int i = 0; i < targetColumnNames.Length; i++) { if (!source.DataSet[sourceColumnNames[i].Trim()].HasValue()) { find = false; break; } else { row[i] = source.DataSet[sourceColumnNames[i].Trim()].Value; } } DAE.Client.TableDataSet targetDataSet = target.DataSet as DAE.Client.TableDataSet; if (find && (targetDataSet != null)) { string saveOrder = String.Empty; // If the view order does not match the row to find bool orderMatches = true; for (int index = 0; index < row.DataType.Columns.Count; index++) { if ((index >= targetDataSet.Order.Columns.Count) || !DAE.Schema.Object.NamesEqual(targetDataSet.Order.Columns[index].Column.Name, row.DataType.Columns[index].Name)) { orderMatches = false; break; } } if (!orderMatches) { saveOrder = targetDataSet.OrderString; DAE.Schema.Order newOrder = new DAE.Schema.Order(); foreach (DAE.Schema.Column column in row.DataType.Columns) { newOrder.Columns.Add(new DAE.Schema.OrderColumn(target.DataSet.TableVar.Columns[column.Name], true)); } targetDataSet.Order = newOrder; } try { targetDataSet.FindNearest(row); } finally { if (saveOrder != String.Empty) { targetDataSet.OrderString = saveOrder; } } } } }