Example #1
0
    void Start()
    {
        //Setting of above variables
        exitCollider       = FindObjectOfType <LevelExitCollider>();
        genComponent       = GameObject.Find("LevelGenerator").GetComponent <Generator>();
        uiGenComponent     = GameObject.Find("Hand1").GetComponent <UIGenerator>();
        uiGameObjects      = uiGenComponent.comparisonGameObjectsGeneratorUI;
        bigCubeGameObjects = genComponent.comparisonGameObjectsGenerator;

        uiCubeParent       = uiGenComponent.parentHolderUI;
        bigCubeParent      = genComponent.parentHolder;
        doorGameObjects    = FindObjectsOfType <Door>();
        roomTypeindicators = FindObjectsOfType <RoomTypeindicator>();

        levelAnalytics = FindObjectOfType <AnalyticsTestingClass>();
        levelAnalytics = AnalyticsTestingClass.analyticsResults;

        //Find the objects that contain the scripts for analytics to work, then call levelstart to send analytics for funnel
        levelAnalytics.FindGameObjects();
        RestartDoorSymbols(true, true);
        CheckDoors();
        LevelStart();
    }
Example #2
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            if (!g.IsList())
            {
                return;
            }

            ListGroupNode lg = (ListGroupNode)g;

            ConcreteInteractionObject cio =
                ui.Core.ObjectRegistry.ChooseWidget(lg);

            g.Decorations.Add(ListDecision.DECISION_KEY, new ListDecision());

            if (cio != null)
            {
                g.Decorations.Add(UnitDecision.DECISION_KEY, new UnitDecision(cio));
            }
            else
            {
                // add in some components to allow the user to scroll through elements
                // in the list and make selections (if relevant)

                ApplianceState  indexState = new ListIndexState(lg.Appliance, lg);
                ObjectGroupNode idxGrp     = new ObjectGroupNode(indexState);

                lg.Children.Add(idxGrp);
                idxGrp.Parent = lg;

                if (lg.SelectionType == SelectionType.One)
                {
                    lg.SelectionState.ValueChangedEvent += new PUC.ApplianceState.ValueChangedHandler(((ListIndexState)indexState).SelectionChanged);
                }

                // TODO: Implement multiple selections code
            }
        }
Example #3
0
        private void DebugServerFrame_Resize(object sender, System.EventArgs e)
        {
            if (this.ClientSize.Width == 0 && this.ClientSize.Height == 0)
            {
                // this happens when the window is minimized
                return;
            }

            this.logPanel.Size = this.ClientSize;
            this.logBox.Size   = new System.Drawing.Size(this.logPanel.Size.Width,
                                                         this.logPanel.Size.Height -
                                                         this.logBox.Location.Y);

            if (_appliance != null)
            {
                UIGenerator   ui   = _appliance.GetUIGenerator();
                InterfaceNode root = ui.InterfaceRoot;

                ui.Size = this.ClientSize;

                root.SetSize(ui.Size.Width, ui.Size.Height);
                root.DoLayout(ui.LayoutVars);
            }
        }
Example #4
0
        public JsonTable BuidJsonTable(DataTable table, IEnumerable <REPORTCOLUMNDEFINITION> columns, int total = 0, int currentPage = 0, int pageSize = 0)
        {
            var jTable = new JsonTable();

            jTable.CurrentPage = currentPage;
            jTable.PageSize    = pageSize;
            jTable.Total       = total;
            foreach (var column in columns)
            {
                jTable.ColumTemplate.Add(new JsonColumn {
                    ColumnName = column.COLUMN_NAME, ColumnType = column.COLUMN_TYPE, Name = column.DisplayName, ColumnStyle = column.COLUMN_STYLE ?? ""
                });
            }
            foreach (DataRow row in table.Rows)
            {
                var currentRow = new Dictionary <string, string>();
                foreach (REPORTCOLUMNDEFINITION column in columns)
                {
                    if (!currentRow.Keys.Contains(column.COLUMN_NAME))
                    {
                        currentRow.Add(column.COLUMN_NAME, column.COLUMN_STYLE != "" && row[column.COLUMN_NAME].ToString().Length > 200 ? (row[column.COLUMN_NAME].ToString().Substring(0, 200) + "...") : UIGenerator.FormatCellValue(row, column));
                    }
                }
                if (!columns.Any(x => x.COLUMN_NAME == "Code"))
                {
                    currentRow.Add("Code", row["Code"].ToString());
                }
                if (!columns.Any(x => x.COLUMN_NAME == "AssetId"))
                {
                    currentRow.Add("AssetId", row["AssetId"].ToString());
                }
                jTable.RowData.Add(currentRow);
            }
            return(jTable);
        }
