コード例 #1
0
        public UI.Control Make(ControlDefinition definition, DbSearchResponse ticketSet, UI.Instance parentNode, Action <UI.Control> controlAction)
        {
            var control = new UI.Control
            {
                ControlType = Mapper.Map <UI.ControlType>(definition.ControlType),
                ParentNode  = parentNode
            };

            var ticket = ticketSet.Tickets.FirstOrDefault();

            var dalControl = (DAL.Models.Control)definition.Entity;

            control.Events = definition
                             .Events
                             .Select(e => BehaviourSelector.EventBehaviours[Mapper.Map <UI.EventType>(e.EventType)](CurrentUser).Make(e, ticketSet, control))
                             .ToList();

            control.Props.Add("DisplayName", definition.DisplayName);
            control.Props.Add("Order", definition.OrderIndex);
            control.Props.Add("Width", definition.Width);
            control.Props.Add("Style", Mapper.Map <UI.StyleDefinition>(((DAL.Models.Control)definition.Entity).Style));

            if (dalControl.Field != null)
            {
                control.Props.Add("FieldId", dalControl.Field.Id);
            }

            if (ticket != null)
            {
                control.DocId = Convert.ToInt32(ticket[dalControl.Field.TemplateId, "Id"]);

                if (dalControl.Field.FieldType.In(DAL.Models.FieldType.Dictionary))
                {
                    control.Props.Add("DictionaryId", dalControl.Field.Dictionary.Id);
                    control.Props.Add("DictionaryName", dalControl.Field.Dictionary.Name);
                    control.Props.Add("DictionaryType", Enum.GetName(typeof(DAL.Models.DictionaryType), dalControl.Field.Dictionary.DictionaryType));

                    var options = DbDictionaryCache.GetDictionaryRecords(dalControl.Field.Dictionary);

                    var values = DbDictionaryCache.GetValues(dalControl.Field.Dictionary, dalControl.Field.Id, control.DocId.Value);
                    control.Value = string.Join(", ", values.Select(v => options[v]));
                }
                else if (dalControl.Field.FieldType == DAL.Models.FieldType.Flag)
                {
                    control.Value = (ticket[dalControl.Field] == null) ? string.Empty :
                                    (bool)ticket[dalControl.Field] ? $"{definition.DisplayName}" : string.Empty;
                }
                else if (dalControl.Field.FieldType == DAL.Models.FieldType.DateTime)
                {
                    control.Value = (ticket[dalControl.Field] != null) ?
                                    ((DateTime)ticket[dalControl.Field]).ToString("dd.MM.yyyy") : string.Empty;
                }
                else
                {
                    control.Value = ticket[dalControl.Field] ?? string.Empty;
                }
            }

            return(control);
        }
コード例 #2
0
        public Control Make(ControlDefinition definition, DAL.Models.DbSearchResponse ticketSet, UI.Instance parentNode, Action <Control> controlAction)
        {
            var control = new Control()
            {
                ControlType = Mapper.Map <UI.ControlType>(definition.ControlType),
                ParentNode  = parentNode
            };

            control.Props = new Dictionary <string, object>()
            {
                { "Id", definition.Id },
                { "DisplayName", definition.DisplayName },
                { "Width", definition.Width },
                { "Order", definition.OrderIndex },
                { "Style", Mapper.Map <UI.StyleDefinition>(((DAL.Models.Control)definition.Entity).Style) }
            };

            var dalControl = (DAL.Models.Control)definition.Entity;

            if (dalControl.Field != null)
            {
                control.Props.Add("FieldId", dalControl.Field.Id);
                control.Props.Add("Name", dalControl.Field.Name);
            }

            var ticket = ticketSet.Tickets.FirstOrDefault();

            control.Events = definition
                             .Events
                             .Select(e => BehaviourSelector.EventBehaviours[Mapper.Map <UI.EventType>(e.EventType)](CurrentUser).Make(e, ticketSet, control))
                             .ToList();

            if (ticket != null && dalControl.FieldId.HasValue)
            {
                control.Value = ticket[dalControl.Field];
                control.DocId = Convert.ToInt32(ticket[dalControl.Field.TemplateId, "Id"]);
            }

            return(control);
        }
コード例 #3
0
        public Control Make(UI.ControlDefinition definition, DAL.Models.DbSearchResponse ticketSet, UI.Instance parentNode, Action <Control> controlAction)
        {
            var button = new Control()
            {
                Virtual     = true,
                ParentNode  = parentNode,
                ControlType = ControlType.ButtonPageNumberControl
            };

            button.Props = new Dictionary <string, object>()
            {
                { "Width", 1 },
                { "PageSize", ticketSet.PageSize.ToString() },
                { "SortFieldId", ticketSet.SortField.Id.ToString() },
                { "SortDirection", ticketSet.SortDirection },
                { "Style", GetStyle() }
            };

            controlAction(button);

            button.Props.Add("PageNumber", button.Props["DisplayName"]);

            button.Value = button.Props["DisplayName"];

            var evt = new Event()
            {
                Virtual = true, EventType = EventType.Click, ParentNode = button
            };

            evt.Actions.Add(new SearchActionBehaviour(CurrentUser).Make(null, null, evt));

            button.Events.Add(evt);

            return(button);
        }
