Example #1
0
        public override void ToJSON(JObject ParentObject)
        {
            ParentObject[_SelectedNodeTypeIdsSubField.ToXmlNodeName().ToLower()] = SelectedNodeTypeIds.ToString();
            ParentObject["selectmode"]      = SelectMode.ToString();
            ParentObject[_ElemName_Options] = new JObject();

            CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions();

            CBAOptions.Columns.Add("Include");

            DataTable Data = Options;

            foreach (DataRow Row in Data.Rows)
            {
                bool isSelected = SelectedNodeTypeIds.Contains(Row[KeyColumn]);
                if (IsEditModeEditable || isSelected)
                {
                    CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option();
                    Option.Key   = CswConvert.ToString(Row[KeyColumn]);
                    Option.Label = CswConvert.ToString(Row[NameColumn]);
                    Option.Values.Add(CswConvert.ToBoolean(Row[ValueColumn]));
                    CBAOptions.Options.Add(Option);
                }
            }

            CBAOptions.ToJSON((JObject)ParentObject[_ElemName_Options]);
        } // ToJSON()
Example #2
0
        private Collection <CswNbtNodeKey> _loadNodeAsChildFromRow(CswNbtNodeKey ParentNodeKey, DataRow DataRowToAdd,
                                                                   bool UseGrouping, string GroupName,
                                                                   CswNbtViewRelationship Relationship, bool Selectable,
                                                                   bool ShowInTree,
                                                                   CswEnumNbtViewAddChildrenSetting AddChildren, Int32 RowCount,
                                                                   bool Included = true, bool Favorited = false)
        {
            CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(DataRowToAdd[_CswNbtColumnNames.NodeTypeId.ToLower()].ToString()));

            //string TableName = NodeType.TableName;
            //string PkColumnName = _CswNbtResources.getPrimeKeyColName( TableName );

            return(_loadNodeAsChild(ParentNodeKey, UseGrouping, GroupName, Relationship, Selectable, ShowInTree,
                                    AddChildren, RowCount, Included,
                                    DataRowToAdd[_CswNbtColumnNames.IconFileName.ToLower()].ToString(),
                                    DataRowToAdd[_CswNbtColumnNames.NameTemplate.ToLower()].ToString(),
                                    new CswPrimaryKey("nodes", CswConvert.ToInt32(DataRowToAdd["nodeid"])),
                                    new CswPrimaryKey(CswConvert.ToString(DataRowToAdd["relationaltable"]), CswConvert.ToInt32(DataRowToAdd["relationalid"])),
                                    DataRowToAdd[_CswNbtColumnNames.NodeName.ToLower()].ToString(),
                                    CswConvert.ToInt32(DataRowToAdd[_CswNbtColumnNames.NodeTypeId.ToLower()].ToString()),
                                    DataRowToAdd[_CswNbtColumnNames.NodeTypeName.ToLower()].ToString(),
                                    CswConvert.ToInt32(DataRowToAdd[_CswNbtColumnNames.ObjectClassId.ToLower()].ToString()),
                                    DataRowToAdd[_CswNbtColumnNames.ObjectClassName.ToLower()].ToString(),
                                    CswConvert.ToBoolean(DataRowToAdd[_CswNbtColumnNames.Locked.ToLower()]),
                                    Favorited
                                    ));
        }
Example #3
0
        /// <summary>
        /// Returns import data table names, in import order
        /// </summary>
        /// <param name="IncludeCompleted">If true, also include table names for already completed imports</param>
        public static StringCollection getImportDataTableNames(CswNbtResources CswNbtResources, bool IncludeCompleted = false)
        {
            StringCollection ret = new StringCollection();

            string Sql = @"select m." + CswNbtImportTables.ImportDataMap.datatablename +
                         " from " + CswNbtImportTables.ImportDataMap.TableName + " m " +
                         " join " + CswNbtImportTables.ImportDataJob.TableName + " j on m." + CswNbtImportTables.ImportDataMap.importdatajobid + " = j." + CswNbtImportTables.ImportDataJob.importdatajobid +
                         " join " + CswNbtImportTables.ImportDef.TableName + " d on m." + CswNbtImportTables.ImportDataMap.importdefid + " = d." + CswNbtImportTables.ImportDef.importdefid;

            if (false == IncludeCompleted)
            {
                Sql += "  where " + CswNbtImportTables.ImportDataJob.dateended + " is null";
                Sql += "    and m." + CswNbtImportTables.ImportDataMap.completed + " = '" + CswConvert.ToDbVal(false) + "'";
            }
            Sql += @"     order by j." + CswNbtImportTables.ImportDataJob.datestarted + ", d." + CswNbtImportTables.ImportDef.sheetorder + ", m." + CswNbtImportTables.ImportDataMap.PkColumnName;

            CswArbitrarySelect ImportDataSelect = CswNbtResources.makeCswArbitrarySelect("getImportDataTableNames_Select", Sql);
            DataTable          ImportDataTable  = ImportDataSelect.getTable();

            foreach (DataRow Row in ImportDataTable.Rows)
            {
                ret.Add(CswConvert.ToString(Row[CswNbtImportTables.ImportDataMap.datatablename]));
            }

            return(ret);
        } // getImportDataTableNames()
        } // saveSessionData(View)

        private DataRow _getSessionViewRow( DataTable SessionViewTable, object Name, CswEnumNbtSessionDataType DataType, bool IncludeInQuickLaunch, bool KeepInQuickLaunch )
        {
            DataRow SessionViewRow = null;
            if( SessionViewTable.Rows.Count > 0 )
            {
                SessionViewRow = SessionViewTable.Rows[0];
            }
            else
            {
                SessionViewRow = SessionViewTable.NewRow();
                SessionViewTable.Rows.Add( SessionViewRow );
            }

            SessionViewRow[SessionDataColumn_Name] = CswConvert.ToString( Name );
            SessionViewRow[SessionDataColumn_SessionId] = SessionId;
            SessionViewRow[SessionDataColumn_SessionDataType] = DataType.ToString();
            if( CswConvert.ToBoolean( SessionViewRow[SessionDataColumn_QuickLaunch] ) == false )
            {
                // Only set false to true, not true to false.  See case 23999.
                SessionViewRow[SessionDataColumn_QuickLaunch] = CswConvert.ToDbVal( IncludeInQuickLaunch );
            }
            SessionViewRow[SessionDataColumn_KeepInQuickLaunch] = CswConvert.ToDbVal( KeepInQuickLaunch );

            return SessionViewRow;
        } // _getSessionViewRow()
