예제 #1
0
        protected override void OnInit()
        {
            // link to the parent component
            ParentField?.Hook(this);

            base.OnInit();
        }
예제 #2
0
        private Durados.Web.Mvc.UI.Json.Field GetParentJsonField(ParentField parentField, string fk, DataAction dataAction, string guid)
        {
            bool   disabled = parentField.IsDisable(dataAction, guid);
            string value    = string.Empty;

            if (dataAction == DataAction.Create)
            {
                if (parentField.IncludeInDuplicate)
                {
                    value = fk;
                }
                else
                {
                    if (parentField.DefaultValue != null)
                    {
                        value = parentField.ConvertDefaultToString();
                    }
                }
            }
            else
            {
                value = fk;
            }
            Json.Field jsonField = new Json.Field()
            {
                Name = parentField.Name, Value = value, Type = parentField.GetHtmlControlType().ToString(), ValidationType = parentField.GetValidationType(), Format = parentField.Validation.Format, Required = parentField.Required, DependencyChildren = parentField.GetDependencyTriggeredFieldNames(), Searchable = parentField.IsSearchable(), Disabled = parentField.IsDisableForCreate(), DisDup = parentField.DisableInDuplicate, Refresh = parentField.Refresh, DependencyData = parentField.DependencyData
            };
            if (parentField.ParentHtmlControlType == ParentHtmlControlType.Autocomplete || disabled)
            {
                jsonField.Default = parentField.GetLocalizedDisplayValue(value);
            }

            return(jsonField);
        }
예제 #3
0
        /// <summary>
        /// Get select options for filter field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="fk"></param>
        /// <returns></returns>
        public static Dictionary <string, string> GetSelectOptions(this ParentField field, View view, string fk, int?top, bool forFilter)
        {
            Dictionary <string, string> selectOptions = null;
            Dictionary <string, object> values        = new Dictionary <string, object>();

            if (field != null)
            {
                if (forFilter)
                {
                    FormCollection collection = null;
                    Json.Filter    filter     = null;

                    //Init collection
                    collection = new FormCollection(ViewHelper.GetSessionState(view.Name + "Filter"));
                    if (collection != null && collection["jsonFilter"] != null)
                    {
                        try
                        {
                            filter = Json.JsonSerializer.Deserialize <Json.Filter>(collection["jsonFilter"]);
                        }
                        catch (Exception ex)
                        {
                            Map.Logger.Log(string.Empty, string.Empty, "GetSelectOptions", ex, 3, string.Empty);
                        }
                    }

                    //Init json filter
                    if (filter != null)
                    {
                        foreach (Json.Field jsonField in filter.Fields.Values)
                        {
                            if (jsonField.Value != null && !string.IsNullOrEmpty(jsonField.Value.ToString()))
                            {
                                values.Add(jsonField.Name, jsonField.Value);
                            }
                        }
                    }
                }

                //Init useUniqueName
                bool useUniqueName = field.ParentHtmlControlType == ParentHtmlControlType.InsideDependencyUniqueNames;

                //Extract selectOptions
                if (string.IsNullOrEmpty(fk))
                {
                    selectOptions = field.GetSelectOptions(view, forFilter, useUniqueName, top, values);
                }
                else
                {
                    selectOptions = field.GetSelectOptions(view, fk, top, values, forFilter);
                }
            }
            else
            {
                selectOptions = new Dictionary <string, string>();
            }

            return(selectOptions);
        }
예제 #4
0
        private string GetContactOrganizationKey(string contactKey)
        {
            Durados.Web.Mvc.View contactView = GetView(CRMViews.V_Contact.ToString());
            DataRow     dataRow           = contactView.GetDataRow(contactKey);
            ParentField organizationField = (Durados.Web.Mvc.ParentField)contactView.Fields[V_Contact.FK_Contact_Organization_Parent.ToString()];

            return(organizationField.GetValue(dataRow));
        }
예제 #5
0
        protected virtual string GetUserPK(View view, string pk, DataRow dataRow)
        {
            ParentField ownerField = GetOwnerField(view, pk);

            if (ownerField == null)
            {
                return(Map.Database.GetUserID());
            }
            string userPk = ownerField.GetValue(dataRow);

            return(userPk);
        }