Example #5
0
        /*
         * Abstract Methods
         */

        /// <summary>
        /// This method applies all of the rules to the input and
        /// returns the output of their application.  In cases where
        /// the input is being modified internally, then the returned
        /// value should be the same as the input value.
        /// </summary>
        /// <param name="o">the input to this rule phase</param>
        /// <returns>the output of the rule phase</returns>
        public abstract object Process(object o, UIGenerator ui);
Example #6
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        /// <summary>
        /// This method checks if for a pattern that looks like
        /// ListNode->ListNode(one child)->ListNode and removes the
        /// intermediate ListNode.
        /// </summary>
        public override bool Process(ListItemNode node, UIGenerator ui)
        {
            // promotion rules can't work on the root node
            bool ableToPromote = node.Parent != null;

            if (node is ListNode)
            {
                ListNode  listNode   = (ListNode)node;
                Hashtable panelNodes = new Hashtable(listNode.Items.Count);

                IEnumerator e = listNode.Items.GetEnumerator();
                while (e.MoveNext())
                {
                    if (e.Current is PanelListNode)
                    {
                        //
                        // ASSUMPTION: All items in a panel node share
                        // the same parent group
                        //
                        GroupDecision d =
                            (GroupDecision)((ListItemNode)((PanelListNode)e.Current).Items[0]).Decorations[GroupDecision.DECISION_KEY];
                        if (d != null)
                        {
                            ArrayList list = (ArrayList)panelNodes[d.Group.Parent];

                            if (list == null)
                            {
                                list = new ArrayList(listNode.Items.Count);
                            }

                            list.Add(e.Current);

                            panelNodes[d.Group.Parent] = list;
                        }
                    }
                }

                e = panelNodes.Keys.GetEnumerator();
                while (e.MoveNext())
                {
                    GroupNode parent = (GroupNode)e.Current;

                    if (parent.Labels == null)
                    {
                        // has no labels, so abort for this group
                        continue;
                    }

                    // create a new PanelNode and move all items into this node
                    PanelListNode newPanel = new PanelListNode(parent.Labels);
                    ArrayList     list     = (ArrayList)panelNodes[parent];

                    if (list.Count <= 1)
                    {
                        continue;
                    }

                    IEnumerator panels = list.GetEnumerator();
                    while (panels.MoveNext())
                    {
                        PanelListNode existPanel = (PanelListNode)panels.Current;
                        IEnumerator   items      = existPanel.Items.GetEnumerator();
                        while (items.MoveNext())
                        {
                            newPanel.Add((ListItemNode)items.Current);
                        }

                        listNode.Remove(existPanel);
                    }

                    listNode.Add(newPanel);
                }
            }

            return(false);
        }
Example #7
0
 private void Start()
 {
     uIGenerator = GameObject.Find("Hand1").GetComponent <UIGenerator>();
 }
