// Protected Methods (13) protected virtual void AddInlineSearch(ChildrenField field, string prefix, StringBuilder element, string type, string id, string guid) { //string inlineSearch = string.Empty; Durados.ParentField parentField = null; Durados.ParentField fkField = null; View searchView = (View)field.GetOtherParentView(out parentField, out fkField); if (field.InlineSearch && prefix != filterPrefix && searchView.IsAllow()) { element.Insert(0, "<table border=0 cellspacing=0 cellpadding=0><tr><td>"); //inlineSearch += element; element.Append("</td><td>"); string title = "Search for " + searchView.DisplayName; string className = "Search-icon"; guid = searchView.Name + "_" + Durados.Web.Mvc.Infrastructure.ShortGuid.Next() + "_"; string onClick = "SearchDialog.CreateAndOpen('" + searchView.Name + "','" + searchView.DisplayName + "','" + type + "','" + id + "','" + searchView.GetIndexUrl() + "?firstTime=true&disabled=true" + "', '" + guid + "')"; element.Append(GetInlineAddingImg(guid, title, className, onClick)); element.Append("</td></tr></table>"); } //return inlineSearch; }
protected virtual string GetCheckList(ChildrenField field, string prefix, bool disabled, string pk, string guid, bool forFilter) { StringBuilder selectList = new StringBuilder(); string insideTriggerAttributes = string.Empty; if (!string.IsNullOrEmpty(field.InsideTriggerFieldName)) { insideTriggerAttributes = " hasInsideTrigger='hasInsideTrigger' triggerName='" + field.InsideTriggerFieldName + "' "; } string id = guid + prefix + field.Name.ReplaceNonAlphaNumeric(); selectList.Append("<select " + GetDisabledHtmlAttribute(disabled) + " id='" + id + "' name='" + field.Name + "' viewName='" + field.View.Name + "' pk='" + pk + "' style='display:none' multiple='multiple' d_loaded='d_loaded' role='childrenCheckList'" + insideTriggerAttributes + " class='dropdownchecklist' d_minWidth='" + field.MinWidth.ToString() + "'>"); selectList.Append("<option value=''>(All)</option>"); if (string.IsNullOrEmpty(field.InsideTriggerFieldName)) { IEnumerable <SelectListItem> selectListItems = field.GetSelectList(pk, forFilter); foreach (SelectListItem item in selectListItems) { selectList.Append("<option value='" + item.Value + "' " + (item.Selected ? "selected='selected'>" : ">").ToString() + item.Text + "</option>"); } } selectList.Append("</select>"); if (field.InlineSearch) { AddInlineSearch(field, prefix, selectList, "CheckList", id, guid); } return(selectList.ToString()); }
protected virtual string GetDiv(ChildrenField field, string prefix, string guid, string url, bool disabled) { string div = string.Empty; //string src = General.GetRootPath() + "Content/Images/Plus.jpg"; string title = ""; //string title = "Expand"; if (disabled) { //src = General.GetRootPath() + "Content/Images/PlusDisabled.jpg"; title = string.Format(field.SubgridInstructions, field.DisplayName); } string id = guid + prefix + field.Name.ReplaceNonAlphaNumeric(); string updateParent = " updateParent='" + field.UpdateParent.ToString() + "' "; string itemsFilter = string.Empty; if (!string.IsNullOrEmpty(field.DependencyFieldName)) { itemsFilter = "itemsFilter='" + field.DependencyFieldName + "' "; } //string expand = "<input id='" + id + "' style='display:none' state='collapsedEmpty' type='image' class='inlineAddingImg expand' title='expand' alt='expand' src='" + src + "' onclick=\"expand(this, false,null,false,'" + guid + "');\" " + GetDisabledHtmlAttribute(disabled) + " title='" + title + "' alt='" + title + "'" + updateParent + "/>"; string expand = "<span id='" + id + "' state='collapsedEmpty' class='inlineAddingImg expand' " + GetDisabledHtmlAttribute(disabled) + updateParent + ">" + title + "</span>"; //string label = ((Durados.Web.Mvc.View)field.View).DataRowView == DataRowView.Divs ? string.Empty : field.DisplayName; div = "<div><div>" + expand + "</div><div url='" + url + "' class='childrenViewer' " + itemsFilter + " pk=''></div></div>"; return(div); }
protected virtual void LoadChildren(ChildrenField childrenField, DataRow row, DataRow xmlRow, DataRelation xmlRelation, DataView dataView) { foreach (DataRowView childRow in dataView) { LoadElement(xmlRow.Table.DataSet, childrenField.ChildrenView, childRow.Row, xmlRelation, xmlRow); } }
public string Export(DataView dataView, View view, string[] roles, ITableViewer tableViewer, string guid) { //Load SubGrids Data once Dictionary <string, DataView> SubGrids = new Dictionary <string, DataView>(); Dictionary <string, Field> excluded = new Dictionary <string, Field>(); foreach (Field field in view.Fields.Values.OrderBy(f => f.Order)) { if (field.FieldType == FieldType.Children && field.GetFieldControlType() != "CheckList" && !field.IsHiddenInTable() && !IsDenied(field.DenySelectRoles, roles) && tableViewer.IsVisible(field, excluded, guid)) { ChildrenField c_field = (ChildrenField)field; if (c_field.SubGridExport) { View c_view = (View)c_field.ChildrenView; SubGrids.Add(c_view.Name, GetSubGridData(c_view)); } } } //Headers string header = GetColumnsHeaders(view, roles, tableViewer, guid, true, SubGrids, false) + charNewLine; //Columns Data - CSV return(header + GetColumnsData(dataView, view, roles, tableViewer, guid, SubGrids) + charNewLine); }
protected virtual string GetDivForTable(ChildrenField field, string prefix, string guid, string url, bool disabled, DataRow dataRow) { string div = string.Empty; string src = General.GetRootPath() + "Content/Images/Plus.gif"; string title = "Expand"; //if (disabled) //{ // src = General.GetRootPath() + "Content/Images/PlusDisabled.gif"; // title = "Please save first"; //} disabled = !field.IsDerivationEditable(dataRow); string disabledStr = disabled ? "true" : "false"; string updateParent = " updateParent='" + field.UpdateParent.ToString() + "' "; string itemsFilter = string.Empty; if (!string.IsNullOrEmpty(field.DependencyFieldName)) { itemsFilter = "itemsFilter='" + field.DependencyFieldName + "' "; } string nocache = (field.NoCache) ? " nocache='nocache' " : string.Empty; string expand = "<img state='collapsedEmpty' class='inlineAddingImg expand' title='expand' alt='expand' src='" + src + "' onclick=\"expand(this, false, " + field.SubGridPlacement + "," + disabledStr + ",'" + guid + "');\" " + GetDisabledHtmlAttribute(false) + " title='" + title + "' alt='" + title + "' " + updateParent + nocache + " selectedClass='tablecommand' /> "; //string label = field.ConvertToString(dataRow); string label = "<a href='" + url + "'>" + field.ConvertToString(dataRow) + "</a>"; div = "<div><div>" + expand + label + "</div><div url='" + url + "' class='childrenViewer' " + itemsFilter + " pk=''></div></div>"; return(div); }
private Durados.Web.Mvc.UI.Json.Field GetChildrenJsonField(ChildrenField childrenField, string value) { Json.Field jsonField = new Json.Field() { Name = childrenField.Name, Value = value, Type = childrenField.GetHtmlControlType().ToString(), DependencyData = childrenField.DependencyData }; return(jsonField); }
protected virtual string GetCheckListUrl(ChildrenField field, string guid, string url, string prefix) { string query = "?"; query += "guid=" + guid + "&fieldName=" + field.Name + "&pk=$$&prefix=" + prefix; return(url + query); }
public static string GetSelectedChildrenPKDelimited(this ChildrenField childrenField, string fk) { string[] pks = GetSelectedChildrenPK(childrenField, fk); string delimited = string.Empty; foreach (string pk in pks) { delimited += pk + ","; } delimited = delimited.TrimEnd(','); return(delimited); }
private string GetColumnsHeaders(View view, string[] roles, ITableViewer tableViewer, string guid, bool withSubgrids, Dictionary <string, DataView> SubGrids, bool isSubGrid) { string header = string.Empty; string columnHeader = string.Empty; Dictionary <string, Field> excluded = new Dictionary <string, Field>(); foreach (Field field in view.Fields.Values.OrderBy(f => f.Order)) { if (!field.IsHiddenInTable() && !IsDenied(field.DenySelectRoles, roles) && tableViewer.IsVisible(field, excluded, guid)) { if (field.FieldType == FieldType.Children && field.GetFieldControlType() != "CheckList") { ChildrenField c_field = (ChildrenField)field; if (withSubgrids && (c_field.SubGridExport)) { View c_view = (View)c_field.ChildrenView; DataView c_grid = SubGrids[c_view.Name]; tableViewer.DataView = c_grid; header += GetColumnsHeaders(c_view, roles, tableViewer, "", false, null, true); } } else { columnHeader = tableViewer.GetDisplayName(field, null, guid); if (field.Equals(view.Fields.First()) && columnHeader.ToLower() == "id") { columnHeader = " " + columnHeader; } if (isSubGrid) { header += view.DisplayName + " "; } header += ValidCsvContent(columnHeader, false) + charDelimeter; } } } return(header); }
protected virtual string GetNavigationUrl(ChildrenField field, DataRow dataRow, string url, string guid, bool isMainPage) { string query = "?"; for (int i = 0; i < field.DataRelation.ChildColumns.Count(); i++) { DataColumn childColumn = field.DataRelation.ChildColumns[i]; DataColumn parentColumn = field.DataRelation.ParentColumns[i]; string key = (dataRow == null) ? "$$" : dataRow[parentColumn.ColumnName].ToString(); query += childColumn.ColumnName + "=" + System.Web.HttpContext.Current.Server.UrlEncode(key) + "&"; } string display = (dataRow == null) ? "xx" : field.View.DisplayField.ConvertToString(dataRow); query += "__" + field.Name + "__=" + System.Web.HttpContext.Current.Server.UrlEncode(display); return(url + query + (((View)field.ChildrenView).Check(TriggerDataAction.Open, dataRow) ? "&disabled=True" : "") + (isMainPage ? "&isMainPage=True" : "") + "&BackTo=" + System.Web.HttpContext.Current.Server.UrlEncode(field.View.Name)); }
public virtual string GetElementForTableView(ChildrenField field, DataRow dataRow, string guid) { View childrenView = ((View)field.ChildrenView); if (!childrenView.IsAllow()) { if (dataRow == null) { return(string.Empty); } else { return(field.ConvertToString(dataRow)); } } else { if (field.FieldType == FieldType.Children && ((ChildrenField)field).ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) { return(string.Empty); } else { if (dataRow == null) { return(GetNavigationUrl(field, null, guid)); } //if (field.ChildrenHtmlControlType == ChildrenHtmlControlType.Grid) // return GetNavigationUrl(field, null); //else if (field.ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) // return GetNavigationUrl(field, null, GetUrlWithoutQuery(field, childrenView.CheckListAction)); //else // return string.Empty; else { return(GetDivForTable(field, string.Empty, guid, GetNavigationUrl(field, dataRow, guid, true), false, dataRow)); } //return "<a href='" + GetNavigationUrl(field, dataRow) + "'>" + field.ConvertToString(dataRow) + "</a>"; } } }
public virtual string GetElementForEdit(ChildrenField field, string pk, string value, string guid) { View childrenView = ((View)field.ChildrenView); View view = ((View)field.View); if (field.ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) { //return GetDiv(field, editPrefix, guid, GetCheckListUrl(field, guid, GetUrlWithoutQuery(view, view.CheckListAction), editPrefix), false); return(GetCheckList(field, editPrefix, false, pk, guid, false)); } else if (field.ChildrenHtmlControlType == ChildrenHtmlControlType.Grid) { return(GetDiv(field, editPrefix, guid, GetNavigationUrl(field, null, guid), false)); } else { return(string.Empty); } }
// <summary> /// Try get parent field of a field /// </summary> /// <param name="viewName"></param> /// <param name="fieldName"></param> /// <returns></returns> public static ParentField GetParentField(this Field field) { ParentField parentField = null; if (field.FieldType == FieldType.Children) { ChildrenField childrenField = field as ChildrenField; if (childrenField != null) { parentField = childrenField.GetFirstNonEquivalentParentField() as ParentField; } } else { parentField = field as ParentField; } return(parentField); }
protected virtual ChildrenField GetApprovalProcessUsersChildrenField(IApprovalProcess controller, View view) { ChildrenField usersChildrenField = controller.GetApprovalProcessUsersChildrenField(view); if (usersChildrenField != null) { return(usersChildrenField); } string approvalProcessUserViewName = GetApprovalProcessUserViewName(controller); usersChildrenField = (ChildrenField)view.Fields.Values.Where(f => f.FieldType == FieldType.Children && ((ChildrenField)f).ChildrenView.Name == approvalProcessUserViewName).FirstOrDefault(); if (usersChildrenField == null) { throw new WorkflowEngineException("Could not found the Approval Process Users field on view " + view.Name + " that connect to the Approval Process Users View by the name " + approvalProcessUserViewName + "."); } return(usersChildrenField); }
private void Notify(int id, View view, string document) { ChildrenField childrenField = (ChildrenField)view.Fields["FK_ApprovalProcessUser_ApprovalProcess_Children"]; DataView approvalProcessUserDataView = childrenField.GetDataView(id.ToString()); foreach (System.Data.DataRowView row in approvalProcessUserDataView) { int userId = (int)row.Row["UserId"]; int approvalProcessUserId = (int)row.Row["Id"]; string subject = GetSubject((View)childrenField.ChildrenView, approvalProcessUserId); string message = GetMessage((View)childrenField.ChildrenView, approvalProcessUserId); string to = string.Empty; string name = string.Empty; GetEmailInfo(userId.ToString(), out to, out name); SendEmail(GetDefaultFrom(), to, string.Empty, message, subject, new string[1] { document }); } }
public static DataView GetDataView(this ChildrenField childrenField, string key) { ParentField parentField = childrenField.GetEquivalentParentField(); View view = parentField.View; Dictionary <string, object> values = new Dictionary <string, object>(); values.Add(parentField.Name, key); int rowCount = 0; Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>(); if (!string.IsNullOrEmpty(view.OrdinalColumnName) && view.DataTable.Columns.Contains(view.OrdinalColumnName)) { sortColumns.Add(view.OrdinalColumnName, SortDirection.Asc); } DataView dataView = view.FillPage(1, 1000, values, false, sortColumns, out rowCount, null, null); return(dataView); }
private void AddToSelectable(Component parentSelectableComponent) { _selectable.transform.SetParent(parentSelectableComponent.transform, true); object thisSelectable = _selectable.GetComponent(SelectableType); object parentSelectable = parentSelectableComponent.GetComponent(SelectableType); ParentField.SetValue(thisSelectable, parentSelectable); Array parentChildren = (Array)ChildrenField.GetValue(parentSelectable); Array newParentChildren = Array.CreateInstance(SelectableType, parentChildren.Length + 1); Array.Copy(parentChildren, newParentChildren, holdableChildIndex); newParentChildren.SetValue(thisSelectable, holdableChildIndex); Array.Copy(parentChildren, holdableChildIndex, newParentChildren, holdableChildIndex + 1, parentChildren.Length - holdableChildIndex); ChildrenField.SetValue(parentSelectable, newParentChildren); ChildRowLengthField.SetValue(parentSelectable, ((int)ChildRowLengthField.GetValue(parentSelectable)) + 1); InitMethod.Invoke(parentSelectable, null); InputHelper.InvokeConfigureSelectableAreas(parentSelectableComponent); }
protected override DataView GetDataView(ChildrenField childrenField, DataRow dataRow) { DataView dataView = base.GetDataView(childrenField, dataRow); DataTable dataTable = new DataTable(); string[] fieldsNames = new string[6] { ProposalItem.FK_ProposalItem_ProposalItemType_Parent.ToString(), ProposalItem.Description.ToString(), ProposalItem.Color.ToString(), ProposalItem.Qty.ToString(), ProposalItem.Rate.ToString(), ProposalItem.Total.ToString() }; foreach (string name in fieldsNames) { dataTable.Columns.Add(name); } foreach (DataRow row in dataView.Table.Rows) { List <object> values = new List <object>(); foreach (string name in fieldsNames) { string value = childrenField.ChildrenView.Fields[name].ConvertToString(row); values.Add(value); } dataTable.Rows.Add(values.ToArray()); } return(new DataView(dataTable)); }
protected virtual Dictionary <int, string> Notify(IApprovalProcess controller, string messageKey, string subjectKey, int id, Dictionary <string, Parameter> parameters, View view, Dictionary <string, object> values, DataRow prevRow, string pk) { ChildrenField childrenField = GetApprovalProcessUsersChildrenField(controller, view); DataView approvalProcessUserDataView = GetApprovalProcessUserDataView(id, childrenField, controller); if (approvalProcessUserDataView == null) { throw new WorkflowEngineException("Could not load the Approval Process Users view ."); } Dictionary <int, string> messages = new Dictionary <int, string>(); string siteWithoutQueryString = ((INotifier)controller).GetSiteWithoutQueryString(); int currentUserId = controller.GetCurrentUserId(); foreach (System.Data.DataRowView row in approvalProcessUserDataView) { int userId = (int)row.Row["UserId"]; int approvalProcessUserId = (int)row.Row["Id"]; string subject = controller.GetSubject((View)childrenField.ChildrenView, subjectKey, approvalProcessUserId); string message = controller.GetMessage((View)childrenField.ChildrenView, messageKey, approvalProcessUserId); string urlAction = ((INotifier)controller).GetUrlAction(childrenField.ChildrenView, approvalProcessUserId.ToString()); string to = string.Empty; string name = string.Empty; controller.GetEmailInfo(userId.ToString(), out to, out name); messages.Add(approvalProcessUserId, message); SendEmail(controller, to, string.Empty, message, subject); string messageBoardId = ((INotifier)controller).SaveInMessageBoard(parameters, childrenField.ChildrenView, values, prevRow, approvalProcessUserId.ToString(), siteWithoutQueryString, urlAction, subject, message, currentUserId, null, new Dictionary <int, bool>()); ((INotifier)controller).SaveMessageAction(view, messageBoardId, "True", 5, userId); // Required Action } return(messages); }
public static IEnumerable <SelectListItem> GetSelectList(this ChildrenField childrenField, bool forFilter) { return(GetSelectList(childrenField, null, forFilter)); }
public NoLongerChecklistException(ChildrenField childrenField) : base("The field " + childrenField.JsonName + " is no longer checklist. Please try again or call the administrator.") { ChildrenField = childrenField; }
protected virtual string GetCheckListForFilter(ChildrenField field, string prefix, bool disabled, string selectedValue, string guid) { string style = GetFilterStyle(field); StringBuilder selectList = new StringBuilder(); string id = guid + prefix + field.Name.ReplaceNonAlphaNumeric(); bool load = !string.IsNullOrEmpty(selectedValue) || !string.IsNullOrEmpty(field.DefaultFilter); //Changed by br bool isGroupFilter = field.View != null && field.View.FilterType == FilterType.Group ? true : false; selectList.Append("<select " + style + " " + GetDisabledHtmlAttribute(disabled) + " id='" + id + "' name='" + field.Name + "' isGroupFilter='" + isGroupFilter + "' viewName='" + field.View.Name + "' role='childrenCheckListFilter' style='display:none' multiple='multiple' filter='filter' class='dropdownchecklist' onkeypress='handleEnterFilter(this, event, \"" + guid + "\")' >"); selectList.Append("<option value=''>(All)</option>"); if (load) { string[] selectedValues = field.GetFirstNonEquivalentParentField().SplitValues(selectedValue); bool empty = selectedValues.Contains(Database.EmptyString); if (prefix == filterPrefix) { selectList.Append("<option value='" + Database.EmptyString + "' " + (empty ? "selected='selected'" : "").ToString() + ">" + field.View.Database.EmptyDisplay + "</option>"); } IEnumerable <SelectListItem> selectListItems = field.GetSelectList(true); foreach (SelectListItem item in selectListItems) { bool selected = selectedValues.Contains(item.Value); selectList.Append("<option value='" + item.Value + "' " + (selected ? "selected='selected'>" : ">").ToString() + item.Text + "</option>"); } } selectList.Append("</select>"); if (!load) { //Changed by br string widthStyle = GetFilterWidthStyle(field); string displayStyle = "display: " + (isGroupFilter ? "inline-block" : "block") + ";"; string onclicked = ""; string onhovered = ""; if (!disabled && string.IsNullOrEmpty(field.InsideTriggerFieldName)) { onclicked = " onclick='LoadCheckListFilter($(\"#" + id + "\"), \"" + guid + "\")'"; onhovered = " onmouseover='$(this).addClass(\"ui-state-hover\")' onmouseout='$(this).removeClass(\"ui-state-hover\")'"; } string icon = ""; if (Map.Database.Localizer.Direction != "RTL") { icon = "<div style='float: left;' class='ui-icon ui-icon-triangle-1-e'></div>"; } else { icon = "<div style='float: right;' class='ui-icon ui-icon-triangle-1-w'></div>"; } selectList.Append("<span d_ph='ph' class='ui-dropdownchecklist ui-dropdownchecklist-selector-wrapper ui-widget' style='cursor: default; overflow: hidden; " + displayStyle + widthStyle + "'><span tabindex='0'" + onclicked + " class='ui-dropdownchecklist-selector ui-state-default' style='overflow: hidden; white-space: nowrap; " + displayStyle + widthStyle + "'" + onhovered + ">" + icon + "<span style='display: inline-block; white-space: nowrap; overflow: hidden' class='ui-dropdownchecklist-text'></span></span></span>"); } return(selectList.ToString()); }
public static IEnumerable <SelectListItem> GetSelectList(this ChildrenField childrenField, string fk, string pk) { List <SelectListItem> selectList = new List <SelectListItem>(); View childrenView = (Durados.Web.Mvc.View)childrenField.ChildrenView; View view = (Durados.Web.Mvc.View)childrenField.View; ParentField fkField = null; ParentField parentField = null; View parentView = null; foreach (ParentField field in childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent)) { if (!field.ParentView.Base.Equals(view.Base)) { parentField = field; parentView = (Durados.Web.Mvc.View)field.ParentView; } else { fkField = field; } } if (parentField == null) { return(selectList); } Dictionary <string, object> filterParent = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(fk) && !string.IsNullOrEmpty(childrenField.DependencyFieldName)) { filterParent.Add(childrenField.DependencyFieldName, fk); } int rowCount = 0; DataView parentDataView = parentView.FillPage(1, 1000000, filterParent, false, null, out rowCount, null, null); if (childrenField.View.Database.DiagnosticsReportInProgress) { if (parentDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit) { Map.Logger.Log(parentView.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -parentDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime); } } //Selected values = rows in many-to-many view Dictionary <object, object> keys = new Dictionary <object, object>(); Dictionary <string, object> filter = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(pk) && fkField != null) { filter.Add(fkField.Name, pk); DataView childrenDataView = childrenView.FillPage(1, 1000000, filter, false, null, out rowCount, null, null); if (childrenField.View.Database.DiagnosticsReportInProgress) { if (parentDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit) { Map.Logger.Log(childrenView.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -parentDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime); } } foreach (System.Data.DataRowView row in childrenDataView) { string key = parentField.GetValue(row.Row); if (!keys.ContainsKey(key)) { keys.Add(key, key); } } } //Create Options foreach (System.Data.DataRowView row in parentDataView) { string text = parentView.GetDisplayValue(row.Row); string value = parentView.GetPkValue(row.Row); bool selected = keys.ContainsKey(value); SelectListItem item = new SelectListItem(); item.Text = text; item.Value = value; item.Selected = selected; selectList.Add(item); } return(selectList); }
protected virtual string GetNavigationUrl(ChildrenField field, DataRow dataRow, string guid, bool isMainPage) { string url = GetUrlWithoutQuery(field); return(GetNavigationUrl(field, dataRow, url, guid, isMainPage)); }
// Public Methods (10) public static string GetListPKDelimitedByValuesForImport(this ChildrenField childrenField, List <string> displayValues, Importer importer) { View childrenView = (Durados.Web.Mvc.View)childrenField.ChildrenView; View view = (Durados.Web.Mvc.View)childrenField.View; View parentView = null; //ParentField parentField = null; string pks = ""; string temp; string msg; GetPKValueByDisplayValueStatus status; ParentField parentField = null; foreach (ParentField field in childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent)) { if (!field.ParentView.Base.Equals(view.Base)) { parentField = field; parentView = (Durados.Web.Mvc.View)field.ParentView; break; } } string displayName = childrenField.DisplayName; foreach (string displayValue in displayValues) { temp = parentView.GetPKValueByDisplayValue(displayValue.Trim(), out status); if (childrenField.Import && status == GetPKValueByDisplayValueStatus.NotFound) { temp = importer.CreateParentRecord(parentField, displayValue); if (temp != string.Empty) { status = GetPKValueByDisplayValueStatus.FoundUnique; } } if (status == GetPKValueByDisplayValueStatus.FoundUnique) { pks += temp + ","; } else { if (status == GetPKValueByDisplayValueStatus.FoundMoreThanOne) { msg = "(SelectList) The display value [" + displayValue + "] is not a unique identifier of the parent record [" + displayName + "]"; } else { msg = "(SelectList) Primary key for parent record [" + displayName + "] was not found by value [" + displayValue + "]"; } throw new DuradosException(msg); } } return(pks.Trim(',')); }
//public static View GetOtherParentView(this ChildrenField childrenField, ParentField parentField, ParentField fkField) //{ // View childrenView = (Durados.Web.Mvc.View)childrenField.ChildrenView; // View view = (Durados.Web.Mvc.View)childrenField.View; // View parentView = null; // foreach (ParentField field in childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent)) // { // if (!field.ParentView.Base.Equals(view.Base)) // { // parentField = field; // parentView = (Durados.Web.Mvc.View)field.ParentView; // } // else // { // fkField = field; // } // } // return parentView; //} public static IEnumerable <SelectListItem> GetSelectList(this ChildrenField childrenField, string fk, bool forFilter) { View childrenView = (Durados.Web.Mvc.View)childrenField.ChildrenView; View view = (Durados.Web.Mvc.View)childrenField.View; //ParentField parentField = null; //ParentField fkField = null; //View parentView = null; //foreach (ParentField field in childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent)) //{ // if (!field.ParentView.Base.Equals(view.Base)) // { // parentField = field; // parentView = (Durados.Web.Mvc.View)field.ParentView; // } // else // { // fkField = field; // } //} Durados.ParentField parentField = null; Durados.ParentField fkField = null; View parentView = (View)childrenField.GetOtherParentView(out parentField, out fkField); Dictionary <string, string> selectOptions = parentField.GetSelectOptions(fk, null, forFilter); //int rowCount = 0; //DataView parentDataView = parentView.FillPage(1, 1000000, null, false, null, out rowCount, null, null); //if (childrenField.View.Database.DiagnosticsReportInProgress) //{ // if (parentDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit) // { // Map.Logger.Log(parentView.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -parentDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime); // } //} //Dictionary<object, object> keys = new Dictionary<object, object>(); //if (!string.IsNullOrEmpty(fk)) //{ // Dictionary<string, object> filter = new Dictionary<string, object>(); // filter.Add(fkField.Name, fk); // DataView childrenDataView = childrenView.FillPage(1, 1000000, filter, false, null, out rowCount, null, null); // if (childrenField.View.Database.DiagnosticsReportInProgress) // { // if (parentDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit) // { // Map.Logger.Log(childrenField.View.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -parentDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime); // } // } // foreach (System.Data.DataRowView row in childrenDataView) // { // string key = parentField.GetValue(row.Row); // keys.Add(key, key); // } //} List <SelectListItem> selectList = new List <SelectListItem>(); //foreach (System.Data.DataRowView row in parentDataView) //{ // string text = parentView.GetDisplayValue(row.Row); // string value = parentView.GetPkValue(row.Row); // bool selected = keys.ContainsKey(value); // SelectListItem item = new SelectListItem(); // item.Text = text; // item.Value = value; // item.Selected = selected; // selectList.Add(item); //} foreach (string key in selectOptions.Keys) { SelectListItem item = new SelectListItem(); item.Text = selectOptions[key]; item.Value = key; item.Selected = false; selectList.Add(item); } return(selectList); }
protected virtual string GetUrlWithoutQuery(ChildrenField field, string action) { return(GetUrlWithoutQuery((View)field.ChildrenView, action)); }
public static string[] GetSelectedChildrenPK(this ChildrenField childrenField, string fk) { childrenField = (ChildrenField)childrenField.Base; View childrenView = (Durados.Web.Mvc.View)childrenField.ChildrenView; View view = (Durados.Web.Mvc.View)childrenField.View; View parentView = null; ParentField parentField = null; ParentField fkField = null; var parentFields = childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent); foreach (ParentField field in childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent)) { if (!field.ParentView.Equals(view)) { parentField = field; parentView = (Durados.Web.Mvc.View)field.ParentView; } else { fkField = field; } } if (parentView == null) { if (parentFields.Count() == 2) { if (((ParentField)parentFields.FirstOrDefault()).ParentView.Equals(((ParentField)parentFields.LastOrDefault()).ParentView)) { ParentField p1 = (ParentField)parentFields.FirstOrDefault(); ParentField p2 = (ParentField)parentFields.LastOrDefault(); if (!p1.DataRelation.ChildColumns[0].Equals(childrenField.DataRelation.ChildColumns[0])) { parentField = p1; fkField = p2; } else { parentField = p2; fkField = p1; } parentView = (View)parentField.ParentView; } } } //int rowCount = 0; //List<string> keys = new List<string>(); //if (!string.IsNullOrEmpty(fk)) //{ // Dictionary<string, object> filter = new Dictionary<string, object>(); // filter.Add(fkField.Name, fk); // DataView childrenDataView = childrenView.FillPage(1, 1000000, filter, false, null, out rowCount, null, null); // if (childrenField.View.Database.DiagnosticsReportInProgress) // { // if (childrenDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit) // { // Map.Logger.Log(childrenView.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -childrenDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime); // } // } // foreach (System.Data.DataRowView row in childrenDataView) // { // string key = parentField.GetValue(row.Row); // keys.Add(key); // } //} //return keys.ToArray(); if (parentField == null) { throw new NoLongerChecklistException(childrenField); } return(childrenView.GetKeys(parentField, fkField.Name, fk)); }
protected virtual string GetUrlWithoutQuery(ChildrenField field) { View childrenView = ((View)field.ChildrenView); return(GetUrlWithoutQuery(field, childrenView.IndexAction)); }