}//checkC3ServiceReferenceStatus() private bool _checkConnection(SearchClient SearchClient) { bool Ret = false; CswWebSvcReturnBaseStatus Status = new CswWebSvcReturnBaseStatus(); CswC3Params CswC3Params = new CswC3Params(); if (null != _CswC3Params) { CswC3Params = _CswC3Params; } else { CswC3Params.AccessId = _CswC3SearchParams.AccessId; CswC3Params.CustomerLoginName = _CswC3SearchParams.CustomerLoginName; CswC3Params.LoginPassword = _CswC3SearchParams.LoginPassword; } Status = SearchClient.canConnect(CswC3Params); if (Status.Success) { Ret = true; } else { foreach (CswWebSvcReturnBaseErrorMessage Message in Status.Messages) { _createMessage(Message.Type, Message.Detail, true, Message.Message); } } return(Ret); }
public CswNbtC3ClientManager(CswNbtResources CswNbtResources, CswC3Params CswC3Params) { _CswNbtResources = CswNbtResources; _CswC3Params = CswC3Params; _setRegulationDatabase(); _setDataService(); }//ctor1
public void threadCallBack(ICswResources CswResources) { _LogicRunStatus = CswEnumScheduleLogicRunStatus.Running; CswNbtResources CswNbtResources = (CswNbtResources)CswResources; CswNbtResources.AuditContext = "Scheduler Task: " + RuleName; if (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus) { try { if (_SyncModules.Any(SyncModule => CswNbtResources.Modules.IsModuleEnabled(SyncModule))) { // Check C3 Status CswC3Params CswC3Params = new CswC3Params(); CswNbtC3ClientManager CswNbtC3ClientManager = new CswNbtC3ClientManager(CswNbtResources, CswC3Params); SearchClient SearchClient = CswNbtC3ClientManager.initializeC3Client(); if (null != SearchClient) { int MaterialsProcessedPerIteration = CswConvert.ToInt32(CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle)); int TotalProcessedThisIteration = 0; while (TotalProcessedThisIteration < MaterialsProcessedPerIteration && _MaterialPks.Count > 0 && (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus)) { CswNbtObjClassChemical MaterialNode = CswNbtResources.Nodes[_MaterialPks[0]]; if (null != MaterialNode) { _setPendingUpdate(CswNbtResources, CswConvert.ToString(MaterialNode.NodeId.PrimaryKey)); _MaterialPks.RemoveAt(0); TotalProcessedThisIteration++; } //if (null != MaterialNode) } } else { // TODO: What should we do with the error in the case of the schedule service? } } _CswScheduleLogicDetail.StatusMessage = "Completed without error"; _LogicRunStatus = CswEnumScheduleLogicRunStatus.Succeeded; //last line }//try catch (Exception Exception) { _CswScheduleLogicDetail.StatusMessage = "CswScheduleLogicNbtExtChemDataSync exception: " + Exception.Message + "; " + Exception.StackTrace; CswNbtResources.logError(new CswDniException(_CswScheduleLogicDetail.StatusMessage)); _LogicRunStatus = CswEnumScheduleLogicRunStatus.Failed; } } }
}//getLastRegulationDataImportDate() #region Private Helper Methods /// <summary> /// Set the c3 parameter object's CustomerLoginName, LoginPassword, and AccessId /// parameters using the values from the configuration_variables table in the db. /// </summary> /// <param name="CswC3Params"></param> private bool _setConfigurationVariables(CswC3Params CswC3Params, CswNbtResources _CswNbtResources) { bool Ret = true; CswC3Params.CustomerLoginName = _CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.C3_Username); CswC3Params.LoginPassword = _CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.C3_Password); CswC3Params.AccessId = _CswNbtResources.SetupVbls[CswEnumSetupVariableNames.C3AccessId]; if (string.IsNullOrEmpty(CswC3Params.CustomerLoginName) || string.IsNullOrEmpty(CswC3Params.LoginPassword) || string.IsNullOrEmpty(CswC3Params.AccessId)) { _createMessage(CswEnumErrorType.Error, "C3_Username, C3_Password, or C3AccessId value is null"); Ret = false; } return(Ret); }//_setConfigurationVariables()
public CswNbtWebServiceC3Search.CswNbtC3SearchReturn GetACDSuppliers() { CswC3Params CswC3Params = new CswC3Params(); CswNbtWebServiceC3Search.CswNbtC3SearchReturn Ret = new CswNbtWebServiceC3Search.CswNbtC3SearchReturn(); var SvcDriver = new CswWebSvcDriver <CswNbtWebServiceC3Search.CswNbtC3SearchReturn, CswC3Params>( CswWebSvcResourceInitializer: new CswWebSvcResourceInitializerNbt(_Context, null), ReturnObj: Ret, WebSvcMethodPtr: CswNbtWebServiceC3Search.GetACDSuppliers, ParamObj: CswC3Params ); SvcDriver.run(); return(Ret); }
public JObject makeVersionJson(CswSessionResourcesNbt _CswSessionResources) { JObject ret = new JObject(); string AssemblyFilePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "/_Assembly.txt"; if (File.Exists(AssemblyFilePath)) { TextReader AssemblyFileReader = new StreamReader(AssemblyFilePath); ret.Add(new JProperty("assembly", AssemblyFileReader.ReadLine())); AssemblyFileReader.Close(); } JObject ComponentObj = new JObject(); JProperty ComponentsProp = new JProperty("components", ComponentObj); ret.Add(ComponentsProp); string ThisYear = DateTime.Now.Year.ToString(); ArrayList CswAssemblies = new ArrayList(); CswAssemblies.Add("NbtWebApp"); CswAssemblies.Add("CswCommon"); CswAssemblies.Add("CswWebControls"); CswAssemblies.Add("NbtLogic"); CswAssemblies.Add("NbtWebControls"); foreach (string AssemblyName in CswAssemblies) { string name = AssemblyName.Contains(",") ? AssemblyName.Substring(0, AssemblyName.IndexOf(',')) : AssemblyName; JObject AssemObj = new JObject(); ComponentObj.Add(new JProperty(name, AssemObj)); Assembly AssemblyInfo = Assembly.Load(AssemblyName); string Version = AssemblyInfo.GetName().Version.ToString(); AssemObj.Add(new JProperty("name", name)); AssemObj.Add(new JProperty("version", Version)); AssemObj.Add(new JProperty("copyright", "Copyright © ChemSW, Inc. 2005-" + ThisYear)); } ArrayList ThirdAssemblies = new ArrayList(); ThirdAssemblies.Add("CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"); ThirdAssemblies.Add("Telerik.Web.UI"); foreach (string AssemblyName in ThirdAssemblies) { string name = AssemblyName.Contains(",") ? AssemblyName.Substring(0, AssemblyName.IndexOf(',')) : AssemblyName; JObject AssemObj = new JObject(); ComponentObj.Add(new JProperty(name, AssemObj)); Assembly AssemblyInfo = Assembly.Load(AssemblyName); object[] AssemblyAttributes = (object[])AssemblyInfo.GetCustomAttributes(true); string Version = AssemblyInfo.GetName().Version.ToString(); string Copyright = string.Empty; foreach (AssemblyCopyrightAttribute AssemblyAttribute in AssemblyAttributes.OfType <AssemblyCopyrightAttribute>()) { Copyright = (AssemblyAttribute).Copyright; } AssemObj.Add(new JProperty("name", name)); AssemObj.Add(new JProperty("version", Version)); AssemObj.Add(new JProperty("copyright", Copyright)); } ComponentObj.Add(new JProperty("Schema", new JObject( new JProperty("name", "Schema"), new JProperty("version", _CswNbtResources.ConfigVbls.getConfigVariableValue("schemaversion")), new JProperty("copyright", "Copyright © ChemSW, Inc. 2005-" + ThisYear) ) )); #region ChemCatCentral Products Versions // Add ChemCatCentral version to the About dialog: Case 29380 if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3Products)) { CswC3Params CswC3Params = new CswC3Params(); CswNbtC3ClientManager C3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params); SearchClient C3SearchClient = C3ClientManager.initializeC3Client(); if (null != C3SearchClient) { string C3Version = C3ClientManager.getCurrentC3Version(); ComponentObj.Add(new JProperty("ChemCatCentral", new JObject( new JProperty("name", "ChemCatCentral"), new JProperty("version", Regex.Replace(C3Version, "_", " ")), new JProperty("copyright", "Copyright © ChemSW, Inc. 2005-" + ThisYear)))); // Add the datasource import dates (if they are available to the user and/or the module is enabled CswC3ServiceLogicGetDataSourcesDataSource[] DataSourceDates = C3ClientManager.getDataSourceDates(); if (null != DataSourceDates) { JObject DSDatesObj = new JObject(); foreach (CswC3ServiceLogicGetDataSourcesDataSource ds in DataSourceDates) { if (ds.DataType == "Extra Chemical") { switch (ds.DataSourceName) { case "FireDb": if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.FireDbSync)) { DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate)); } break; case "PCID": if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.PCIDSync)) { DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate)); } break; } //switch } else { DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate)); } } ret.Add(new JProperty("dsDates", DSDatesObj)); } }//if( C3ClientManager.checkC3ServiceReferenceStatus() ) } #endregion ChemCatCentral Products Versions #region ACD Version if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3ACD)) { CswC3Params CswC3Params = new CswC3Params(); CswNbtC3ClientManager C3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params); SearchClient C3SearchClient = C3ClientManager.initializeC3Client(); if (null != C3SearchClient) { CswRetObjSearchResults Results = C3SearchClient.getACDVersion(CswC3Params); if (null != Results) { ComponentObj.Add(new JProperty("ACD", new JObject( new JProperty("name", "Available Chemicals Directory (ACD)"), new JProperty("version", Regex.Replace(Results.ACDVersion, "_", " ")), new JProperty("copyright", "Copyright © Accelrys, Inc. 1983-" + ThisYear)))); } } } #endregion ACD Version SortedList <string, CswSessionsListEntry> sessions = _CswSessionResources.CswSessionManager.SessionsList.AllSessions; CswDateTime loginDate = new CswDateTime(_CswNbtResources); foreach (var entry in sessions) { CswSessionsListEntry sessionEntry = entry.Value; if (sessionEntry.UserName.Equals(_CswNbtResources.CurrentUser.Username)) { loginDate.FromClientDateString(sessionEntry.LoginDate.ToString()); } } JObject UserObj = new JObject(); UserObj["customerid"] = new JObject(new JProperty("componentName", "Customer ID:"), new JProperty("value", _CswNbtResources.AccessId)); UserObj["loggedinas"] = new JObject(new JProperty("componentName", "Logged in as:"), new JProperty("value", _CswNbtResources.CurrentUser.Username)); UserObj["sessionsince"] = new JObject(new JProperty("componentName", "Session since:"), new JProperty("value", loginDate.ToDateTime().ToString())); ret.Add(new JProperty("userProps", UserObj)); return(ret); } // makeVersionJson()
}//_getPreferredSuppliers() private static Collection <VendorOption> _getAvailableDataSources(CswNbtC3ClientManager CswNbtC3ClientManager, CswC3Params CswC3Params) { Collection <VendorOption> AvailableDataSources = new Collection <VendorOption>(); SearchClient C3SearchClient = CswNbtC3ClientManager.initializeC3Client(); if (null != C3SearchClient) { CswRetObjSearchResults SourcesList = C3SearchClient.getDataSources(CswC3Params); if (null != SourcesList) { //Create the "All Sources" option CswCommaDelimitedString AllSources = new CswCommaDelimitedString(); AllSources.FromArray(SourcesList.AvailableDataSources); VendorOption allSourcesDs = new VendorOption(); allSourcesDs.value = AllSources.ToString(); allSourcesDs.display = "All Sources"; AvailableDataSources.Add(allSourcesDs); //Add available data source options foreach (string DataSource in SourcesList.AvailableDataSources) { VendorOption dS = new VendorOption(); dS.value = DataSource; dS.display = DataSource; AvailableDataSources.Add(dS); } } //if( null != SourcesList ) } //if( null != C3SearchClient ) return(AvailableDataSources); }//_getAvailableDataSources()
}//UpdateACDPrefSuppliers() public static void GetSearchProperties(ICswResources CswResources, CswNbtC3SearchReturn Return, CswC3Params CswC3Params) { CswNbtResources _CswNbtResources = (CswNbtResources)CswResources; List <string> SearchProperties = new List <string>() ; if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3ACD)) { SearchProperties = (from ACDSearchParams.SearchFieldType SearchType in Enum.GetValues(typeof(ACDSearchParams.SearchFieldType)) select SearchType.ToString()).ToList(); } if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3Products)) { SearchProperties = (from C3SearchParams.SearchFieldType SearchType in Enum.GetValues(typeof(C3SearchParams.SearchFieldType)) select SearchType.ToString()).ToList(); } Return.Data.SearchProperties = SearchProperties; }//GetSearchProperties()
public static void GetACDSuppliers(ICswResources CswResources, CswNbtC3SearchReturn Return, CswC3Params CswC3Params) { CswNbtResources _CswNbtResources = (CswNbtResources)CswResources; CswNbtC3ClientManager CswNbtC3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params); SearchClient C3SearchClient = CswNbtC3ClientManager.initializeC3Client(); if (null != C3SearchClient) { CswRetObjSearchResults Results = C3SearchClient.getACDSuppliers(CswC3Params); // Get the already set perferred suppliers so we can select them List <string> PreferredSuppliers = new List <string>(); CswNbtObjClassUser CurrentUser = _CswNbtResources.Nodes.GetNode(_CswNbtResources.CurrentNbtUser.UserId); if (null != CurrentUser) { PreferredSuppliers = CurrentUser.C3ACDPreferredSuppliers.Text.Split(',').ToList(); } Collection <ACDSupplier> ACDSuppliers = new Collection <ACDSupplier>(); IEnumerable <ACDSupplier> SortedSuppliers = new Collection <ACDSupplier>(); if (null != Results) { foreach (CswC3ACDResponseACDSupplier ACDSupplier in Results.ACDSuppliers) { ACDSupplier NewSupplier = new ACDSupplier(); NewSupplier.Name = ACDSupplier.Name + ": " + ACDSupplier.Country; NewSupplier.Id = CswConvert.ToString(ACDSupplier.Id); NewSupplier.Selected = PreferredSuppliers.Contains(ACDSupplier.Id.ToString()); ACDSuppliers.Add(NewSupplier); } SortedSuppliers = ACDSuppliers.OrderBy(si => si.Name); } Return.Data.ACDSuppliers = SortedSuppliers; } }//GetACDSuppliers()
}//getC3DataService() public static void GetVendorOptions(ICswResources CswResources, CswNbtC3SearchReturn Return, CswC3Params CswC3Params) { CswNbtResources _CswNbtResources = (CswNbtResources)CswResources; CswNbtC3ClientManager CswNbtC3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params); if (CswNbtC3ClientManager.DataService == "C3") { Return.Data.VendorListOptions = _getAvailableDataSources(CswNbtC3ClientManager, CswC3Params); } else if (CswNbtC3ClientManager.DataService == "ACD") { Return.Data.VendorListOptions = _getPreferredSuppliers(_CswNbtResources); } }