Example #5
0
        } // update()

        private void _fixBadScheudlesAndTasks()
        {
            ICswNbtTree BadSchedulesTree = _CswNbtSchemaModTrnsctn.getTreeFromView( _getBadSchedulesAndTasksView(), false );
            BadSchedulesTree.goToRoot();
            for( int i = 0; i < BadSchedulesTree.getChildNodeCount(); i++ )
            {
                BadSchedulesTree.goToNthChild( i );

                CswNbtObjClassGenerator ScheduleNode = BadSchedulesTree.getNodeForCurrentPosition();
                int TargetTypeId = ScheduleNode.NodeTypeId == AssemblyScheduleNT.NodeTypeId ? AssemblyTaskNT.NodeTypeId : EquipmentTaskNT.NodeTypeId;
                ScheduleNode.TargetType.SelectedNodeTypeIds.Clear();
                ScheduleNode.TargetType.SelectedNodeTypeIds.Add( CswConvert.ToString( TargetTypeId ) );
                ScheduleNode.postChanges( false );

                for( int j = 0; j < BadSchedulesTree.getChildNodeCount(); j++ )
                {
                    BadSchedulesTree.goToNthChild( j );

                    CswNbtNode OldTaskNode = BadSchedulesTree.getNodeForCurrentPosition();
                    CswNbtObjClassTask NewTaskNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( TargetTypeId, CswEnumNbtMakeNodeOperation.WriteNode );
                    NewTaskNode.Node.copyPropertyValues( OldTaskNode );
                    NewTaskNode.Owner.RelatedNodeId = ScheduleNode.Owner.RelatedNodeId;
                    OldTaskNode.delete();
                    NewTaskNode.postChanges( false );

                    BadSchedulesTree.goToParentNode();
                }

                BadSchedulesTree.goToParentNode();
            }
        }
        private static Collection <CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData.DoomedNode> _retriveDoomedNodes(CswNbtResources NbtResources)
        {
            Collection <CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData.DoomedNode> DoomedNodes = new Collection <CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData.DoomedNode>();

            CswArbitrarySelect NodeTblSelect = NbtResources.makeCswArbitrarySelect("getDoomedNodes_nbtImporter",
                                                                                   @"select t.nodeid, t.nodename, t.nodetypeid, nt.nodetypename
                                from nodes t
                                join nodetypes nt on (nt.nodetypeid = t.nodetypeid)
                                where nodename not in ('chemsw_admin', 'chemsw_admin_role', 'Each', 'Days', 'Ci', 'kg',
                                    'Liters', 'lb', 'gal', 'cu.ft.', 'CISPro_Admin',
                                    'CISPro_General', 'Default Jurisdiction')
                                and t.nodetypeid not in
                                    (1130, 1212, 1329, 1330, 1369, 33, 114, 659, 1052, 1053, 1290, 1291, 1292, 1293, 1211)
                                and nodetypename not like 'Design%'");

            DataTable NodesTbl = NodeTblSelect.getTable();

            foreach (DataRow Row in NodesTbl.Rows)
            {
                DoomedNodes.Add(new CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData.DoomedNode
                {
                    NodeId   = CswConvert.ToInt32(Row["nodeid"]),
                    NodeName = CswConvert.ToString(Row["nodename"]),
                    NodeType = CswConvert.ToString(Row["nodetypename"])
                });
            }

            return(DoomedNodes);
        }//_retriveDoomedNodes()
        public JObject dispenseIntoChildContainers(string ContainerNodeTypeId, string DispenseGrid, string RequestItemId)
        {
            JObject ret = new JObject();

            if (null != _SourceContainer)
            {
                CswPrimaryKey RequestItemPk = new CswPrimaryKey();
                RequestItemPk.FromString(RequestItemId);
                JArray  GridArray = JArray.Parse(DispenseGrid);
                JObject jBarcodes = new JObject();
                ret["barcodes"] = jBarcodes;
                for (Int32 i = 0; i < GridArray.Count; i += 1)
                {
                    if (GridArray[i].Type == JTokenType.Object)
                    {
                        JObject CurrentRow               = (JObject)GridArray[i];
                        int     NumOfContainers          = CswConvert.ToInt32(CurrentRow["containerNo"]);
                        double  QuantityToDispense       = CswConvert.ToDouble(CurrentRow["quantity"]);
                        string  UnitId                   = CswConvert.ToString(CurrentRow["unitid"]);
                        CswCommaDelimitedString Barcodes = new CswCommaDelimitedString();
                        Barcodes.FromString(CswConvert.ToString(CurrentRow["barcodes"]));

                        CswPrimaryKey UnitOfMeasurePK = new CswPrimaryKey();
                        UnitOfMeasurePK.FromString(UnitId);

                        if (NumOfContainers == 0)
                        {
                            _SourceContainer.DispenseOut(
                                CswEnumNbtContainerDispenseType.Dispense, QuantityToDispense,
                                UnitOfMeasurePK, RequestItemPk);
                            _SourceContainer.postChanges(false);
                        }
                        else
                        {
                            for (Int32 c = 0; c < NumOfContainers; c += 1)
                            {
                                CswNbtObjClassContainer ChildContainer = _createChildContainer(ContainerNodeTypeId,
                                                                                               UnitOfMeasurePK, Barcodes[c]);
                                _SourceContainer.DispenseOut(
                                    CswEnumNbtContainerDispenseType.Dispense, QuantityToDispense,
                                    UnitOfMeasurePK, RequestItemPk, ChildContainer);
                                //ChildContainer.DispenseIn( CswEnumNbtContainerDispenseType.Dispense, QuantityToDispense, UnitOfMeasurePK, RequestItemPk, _SourceContainer );
                                ChildContainer.postChanges(false);

                                JObject BarcodeNode = new JObject();
                                jBarcodes[ChildContainer.NodeId.ToString()] = BarcodeNode;
                                BarcodeNode["nodeid"]   = ChildContainer.NodeId.ToString();
                                BarcodeNode["nodename"] = ChildContainer.NodeName;
                            }
                            _SourceContainer.postChanges(false);
                        }
                    }
                }
                _SourceContainer.postChanges(false);

                string ViewId = _getViewForAllDispenseContainers();
                ret["viewId"] = ViewId;
            }
            return(ret);
        }
Example #8
0
        public void addSingleNodeProp(CswNbtNode Node, JObject PropObj, CswNbtMetaDataNodeTypeTab Tab)
        {
            CswPropIdAttr PropIdAttr = new CswPropIdAttr(CswConvert.ToString(PropObj["id"]));

            CswNbtMetaDataNodeTypeProp MetaDataProp = _CswNbtResources.MetaData.getNodeTypeProp(PropIdAttr.NodeTypePropId);

            if (null != MetaDataProp)
            {
                CswNbtMetaDataNodeType NodeType = MetaDataProp.getNodeType();

                if (_CswNbtResources.Permit.canNodeType(Security.CswEnumNbtNodeTypePermission.Edit, NodeType) ||
                    _CswNbtResources.Permit.canTab(Security.CswEnumNbtNodeTypePermission.Edit, NodeType, Tab) ||
                    _CswNbtResources.Permit.isPropWritable(Security.CswEnumNbtNodeTypePermission.Edit, MetaDataProp, Tab))
                {
                    Node.Properties[MetaDataProp].ReadJSON(PropObj, null, null);

                    // Recurse on sub-props
                    if (null != PropObj["subprops"])
                    {
                        JObject SubPropsObj = (JObject)PropObj["subprops"];
                        if (SubPropsObj.HasValues)
                        {
                            foreach (JObject ChildPropObj in SubPropsObj.Properties()
                                     .Where(ChildProp => null != ChildProp.Value && ChildProp.Value.HasValues)
                                     .Select(ChildProp => (JObject)ChildProp.Value)
                                     .Where(ChildPropObj => ChildPropObj.HasValues))
                            {
                                addSingleNodeProp(Node, ChildPropObj, Tab);
                            }
                        }
                    }
                } //if user has permission to edit the property
            }     //if not null
        }         // addSingleNodeProp()
Example #9
0
        public static void saveMaterialProps(ICswResources CswResources, MaterialResponse Response, string PropDefinition)
        {
            if (null != CswResources)
            {
                CswNbtResources         NbtResources         = (CswNbtResources)CswResources;
                CswNbtActCreateMaterial CreateMaterialAction = new CswNbtActCreateMaterial(NbtResources);

                // Convert PropDefintion to JObject
                JObject PropsObj = CswConvert.ToJObject(PropDefinition);

                if (PropsObj.HasValues)
                {
                    // Convert the nodeid to a primary key
                    CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(CswConvert.ToString(PropsObj["NodeId"]));

                    // Convert the Nodetypeid to an Int32
                    Int32 NodeTypeId = CswConvert.ToInt32(CswConvert.ToString(PropsObj["NodeTypeId"]));

                    // Properties only
                    JObject Properties = CswConvert.ToJObject(PropsObj["Properties"]);

                    // Save the properties
                    JObject PropValues = CreateMaterialAction.saveMaterialProps(NodePk, Properties, NodeTypeId);

                    // Set the return object
                    if (PropValues.HasValues)
                    {
                        if (null != PropValues.Property("PhysicalState"))
                        {
                            Response.Data.Properties.PhysicalState = CswConvert.ToString(PropValues["PhysicalState"]);
                        }
                    }
                }//if( PropsObj.HasValues )
            }
        }
Example #10
0
        private static readonly CookieManagerBehavior _cookieBehavior = new CookieManagerBehavior(); //All ChemWatch service clients must share this

        public static CswNbtChemWatchRequest Initialize(ICswResources CswResources, CswNbtChemWatchRequest Request)
        {
            CswNbtChemWatchRequest Return       = new CswNbtChemWatchRequest();
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;

            CswNbtObjClassChemical ChemicalNode = NbtResources.Nodes[Request.NbtMaterialId];

            Return.Supplier      = ChemicalNode.Supplier.CachedNodeName;
            Return.PartNo        = ChemicalNode.PartNumber.Text;
            Return.MaterialName  = ChemicalNode.TradeName.Text;
            Return.NbtMaterialId = ChemicalNode.NodeId;

            string errorMsg;

            if (_authenticate(NbtResources, out errorMsg))
            {
                CommonServiceClient cwCommonClient = new CommonServiceClient();
                cwCommonClient.Endpoint.Behaviors.Add(_cookieBehavior);

                // Populate Language list
                List <ChemWatchMultiSlctListItem> Languages = new List <ChemWatchMultiSlctListItem>();
                Languages cwLanguages = cwCommonClient.GetLanguages();
                foreach (Language cwLanguage in cwLanguages)
                {
                    if (cwLanguage.UILanguage)
                    {
                        Languages.Add(new ChemWatchMultiSlctListItem()
                        {
                            Name = cwLanguage.Name,
                            Id   = CswConvert.ToString(cwLanguage.Id)
                        });
                    }
                }
                IEnumerable <ChemWatchMultiSlctListItem> SortedLanguages = Languages.OrderBy(si => si.Name);
                Return.Languages.options = SortedLanguages.ToList();

                // Populate Country list
                List <ChemWatchMultiSlctListItem> Countries = new List <ChemWatchMultiSlctListItem>();
                Countries cwCountries = cwCommonClient.GetCountries();
                foreach (Country cwCountry in cwCountries)
                {
                    Countries.Add(new ChemWatchMultiSlctListItem()
                    {
                        Name = cwCountry.Name,
                        Id   = CswConvert.ToString(cwCountry.Id)
                    });
                }
                IEnumerable <ChemWatchMultiSlctListItem> SortedCountries = Countries.OrderBy(si => si.Name);
                Return.Countries.options = SortedCountries.ToList();

                // Attempt to populate the Suppliers list
                _getMatchingSuppliers(Return.Supplier, Return);
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error, "There was a problem authenticating with ChemWatch", errorMsg);
            }

            return(Return);
        }
