Пример #1
0
        } // setupPhraseView()

        private void _setupClassificationView(CswNbtView View, CswCommaDelimitedString SelectedClassIds)
        {
            CswNbtMetaDataObjectClass GhsClassOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.GHSClassificationClass);
            CswNbtMetaDataNodeType    GhsClassNT = GhsClassOC.FirstNodeType;

            View.SetVisibility(CswEnumNbtViewVisibility.Hidden, null, null);
            View.ViewMode = CswEnumNbtViewRenderingMode.Grid;
            View.Root.ChildRelationships.Clear();
            if (SelectedClassIds.Count > 0)
            {
                CswNbtViewRelationship ClassVR = View.AddViewRelationship(GhsClassOC, false);
                foreach (string ClassId in SelectedClassIds)
                {
                    CswPrimaryKey ClassPk = new CswPrimaryKey();
                    ClassPk.FromString(ClassId);
                    ClassVR.NodeIdsToFilterIn.Add(ClassPk);
                }

                View.AddViewProperty(ClassVR, GhsClassOC.getObjectClassProp(CswNbtObjClassGHSClassification.PropertyName.Category));
                if (null != GhsClassNT)
                {
                    CswNbtMetaDataNodeTypeProp LanguageProp = GhsClassNT.getNodeTypePropByObjectClassProp(_getLanguageForTranslation());
                    CswNbtViewProperty         LanguageVP   = View.AddViewProperty(ClassVR, LanguageProp);
                    LanguageVP.Width = 100;
                }
            } // if( SelectedClassIds.Count > 0 )
            View.SaveToCache(IncludeInQuickLaunch: false, UpdateCache: true, KeepInQuickLaunch: false);
        }     // _setupClassificationView()
Пример #2
0
        } // _addNodeToData()

        public static void UploadBulkEditData(ICswResources CswResources, BulkEditReturn ret, BulkEditUpload Params)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswTempFile temp     = new CswTempFile(CswResources);
            string      tempPath = temp.saveToTempFile(Params.PostedFile.InputStream, CswResources.AccessId + "_bulkedit_" + DateTime.Now.Ticks.ToString());

            DataSet uploadDataSet = CswNbtImportTools.ReadExcel(tempPath);

            if (uploadDataSet.Tables.Count > 0)
            {
                DataTable uploadTable = uploadDataSet.Tables[0];

                CswNbtBatchOpBulkEdit batch     = new CswNbtBatchOpBulkEdit(NbtResources);
                CswNbtObjClassBatchOp batchNode = batch.makeBatchOp(uploadTable);

                CswNbtView BatchOpsView = new CswNbtView((CswNbtResources)CswResources);
                BatchOpsView.ViewName = "New Batch Operations";
                BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(batchNode.NodeType, false);
                BatchRel.NodeIdsToFilterIn.Add(batchNode.NodeId);

                BatchOpsView.SaveToCache(true);
                ret.ViewId = BatchOpsView.SessionViewId.ToString();
            } // if( uploadDataSet.Tables.Count > 0 )
        }     // UploadBulkEditData()
Пример #3
0
        /// <summary>
        /// Get a landing page for a Material
        /// </summary>
        public static JObject getLandingPageData(CswNbtResources NbtResources, CswNbtNode MaterialNode, CswNbtView MaterialNodeView = null)
        {
            JObject Ret = new JObject();

            if (null != MaterialNode)
            {
                MaterialNodeView = MaterialNodeView ?? CswNbtPropertySetMaterial.getMaterialNodeView(NbtResources, MaterialNode);
                MaterialNodeView.SaveToCache(IncludeInQuickLaunch: false);

                Ret["ActionId"] = NbtResources.Actions[CswEnumNbtActionName.Create_Material].ActionId.ToString();
                //Used for Tab and Button items
                Ret["NodeId"]     = MaterialNode.NodeId.ToString();
                Ret["NodeViewId"] = MaterialNodeView.SessionViewId.ToString();
                //Used for node-specific Add items
                Ret["RelatedNodeId"]   = MaterialNode.NodeId.ToString();
                Ret["RelatedNodeName"] = MaterialNode.NodeName;
                //If (and when) action landing pages are slated to be roleId-specific, remove this line
                Ret["isConfigurable"] = NbtResources.CurrentNbtUser.IsAdministrator();
                //Used for viewing new material
                Ret["ActionLinks"] = new JObject();
                string ActionLinkName = MaterialNode.NodeId.ToString();
                Ret["ActionLinks"][ActionLinkName]           = new JObject();
                Ret["ActionLinks"][ActionLinkName]["Text"]   = MaterialNode.NodeName;
                Ret["ActionLinks"][ActionLinkName]["ViewId"] = MaterialNodeView.SessionViewId.ToString();
            }
            return(Ret);
        }
Пример #4
0
        //Here we take the Request base and, for each requestItem type, add them to the Cart view
        public CswNbtView getOpenCartsView(bool IncludeItemProperties = true)
        {
            CswNbtView             Ret    = getRequestViewBase(IncludeDefaultFilters: true, LimitToUnsubmitted: true);
            CswNbtViewRelationship RootVr = Ret.Root.ChildRelationships[0];

            if (null != _CurrentRequestNode)
            {
                RootVr.NodeIdsToFilterIn.Clear();
                RootVr.NodeIdsToFilterIn.Add(_CurrentRequestNode.NodeId);
            }
            CswNbtMetaDataObjectClassProp RequestOcp     = _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.Request);
            CswNbtViewRelationship        RequestItemRel = Ret.AddViewRelationship(RootVr,
                                                                                   CswEnumNbtViewPropOwnerType.Second,
                                                                                   RequestOcp, IncludeDefaultFilters: true);

            if (IncludeItemProperties)
            {
                CswNbtViewProperty ItemNumberVP = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.ItemNumber), 1);
                ItemNumberVP.Width = 10;
                CswNbtViewProperty DescriptionVP = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.Description), 2);
                DescriptionVP.Width = 50;
                CswNbtViewProperty NeededByVP = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.NeededBy), 3);
                CswNbtViewProperty LocationVP = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.Location), 4);
                LocationVP.Width = 40;
                CswNbtViewProperty InventoryGroupVP = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.InventoryGroup), 5);
                InventoryGroupVP.Width = 20;
                CswNbtViewProperty RequestedForVP = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.RequestedFor), 6);
                CswNbtViewProperty RequestTypeVP  = Ret.AddViewProperty(RequestItemRel, _RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.RequestType), 7);
                RequestTypeVP.Width = 20;
            }

            Ret.SaveToCache(IncludeInQuickLaunch: false);
            return(Ret);
        }
