示例#1
0
        public static DynatraceConfig read(Context context, string visualStudioVersion)
        {
            try
            {
                string path = getConfigFilePath(visualStudioVersion);

                DynatraceConfig config;
                if (File.Exists(path))
                {
                    FileStream stream = new FileStream(path, FileMode.Open);
                    config = (DynatraceConfig)xmlSerializer.Deserialize(stream);
                    stream.Close();
                }
                else
                {
                    config = new DynatraceConfig();
                    config.write(context, visualStudioVersion);
                }
                return(config);
            }
            catch (Exception e)
            {
                context.log(Context.LOG_ERROR + e.ToString());
                return(null);
            }
        }
示例#2
0
 /// <summary>return the path and the name (codeLinkLog + SolutionName + processID)of the logfile</summary>
 private string getLogFilePath()
 {
     System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
     return
         (Path.Combine(
              Path.Combine(DynatraceConfig.getAppDataPath(), "log"),
              "log_" + p.Id.ToString() + ".log"));
 }
示例#3
0
        public static bool Ok(Context context, bool enabled, String portStr, DynatraceConfig prevConfig)
        {
            // if the plugin was disabled, close connection
            if (!enabled)
            {
                try
                {
                    context.disconnect();
                }
                catch (Exception e)
                {
                    context.log(Context.LOG_ERROR + e.ToString());
                }
                context.Config.PluginEnabled = false;
                context.Config.write(context, context.VisualStudioVersion);
                return(true);
            }

            // validate input data
            int port;

            try
            {
                port = Convert.ToInt32(portStr);
            }
            catch (System.FormatException)
            {
                MessageBox.Show("Port must be an integer beetween 0-65535");
                return(false);
            }

            if (!(port >= 0 && port <= 65535))
            {
                MessageBox.Show("Port must be an integer beetween 0-65535");
                return(false);
            }

            context.Config.PluginEnabled = true;
            context.Config.ClientPort    = port;

            if (prevConfig.ClientPort != port || !prevConfig.PluginEnabled)   //connect only if port has changed or if plugin was enabled
            {
                // connect using new port
                try
                {
                    context.connect();
                    context.Config.write(context, context.VisualStudioVersion);
                }
                catch (Exception e)
                {
                    context.log(Context.LOG_ERROR + e.ToString());
                }
            }
            return(true);
        }
示例#4
0
 public Context(DTE2 dte)
 {
     visualStudioVersion = dte.Version;
     this.dte            = dte;
     try
     {
         this.config = DynatraceConfig.read(this, visualStudioVersion);
     }
     catch (Exception e)
     {
         log(Context.LOG_ERROR + e.ToString());
         this.config = new DynatraceConfig();
     }
 }
示例#5
0
 public DynatraceConfig(DynatraceConfig config)
 {
     pluginEnabled = config.pluginEnabled;
     port          = config.port;
     clientPort    = config.clientPort;
 }