Example #11
0
        public static CswNbtChemWatchRequest MaterialSearch(ICswResources CswResources, CswNbtChemWatchRequest Request)
        {
            CswNbtChemWatchRequest Return       = new CswNbtChemWatchRequest();
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            string errorMsg;

            if (_authenticate(NbtResources, out errorMsg))
            {
                MaterialServiceClient cwMaterialClient = new MaterialServiceClient();
                cwMaterialClient.Endpoint.Behaviors.Add(_cookieBehavior);

                List <ChemWatchListItem> Materials   = new List <ChemWatchListItem>();
                ListResultOfMaterial     cwMaterials = cwMaterialClient.GetMaterialsByVendorGroupId(Request.Supplier, Request.MaterialName, Request.PartNo, false, 1, 100, "", 0);
                foreach (Material cwMaterial in cwMaterials.Rows)
                {
                    Materials.Add(new ChemWatchListItem()
                    {
                        Id   = CswConvert.ToString(cwMaterial.MaterialID),
                        Name = cwMaterial.Name
                    });
                }
                IEnumerable <ChemWatchListItem> SortedMaterials = Materials.OrderBy(si => si.Name);
                Return.Materials = SortedMaterials.ToList();
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error, "There was a problem authenticating with ChemWatch", errorMsg);
            }

            return(Return);
        }
        /// <summary>
        /// Finalize the new Material
        /// </summary>
        public JObject commitMaterial(string MaterialDefinition)
        {
            JObject RetObj = new JObject();

            JObject MaterialObj = CswConvert.ToJObject(MaterialDefinition);

            if (MaterialObj.HasValues)
            {
                JArray        SizesArray = CswConvert.ToJArray(MaterialObj["sizeNodes"]);
                CswPrimaryKey MaterialId = new CswPrimaryKey();
                MaterialId.FromString(CswConvert.ToString(MaterialObj["materialId"]));
                if (CswTools.IsPrimaryKey(MaterialId))
                {
                    CswNbtNode MaterialNode = _CswNbtResources.Nodes[MaterialId];
                    if (null != MaterialNode)
                    {
                        /* 1. Validate the new material and get its properties */
                        MaterialNode = _commitMaterialNode(MaterialObj);
                        RetObj["createdmaterial"] = true;

                        /* 2. Add the sizes */
                        if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers))
                        {
                            SizesArray = _removeDuplicateSizes(SizesArray);
                            _addMaterialSizes(SizesArray, MaterialNode);
                            RetObj["sizescount"] = SizesArray.Count;
                        }

                        /* 3. Add landingpage data */
                        RetObj["landingpagedata"] = _getLandingPageData(MaterialNode);
                    }
                }
            }
            return(RetObj);
        }
        public override CswNbtViewEditorData GetStepData()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            _getFilters(Return, CurrentView);

            HashSet <string> seenRels = new HashSet <string>();

            CswNbtViewRoot.forEachRelationship eachRelationship = relationship =>
            {
                string label = _getRelationshipOwnerName(relationship);

                if (false == seenRels.Contains(label))
                {
                    seenRels.Add(label);
                    Return.Step4.Relationships.Add(relationship);
                }
            };
            CurrentView.Root.eachRelationship(eachRelationship, null);

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());

            base.Finalize(Return);
            return(Return);
        }
        public static string generateImportQueueTableSQL(ICswResources CswResources)
        {
            string Ret = string.Empty;

            CswArbitrarySelect ImportDefSelect = CswResources.makeCswArbitrarySelect("importdef_get_caf_rows", "select distinct pkcolumnname, coalesce(viewname, tablename) as sourcename " +
                                                                                     "from import_def_order io, import_def id " +
                                                                                     "where id.importdefid = io.importdefid " +
                                                                                     "and id.definitionname = '" + DefinitionName + "'");
            DataTable ImportDefTable = ImportDefSelect.getTable();
            bool      FirstRow       = true;

            foreach (DataRow DefRow in ImportDefTable.Rows)
            {
                string CurrentDefRowSql = @"insert into nbtimportqueue(nbtimportqueueid, state, itempk, sheetname, priority, errorlog) "
                                          + " select seq_nbtimportqueueid.nextval, '"
                                          + State.I + "', "
                                          + CswConvert.ToString(DefRow[CswNbtImportTables.ImportDefOrder.pkcolumnname]) + ", "
                                          + "'" + CswConvert.ToString(DefRow["sourcename"]) + "', "
                                          + "0, "
                                          + "'' from " + CswConvert.ToString(DefRow["sourcename"]) + " where deleted = '0';";
                CurrentDefRowSql = CurrentDefRowSql + "\ncommit;";

                if (FirstRow)
                {
                    Ret      = CurrentDefRowSql + Environment.NewLine;
                    FirstRow = false;
                }
                else
                {
                    Ret = Ret + Environment.NewLine + CurrentDefRowSql + Environment.NewLine;
                }
            }

            return(Ret);
        }
        private void _addFilter(CswNbtViewEditorData Return)
        {
            CswNbtViewRelationship parent = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(Request.Property.ParentArbitraryId);

            CswNbtViewRoot.forEachRelationship eachRel = relationship =>
            {
                if (parent.SecondId == relationship.SecondId)
                {
                    CswNbtViewProperty viewProp = relationship.Properties.FirstOrDefault(vp => vp.Name == Request.Property.Name);
                    if (null != viewProp)
                    {
                        if (false == _hasFilter(viewProp))
                        {
                            CurrentView.AddViewPropertyFilter(viewProp,
                                                              Conjunction: (CswEnumNbtFilterConjunction)Request.FilterConjunction,
                                                              SubFieldName: (CswEnumNbtSubFieldName)Request.FilterSubfield,
                                                              FilterMode: (CswEnumNbtFilterMode)Request.FilterMode,
                                                              Value: Request.FilterValue);
                        }
                    }
                    else
                    {
                        ICswNbtMetaDataProp Prop = null;
                        if (Request.Property.Type.Equals(CswEnumNbtViewPropType.NodeTypePropId))
                        {
                            Prop = _CswNbtResources.MetaData.getNodeTypeProp(Request.Property.NodeTypePropId);
                        }
                        else if (Request.Property.Type.Equals(CswEnumNbtViewPropType.ObjectClassPropId))
                        {
                            Prop = _CswNbtResources.MetaData.getObjectClassProp(Request.Property.ObjectClassPropId);
                        }

                        CurrentView.AddViewPropertyAndFilter(relationship, Prop,
                                                             Value: Request.FilterValue,
                                                             Conjunction: Request.FilterConjunction,
                                                             SubFieldName: (CswEnumNbtSubFieldName)Request.FilterSubfield,
                                                             FilterMode: (CswEnumNbtFilterMode)Request.FilterMode,
                                                             ShowInGrid: false       // the user is filtering on a prop not in the grid, don't show it in the grid
                                                             );
                    }
                }
            };
            CurrentView.Root.eachRelationship(eachRel, null);

            _getFilters(Return, CurrentView);
            HashSet <string> seenRels = new HashSet <string>();

            CswNbtViewRoot.forEachRelationship eachRelationship = relationship =>
            {
                if (false == seenRels.Contains(relationship.TextLabel))
                {
                    seenRels.Add(relationship.TextLabel);
                    Return.Step4.Relationships.Add(relationship);
                }
            };
            CurrentView.Root.eachRelationship(eachRelationship, null);

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());
        }
        public void threadCallBack(ICswResources CswResources)
        {
            _LogicRunStatus = CswEnumScheduleLogicRunStatus.Running;

            CswNbtResources CswNbtResources = (CswNbtResources)CswResources;

            CswNbtResources.AuditContext = "Scheduler Task: " + RuleName;

            if (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus)
            {
                try
                {
                    // Find which nodes are out of date
                    CswArbitrarySelect OutOfDateNodesQuerySelect = getValuesToUpdate(CswNbtResources);
                    DataTable          OutOfDateNodes            = null;

                    Int32 NodesPerCycle = CswConvert.ToInt32(CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle));
                    if (NodesPerCycle <= 0)
                    {
                        NodesPerCycle = 25;
                    }
                    OutOfDateNodes = OutOfDateNodesQuerySelect.getTable(0, NodesPerCycle, false);
                    NodesPerCycle  = OutOfDateNodes.Rows.Count; //in case we didn't actually retrieve that amount

                    Int32  ErroneousNodeCount = 0;
                    string ErroneousNodes     = "The following Nodes failed to update:\n";
                    for (Int32 idx = 0; (idx < NodesPerCycle); idx++)
                    {
                        CswPrimaryKey nodeid = new CswPrimaryKey("nodes", CswConvert.ToInt32(OutOfDateNodes.Rows[idx]["nodeid"].ToString()));
                        try//Case 29526 - if updating the node fails for whatever reason, log it and move on
                        {
                            CswNbtNode Node = CswNbtResources.Nodes[nodeid];
                            CswNbtActUpdatePropertyValue CswNbtActUpdatePropertyValue = new CswNbtActUpdatePropertyValue(CswNbtResources);
                            CswNbtActUpdatePropertyValue.UpdateNode(Node, false);
                            // Case 28997:
                            Node.postChanges(ForceUpdate: true);
                        }
                        catch (Exception ex)
                        {
                            if (false == ErroneousNodes.Contains(CswConvert.ToString(nodeid)))
                            {
                                ErroneousNodeCount++;
                                ErroneousNodes += nodeid + " - " + ex.Message + ex.StackTrace + "\n\n";
                            }
                        }
                    }//if we have nodes to process

                    _CswScheduleLogicDetail.StatusMessage = 0 == ErroneousNodeCount ? "Completed without error" : ErroneousNodes;

                    _LogicRunStatus = CswEnumScheduleLogicRunStatus.Succeeded; //last line
                }
                catch (Exception Exception)
                {
                    CswNbtResources.logError(Exception);
                    _CswScheduleLogicDetail.StatusMessage = "CswScheduleLogicNbtUpdtPropVals exception: " + Exception.Message + "; " + Exception.StackTrace;
                    _LogicRunStatus = CswEnumScheduleLogicRunStatus.Failed;//last line
                }
            }//if we're not shutting down
        }//threadCallBack()
        protected override void OnEnable()
        {
            // Clear the C3SyncDate configuration variable
            _CswNbtResources.ConfigVbls.setConfigVariableValue(CswConvert.ToString(CswEnumConfigurationVariableNames.C3SyncDate), string.Empty);

            // Clear the C3SyncDate configuration variable
            _CswNbtResources.ConfigVbls.setConfigVariableValue(CswConvert.ToString(CswEnumConfigurationVariableNames.C3SyncDate), string.Empty);
        }// OnEnable()
        public override CswNbtViewEditorData GetStepData()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());
            base.Finalize(Return);
            return(Return);
        }
