public static void LogToFile(DTE dte, Logger logger, string message, LogLevel logLevel)
 {
     if (UserOptionsGrid.GetLoggingOptionBoolean(dte, "ExtensionLoggingEnabled"))
     {
         logger.Log(logLevel, message);
     }
 }
Beispiel #2
0
        private void RegistrationTool_OnClick(object sender, RoutedEventArgs e)
        {
            string path = UserOptionsGrid.GetPluginRegistraionToolPath(_dte);

            if (string.IsNullOrEmpty(path))
            {
                MessageBox.Show("Set Plug-in Registraion Tool path under Tools -> Options -> CRM Developer Extensions");
                return;
            }

            if (!path.EndsWith("exe", StringComparison.CurrentCultureIgnoreCase))
            {
                path = Path.Combine(path, "PluginRegistration.exe");
            }


            if (!File.Exists(path))
            {
                MessageBox.Show("PluginRegistration.exe not found at: " + path);
                return;
            }

            try
            {
                System.Diagnostics.Process.Start(path);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error launching Plug-in Registration Tool: " + Environment.NewLine + Environment.NewLine + ex.Message);
            }
        }
        private void EnableXrmToolingLogging()
        {
            DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;

            if (!UserOptionsGrid.GetLoggingOptionBoolean(dte, "ExtensionLoggingEnabled"))
            {
                return;
            }

            TraceControlSettings.TraceLevel = SourceLevels.All;
            string logPath = XrmToolingLogging.GetLogFilePath(dte);

            TraceControlSettings.AddTraceListener(new TextWriterTraceListener(logPath));
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            //This gets executed as each code file is loaded
            //1st
            DTE dte = GetGlobalService(typeof(DTE)) as DTE;

            if (dte == null)
            {
                return;
            }

            bool useIntellisense = UserOptionsGrid.GetUseIntellisense(dte);

            if (!useIntellisense)
            {
                return;
            }

            CrmServiceClient client = SharedGlobals.GetGlobal("CrmService", dte) as CrmServiceClient;

            if (client == null)
            {
                return;
            }

            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            CrmCompletionCommandHandler CreateCommandHandler() => new CrmCompletionCommandHandler(textViewAdapter, textView, this);

            textView.Properties.GetOrCreateSingletonProperty(CreateCommandHandler);

            if (CrmMetadata.Metadata == null)
            {
                CrmMetadata.GetMetadata(client);
            }
        }
        private static string GetLogFilePath(DTE dte)
        {
            string logFilePath = UserOptionsGrid.GetLoggingOptionString(dte, "ExtensionLogFilePath");

            return(Path.Combine(logFilePath, "CrmDevExLog_" + DateTime.Now.ToString("MMddyyyy") + ".log"));
        }