Пример #5
0
        /// <summary>
        /// Get a landing page for a Material
        /// </summary>
        public static JObject getLandingPageData(CswNbtResources NbtResources, CswNbtNode MaterialNode, bool UseBatchOp, Collection <CswPrimaryKey> ContainerIds, CswNbtView MaterialNodeView = null)
        {
            JObject Ret = new JObject();

            if (null != MaterialNode)
            {
                MaterialNodeView = MaterialNodeView ?? CswNbtPropertySetMaterial.getMaterialNodeView(NbtResources, MaterialNode, "Received: ");
                MaterialNodeView.SaveToCache(IncludeInQuickLaunch: false);

                Ret["ActionId"] = NbtResources.Actions[CswEnumNbtActionName.Receiving].ActionId.ToString();

                //Used for Tab and Button items
                Ret["NodeId"]     = MaterialNode.NodeId.ToString();
                Ret["NodeViewId"] = MaterialNodeView.SessionViewId.ToString();

                //Used for node-specific Add items
                Ret["RelatedNodeId"]   = MaterialNode.NodeId.ToString();
                Ret["RelatedNodeName"] = MaterialNode.NodeName;

                //If (and when) action landing pages are slated to be roleId-specific, remove this line
                Ret["isConfigurable"] = NbtResources.CurrentNbtUser.IsAdministrator();

                //Used for viewing new material
                Ret["ActionLinks"] = new JObject();
                string ActionLinkName = MaterialNode.NodeId.ToString();
                Ret["ActionLinks"][ActionLinkName]           = new JObject();
                Ret["ActionLinks"][ActionLinkName]["Text"]   = MaterialNode.NodeName;
                Ret["ActionLinks"][ActionLinkName]["ViewId"] = MaterialNodeView.SessionViewId.ToString();

                if (UseBatchOp)
                {
                    Ret["Title"] = "The containers for this material have been scheduled for creation, but may not be available immediately. Click 'View Batch Operations' to check their progress.";
                    Ret["ActionLinks"]["BatchOps"] = new JObject();
                    Ret["ActionLinks"]["BatchOps"]["ActionName"] = "These containers will be created in a batch operation and may not be immediately available. You can check the progress of their creation below:";
                    Ret["ActionLinks"]["BatchOps"]["Text"]       = "View Batch Operations";
                    Ret["ActionLinks"]["BatchOps"]["ViewId"]     = NbtResources.ViewSelect.getViewIdByName("My Batch Operations", CswEnumNbtViewVisibility.Global, null, null).ToString();
                }
                else
                {
                    CswNbtMetaDataNodeType ContainerNT = NbtResources.MetaData.getNodeType("Container");
                    if (null != ContainerNT)
                    {
                        CswNbtView NewContainersView = new CswNbtView(NbtResources);
                        NewContainersView.ViewName = "New Containers";
                        CswNbtViewRelationship ContainerVr = NewContainersView.AddViewRelationship(ContainerNT, true);
                        ContainerVr.NodeIdsToFilterIn = ContainerIds;
                        NewContainersView.SaveToCache(false);

                        Ret["ActionLinks"]["NewContainers"]           = new JObject();
                        Ret["ActionLinks"]["NewContainers"]["Text"]   = "View Received Containers";
                        Ret["ActionLinks"]["NewContainers"]["ViewId"] = NewContainersView.SessionViewId.ToString();;
                    }
                }
            }
            return(Ret);
        }
Пример #6
0
        public static void finishMerge(ICswResources CswResources, MergeFinishReturn Return, MergeChoicesRequest Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswNbtActMerge Merge = new CswNbtActMerge(NbtResources);
            CswNbtView     view  = Merge.finishMerge(Request.Choices);

            view.SaveToCache(IncludeInQuickLaunch: false);
            Return.Data.ViewId = view.SessionViewId.ToString();
        } // finishMerge()
Пример #7
0
        public static void getLocationTree(ICswResources CswResources, Contract.Response Response, object Request)
        {
            CswNbtResources Resources = (CswNbtResources)CswResources;

            CswNbtView View = new CswNbtView(Resources);

            CswNbtObjClassLocation.makeLocationsTreeView(ref View, Resources);
            View.SaveToCache(false, false);
            Response.Data.ViewId = View.SessionViewId;
        } //getLocationTree()
Пример #8
0
        public Cart getCart(Cart Cart, bool CalculateCounts = false)
        {
            CswNbtObjClassRequest NodeAsRequest = getCurrentRequestNode();

            if (null != NodeAsRequest)
            {
                Cart.CurrentRequest = new CswNbtNode.Node(NodeAsRequest.Node);
            }

            CswNbtView PendingItemsView = getPendingItemsView();

            PendingItemsView.SaveToCache(IncludeInQuickLaunch: false);
            Cart.PendingItemsView = PendingItemsView;

            CswNbtView FavoritesView = getFavoriteRequestNamesView();

            FavoritesView.SaveToCache(IncludeInQuickLaunch: false);
            Cart.FavoritesView = FavoritesView;

            CswNbtView SubmittedItems = getSubmittedRequestItemsView();

            SubmittedItems.SaveToCache(IncludeInQuickLaunch: false);
            Cart.SubmittedItemsView = SubmittedItems;

            CswNbtView RecurringItems = getUsersRecurringRequestItemsView();

            RecurringItems.SaveToCache(IncludeInQuickLaunch: false);
            Cart.RecurringItemsView = RecurringItems;

            CswNbtView FavoriteItems = getFavoriteRequestsItemsView();

            FavoriteItems.SaveToCache(IncludeInQuickLaunch: false);
            Cart.FavoriteItemsView = FavoriteItems;

            Cart.CopyableRequestTypes = new Collection <String>
            {
                CswNbtObjClassRequestItem.Types.EnterprisePart,
                CswNbtObjClassRequestItem.Types.MaterialBulk,
                CswNbtObjClassRequestItem.Types.MaterialSize
            };

            Cart.Counts = CswNbtObjClassUser.getCurrentUserCache(_CswNbtResources).CartCounts;



            //if( CalculateCounts )
            //{
            //    //This is expensive and we can do it in the next async request
            //    Cart.Counts.PendingRequestItems = getCartContentCount();
            //    Cart.Counts.SubmittedRequestItems = _getItemCount( SubmittedItems );
            //    Cart.Counts.RecurringRequestItems = _getItemCount( RecurringItems );
            //    Cart.Counts.FavoriteRequestItems = _getItemCount( FavoriteItems );
            //}
            return(Cart);
        }
Пример #9
0
        } //ctor

        public JObject runGrid(string Title, bool IncludeInQuickLaunch, bool GetAllRowsNow = false, bool IsPropertyGrid = false, string GroupByCol = "", Int32 ResultsLimit = Int32.MinValue)
        {
            _View.SaveToCache(IncludeInQuickLaunch);
            ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false, PerLevelNodeLimit: ResultsLimit);

            if (String.IsNullOrEmpty(Title))
            {
                Title = _View.ViewName;
            }
            return(_CswNbtGrid.TreeToJson(Title, _View, Tree, IsPropertyGrid: (IsPropertyGrid || _View.Visibility == CswEnumNbtViewVisibility.Property), GroupByCol: GroupByCol));
        } // runGrid()
Пример #10
0
        } // _applyPropJson

        /// <summary>
        /// Creates a temporary node of the given NodeTypeId and returns a view containing the temp node
        /// </summary>
        /// <param name="_CswResources">Resources</param>
        /// <param name="Response">Repsonse Object containing the ViewId</param>
        /// <param name="NodeTypeId">NodeTypeId of which to create a temp node</param>
        public static void createTempNode(ICswResources _CswResources, CswNbtViewIdReturn Response, string NodeTypeId)
        {
            CswNbtResources        _CswNbtResources = (CswNbtResources)_CswResources;
            CswNbtMetaDataNodeType NT       = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(NodeTypeId));
            CswNbtNode             TempNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(NT.NodeTypeId, null, true);
            CswNbtView             TempView = TempNode.getViewOfNode(false);

            TempView.Root.ChildRelationships[0].AllowAdd = true;
            TempView.IncludeTempNodes = true;
            TempView.SaveToCache(false);
            Response.Data.ViewId = TempView.SessionViewId.ToString();
        }
