internal void ShowRunQueryUrl() { if (Query == null || Query.UserObject == null || Query.UserObject.Id <= 0) { MessageBoxMx.ShowError("The query must first be saved."); return; } string folder = ServicesIniFile.Read("QueryLinksNetworkFolder"); // get unc form of folder string fileName = "Run_Query_" + Query.UserObject.Id + ".bat"; // file name string uncPath = folder + '\\' + fileName; // unc file to write now and read later string tempFile = TempFile.GetTempFileName(); StreamWriter sw = new StreamWriter(tempFile); string cmd = // batch command to start the Mobius client and run the specified query Lex.AddDoubleQuotes(ClientDirs.ExecutablePath) + // path to executable in quotes " Mobius:Command='Run Query " + Query.UserObject.Id + "'"; // the mobius command to run sw.WriteLine(cmd); sw.Close(); ServerFile.CopyToServer(tempFile, uncPath); FileUtil.DeleteFile(tempFile); string url = "file:///" + folder.Replace('\\', '/') + "/" + fileName; // put in "file:" schema & switch slashes to get URL from UNC name InputBoxMx.Show( "The following URL can be used from a web page " + "to start Mobius and run the current query:", "Run Query URL", url); //"Mobius:Command='Run Query " + Query.UserObject.Id + "'"); // this is better but isn't accepted by SharePoint return; }
/// <summary> /// Write out the data and return the html/js to open the template .dxp file with the exported data file /// </summary> /// <param name="q"></param> /// <param name="trvp"></param> /// <returns></returns> public static string CreateSpotfireAnalysisDocument( Query q, TargetSummaryOptions trvp) { ExportParms ep = new ExportParms(); ep.OutputDestination = OutputDest.TextFile; ep.ExportFileFormat = ExportFileFormat.Csv; ep.OutputFileName = TempFile.GetTempFileName(".csv"); // temp .csv file to export to ep.IncludeDataTypes = true; string result = UalUtil.IQueryExec.RunQuery(q, ep); // do the export if (result == null) { return(null); // just return if cancelled } string templateLibFolder = // unc name of the lib folder (not currently used) ServicesIniFile.Read("SpotfireLibraryFolder"); string templateLibUrl = // url of the library containing the Mobius templates ServicesIniFile.Read("SpotfireLibraryUrl"); templateLibUrl = @"http://[server]/SpotfireWeb/Library.aspx?folder=DCRT%20(chemistry)%20users/Mobius/Templates"; string templateUrl = templateLibUrl + "/MultiDbView"; string html = templateUrl; // todo, build html/js to open the template with the specified file return(html); }
/// <summary> /// Get security parms /// </summary> /// <returns></returns> public static void ReadSecurityParms() { if (_readSecurityParms) { return; } if (ServicesIniFile.IniFile == null) { return; } _useActiveDirectory = ServicesIniFile.ReadBool("UseActiveDirectory", true); _approvedMobiusUsersGroupName = ServicesIniFile.Read("ApprovedMobiusUsers", @"<domain>Approved_Mobius_Users"); _approvedMobiusChemViewGroupName = ServicesIniFile.Read("ApprovedMobiusChemView", @"<domain>Approved_Mobius_Chemview"); _approvedMobiusSequenceViewGroupName = ServicesIniFile.Read("ApprovedMobiusSequenceView", @"<domain>Lg_Mol_Search_Incl_Seq"); string txt = ServicesIniFile.Read("SpecialMobiusSystemAccounts", "MOBIUS"); _specialMobiusSystemAccounts = new HashSet <string>(); string[] sa = txt.Split(','); foreach (string s in sa) { if (Lex.IsDefined(s)) { _specialMobiusSystemAccounts.Add(s.Trim().ToUpper()); } } _readSecurityParms = true; }
/// <summary> /// Check to see if any Annotation table updates need to started /// </summary> public static string CheckForAllUsersImportFileUpdates() { if (!Security.IsMobius) { return("Only the account <mobiusAccount> can check for all annotation table updates"); } UserData ud = new UserData(); if (!ServicesIniFile.ReadBool("RunBackgroundProcessesInForeground", false)) { ParameterizedThreadStart ts = new ParameterizedThreadStart(ud.CheckForImportFileUpdatesThreadMethod); Thread newThread = new Thread(ts); newThread.IsBackground = true; newThread.SetApartmentState(ApartmentState.STA); newThread.Start(true); } else { ud.CheckForImportFileUpdatesThreadMethod(true); } return("CheckForAllUsersImportFileUpdates started"); }
/// <summary> /// Main tool entry point /// </summary> /// <param name="args"></param> /// <returns></returns> public string Run( string args) { QbUtil.SetMode(QueryMode.Build); // be sure in build mode //List<StructureDbInfo> dbInfo = StructureDbInfo.GetList(); // get list of root structure tables //MetaTable mt = MetaTableCollection.Get(dbInfo[0].StructureTable); // use first structure table if (DatabasesToSearch.Text == "") { // default to first structure table List <RootTable> dbInfo = RootTable.GetList(); // get list of root structure tables if (dbInfo != null && dbInfo.Count > 0) { DatabasesToSearch.Text = dbInfo[0].Label; } } if (ServicesIniFile.Read("MultStructSearchHelpUrl") != "") { Help.Enabled = true; } DialogResult dr = ShowDialog(SessionManager.ActiveForm); return(""); }
/// <summary> /// Return true if this column can be a secondary image column /// </summary> /// <param name="mc"></param> /// <returns></returns> public static bool CanBeSecondaryImageColumnObsolete( MetaColumn mc) { if (!CanHaveRelatedImageColumn(mc)) { return(false); // must be image column } bool allowSecondaryImageColumns = ServicesIniFile.ReadBool("AllowSecondaryImageColumns", false); if (!allowSecondaryImageColumns) { return(false); } if (Lex.Contains(mc.Label, "Non Standard") || // nonstandards can be secondary Lex.Contains(mc.Label, "_NS") || Lex.Contains(mc.Label, "(NS)")) { return(true); } foreach (string s in ImageResultTypes) { string resultCode = mc.Name.Substring(2); // get the assay metadata code if (s == mc.MetaTable.Code + "." + resultCode) { return(true); } } return(false); }
/// <summary> /// Build & return the full MetaTree /// </summary> /// public Dictionary <string, MetaTreeNode> GetMetaTree2() { if (ServiceFacade.UseRemoteServices) { NativeMethodTransportObject resultObject = ServiceFacade.CallServiceMethod( ServiceCodes.MobiusMetaDataService, MobiusMetaDataService.Build, new object[] { false }); // Get the cache from the server if newer than the client cache string cacheFile = ServicesIniFile.Read("CachedTreeFile", DefaultCachedTreeFile); string serverCacheFile = @"<MetaDataDir>\MetaTrees\" + cacheFile; string clientCacheFile = ClientDirs.CacheDir + @"\" + cacheFile; //ServerFile.Get(serverCacheFile, clientCacheFile); // debug, always get bool changed = ServerFile.GetIfChanged(serverCacheFile, clientCacheFile); // just get if changed // Build the tree from the local copy of the cache MetaFactoryNamespace.MetaTreeFactory.BuildFromCache(ClientDirs.CacheDir, false); return(Mfn.MetaTreeFactory.Nodes); } else { Mfn.MetaTreeFactory.Build(); return(Mfn.MetaTreeFactory.Nodes); } }
void SetupGrid(List <UserObject> alerts) { string txt, tok; DataTable dt = CreateDataTable(); foreach (UserObject uo in alerts) // fill the grid { UserObject uo2 = uo; Alert alert = Alert.GetAlertFromUserObject(uo2, false); UserObject quo = UserObjectDao.ReadHeader(alert.QueryObjId); // get query header for name if (quo == null) { continue; // associated query missing? } alert.QueryName = quo.Name; alert.LastQueryUpdate = quo.UpdateDateTime; DataRow dr = dt.NewRow(); SetDataRow(dr, alert); dt.Rows.Add(dr); } Grid.DataSource = dt; Grid.Refresh(); if (ServicesIniFile.Read("AlertHelpUrl") != "") { Help.Enabled = true; } return; }
public List <StructSearchMatch> MatchList; // merged list of matches /// <summary> /// InitializeForSession /// </summary> public static void InitializeForSession() { SearchCorpSimEnabled = ServicesIniFile.ReadBool("CdkSimSearchCorp", true); SearchChemblSimEnabled = ServicesIniFile.ReadBool("CdkSimSearchChembl", true); UseMultipleThreads = ServicesIniFile.ReadBool("CdkSimSearchUseMultipleThreads", true); Debug = ServicesIniFile.ReadBool("CdkSimSearchDebug", false); }
/// <summary> /// Initialize the UAL /// </summary> public static void Initialize(string iniFileName) { ServicesDirs.ExecutablePath = Application.ExecutablePath; ServicesDirs.ServerStartupDir = Application.StartupPath; //DebugLog.Message("UalUtil.Initialize iniFileName: " + iniFileName); ServicesIniFile.Initialize(iniFileName); CommonConfigInfo.MiscConfigDir = ServicesIniFile.Read("MiscConfigDirectory"); ServicesDirs.MetaDataDir = ServicesIniFile.Read("MetaDataDirectory"); //DebugLog.Message("MetaDataDir: " + MetaDataDir); ServicesDirs.TargetMapsDir = ServicesDirs.MetaDataDir + @"\TargetMaps"; // target maps relative to MetaDataDir ServicesDirs.DocDir = ServicesIniFile.Read("DocumentDirectory"); ServicesDirs.LogDir = ServicesIniFile.Read("LogDirectory"); ServicesDirs.CacheDir = ServicesIniFile.Read("CacheDirectory"); ServicesDirs.TempDir = TempFile.TempDir = ServicesIniFile.Read("TempDirectory"); ServicesDirs.QueryResultsDataSetDir = ServicesIniFile.Read("QueryResultsDataSetDirectory"); ServicesDirs.BackgroundExportDir = ServicesIniFile.Read("BackgroundExportDirectory"); ServicesDirs.BinaryDataDir = ServicesIniFile.Read("BinaryDataDirectory"); ServicesDirs.ModelQueriesDir = ServicesIniFile.Read("ModelQueriesDirectory"); ServicesDirs.ModelQueriesDir = ServicesIniFile.Read("ModelQueriesDirectory"); ServicesDirs.ImageDir = ServicesIniFile.Read("ImageDirectory"); ServicesDirs.ImageDirUNC = ServicesIniFile.Read("ImageDirectoryUNC"); LogExecutionTimes = ServicesIniFile.ReadBool("LogUalExecutionTimes", false); DbCommandMx.LogDatabaseCalls = ServicesIniFile.ReadBool("LogDatabaseCalls", DbCommandMx.LogDatabaseCalls); return; }
private void CreateUserGroupMenuItem_Click(object sender, EventArgs e) { if (!Security.IsAdministrator(SS.I.UserName) && !Security.HasPrivilege(SS.I.UserName, "CreateUserGroup") && !ServicesIniFile.ReadBool("CreateUserGroupByAnyUser", true)) { MessageBoxMx.ShowError("Your account is not authorized to create and/or edit user groups"); return; } string groupName = InputBoxMx.Show("Enter the name of the new user group to be created.", "Create User Group"); if (Lex.IsNullOrEmpty(groupName)) { return; } if (UserGroups.LookupExternalName(groupName) != null) { MessageBoxMx.ShowError("Group \"" + groupName + "\" already exists"); return; } DialogResult dr = PermissionsGroupEditor.Show(groupName, true); if (dr == DialogResult.OK) { PermissionsList.ItemNameComboBox.Properties.Items.Clear(); // rebuild for new group } }
/// <summary> /// New update the list of related compounds /// </summary> /// <param name="mt"></param> /// <param name="cid"></param> /// <param name="queryStruct"></param> private void UpdateRelatedCidsDisplay( MetaTable mt, string cid, MoleculeMx queryStruct, int renderId) { bool useNew = ServicesIniFile.ReadBool("UseNewRelatedCompoundsPopup", true); // use new or old related compounds display if (!useNew) { UpdateRelatedCidsDisplayOld(mt, cid, queryStruct); return; } //if (!SS.I.AllowGroupingBySalts || // need this? // Lex.Ne(MetaTable.DefaultRootTable, mt.Name)) //{ // this.Height = RelatedStructuresPanel.Top; // return; //} if (SS.I.FindRelatedCpdsInQuickSearch) { RSM.StartSearchAndRetrievalOfRelatedStructures(mt.Name, cid, queryStruct, RelatedStructureBrowser.StructureSearchTypes); } return; }
/// <summary> /// Initialize the UAL and load the MetaData /// </summary> //public void Initialize() //{ // InitializeUAL(); // LoadMetaData(); // return; //} /// <summary> /// Initialize the UAL so basic Oracle operations can be performed /// </summary> public void InitializeUAL() { lock (_lockObject) { // Set the ini file if (ServicesIniFile.IniFile == null) { string iniFilePath = GetMobiusServicesIniFileLocation(); Mobius.UAL.UalUtil.Initialize(iniFilePath); if (!System.IO.File.Exists(iniFilePath)) { throw new Exception("IniFile doesn't exist: " + iniFilePath); } } if (ServicesDirs.MetaDataDir == "") { ServicesDirs.MetaDataDir = ServicesIniFile.Read("MetaData"); } string logFile = ServicesDirs.LogDir + @"\" + Mobius.ComOps.CommonConfigInfo.ServicesLogFileName; // log file name Mobius.Services.Util.ServicesLog.Initialize(logFile); // initialize for logging // Get list of valid privileges Mobius.ComOps.PrivilegesMx.SetValidPrivilegeListFromInifile(ServicesIniFile.IniFile); // Load data source meta info if (Mobius.UAL.DataSourceMx.DataSources == null || Mobius.UAL.DataSourceMx.DataSources.Count == 0 || Mobius.UAL.DataSourceMx.Schemas == null || Mobius.UAL.DataSourceMx.Schemas.Count == 0) { Mobius.UAL.DataSourceMx.LoadMetadata(); } // Foundation dependency injections // Dependency injections for client components //Mobius.Data.Query.IDataTableManager = new DataTableManager(); //Mobius.Data.ChemicalStructure.IChemicalStructureUtil = new Mobius.ClientComponents.ChemicalStructureUtil(); //Mobius.Data.RootTable.IServerFile = new ServerFile(); //Mobius.ServServiceFacade.ServiceFacade.IDebugLog = new DebugLogMediator(); Mobius.Data.ResultsViewProps.ResultsViewFactory = new Mobius.ClientComponents.ViewFactory(); Mobius.Data.Query.IDataTableManager = new Mobius.ClientComponents.DataTableManager(); Mobius.Data.CidList.ICidListDao = new Mobius.UAL.CidListDao(); Mobius.Data.MoleculeMx.IMoleculeMxUtil = new Mobius.QueryEngineLibrary.MoleculeUtil(); Mobius.Data.RootTable.IServerFile = new Mobius.UAL.ServerFile(); Mobius.Data.InterfaceRefs.IUserObjectDao = new Mobius.UAL.IUserObjectDaoMethods(); Mobius.Data.InterfaceRefs.IUserObjectIUD = new Mobius.ClientComponents.IUserObjectIUDMethods(); Mobius.Data.InterfaceRefs.IUserObjectTree = new Mobius.ClientComponents.IUserObjectTreeMethods(); Mobius.MolLib1.StructureConverter.ICdkUtil = new Mobius.CdkMx.CdkUtil(); } }
/// <summary> /// GetDefaultWebPlayerUrl /// </summary> /// <returns></returns> static string GetDefaultWebPlayerUrl() { if (_defaultWebplayerUrl == null) { _defaultWebplayerUrl = ServicesIniFile.Read("SpotfireWebplayer", "https://[server]/spotfire/wp"); } return(_defaultWebplayerUrl); }
/// <summary> /// Get server file name to export to /// </summary> /// <param name="rf"></param> /// <param name="objId"></param> /// <returns></returns> static string GetServerFileName(ResultsFormat rf, int objId) { string clientFile = rf.OutputFileName; // file name on client string ext = Path.GetExtension(clientFile); string serverExpDir = ServicesIniFile.Read("BackgroundExportDirectory"); string serverFile = serverExpDir + @"\" + objId + ext; // use background export userobject id & client file extension return(serverFile); }
/// <summary> /// Do initial read of the list of views and the users for each view. /// </summary> public static void ReadViews() { StreamReader sr; ViewDict = new Dictionary <string, RestrictedDatabaseView>(); bool restrictionsActive = ServicesIniFile.ReadBool("UseRestrictedDatabaseViews", false); if (!restrictionsActive) { return; } string dirName = ServicesDirs.MetaDataDir + @"\RestrictedDatabaseViews"; if (!Directory.Exists(dirName)) { return; // throw new Exception("RestrictedDatabaseViews Directory does not exist: " + dirName); } string fileName = dirName + @"\ViewList.txt"; if (!File.Exists(fileName)) { return; } try { sr = new StreamReader(fileName); } catch (Exception ex) { return; } while (true) { string txt = sr.ReadLine(); if (txt == null) { break; } if (Lex.IsUndefined(txt) || txt.StartsWith(";")) { continue; } string viewName = txt.Trim().ToUpper(); RestrictedDatabaseView v = new RestrictedDatabaseView(); ViewDict[viewName] = v; v.Name = viewName; ReadViewUsers(v); } sr.Close(); }
/// <summary> /// Send mail object /// </summary> /// <param name="mail"></param> public static void SendEmail( MailMessage mail) { SmtpClient mailClient = new SmtpClient(); string mailServerName = ServicesIniFile.Read("SmtpServer"); mailClient.Host = mailServerName; mailClient.UseDefaultCredentials = true; // mailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; mailClient.Send(mail); }
/// <summary> /// Main tool entry point /// </summary> /// <param name="args"></param> /// <returns></returns> public string Run( string args) { QbUtil.SetMode(QueryMode.Build); // be sure in build mode if (ServicesIniFile.Read("RgroupDecompositionHelpUrl") != "") { Help.Enabled = true; } this.ShowDialog(); return(""); }
/// <summary> /// Show NCBI Entre Gene web page for supplied geneId and/or symbol /// </summary> /// <param name="geneIdSymbol"></param> public static string GetTargetDescriptionUrl( string targetIdSymbol) { int targetId; string targetSymbol; if (String.IsNullOrEmpty(targetIdSymbol)) { return(null); } else if (Lex.IsInteger(targetIdSymbol)) // numeric gene id { targetId = int.Parse(targetIdSymbol); } else if (targetIdSymbol.Contains("-")) // 1234-Symbol form { string[] sa = targetIdSymbol.Split('-'); targetSymbol = sa[1].ToUpper(); try { targetId = TargetSymbolToId(targetSymbol); } catch { return(null); } } else // must be symbol { targetSymbol = targetIdSymbol.ToUpper(); try { targetId = TargetSymbolToId(targetSymbol); } catch { return(null); } } if (targetId <= 0) { return(null); } string url = ServicesIniFile.Read("NcbiGeneIdUrlTemplate"); if (String.IsNullOrEmpty(url)) { return(null); } url = url.Replace("<GENE_ID>", targetId.ToString()); return(url); }
/// <summary> /// Display any new news if requested /// </summary> public static bool ShowNewNews() { try { string lastNews = Preferences.Get("ShowNews"); if (lastNews == "false") { return(false); // user doesn't want to see news } if (ClientState.IsDeveloper) { return(false); // debug } string fileName = ServicesIniFile.Read("NewsFile"); if (fileName == "") { throw new Exception("NewsFile not defined"); } DateTime dt = File.GetLastWriteTime(fileName); string fileDate = String.Format("{0,4:0000}{1,2:00}{2,2:00}", dt.Year, dt.Month, dt.Day); if (String.Compare(fileDate, lastNews) > 0 || lastNews == "") { ShowNews(); // show the news UserObjectDao.SetUserParameter(SS.I.UserName, "ShowNews", fileDate); return(true); } else { return(false); } } catch (Exception ex) { //if (ClientState.IsDeveloper) // MessageBoxMx.ShowError(ex.Message); return(false); } }
/// <summary> /// Check to see if any imports need to started /// </summary> public static string CheckForCurrentUserImportFileUpdates() { UserData ud = new UserData(); if (!ServicesIniFile.ReadBool("RunBackgroundProcessesInForeground", false)) // run as separate thread? { ParameterizedThreadStart ts = new ParameterizedThreadStart(ud.CheckForImportFileUpdatesThreadMethod); Thread newThread = new Thread(ts); newThread.IsBackground = true; newThread.SetApartmentState(ApartmentState.STA); newThread.Start(false); } else { ud.CheckForImportFileUpdatesThreadMethod(false); } return("CheckForImportFileUpdates started"); }
/// <summary> /// Some methods in the AlertQueue class are static. Therefore the _alertQueueFileName will not be set in those cases. /// This method will ensure we have a valid file name in all cases. /// </summary> /// <returns></returns> private static string GetAlertQueueFileName() { if (_alertQueueFileName != null) { return(_alertQueueFileName); } if (_serverLogDir == null) { _serverLogDir = ServicesIniFile.Read("LogDirectory"); } if (String.IsNullOrEmpty(_serverLogDir)) { throw new Exception("Server LogDirectory not defined in config file"); } if (_alertQueueFileName == null) { _alertQueueFileName = _serverLogDir + @"\AlertQueue.txt"; } return(_alertQueueFileName); }
public static void Initialize() { MetaTableXmlFolder = ServicesDirs.MetaDataDir + @"\MetaTables"; string rootFile = ServicesIniFile.Read("MetaTableRootFile", "Metatables.xml"); // root to start at if (rootFile.IndexOf(@"\") < 0) { rootFile = MetaTableXmlFolder + @"\" + rootFile; } IncludeQualifiedNumberDetailColumnsInMetaTables = // get flag for including hidden Qualified Number detail cols in metatables ServicesIniFile.ReadBool("IncludeQualifiedNumberDetailColumnsInMetaTables", true); BuildFromXmlFile(rootFile); // get initial metatables RegisterFactory("CalcField", new CalcFieldMetaFactory()); RegisterFactory("Annotation", new AnnotationMetaFactory()); RegisterFactory("MultiTable", new MultiTableMetaFactory()); RegisterFactory("Oracle", new OracleMetaFactory()); RegisterFactory("PubChem", new PubChemMetaFactory()); RegisterFactory("UnpivotedAssay", new UnpivotedAssayMetaFactory()); RegisterFactory("SpotfireLink", new SpotfireLinkMetafactory()); }
/// <summary> /// Read and set the config settings /// </summary> public static void ReadConfigSettings() { if (ConfigSettingsHaveBeenRead) { return; } SearchFssEnabled = ServicesIniFile.ReadBool("RssSearchFss", true); SearchCorpDbFssEnabled = ServicesIniFile.ReadBool("RssSearchCorpFss", true); SearchChemblFssEnabled = ServicesIniFile.ReadBool("RssSearchChemblFss", true); SearchMmpEnabled = ServicesIniFile.ReadBool("RssSearchMmp", true); SearchCorpDbMmpEnabled = ServicesIniFile.ReadBool("RssSearchCorpMmp", true); SearchChemblMmpEnabled = ServicesIniFile.ReadBool("RssSearchChemblMmp", false); KeepHighestCidPairScoreOnlyEnabled = ServicesIniFile.ReadBool("RssKeepHighestCidPairScoreOnly", true); SearchSmallWorldEnabled = ServicesIniFile.ReadBool("RssSearchSmallWorld", true); SearchCorpDbSmallWorldEnabled = ServicesIniFile.ReadBool("RssSearchCorpSmallWorld", true); SearchChemblSmallWorldEnabled = ServicesIniFile.ReadBool("RssSearchChemblSmallWorld", true); //SearchSmallWorldEnabled = SearchCorpSmallWorldEnabled = SearchChemblSmallWorldEnabled = true; // for testing SearchSimEnabled = ServicesIniFile.ReadBool("RssSearchSim", true); SearchCorpSimEnabled = ServicesIniFile.ReadBool("RssSearchCorpSim", true); SearchChemblSimEnabled = ServicesIniFile.ReadBool("RssSearchChemblSim", true); SearchSssEnabled = ServicesIniFile.ReadBool("RssSearchSSS", true); SearchCorpSssEnabled = ServicesIniFile.ReadBool("RssSearchCorpSSS", true); SearchChemblSssEnabled = ServicesIniFile.ReadBool("RssSearchChemblSSS", true); UseMultipleThreads = ServicesIniFile.ReadBool("RssUseMultipleThreads", true); UseCachedResults = ServicesIniFile.ReadBool("RssUseCachedResults", true); Debug = ServicesIniFile.ReadBool("RssDebug", false); ConfigSettingsHaveBeenRead = true; return; }
/// <summary> /// Display the news file /// </summary> public static void ShowNews() { try { string fileName = ServicesIniFile.Read("NewsFile"); if (fileName == "") { return; } if (Instance == null) { Instance = new NewsDialog(); } Instance.ShowNewsCheckBox.Checked = Preferences.GetBool("ShowNews"); Instance.Show(); Application.DoEvents(); // allow form to draw before doing navigate Instance.WebBrowser.Navigate(fileName); } catch (Exception ex) { return; } }
/// <summary> /// Create WinForms.ChromiumWebBrowser and navigate to the initial page /// </summary> public void LoadInitialPage() { if (Browser != null) { return; } string url = ""; if (RendererMode == KekuleJsControlMode.OffScreenBitmap) { url = ServicesIniFile.ReadWithException("KekuleJsRendererUrl"); } else if (RendererMode == KekuleJsControlMode.BrowserViewOnly) { url = ServicesIniFile.ReadWithException("KekuleJsRendererUrl"); } else if (RendererMode == KekuleJsControlMode.BrowserEditor) { url = ServicesIniFile.ReadWithException("KekuleJsEditorUrl"); } if (Debug) { DebugLog.Message("Loading initial " + RendererMode + " mode page: " + url + IdText); } Browser = new WebBrowser(); // create the browser Browser.Location = new Point(0, 0); Browser.Size = new Size(256, 256); Browser.Dock = DockStyle.None; Browser.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right); Browser.Name = "WebBrowser"; Browser.ScrollBarsEnabled = false; Browser.ScriptErrorsSuppressed = JavaScriptManager.SuppressJavaScriptErrors; Browser.ObjectForScripting = new JavaScriptManager(this); // create ScriptManager that can call back to this JavaScriptInterface instance from within web page JavaScript // The following three events are also in WebBrowserWrapper (not needed here) Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Browser_DocumentCompleted); Browser.Navigated += new WebBrowserNavigatedEventHandler(this.WebBrowser_Navigated); Browser.Navigating += new WebBrowserNavigatingEventHandler(this.WebBrowser_Navigating); Browser.ProgressChanged += new WebBrowserProgressChangedEventHandler(Browser_ProgressChanged); Browser.StatusTextChanged += new EventHandler(WebBrowserStatusTextChanged); Browser.Resize += new EventHandler(WebBrowser_Resize); Browser.SizeChanged += new EventHandler(Browser_SizeChanged); if (ContainingControl != null) { Browser.Size = ContainingControl.Size; ContainingControl.Controls.Clear(); ContainingControl.Controls.Add(Browser); } else { Browser.Size = new Size(1024, 768); } BrowserWrapper = new WebBrowserWrapper(Browser); BrowserWrapper.NavigateAndWait(url); // navigate to the initial page ResizeRendering(); if (Debug) { DebugLog.Message("Browser created, initial page loaded" + IdText); } return; }
/// <summary> /// Edit a new or existing calculated field /// </summary> /// <param name="cf"></param> /// <param name="uoIn"></param> /// <returns></returns> public static UserObject Edit( CalcField cf, UserObject uoIn) { QueryTable qt; MetaTable mt = null; MetaColumn mc, field; UserObject uo2; CalcField cf2 = null; string msg; int i1; CalcFieldEditor lastInstance = Instance; CalcFieldEditor i = Instance = new CalcFieldEditor(); i.AdvancedPanel.BorderStyle = BorderStyle.None; i.AdvancedPanel.Visible = false; i.AdvancedPanel.Dock = DockStyle.Fill; i.BasicPanel.BorderStyle = BorderStyle.None; i.BasicPanel.Visible = true; i.BasicPanel.Dock = DockStyle.Fill; i.SetupStandardCalculatedFields(); if (ServicesIniFile.Read("CalcFieldHelpUrl") != "") { i.Help.Enabled = true; } if (lastInstance != null) { i.StartPosition = FormStartPosition.Manual; i.Location = lastInstance.Location; i.Size = lastInstance.Size; lastInstance = null; } if (uoIn == null) { uoIn = new UserObject(UserObjectType.CalcField); } else if (uoIn.Id > 0) // get existing metatable for calc field for exclusion in BuildQuickSelectTableMenu { string tName = "CALCFIELD_" + uoIn.Id.ToString(); mt = MetaTableCollection.GetExisting(tName); if (MainMenuControl != null) { MainMenuControl.UpdateMruList(tName); } } Instance.UoIn = uoIn; string title = "Edit Calculated Field"; if (!String.IsNullOrEmpty(uoIn.Name)) { title += " - " + uoIn.Name; } Instance.Text = title; Instance.CalcField = cf; // what we're editing Instance.SetupForm(); // set up the form DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm); if (dr == DialogResult.Cancel) { return(null); } return(Instance.UoIn); // return saved object }
public bool CanCreateTempTables = false; // true if the associated account can create temp tables /// <summary> /// Load metadata describing connections and associated schemas /// </summary> /// <param name="dsFileName"></param> /// <returns></returns> public static int LoadMetadata() { XmlAttributeCollection atts; // Get some inifile parameters first if (ServicesIniFile.IniFile == null) { throw new Exception("ServicesIniFile.IniFile is null"); } SessionConnection.Pooling = ServicesIniFile.ReadBool("Pooling", true); SessionConnection.MinPoolSize = ServicesIniFile.ReadInt("MinPoolSize", 1); SessionConnection.IncrPoolSize = ServicesIniFile.ReadInt("IncrPoolSize", 5); SessionConnection.MaxPoolSize = ServicesIniFile.ReadInt("MaxPoolSize", 100); SessionConnection.DecrPoolSize = ServicesIniFile.ReadInt("DecrPoolSize", 1); SessionConnection.ConnectionLifetime = ServicesIniFile.ReadInt("ConnectionLifetime", 0); string tok = ServicesIniFile.Read("KeyListPredType", "Parameterized"); int enumInt = EnumUtil.Parse(typeof(KeyListPredTypeEnum), tok); if (enumInt >= 0) { DbCommandMx.DefaultKeyListPredType = (KeyListPredTypeEnum)enumInt; } DbCommandMx.DbFetchRowCount = ServicesIniFile.ReadInt("DbFetchRowCount", DbCommandMx.DbFetchRowCount); DbCommandMx.DbFetchSizeMax = ServicesIniFile.ReadInt("DbFetchSizeMax", DbCommandMx.DbFetchSizeMax); DataSources = new Dictionary <string, DataSourceMx>(StringComparer.OrdinalIgnoreCase); Schemas = new Dictionary <string, DbSchemaMx>(StringComparer.OrdinalIgnoreCase); string dsFileName = ServicesDirs.MetaDataDir + @"\" + "DataSources.xml"; StreamReader sr = new StreamReader(dsFileName); XmlDocument doc = new XmlDocument(); doc.Load(sr); XmlNode node = doc.FirstChild; while (node != null) { if (node.NodeType == XmlNodeType.Element) { break; } node = node.NextSibling; if (node == null) { throw new Exception("No initial element found"); } } if (!Lex.Eq(node.Name, "DataSources")) { throw new Exception("Expected DataSources node: " + node.Name); } atts = node.Attributes; // datasources attributes for (int i = 0; i < atts.Count; i++) { XmlNode att = atts.Item(i); if (Lex.Eq(att.Name, "DblinkConnName")) { } // obsolete key word else { throw new Exception ("Unexpected DataSources attribute: " + att.Name); } } node = node.FirstChild; while (node != null) { if (node.NodeType != XmlNodeType.Element) { ; // ignore non-elements } else if (Lex.Eq(node.Name, "DataSource") || // connection element Lex.Eq(node.Name, "Connection")) { DataSourceMx cd = new DataSourceMx(); atts = node.Attributes; for (int i = 0; i < atts.Count; i++) { XmlNode att = atts.Item(i); if (Lex.Eq(att.Name, "DatabaseType") || Lex.Eq(att.Name, "DbType")) { if (!Enum.TryParse <DatabaseType>(att.Value, true, out cd.DbType)) { throw new Exception("Invalid Database type: " + att.Value); } } else if (Lex.Eq(att.Name, "Name")) { cd.DataSourceName = att.Value.ToUpper().Trim(); } else if (Lex.Eq(att.Name, "DatabaseName") || Lex.Eq(att.Name, "OracleName")) { cd.DatabaseLocator = att.Value.ToUpper().Trim(); } else if (Lex.Eq(att.Name, "ConnectionString")) // keep case if connection string { cd.DatabaseLocator = att.Value.Trim(); } else if (Lex.Eq(att.Name, "UserName")) { cd.UserName = att.Value.Trim(); // keep case as is (Oracle 11g) } else if (Lex.Eq(att.Name, "Password")) { cd.Password = att.Value.Trim(); // keep case as is (Oracle 11g) } else if (Lex.Eq(att.Name, "MdlInit")) // mdl initialization { cd.InitCommand = "select cdcaux.ctenvinit('" + att.Value.Trim() + "') from dual"; } else if (Lex.Eq(att.Name, "InitCommand")) { cd.InitCommand = att.Value.Trim(); } else if (Lex.Eq(att.Name, "KeyDataSource")) { bool.TryParse(att.Value.Trim(), out cd.IsKeyDataSource); } else if (Lex.Eq(att.Name, "CanCreateTempTables")) { bool.TryParse(att.Value.Trim(), out cd.CanCreateTempTables); } else if (Lex.Eq(att.Name, "AlwaysUseDbLink")) { } // obsolete else { throw new Exception ("Unexpected Connection attribute: " + att.Name); } } if (cd.DataSourceName == "") { DebugLog.Message("Connection is missing name: " + cd.DatabaseLocator); } else if (DataSourceMx.DataSources.ContainsKey(cd.DataSourceName)) { DebugLog.Message("Data source defined twice: " + cd.DataSourceName); } else { DataSourceMx.DataSources.Add(cd.DataSourceName, cd); } } else if (Lex.Eq(node.Name, "SchemaToDataSource") || // schema map element Lex.Eq(node.Name, "SchemaToConnection")) { DbSchemaMx schema = new DbSchemaMx(); atts = node.Attributes; for (int i = 0; i < atts.Count; i++) { XmlNode att = atts.Item(i); if (Lex.Eq(att.Name, "Schema")) { schema.Name = att.Value.ToUpper().Trim(); } else if (Lex.Eq(att.Name, "AliasFor")) { schema.AliasFor = att.Value.ToUpper().Trim(); } else if (Lex.Eq(att.Name, "Connection")) { schema.DataSourceName = att.Value.ToUpper().Trim(); } else if (Lex.Eq(att.Name, "Label") || Lex.Eq(att.Name, "L")) { schema.Label = att.Value.Trim(); } else { throw new Exception ("Unexpected Connection attribute: " + att.Name); } } if (schema.Name == "") { throw new Exception("Missing schema name"); } if (schema.DataSourceName == "") { throw new Exception("Missing data source/connection name"); } Schemas[schema.Name] = schema; } else { throw new Exception("Expected Connection or SchemaToDataSource element but saw " + node.Name); } node = node.NextSibling; } sr.Close(); return(DataSources.Count); }
/// <summary> /// Method to run query in background and save the results for later retrieval /// </summary> /// <param name="q"></param> /// <param name="emailSubject">Send email if defined</param> /// <param name="templateName"></param> /// <returns></returns> public static string RunBackgroundQuery( Query q, string emailSubject, string templateName) { ResultsFormat rf; QueryManager qm; DataTableManager dtm; string msg = "", html = "", resultsFileName; string viewCmd = "View Background Query Results"; bool notifyUserByEmail = !Lex.IsNullOrEmpty(emailSubject); try // execute the query & read in all results { QbUtil.AddQueryAndRender(q, false); // add it to the query builder q.BrowseSavedResultsUponOpen = false; // be sure query is run rather than using existing results msg = QueryExec.RunQuery(q, OutputDest.WinForms); qm = q.QueryManager as QueryManager; dtm = qm.DataTableManager; DialogResult dr = dtm.CompleteRetrieval(); } catch (Exception ex) // some exceptions are normal, e.g. no criteria, others may be bugs { msg = "RunQueryInBackground could not complete due to an unexpected exception: " + DebugLog.FormatExceptionMessage(ex); ServicesLog.Message(msg); if (notifyUserByEmail) { Email.Send(null, SS.I.UserInfo.EmailAddress, emailSubject, msg); } return(msg); } if (dtm.KeyCount == 0) { msg = "Query " + Lex.Dq(q.UserObject.Name) + " returned no results."; if (notifyUserByEmail) { Email.Send(null, SS.I.UserInfo.EmailAddress, emailSubject, msg); } return(msg); } try { resultsFileName = q.ResultsDataTableFileName; // see if name supplied in query if (Lex.IsNullOrEmpty(resultsFileName)) { resultsFileName = "Query_" + q.UserObject.Id + "_Results.bin"; } resultsFileName = ServicesIniFile.Read("BackgroundExportDirectory") + @"\" + resultsFileName; dtm.WriteBinaryResultsFile(resultsFileName); // write the file UserObject cidListUo = SaveBackgroundQueryResultsReferenceObject(qm, "BkgrndQry", resultsFileName); if (!Lex.IsNullOrEmpty(templateName)) { html = ReadTemplateFile(templateName); } if (notifyUserByEmail) { AlertUtil.MailResultsAvailableMessage( // send the mail q, dtm.KeyCount, SS.I.UserInfo.EmailAddress, emailSubject, viewCmd, cidListUo.Id, null, html); } else { html = SubstituteBackgroundExportParameters(html, "", "", dtm.RowCount, dtm.KeyCount, false, ""); return(html); // return the html } } catch (Exception ex) { msg = "Error sending background query results: " + DebugLog.FormatExceptionMessage(ex); ServicesLog.Message(msg); } return(msg); }
/// <summary> /// Get image & coordinates file from KEGG FTP /// </summary> /// <param name="pathwayId"></param> /// <returns></returns> public static TargetMap GetKeggPathway( string pathwayId) { String ftpPath, rec; if (TargetMapDict == null) { ReadTargetMapDict(); } TargetMap tm = new TargetMap(); tm.Name = pathwayId; tm.Label = pathwayId; // default label tm.Source = "KEGG"; tm.Type = "Pathway"; // Build basic paths string ftpFolder = ServicesIniFile.Read("KeggPathWayFtpDirectory"); // get from here if (String.IsNullOrEmpty(ftpFolder)) { throw new Exception("KeggPathWayFtpDirectory not defined"); } if (!ftpFolder.EndsWith(@"/")) { ftpFolder += @"/"; } // Get map_title file and read title for pathway string filePath = TargetMapDir + @"\map_title.tab"; string pathwayPrefix = pathwayId.Substring(0, 3); string pathwayNbr = pathwayId.Substring(3); // bool download = false; if (!File.Exists(filePath)) { download = true; } while (true) { if (download) { ftpPath = ftpFolder + "map_title.tab"; Download(ftpPath, filePath); } StreamReader sr = new StreamReader(filePath); while (true) { rec = sr.ReadLine(); if (rec == null) { break; } if (!rec.StartsWith(pathwayNbr)) { continue; } string[] sa = rec.Split('\t'); tm.Label = sa[1].Trim() + " (KEGG: " + pathwayId + ")"; break; } sr.Close(); if (!String.IsNullOrEmpty(tm.Label)) { break; // have it } else if (download) // already downloaded but not found { tm.Label = pathwayId; break; } else { // download again if not done yet download = true; continue; } } // Get gif file if (Lex.Ne(pathwayPrefix, "map")) // if not a base level map then in organisms { ftpFolder += @"organisms/"; } ftpFolder += pathwayPrefix + @"/"; ftpPath = ftpFolder + pathwayId + ".gif"; filePath = TargetMapDir + @"\" + pathwayId + ".gif"; Download(ftpPath, filePath); Image img = Image.FromFile(filePath); tm.Bounds = new Rectangle(0, 0, img.Width, img.Height); tm.MarkBounds = true; filePath = TargetMapDir + @"\" + pathwayId + ".png"; // save as .png file that Spotfire can read img.Save(filePath, System.Drawing.Imaging.ImageFormat.Png); tm.ImageType = "png"; tm.ImageFile = Path.GetFileName(filePath); // store just file name // Get coordinates file if (Lex.Eq(pathwayPrefix, "map")) { ftpPath = ftpFolder + pathwayId + "_ec.coord"; filePath = TargetMapDir + @"\" + pathwayId + "_ec.coord"; } else { ftpPath = ftpFolder + pathwayId + "_gene.coord"; filePath = TargetMapDir + @"\" + pathwayId + "_gene.coord"; } Download(ftpPath, filePath); tm.CoordsFile = Path.GetFileName(filePath); TargetMapDict[tm.Name.ToUpper()] = tm; // add to list of maps TargetMapDictByLabel[tm.Label.ToUpper()] = tm; GetMapWithCoords(pathwayId); // read in coords to validate file format // Write out the map file containing basic map data filePath = TargetMapDir + @"\" + pathwayId + ".map"; StreamWriter sw = new StreamWriter(filePath); rec = tm.Name + "\t" + tm.Label + "\t" + tm.Source + "\t" + tm.Type + "\t" + tm.ImageType + "\t" + tm.ImageFile + "\t" + tm.Bounds.Left + "\t" + tm.Bounds.Top + "\t" + tm.Bounds.Right + "\t" + tm.Bounds.Bottom + "\t" + tm.MarkBounds + "\t" + tm.CoordsFile; sw.WriteLine(rec); sw.Close(); return(tm); }