Example #8
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled &&
                    d.State.Type.ValueSpace is EnumeratedSpace)
                {
                    object          stateval = d.State.Value;
                    EnumeratedSpace espc     = (EnumeratedSpace)d.State.Type.ValueSpace;

                    if (espc.GetItemCount() == (d.DependencySets.Count - 1))
                    {
                        for (int i = 1; i < d.DependencySets.Count; i++)
                        {
                            ArrayList dep = (ArrayList)d.DependencySets[i];

                            if (dep.Count != 1)
                            {
                                // Globals.AddLogLine("size! " + dep.Count );
                                return;
                            }
                            if (!(dep[0] is EqualsDependency))
                            {
                                // Globals.AddLogLine("not equals!");
                                return;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }

                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    ObjectGroupNode stateGroup = null;
                    BranchGroupNode bg         = (BranchGroupNode)g;

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).IsObject() &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // re-order the tree

                    ArrayList childOrder = new ArrayList();

                    bg.Children.Remove(stateGroup);

                    BranchGroupNode midG = new BranchGroupNode();

                    midG.Children = bg.Children;
                    e             = midG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = midG;
                    }

                    bg.Children = new ArrayList();

                    ArrayList dset = (ArrayList)d.ChildSets[0];
                    if (dset.Count > 0)
                    {
                        e = dset.GetEnumerator();
                        while (e.MoveNext())
                        {
                            GroupNode c = (GroupNode)e.Current;

                            c.Parent = bg;

                            midG.Children.Remove(c);
                            bg.Children.Add(c);
                        }
                    }

                    bg.Children.Add(midG);
                    midG.Parent       = bg;
                    stateGroup.Parent = bg;

                    for (int i = 1; i < d.ChildSets.Count; i++)
                    {
                        dset = (ArrayList)d.ChildSets[i];

                        if (dset.Count > 1)
                        {
                            BranchGroupNode newG = new BranchGroupNode();
                            newG.Parent = midG;

                            e = dset.GetEnumerator();
                            while (e.MoveNext())
                            {
                                GroupNode c = (GroupNode)e.Current;

                                c.Parent = newG;

                                midG.Children.Remove(c);
                                newG.Children.Add(c);
                            }

                            childOrder.Insert(i - 1, newG);
                        }
                        else if (dset.Count == 0)
                        {
                            BranchGroupNode newG = new BranchGroupNode();

                            newG.Parent   = midG;
                            newG.Children = new ArrayList();

                            midG.Children.Add(newG);

                            childOrder.Insert(i - 1, newG);
                        }
                        else
                        {
                            childOrder.Insert(i - 1, dset[0]);
                        }
                    }

                    d.DependencySets.RemoveAt(0);

                    OrganizationDecision newDecision = new TabbedOverlapOrgDecision(d, ui, d.State, childOrder, d.DependencySets, true);
                    midG.Decorations.Add(OrganizationDecision.DECISION_KEY, newDecision);

                    d.Handled = true;
                }
            }
        }
Example #9
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        public abstract ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui);
Example #10
0
        /*
         * Process Method
         */

        public override ConcreteInteractionObject Process(ListItemNode node,
                                                          ConcreteInteractionObject cio,
                                                          UIGenerator ui)
        {
            if (node.Decorations[ItemDecision.DECISION_KEY] == null &&
                node is CIOListItemNode &&
                cio is ScrollingPanelCIO)
            {
                // the item node represents an appliance object and it will be
                // placed on the ScrollingPanelCIO
                CIOListItemNode   item  = (CIOListItemNode)node;
                ScrollingPanelCIO panel = (ScrollingPanelCIO)cio;
                LabelDictionary   labels;
                if (item.CIO is StateLinkedCIO)
                {
                    labels = ((ApplianceState)((StateLinkedCIO)item.CIO).GetApplObj()).Labels;
                }
                else if (item.CIO is SmartCIO)
                {
                    labels = ((SmartCIO)item.CIO).Labels;
                }

                // get information about the bottom of the current
                // panel's layout
                PanelLayoutDecision panelDecision =
                    (PanelLayoutDecision)node.Parent.Decorations[PanelLayoutDecision.DECISION_KEY];

                if (panelDecision == null)
                {
                    // make one
                    panelDecision = new PanelLayoutDecision();
                    node.Parent.Decorations.Add(PanelLayoutDecision.DECISION_KEY, panelDecision);
                }

                LabelCIO label = null;
                if (item.CIO.HasLabel())
                {
                    label = (LabelCIO)item.CIO.GetLabelCIO();
                    panel.AddCIO(label);
                }

                ControlBasedCIO control = (ControlBasedCIO)item.CIO;
                panel.AddCIO(control);

                // do some sizing here
                int width = ui.Size.Width - 2 * ui.LayoutVars.RowPadding - 5;

                if (item.CIO.HasLabel())
                {
                    // layout label CIO
                    label.GetControl().Location =
                        new System.Drawing.Point(ui.LayoutVars.RowPadding, panelDecision.Bottom);
                    label.GetControl().Size =
                        new System.Drawing.Size(width, label.GetMinimumSize().Height);
                    panelDecision.Bottom += label.GetControl().Size.Height + ui.LayoutVars.RowPadding;

                    label.FinalSizeNotify();
                }

                control.GetControl().Location =
                    new System.Drawing.Point(ui.LayoutVars.RowPadding, panelDecision.Bottom);
                control.GetControl().Size =
                    new System.Drawing.Size(width, ((ControlBasedCIO)item.CIO).GetMinimumSize().Height);
                panelDecision.Bottom += ((ControlBasedCIO)item.CIO).GetMinimumSize().Height + 2 * ui.LayoutVars.RowPadding;

                item.Decorations[ItemDecision.DECISION_KEY] =
                    new PanelItemDecision(item.CIO);
            }

            return(cio);
        }
