public virtual string GetFieldDisplayValue(Durados.Field field, DataRow row, bool forExport) { if (field.FieldType == FieldType.Children && ((ChildrenField)field).ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) { if (DataView == null) { return(string.Empty); } if (!checkListTableViewers.ContainsKey(field.Name)) { checkListTableViewers.Add(field.Name, new CheckListTableViewer((ChildrenField)field, DataView)); } Dictionary <string, string> values = checkListTableViewers[field.Name].GetValue(field.View.GetPkValue(row)); if (values == null) { return(string.Empty); } string[] valuesArray = values.Values.ToArray(); return(valuesArray.Delimited()); } else { string s = field.ConvertToString(row); if (!string.IsNullOrEmpty(s) && forExport && field.FieldType == FieldType.Column && ((ColumnField)field).Rich) { return(Durados.Web.Mvc.Infrastructure.General.StripTags(s)); } else { return(s); } } }
public virtual string GetDisplayValues(Durados.Field field, DataRow row, bool ignoreChecklistLimit = false) { if (field.FieldType == FieldType.Children && ((ChildrenField)field).ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) { if (DataView == null) { return(string.Empty); } if (!checkListTableViewers.ContainsKey(field.Name)) { checkListTableViewers.Add(field.Name, new CheckListTableViewer((ChildrenField)field, DataView)); } int limit = ignoreChecklistLimit ? 0 : ((ChildrenField)field).CheckListInTableLimit; Dictionary <string, string> values = checkListTableViewers[field.Name].GetValue(field.View.GetPkValue(row)); if (values == null) { return(string.Empty); } string[] valuesArray = values.Values.ToArray(); string title = valuesArray.Delimited(); string display = title; if (limit > 0 && values.Count > limit) { valuesArray = valuesArray.Take(limit).ToArray(); display = valuesArray.Delimited(); } return(display); } else { return(field.ConvertToString(row)); } }
public virtual string GetFieldValue(Durados.Field field, DataRow row) { if (field.FieldType == FieldType.Children && ((ChildrenField)field).ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) { if (DataView == null) { return(string.Empty); } if (!checkListTableViewers.ContainsKey(field.Name)) { checkListTableViewers.Add(field.Name, new CheckListTableViewer((ChildrenField)field, DataView)); } Dictionary <string, string> values = checkListTableViewers[field.Name].GetValue(field.View.GetPkValue(row)); if (values == null) { return(string.Empty); } string[] valuesArray = values.Keys.ToArray(); return(valuesArray.Delimited()); } else if (field.FieldType == FieldType.Column && ((ColumnField)field).Encrypted && ((ColumnField)field).SpecialColumn == SpecialColumn.Password) { return(field.View.Database.EncryptedPlaceHolder); } else if (field.FieldType == Durados.FieldType.Column && ((Durados.Web.Mvc.ColumnField)field).DataColumn.DataType != typeof(DateTime) && ((Durados.Web.Mvc.ColumnField)field).DataColumn.DataType != typeof(bool) && !row.IsNull(field.Name)) { return(row[field.Name].ToString()); } else { return(field.GetValue(row)); } }
//public static string ReplaceGlobals(this string template, View view) //{ // return ReplaceGlobals(template, view.Database); //} //public static string ReplaceGlobals(this string template, Database database) //{ // string s = template; // try // { // foreach (int key in database.Globals.Keys) // { // string name = database.Globals[key].Name; // string value = database.Globals[key].Value; // s = s.Replace((Database.SysPlaceHolder + name).AsToken(), value); // } // } // catch { } // return s; //} private static Durados.View GetChildrenView(Durados.View view, string name) { name = name.TrimStart('[').TrimEnd(']'); string[] names = name.Split('.'); if (names.Length <= 1) { return(null); } Durados.View root = view.Database.GetView(names[0]); if (root == null) { return(null); } Durados.View parentView = root; Durados.Field[] fields = null; Durados.Field field = null; for (int i = 1; i < names.Length - 1; i++) { fields = parentView.GetFieldsByDisplayName(names[i]); if (fields == null || fields.Length != 1) { return(null); } field = fields[0]; if (field.FieldType != Durados.FieldType.Parent) { return(null); } parentView = ((Durados.ParentField)field).ParentView; } fields = parentView.GetFieldsByDisplayName(names[names.Length - 1]); if (fields == null || fields.Length != 1) { return(null); } field = fields[0]; if (field.FieldType != Durados.FieldType.Children) { return(null); } return(((Durados.ChildrenField)field).ChildrenView); }
public virtual string GetElementForTableView(Durados.Field field, DataRow row, string guid, bool ignoreChecklistLimit) { if (field.FieldType == FieldType.Children && ((ChildrenField)field).ChildrenHtmlControlType == ChildrenHtmlControlType.CheckList) { if (DataView == null) { return(string.Empty); } if (!checkListTableViewers.ContainsKey(field.Name)) { checkListTableViewers.Add(field.Name, new CheckListTableViewer((ChildrenField)field, DataView)); } int limit = ignoreChecklistLimit ? 0 : ((ChildrenField)field).CheckListInTableLimit; Dictionary <string, string> values = checkListTableViewers[field.Name].GetValue(field.View.GetPkValue(row)); if (values == null) { return("<span></span>"); } string[] valuesArray = values.Values.ToArray(); string title = valuesArray.Delimited(); string display = title; if (limit > 0 && values.Count > limit) { valuesArray = valuesArray.Take(limit).ToArray(); display = valuesArray.Delimited() + "..."; } string span; if (limit > 0) { span = "<span alt='" + title + "' title='" + title + "'>" + display + "</span>"; } else { span = display; } return(span); } else { return(field.GetElementForTableView(row, guid)); } }
public static string Parse(this string formula, Durados.Field field, Durados.View view, Dictionary <string, Durados.Field> calcDynasty) { if (view == null) { view = field.View; } string formulaDetail = string.Empty; if (view == null || view.Fields == null) { throw new Durados.DuradosException("Could not parse calculted field, missing view or fields."); } if (field.IsCalculated && !string.IsNullOrEmpty(field.Formula)) { if (calcDynasty == null) { calcDynasty = new Dictionary <string, Durados.Field>(); } else { if (calcDynasty.ContainsKey(field.DatabaseNames)) { string strace = String.Join(",", calcDynasty.Keys.Select(o => o.ToString()).ToArray()); //calcDynasty.Keys.; throw new Durados.DuradosException("Calculted field cannot containe recursive call, check " + strace); //calcDynasty.Keys. } } calcDynasty.Add(field.DatabaseNames, field); formulaDetail = string.Format("({0})", field.Formula); foreach (Durados.Field f in view.Fields.Values.Where(r => (r.IsCalculated == true && r.DatabaseNames != field.DatabaseNames)).OrderBy(r => r.DatabaseNames.Length)) { string pattern = @"\b" + f.DatabaseNames + @"\b"; if ((Regex.Match(formulaDetail, pattern)).Success) { formulaDetail = formulaDetail.Replace(string.Format("[{0}]", f.DatabaseNames), f.DatabaseNames); Dictionary <string, Durados.Field> subTree = new Dictionary <string, Durados.Field>(calcDynasty); formulaDetail = string.Format("({0})", Regex.Replace(formulaDetail, pattern, f.Formula.Parse(f, view, subTree))); } } } return(formulaDetail); }
public void LoadValue(Dictionary <string, object> values, DataRow dataRow, Durados.View view, Durados.Field field, string dynastyPath, string prefix, string postfix, Dictionary <string, Durados.Workflow.DictionaryField> dicFields, string internalDynastyPath) { string name = prefix + dynastyPath + field.DisplayName + postfix; string InternalName = prefix + internalDynastyPath + field.Name + postfix; string value = view.GetDisplayValue(field.Name, dataRow); if (!values.ContainsKey(name)) { values.Add(name, value); dicFields.Add(InternalName, new Durados.Workflow.DictionaryField { DisplayName = name, Type = field.DataType, Value = value }); } if (field.FieldType == FieldType.Column && ((ColumnField)field).Upload != null) { if (dataRow.Table.Columns.Contains(field.Name)) { dataRow.Table.Columns[field.Name].ExtendedProperties["ImagePath"] = ((ColumnField)field).GetUploadPath(); } } }
public virtual bool IsSortable(Durados.Field field, string guid) { return(field.Sortable); }
public virtual string GetDisplayName(Durados.Field field, DataRow row, string guid) { return(field.GetLocalizedDisplayName()); }
public virtual string GetElementForTableView(Durados.Field field, DataRow row, string guid) { return(GetElementForTableView(field, row, guid, false)); }
public static string Parse(this string formula, Durados.Field field, Durados.View view) { return(Parse(formula, field, view, null)); }