예제 #6
0
        protected override void DropDownFilter(ParentField parentField, ref string sql)
        {
            HashSet <string> parents = new HashSet <string>()
            {
                "v_Location", "v_Failure", "v_Correction", "v_RemoteDiagnostic", "v_Repair", "v_EngineeringGroup"
            };

            if (parents.Contains(parentField.ParentView.Name))
            {
                SetFilter(ref sql);
            }
        }
예제 #7
0
파일: Product.cs 프로젝트: yarivat/Admin
        public Json.ProductInfo GetProductInfo(string pk)
        {
            View productView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.Product.ToString()];

            Json.ProductInfo productInfo = new Durados.Web.Mvc.Specifics.Shade.CRM.BusinessLogic.Json.ProductInfo();

            DataRow productRow = productView.GetDataRow(pk);

            ColumnField descriptionField = (ColumnField)productView.Fields[Durados.Web.Mvc.Specifics.Shade.CRM.Product.Description.ToString()];
            string      description      = descriptionField.GetValue(productRow);

            productInfo.Description = description;

            ParentField productPriceCategoryField = (ParentField)productView.Fields[Durados.Web.Mvc.Specifics.Shade.CRM.Product.FK_Product_ProductPriceCategory_Parent.ToString()];

            string productPriceCategoryId = productPriceCategoryField.GetValue(productRow);

            View productPriceView = (Durados.Web.Mvc.View)Map.Database.Views[ShadeViews.ProductPrice.ToString()];

            Dictionary <string, object> values = new Dictionary <string, object>();

            values.Add(ProductPrice.FK_ProductPrice_ProductCategory_Parent.ToString(), productPriceCategoryId);

            Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>();
            string sortColumn = ProductPrice.Width.ToString();

            if (!string.IsNullOrEmpty(sortColumn))
            {
                sortColumns.Add(sortColumn, SortDirection.Asc);
            }

            int      rowCount = 0;
            DataView dataView = productPriceView.FillPage(1, 10000, values, false, sortColumns, out rowCount, null, null);

            List <Json.Price> prices = new List <Durados.Web.Mvc.Specifics.Shade.CRM.BusinessLogic.Json.Price>();

            foreach (DataRow productPriceRow in dataView.Table.Rows)
            {
                double cost   = Convert.ToDouble(productPriceRow[ProductPrice.Cost.ToString()]);
                double pprice = (productPriceRow[ProductPrice.Price.ToString()] == DBNull.Value) ? 0 : Convert.ToDouble(productPriceRow[ProductPrice.Price.ToString()]);
                double width  = Convert.ToDouble(productPriceRow[ProductPrice.Width.ToString()]);
                double height = Convert.ToDouble(productPriceRow[ProductPrice.Height.ToString()]);
                bool   seamed = Convert.ToBoolean(productPriceRow[ProductPrice.Seamed.ToString()]);
                prices.Add(new Json.Price()
                {
                    Cost = cost, PPrice = pprice, Height = height, Width = width, Seamed = seamed
                });
            }

            productInfo.Prices = prices.OrderBy(p => p.Width).OrderBy(p => p.Height).ToArray();

            return(productInfo);
        }
예제 #8
0
        public static string GetLocalizedDisplayValue(this ParentField field, string value)
        {
            string displayValue = field.GetDisplayValue(value);

            if (field.DoLocalize())
            {
                return(Map.Database.Localizer.Translate(displayValue));
            }
            else
            {
                return(displayValue);
            }
        }
예제 #9
0
        protected override void OnInit()
        {
            // link to the parent component
            ParentField?.Hook(this);

            if (ParentValidation != null)
            {
                ParentValidation.InitInputValue(internalValue);

                ParentValidation.Validated += OnValidated;
            }

            base.OnInit();
        }
예제 #10
0
        protected override string GetUserPK(View view, string pk, DataRow dataRow)
        {
            ParentField ownerField = GetOwnerField(view, pk);

            ParentField jobField = (Durados.Web.Mvc.ParentField)view.Fields[v_JobVendor.FK_JobVendor_Job_Parent.ToString()];
            string      jobFk    = jobField.GetValue(dataRow);

            Durados.Web.Mvc.View jobView = GetView(ShadeViews.Job.ToString());

            DataRow jobRow = jobView.GetDataRow(jobFk);

            string userPk = ownerField.GetValue(jobRow);

            return(userPk);
        }