Пример #11
0
        public static void RunStructureSearch(ICswResources CswResources, StructureSearchDataReturn Return, StructureSearchViewData StructureSearchData)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;
            string          molData      = StructureSearchData.molString;
            bool            exact        = StructureSearchData.exact;

            Collection <CswPrimaryKey> results = new Collection <CswPrimaryKey>();

            //If the DirectStructureSearch module is enabled, use AcclDirect to run a search. Otherwise use the legacy code
            if (NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch))
            {
                DataTable resultsTbl = NbtResources.AcclDirect.RunStructureSearch(molData, exact);
                foreach (DataRow row in resultsTbl.Rows)
                {
                    results.Add(new CswPrimaryKey("nodes", CswConvert.ToInt32(row["nodeid"])));
                }
            }
            else
            {
                Dictionary <int, string> resultsDict = NbtResources.StructureSearchManager.RunSearch(molData, exact);
                foreach (int nodeidPk in resultsDict.Keys)
                {
                    results.Add(new CswPrimaryKey("nodes", nodeidPk));
                }
            }
            CswNbtView searchView = new CswNbtView(NbtResources);

            searchView.SetViewMode(CswEnumNbtViewRenderingMode.Table);
            searchView.Category = "Recent";
            searchView.ViewName = "Structure Search Results";

            if (results.Count > 0)
            {
                CswNbtMetaDataObjectClass     materialOC = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass);
                CswNbtMetaDataObjectClassProp molCOP     = materialOC.getObjectClassProp(CswNbtObjClassChemical.PropertyName.Structure);
                CswNbtViewRelationship        parent     = searchView.AddViewRelationship(materialOC, false);
                searchView.AddViewProperty(parent, molCOP);

                foreach (CswPrimaryKey nodeId in results)
                {
                    parent.NodeIdsToFilterIn.Add(nodeId);
                }
            }

            searchView.SaveToCache(false);

            StructureSearchData.viewId   = searchView.SessionViewId.ToString();
            StructureSearchData.viewMode = searchView.ViewMode.ToString();
            Return.Data = StructureSearchData;
        }
Пример #12
0
        /// <summary>
        /// Gets the url for the active C of A Document attached to this ReceiptLot node.
        /// </summary>
        /// <param name="ButtonData">Data required for the client to open the file</param>
        public void getCofA(NbtButtonData ButtonData)
        {
            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.ManufacturerLotInfo))
            {
                if (ButtonData.SelectedText.Equals(PropertyName.ViewCofA))
                {
                    CswNbtObjClassCofADocument CofADoc = CswNbtObjClassCofADocument.getActiveCofADocument(_CswNbtResources, NodeId);
                    if (null != CofADoc)
                    {
                        string url = "";
                        switch (CofADoc.FileType.Value)
                        {
                        case CswNbtPropertySetDocument.CswEnumDocumentFileTypes.File:
                            url = CswNbtNodePropBlob.getLink(CofADoc.File.JctNodePropId, CofADoc.NodeId);
                            break;

                        case CswNbtPropertySetDocument.CswEnumDocumentFileTypes.Link:
                            url = CswNbtNodePropLink.GetFullURL(CofADoc.Link.Prefix, CofADoc.Link.Href, CofADoc.Link.Suffix);
                            break;
                        }
                        ButtonData.Data["url"] = url;
                        ButtonData.Action      = CswEnumNbtButtonAction.popup;
                    }
                    else
                    {
                        ButtonData.Message = "There are no active C of A assigned to this " + NodeType.NodeTypeName;
                        ButtonData.Action  = CswEnumNbtButtonAction.nothing;
                    }
                }
                else
                {
                    CswNbtView AssignedCofADocsView = CswNbtObjClassCofADocument.getAssignedCofADocumentsView(_CswNbtResources, NodeId);
                    if (null != AssignedCofADocsView)
                    {
                        AssignedCofADocsView.SaveToCache(IncludeInQuickLaunch: false, UpdateCache: true);
                        ButtonData.Data["viewid"]     = AssignedCofADocsView.SessionViewId.ToString();
                        ButtonData.Data["title"]      = AssignedCofADocsView.ViewName;
                        ButtonData.Data["nodeid"]     = NodeId.ToString();
                        ButtonData.Data["nodetypeid"] = NodeTypeId.ToString();
                        ButtonData.Action             = CswEnumNbtButtonAction.griddialog;
                    }
                    else
                    {
                        ButtonData.Message = "Could not find the Assigned C of A prop";
                        ButtonData.Action  = CswEnumNbtButtonAction.nothing;
                    }
                }
            }
        }
Пример #13
0
        protected override void afterPopulateProps()
        {
            LabelCodes.InitOptions      = _initGhsPhraseOptions;
            Classifications.InitOptions = _initGhsClassificationOptions;

            AddLabelCodes.SetOnPropChange(OnAddLabelCodesPropChange);
            Pictograms.SetOnPropChange(OnPictorgramsChange);

            LabelCodesGrid.SetOnBeforeRender(delegate(CswNbtNodeProp Prop)
            {
                CswNbtNodePropGrid PropAsGrid = (CswNbtNodePropGrid)Prop;
                CswNbtView UpdatedPhraseView  = setupPhraseView(PropAsGrid.View, LabelCodes.Value);
                UpdatedPhraseView.SaveToCache(IncludeInQuickLaunch: false, UpdateCache: true, KeepInQuickLaunch: false);
            });

            ClassificationsGrid.SetOnBeforeRender(delegate(CswNbtNodeProp Prop)
            {
                CswNbtNodePropGrid PropAsGrid = (CswNbtNodePropGrid)Prop;
                _setupClassificationView(PropAsGrid.View, Classifications.Value);
            });

            SignalWord.SetOnBeforeRender(delegate(CswNbtNodeProp Prop)
            {
                CswNbtNodePropRelationship PropAsRelationship     = (CswNbtNodePropRelationship)Prop;
                Dictionary <CswPrimaryKey, string> TranslatedOpts = new Dictionary <CswPrimaryKey, string>();
                ICswNbtTree tree = _CswNbtResources.Trees.getTreeFromView(PropAsRelationship.View, true, false, false);
                int count        = tree.getChildNodeCount();
                for (int i = 0; i < count; i++)
                {
                    tree.goToNthChild(i);
                    CswNbtObjClassGHSSignalWord SignalWordNode = tree.getNodeForCurrentPosition();
                    string TranslatedText = SignalWordNode.Node.Properties[_getLanguageForTranslation()].AsText.Text;
                    TranslatedOpts.Add(SignalWordNode.NodeId, TranslatedText);
                    tree.goToParentNode();
                }

                PropAsRelationship.SetOptionsOverride(TranslatedOpts);
                if (CswTools.IsPrimaryKey(PropAsRelationship.RelatedNodeId))
                {
                    CswNbtObjClassGHSSignalWord Selected = _CswNbtResources.Nodes[PropAsRelationship.RelatedNodeId];
                    string TranslantedText = Selected.Node.Properties[_getLanguageForTranslation()].AsText.Text;
                    Selected.Node.NodeName = (false == string.IsNullOrEmpty(TranslantedText) ? TranslantedText : Selected.English.Text);
                }
            });
        } //afterPopulateProps()
        public JObject futureScheduling(CswCommaDelimitedString SelectedGeneratorNodeKeys, DateTime EndDate)
        {
            JObject ret = new JObject();

            CswNbtActGenerateFutureNodes CswNbtActGenerateFutureNodes = new CswNbtActGenerateFutureNodes(_CswNbtResources);

            Collection <CswNbtObjClassBatchOp> BatchNodes = new Collection <CswNbtObjClassBatchOp>();

            foreach (string NodeKeyStr in SelectedGeneratorNodeKeys)
            {
                CswNbtNodeKey CurrentNodeKey       = new CswNbtNodeKey(NodeKeyStr);
                CswNbtNode    CurrentGeneratorNode = _CswNbtResources.Nodes[CurrentNodeKey.NodeId];
                BatchNodes.Add(CswNbtActGenerateFutureNodes.makeNodesBatch(CurrentGeneratorNode, EndDate));
            }//iterate selected Generator notes

            if (BatchNodes.Count > 0)
            {
                ret["result"] = BatchNodes.Count.ToString();

                CswNbtView BatchOpsView = new CswNbtView(_CswNbtResources);
                BatchOpsView.ViewName = "New Batch Operations";
                BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(BatchNodes[0].NodeType, false);
                foreach (CswNbtObjClassBatchOp BatchNode in BatchNodes)
                {
                    if (BatchNode != null)
                    {
                        BatchRel.NodeIdsToFilterIn.Add(BatchNode.NodeId);
                    }
                }

                CswNbtWebServiceTree ws = new CswNbtWebServiceTree(_CswNbtResources, BatchOpsView);
                ret["treedata"] = ws.runTree(null, null, false, true, string.Empty);

                BatchOpsView.SaveToCache(true);
                ret["sessionviewid"] = BatchOpsView.SessionViewId.ToString();
                ret["viewmode"]      = BatchOpsView.ViewMode.ToString();
            }

            return(ret);
        } // futureScheduling()