Example #19
0
        /// <summary>
        /// Serializes a string into a safe JavaScript string
        /// </summary>
        public static string ToSafeJavaScriptParam(object Param)
        {
            string ParamText = CswConvert.ToString(Param);
            JavaScriptSerializer Serializer = new JavaScriptSerializer();
            string ReturnText = Serializer.Serialize(ParamText);

            return(ReturnText);
        }
Example #20
0
        /// <summary>
        /// Creates a CswNbtViewPropertyFilter and returns its Json
        /// </summary>
        public JObject makeViewPropFilter(CswNbtView View, JObject FilterProp, bool ClearFilters = false)
        {
            JObject Ret = new JObject();

            string FiltArbitraryId = CswConvert.ToString(FilterProp["filtarbitraryid"]);
            string PropArbitraryId = CswConvert.ToString(FilterProp["proparbitraryid"]);

            if (FiltArbitraryId == "undefined")
            {
                FiltArbitraryId = string.Empty;
            }
            if (PropArbitraryId == "undefined")
            {
                PropArbitraryId = string.Empty;
            }

            CswNbtViewPropertyFilter ViewPropFilt = null;

            if (false == string.IsNullOrEmpty(PropArbitraryId))
            {
                CswNbtViewProperty ViewProp = (CswNbtViewProperty)View.FindViewNodeByArbitraryId(PropArbitraryId);

                if (false == string.IsNullOrEmpty(FiltArbitraryId))
                {
                    ViewPropFilt = (CswNbtViewPropertyFilter)View.FindViewNodeByArbitraryId(FiltArbitraryId);
                }
                else
                {
                    ViewPropFilt = View.AddViewPropertyFilter(ViewProp, CswEnumNbtSubFieldName.Unknown, CswEnumNbtFilterMode.Unknown, string.Empty, false);
                }

                //Case 23779, 23937, 24064
                if (ClearFilters && null != ViewPropFilt)
                {
                    ViewProp.Filters.Clear();
                    ViewProp.Filters.Add(ViewPropFilt);
                }
            }

            if (ViewPropFilt != null)
            {
                CswEnumNbtFilterConjunction Conjunction = (CswEnumNbtFilterConjunction)CswConvert.ToString(FilterProp["conjunction"]);
                CswEnumNbtSubFieldName      FieldName   = (CswEnumNbtSubFieldName)CswConvert.ToString(FilterProp["subfieldname"]);
                CswEnumNbtFilterMode        FilterMode  = (CswEnumNbtFilterMode)CswConvert.ToString(FilterProp["filter"]);
                string FilterValue = CswConvert.ToString(FilterProp["filtervalue"]);

                if (FieldName != CswEnumNbtSubFieldName.Unknown &&
                    FilterMode != CswEnumNbtFilterMode.Unknown)
                {
                    ViewPropFilt.FilterMode   = FilterMode;
                    ViewPropFilt.Conjunction  = Conjunction;
                    ViewPropFilt.SubfieldName = FieldName;
                    ViewPropFilt.Value        = FilterValue;
                    _addVbPropFilter(Ret, ViewPropFilt);
                }
            }
            return(Ret);
        }
