Exemple #1
0
        // 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;
        }
Exemple #2
0
        //protected override Category GetCategory()
        //{
        //    if (ChildrenHtmlControlType == ChildrenHtmlControlType.Grid && category == null)
        //    {
        //        return new Category() { Name = DisplayName, Ordinal = 100 };
        //    }
        //    else
        //    {
        //        return base.GetCategory();
        //    }
        //}

        public override Dictionary <string, string> GetAutocompleteValues(string q, int limit)
        {
            Durados.ParentField parentField     = null;
            Durados.ParentField fkField         = null;
            Durados.View        otherParentView = GetOtherParentView(out parentField, out fkField);

            return(((ParentField)parentField).GetSelectOptions(q, AutocompleteMathing == AutocompleteMathing.StartsWith, limit, null));
        }
Exemple #3
0
        public virtual string GetParentFiterFieldName(Database database)
        {
            Durados.ParentField parentField = null;
            foreach (Field field in Fields.Values)
            {
                foreach (Durados.View view in database.Views.Values)
                {
                    if (view.Fields.ContainsKey(field.Name))
                    {
                        Durados.Field f = view.Fields[field.Name];
                        switch (f.FieldType)
                        {
                        case FieldType.Parent:
                            break;

                        case FieldType.Children:
                            parentField = ((ChildrenField)f).GetRelatedParentField();
                            break;

                        case FieldType.Column:
                            return(field.Name);

                        default:
                            throw new NotSupportedException();
                        }
                        break;
                    }
                }
            }

            if (parentField == null)
            {
                return(string.Empty);
            }

            return(parentField.Name);
        }
Exemple #4
0
        //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);
        }
Exemple #5
0
        public void LoadValues(Dictionary <string, object> values, System.Data.DataRow dataRow, Durados.View view, Durados.ParentField parentField, Durados.View rootView, string dynastyPath, string prefix, string postfix, Dictionary <string, Durados.Workflow.DictionaryField> dicFields, string internalDynastyPath)
        {
            if (view.Equals(rootView))
            {
                dynastyPath         = GetViewDisplayName((View)view) + ".";
                internalDynastyPath = view.Name + ".";
            }
            foreach (Durados.Field field in view.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Column))
            {
                LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);
            }

            var childrenFields = view.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Children && ((ChildrenField)f).LoadForBlockTemplate);

            foreach (ChildrenField field in childrenFields)
            {
                string name                = prefix + dynastyPath + field.DisplayName + postfix;
                string internalName        = prefix + internalDynastyPath + field.Name + postfix;
                System.Data.DataView value = GetDataView(field, dataRow);
                if (!values.ContainsKey(name))
                {
                    values.Add(name, value);
                    dicFields.Add(internalDynastyPath, new Durados.Workflow.DictionaryField {
                        DisplayName = field.DisplayName, Type = field.DataType, Value = value
                    });
                }

                foreach (ColumnField columnField in field.ChildrenView.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Column))
                {
                    if (columnField.Upload != null)
                    {
                        value.Table.Columns[columnField.Name].ExtendedProperties["ImagePath"] = columnField.GetUploadPath();
                    }
                }
            }

            foreach (ParentField field in view.Fields.Values.Where(f => f.FieldType == Durados.FieldType.Parent))
            {
                if (view.Equals(rootView))
                {
                    dynastyPath         = view.DisplayName + ".";
                    internalDynastyPath = view.Name + ".";
                }
                LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);

                System.Data.DataRow parentRow = null;
                View parentView = null;
                if (dataRow != null)
                {
                    parentRow  = dataRow.GetParentRow(field.DataRelation.RelationName);
                    parentView = (View)field.ParentView;
                    if (parentRow == null)
                    {
                        string key = field.GetValue(dataRow);
                        if (!string.IsNullOrEmpty(key))
                        {
                            parentRow = parentView.GetDataRow(key, dataRow.Table.DataSet);
                        }
                    }
                }
                if (parentRow != null && parentField != field)
                {
                    if (parentView != rootView)
                    {
                        //dynastyPath += field.DisplayName + ".";
                        dynastyPath         = GetDynastyPath(dynastyPath, (ParentField)parentField, field);
                        internalDynastyPath = GetInternalDynastyPath(internalDynastyPath, (ParentField)parentField, field);
                        LoadValues(values, parentRow, parentView, field, rootView, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);
                    }
                }
            }
        }