示例#1
0
        //private void changeMonitor_Tick(object sender, EventArgs e) { UpdateTabStatus(); }

        //private void UpdateTabStatus()
        //{
        //    foreach (var tabIndex in SaveTabs)
        //    {
        //        if (!mainTabControl.TabPages[tabIndex.Key].Text.EndsWith("*") && tabIndex.Value)
        //            mainTabControl.TabPages[tabIndex.Key].Text += "*";
        //    }
        //}

        //public void SetTabStatus(bool isModified)
        //{
        //    var tabIndexCount = SaveTabs.Count();
        //    for (var i = 0; i < tabIndexCount; i++)
        //    {
        //        mainTabControl.TabPages[i].Text = mainTabControl.TabPages[i].Text.Split('*')[0];
        //        SaveTabs[i] = isModified;
        //    }

        //    SaveAlert = false;
        //    SaveStatus = "Changes Saved";
        //}

        internal void LoadTab(List <Sku> items, object filter)
        {
            if (items.Count == 0 || (items.Count > 0 && items[0] == null))
            {
                return;
            }

            var nodeItems = new Dictionary <TaxonomyInfo, List <Sku> >();

            foreach (var sku in items)
            {
                var tax = sku.SkuInfos.Where(a => a.Active).Select(t => t.TaxonomyInfo).FirstOrDefault();
                if (nodeItems.Keys.Contains(tax))
                {
                    if (!nodeItems[tax].Contains(sku))
                    {
                        nodeItems[tax].Add(sku);
                    }
                }
                else
                {
                    nodeItems.Add(tax, new List <Sku> {
                        sku
                    });
                }
            }

            foreach (var node in nodeItems)
            {
                DisplayColumns cols;
                if (_display.Keys.Contains(node.Key))
                {
                    cols = _display[node.Key];
                }
                else
                {
                    cols = new DisplayColumns(new List <string>(), new List <string>(), new Dictionary <string, int>());
                    _display.Add(node.Key, cols);
                }
                var    buildGridView = new BuildDataGridView(node.Key, node.Value, cols);
                string tabName;
                string tooltipText;
                FrmSchemaView.GetTabName(nodeItems.Keys, nodeItems.Keys, out tabName, out tooltipText);
                LoadNewTab(buildGridView, "T:" + tabName,
                           string.Format("{0} node(s):{1}{2}", nodeItems.Count, Environment.NewLine, tooltipText));
            }

            //List<TaxonomyInfo> nodes = new List<TaxonomyInfo>();

            //foreach (var sku in items)
            //{
            //    var tax = sku.SkuInfos.Where(a => a.Active).Select(t => t.TaxonomyInfo).FirstOrDefault();
            //    if (!nodes.Contains(tax))
            //        nodes.Add(tax);
            //}

            //BuildDataGridView buildGridView = new BuildDataGridView(nodes, items);
            //AryaTools.GetTabName(nodes, nodes, out tabName, out tooltipText);
            //LoadNewTab(buildGridView, "T:" + tabName, string.Format("{0} node(s):{1}{2}", nodes.Count, Environment.NewLine, tooltipText));
        }