Example #11
0
        /// <summary>
        /// This rule looks for InsufficientHeight layout problems, and attempts
        /// to fix them by splitting controls onto multiple tabbed panels.
        /// </summary>
        /// <param name="problem">the layout problem to fix</param>
        /// <param name="node">the root of the interface tree</param>
        /// <param name="ui">the UIGenerator object, which contains global variables to the layout process</param>
        public override InterfaceNode Process(LayoutProblem problem, InterfaceNode root, UIGenerator ui)
        {
            if (problem is InsufficientHeight)
            {
                InsufficientHeight prob = (InsufficientHeight)problem;

                // we will use tabs if the group associated with this panel
                // has only BranchGroupNodes as children, and each of those
                // groups has labels

                // Step #1: check if the above criteria are true

                if (prob.Panel.Group is BranchGroupNode)
                {
                    BranchGroupNode bg = (BranchGroupNode)prob.Panel.Group;

                    if (!bg.ContainsOnlyGroups())
                    {
                        return(root);
                    }

                    while (bg.Count == 1)
                    {
                        bg = (BranchGroupNode)bg.Children[0];

                        if (!bg.ContainsOnlyGroups())
                        {
                            return(root);
                        }
                    }

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).Labels == null)
                        {
                            return(root);
                        }
                    }

                    // If we get here, all of the criteria have been met.

                    // Now we insert our tabbed panel.
                    TabbedOverlappingPanelsNode tabs = new TabbedOverlappingPanelsNode(bg);
                    prob.Panel.Container.GetControl().Controls.Remove(prob.Panel.GetContainerCIO().GetControl());

                    if (prob.Panel.GetParent() != null)
                    {
                        prob.Panel.GetParent().AddPanel(tabs);
                        prob.Panel.GetParent().RemovePanel(prob.Panel);
                    }
                    else
                    {
                        root = tabs;
                    }

                    // now we need to distribute the rows from the panel into the new tabbed panels
                    IEnumerator row = prob.Panel.Rows.GetEnumerator();
                    while (row.MoveNext())
                    {
                        Row       r = (Row)row.Current;
                        GroupNode g = r.Group;
                        while (tabs[g] == null)
                        {
                            g = g.Parent;
                        }

                        ((PanelNode)tabs[g].GetChildNode()).AddRow(r);
                    }

                    // finally, add the components and the do the layout for the tabs
                    tabs.SetLocation(prob.Panel.GetBounds().X, prob.Panel.GetBounds().Y);
                    tabs.SetSize(prob.Panel.GetBounds().Width, prob.Panel.GetBounds().Height);
                    tabs.AddComponents(prob.Panel.Container, ui.LayoutVars);
                    tabs.DoLayout(ui.LayoutVars);
                }
            }

            return(root);
        }
Example #12
0
 public void SetUIGenerator(UIGenerator ui)
 {
     _uiGenerator = ui;
 }