Example #21
0
        } // getPercentDone()

        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.SyncLocation)
                {
                    BatchNode.start();

                    SyncLocationBatchData BatchData = new SyncLocationBatchData(BatchNode.BatchData.Text);

                    if (BatchData.NodePks.Count > 0)
                    {
                        int NodesProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle));
                        for (int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++)
                        {
                            CswNbtNode Node = _CswNbtResources.Nodes[CswConvert.ToString(BatchData.NodePks[0])];
                            BatchData.NodePks.RemoveAt(0);
                            bool LocationUpdated = false;
                            if (null != Node)
                            {
                                CswNbtMetaDataNodeType NodeType = Node.getNodeType();
                                if (null != NodeType)
                                {
                                    CswNbtMetaDataNodeTypeProp LocationNTP = NodeType.getLocationProperty();
                                    if (null != LocationNTP)
                                    {
                                        CswNbtNodePropLocation LocationProp = Node.Properties[LocationNTP];
                                        if (null != LocationProp)
                                        {
                                            LocationProp.SelectedNodeId = BatchData.LocationId;
                                            Node.postChanges(false);
                                            LocationUpdated = true;
                                        }
                                    }
                                }
                            }//if( null != Node )

                            if (false == LocationUpdated)
                            {
                                BatchNode.appendToLog("Unable to update the location of: " + Node.NodeName + " (" + Node.NodeId.ToString() + ")");
                            }
                        }//for( int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++ )
                    }
                    else
                    {
                        BatchNode.finish();
                    }

                    BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                    BatchNode.BatchData.Text    = BatchData.ToString();
                    BatchNode.postChanges(false);
                }
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        } // runBatchOp()
 public NodeTypeLayout(DataRow LayoutRow)
 {
     LayoutType    = LayoutRow["layouttype"].ToString();
     NodeTypeId    = CswConvert.ToInt32(LayoutRow["nodetypeid"]);
     PropId        = CswConvert.ToInt32(LayoutRow["nodetypepropid"]);
     TabId         = CswConvert.ToInt32(LayoutRow["nodetypetabsetid"]); // This is Int32.MinValue for non-Edit
     DisplayRow    = CswConvert.ToInt32(LayoutRow["display_row"]);
     DisplayColumn = CswConvert.ToInt32(LayoutRow["display_column"]);
     TabGroup      = CswConvert.ToString(LayoutRow["tabgroup"]);
 }
        /// <summary>
        /// Get the Current state of the Property's value using a specific subfield
        /// </summary>
        public string GetSubFieldValue(CswNbtSubField SubField)
        {
            string ret = string.Empty;

            if (null != SubField)
            {
                ret = CswConvert.ToString(_CswNbtNodeProp.GetSubFieldValue(SubField.Name));
            }
            return(ret);
        }