Пример #15
0
        /// <summary>
        /// Get the view to drive the Supplier picklist in the Create Material wizard
        /// </summary>
        public CswNbtView getMaterialSuppliersView()
        {
            CswNbtView Ret = new CswNbtView(_CswNbtResources);
            CswNbtMetaDataObjectClass VendorOc   = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.VendorClass);
            CswNbtViewRelationship    SupplierVr = Ret.AddViewRelationship(VendorOc, IncludeDefaultFilters: true);

            //This matches the MLM module event logic, but it may need adjustment down the line
            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.MLM))
            {
                CswNbtMetaDataObjectClassProp CoorporateOcp = VendorOc.getObjectClassProp(CswNbtObjClassVendor.PropertyName.VendorTypeName);
                Ret.AddViewPropertyAndFilter(SupplierVr,
                                             MetaDataProp: CoorporateOcp,
                                             Value: CswNbtObjClassVendor.VendorTypes.Corporate,
                                             FilterMode: CswEnumNbtFilterMode.Equals);
            }

            Ret.ViewName = "Create Material Supplier";
            //Case 30335 - This is required for MLM to filter to Corporate Vendors
            Ret.SaveToCache(IncludeInQuickLaunch: false);
            return(Ret);
        }
Пример #16
0
        } //afterPopulateProps()

        protected override bool onButtonClick(NbtButtonData ButtonData)
        {
            if (null != ButtonData && null != ButtonData.NodeTypeProp)
            {
                string OCPPropName = ButtonData.NodeTypeProp.getObjectClassPropName();
                switch (OCPPropName)
                {
                case PropertyName.ViewNodesButton:
                    CswNbtView DefaultView = RelationalNodeType.CreateDefaultView(includeDefaultFilters: true);
                    DefaultView.ViewName = NodeTypeName.Text + " Default View";
                    DefaultView.SaveToCache(IncludeInQuickLaunch: true);

                    ButtonData.Action           = CswEnumNbtButtonAction.loadView;
                    ButtonData.Data["viewid"]   = DefaultView.SessionViewId.ToString();
                    ButtonData.Data["viewmode"] = DefaultView.ViewMode.ToString();
                    ButtonData.Data["type"]     = "view";
                    break;
                }
            }
            return(true);
        }
Пример #17
0
        }//searchLocations()

        private CswNbtView _getLocationsView(string ViewId, string FullPathFilter = "")
        {
            CswNbtView Ret = new CswNbtView();

            if (string.IsNullOrEmpty(ViewId))
            {
                Ret = CswNbtNodePropLocation.LocationPropertyView(_CswNbtResources, null, ResultMode: CswEnumNbtFilterResultMode.Disabled, FullPathFilter: FullPathFilter);
                Ret.SaveToCache(false);
                ViewId = Ret.SessionViewId.ToString();
            }

            CswNbtSessionDataId SessionViewId = new CswNbtSessionDataId(ViewId);

            if (SessionViewId.isSet())
            {
                Ret = _CswNbtResources.ViewSelect.getSessionView(SessionViewId);
                CswNbtMetaDataObjectClass     LocationOC          = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass);
                CswNbtMetaDataObjectClassProp LocationFullPathOCP = LocationOC.getObjectClassProp(CswNbtObjClassLocation.PropertyName.FullPath);
                if (false == string.IsNullOrEmpty(FullPathFilter))
                {
                    CswNbtViewRoot.forEachProperty forEachPropDelegate = delegate(CswNbtViewProperty ViewProp)
                    {
                        if (ViewProp.ObjectClassPropId == LocationFullPathOCP.PropId)
                        {
                            Ret.AddViewPropertyFilter(ViewProp,
                                                      Conjunction: CswEnumNbtFilterConjunction.And,
                                                      FilterMode: CswEnumNbtFilterMode.Contains,
                                                      SubFieldName: CswEnumNbtSubFieldName.Value,
                                                      Value: FullPathFilter);
                        }
                    };
                    Ret.Root.eachRelationship(null, forEachPropDelegate);
                }
            }

            return(Ret);
        }//_getLocationsView()
Пример #18
0
        public static void getSizes(ICswResources CswResources, NodeResponse Response, CswNbtNode.Node Request)
        {
            if (null != CswResources)
            {
                CswNbtResources NbtResources = (CswNbtResources)CswResources;

                CswPrimaryKey pk = CswConvert.ToPrimaryKey(Request.NodeId);
                if (CswTools.IsPrimaryKey(pk))
                {
                    CswNbtMetaDataObjectClass     sizeOC      = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.SizeClass);
                    CswNbtMetaDataObjectClassProp materialOCP = sizeOC.getObjectClassProp(CswNbtObjClassSize.PropertyName.Material);

                    CswNbtView             sizesView = new CswNbtView(NbtResources);
                    CswNbtViewRelationship parent    = sizesView.AddViewRelationship(sizeOC, true);
                    sizesView.AddViewPropertyAndFilter(parent,
                                                       MetaDataProp: materialOCP,
                                                       Value: pk.PrimaryKey.ToString(),
                                                       SubFieldName: CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID,
                                                       FilterMode: CswEnumNbtFilterMode.Equals);

                    ICswNbtTree tree = NbtResources.Trees.getTreeFromView(sizesView, true, false, false);
                    for (int i = 0; i < tree.getChildNodeCount(); i++)
                    {
                        tree.goToNthChild(i);
                        Response.Data.Nodes.Add(new CswNbtNode.Node(null)
                        {
                            NodeId   = tree.getNodeIdForCurrentPosition(),
                            NodeName = tree.getNodeNameForCurrentPosition()
                        });
                        tree.goToParentNode();
                    }

                    sizesView.SaveToCache(false, true);
                    Response.Data.ViewId = sizesView.SessionViewId.ToString();
                }
            }
        }
        private string _getViewForAllDispenseContainers()
        {
            Collection <CswPrimaryKey> SourceContainerRoot = new Collection <CswPrimaryKey>();

            SourceContainerRoot.Add(_SourceContainer.NodeId);
            CswNbtView DispenseContainerView = new CswNbtView(_CswNbtResources);

            DispenseContainerView.ViewName = "Containers Dispensed at " + DateTime.Now.ToShortTimeString();

            CswNbtMetaDataObjectClass ContainerOc      = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerClass);
            CswNbtViewRelationship    RootRelationship = DispenseContainerView.AddViewRelationship(ContainerOc, false);

            RootRelationship.NodeIdsToFilterIn = SourceContainerRoot;

            if (_ContainersToView.Count > 0)
            {
                CswNbtMetaDataObjectClassProp SourceContainerProp = ContainerOc.getObjectClassProp(CswNbtObjClassContainer.PropertyName.SourceContainer);
                CswNbtViewRelationship        ChildRelationship   = DispenseContainerView.AddViewRelationship(RootRelationship, CswEnumNbtViewPropOwnerType.Second, SourceContainerProp, false);
                ChildRelationship.NodeIdsToFilterIn = _ContainersToView;
            }

            DispenseContainerView.SaveToCache(false);
            return(DispenseContainerView.SessionViewId.ToString());
        }