示例#2
0
文件: FrmTree.cs 项目: ewin66/Arya
        private void LoadTaxonomy(List <TaxonomyInfo> taxonomies)
        {
            var waitkey = FrmWaitScreen.ShowMessage("Generating list of nodes to open");

            var nodesToLoad = new List <TaxonomyInfo>();

            //Vivek - not sure why we need this
            if (taxonomies.Count == 1 && CurrentView == AryaView.SkuView)
            {
                var nodeType = taxonomies.Single().NodeType;
                if (nodeType == "Derived")
                {
                    Query.DisplayCrossListInSkuView(Query.FetchCrossListObject(taxonomies.Single()));
                    FrmWaitScreen.HideMessage(waitkey);
                    return;
                }
            }

            taxonomies.ForEach(
                tax => nodesToLoad.AddRange(tax.GetNodes(IncludeChildren, CurrentView == AryaView.SchemaView)));

            if (nodesToLoad.Count == 0)
            {
                FrmWaitScreen.HideMessage(waitkey);
                MessageBox.Show("There are no SKUs to load.", "Zero SKUs");
                return;
            }
            if (nodesToLoad.Count > 2000)
            {
                FrmWaitScreen.HideMessage(waitkey);
                MessageBox.Show("A database limit does not allow me to load more than 2000 nodes at once.",
                                "Too many nodes");
                return;
            }
            FrmWaitScreen.HideMessage(waitkey);

            // Now generate the name to be shown on the tab
            string tabName, fullTaxList;

            FrmSchemaView.GetTabName(taxonomies, nodesToLoad, out tabName, out fullTaxList);

            Program.WriteToErrorFile(
                string.Format("{0} Opening: {1} in {2} in {3}", DateTime.Now.ToShortTimeString(), tabName,
                              (LoadToOneTab ? "one tab" : "separate tabs"), CurrentView), true);

            if (LoadToOneTab || CurrentView == AryaView.AttributeView)
            {
                TaxonomyInfo currentTaxonomy = null;
                if (nodesToLoad.Count == 1)
                {
                    currentTaxonomy = nodesToLoad.First();
                }

                switch (CurrentView)
                {
                //case AryaView.SkuView:
                //    // TODO: Rewrite load function in Sku View and Attribute View to be able to accept multiple taxonomy nodes
                //    break;

                case AryaView.SchemaView:
                    AryaTools.Instance.Forms.SchemaForm.LoadTab(nodesToLoad.Cast <object>().ToList(), null);
                    break;

                //case AryaView.BuildView:
                //   // MessageBox.Show("Under Construction");
                //    AryaTools.Instance.BuildForm.LoadTab(nodesToLoad.Cast<object>().ToList(), null);
                //    break;

                default:
                    // Get the list of SKUs

                    var nodesToLoadTaxonomIds = nodesToLoad.Select(p => p.ID).ToList();

                    switch (CurrentView)
                    {
                    case AryaView.SkuView:
                    {
                        var skuQuery = from si in AryaTools.Instance.InstanceData.Dc.SkuInfos
                                       where
                                       si.Active && nodesToLoadTaxonomIds.Contains(si.TaxonomyID) &&
                                       si.Sku.SkuType == Framework.Data.AryaDb.Sku.ItemType.Product.ToString()
                                       select si.Sku;

                        AryaTools.Instance.Forms.SkuForm.LoadTab(skuQuery, currentTaxonomy, tabName,
                                                                 fullTaxList);

                        break;
                    }

                    case AryaView.AssetView:
                    {
                        var skuQuery = from si in AryaTools.Instance.InstanceData.Dc.SkuInfos
                                       where
                                       si.Active && nodesToLoadTaxonomIds.Contains(si.TaxonomyID) &&
                                       si.Sku.SkuType == Framework.Data.AryaDb.Sku.ItemType.EnrichmentImage.ToString()
                                       select si.Sku;

                        AryaTools.Instance.Forms.SkuForm.LoadTab(skuQuery, currentTaxonomy, tabName,
                                                                 fullTaxList);

                        break;
                    }

                    case AryaView.AttributeView:

                        //IQueryable<EntityInfo> entityInfoQuery = from ed in AryaTools.Instance.InstanceData.Dc.EntityDatas
                        //                                         join ei in AryaTools.Instance.InstanceData.Dc.EntityInfos on ed.EntityID equals
                        //                                             ei.ID
                        //                                         join si in AryaTools.Instance.InstanceData.Dc.SkuInfos on ei.SkuID equals si.SkuID
                        //                                         where
                        //                                             ed.Active && si.Active &&
                        //                                             nodesToLoadTaxonomIds.Contains(si.TaxonomyID)
                        //                                         select ei;

                        //IQueryable<EntityInfo> entityInfoQuery = from ed in AryaTools.Instance.InstanceData.Dc.EntityDatas
                        //                                         join ei in AryaTools.Instance.InstanceData.Dc.EntityInfos on ed.EntityID equals
                        //                                             ei.ID
                        //                                         join si in AryaTools.Instance.InstanceData.Dc.SkuInfos on ei.SkuID equals si.SkuID
                        //                                         where
                        //                                             ed.Active && si.Active
                        //                                         select ei;

                        //clone the nodesToList collection to remove dependency
                        AryaTools.Instance.Forms.AttributeView.LoadQuery(tabName, nodesToLoad.ToList());
                        break;

                    case AryaView.SchemaView:
                        //Wonder how control got here!!!?
                        break;
                    }
                    break;
                }
            }
            else // load in separate tabs
            {
                var result = DialogResult.None;
                foreach (var tax in nodesToLoad)
                {
                    var currentTaxonomy = tax;
                    if (nodesToLoad.Count <= AryaTools.Instance.InstanceData.CurrentUserProjectsPreferences.TabsThreshold)
                    {
                        switch (CurrentView)
                        {
                        case AryaView.SchemaView:
                            AryaTools.Instance.Forms.SchemaForm.LoadTab(new List <object> {
                                currentTaxonomy
                            }, null);
                            break;

                        default:

                            switch (CurrentView)
                            {
                            case AryaView.SkuView:
                            {
                                var skuQuery =
                                    AryaTools.Instance.InstanceData.Dc.SkuInfos.Where(
                                        si =>
                                        si.Active && si.Sku.SkuType == Framework.Data.AryaDb.Sku.ItemType.Product.ToString() &&
                                        si.TaxonomyID == tax.ID).Select(si => si.Sku);

                                AryaTools.Instance.Forms.SkuForm.LoadTab(skuQuery, tax,
                                                                         currentTaxonomy.TaxonomyData.NodeName, tax.ToString());
                                break;
                            }

                            case AryaView.AssetView:
                            {
                                var skuQuery =
                                    AryaTools.Instance.InstanceData.Dc.SkuInfos.Where(
                                        si =>
                                        si.Active && si.Sku.SkuType == Framework.Data.AryaDb.Sku.ItemType.EnrichmentImage.ToString() &&
                                        si.TaxonomyID == currentTaxonomy.ID).Select(si => si.Sku);

                                AryaTools.Instance.Forms.SkuForm.LoadTab(skuQuery, currentTaxonomy,
                                                                         currentTaxonomy.TaxonomyData.NodeName, currentTaxonomy.ToString());
                                break;
                            }

                            case AryaView.AttributeView:
                            {
                                // TODO: Check attribute view over...
                                var skuQuery =
                                    AryaTools.Instance.InstanceData.Dc.SkuInfos.Where(
                                        si =>
                                        si.Active && si.Sku.SkuType == Framework.Data.AryaDb.Sku.ItemType.Product.ToString() &&
                                        si.TaxonomyID == currentTaxonomy.ID).Select(si => si.Sku);

                                AryaTools.Instance.Forms.AttributeView.LoadQuery(skuQuery,
                                                                                 currentTaxonomy.TaxonomyData.NodeName);
                                break;
                            }

                            case AryaView.SchemaView:
                                //Wonder how control got here!!!?
                                break;
                            }      //end of switch inner
                            break; // Load only the first Node
                        }//end of switch outer
                    } //end: foreach node in the list of nodes to load
                    else
                    {
                        var sModalText =
                            String.Format(
                                "You have chosen to open {0} nodes in separate tabs. This may take some time. Do you still want to open these nodes?",
                                nodesToLoad.Count);
                        Invoke(
                            (MethodInvoker)
                            delegate { result = MessageBox.Show(this, sModalText, "Alert", MessageBoxButtons.YesNo); });
                        if (result == DialogResult.No)
                        {
                            break;
                        }
                        else
                        {
                            foreach (var taxonomy in nodesToLoad)
                            {
                                currentTaxonomy = taxonomy;
                                switch (CurrentView)
                                {
                                case AryaView.SkuView:
                                {
                                    var skuQuery =
                                        AryaTools.Instance.InstanceData.Dc.SkuInfos.Where(
                                            si =>
                                            si.Active && si.Sku.SkuType == Framework.Data.AryaDb.Sku.ItemType.Product.ToString() &&
                                            si.TaxonomyID == currentTaxonomy.ID).Select(si => si.Sku);
                                    AryaTools.Instance.Forms.SkuForm.LoadTab(skuQuery, currentTaxonomy, currentTaxonomy.TaxonomyData.NodeName, currentTaxonomy.ToString());
                                    break;
                                }

                                case AryaView.SchemaView:
                                {
                                    AryaTools.Instance.Forms.SchemaForm.LoadTab(new List <object> {
                                            currentTaxonomy
                                        }, null);
                                    break;
                                }
                                }
                            }
                        }
                        break;
                    }
                }
            }
            //end: load in one tab vs. load in separate tabs
        }