Example #13
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        public abstract void Process(InterfaceNode node, UIGenerator ui);
Example #14
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        /// <summary>
        /// This process methods returns a boolean that indicates whether the
        /// phase will need to restart its iteration on the current ListNode.
        /// </summary>
        public abstract bool Process(ListItemNode node, UIGenerator ui);
Example #15
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled &&
                    d.State.Type.ValueSpace is BooleanSpace &&
                    ((ArrayList)d.ChildSets[0]).Count == 0)
                {
                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    BranchGroupNode bg         = (BranchGroupNode)g;
                    ObjectGroupNode stateGroup = null;

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).IsObject() &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // now we modify the tree to incluce a power panel

                    BranchGroupNode newG = new BranchGroupNode();

                    newG.Parent   = bg;
                    newG.Children = bg.Children;

                    bg.Children = new ArrayList();

                    // make two groups under the common group
                    bg.Children.Add(stateGroup);
                    bg.Children.Add(newG);

                    d.State.InternalController = true;

                    e = newG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = newG;
                    }

                    ArrayList n = (ArrayList)d.DependencySets[0];
                    ArrayList i = (ArrayList)d.DependencySets[1];

                    EqualsDependency equalDep = (EqualsDependency)i[0];
                    if ((bool)equalDep.Value)
                    {
                        n.Add(new EqualsDependency(equalDep.State, "false"));
                    }
                    else
                    {
                        n.Add(new EqualsDependency(equalDep.State, "true"));
                    }

                    OrganizationDecision newDecision = new InternalOverlapOrgDecision(d, d.State, bg.Children, d.DependencySets);
                    g.Decorations.Add(OrganizationDecision.DECISION_KEY, newDecision);

                    // make sure that other rules don't try to reorganize this node
                    d.Handled = true;
                }
            }
        }
Example #16
0
        /*
         * Process Method
         */

        public override void Process(GroupNode g, UIGenerator ui)
        {
            // look for MutualExclusionDecisions

            object o = g.Decorations[MutualExclusionDecision.DECISION_KEY];

            if (o != null && o is MutualExclusionDecision)
            {
                MutualExclusionDecision d = (MutualExclusionDecision)o;

                if (!d.Handled)
                {
                    // this will never occur on an ObjectGroupNode
                    BranchGroupNode bg = (BranchGroupNode)g;

                    // we need a pointer to the GroupNode that contains the state
                    // variable that we are looking at (because tree manipulations
                    // will need to use it)

                    ObjectGroupNode stateGroup = null;

                    IEnumerator e = bg.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        if (((GroupNode)e.Current).IsObject() &&
                            ((ObjectGroupNode)e.Current).Object == d.State)
                        {
                            stateGroup = (ObjectGroupNode)e.Current;
                            break;
                        }
                    }

                    // re-order the tree

                    ArrayList childOrder = new ArrayList();

                    bg.Children.Remove(stateGroup);

                    BranchGroupNode midG = new BranchGroupNode();

                    midG.Children = bg.Children;
                    e             = midG.Children.GetEnumerator();
                    while (e.MoveNext())
                    {
                        ((GroupNode)e.Current).Parent = midG;
                    }

                    bg.Children = new ArrayList();

                    ArrayList dset = (ArrayList)d.ChildSets[0];
                    if (dset.Count > 0)
                    {
                        e = dset.GetEnumerator();
                        while (e.MoveNext())
                        {
                            GroupNode c = (GroupNode)e.Current;

                            c.Parent = bg;

                            midG.Children.Remove(c);
                            bg.Children.Add(c);
                        }
                    }

                    bg.Children.Add(stateGroup);
                    bg.Children.Add(midG);
                    midG.Parent       = bg;
                    stateGroup.Parent = bg;

                    for (int i = 1; i < d.ChildSets.Count; i++)
                    {
                        dset = (ArrayList)d.ChildSets[i];

                        if (dset.Count > 1)
                        {
                            BranchGroupNode newG = new BranchGroupNode();
                            newG.Parent = midG;

                            e = dset.GetEnumerator();
                            while (e.MoveNext())
                            {
                                GroupNode c = (GroupNode)e.Current;

                                c.Parent = newG;

                                midG.Children.Remove(c);
                                newG.Children.Add(c);
                            }

                            childOrder.Insert(i - 1, newG);
                        }
                        else if (dset.Count == 0)
                        {
                            BranchGroupNode newG = new BranchGroupNode();

                            newG.Parent   = midG;
                            newG.Children = new ArrayList();

                            midG.Children.Add(newG);

                            childOrder.Insert(i - 1, newG);
                        }
                        else
                        {
                            childOrder.Insert(i - 1, dset[0]);
                        }
                    }

                    d.DependencySets.RemoveAt(0);

                    OrganizationDecision newDecision = new ExternalOverlapOrgDecision(d, d.State, childOrder, d.DependencySets);
                    midG.Decorations.Add(OrganizationDecision.DECISION_KEY, newDecision);

                    d.Handled = true;
                }
            }
        }