Example #24
0
        }     //ctor

        /// <summary>
        /// For loading from JSON
        /// </summary>
        public CswNbtViewPropertyFilter(CswNbtResources CswNbtResources, CswNbtView View, JObject FilterObj)
            : base(CswNbtResources, View)
        {
            try
            {
                string _Value = CswConvert.ToString(FilterObj["value"]);
                if (!string.IsNullOrEmpty(_Value))
                {
                    Value = _Value;
                }

                string _FilterMode = CswConvert.ToString(FilterObj["filtermode"]);
                if (!string.IsNullOrEmpty(_FilterMode))
                {
                    FilterMode = (CswEnumNbtFilterMode)_FilterMode;
                }

                if (FilterObj["casesensitive"] != null)
                {
                    CaseSensitive = CswConvert.ToBoolean(FilterObj["casesensitive"]);
                }

                if (FilterObj["showatruntime"] != null)
                {
                    ShowAtRuntime = CswConvert.ToBoolean(FilterObj["showatruntime"]);
                }

                string _SfName = CswConvert.ToString(FilterObj["subfieldname"]);
                if (!string.IsNullOrEmpty(_SfName))
                {
                    SubfieldName = (CswEnumNbtSubFieldName)_SfName;
                }

                string _ResultMode = CswConvert.ToString(FilterObj["resultmode"]);
                if (!string.IsNullOrEmpty(_ResultMode))
                {
                    ResultMode = (CswEnumNbtFilterResultMode)_ResultMode;
                }

                string _Conjunction = CswConvert.ToString(FilterObj["conjunction"]);
                if (!string.IsNullOrEmpty(_Conjunction))
                {
                    Conjunction = (CswEnumNbtFilterConjunction)_Conjunction;
                }

                _validate();
            }//try

            catch (Exception ex)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewPropertyFilterValue",
                                          "CswViewPropertyFilterValue.constructor(xmlnode) encountered an invalid attribute value",
                                          ex);
            } //catch
        }     //ctor