Пример #20
0
        } // _treeNodeJObject()

        public JObject runTree(CswPrimaryKey IncludeNodeId, CswNbtNodeKey IncludeNodeKey, bool IncludeNodeRequired, bool IncludeInQuickLaunch, string DefaultSelect, string AccessedByObjClassId = "")
        {
            JObject ReturnObj = new JObject();

            if (null != _View)  //&& ( _View.ViewMode == NbtViewRenderingMode.Tree || _View.ViewMode == NbtViewRenderingMode.List ) )
            {
                ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false);
                _View.SaveToCache(IncludeInQuickLaunch);

                if (IncludeNodeId != null && IncludeNodeId.PrimaryKey != Int32.MinValue && IncludeNodeKey == null)
                {
                    IncludeNodeKey = Tree.getNodeKeyByNodeId(IncludeNodeId);
                    if (IncludeNodeRequired && IncludeNodeKey == null)
                    {
                        CswNbtMetaDataNodeType IncludeKeyNodeType = _CswNbtResources.Nodes[IncludeNodeId].getNodeType();
                        _View          = IncludeKeyNodeType.CreateDefaultView();
                        _View.ViewName = "New " + IncludeKeyNodeType.NodeTypeName;
                        _View.Root.ChildRelationships[0].NodeIdsToFilterIn.Add(IncludeNodeId);
                        _View.SaveToCache(IncludeInQuickLaunch);   // case 22713
                        ReturnObj["newviewid"]   = _View.SessionViewId.ToString();
                        ReturnObj["newviewmode"] = _View.ViewMode.ToString();
                        Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false);
                    }
                }
                if (IncludeNodeRequired && IncludeNodeKey != null && Tree.getNodeKeyByNodeId(IncludeNodeKey.NodeId) == null)
                {
                    CswNbtMetaDataNodeType IncludeKeyNodeType = _CswNbtResources.MetaData.getNodeType(IncludeNodeKey.NodeTypeId);
                    _View          = IncludeKeyNodeType.CreateDefaultView();
                    _View.ViewName = "New " + IncludeKeyNodeType.NodeTypeName;
                    _View.Root.ChildRelationships[0].NodeIdsToFilterIn.Add(IncludeNodeKey.NodeId);
                    _View.SaveToCache(IncludeInQuickLaunch);   // case 22713
                    ReturnObj["newviewid"]   = _View.SessionViewId.ToString();
                    ReturnObj["newviewmode"] = _View.ViewMode.ToString();
                    Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false);
                }

                Tree.goToRoot();
                bool HasResults = (Tree.getChildNodeCount() > 0);
                ReturnObj["result"] = HasResults.ToString().ToLower();
                ReturnObj["types"]  = getTypes();
                //ReturnObj["pagesize"] = _CswNbtResources.CurrentNbtUser.PageSize.ToString();

                if (HasResults)
                {
                    // Determine the default selected node:
                    // If the requested node to select is on the tree, return it.
                    // If the requested node to select is not on the tree, return the first child of the root.
                    if (IncludeNodeKey != null)
                    {
                        Tree.makeNodeCurrent(IncludeNodeKey);
                        if (Tree.isCurrentNodeDefined())
                        {
                            //ReturnObj["selectid"] = _IdPrefix + IncludeNodeKey.NodeId.ToString();
                            ReturnObj["selectid"] = _IdPrefix + IncludeNodeKey.ToString();
                        }
                    }
                    if (ReturnObj["selectid"] == null)
                    {
                        switch (DefaultSelect)
                        {
                        case "none":
                            break;

                        case "root":
                            ReturnObj["selectid"] = _IdPrefix + "root";
                            break;

                        case "firstchild":
                            Tree.goToRoot();
                            CswNbtNodeKey CurrentKey = Tree.getNodeKeyForCurrentPosition();
                            while (CurrentKey != null &&
                                   CurrentKey.NodeSpecies != CswEnumNbtNodeSpecies.Plain &&
                                   Tree.getChildNodeCount() > 0)
                            {
                                Tree.goToNthChild(0);
                                CurrentKey = Tree.getNodeKeyForCurrentPosition();
                            }
                            if (CurrentKey != null && CurrentKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain)
                            {
                                // ReturnObj["selectid"] = _IdPrefix + Tree.getNodeIdForCurrentPosition().ToString();
                                ReturnObj["selectid"] = _IdPrefix + CurrentKey.ToString();
                            }
                            break;
                        } // switch( DefaultSelect )
                    }     // if( ReturnObj["selectid"] == null )
                }         // if( HasResults )
                else
                {
                    ReturnObj["selectid"] = _IdPrefix + "root";
                }

                Tree.goToRoot();
                ReturnObj["root"]                     = new JObject();
                ReturnObj["root"]["data"]             = _View.ViewName;
                ReturnObj["root"]["attr"]             = new JObject();
                ReturnObj["root"]["attr"]["id"]       = _IdPrefix + "root";
                ReturnObj["root"]["attr"]["rel"]      = "root";
                ReturnObj["root"]["attr"]["disabled"] = false == Tree.getNodeIncludedForCurrentPosition();
                //Tree.goToRoot();
                //ReturnObj["attr"]["nodekey"] = Tree.getNodeKeyForCurrentPosition().ToString();
                ReturnObj["root"]["state"]    = "open";
                ReturnObj["root"]["children"] = new JArray();

                if (HasResults)
                {
                    Tree.goToRoot();
                    _runTreeNodesRecursive(Tree, (JArray)ReturnObj["root"]["children"], true);
                }
                else
                {
                    JObject NoResultsObj = new JObject();
                    NoResultsObj["state"] = "leaf";
                    NoResultsObj["data"]  = "No Results";
                    ((JArray)ReturnObj["root"]["children"]).Add(NoResultsObj);
                }
            }
            return(ReturnObj);
        } // runTree()
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="CswResources"></param>
        /// <param name="ReturnObj"></param>
        /// <param name="LegacyFileData"></param>
        public static void performOperations(ICswResources CswResources, CswNbtMobileReturn ReturnObj, string LegacyFileData)
        {
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            Collection <CswNbtCISProNbtMobileData.MobileRequest.Operation> LegacyOperations = new Collection <CswNbtCISProNbtMobileData.MobileRequest.Operation>();

            // string filecontents = MPFDF.FileContents;
            string filecontents = LegacyFileData;

            //Convert string into an array of strings
            string[]      delimiters = new string[] { "\r\n", "\n" };
            List <string> ops        = new List <string>(filecontents.Split(delimiters, StringSplitOptions.RemoveEmptyEntries));

            //Grab the first line and store it as programname
            CswNbtCISProNbtMobileData.MobileRequest.Data LegacyData = new CswNbtCISProNbtMobileData.MobileRequest.Data();
            LegacyData.programname = ops[0];
            // We set the user to the user who is uploading the data
            LegacyData.username = CswResources.CurrentUser.Username;

            //What to do if the first line doesn't match with enum?
            DataFormat Format;

            if (Enum.TryParse(LegacyData.programname, out Format))
            {
                //remove the first line
                ops.RemoveAt(0);

                if (DataFormat.multi1 == Format)
                {
                    //iterate through operations and save as objects
                    foreach (string op in ops)
                    {
                        string[] currentOp = op.Split(',');
                        //create an operation object
                        CswNbtCISProNbtMobileData.MobileRequest.Operation NewOperation = new CswNbtCISProNbtMobileData.MobileRequest.Operation();
                        NewOperation.op = textInfo.ToTitleCase(currentOp[0].ToLower());
                        string barcodeIn = currentOp[3];
                        if (false == barcodeIn.StartsWith("C"))
                        {
                            barcodeIn = "C" + barcodeIn;
                        }
                        NewOperation.barcode = barcodeIn;
                        //create an update object
                        CswNbtCISProNbtMobileData.MobileRequest.Update NewUpdate = new CswNbtCISProNbtMobileData.MobileRequest.Update();
                        NewUpdate.user     = currentOp[1];
                        NewUpdate.location = currentOp[2];
                        //add update object to the operation object
                        NewOperation.update = NewUpdate;

                        //save the operation object to the collection of operations
                        LegacyOperations.Add(NewOperation);
                    }
                }
                else if (DataFormat.reconcilectrlctns == Format)
                {
                    //iterate through operations and save as objects
                    foreach (string op in ops)
                    {
                        string[] currentOp = op.Split(',');
                        //create an operation object
                        CswNbtCISProNbtMobileData.MobileRequest.Operation NewOperation = new CswNbtCISProNbtMobileData.MobileRequest.Operation();
                        NewOperation.op = "Reconcile";
                        string barcodeIn = currentOp[1];
                        if (false == barcodeIn.StartsWith("C"))
                        {
                            barcodeIn = "C" + barcodeIn;
                        }
                        NewOperation.barcode = barcodeIn;
                        //create an update object
                        CswNbtCISProNbtMobileData.MobileRequest.Update NewUpdate = new CswNbtCISProNbtMobileData.MobileRequest.Update();
                        NewUpdate.location = currentOp[0];
                        //add update object to the operation object
                        NewOperation.update = NewUpdate;

                        //save the operation object to the collection of operations
                        LegacyOperations.Add(NewOperation);
                    }
                }

                //Add the collection of operations to the data object
                LegacyData.MultiOpRows = LegacyOperations;

                //Create a new mobilerequest object and add the data object to it
                CswNbtCISProNbtMobileData.MobileRequest LegacyMobileDataObj = new CswNbtCISProNbtMobileData.MobileRequest();
                LegacyMobileDataObj.data = LegacyData;

                //Call the action class which makes the batch op
                CswNbtActUploadLegacyMobileData _CswNbtActUploadLegacyMobileData = new CswNbtActUploadLegacyMobileData((CswNbtResources)CswResources);
                CswNbtObjClassBatchOp           BatchNode = _CswNbtActUploadLegacyMobileData.makeNodesBatch(LegacyMobileDataObj);

                //Create a JObject to display the tree view in the last step of the wizard
                JObject ret = new JObject();

                if (null != BatchNode)
                {
                    ret["result"] = 1;

                    CswNbtView BatchOpsView = new CswNbtView((CswNbtResources)CswResources);
                    BatchOpsView.ViewName = "New Batch Operations";
                    BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                    CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(BatchNode.NodeType, false);
                    BatchRel.NodeIdsToFilterIn.Add(BatchNode.NodeId);

                    CswNbtWebServiceTree ws = new CswNbtWebServiceTree((CswNbtResources)CswResources, BatchOpsView);
                    ret["treedata"] = ws.runTree(null, null, false, true, string.Empty);

                    BatchOpsView.SaveToCache(true);
                    ret["sessionviewid"] = BatchOpsView.SessionViewId.ToString();
                    ret["viewmode"]      = BatchOpsView.ViewMode.ToString();
                }

                ReturnObj.Data.TreeData = ret.ToString();
            }
            else
            {
                ReturnObj.Data.Error = "The program name is invalid.";
            }
        }