コード例 #4
0
        public Control Make(ControlDefinition definition, DAL.Models.DbSearchResponse ticketSet, UI.Instance parentNode, Action <Control> controlAction)
        {
            var button = new UI.Control()
            {
                Virtual     = true,
                ParentNode  = parentNode,
                ControlType = ControlType.ButtonSearch
            };

            button.Props = new Dictionary <string, object>()
            {
                { "DisplayName", RC.BTN_SEARCH },
                { "Width", 3 },
                { "Order", 0 },
                //{ "PageSize", ticketSet.PageSize.ToString() },
                //{ "PageNumber", "1" },
                //{ "SortFieldId", "Id"},
                //{ "SortDirection", "asc" },
                { "Style", GetStyle() }
            };

            var evt = new Event()
            {
                Virtual = true, EventType = EventType.Click, ParentNode = button
            };

            evt.Actions.Add(new SearchActionBehaviour(CurrentUser).Make(null, null, evt));

            button.Events.Add(evt);

            return(button);
        }
コード例 #5
0
        public Control Make(ControlDefinition definition, DAL.Models.DbSearchResponse ticketSet, UI.Instance parentNode, Action <Control> controlAction)
        {
            var control = new UI.Control
            {
                ControlType = Mapper.Map <UI.ControlType>(definition.ControlType),
                ParentNode  = parentNode
            };

            var ticket = ticketSet.Tickets.FirstOrDefault();

            var dalControl = (DAL.Models.Control)definition.Entity;

            if (ticket != null)
            {
                control.DocId = Convert.ToInt32(ticket[dalControl.Field.TemplateId, "Id"]);
            }

            control.Props.Add("DisplayName", definition.DisplayName);
            control.Props.Add("FieldId", dalControl.Field.Id);
            control.Props.Add("DictionaryId", dalControl.Field.Dictionary.Id);
            control.Props.Add("DictionaryName", dalControl.Field.Dictionary.Name);
            control.Props.Add("DictionaryType", Enum.GetName(typeof(DAL.Models.DictionaryType), dalControl.Field.Dictionary.DictionaryType));
            control.Props.Add("Order", definition.OrderIndex);
            control.Props.Add("Width", definition.Width);
            control.Props.Add("Style", Mapper.Map <UI.StyleDefinition>(((DAL.Models.Control)definition.Entity).Style));

            var options        = DbDictionaryCache.GetDictionaryRecords(dalControl.Field.Dictionary);
            var controlOptions = options.Select(i => new KeyValuePair <object, string>(i.Key, i.Value)).ToList();

            control.Props.Add("Options", controlOptions);
            control.Value = DbDictionaryCache.GetValues(dalControl.Field.Dictionary, dalControl.Field.Id, control.DocId.Value);

            return(control);
        }
コード例 #6
0
        public UI.Control Make(ControlDefinition definition, DAL.Models.DbSearchResponse ticketSet, UI.Instance parentNode, Action <UI.Control> controlAction)
        {
            var button = new UI.Control()
            {
                Virtual     = true,
                ParentNode  = parentNode,
                ControlType = ControlType.SectionSettingsButton
            };

            var evt = new Event()
            {
                Virtual    = true,
                EventType  = EventType.Click,
                ParentNode = button
            };

            evt.Actions.Add(new GetSectionSettingsBehaviour(CurrentUser).Make(null, null, evt));

            button.Events.Add(evt);

            return(button);
        }
コード例 #7
0
        public Control Make(ControlDefinition definition, DAL.Models.DbSearchResponse ticketSet, UI.Instance parentNode, Action <UI.Control> controlAction)
        {
            var header = new Control()
            {
                ControlType = UI.ControlType.TableHeaderControl,
                ParentNode  = parentNode,
                Virtual     = true
            };

            header.Props = new Dictionary <string, object>()
            {
                { "DisplayName", definition.DisplayName },
                { "Width", definition.Width },
                { "Order", definition.OrderIndex },
                { "Style", GetStyle() }
            };

            var dalControl = (DAL.Models.Control)definition.Entity;

            if (dalControl.FieldId.HasValue && !dalControl.Field.FieldType.In(DAL.Models.FieldType.Dictionary, DAL.Models.FieldType.File))
            {
                var controlFieldId = ((DAL.Models.Control)definition.Entity).Field.Id;

                header.Props.Add("IsCurrentSortControl", ticketSet.SortField.Id == controlFieldId);

                header.Props.Add("PageSize", ticketSet.PageSize.ToString());
                header.Props.Add("PageNumber", ticketSet.PageNumber.ToString());
                header.Props.Add("SortFieldId", ((DAL.Models.Control)definition.Entity).Field?.Id.ToString());
                header.Props.Add("SortDirection", (ticketSet.SortField.Id != controlFieldId) ? "asc" :
                                 ticketSet.SortDirection == "asc" ? "desc" : "asc");

                var evt = new Event()
                {
                    Virtual = true, EventType = EventType.Click, ParentNode = header
                };
                evt.Actions.Add(new SearchActionBehaviour(CurrentUser).Make(null, null, evt));

                header.Events.Add(evt);
            }

            return(header);
        }