예제 #11
0
 protected void OnParentFieldStateChanged(object sender, EventArgs e)
 {
     if (ParentFieldState == MinesweeperGameState.GameWon)
     {
         Image = SmileyOnWin;
     }
     else if (ParentFieldState == MinesweeperGameState.GameLost)
     {
         Image = SmileyOnLose;
     }
     else if (ParentFieldActive)
     {
         Image = SmileyStandard;
         ParentField.RegisterMouseDownEventHandler(OnForeignObjectMouseDown);
         ParentField.RegisterMouseUpEventHandler(OnForeignObjectMouseUp);
     }
 }
예제 #12
0
        /// <summary>
        /// Get select options for filter field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="fk"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public static Dictionary <string, string> GetSelectOptions(this Field field, string fk, int?top, bool forFilter)
        {
            ParentField parentField = field.GetParentField();

            Durados.View view = null;

            if (field != null && field.FieldType == FieldType.Children)
            {
                view = field.View;
            }
            else if (parentField != null)
            {
                view = parentField.View;
            }

            return(GetSelectOptions(parentField, view as Durados.Web.Mvc.View, fk, top, forFilter));
        }
예제 #13
0
파일: Converter.cs 프로젝트: yarivat/Admin
        protected virtual DataRow GetParentViewRow(ParentField parentField, DataRow row)
        {
            DataRow parentRow = null;

            parentRow = row.GetParentRow(parentField.DataRelation.RelationName);
            if (parentRow == null)
            {
                View parentView = parentField.ParentView;
                if (row.Table.Columns.Contains(parentField.DatabaseNames))
                {
                    if (!string.IsNullOrEmpty(row[parentField.DatabaseNames].ToString()))
                    {
                        parentRow = parentView.GetDataRow(row[parentField.DatabaseNames].ToString());
                    }
                }
            }
            return(parentRow);
        }
예제 #14
0
        protected void LoadNames(List <string> names, View view, ParentField parentField, View rootView, string dynastyPath, string prefix, string postfix, string pk, Dictionary <string, Durados.Workflow.DictionaryField> dicFields, string internalDynastyPath)
        {
            if (pk == null)
            {
                LoadNames(names, view, parentField, rootView, dynastyPath, prefix, postfix);
            }
            else
            {
                DataRow row = view.GetDataRow(pk);
                Dictionary <string, object> values = new Dictionary <string, object>();
                LoadValues(values, row, view, parentField, rootView, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);

                foreach (string name in values.Keys)
                {
                    names.Add(name);
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Try get parent field by viewName and fieldName
        /// </summary>
        /// <param name="viewName"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static ParentField GetParentField(string viewName, string fieldName)
        {
            Durados.Web.Mvc.View view  = ViewHelper.GetView(viewName);
            ParentField          field = null;

            if (view.Fields.ContainsKey(fieldName))
            {
                if (view.Fields[fieldName].FieldType == FieldType.Parent)
                {
                    field = (ParentField)view.Fields[fieldName];
                }
                else if (view.Fields[fieldName].FieldType == FieldType.Children)
                {
                    field = (ParentField)((ChildrenField)view.Fields[fieldName]).GetFirstNonEquivalentParentField();
                }
            }

            return(field);
        }
예제 #16
0
        // <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);
        }
예제 #17
0
파일: Converter.cs 프로젝트: yarivat/Admin
        protected virtual void LoadParent(ParentField parentField, DataRow row, DataRow xmlRow, DataTable table)
        {
            string[] attributesNames = GetAttributesNames(parentField);
            Field[]  fields          = GetFields(parentField);

            if (attributesNames.Length != fields.Length)
            {
                throw new DuradosXmlException();
            }

            DataRow parentRow = GetParentViewRow(parentField, row);

            if (parentRow == null)
            {
                return;
            }


            for (int i = 0; i < attributesNames.Length; i++)
            {
                string attributeName = attributesNames[i];
                Field  field         = fields[i];

                if (table.Columns.Contains(attributeName))
                {
                    //if (parentRow == null)
                    //    xmlRow[attributeName] = string.Empty;
                    //else
                    //{
                    Type attributeType = table.Columns[attributeName].DataType;
                    xmlRow[attributeName] = GetValue(field, parentRow, attributeType) ?? DBNull.Value;
                    //}
                }
                else
                {
                    // handle error
                }
            }
        }
예제 #18
0
        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);
        }