Пример #22
0
        public JObject getMenu(CswNbtView View, string SafeNodeKey, Int32 NodeTypeId, string PropIdAttr, bool ReadOnly, string NodeId)
        {
            CswTimer MainMenuTimer = new CswTimer();

            JObject Ret = new JObject();

            CswPrimaryKey RelatedNodeId   = new CswPrimaryKey();
            string        RelatedNodeName = string.Empty;
            CswNbtNode    Node            = null;

            if (false == String.IsNullOrEmpty(SafeNodeKey))
            {
                CswNbtNodeKey NbtNodeKey = new CswNbtNodeKey(SafeNodeKey);
                Node = _CswNbtResources.Nodes[NbtNodeKey];
            }
            else if (false == String.IsNullOrEmpty(NodeId))
            {
                CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(NodeId);
                Node = _CswNbtResources.Nodes[NodePk];
            }
            if (null != Node)
            {
                RelatedNodeId   = Node.NodeId;
                RelatedNodeName = Node.NodeName;
            }

            // MORE
            if (_MenuItems.Contains("More"))
            {
                JObject MoreObj = new JObject();

                if (null == View && Int32.MinValue != NodeTypeId)
                {
                    // ADD for Searches
                    if (_MenuItems.Contains("Add") && false == ReadOnly)
                    {
                        JObject AddObj = new JObject();

                        CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeId);
                        if (null != NodeType && _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, NodeType) && NodeType.getObjectClass().CanAdd)
                        {
                            AddObj[NodeType.NodeTypeName] = makeAddMenuItem(NodeType, RelatedNodeId, RelatedNodeName);
                            AddObj["haschildren"]         = true;
                            Ret["Add"] = AddObj;
                        }
                    } // if( _MenuItems.Contains( "Add" ) && false == ReadOnly )
                }     // if( null == View && Int32.MinValue != NodeTypeId )
                if (null != View)
                {
                    // ADD for Views
                    if (_MenuItems.Contains("Add") && false == ReadOnly)
                    {
                        JObject AddObj = new JObject();

                        // case 21672
                        CswNbtViewNode ParentNode = View.Root;
                        bool           LimitToFirstLevelRelationships = (View.ViewMode == CswEnumNbtViewRenderingMode.Grid);
                        if (LimitToFirstLevelRelationships && View.Visibility == CswEnumNbtViewVisibility.Property)
                        {
                            if (null == Node)
                            {
                                ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(View, false, false, false);
                                if (Tree.getChildNodeCount() > 0)
                                {
                                    Tree.goToNthChild(0);
                                    CswNbtNodeKey NodeKey = Tree.getNodeKeyForCurrentPosition();
                                    Node = _CswNbtResources.Nodes[NodeKey];
                                    if (null != Node)
                                    {
                                        RelatedNodeId   = Node.NodeId;
                                        RelatedNodeName = Node.NodeName;
                                    }
                                }
                            }
                            if (View.Root.ChildRelationships.Count > 0)
                            {
                                ParentNode = View.Root.ChildRelationships[0];
                            }
                        }
                        foreach (JProperty AddNodeType in ParentNode.AllowedChildNodeTypes(LimitToFirstLevelRelationships)
                                 .Select(Entry => new JProperty(Entry.NodeType.NodeTypeName,
                                                                makeAddMenuItem(Entry.NodeType, RelatedNodeId, RelatedNodeName))))
                        {
                            AddObj.Add(AddNodeType);
                        }

                        if (AddObj.HasValues)
                        {
                            AddObj["haschildren"] = true;
                            Ret["Add"]            = AddObj;
                        }
                    }

                    // COPY
                    if (
                        _MenuItems.Contains("Copy") &&
                        false == ReadOnly &&
                        null != Node && Node.NodeSpecies == CswEnumNbtNodeSpecies.Plain &&
                        View.ViewMode != CswEnumNbtViewRenderingMode.Grid &&
                        _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, Node.getNodeType()) &&
                        Node.getObjectClass().CanAdd //If you can't Add the node, you can't Copy it either
                        )
                    {
                        MoreObj["Copy"]               = new JObject();
                        MoreObj["Copy"]["copytype"]   = _getActionType(Node.getNodeType());
                        MoreObj["Copy"]["action"]     = CswEnumNbtMainMenuActions.CopyNode.ToString();
                        MoreObj["Copy"]["nodeid"]     = Node.NodeId.ToString();
                        MoreObj["Copy"]["nodename"]   = Node.NodeName;
                        MoreObj["Copy"]["nodetypeid"] = Node.NodeTypeId.ToString();
                    }

                    // DELETE
                    if (_MenuItems.Contains("Delete") &&
                        false == ReadOnly &&
                        false == string.IsNullOrEmpty(SafeNodeKey) &&
                        null != Node &&
                        View.ViewMode != CswEnumNbtViewRenderingMode.Grid &&
                        Node.NodeSpecies == CswEnumNbtNodeSpecies.Plain &&
                        _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.Delete, Node.getNodeType(), Node.NodeId))
                    {
                        MoreObj["Delete"]             = new JObject();
                        MoreObj["Delete"]["action"]   = CswEnumNbtMainMenuActions.DeleteNode.ToString();
                        MoreObj["Delete"]["nodeid"]   = Node.NodeId.ToString();
                        MoreObj["Delete"]["nodename"] = Node.NodeName;
                    }

                    // SAVE VIEW AS
                    if (_MenuItems.Contains("Save View As") &&
                        false == View.ViewId.isSet() &&
                        _CswNbtResources.Permit.can(_CswNbtResources.Actions[CswEnumNbtActionName.Edit_View]))
                    {
                        View.SaveToCache(false);
                        MoreObj["Save View As"]             = new JObject();
                        MoreObj["Save View As"]["action"]   = CswEnumNbtMainMenuActions.SaveViewAs.ToString();
                        MoreObj["Save View As"]["viewid"]   = View.SessionViewId.ToString();
                        MoreObj["Save View As"]["viewmode"] = View.ViewMode.ToString();
                    }

                    JObject PrintObj = null;

                    // PRINT LABEL

                    bool ValidForTreePrint = (false == string.IsNullOrEmpty(SafeNodeKey) &&
                                              View.ViewMode != CswEnumNbtViewRenderingMode.Grid &&
                                              null != Node &&
                                              null != Node.getNodeType() &&
                                              Node.getNodeType().HasLabel);

                    bool  ValidForGridPrint    = false;
                    bool  TryValidForGridPrint = (View.ViewMode == CswEnumNbtViewRenderingMode.Grid);
                    Int32 MultiPrintNodeTypeId = Int32.MinValue;
                    if (TryValidForGridPrint)
                    {
                        CswNbtViewRelationship TryRel = null;
                        if (View.Visibility != CswEnumNbtViewVisibility.Property && View.Root.ChildRelationships.Count == 1)
                        {
                            TryRel = View.Root.ChildRelationships[0];
                        }
                        else if (View.Visibility == CswEnumNbtViewVisibility.Property &&
                                 View.Root.ChildRelationships.Count == 1 &&
                                 View.Root.ChildRelationships[0].ChildRelationships.Count == 1)
                        {
                            TryRel = View.Root.ChildRelationships[0].ChildRelationships[0];
                        }

                        if (null != TryRel)
                        {
                            ICswNbtMetaDataDefinitionObject MdDef = TryRel.SecondMetaDataDefinitionObject();
                            if (null != MdDef)
                            {
                                if (MdDef.HasLabel)
                                {
                                    //This assumes that only NodeTypes will implement this property
                                    MultiPrintNodeTypeId = MdDef.UniqueId;
                                    ValidForGridPrint    = true;
                                }
                            }
                        }
                    }

                    if (_MenuItems.Contains("Print") &&
                        (ValidForTreePrint || ValidForGridPrint))
                    {
                        PrintObj = PrintObj ?? new JObject(new JProperty("haschildren", true));
                        PrintObj["Print Label"]           = new JObject();
                        PrintObj["Print Label"]["action"] = CswEnumNbtMainMenuActions.PrintLabel.ToString();

                        if (ValidForTreePrint)
                        {
                            PrintObj["Print Label"]["nodeid"]     = Node.NodeId.ToString();
                            PrintObj["Print Label"]["nodetypeid"] = Node.NodeTypeId;
                            PrintObj["Print Label"]["nodename"]   = Node.NodeName;
                        }
                        else if (ValidForGridPrint)
                        {
                            PrintObj["Print Label"]["nodetypeid"] = MultiPrintNodeTypeId;
                        }
                    }
                    // PRINT
                    if (_MenuItems.Contains("Print") &&
                        View.ViewMode == CswEnumNbtViewRenderingMode.Grid)
                    {
                        View.SaveToCache(false);
                        PrintObj = PrintObj ?? new JObject(new JProperty("haschildren", true));
                        PrintObj["Print View"]           = new JObject();
                        PrintObj["Print View"]["action"] = CswEnumNbtMainMenuActions.PrintView.ToString();
                    }

                    if (null != PrintObj)
                    {
                        MoreObj["Print"] = PrintObj;
                    }

                    // EXPORT
                    if (_MenuItems.Contains("Export"))
                    {
                        if (CswEnumNbtViewRenderingMode.Grid == View.ViewMode)
                        {
                            JObject ExportObj = new JObject();
                            MoreObj["Export"] = ExportObj;

                            View.SaveToCache(false);
                            ExportObj["CSV"] = new JObject();
                            string ExportLink = "wsNBT.asmx/gridExportCSV?ViewId=" + View.SessionViewId + "&SafeNodeKey='";
                            if (CswEnumNbtViewVisibility.Property == View.Visibility)
                            {
                                ExportLink += SafeNodeKey;
                            }
                            ExportLink += "'";

                            ExportObj["CSV"]["popup"] = ExportLink;

                            ExportObj["haschildren"] = true;
                        }
                    }
                } // if( null != View )

                // EDIT VIEW
                if (_MenuItems.Contains("Edit View") &&
                    _CswNbtResources.Permit.can(CswEnumNbtActionName.Edit_View) &&
                    (null == View || (false == View.IsSystem || CswNbtObjClassUser.ChemSWAdminUsername == _CswNbtResources.CurrentNbtUser.Username)))
                {
                    MoreObj["Edit View"]           = new JObject();
                    MoreObj["Edit View"]["action"] = CswEnumNbtMainMenuActions.editview.ToString();
                }

                if (_MenuItems.Contains("Multi-Edit") &&
                    false == ReadOnly &&
                    null != View &&
                    _CswNbtResources.Permit.can(CswEnumNbtActionName.Multi_Edit) &&
                    // Per discussion with David, for the short term eliminate the need to validate the selection of nodes across different nodetypes in Grid views.
                    // Case 21701: for Grid Properties, we need to look one level deeper
                    // Case 29032: furthermore (for Grids), we need to exclude ObjectClass relationships (which can also produce the multi-nodetype no-no
                    (View.ViewMode != CswEnumNbtViewRenderingMode.Grid ||
                     ((View.Root.ChildRelationships.Count == 1 && View.Root.ChildRelationships[0].SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId) &&
                      (View.Visibility != CswEnumNbtViewVisibility.Property || (View.Root.ChildRelationships[0].ChildRelationships.Count == 1 && View.Root.ChildRelationships[0].ChildRelationships[0].SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId))))
                    )
                {
                    MoreObj["Multi-Edit"]           = new JObject();
                    MoreObj["Multi-Edit"]["action"] = CswEnumNbtMainMenuActions.multiedit.ToString();
                }
                if (_MenuItems.Contains("Bulk Edit") &&
                    false == ReadOnly &&
                    null != View &&
                    _CswNbtResources.Permit.can(CswEnumNbtActionName.Bulk_Edit))
                {
                    MoreObj["Bulk Edit"]           = new JObject();
                    MoreObj["Bulk Edit"]["action"] = CswEnumNbtMainMenuActions.bulkedit.ToString();
                }

                if (MoreObj.Count > 0)
                {
                    MoreObj["haschildren"] = true;
                    Ret["More"]            = MoreObj;
                }
            } // if( _MenuItems.Contains( "More" ) )

            _CswNbtResources.logTimerResult("CswNbtWebServiceMainMenu.getMenu()", MainMenuTimer.ElapsedDurationInSecondsAsString);


            return(Ret);
        } // getMenu()