Example #25
0
        } // update()

        private void _updateAliasesValue( CswNbtMetaDataObjectClass UoMOC, CswNbtObjClassUnitOfMeasure UoMNode, string NewAliases )
        {
            // The new aliases we want to add
            CswCommaDelimitedString NewAliasesCommaDelimited = new CswCommaDelimitedString( NewAliases );
            CswCommaDelimitedString UpdatedAliases = UoMNode.AliasesAsDelimitedString;

            // Create a view of all UoM nodes and their Aliases property
            CswNbtView UoMView = _CswNbtSchemaModTrnsctn.makeView();
            CswNbtViewRelationship ParentRelationship = UoMView.AddViewRelationship( UoMOC, false );

            CswNbtMetaDataObjectClassProp AliasesOCP = UoMOC.getObjectClassProp( CswNbtObjClassUnitOfMeasure.PropertyName.Aliases );
            UoMView.AddViewProperty( ParentRelationship, AliasesOCP );

            CswCommaDelimitedString AliasesToRemove = new CswCommaDelimitedString();
            ICswNbtTree UoMNodesTree = _CswNbtSchemaModTrnsctn.getTreeFromView( UoMView, false );
            for( int i = 0; i < UoMNodesTree.getChildNodeCount(); i++ )
            {
                UoMNodesTree.goToNthChild( i );
                string CurrentNodeName = UoMNodesTree.getNodeNameForCurrentPosition();
                CswPrimaryKey CurrentNodeId = UoMNodesTree.getNodeIdForCurrentPosition();
                if( CurrentNodeId != UoMNode.NodeId )
                {
                    foreach( CswNbtTreeNodeProp TreeNodeProp in UoMNodesTree.getChildNodePropsOfNode() )
                    {
                        CswCommaDelimitedString CurrentUoMNodeAliases = new CswCommaDelimitedString();
                        CurrentUoMNodeAliases.FromString( TreeNodeProp.Gestalt, false, true );

                        foreach( string alias1 in NewAliasesCommaDelimited )
                        {
                            // If alias1 matches the NodeName or any of the Aliases on the Node, we don't want it
                            if( alias1.Equals( CurrentNodeName ) || CurrentUoMNodeAliases.Any( alias2 => alias1.Equals( alias2 ) ) )
                            {
                                AliasesToRemove.Add( alias1 );
                            }
                        }
                    }
                }
                UoMNodesTree.goToParentNode();
            }

            // Make the updated aliases for the node
            foreach( string alias1 in NewAliasesCommaDelimited )
            {
                if( false == AliasesToRemove.Contains( alias1 ) && false == UoMNode.AliasesAsDelimitedString.Contains( alias1 ) )
                {
                    UpdatedAliases.Add( alias1 );
                }
            }

            // Update the property value
            UoMNode.Aliases.Text = CswConvert.ToString( UpdatedAliases );
            UoMNode.postChanges( false );

        }//_updateAliasesValue()
 private void _addQuickLaunchAction( ViewSelect.Response.Category Category, string Text, CswNbtSessionDataId SessionDataId, CswNbtAction Action )
 {
     Category.items.Add(
         new ViewSelect.Response.Item( CswEnumNbtViewItemType.Action )
         {
             name = Text,
             itemid = SessionDataId.ToString(),
             iconurl = CswNbtMetaDataObjectClass.IconPrefix16 + Action.IconFileName,
             url = CswConvert.ToString( Action.Url )
         } );
 }