Example #17
0
        public JsonTable buildJsonTable(BaseReport report)
        {
            var table = new JsonTable();

            switch (report.GetType().Name)
            {
            case "StandardReport":
                var data = (StandardReport)report;
                if (data.ResultDataTable.Rows.Count > 0)
                {
                    table.ReportDate = ((DateTime)data.ResultDataTable.Rows[0]["REDATE"]).ToString("yyyy-MM");
                }

                foreach (var column in data.Columns)
                {
                    table.ColumTemplate.Add(new JsonColumn()
                    {
                        ColumnName  = column.ColumnName.ToLower(),
                        ColumnStyle = column.ColumnStyle,
                        ColumnType  = column.ColumnType,
                        Name        = column.Culture == "zh-CN" ? column.ColumnHeaderCN : column.ColumnHeaderEN
                    });
                }

                table.ExtraHeaders = new List <JsonExtraColumn>();
                foreach (var extraHeader in data.ExtraHeaderCollection)
                {
                    table.ExtraHeaders.Add(new JsonExtraColumn()
                    {
                        Name        = extraHeader.Culture == "zh-CN" ? extraHeader.HeaderTextCN : extraHeader.HeaderTextEN,
                        ColumnStyle = extraHeader.HeaderStyle,
                        ColSpan     = extraHeader.HeaderColumnSpan,
                        HeaderLevel = extraHeader.HeaderLevel
                    });
                }

                table.RowData = new List <Dictionary <string, string> >();

                foreach (DataRow row in data.ResultDataTable.Rows)
                {
                    var currentRow = new Dictionary <string, string>();

                    foreach (var column in data.Columns)
                    {
                        if (!currentRow.Keys.Contains(column.ColumnName))
                        {
                            currentRow.Add(column.ColumnName.ToLower(), UIGenerator.FormatCellValue(row, column));
                        }
                    }
                    if (row.Table.Columns.Contains("id"))
                    {
                        currentRow.Add("id", row["id"].ToString());
                    }
                    if (row.Table.Columns.Contains("last_update"))
                    {
                        currentRow.Add("last_update", row["last_update"].ToString());
                    }
                    if (row.Table.Columns.Contains("row_index"))
                    {
                        currentRow.Add("row_index", row["row_index"].ToString());
                    }
                    if (row.Table.Columns.Contains("chart_source"))
                    {
                        currentRow.Add("chart_source", row["chart_source"].ToString());
                    }
                    if (row.Table.Columns.Contains("row_level"))
                    {
                        currentRow.Add("row_level", row["row_level"].ToString());
                    }

                    table.RowData.Add(currentRow);
                }

                break;
            }
            return(table);
        }