Пример #23
0
        } // _treeNodeJObject()

        public void runTree(Contract.Response.ResponseData ResponseData, Contract.Request Request, Int32 PerLevelNodeLimit = Int32.MinValue, Int32 TotalNodeLimit = Int32.MinValue)
        {
            ResponseData.Tree = ResponseData.Tree ?? new Collection <CswExtTree.TreeNode>();
            ICswNbtTree Tree     = null;
            string      RootName = string.Empty;

            if (null != _View)
            {
                Tree = _CswNbtResources.Trees.getTreeFromView(_View, Request.RequireViewPermissions, false, false, PerLevelNodeLimit: PerLevelNodeLimit);
                _View.SaveToCache(Request.IncludeInQuickLaunch);
                RootName = _View.ViewName;
            }

            CswPrimaryKey IncludeNodeId     = null;
            CswNbtNodeKey SelectKey         = null;
            Int32         IncludeNodeTypeId = Int32.MinValue;

            if (null != Request.IncludeNodeKey)
            {
                IncludeNodeId     = Request.IncludeNodeKey.NodeId;
                IncludeNodeTypeId = Request.IncludeNodeKey.NodeTypeId;
                if (null != Tree)
                {
                    Tree.makeNodeCurrent(Request.IncludeNodeKey);
                    if (Tree.isCurrentNodeDefined())
                    {
                        SelectKey = Request.IncludeNodeKey;
                    }
                }
            }
            else if (CswTools.IsPrimaryKey(Request.IncludeNodeId))
            {
                IncludeNodeId = Request.IncludeNodeId;
                CswNbtNode IncludeNode = _CswNbtResources.Nodes[IncludeNodeId];
                if (null != IncludeNode)
                {
                    IncludeNodeTypeId = IncludeNode.NodeTypeId;
                }
                if (null != Tree)
                {
                    SelectKey = Tree.getNodeKeyByNodeId(IncludeNodeId);
                }
            }

            if ((CswTools.IsPrimaryKey(IncludeNodeId) && IncludeNodeTypeId != Int32.MinValue) &&
                (Tree == null ||
                 (Request.IncludeNodeRequired && SelectKey == null)))
            {
                CswNbtMetaDataNodeType IncludeNodeType = _CswNbtResources.MetaData.getNodeType(IncludeNodeTypeId);
                if (null != IncludeNodeType)
                {
                    _View          = IncludeNodeType.CreateDefaultView(false);
                    _View.ViewName = IncludeNodeType.NodeTypeName;
                    _View.Root.ChildRelationships[0].NodeIdsToFilterIn.Add(IncludeNodeId);
                    _View.SaveToCache(Request.IncludeInQuickLaunch);   // case 22713
                    RootName = _View.ViewName;

                    Tree = _CswNbtResources.Trees.getTreeFromView(_View, false, false, false);
                }
            }

            bool HasResults = false;

            if (null != Tree)
            {
                Tree.goToRoot();
                HasResults = (Tree.getChildNodeCount() > 0);
                //ReturnObj["result"] = HasResults.ToString().ToLower();
                //ReturnObj["types"] = getTypes();
                ResponseData.PageSize = _CswNbtResources.CurrentNbtUser.PageSize;

                ResponseData.SelectedNodeKey = null;
                if (HasResults)
                {
                    // Determine the default selected node:
                    // If the requested node to select is on the tree, return it.
                    // If the requested node to select is not on the tree, return the first child of the root.
                    if (SelectKey != null)
                    {
                        Tree.makeNodeCurrent(SelectKey);
                        if (Tree.isCurrentNodeDefined())
                        {
                            ResponseData.SelectedNodeKey = SelectKey;
                        }
                    }
                    if (ResponseData.SelectedNodeKey == null)
                    {
                        switch (Request.DefaultSelect)
                        {
                        case "none":
                            break;

                        case "root":
                            break;

                        case "firstchild":
                            Tree.goToRoot();
                            CswNbtNodeKey CurrentKey = Tree.getNodeKeyForCurrentPosition();
                            while (CurrentKey != null &&
                                   CurrentKey.NodeSpecies != CswEnumNbtNodeSpecies.Plain &&
                                   Tree.getChildNodeCount() > 0)
                            {
                                Tree.goToNthChild(0);
                                CurrentKey = Tree.getNodeKeyForCurrentPosition();
                            }
                            if (CurrentKey != null && CurrentKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain)
                            {
                                ResponseData.SelectedNodeKey = CurrentKey;
                            }
                            break;
                        } // switch( DefaultSelect )
                    }     // if( ReturnObj["selectid"] == null )
                }         // if( HasResults )
                else
                {
                    Request.DefaultSelect = "root";
                }

                Tree.goToRoot();
            }
            //Build the Response:

            ResponseData.Name = RootName;

            //#1: the Root node
            CswExtTree.TreeNode RootNode = new CswExtTree.TreeNode();
            ResponseData.Tree.Add(RootNode);

            RootNode.Name     = RootName;
            RootNode.IsRoot   = true;
            RootNode.Expanded = true;
            RootNode.Path     = "|root";
            RootNode.Id       = "root";
            RootNode.Icon     = "Images/view/viewtree.gif";

            //#2: the columns for the Tree Grid
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "text"),
                xtype        = CswEnumExtJsXType.treecolumn,
                MenuDisabled = true,
                width        = 269,
                header       = "Tree",
                resizable    = false,
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "nodetypeid"),
                header       = "NodeTypeId",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.gridcolumn,
                MenuDisabled = false
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "objectclassid"),
                header       = "ObjectClassId",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.gridcolumn,
                MenuDisabled = false
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "nodeid"),
                header       = "NodeId",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.gridcolumn,
                MenuDisabled = false
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "disabled"),
                header       = "Disabled",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.booleancolumn,
                MenuDisabled = false
            });


            //#3: The fields to map the columns to the data store
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "text", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "nodetypeid", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "objectclassid", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "nodeid", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "disabled", type = "bool"
            });

            //#4: View Properties are columns now too
            Collection <string> UniqueColumnNames = new Collection <string>()
            {
                "text", "nodetypeid", "objectclassid", "nodeid", "disabled"
            };

            CswNbtViewRoot.forEachProperty AddProp = (ViewProperty) =>
            {
                string PropName = ViewProperty.Name.ToLower().Trim();
                bool   HideProp = (null != Request.PropsToShow && false == Request.PropsToShow.Contains(PropName));
                if (false == UniqueColumnNames.Contains(PropName))
                {
                    UniqueColumnNames.Add(PropName);

                    CswExtJsGridColumn Col = new CswExtJsGridColumn
                    {
                        dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, PropName),
                        header       = ViewProperty.Name,
                        hidden       = HideProp,
                        resizable    = false,
                        width        = ViewProperty.Width * 7,
                        xtype        = CswEnumExtJsXType.gridcolumn,
                        MenuDisabled = false
                    };
                    CswExtJsGridField Fld = new CswExtJsGridField {
                        name = PropName, type = "string"
                    };
                    Fld.dataIndex = Col.dataIndex;

                    ResponseData.Columns.Add(Col);
                    ResponseData.Fields.Add(Fld);
                }
            };
            _View.Root.eachRelationship(relationshipCallBack: null, propertyCallBack: AddProp);


            //#5: the tree
            RootNode.Children = new Collection <CswExtTree.TreeNode>();
            if (HasResults)
            {
                Tree.goToRoot();
                int count = 0;
                _runTreeNodesRecursive(Tree, RootNode.Children, RootNode, Request, TotalNodeLimit, ref count);

                if (Int32.MinValue != TotalNodeLimit && count >= TotalNodeLimit && RootNode.Children[0].Name != "Results Truncated")
                {
                    CswExtTree.TreeNode TruncatedTreeNode = _getTreeNode(Tree, RootNode, null);
                    TruncatedTreeNode.Name   = "Results Truncated";
                    TruncatedTreeNode.IsLeaf = true;
                    TruncatedTreeNode.Icon   = "Images/icons/truncated.gif";
                    TruncatedTreeNode.Id     = TruncatedTreeNode.Id + "_truncated";
                    TruncatedTreeNode.NodeId = "";
                    RootNode.Children.Insert(0, TruncatedTreeNode);
                }
            }
            else
            {
                CswExtTree.TreeNode EmptyNode = new CswExtTree.TreeNode();
                EmptyNode.Name     = "No Results";
                EmptyNode.IsLeaf   = true;
                EmptyNode.Selected = true;
                EmptyNode.Id       = "empty";
                EmptyNode.ParentId = RootNode.Id;
                EmptyNode.Path     = RootNode.Path + "|empty";
                RootNode.Children.Add(EmptyNode);
            }
            //}
        } // runTree()