예제 #19
0
    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);
    }
예제 #20
0
        protected virtual string GetTemplateForNew(View view, string pk)
        {
            DataRow dataRow = view.GetDataRow(pk);

            string templateFieldName;

            //if (view.Name == CRMViews.Proposal.ToString())
            //    templateFieldName = Proposal.FK_Proposal_Template_Parent.ToString();
            //else
            //    templateFieldName = v_ProposalLast2Months.FK_Proposal_Template1_Parent.ToString();
            templateFieldName = v_Proposal.FK_Proposal_Template_Parent.ToString();

            ParentField templateField = (ParentField)view.Fields[templateFieldName];

            string templatePK = templateField.GetValue(dataRow);

            Durados.Web.Mvc.View templateView     = GetView(ShadeViews.Template.ToString());
            string      documentLocationFiledName = Template.DocumentLocation.ToString();
            ColumnField documentLocationField     = (ColumnField)templateView.Fields[documentLocationFiledName];
            string      virtualPath = documentLocationField.Upload.UploadVirtualPath;

            return(GetTemplate(templatePK, templateView, documentLocationFiledName, virtualPath));
        }
예제 #21
0
        protected override string GetDynastyPath(string dynastyPath, ParentField parentField, ParentField field)
        {
            if (parentField == null)
            {
                return(dynastyPath + field.DisplayName + ".");
            }

            string[] s = dynastyPath.Split('.');

            for (int i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] == parentField.DisplayName)
                {
                    string r = string.Empty;
                    for (int j = 0; j <= i; j++)
                    {
                        r += s[j] + ".";
                    }
                    return(r + field.DisplayName + ".");
                }
            }

            return(dynastyPath += field.DisplayName + ".");
        }
예제 #22
0
        protected void LoadNames(List <string> names, View view, ParentField parentField, View rootView, string dynastyPath, string prefix, string postfix)
        {
            if (view.Equals(rootView))
            {
                dynastyPath = view.DisplayName + ".";
            }

            foreach (Field field in view.Fields.Values.Where(f => f.FieldType == FieldType.Column))
            {
                LoadName(names, view, field, dynastyPath, prefix, postfix);
            }

            foreach (ChildrenField field in view.Fields.Values.Where(f => f.FieldType == FieldType.Children && ((ChildrenField)f).LoadForBlockTemplate))
            {
                LoadName(names, view, field, dynastyPath, prefix, postfix);
            }

            foreach (ParentField field in view.Fields.Values.Where(f => f.FieldType == FieldType.Parent))
            {
                if (view.Equals(rootView))
                {
                    dynastyPath = view.DisplayName + ".";
                }

                LoadName(names, view, field, dynastyPath, prefix, postfix);

                View parentView = (View)field.ParentView;

                if (parentView != rootView && !IsRecursive(dynastyPath + field.DisplayName))
                {
                    //dynastyPath += field.DisplayName + ".";
                    dynastyPath = GetDynastyPath(dynastyPath, parentField, field);
                    LoadNames(names, parentView, field, rootView, dynastyPath, prefix, postfix);
                }
            }
        }
예제 #23
0
        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);
        }
