} // GetQuotas() public bool SaveQuotas(string inQuotas) { JObject inQuotasJson = JObject.Parse(inQuotas); if (_CanEditQuotas) { foreach (JObject JObjClass in inQuotasJson["objectclasses"].Children().Values()) { Int32 ObjectClassId = CswConvert.ToInt32(JObjClass["objectclassid"]); Int32 NewOCQuota = CswConvert.ToInt32(JObjClass["quota"]); bool ExcludeInQuotaBarOC = CswConvert.ToBoolean(JObjClass["excludeinquotabar"]); _CswNbtActQuotas.SetQuotaForObjectClass(ObjectClassId, NewOCQuota, ExcludeInQuotaBarOC); foreach (JObject JNodeType in JObjClass["nodetypes"].Children().Values()) { Int32 NodeTypeId = CswConvert.ToInt32(JNodeType["nodetypeid"]); Int32 NewNTQuota = CswConvert.ToInt32(JNodeType["quota"]); bool ExcludeInQuotaBarNT = CswConvert.ToBoolean(JNodeType["excludeinquotabar"]); _CswNbtActQuotas.SetQuotaForNodeType(NodeTypeId, NewNTQuota, ExcludeInQuotaBarNT); } // foreach( DataRow OCRow in OCTable.Rows ) } // foreach( DataRow OCRow in OCTable.Rows ) return(true); } // if( CanEditQuotas ) else { return(false); } } // SaveQuotas()
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()
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 )); }
public override void ReadDataRow(DataRow PropRow, Dictionary <string, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap) { if (PropRow.Table.Columns.Contains(_LowerSubField.ToXmlNodeName())) { string Val = CswTools.XmlRealAttributeName(PropRow[_LowerSubField.ToXmlNodeName()].ToString()); if (Val != string.Empty) { Lower = Convert.ToDouble(PropRow[_LowerSubField.ToXmlNodeName()].ToString()); } } if (PropRow.Table.Columns.Contains(_TargetSubField.ToXmlNodeName())) { string Val = CswTools.XmlRealAttributeName(PropRow[_TargetSubField.ToXmlNodeName()].ToString()); if (Val != string.Empty) { Target = Convert.ToDouble(PropRow[_TargetSubField.ToXmlNodeName()].ToString()); } } if (PropRow.Table.Columns.Contains(_UpperSubField.ToXmlNodeName())) { string Val = CswTools.XmlRealAttributeName(PropRow[_UpperSubField.ToXmlNodeName()].ToString()); if (Val != string.Empty) { Upper = Convert.ToDouble(PropRow[_UpperSubField.ToXmlNodeName()].ToString()); } } if (PropRow.Table.Columns.Contains(_LowerInclusiveSubField.ToXmlNodeName())) { LowerInclusive = CswConvert.ToBoolean(CswTools.XmlRealAttributeName(PropRow[_LowerInclusiveSubField.ToXmlNodeName()].ToString())); } if (PropRow.Table.Columns.Contains(_UpperInclusiveSubField.ToXmlNodeName())) { UpperInclusive = CswConvert.ToBoolean(CswTools.XmlRealAttributeName(PropRow[_UpperInclusiveSubField.ToXmlNodeName()].ToString())); } }
private static CswScheduleLogicDetail _getLogicDetailFromGridRow(CswExtJsGridRow GridRow, String GridPrefix) { DateTime StartTime = String.IsNullOrEmpty(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.RunStartTime)]) ? DateTime.MinValue : DateTime.Parse(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.RunStartTime)]); DateTime EndTime = String.IsNullOrEmpty(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.RunEndTime)]) ? DateTime.MinValue : DateTime.Parse(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.RunEndTime)]); DateTime LoadCheckTime = String.IsNullOrEmpty(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.LastLoadCheck)]) ? DateTime.MinValue : DateTime.Parse(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.LastLoadCheck)]); CswScheduleLogicDetail Rule = new CswScheduleLogicDetail { RuleName = GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.RuleName)], Recurrence = GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.Recurrance)], Interval = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.Interval)]), ReprobateThreshold = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.ReprobateThreshold)]), MaxRunTimeMs = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.MaxRunTimeMs)]), Reprobate = CswConvert.ToBoolean(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.Reprobate)]), RunStartTime = StartTime, RunEndTime = EndTime, TotalRogueCount = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.TotalRogueCount)]), FailedCount = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.FailedCount)]), ThreadId = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.ThreadId)]), StatusMessage = GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.StatusMessage)], Priority = Convert.ToUInt16(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.Priority)]), LoadCount = CswConvert.ToInt32(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.LoadCount)]), LastLoadCheck = LoadCheckTime, Disabled = CswConvert.ToBoolean(GridRow.data[new CswExtJsGridDataIndex(GridPrefix, CswEnumScheduleLogicDetailColumnNames.Disabled)]) }; return(Rule); }
public CswNbtView restoreView(CswNbtViewId NbtViewId) { CswNbtView ReturnVal = null; CswTableSelect ViewsTableSelect = _CswNbtResources.makeCswTableSelect("restoreView_select", "node_views"); if (NbtViewId.isSet()) { Int32 ViewId = NbtViewId.get(); if (Int32.MinValue != ViewId) { DataTable ViewTable = ViewsTableSelect.getTable("nodeviewid", ViewId); if (ViewTable.Rows.Count > 0) { string ViewAsString = ViewTable.Rows[0]["viewxml"].ToString(); ReturnVal = restoreView(ViewAsString); ReturnVal.ViewId = NbtViewId; ReturnVal.Visibility = (CswEnumNbtViewVisibility)ViewTable.Rows[0]["visibility"].ToString(); ReturnVal.VisibilityRoleId = new CswPrimaryKey("nodes", CswConvert.ToInt32(ViewTable.Rows[0]["roleid"])); ReturnVal.VisibilityUserId = new CswPrimaryKey("nodes", CswConvert.ToInt32(ViewTable.Rows[0]["userid"])); ReturnVal.Category = ViewTable.Rows[0]["category"].ToString(); ReturnVal.ViewName = ViewTable.Rows[0]["viewname"].ToString(); ReturnVal.IsDemo = CswConvert.ToBoolean(ViewTable.Rows[0]["isdemo"].ToString()); ReturnVal.IsSystem = CswConvert.ToBoolean(ViewTable.Rows[0]["issystem"].ToString()); } } } else { throw new CswDniException(CswEnumErrorType.Error, "Attempt to restore view failed.", "CswNbtViewSelect was handed an invalid NbtViewId in restoreView()."); } return(ReturnVal); }//restoreView()
public ICswResources make() { CswSetupVbls SetupVbls = new CswSetupVbls(CswEnumSetupMode.NbtExe); CswEnumPooledConnectionState PooledConnectionState; if (SetupVbls.doesSettingExist("CloseSchedulerDbConnections")) { if (true == CswConvert.ToBoolean(SetupVbls["CloseSchedulerDbConnections"])) { PooledConnectionState = CswEnumPooledConnectionState.Closed; } else { PooledConnectionState = CswEnumPooledConnectionState.Open; } } else { PooledConnectionState = CswEnumPooledConnectionState.Closed; } CswNbtResources ReturnVal = CswNbtResourcesFactory.makeCswNbtResources(CswEnumAppType.Nbt, CswEnumSetupMode.NbtExe, true, null, PooledConnectionState); ReturnVal.InitCurrentUser = InitUser; return(ReturnVal); }
//private string _TableName = "logicalsetitem"; // ToXml() public override void ToJSON(JObject ParentObject) { ParentObject[_ElemName_LogicalSetJson] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); DataTable Data = GetDataAsTable(_NameColumn, _KeyColumn); foreach (DataColumn Column in Data.Columns) { if (Column.ColumnName != _NameColumn && Column.ColumnName != _KeyColumn && false == CBAOptions.Columns.Contains(Column.ColumnName)) { CBAOptions.Columns.Add(Column.ColumnName); } } foreach (DataRow Row in Data.Rows) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = Row[_KeyColumn].ToString(); Option.Label = Row[_NameColumn].ToString(); for (Int32 i = 0; i < CBAOptions.Columns.Count; i++) { Option.Values.Add(CswConvert.ToBoolean(Row[CBAOptions.Columns[i]].ToString())); } CBAOptions.Options.Add(Option); } CBAOptions.ToJSON((JObject)ParentObject[_ElemName_LogicalSetJson]); } // ToJSON()
}//getScheduledRulesGrid() public static void updateAllScheduledRules(ICswResources CswResources, CswNbtScheduledRulesReturn Return, CswNbtScheduledRulesReturn.Ret Request) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswSchedSvcReturn svcReturn = new CswSchedSvcReturn(); CswSchedSvcAdminEndPointClient SchedSvcRef = new CswSchedSvcAdminEndPointClient(); //Overwrite the app.config endpoint uri with the one defined in SetupVbls EndpointAddress URI = new EndpointAddress(CswResources.SetupVbls["SchedServiceUri"]); SchedSvcRef.Endpoint.Address = URI; CswSchedSvcParams CswSchedSvcParams = new CswSchedSvcParams(); CswSchedSvcParams.CustomerId = Request.CustomerId; CswSchedSvcParams.LogicDetails = new Collection <CswScheduleLogicDetail>(); foreach (CswExtJsGridRow GridRow in Request.Grid.rowData.rows) { if (CswConvert.ToBoolean(GridRow.data[new CswExtJsGridDataIndex("ScheduledRules", CswEnumScheduleLogicDetailColumnNames.HasChanged)])) { CswScheduleLogicDetail Rule = _getLogicDetailFromGridRow(GridRow, "ScheduledRules"); CswSchedSvcParams.LogicDetails.Add(Rule); } } svcReturn = SchedSvcRef.updateScheduledRules(CswSchedSvcParams); if (null != svcReturn) { _updateScheduledRulesTable(NbtResources, CswSchedSvcParams.LogicDetails); _addScheduledRulesGrid(NbtResources, svcReturn.Data, Return); } }
} // 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()
public override void update() { CswNbtView DueInspectionsAllView = _CswNbtSchemaModTrnsctn.restoreView( "Due Inspections (all)" ); if( null != DueInspectionsAllView ) { // Set the view name DueInspectionsAllView.ViewName = "Due Inspections"; // Show the due date filter at runtime CswNbtMetaDataObjectClass InspectionDesignOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.InspectionDesignClass ); CswNbtMetaDataObjectClassProp DueDateOCP = InspectionDesignOC.getObjectClassProp( CswNbtObjClassInspectionDesign.PropertyName.DueDate ); foreach( CswNbtViewRelationship ViewRelationship in DueInspectionsAllView.Root.ChildRelationships ) { foreach( CswNbtViewProperty ViewProperty in ViewRelationship.Properties ) { if( ViewProperty.ObjectClassPropId == DueDateOCP.ObjectClassPropId ) { foreach( CswNbtViewPropertyFilter ViewPropertyFilter in ViewProperty.Filters ) { if( ViewPropertyFilter.Value == "today+7" ) { ViewPropertyFilter.ShowAtRuntime = CswConvert.ToBoolean( CswEnumTristate.True ); break; } } } } } DueInspectionsAllView.save(); } } // update()
public override void ToJSON( JObject ParentObject ) { ParentObject[_SelectedViewIdsSubField.ToXmlNodeName()] = SelectedViewIds.ToString(); ParentObject["selectmode"] = SelectMode.ToString(); ParentObject[_CachedViewNameSubField.ToXmlNodeName()] = CachedViewNames.ToString(); ParentObject[ElemName_Options] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); CBAOptions.Columns.Add( "Include" ); DataTable ViewsTable = ViewsForCBA(); foreach( DataRow ViewRow in ViewsTable.Rows ) { bool isSelected = SelectedViewIds.Contains( ViewRow[KeyColumn] ); if( IsEditModeEditable || isSelected ) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = ViewRow[KeyColumn].ToString(); Option.Label = ViewRow[NameColumn].ToString(); Option.Values.Add( CswConvert.ToBoolean( ViewRow[ValueColumn] ) ); CBAOptions.Options.Add( Option ); } } CBAOptions.ToJSON( (JObject) ParentObject[ElemName_Options] ); } // ToJSON()
public void getQuickLaunchJson( ref ViewSelect.Response.Category Category ) { CswTableSelect SessionDataSelect = _CswNbtResources.makeCswTableSelect( "getQuickLaunchXml_select", "session_data" ); Collection<OrderByClause> OrderBy = new Collection<OrderByClause>(); OrderBy.Add( new OrderByClause( SessionDataColumn_PrimaryKey, CswEnumOrderByType.Descending ) ); string WhereClause = @"where " + SessionDataColumn_SessionId + "='" + _CswNbtResources.Session.SessionId + "' and " + SessionDataColumn_QuickLaunch + " = '" + CswConvert.ToDbVal( true ).ToString() + "'"; DataTable SessionDataTable = SessionDataSelect.getTable( WhereClause, OrderBy ); Int32 RowCount = 0; foreach( DataRow Row in SessionDataTable.Rows ) { bool KeepInQuickLaunch = CswConvert.ToBoolean( Row[SessionDataColumn_KeepInQuickLaunch] ); if( KeepInQuickLaunch ) { _addQuickLaunchProp( Row, Category ); } else if( RowCount < 5 ) { _addQuickLaunchProp( Row, Category ); RowCount++; } } } // getQuickLaunchJson()
public void FromJObject(JObject SearchObj) { SearchTerm = SearchObj["searchterm"].ToString(); if (null != SearchObj["searchtype"]) { SearchType = (CswEnumSqlLikeMode)SearchObj["searchtype"].ToString(); } if (null != SearchObj["name"]) { Name = SearchObj["name"].ToString(); } if (null != SearchObj["category"]) { Category = SearchObj["category"].ToString(); } if (null != SearchObj["searchid"]) { SearchId = new CswPrimaryKey(CswNbtSearchManager.SearchTableName, CswConvert.ToInt32(SearchObj["searchid"])); } if (null != SearchObj["sessiondataid"]) { SessionDataId = new CswNbtSessionDataId(SearchObj["sessiondataid"].ToString()); } if (null != SearchObj["onlymergeablenodetypes"]) { OnlyMergeableNodeTypes = CswConvert.ToBoolean(SearchObj["onlymergeablenodetypes"]); } JArray FiltersArr = (JArray)SearchObj["filtersapplied"]; foreach (JObject FilterObj in FiltersArr) { addFilter(FilterObj); } } // FromJObject()
} //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
/// <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)); } } }
/// <summary> /// Enable/disable a module in an ORNy safe fashion /// </summary> private void _updateModule(CswEnumNbtModuleName Module, bool Enable) { int moduleid = GetModuleId(Module); if (false == _RulesAreInitialized) { initModules(); } bool ModuleEnabled = false; if (Enable) { string ErrorMsg = _ModuleRules[Module].CanModuleBeEnabled(); if (false == String.IsNullOrEmpty(ErrorMsg)) { throw new CswDniException(CswEnumErrorType.Warning, "The " + Module.Value + " module cannot be enabled because: " + ErrorMsg, "The Module was not able to be enabled because an error message was returned from the CanModuleBeEnabled functuon"); } } CswTableUpdate ModuleUpdate = _CswNbtResources.makeCswTableUpdate("ModuleManager.UpdateModule", "modules"); DataTable ModulesTbl = ModuleUpdate.getTable("moduleid", moduleid); foreach (DataRow row in ModulesTbl.Rows) //should only ever get one row { ModuleEnabled = CswConvert.ToBoolean(row["enabled"]); row["enabled"] = CswConvert.ToDbVal(Enable); _ModuleRules[Module].Enabled = Enable; } //Case 31546 - if we're DISABLING a module, we have to call Disable() BEFORE reseting available metadata or metadata objects hidden by the module will not be fetchable in the toggle events if (false == Enable && ModuleEnabled) { _ModuleRules[Module].Disable(); } ModuleUpdate.update(ModulesTbl); _CswNbtResources.MetaData.ResetEnabledNodeTypes(); _CswNbtResources.finalize(); _CswNbtResources.MetaData.refreshAll(); //Case 31546 - if we ENABLING a module, we have to call Enable() AFTER reseting available metadata or modules won't be able to find their child metadata objects if (Enable && false == ModuleEnabled) { _ModuleRules[Module].Enable(); } //We have to clear Session data or the view selects recent views will have non-accesible views and break _CswNbtResources.SessionDataMgr.removeAllSessionData(_CswNbtResources.Session.SessionId); }
private bool _getRowBoolVal(CswEnumNbtPropColumn ColumnName) { bool ReturnVal = false; if (_PropRow != null) { if (_PropsTable.Columns.Contains(ColumnName.ToString()) && !_PropRow.IsNull(ColumnName.ToString())) { ReturnVal = CswConvert.ToBoolean(_PropRow[ColumnName.ToString()]); } } return(ReturnVal); }
public CswSessionResourcesNbt(HttpApplicationState HttpApplicationState, HttpRequest HttpRequest, HttpResponse HttpResponse, HttpContext Context, string LoginAccessId, CswEnumSetupMode SetupMode) { //SuperCycleCache configuraiton has to happen here because here is where we can stash the cache, //so to speak, in the wrapper class -- the resource factory is agnostic with respect to cache type CswSetupVbls SetupVbls = new CswSetupVbls(CswEnumSetupMode.NbtWeb); ICswSuperCycleCache CswSuperCycleCache = new CswSuperCycleCacheWeb(Context.Cache); // Set the cache to drop anything 10 minutes old CswSuperCycleCache.CacheDirtyThreshold = DateTime.Now.Subtract(new TimeSpan(0, 10, 0)); CswDbCfgInfo CswDbCfgInfo = new CswDbCfgInfo(CswEnumSetupMode.NbtWeb); CswResourcesMaster = new CswResources(CswEnumAppType.Nbt, SetupVbls, CswDbCfgInfo, new CswSuperCycleCacheDefault(), null); CswResourcesMaster.SetDbResources(ChemSW.RscAdo.CswEnumPooledConnectionState.Open); CswResourcesMaster.AccessId = CswDbCfgInfo.MasterAccessId; CswNbtResources = CswNbtResourcesFactory.makeCswNbtResources(CswEnumAppType.Nbt, SetupMode, true, CswSuperCycleCache, RscAdo.CswEnumPooledConnectionState.Open, CswResourcesMaster, CswResourcesMaster.CswLogger); bool RecordStatistics = CswConvert.ToBoolean(CswNbtResources.SetupVbls[CswEnumSetupVariableNames.RecordUserStatistics]); //Dictionary<string, string> Cookies = new Dictionary<string, string>(); //foreach( string CookieName in Context.Request.Cookies ) //{ // Cookies[CookieName] = Context.Request.Cookies[CookieName].Value; //} CswNbtSchemaAuthenticatorFactory AuthenticatorFactory = new CswNbtSchemaAuthenticatorFactory(CswNbtResources); ICswSchemaAuthenticater Authenticator = AuthenticatorFactory.Make(CswNbtResources.SetupVbls); CswSessionManager = new CswSessionManager(CswEnumAppType.Nbt, new CswWebClientStorageHttpHeader(HttpRequest, HttpResponse), //new CswWebClientStorageCookies( HttpRequest, HttpResponse ), LoginAccessId, CswNbtResources.SetupVbls, CswNbtResources.CswDbCfgInfo, CswNbtResources, CswResourcesMaster, Authenticator, //Cookies, _CswNbtStatistics = new CswNbtStatistics(new CswNbtStatisticsStorageDb(CswNbtResources), new CswNbtStatisticsStorageStateServer(), RecordStatistics)); CswNbtResources.CswSessionManager = CswSessionManager; CswNbtStatisticsEvents = _CswNbtStatistics.CswNbtStatisticsEvents; CswSessionManager.OnDeauthenticate += new CswSessionManager.DeathenticationHandler(OnDeauthenticate); CswNbtResources.AccessId = CswSessionManager.AccessId; }//ctor()
public DataTable GetDataAsTable(string NameColumn, string KeyColumn) { DataTable Data = new CswDataTable("GetDataAsTable_DataTable", ""); Data.Columns.Add(NameColumn); Data.Columns.Add(KeyColumn); foreach (string XValue in XValues) { Data.Columns.Add(XValue, typeof(bool)); } //if( _CswNbtMetaDataNodeTypeProp.IsFK && _CswNbtMetaDataNodeTypeProp.FKType == "fkeydefid" ) if (CswConvert.ToBoolean(_CswNbtNodePropData[CswNbtFieldTypeRuleLogicalSet.AttributeName.IsFK]) && _CswNbtNodePropData[CswNbtFieldTypeRuleLogicalSet.AttributeName.FKType] == "fkeydefid") { CswTableSelect FkeyDefsSelect = _CswNbtResources.makeCswTableSelect("YValues_fkeydef_select", "fkey_definitions"); //DataTable FkeyDefsTable = FkeyDefsSelect.getTable( "fkeydefid", _CswNbtMetaDataNodeTypeProp.FKValue ); DataTable FkeyDefsTable = FkeyDefsSelect.getTable("fkeydefid", CswConvert.ToInt32(_CswNbtNodePropData[CswNbtFieldTypeRuleLogicalSet.AttributeName.FKValue])); string Sql = FkeyDefsTable.Rows[0]["sql"].ToString(); CswArbitrarySelect YValuesSelect = _CswNbtResources.makeCswArbitrarySelect("YValues_select", Sql); DataTable YValuesTable = YValuesSelect.getTable(); foreach (DataRow CurrentYValueRow in YValuesTable.Rows) { DataRow Row = Data.NewRow(); Row[NameColumn] = CurrentYValueRow[FkeyDefsTable.Rows[0]["ref_column"].ToString()].ToString(); Row[KeyColumn] = CurrentYValueRow[FkeyDefsTable.Rows[0]["pk_column"].ToString()].ToString(); foreach (string XValue in XValues) { Row[XValue] = CheckValue(XValue, Row[KeyColumn].ToString()); } Data.Rows.Add(Row); } } else { foreach (string YValue in YValues) { DataRow Row = Data.NewRow(); Row[NameColumn] = YValue; Row[KeyColumn] = YValue; foreach (string XValue in XValues) { Row[XValue] = CheckValue(XValue, YValue); } Data.Rows.Add(Row); } } return(Data); }
public static void CreateCafProps(CswNbtResources NbtResources, List <string> NodeTypes, string PropsValsTblName, string PropsValsPKName, CswEnumSetupMode SetupMode) { CswNbtSchemaUpdateImportMgr ImpMgr = new CswNbtSchemaUpdateImportMgr(new CswNbtSchemaModTrnsctn(NbtResources), "CAF", ImporterSetUpMode: SetupMode); string sql = GetCAFPropertiesSQL(PropsValsTblName, NodeTypes); CswArbitrarySelect cafChemPropAS = NbtResources.makeCswArbitrarySelect("cafProps_" + PropsValsPKName, sql); DataTable cafChemPropsDT = cafChemPropAS.getTable(); foreach (DataRow row in cafChemPropsDT.Rows) { foreach (string nt in NodeTypes) { CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType(nt); string PropName = row["propertyname"].ToString(); int PropId = CswConvert.ToInt32(row["propertyid"]); PropName = GetUniquePropName(NodeType, PropName); //keep appending numbers until we have a unique prop name CswEnumNbtFieldType propFT = GetFieldTypeFromCAFPropTypeCode(row["propertytype"].ToString()); CswNbtMetaDataNodeTypeProp newProp = NbtResources.MetaData.makeNewProp(new CswNbtWcfMetaDataModel.NodeTypeProp(NodeType, NbtResources.MetaData.getFieldType(propFT), PropName) { IsRequired = CswConvert.ToBoolean(row["required"]), ReadOnly = CswConvert.ToBoolean(row["readonly"]), ListOptions = CswConvert.ToString(row["listopts"]) }); newProp.removeFromAllLayouts(); string cafColPropName = "prop" + row["propertyid"]; string cafSourceCol = "propvaltext"; if (CswEnumNbtFieldType.DateTime == propFT) { cafSourceCol = "propvaldate"; } else if (CswEnumNbtFieldType.Number == propFT) { cafSourceCol = "propvalnumber"; } ImpMgr.importBinding(cafSourceCol, PropName, "", "CAF", NodeType.NodeTypeName, ClobTableName: PropsValsTblName, LobDataPkColOverride: cafColPropName, LobDataPkColName: PropsValsPKName, LegacyPropId: PropId); } } NbtResources.commitTransaction(); ImpMgr.finalize(); }
/// <summary> /// For loading from a string (created by ToString()) /// </summary> public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, CswDelimitedString PropertyString) : base(CswNbtResources, View) { if (PropertyString[0] == CswEnumNbtViewNodeType.CswNbtViewProperty.ToString()) { if (PropertyString[1] != string.Empty) { Type = PropertyString[1]; } if (PropertyString[2] != string.Empty) { NodeTypePropId = CswConvert.ToInt32(PropertyString[2]); } if (PropertyString[3] != string.Empty) { Name = PropertyString[3]; } //if( Values[4] != string.Empty ) // ArbitraryId = Values[4]; if (PropertyString[5] != string.Empty) { SortBy = Convert.ToBoolean(PropertyString[5]); } if (PropertyString[6] != string.Empty) { SortMethod = PropertyString[6]; } if (PropertyString[7] != string.Empty) { FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(PropertyString[7]); } if (PropertyString[8] != string.Empty) { Order = CswConvert.ToInt32(PropertyString[8]); } if (PropertyString[9] != string.Empty) { Width = CswConvert.ToInt32(PropertyString[9]); } if (PropertyString[10] != string.Empty) { ObjectClassPropId = CswConvert.ToInt32(PropertyString[10]); } if (PropertyString[11] != string.Empty) { ShowInGrid = CswConvert.ToBoolean(PropertyString[11]); } } }
private ContainerData.UnscannedLocation _makeUnscannedLocation(CswPrimaryKey LocationId) { ContainerData.UnscannedLocation UnscannedLocation = new ContainerData.UnscannedLocation(); CswNbtObjClassLocation LocationNode = _CswNbtResources.Nodes[LocationId]; if (null != LocationNode) { UnscannedLocation.LocationId = LocationId.ToString(); UnscannedLocation.Name = LocationNode.Name.Text; UnscannedLocation.Path = LocationNode.Location.CachedFullPath; UnscannedLocation.Link = LocationNode.Node.NodeLink; UnscannedLocation.AllowInventory = CswConvert.ToBoolean(LocationNode.AllowInventory.Checked); } return(UnscannedLocation); }
} // ToJObject() public JObject FromJObject(JObject FilterObj) { FilterName = FilterObj["filtername"].ToString(); Type = (CswEnumNbtSearchFilterType)FilterObj["filtertype"].ToString(); FilterId = FilterObj["filterid"].ToString(); Count = CswConvert.ToInt32(FilterObj["count"]); Icon = FilterObj["icon"].ToString(); Removeable = CswConvert.ToBoolean(FilterObj["removeable"]); Source = (CswEnumNbtSearchPropOrderSourceType)FilterObj["source"].ToString(); FilterValue = FilterObj["filtervalue"].ToString(); FirstVersionId = CswConvert.ToInt32(FilterObj["firstversionid"]); FirstPropVersionId = CswConvert.ToInt32(FilterObj["firstpropversionid"]); ObjectClassId = CswConvert.ToInt32(FilterObj["objectclassid"]); PropertySetId = CswConvert.ToInt32(FilterObj["propertysetid"]); return(FilterObj); } // FromJObject()
public void RefreshStringValue(bool SetPendingUpdate = true) { string CheckedNames = string.Empty; DataTable Data = GetDataAsTable("Name", "Key"); if (XValues.Count == 1) { foreach (DataRow Row in Data.Rows) { if (CswConvert.ToBoolean(Row[XValues[0]])) { if (CheckedNames != string.Empty) { CheckedNames += ","; } CheckedNames += Row["Name"].ToString(); } } } else { foreach (string XValue in XValues) { if (CheckedNames != string.Empty) { CheckedNames += ";"; } CheckedNames += XValue + ":"; string ThisCheckedNames = string.Empty; foreach (DataRow Row in Data.Rows) { if (CswConvert.ToBoolean(Row[XValues[0]])) { if (ThisCheckedNames != string.Empty) { ThisCheckedNames += ","; } ThisCheckedNames += Row["Name"].ToString(); } } CheckedNames += ThisCheckedNames; } } SetPropRowValue(CswEnumNbtSubFieldName.Gestalt, CswEnumNbtPropColumn.Gestalt, CheckedNames); PendingUpdate = SetPendingUpdate; }
/// <summary> /// NOTE: In this case, 'hidden' means hidden from the Modules page on the UI. This does /// not restrict you from accessing the module on the server. /// </summary> /// <param name="Module"></param> /// <returns></returns> public bool ModuleIsHidden(CswEnumNbtModuleName Module) { bool Ret = false; int ModuleId = _CswNbtResources.Modules.GetModuleId(Module); CswTableSelect ModulesTblSelect = _CswNbtResources.makeCswTableSelect("isModuleHidden", "modules"); DataTable ModulesDt = ModulesTblSelect.getTable("where moduleid = " + ModuleId); if (ModulesDt.Rows.Count > 0) { if (CswConvert.ToBoolean(ModulesDt.Rows[0]["hidden"])) { Ret = true; } } return(Ret); }
}//ctor /// <summary> /// For loading from XML /// </summary> public CswNbtViewPropertyFilter(CswNbtResources CswNbtResources, CswNbtView View, XmlNode FilterNode) : base(CswNbtResources, View) { try { if (FilterNode.Attributes["value"] != null) { Value = FilterNode.Attributes["value"].Value; } if (FilterNode.Attributes["filtermode"] != null) { FilterMode = (CswEnumNbtFilterMode)FilterNode.Attributes["filtermode"].Value; } if (FilterNode.Attributes["casesensitive"] != null) { CaseSensitive = CswConvert.ToBoolean(FilterNode.Attributes["casesensitive"].Value); } if (FilterNode.Attributes["showatruntime"] != null) { ShowAtRuntime = CswConvert.ToBoolean(FilterNode.Attributes["showatruntime"].Value); } if (FilterNode.Attributes["subfieldname"] != null) { SubfieldName = (CswEnumNbtSubFieldName)FilterNode.Attributes["subfieldname"].Value; } if (FilterNode.Attributes["resultmode"] != null) { ResultMode = (CswEnumNbtFilterResultMode)FilterNode.Attributes["resultmode"].Value; } if (FilterNode.Attributes["conjunction"] != null) { Conjunction = FilterNode.Attributes["conjunction"].Value; } _validate(); }//try catch (Exception ex) { throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewPropertyFilterValue", "CswViewPropertyFilterValue.constructor(xmlnode) encountered an invalid attribute value", ex); } //catch } //ctor
private bool _validateContainer(ref OperationData OpData) { bool ret = false; ICswNbtTree tree = _getTree(CswEnumNbtObjectClass.ContainerClass, OpData.Field1.Value, true); if (tree.getChildNodeCount() > 0) { tree.goToNthChild(0); foreach (CswNbtTreeNodeProp treeNodeProp in tree.getChildNodePropsOfNode()) { if (treeNodeProp.PropName.Equals(CswNbtObjClassContainer.PropertyName.Disposed)) { bool disposed = CswConvert.ToBoolean(treeNodeProp.Field1); if (disposed) { OpData.Field1.StatusMsg = "Cannot perform " + OpData.Mode + " operation on disposed Container " + OpData.Field1.Value; OpData.Log.Add(DateTime.Now + " - ERROR: " + OpData.Field1.StatusMsg); } if (false == disposed) { OpData.Field1.NodeIdStr = tree.getNodeIdForCurrentPosition().ToString(); ret = true; } } else if (treeNodeProp.PropName.Equals(CswNbtObjClassContainer.PropertyName.Quantity)) { OpData.Field1.SecondValue = " (current quantity: " + treeNodeProp.Gestalt + ")"; OpData.ScanTextLabel = "Enter a quantity (" + treeNodeProp.Field1 + ") :"; } } } else { OpData.Field1.StatusMsg = "Could not find a Container with barcode " + OpData.Field1.Value; OpData.Field1.ServerValidated = false; OpData.Log.Add(DateTime.Now + " - ERROR: " + OpData.Field1.StatusMsg); } return(ret); }
/// <summary> /// For loading from a string (created by ToString()) /// </summary> public CswNbtViewPropertyFilter(CswNbtResources CswNbtResources, CswNbtView View, CswDelimitedString FilterString) : base(CswNbtResources, View) { if (FilterString[0] == CswEnumNbtViewNodeType.CswNbtViewPropertyFilter.ToString()) { if (FilterString[1] != string.Empty) { Conjunction = (CswEnumNbtFilterConjunction)FilterString[1].ToString(); } if (FilterString[2] != string.Empty) { Value = FilterString[2].ToString(); } if (FilterString[3] != string.Empty) { FilterMode = (CswEnumNbtFilterMode)FilterString[3].ToString(); } if (FilterString[4] != string.Empty) { CaseSensitive = CswConvert.ToBoolean(FilterString[4].ToString()); } //if( Values[ 5 ] != String.Empty ) //{ // ArbitraryId = Values[ 5 ].ToString(); //} if (FilterString[6] != string.Empty) { SubfieldName = (CswEnumNbtSubFieldName)FilterString[6].ToString(); } if (FilterString[7] != string.Empty) { ShowAtRuntime = CswConvert.ToBoolean(FilterString[7]); } if (FilterString[8] != string.Empty) { ResultMode = (CswEnumNbtFilterResultMode)FilterString[8].ToString(); } _validate(); } }//ctor
/// <summary> /// Update the attributes of an Object Class Prop, and cascade changes to existing NodeTypeProps /// </summary> public void UpdateObjectClassProp(CswNbtMetaDataObjectClassProp ObjectClassProp, CswEnumNbtObjectClassPropAttributes AttributeColumnName, object Value) { if (AttributeColumnName != CswResources.UnknownEnum) { string AttributeColumnNameString = CswNbtMetaDataObjectClassProp.getObjectClassPropAttributesAsString(AttributeColumnName); object DBValue = CswConvert.ToDbVal(Value); if (ObjectClassProp._DataRow[AttributeColumnNameString] != DBValue) { ObjectClassProp._DataRow[AttributeColumnNameString] = DBValue; if (AttributeColumnName == CswEnumNbtObjectClassPropAttributes.setvalonadd) { ObjectClassProp._DataRow[CswNbtMetaDataObjectClassProp.getObjectClassPropAttributesAsString(CswEnumNbtObjectClassPropAttributes.display_col_add)] = DBNull.Value; ObjectClassProp._DataRow[CswNbtMetaDataObjectClassProp.getObjectClassPropAttributesAsString(CswEnumNbtObjectClassPropAttributes.display_row_add)] = DBNull.Value; } _CswNbtMetaDataResources.ObjectClassPropTableUpdate.update(ObjectClassProp._DataRow.Table); foreach (CswNbtMetaDataNodeTypeProp NodeTypeProp in ObjectClassProp.getNodeTypeProps()) { CswNbtFieldTypeAttribute attr = NodeTypeProp.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == AttributeColumnName); if (null != attr) { CswNbtNodePropWrapper attrProp = NodeTypeProp.DesignNode.AttributeProperty[attr.Name]; attrProp.SetSubFieldValue(attrProp.NodeTypeProp.getFieldTypeRule().SubFields.Default, DBValue); } if (AttributeColumnName == CswEnumNbtObjectClassPropAttributes.setvalonadd) { if (CswConvert.ToBoolean(Value)) { NodeTypeProp.updateLayout(CswEnumNbtLayoutType.Add, true); } else { NodeTypeProp.removeFromLayout(CswEnumNbtLayoutType.Add); } } } } } } // UpdateObjectClassProp()