private static void setDataBind(HtmlNode node, IList <HtmlElement_BodyBase> htmlElements) { string id = node.GetAttributeValue("id", string.Empty); if (!string.IsNullOrEmpty(id)) { foreach (HtmlElement_BodyBase hbb in htmlElements) { if (string.CompareOrdinal(id, hbb.id) == 0) { setDataBind0(node, hbb); IDataSourceBinder dsb = hbb as IDataSourceBinder; if (dsb != null) { IDataSetSource ids = dsb.DataSource as IDataSetSource; if (ids != null && !string.IsNullOrEmpty(ids.TableName)) { node.SetAttributeValue("jsdb", ids.TableName); } } break; } } } if (node.ChildNodes.Count > 0) { for (int i = 0; i < node.ChildNodes.Count; i++) { setDataBind(node.ChildNodes[i], htmlElements); } } }
void _tbl_ColumnChanged(object sender, DataColumnChangeEventArgs e) { IDataSetSource dss = _owner.DataSetStore; if (dss != null) { dss.SetFieldValueEx(_rowIdx, e.Column.ColumnName, e.ProposedValue); } }
public string GetFieldNameByIndex(int index) { IDataSetSource ds = DataSource as IDataSetSource; if (ds != null) { return(ds.GetFieldNameByIndex(index)); } return(string.Empty); }
public async Task <DataSetSummary> Create(IDataSetSource source) { try { var result = await DataSetRepository.Create(source); return(result); } catch (Exception ex) { Logger.Error("DataSetService.Create failed", this, ex); } return(null); }
public async Task <DataSetSummary> Create(IDataSetSource source, CancellationToken cancellationToken = default(CancellationToken)) { Argument.IsNotNullOrEmpty(source.Name, nameof(source.Name)); switch (source) { case DataSetDetailSource detail: Argument.IsNotNull(detail.Data, nameof(detail.Data)); return(await apiConnection.Put <DataSetSummary>($"data/{detail.Name}", null, detail.Data, HttpMessageTransformer, cancellationToken).ConfigureAwait(false)); case DataSetStreamSource stream: Argument.IsNotNull(stream.Data, nameof(stream.Data)); return(await apiConnection.Put <DataSetSummary>($"data/{stream.Name}", null, stream.Data, HttpMessageTransformer, cancellationToken).ConfigureAwait(false)); default: throw new NotImplementedException($"No DataSet create supported for {source.GetType()}"); } }
public async Task <DataSetSummary> Create(IDataSetSource source) { Argument.IsNotNullOrEmpty(source.Name, nameof(source.Name)); switch (source) { case DataSetDetailSource detail: Argument.IsNotNull(detail.Data, nameof(detail.Data)); return(await Client.Put <DataSetSummary>($"{ApiKeys.Endpoint}data/{detail.Name}", ApiKeys.ApiToken, null, detail.Data).ConfigureAwait(false)); case DataSetStreamSource stream: Argument.IsNotNull(stream.Data, nameof(stream.Data)); return(await Client.Put <DataSetSummary>($"{ApiKeys.Endpoint}data/{stream.Name}", ApiKeys.ApiToken, null, stream.Data).ConfigureAwait(false)); default: throw new NotImplementedException($"No DataSet create supported for {source.GetType()}"); } }
public void OnInputTextChanged(ITextInput txt, string newText) { IDataSetSource dss = _owner.DataSetStore; if (dss != null) { string colName = null; string propName = txt.GetTextPropertyName(); if (txt.DataBindings != null) { foreach (Binding bd in txt.DataBindings) { if (string.CompareOrdinal(bd.PropertyName, propName) == 0) { colName = bd.BindingMemberInfo.BindingMember; break; } } } dss.SetFieldValueEx(this.DataRowIndex, colName, newText); } }
public void OnWebPageLoaded(StringCollection sc) { IDataSetSource ids = DataSource as IDataSetSource; if (this.IsRepeaterHolder && ids != null && !string.IsNullOrEmpty(ids.TableName)) { sc.Add("\r\n"); // sc.Add(string.Format(CultureInfo.InvariantCulture, "var {0} = document.getElementById('{0}');\r\n", CodeName)); sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.IsDataRepeater=true;\r\n", CodeName)); if (ShowAllRecords) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.ShowAllRecords=true;\r\n", CodeName)); } if (this.AutoColumnsAndRows) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.AutoColumnsAndRows=true;\r\n", CodeName)); } if (_displayStyle != null) { _displayStyle = _displayStyle.Trim(); } if (string.IsNullOrEmpty(_displayStyle)) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.displayStyle='';\r\n", CodeName)); } else { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.displayStyle='{1}';\r\n", CodeName, _displayStyle)); } sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.repeatColumnCount={1};\r\n", CodeName, _columnCount)); sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.jsData=JsonDataBinding.DataRepeater({0},null);\r\n", CodeName)); if (PageNavigatorPages != PNUM) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.jsData.setNavigatorPages({1});\r\n", CodeName, PageNavigatorPages)); } } }
public void CreateHtmlContent(XmlNode node, EnumWebElementPositionType positiontype, int groupId) { XmlUtil.SetAttribute(node, "tabindex", this.TabIndex); if (ReadOnly) { XmlUtil.SetAttribute(node, "readonly", true); } WebPageCompilerUtility.SetWebControlAttributes(this, node); _resourceFiles = new List <WebResourceFile>(); _htmlParts = new Dictionary <string, string>(); Dictionary <int, Dictionary <int, List <Control> > > ctrls = new Dictionary <int, Dictionary <int, List <Control> > >(); for (int r = 0; r < RowCount; r++) { Dictionary <int, List <Control> > cr = new Dictionary <int, List <Control> >(); ctrls.Add(r, cr); for (int c = 0; c < ColumnCount; c++) { List <Control> cs = new List <Control>(); cr.Add(c, cs); } } foreach (Control ct in this.Controls) { int i = this.GetRow(ct); int j = this.GetColumn(ct); if (i >= 0 && i < RowCount) { if (j >= 0 && j < ColumnCount) { Dictionary <int, List <Control> > cr; ctrls.TryGetValue(i, out cr); List <Control> cs; cr.TryGetValue(j, out cs); cs.Add(ct); } } } for (int r = 0; r < RowCount; r++) { Dictionary <int, List <Control> > cr; ctrls.TryGetValue(r, out cr); XmlNode rNode = node.OwnerDocument.CreateElement("tr"); node.AppendChild(rNode); if (_eventHandlers != null) { foreach (KeyValuePair <string, string> kv in _eventHandlers) { if (string.CompareOrdinal(kv.Key, "onRowClick") == 0) { XmlUtil.SetAttribute(rNode, "onclick", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onRowMouseDown") == 0) { XmlUtil.SetAttribute(rNode, "onmousedown", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onRowMouseUp") == 0) { XmlUtil.SetAttribute(rNode, "onmouseup", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onRowMouseMove") == 0) { XmlUtil.SetAttribute(rNode, "onmousemove", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onRowMouseOver") == 0) { XmlUtil.SetAttribute(rNode, "onmouseover", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onRowMouseOut") == 0) { XmlUtil.SetAttribute(rNode, "onmouseout", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } } } for (int c = 0; c < ColumnCount; c++) { XmlNode cNode = node.OwnerDocument.CreateElement("td"); rNode.AppendChild(cNode); if (_eventHandlers != null) { foreach (KeyValuePair <string, string> kv in _eventHandlers) { if (string.CompareOrdinal(kv.Key, "onCellClick") == 0) { XmlUtil.SetAttribute(cNode, "onclick", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onCellMouseDown") == 0) { XmlUtil.SetAttribute(cNode, "onmousedown", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onCellMouseUp") == 0) { XmlUtil.SetAttribute(cNode, "onmouseup", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onCellMouseMove") == 0) { XmlUtil.SetAttribute(cNode, "onmousemove", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onCellMouseOver") == 0) { XmlUtil.SetAttribute(cNode, "onmouseover", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } else if (string.CompareOrdinal(kv.Key, "onCellMouseOut") == 0) { XmlUtil.SetAttribute(cNode, "onmouseout", string.Format(CultureInfo.InvariantCulture, "{0}(this,null);", kv.Value)); } } } List <Control> cs; cr.TryGetValue(c, out cs); foreach (Control ct in cs) { createControlWebContents(ct, cNode, groupId); } } } // XmlUtil.SetAttribute(node, "border", _cellBorderWidth); // StringBuilder sb = new StringBuilder(); // if (this.Parent != null) { if (this.BackColor != this.Parent.BackColor) { sb.Append("background-color:"); sb.Append(ObjectCreationCodeGen.GetColorString(this.BackColor)); sb.Append("; "); } } // sb.Append("color:"); sb.Append(ObjectCreationCodeGen.GetColorString(this.ForeColor)); sb.Append("; "); // WebPageCompilerUtility.CreateWebElementZOrder(this.zOrder, sb); WebPageCompilerUtility.CreateElementPosition(this, sb, positiontype); WebPageCompilerUtility.CreateWebElementCursor(cursor, sb, false); // // if (_dataNode != null) { XmlNode pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture, "{0}[@name='Visible']", XmlTags.XML_PROPERTY)); if (pNode != null) { string s = pNode.InnerText; if (!string.IsNullOrEmpty(s)) { try { bool b = Convert.ToBoolean(s, CultureInfo.InvariantCulture); if (!b) { sb.Append("display:none; "); } } catch { } } } sb.Append(ObjectCreationCodeGen.GetFontStyleString(this.Font)); // pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture, "{0}[@name='disabled']", XmlTags.XML_PROPERTY)); if (pNode != null) { string s = pNode.InnerText; if (!string.IsNullOrEmpty(s)) { try { bool b = Convert.ToBoolean(s, CultureInfo.InvariantCulture); if (b) { XmlUtil.SetAttribute(node, "disabled", "disabled"); } } catch { } } } } XmlUtil.SetAttribute(node, "style", sb.ToString()); IDataSetSource ids = DataSource as IDataSetSource; if (ids != null && !string.IsNullOrEmpty(ids.TableName)) { XmlUtil.SetAttribute(node, "jsdb", ids.TableName); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { IDataSetSourceHolder vep = context.Instance as IDataSetSourceHolder; if (vep != null) { IDataSetSource dss = vep.GetDataSource(); if (dss != null) { bool nameOnly = false; if (context.PropertyDescriptor.Attributes != null) { foreach (Attribute a in context.PropertyDescriptor.Attributes) { if (a is FieldNameOnlyAttribute) { nameOnly = true; break; } } } NameTypePair v; if (nameOnly) { string s = value as string; if (string.IsNullOrEmpty(s)) { v = null; } else { v = new NameTypePair(s, typeof(string)); } } else { v = value as NameTypePair; } NameTypePair[] fields = dss.GetFields(); if (fields != null && fields.Length > 0) { ValueList list = new ValueList(edSvc, fields, v); edSvc.DropDownControl(list); if (list.MadeSelection) { if (nameOnly) { value = list.Selection.Name; } else { value = list.Selection; } } } } } } } return(value); }
public void OnWebPageLoaded(StringCollection sc) { ClassPointer cp = this.Owner as ClassPointer; // if (_resourceFiles == null) { _resourceFiles = new List <WebResourceFile>(); } bool b; string btimg = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "dropdownbutton.jpg"); if (File.Exists(btimg)) { _resourceFiles.Add(new WebResourceFile(btimg, WebResourceFile.WEBFOLDER_Images, out b)); } btimg = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "calendar.jpg"); if (File.Exists(btimg)) { _resourceFiles.Add(new WebResourceFile(btimg, WebResourceFile.WEBFOLDER_Images, out b)); } btimg = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "datepicker.css"); if (File.Exists(btimg)) { _resourceFiles.Add(new WebResourceFile(btimg, WebResourceFile.WEBFOLDER_Css, out b)); } string[] jsFiles = new string[14]; jsFiles[0] = "backstripes.gif"; jsFiles[1] = "bg_header.jpg"; jsFiles[2] = "bullet1.gif"; jsFiles[3] = "bullet2.gif"; jsFiles[4] = "cal.gif"; jsFiles[5] = "cal-grey.gif"; jsFiles[6] = "datepicker.js"; jsFiles[7] = "gradient-e5e5e5-ffffff.gif"; jsFiles[8] = "ok.png"; jsFiles[9] = "cancel.png"; jsFiles[10] = "qry.jpg"; jsFiles[11] = "chklist.jpg"; jsFiles[12] = "plus.gif"; jsFiles[13] = "minus.gif"; for (int i = 0; i < jsFiles.Length; i++) { btimg = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), jsFiles[i]); if (File.Exists(btimg)) { WebResourceFile w = new WebResourceFile(btimg, WebResourceFile.WEBFOLDER_Javascript, out b); _resourceFiles.Add(w); string tgt = Path.Combine(Path.Combine(cp.Project.WebPhysicalFolder(null), w.WebFolder), Path.GetFileName(btimg)); File.Copy(btimg, tgt, true); } } // sc.Add("\r\n"); sc.Add(string.Format(CultureInfo.InvariantCulture, "var {0} = document.getElementById('{0}');\r\n", CodeName)); if (this.ReadOnly) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.ReadOnly=true;\r\n", CodeName)); } if (_highlightCellColor != Color.Empty) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.HighlightCellColor='{1}';\r\n", CodeName, ObjectCreationCodeGen.GetColorString(_highlightCellColor))); } if (_alternateColor != Color.Empty) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.AlternateBackgroundColor='{1}';\r\n", CodeName, ObjectCreationCodeGen.GetColorString(_alternateColor))); } if (_highlightRowColor != Color.Empty) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.HighlightRowColor='{1}';\r\n", CodeName, ObjectCreationCodeGen.GetColorString(_highlightRowColor))); } if (_selectRowColor != Color.Empty) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.SelectedRowColor='{1}';\r\n", CodeName, ObjectCreationCodeGen.GetColorString(_selectRowColor))); } if (DatePickerFonstSize != 12) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.DatePickerFonstSize={1};\r\n", CodeName, DatePickerFonstSize)); } IDataSetSource ds = DataSource as IDataSetSource; if (ds != null) { string[] flds = ds.GetReadOnlyFields(); if (flds != null && flds.Length > 0) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.ReadOnlyFields = [\r\n", CodeName)); for (int i = 0; i < flds.Length; i++) { if (i > 0) { sc.Add(","); } sc.Add("'"); sc.Add(flds[i]); sc.Add("'"); } sc.Add("\r\n];\r\n"); } } _useDatetimePicker = false; if (_editorList != null) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.FieldEditors = {{}};\r\n", CodeName)); for (int i = 0; i < FieldCount; i++) { string cn = this.GetFieldNameByIndex(i); for (int j = 0; j < _editorList.Count; j++) { if (_editorList[j] != null && !(_editorList[j] is WebDataEditorNone)) { if (string.Compare(cn, _editorList[j].ValueField, StringComparison.OrdinalIgnoreCase) == 0) { string s = _editorList[j].CreateJavascriptEditor(sc); sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.FieldEditors[{1}] = {2};\r\n", CodeName, i, s)); if (_editorList[j] is WebDataEditorDatetime) { _useDatetimePicker = true; } break; } } } } } if (ActionControls.Count > 0) { bool first = true; StringBuilder sbAc = new StringBuilder(); for (int j = 0; j < ActionControls.Count; j++) { string nmAct = ActionControls[j]; if (!string.IsNullOrEmpty(nmAct)) { if (first) { first = false; } else { sbAc.Append(","); } sbAc.Append(string.Format(CultureInfo.InvariantCulture, "'{0}'", nmAct)); } } if (!first) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.ActControls = [{1}];\r\n", CodeName, sbAc.ToString())); if (ActionColumnWidth > 0) { sc.Add(string.Format(CultureInfo.InvariantCulture, "{0}.ActColWidth={1};\r\n", CodeName, ActionColumnWidth)); } } } }
public void CreateHtmlContent(HtmlNode node) { IDataSetSource ids = DataSource as IDataSetSource; if (IsRepeaterHolder && ids != null && !string.IsNullOrEmpty(ids.TableName)) { node.SetAttributeValue("jsdb", ids.TableName); // if (_columnCount > 0 && _rowCount > 0) { HtmlNode parent = node.ParentNode; if (parent != null) { //create a new div to hold the items string id = node.Id; HtmlNode repeaterNode = parent.OwnerDocument.CreateElement("div"); parent.InsertBefore(repeaterNode, node); parent.RemoveChild(node); node.Id = ""; repeaterNode.Id = id; repeaterNode.SetAttributeValue("id", id); repeaterNode.SetAttributeValue("jsdb", node.GetAttributeValue("jsdb", "")); node.Attributes.Remove("jsdb"); //create page navigator buttons on top if (this.PageNavigatorLocation == EnumPageNavigatorPosition.Top || this.PageNavigatorLocation == EnumPageNavigatorPosition.TopAndBottom) { createPageNavigator(repeaterNode, 0); } //create items HtmlNode tblNode = null; if (!this.AutoColumnsAndRows) { tblNode = repeaterNode.OwnerDocument.CreateElement("table"); repeaterNode.AppendChild(tblNode); tblNode.SetAttributeValue("border", "0"); tblNode.SetAttributeValue("width", "100%"); tblNode.SetAttributeValue("cellpadding", "0"); tblNode.SetAttributeValue("cellspacing", "0"); tblNode.SetAttributeValue("style", "padding:0px;border-collapse:collapse; border-spacing: 0;"); } // int index = 0; for (int r = 0; r < _rowCount; r++) { HtmlNode trNode = null; if (tblNode != null) { trNode = parent.OwnerDocument.CreateElement("tr"); tblNode.AppendChild(trNode); } for (int c = 0; c < _columnCount; c++) { HtmlNode holdNd; if (tblNode == null) { holdNd = repeaterNode; } else { holdNd = parent.OwnerDocument.CreateElement("td"); trNode.AppendChild(holdNd); } createGroup(holdNd, node, index); index++; } } //create page navigator buttons on bottom if (this.PageNavigatorLocation == EnumPageNavigatorPosition.Bottom || this.PageNavigatorLocation == EnumPageNavigatorPosition.TopAndBottom) { createPageNavigator(repeaterNode, 1); } //create template createGroup(repeaterNode, node, -1); } } } }