Example #27
0
        /// <summary>
        /// Constructor
        /// </summary>
        public CswNbtActionCollection(CswNbtResources Resources, bool ExcludeDisabledActions)
        {
            _CswNbtResources = Resources;

            _ActionSL   = new SortedList();
            _ActionHash = new Hashtable();

            // Actions
            DataTable ActionsTable = null;

            if (ExcludeDisabledActions)
            {
                CswStaticSelect ActionsSelect = _CswNbtResources.makeCswStaticSelect("CswNbtActionCollection.ActionsSelect", "getActiveActions");
                ActionsTable = ActionsSelect.getTable();
            }
            else
            {
                CswTableSelect ActionsSelect = _CswNbtResources.makeCswTableSelect("CswNbtActionCollection.AllActionsSelect", "actions");
                ActionsTable = ActionsSelect.getTable();
            }

            foreach (DataRow ActionRow in ActionsTable.Rows)
            {
                try
                {
                    CswEnumNbtActionName CurrentActionName = CswNbtAction.ActionNameStringToEnum(ActionRow["actionname"].ToString());
                    if (CurrentActionName != CswResources.UnknownEnum)
                    {
                        Int32        ActionId = CswConvert.ToInt32(ActionRow["actionid"]);
                        CswNbtAction Action   = new CswNbtAction(_CswNbtResources,
                                                                 ActionId,
                                                                 ActionRow["url"].ToString(),
                                                                 CurrentActionName,
                                                                 CswConvert.ToBoolean(ActionRow["showinlist"]),
                                                                 ActionRow["category"].ToString(),
                                                                 CswConvert.ToString(ActionRow["iconfilename"]));
                        string ActionNameAsString = CswNbtAction.ActionNameEnumToString(CurrentActionName);
                        if (false == _ActionSL.ContainsKey(ActionNameAsString))
                        {
                            _ActionSL.Add(ActionNameAsString, Action);
                        }
                        if (false == _ActionHash.ContainsKey(ActionId))
                        {
                            _ActionHash.Add(ActionId, Action);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Log the error but keep going
                    _CswNbtResources.logError(new CswDniException(CswEnumErrorType.Error, "System Error", "Encountered an invalid Action: " + ActionRow["actionname"] + " (" + ActionRow["actionid"] + ")", ex));
                }
            }
        }
            private static CswPrimaryKey _setLocationPk(JToken BatchDataLocation)
            {
                CswPrimaryKey Location   = null;
                string        LocationId = CswConvert.ToString(BatchDataLocation);

                if (false == String.IsNullOrEmpty(LocationId))
                {
                    Location = new CswPrimaryKey();
                    Location.FromString(LocationId);
                }
                return(Location);
            }
Example #29
0
        /// <summary>
        /// Deserializes a string into from a safe JavaScript string
        /// </summary>
        public static string FromSafeJavaScriptParam(object Param)
        {
            string ReturnText = CswConvert.ToString(Param);

            try
            {
                JavaScriptSerializer Serializer = new JavaScriptSerializer();
                ReturnText = Serializer.Deserialize <string>(ReturnText);
            }
            catch (Exception) { }
            return(ReturnText);
        }
        private void onAliasesPropChange(CswNbtNodeProp Prop, bool Creating)
        {
            // Remove duplicates
            CswCommaDelimitedString AliasesWithoutDupes = new CswCommaDelimitedString();

            foreach (string Alias in AliasesAsDelimitedString.Where(Alias => false == AliasesWithoutDupes.Contains(Alias)))
            {
                AliasesWithoutDupes.Add(Alias);
            }
            Aliases.Text = CswConvert.ToString(AliasesWithoutDupes);

            _validateAliasUniqueness();
        }