Example #18
0
        private List <Dictionary <string, string> > ConvertToRowData(IEnumerable <IssuerFundamental> issuerFundamental, string fundamentalType, string reportType)
        {
            //PID = parent id, IP = is parent id, 0 or 1,IL= indent level , 0, 1, 2, CR= chart row
            List <Dictionary <string, string> > rowData = new List <Dictionary <string, string> >();
            var fieldMapping = _repository.GetFundamentalFiledMapping(fundamentalType);

            PropertyInfo[] properties = typeof(IssuerFundamental).GetProperties();
            var            startYear  = issuerFundamental.Min(f => f.EndDate).Year;
            string         chartRow   = "";

            if (fundamentalType == "tabb")
            {
                chartRow = "Field60";
            }
            else if (fundamentalType == "tacb")
            {
                chartRow = "Field62";
            }
            else if (fundamentalType == "tapb")
            {
                chartRow = "Field50";
            }

            foreach (PropertyInfo p in properties)
            {
                //fields that needn't displaying
                var fieldName = CultureHelper.IsEnglishCulture() ?
                                fieldMapping.Where(f => f.FIELD_NAME == p.Name && f.FUNDAMENATAL_TYPE == fundamentalType).Select(f => f.ENGLISH_NAME).FirstOrDefault()
                                : fieldMapping.Where(f => f.FIELD_NAME == p.Name && f.FUNDAMENATAL_TYPE == fundamentalType).Select(f => f.CHINESE_NAME).FirstOrDefault();

                if (string.IsNullOrEmpty(fieldName))
                {
                    continue;
                }

                var indentLevel = fieldMapping.Where(f => f.FIELD_NAME == p.Name && f.FUNDAMENATAL_TYPE == fundamentalType).Select(f => f.INDENT_LEVEL).FirstOrDefault() ?? 0;
                var is_Parent   = fieldMapping.Where(f => f.FIELD_NAME == p.Name && f.FUNDAMENATAL_TYPE == fundamentalType).Select(f => f.IS_PARENT).FirstOrDefault().ToString();
                var pId         = fieldMapping.Where(f => f.FIELD_NAME == p.Name && f.FUNDAMENATAL_TYPE == fundamentalType).Select(f => f.PARENT_ID).FirstOrDefault().ToString();

                Dictionary <string, string> row = new Dictionary <string, string>();
                row.Add("Item", SetIndent(indentLevel) + fieldName); //add the field name, the first left name column
                row.Add("PID", pId);
                row.Add("IP", is_Parent);
                row.Add("CR", p.Name == chartRow ? (fundamentalType == "tapb" ? fieldName.Substring(2, 3) : fieldName) : "0");

                if (reportType == "Y") //year report
                {
                    for (var i = DateTime.Now.Year - 1; i >= startYear; i--)
                    {
                        var fund  = issuerFundamental.Where(f => f.EndDate.Year == i).FirstOrDefault();
                        var value = fund == null ? null : p.GetValue(fund, null);
                        row.Add("Y" + i.ToString(), value == null ? "" : UIGenerator.FormatCellValue(value, "decimal"));
                    }
                    rowData.Add(row);
                }
                else
                {
                    for (var i = DateTime.Now.Year; i >= startYear; i--)
                    {
                        var funds = issuerFundamental.Where(f => f.EndDate.Year == i).OrderByDescending(f => f.EndDate).ToList(); //add in a year

                        for (var j = 0; j < funds.Count(); j++)
                        {
                            int quarterIndex = 0;
                            int quarter      = Convert.ToInt32(funds.ElementAt(j).EndDate.Month) / 3;

                            switch (quarter)
                            {
                            case 1:
                                quarterIndex = 3;
                                break;

                            case 2:
                                quarterIndex = 2;
                                break;

                            case 3:
                                quarterIndex = 6;
                                break;

                            case 4:
                                quarterIndex = 1;
                                break;

                            default:
                                break;
                            }

                            var fund  = funds.Where(f => f.ReportType == quarterIndex).Select(f => f).FirstOrDefault();
                            var value = fund == null ? null : p.GetValue(fund, null);

                            row.Add("Y" + i.ToString() + "Q" + quarter.ToString(), value == null ? "" : UIGenerator.FormatCellValue(value, "decimal"));
                        }
                    }
                    rowData.Add(row);
                }
            }

            return(rowData);
        }
Example #19
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        public abstract void Process(GroupNode g, UIGenerator ui);
Example #20
0
        /*
         * Member Variables
         */

        /*
         * Constructor
         */

        /*
         * Process Rule Method
         */

        public abstract InterfaceNode Process(LayoutProblem problem, InterfaceNode node, UIGenerator ui);