public void Compose(string sourceText) { /* Method reads a C# source file and parse it through Roslyn compiler. * Enumeration model get filled for all enumerations found in the source file, and SQL statements get extracted */ SourceText = sourceText; //ParseSourceEnumerations(SourceText); Scan(SourceText); if (EnumModels == null || EnumModels.Count == 0) { _log.WriteLine("no enumerations found."); } else { _log.WriteLine("" + EnumModels.Count() + " enumeration(s) found."); } UpdateModelsFromBD(); }
public void ReadEnumeration_Inner(EnumModel model) { /* once new connection string provided, the consecutive EnumModels will be using it */ bool newConnection = BuildConnectionString(model); if (newConnection) { _log.WriteLine("conn:\t {0}.", _scnn); } if (string.IsNullOrWhiteSpace(_scnn)) { /* all attempts failed */ throw new ApplicationException(string.Format("Connection string for the enumeration '{0}' is blank.", model.Name)); } _log.WriteLine("enum:\t {0}\t\t {1}.", model.Name, model.SqlSelect); switch (_dbType) { case DbTypeEnum.SqlServer: ReadSqlServer(model); break; case DbTypeEnum.Oledb: ReadOledb(model); break; case DbTypeEnum.Odbc: ReadOdbc(model); break; case DbTypeEnum.BuildInFake: ReadFake(model); break; } }
private void RunComposerScan(IEnumLog log) { try { RunComposerScan_Inner(log); } catch (Exception ex) { string message = "Sorry, and exception has occurred." + Environment.NewLine + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "See the Output\\Debug window for details."; if (log != null) { string logMessage = DedbugLog.ExceptionMessage(ex); log.WriteLine(logMessage); } //IVsUIShell uiShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); //todo: new dialog //Guid clsid = Guid.Empty; //int result; //uiShell.ShowMessageBox(0, // ref clsid, // "EnumComposer Visual Studio Package", // message, // string.Empty, // 0, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, // OLEMSGICON.OLEMSGICON_INFO, // 0, // false // out result); //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName); string title = "EnumComposerCommand"; // Show a message box to prove we were here VsShellUtilities.ShowMessageBox( this.ServiceProvider, message, title, OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } }
private void RunComposerScan_Inner(IEnumLog log) { DTE2 applicationObject = (DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE)); TextDocument document = ObtainActiveDocument(applicationObject); if (document == null) { log.WriteLine("not a C# file."); return; } DbReader dbReader = new DbReader(null, null, log); IEnumConfigReader configReaderVsp = new ConfigReaderVsp(applicationObject.ActiveDocument.ProjectItem.ContainingProject); dbReader._configReader = configReaderVsp; ComposerStrings composer = new ComposerStrings(dbReader, log); ApplyComposer(document, composer); }
public Tuple <string, string> GetConnectionString(string connectionStringName) //todo: too tight coupling here { try { Tuple <string, string> values = GetConnection(connectionStringName, _fromBottomDirectory, _toUpDirectory); if (values == null) { return(null); } string provider = DbReader.ProviderNameParsing(values.Item1); string scnn = values.Item2; return(new Tuple <string, string>(provider, scnn)); } catch (Exception ex) { string message = DedbugLog.ExceptionMessage(ex); // todo: funny dependancy _log.WriteLine(message); } return(null); }