예제 #24
0
파일: Step.cs 프로젝트: yarivat/Admin
        public virtual Result Complete(object controller, Dictionary <string, Parameter> parameters, View view, Dictionary <string, object> values, DataRow prevRow, string pk, string connectionString, int currentUsetId, string currentUserRole, IDbCommand command, Engine engine)
        {
            Result result = new Result();
            Dictionary <string, EnabledStep> enabledSteps = new Dictionary <string, EnabledStep>();

            ParentField parentField = (ParentField)view.WorkFlowStepsField;
            View        parentView  = parentField.ParentView;
            DataTable   dataTable   = ((ILoader)controller).GetDataTable(parentView);

            result.PK = pk;
            Field ordinalField = null;

            result.Description = ((ILoader)controller).GetTooltip(view.DisplayName + " Steps", parentField.Description);

            if (!string.IsNullOrEmpty(parentView.OrdinalColumnName))
            {
                if (parentView.Fields.ContainsKey(parentView.OrdinalColumnName))
                {
                    ordinalField = parentView.Fields[parentView.OrdinalColumnName];
                }
            }

            string workflowCompletedMessage = string.Empty;
            string workflowNoResultMessage  = string.Empty;

            bool messageOnly = false;

            result.Message = view.Database.DefaultStepMessage;
            result.WorkflowCompletedMessage = view.Database.DefaultWorkFlowCompletedMessage;
            if (values.ContainsKey(parentField.Name))
            {
                result.CurrentStepId = values[parentField.Name].ToString();
            }
            else
            {
                result.CurrentStepId = parentField.GetValue(prevRow);
            }

            foreach (string key in parameters.Keys)
            {
                if (key.ToLower() == "message")
                {
                    result.Message = parameters[key].Value;
                }
                else if (key.ToLower() == "workflowcompletedmessage")
                {
                    workflowCompletedMessage = parameters[key].Value;
                }
                else if (key.ToLower() == "workflownoresultmessage")
                {
                    workflowNoResultMessage = parameters[key].Value;
                }
                else if (key.ToLower() == "messageonly")
                {
                    messageOnly = parameters[key].Value.ToLower() != "false" && parameters[key].Value.ToLower() != "0";
                }
                else
                {
                    Rule stepRule = new Rule();
                    stepRule.WhereCondition = key;
                    string[] ids     = parameters[key].Value.Split('~');
                    bool     enabled = engine.Check(view, stepRule, TriggerDataAction.BeforeCompleteStep, values, pk, prevRow, parameters[key].UseSqlParser, connectionString, currentUsetId, currentUserRole);

                    if (enabled)
                    {
                        foreach (string id2 in ids)
                        {
                            string id = id2;
                            if (id.Equals(Step.PreviousStep))
                            {
                                id = GetPrevStep((ILoader)controller, view, pk, result.CurrentStepId);
                            }
                            if (id != null)
                            {
                                DataRow dataRow = dataTable.Rows.Find(parentView.GetPkValue(id));
                                if (dataRow != null)
                                {
                                    string name    = parentView.GetDisplayValue(dataRow);
                                    int    ordinal = 0;
                                    if (ordinalField != null)
                                    {
                                        string s = ordinalField.GetValue(dataRow);
                                        if (!string.IsNullOrEmpty(s))
                                        {
                                            ordinal = Convert.ToInt32(s);
                                        }
                                    }
                                    string description = string.Empty;
                                    if (dataTable.Columns.Contains("Description"))
                                    {
                                        description = ((ILoader)controller).GetTooltip(name, dataRow["Description"].ToString());
                                    }
                                    if (!enabledSteps.ContainsKey(id))
                                    {
                                        enabledSteps.Add(id, new EnabledStep()
                                        {
                                            Enable = enabled, Id = id, Name = name, Ordinal = ordinal, Description = description
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach (DataRow row in dataTable.Rows)
            {
                string id = parentView.GetPkValue(row);
                if (!enabledSteps.ContainsKey(id))
                {
                    string name    = parentView.GetDisplayValue(row);
                    int    ordinal = 0;
                    if (ordinalField != null)
                    {
                        string s = ordinalField.GetValue(row);
                        if (!string.IsNullOrEmpty(s))
                        {
                            ordinal = Convert.ToInt32(s);
                        }
                    }
                    string description = string.Empty;
                    if (dataTable.Columns.Contains("Description"))
                    {
                        description = row["Description"].ToString();
                    }

                    enabledSteps.Add(id, new EnabledStep()
                    {
                        Enable = false, Id = id, Name = name, Ordinal = ordinal, Description = description
                    });
                }
            }

            result.EnabledSteps = enabledSteps.Values.OrderBy(es => es.Ordinal).ToArray();

            int enabledStepsCount = result.EnabledSteps.Where(es => es.Enable).Count();

            result.MessageOnly = enabledStepsCount == 0 || (enabledStepsCount == 1 && messageOnly);

            if (enabledStepsCount == 0)
            {
                result.WorkflowCompletedMessage = workflowNoResultMessage;
            }
            else
            {
                result.WorkflowCompletedMessage = workflowCompletedMessage;
            }

            return(result);
        }
예제 #25
0
        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));
        }
예제 #26
0
        /// <summary>
        /// Get select options for filter field
        /// </summary>
        /// <param name="viewName"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static Dictionary <string, string> GetSelectOptions(string viewName, string fieldName, string fk, bool forFilter)
        {
            ParentField field = FieldHelper.GetParentField(viewName, fieldName);

            return(GetSelectOptions(field, fk, null, forFilter));
        }
예제 #27
0
 public static Dictionary <string, Dictionary <string, string> > GetSelectOptionsWithGroups(this ParentField parentField)
 {
     return(GetDataTableAccess(parentField.View).GetSelectOptionsWithGroups(parentField));
 }
예제 #28
0
        // 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(','));
        }
예제 #29
0
파일: Contact.cs 프로젝트: yarivat/Admin
        public Json.ContactInfo GetContactInfo(string pk)
        {
            View contactView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.V_Contact.ToString()];

            Json.ContactInfo contactInfo = new Durados.Web.Mvc.Specifics.Projects.CRMShade.BusinessLogic.Json.ContactInfo();

            DataRow contactRow = contactView.GetDataRow(pk);

            ColumnField field = (ColumnField)contactView.Fields[V_Contact.Cellular.ToString()];
            string      val   = field.GetValue(contactRow);

            contactInfo.ClientCellular = val ?? string.Empty;

            field = (ColumnField)contactView.Fields[V_Contact.Email.ToString()];
            val   = field.GetValue(contactRow);
            contactInfo.ClientEmail = val ?? string.Empty;

            field = (ColumnField)contactView.Fields[V_Contact.FullName.ToString()];
            val   = field.GetValue(contactRow);
            contactInfo.ClientName = val ?? string.Empty;

            field = (ColumnField)contactView.Fields[V_Contact.Phone.ToString()];
            val   = field.GetValue(contactRow);
            contactInfo.ClientPhone = val ?? string.Empty;

            View        addressView  = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.Address.ToString()];
            ParentField addressField = (ParentField)contactView.Fields[V_Contact.FK_AddressOther_V_Contact_Parent.ToString()];

            val = addressField.GetValue(contactRow);
            if (string.IsNullOrEmpty(val))
            {
                addressField          = (ParentField)contactView.Fields[V_Contact.FK_Address_V_Contact_Parent.ToString()];
                val                   = addressField.GetValue(contactRow);
                contactInfo.AddressID = val ?? string.Empty;

                DataRow addressRow = contactRow.GetParentRow(addressField.DataRelation.RelationName);
                if (addressRow != null)
                {
                    field = (ColumnField)addressView.Fields[Address.FullAddress.ToString()];
                    val   = field.GetValue(addressRow);
                    contactInfo.AddressText = val ?? string.Empty;
                }
                else
                {
                    contactInfo.AddressText = string.Empty;
                }
            }
            else
            {
                contactInfo.AddressID = val ?? string.Empty;

                DataRow addressRow = contactRow.GetParentRow(addressField.DataRelation.RelationName);
                if (addressRow != null)
                {
                    field = (ColumnField)addressView.Fields[Address.FullAddress.ToString()];
                    val   = field.GetValue(addressRow);
                    contactInfo.AddressText = val ?? string.Empty;
                }
                else
                {
                    contactInfo.AddressText = string.Empty;
                }
            }

            //field = (ColumnField)contactView.Fields[V_Contact.MailingCountry.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobCountry = val ?? string.Empty;

            //field = (ColumnField)contactView.Fields[V_Contact.MailingState.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobState = val ?? string.Empty;


            //field = (ColumnField)contactView.Fields[V_Contact.MailingStreet.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobStreet = val ?? string.Empty;

            //field = (ColumnField)contactView.Fields[V_Contact.MailingZip.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobZip = val ?? string.Empty;

            return(contactInfo);
        }
예제 #30
0
        //changed by br 3
        public static Dictionary <string, string> GetSelectOptions(this ParentField parentField, View view, string fk, int?top, Dictionary <string, object> filterValues, bool forFilter)
        {
            Filter filter = GetDataTableAccess(parentField.View).GetFilter(parentField.View, filterValues, LogicCondition.And, false, false, parentField);

            return(GetDataTableAccess(parentField.View).GetSelectOptions(parentField, fk, top, filter, forFilter));
        }