Ejemplo n.º 1
0
    private static void OnLog(LogEvents type, string text)
    {
      if (_Log == null)
        return;

      _Log(null, new LogEventArgs(type, text));
    }
Ejemplo n.º 2
0
 private void searchBoxListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         var listBox = sender as ListBox;
         if (listBox != null)
         {
             listBox.ScrollIntoView(listBox.SelectedItem);
             LogEvents.SelectingRecommendationItem(this, listBox.SelectedIndex + 1);
         }
     }
     catch (Exception ee)
     {
         LogEvents.UIGenericError(this, ee);
     }
 }
Ejemplo n.º 3
0
        public TestDiscoveryTests(ITestOutputHelper output)
        {
            disposables.Add(LogEvents.Subscribe(e => output.WriteLine(e.ToLogString())));

            var peakyService = new PeakyService(
                targets =>
                targets.Add("staging", "widgetapi", new Uri("http://staging.widgets.com"))
                .Add("production", "widgetapi", new Uri("http://widgets.com"))
                .Add("staging", "sprocketapi", new Uri("http://staging.sprockets.com"))
                .Add("staging", "parameterized", new Uri("http://staging.parameterized.com"))
                .Add("production", "sprocketapi", new Uri("http://sprockets.com")));

            apiClient = peakyService.CreateHttpClient();

            disposables.Add(peakyService);
        }
        public HttpResponseMessage Post(TeleSales value)
        {
            string sYear      = DateTime.Now.Year.ToString();
            string sMonth     = DateTime.Now.Month.ToString();
            string sDay       = DateTime.Now.Day.ToString();
            string sErrorTime = sYear + sMonth + sDay;
            //string strUserAgent = HttpContext.Current.Request.UserAgent.ToString().ToLower();
            //bool result = HttpContext.Current.Request.Browser.IsMobileDevice;
            string    filePath = HttpContext.Current.Server.MapPath("~/App_Data/TeleSalesEvent_" + sErrorTime + ".log");
            LogEvents log      = new LogEvents();

            //log.Logevent(headers, filePath);
            try
            {
                TeleSales objTele = new TeleSales();
                string    result  = objTele.ValidateData(value);
                if (result == "")
                {
                    if (Membership.ValidateUser(value.UserName, value.Password))
                    {
                        AcceesModel obj = new AcceesModel();
                        ;
                        obj.GetResult("SetTeleSalesStagingData " +
                                      value.TeleSalesId + ",'" + value.MerchantName + "','" + value.FNAME + "','" + value.MNAME + "','" + value.LNAME + "','" + value.PhoneNo + "','" + value.CampaignCode + "','" + value.LeadPhoneNo + "','" + value.MissedCall + "','" +
                                      value.DateandTime.ToString("MM-dd-yyyy hh:mm:ss") + "','" + value.Circle + "','" + value.Operator + "','" + value.YourName + "','" + value.Email + "','" + value.City + "'," + value.NoofYearinBusiness + ",'" + value.LoanAmount + "','" + value.Avgsalespermonth +
                                      "','" + value.Source + "','" + value.DOB + "','" + value.ADDRESSOfResidence + "','" + value.ADDRESSOfShop + "','" + value.AddressPinCode + "','" + value.ShopPinCode + "','" + value.Industry + "'"
                                      );
                        log.Logevent(value, filePath);
                        return(Request.CreateResponse(HttpStatusCode.OK, "Data Saved Successfully"));
                    }
                    else
                    {
                        log.Logevent("Authentication Failed", filePath);
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, "Authentication Failed"));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, result));
                }
            }
            catch (Exception ex)
            {
                log.Logevent(ex.Message, filePath);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString()));
            }
        }
Ejemplo n.º 5
0
        internal void Validate()
        {
            bool isTokenIdPresent    = !string.IsNullOrWhiteSpace(QueueData.TokenId);
            bool isBatchIdPresent    = !string.IsNullOrWhiteSpace(QueueData.BatchId);
            bool isDispatchIdPresent = !string.IsNullOrWhiteSpace(QueueData.DispatchId);

            if (isTokenIdPresent && isBatchIdPresent && isDispatchIdPresent)
            {
                IsProcessable = true;
                LogEvents.Add(Utils.CreateLogEvent(QueueData, IRDLM.Validated(QueueData.AdditionalURLParameter)));
            }
            else
            {
                IsProcessable = false;
                LogEvents.Add(Utils.CreateLogEvent(QueueData, IRDLM.Invalidated));
            }
        }
Ejemplo n.º 6
0
        private Hyperlink CreateHyperLinkByShapedWord(IShapedWord shapedWord)
        {
            var link = new SandoQueryHyperLink(new Run(shapedWord.Word),
                                               searchBox.Text + " " + shapedWord.Word, 0)
            {
                FontSize        = shapedWord.FontSize,
                Foreground      = shapedWord.Color,
                IsEnabled       = true,
                TextDecorations = null,
            };

            link.Click += (sender, args) => LogEvents.AddWordFromTagCloud(searchBox.Text,
                                                                          "TOFIXTHE", shapedWord.Word);
            link.Click += StartSearchAfterClick;
            link.Click += (sender, args) => TagCloudPopUpWindow.IsOpen = false;
            return(link);
        }
Ejemplo n.º 7
0
 public void OpenSandoOptions()
 {
     try
     {
         string sandoDialogPageGuid = "B0002DC2-56EE-4931-93F7-70D6E9863940";
         var    command             = new CommandID(
             VSConstants.GUID_VSStandardCommandSet97,
             VSConstants.cmdidToolsOptions);
         var mcs = GetService(typeof(IMenuCommandService))
                   as MenuCommandService;
         mcs.GlobalInvoke(command, sandoDialogPageGuid);
     }
     catch (Exception e)
     {
         LogEvents.UIGenericError(this, e);
     }
 }
Ejemplo n.º 8
0
        public async Task <ActionResult> LogEvents()
        {
            var dbContext = new NotificationDb();
            var logEvent  = new LogEvents()
            {
                EventType           = Enum.EventType.Delete,
                Id                  = Guid.NewGuid(),
                UserWhoCreatesEvent = "*****@*****.**",
                ObjectTypeOfEvent   = Enum.ObjectTypeOfEvent.MonthlyMeeting
            };

            dbContext.LogEventses.Add(logEvent);
            await dbContext.SaveChangesAsync();


            var storageAccount           = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString());
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

            CloudQueue queue = queueClient.GetQueueReference("logeventslog");

            queue.CreateIfNotExists();
            var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(logEvent));

            queue.AddMessage(queueMessage);


            //List<string> c = dbContext.LogEventSubscriptionses.Where(r => r.EventType == logEvent.EventType
            //	&& r.ObjectTypeOfEvent == logEvent.ObjectTypeOfEvent).Select(r => r.UserWhoSubscribed).ToList();

            //var mandrill = new MandrillApi(ConfigurationManager.AppSettings["MandrillApiKey"]);

            //foreach (var row in c)
            //{
            //	var email = new EmailMessage
            //	{
            //		Text = "body",
            //		FromEmail = "*****@*****.**",
            //		To = new List<EmailAddress> {new EmailAddress {Email = row}},
            //		Subject = "Sub"
            //	};

            //	await mandrill.SendMessage(new SendMessageRequest(email));
            //}

            return(Content("new row created"));
        }
Ejemplo n.º 9
0
 private void MyToolWindow_LostFocus(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.searchResultListbox.Items.Count > 0)
         {
             foreach (var item in this.searchResultListbox.Items)
             {
                 ShowPopupOneItem(this.searchResultListbox, false, item);
             }
         }
     }
     catch (Exception ee)
     {
         LogEvents.UIGenericError(this, ee);
     }
 }
Ejemplo n.º 10
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                base.Initialize();
                LogEvents.UISandoBeginInitialization(this);

                SetupDependencyInjectionObjects();

                _viewManager = ServiceLocator.Resolve <ViewManager>();
                AddCommand();
                SetUpLifeCycleEvents();
            }
            catch (Exception e)
            {
                LogEvents.UISandoInitializationError(this, e);
            }
        }
Ejemplo n.º 11
0
        public static void SetEvent(LogEvents logEvent)
        {
            if (HttpContext.Current.Session["EventsLog"] != null)
            {
                List <LogEvents> events = (List <LogEvents>)HttpContext.Current.Session["EventsLog"];

                events.Add(logEvent);

                HttpContext.Current.Session["EventsLog"] = events;
            }
            else
            {
                HttpContext.Current.Session["EventsLog"] = new List <LogEvents>()
                {
                    logEvent
                };
            }
        }
Ejemplo n.º 12
0
        private static FieldElement ParseField(List <ProgramElement> programElements, string fileName, XElement field)
        {
            try
            {
                string name;
                int    definitionLineNumber;
                int    definitionColumnNumber;
                SrcMLParsingUtils.ParseNameAndLineNumber(field, out name, out definitionLineNumber, out definitionColumnNumber);

                ClassElement classElement = RetrieveClassElement(field, programElements);
                Guid         classId      = classElement != null ? classElement.Id : Guid.Empty;
                string       className    = classElement != null ? classElement.Name : String.Empty;

                //parse access level and type
                var         typeElement = field.Element(SRC.Type);
                AccessLevel accessLevel = RetrieveAccessLevel(typeElement);

                IEnumerable <XElement> types = typeElement.Elements(SRC.Name);
                string fieldType             = String.Empty;
                foreach (XElement type in types)
                {
                    fieldType += type.Value + " ";
                }
                fieldType = fieldType.TrimEnd();

                string   initialValue        = String.Empty;
                XElement initialValueElement = field.Element(SRC.Init);
                if (initialValueElement != null)
                {
                    initialValue = initialValueElement.Element(SRC.Expression).Value;
                }

                string fullFilePath = System.IO.Path.GetFullPath(fileName);
                string snippet      = RetrieveSource(field);

                return(new FieldElement(name, definitionLineNumber, definitionColumnNumber, fullFilePath, snippet, accessLevel, fieldType, classId, className, String.Empty, initialValue));
            }
            catch (Exception error)
            {
                Type t = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                LogEvents.ParserGenericException(t, error);
                return(null);
            }
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            LogEvents.Subscribe(i =>
            {
                i.Operation.Id = "";
                Console.WriteLine(i.ToLogString());
            }, new[]
            {
                //typeof(PiTop4Board).Assembly,
                //typeof(FoundationPlate).Assembly,
                typeof(Program).Assembly
            });

            using var pipeline = Pipeline.Create("PiTop", DeliveryPolicy.Unlimited);
            using var module   = PiTop4Board.Instance;
            var plate = module.GetOrCreateFoundationPlate();

            var threshold = plate
                            .GetOrCreatePotentiometer(AnaloguePort.A0)
                            .CreateComponent(pipeline, TimeSpan.FromSeconds(0.5));

            var distance = plate
                           .GetOrCreateUltrasonicSensor(DigitalPort.D0)
                           .CreateComponent(pipeline, TimeSpan.FromSeconds(0.2));

            var alert = new ValueAlertComponent(pipeline,
                                                new[]
            {
                plate.GetOrCreateLed(DigitalPort.D1, Color.Green),
                plate.GetOrCreateLed(DigitalPort.D2, Color.Gold),
                plate.GetOrCreateLed(DigitalPort.D3, Color.RebeccaPurple)
            });

            threshold
            .Select(t => t * 50)
            .PipeTo(alert.Threshold);

            distance
            .Select(d => Math.Min(d.Value, 50))
            .PipeTo(alert.Value);

            pipeline.Run();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Удалить
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public LogEvents DeleteLogEvents(long ID)
        {
            LogEvents dbEntry = context.LogEvents.Find(ID);

            if (dbEntry != null)
            {
                try
                {
                    context.LogEvents.Remove(dbEntry);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    e.SaveErrorMethod(String.Format("DeleteLogEvents(ID={0})", ID), blog);
                    return(null);
                }
            }
            return(dbEntry);
        }
Ejemplo n.º 15
0
        public async Task Diagnostic_logs_do_not_show_up_in_captured_console_output()
        {
            using (LogEvents.Subscribe(e => Console.WriteLine(e.ToLogString())))
            {
                var server = GetCodeRunner();

                var result = await server.Run(
                    new WorkspaceRequest(
                        CreateWorkspaceWithMainContaining(
                            "Console.WriteLine(\"hi!\");"))
                    );

                result.Output
                .Should()
                .BeEquivalentTo(
                    new[] { "hi!", "" },
                    options => options.WithStrictOrdering());
            }
        }
Ejemplo n.º 16
0
        public static void ExitApp(int exitCode, string message = "", LogEvents logEvent = LogEvents.Error, bool errorWritingToLog = false)
        {
            if (exitCode == 0)
            {
                message = "completed successfully";
            }

            message = string.Format("[{0}] {1} - exit code: {2}", appName, message, exitCode);
            if (errorWritingToLog)
            {
                Console.WriteLine(message);
            }
            else
            {
                LogEvent(message, logEvent);
            }

            Environment.Exit(exitCode);
        }
Ejemplo n.º 17
0
 private AtomicCollection <IAtomic> CheckCompounds(AtomicCollection <IAtomic> experimentCollection)
 {
     foreach (var compound in Knowledge.KnownCompounds)
     {
         var result = CanChemistDoCompound(compound, experimentCollection);
         if (result != null)
         {
             var atomStack = new List <AtomStack>();
             foreach (var iatomic in result)
             {
                 atomStack.Add(new AtomStack(iatomic));
                 experimentCollection.Remove(iatomic);
             }
             Compound newCompound = new Compound(atomStack);
             LogEvents.CompoundGot(compound);
             CheckCompounds(experimentCollection);
         }
     }
     return(experimentCollection);
 }
Ejemplo n.º 18
0
        public String CreateEvent(string eventType, string station, string system, string cargo, string cargoAction, int cargoVolume, string notes, DateTime eventDate)
        {
            String newEventID = Guid.NewGuid().ToString();

            LogEvents.Add(new CommandersLogEvent
            {
                EventType   = eventType,
                Station     = station,
                System      = system,
                Cargo       = cargo,
                CargoAction = cargoAction,
                CargoVolume = cargoVolume,
                Notes       = notes,
                EventDate   = eventDate,
                EventID     = newEventID
            });

            UpdateCommandersLogListView();

            return(newEventID);
        }
Ejemplo n.º 19
0
        public void Verbosity_can_be_specified()
        {
            var factory = new LoggerFactory()
                          .AddPocketLogger((category, logLevel) =>
                                           category == "awesome" ||
                                           logLevel == Microsoft.Extensions.Logging.LogLevel.Critical);

            var log = new LogEntryList();

            using (LogEvents.Subscribe(e => log.Add(e)))
            {
                factory.CreateLogger("awesome").LogInformation("this should absolutely be in the log!");

                factory.CreateLogger <string>().LogCritical("this should also be in the log");

                factory.CreateLogger <string>().LogError("this should NOT be in the log");
            }

            log.Should().HaveCount(2);
            log.Should().NotContain(e => e.LogLevel == (int)LogLevel.Error);
        }
Ejemplo n.º 20
0
        public string CreateEvent()
        {
            String newEventID = Guid.NewGuid().ToString();

            _callingForm.tbLogEventID.Text = newEventID;

            LogEvents.Add(new CommandersLogEvent
            {
                EventType   = _callingForm.cbLogEventType.Text,
                Station     = _callingForm.cbLogStationName.Text,
                System      = _callingForm.cbLogSystemName.Text,
                Cargo       = _callingForm.cbLogCargoName.Text,
                CargoAction = _callingForm.cbCargoModifier.Text,
                CargoVolume = int.Parse(_callingForm.cbLogQuantity.Text),
                Notes       = _callingForm.tbLogNotes.Text,
                EventDate   = _callingForm.dtpLogEventDate.Value,
                EventID     = newEventID
            });

            return(newEventID);
        }
Ejemplo n.º 21
0
        public List <ProgramElement> Parse(string filename)
        {
            if (File.Exists(filename) && GetSizeInMb(filename) > 15)
            {
                return(new List <ProgramElement>());
            }
            var list = new List <ProgramElement>();

            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (var sr = new StreamReader(filename))
                {
                    String line;
                    int    linenum = 0;
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        linenum++;
                        if (String.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        //var name = Regex.Replace(line, @"(\w+)\W+", "$1 ");
                        var name = line.TrimStart(' ', '\n', '\r', '\t');
                        name = name.TrimEnd(' ');
                        var snippet = SrcMLParsingUtils.RetrieveSource(name);
                        var element = new TextLineElement(name, linenum, -1000, filename, snippet, line);
                        list.Add(element);
                    }
                }
            }
            catch (Exception e)
            {
                LogEvents.ParserGenericFileError(this, filename);
            }
            return(list);
        }
        public async Task Request_information_is_sent_to_PocketLogger()
        {
            var log = new List <string>();

            using (var fakeService = new FakeHttpService()
                                     .OnRequest(r => true)
                                     .RespondWith(async r =>
            {
                r.Headers.Add("a-response-header", "a-response-header-value");
                await r.WriteAsync(JsonConvert.SerializeObject(new { ResponseProperty = "response-property-value" }));
            }))
                using (LogEvents.Subscribe(e => log.Add(e.ToLogString())))
                {
                    await new HttpClient().PostAsync(
                        new Uri(fakeService.BaseAddress, "/and/the/path?and=query"),
                        new StringContent(JsonConvert.SerializeObject(new { RequestProperty = "request-property-value" }), Encoding.UTF8, "application/json"));
                }

            log.Should()
            .HaveCount(2);

            log[0]
            .NormalizeLineEndings()
            .Should()
            .Match(@"*[FakeHttpService.RequestLoggingMiddleware] [Invoke]  ▶ 
  POST http://127.0.0.1:*/and/the/path?and=query
    Connection: Keep-Alive
    Content-Type: application/json; charset=utf-8
    Host: 127.0.0.1:*
    Content-Length: *
  {""RequestProperty"":""request-property-value""}*".NormalizeLineEndings());

            log[1]
            .NormalizeLineEndings()
            .Should()
            .Match(@"*[FakeHttpService.RequestLoggingMiddleware] [Invoke]  ⏹ -> ✔ (*ms) 
  HTTP/ 200
    a-response-header: a-response-header-value
  {""ResponseProperty"":""response-property-value""}*".NormalizeLineEndings());
        }
Ejemplo n.º 23
0
        public List <ProgramElement> Parse(string fileName)
        {
            var      programElements = new List <ProgramElement>();
            XElement sourceElements;

            if (Archive != null)
            {
                sourceElements = Archive.GetXElementForSourceFile(fileName);
                if (sourceElements != null)
                {
                    programElements = Parse(fileName, sourceElements);
                }
                else
                {
                    LogEvents.ParserFileNotFoundInArchiveError(this, fileName);
                }
            }
            else if (Generator != null)
            {
                string outFile = Path.GetTempFileName();
                try {
                    //This is a CSharp parser, so we'll convert the input file as CSharp no matter what the file extension is
                    Generator.GenerateSrcMLFromFile(fileName, outFile, Language.CSharp);
                    sourceElements = SrcMLElement.Load(outFile);
                    if (sourceElements != null)
                    {
                        programElements = Parse(fileName, sourceElements);
                    }
                } finally {
                    File.Delete(outFile);
                }
            }
            else
            {
                throw new InvalidOperationException("SrcMLCSharpParser - Archive and Generator are both null");
            }

            return(programElements);
        }
Ejemplo n.º 24
0
        public void MonitoringStopped(object sender, EventArgs args)
        {
            lock (tasksTrackerLock)
            {
                foreach (var cancelToken in cancellers)
                {
                    cancelToken.Cancel();
                }
            }

            LogEvents.UIMonitoringStopped(this);
            var currentIndexer = ServiceLocator.ResolveOptional <DocumentIndexer>();

            if (currentIndexer != null)
            {
                currentIndexer.Dispose(false);  // Because in SolutionMonitor: public void StopMonitoring(bool killReaders = false)
            }
            if (SwumManager.Instance != null)
            {
                SwumManager.Instance.PrintSwumCache();
            }
        }
        public static void getChats(string ip, RichTextBox txtBox)
        {
            Tuple <string, UInt16> addr = splitAddr(ip);
            string addrIP = addr.Item1;
            UInt16 port   = addr.Item2;
            string rconPW = decryptRcon();

            var server = ServerQuery.GetServerInstance(
                (Game)appId,
                addrIP,
                port,
                throwExceptions: false,
                retries: retries);

            addLogAddr(ref server, rconPW, txtBox);

            using (Logs logger = server.GetLogs(port))
            {
                LogEvents chatEvents = logger.GetEventsInstance();
                //chatEvents.
            }
        }
        public async Task Middleware_can_be_used_to_log_commands_as_they_are_scheduled()
        {
            var scheduler = CommandScheduler.Create <object>(delivery =>
            {
            })
                            .UseMiddleware(async(delivery, next) =>
            {
                using (Log.ConfirmOnExit())
                {
                    await next(delivery);
                }
            });

            var log = new List <string>();

            using (LogEvents.Subscribe(e => log.Add(e.ToLogString())))
            {
                await scheduler.Schedule(new object());
            }

            log.Should().ContainSingle(e => e.Contains(nameof(Middleware_can_be_used_to_log_commands_as_they_are_scheduled)));
        }
Ejemplo n.º 27
0
 public static string GetDisplayPathMonitoredFiles(ISrcMLGlobalService service, object callingObject)
 {
     if (service.MonitoredDirectories.Count > 0)
     {
         var fullpath = service.MonitoredDirectories.First();
         var path     = Path.GetFileName(fullpath);
         try
         {
             var parent = Path.GetFileName(Path.GetDirectoryName(fullpath));
             path += " in folder " + parent;
         }
         catch (Exception e)
         {
             LogEvents.UIIndexUpdateError(callingObject, e);
         }
         return(path);
     }
     else
     {
         return(SearchViewControl.PleaseAddDirectoriesMessage);
     }
 }
Ejemplo n.º 28
0
        public static void LogEvent(string message, LogEvents logEvent = LogEvents.Error, bool logToLog4Net = true, bool logToConsole = true)
        {
            message = string.Format("{0} | {1}@{2}", message, Environment.UserName, Environment.MachineName);

            if (Settings.Default.LogToLog4Net && logToLog4Net)
            {
                ILog Logger = LogManager.GetLogger("EventLogAppender");

                try
                {
                    switch (logEvent)
                    {
                    case LogEvents.Debug:
                        Logger.DebugFormat(message); break;

                    case LogEvents.Error:
                        Logger.ErrorFormat(message); break;

                    case LogEvents.Fatal:
                        Logger.FatalFormat(message); break;

                    case LogEvents.Info:
                        Logger.InfoFormat(message); break;

                    case LogEvents.Warn:
                        Logger.WarnFormat(message); break;
                    }
                }
                catch (Exception ex)
                {
                    ExitApp(1, string.Format("EXCEPTION in {0}: {1}", MethodBase.GetCurrentMethod(), ex.Message), errorWritingToLog: true);
                }

                if (Settings.Default.LogToConsole && logToConsole)
                {
                    Console.WriteLine(message);
                }
            }
        }
Ejemplo n.º 29
0
        public void StartupCompleted()
        {
            try
            {
                if (_viewManager.ShouldShow())
                {
                    _viewManager.ShowSando();
                    try
                    {
                        //will fail during testing in VS IDE host
                        _viewManager.ShowToolbar();
                    }
                    catch (Exception e)
                    {
                        //ignore
                    }
                }

                if (ServiceLocator.Resolve <DTE2>().Version.StartsWith("10"))
                {
                    //only need to do this in VS2010, and it breaks things in VS2012
                    Solution openSolution = ServiceLocator.Resolve <DTE2>().Solution;

                    // JZ: SrcMLService Integration
                    ////if(openSolution != null && !String.IsNullOrWhiteSpace(openSolution.FullName) && _currentMonitor == null)
                    if (openSolution != null && !String.IsNullOrWhiteSpace(openSolution.FullName))
                    // End of code changes
                    {
                        SolutionHasBeenOpened();
                    }
                }

                RegisterSolutionEvents();
            }
            catch (Exception e)
            {
                LogEvents.UIGenericError(this, e);
            }
        }
Ejemplo n.º 30
0
        public async Task A_script_snippet_workspace_can_be_used_to_get_signature_help()
        {
            await Default.ConsoleWorkspace();

            var log = new LogEntryList();

            var(processed, position) = CodeManipulation.ProcessMarkup("Console.WriteLine($$)");
            using (LogEvents.Subscribe(log.Add))
                using (var agent = new AgentService())
                {
                    var json = new WorkspaceRequest(
                        requestId: "TestRun",
                        activeBufferId: "default.cs",
                        workspace: Workspace.FromSource(
                            processed,
                            "script",
                            id: "default.cs",
                            position: position))
                               .ToJson();

                    var request = new HttpRequestMessage(HttpMethod.Post, @"/workspace/signaturehelp")
                    {
                        Content = new StringContent(
                            json,
                            Encoding.UTF8,
                            "application/json")
                    };

                    var response = await agent.SendAsync(request);

                    var result = await response
                                 .EnsureSuccess()
                                 .DeserializeAs <SignatureHelpResult>();

                    result.Signatures.Should().NotBeNullOrEmpty();
                    result.Signatures.Should().Contain(signature => signature.Label == "void Console.WriteLine(string format, params object[] arg)");
                }
        }
Ejemplo n.º 31
0
        public async Task A_script_snippet_workspace_can_be_used_to_get_diagnostics()
        {
            await Default.ConsoleWorkspace();

            var log = new LogEntryList();

            var(processed, position) = CodeManipulation.ProcessMarkup("adddd");
            using (LogEvents.Subscribe(log.Add))
                using (var agent = new AgentService())
                {
                    var json = new WorkspaceRequest(
                        requestId: "TestRun",
                        activeBufferId: "default.cs",
                        workspace: Workspace.FromSource(
                            processed,
                            "script",
                            id: "default.cs",
                            position: position))
                               .ToJson();

                    var request = new HttpRequestMessage(HttpMethod.Post, @"/workspace/diagnostics")
                    {
                        Content = new StringContent(
                            json,
                            Encoding.UTF8,
                            "application/json")
                    };

                    var response = await agent.SendAsync(request);

                    var result = await response
                                 .EnsureSuccess()
                                 .DeserializeAs <DiagnosticResult>();

                    result.Diagnostics.Should().NotBeNullOrEmpty();
                    result.Diagnostics.Should().Contain(signature => signature.Message == "default.cs(1,1): error CS0103: The name \'adddd\' does not exist in the current context");
                }
        }
Ejemplo n.º 32
0
    ///<summary>
    /// Set the events that will be written to the log. The log will be written to the Log event
    /// and the debug window in VisualStudio. To change the log settings you must use a custom
    /// log.xml file.
    ///</summary>
    ///<param name="events">The events that will be logged.</param>
    public static void SetLogEvents(LogEvents events)
    {
      _LogEvents = events;

      if (_Log != null)
        SetLogEvents();
    }
Ejemplo n.º 33
0
        /// <summary>
        /// Loads the content of the Log from Sqlite.
        /// </summary>
        /// <param name="xmlReader">The XmlReader instance containing the data.</param>
        public void LoadSqlite(string filePath)
        {
            if (filePath.IsNullOrBlank()) throw new ArgumentNullException("filePath");
            if (!File.Exists(filePath)) throw new FileNotFoundException(String.Format("Specified File '{0}' not found.", filePath), filePath);

            using (SqliteDataContext context = new SqliteDataContext(filePath))
            {
                LogEvents logEvents = new LogEvents(context.LogEvents);
                Entries.AddRange(logEvents.Select(logEvent => (LogEntry) logEvent));
            }
        }
Ejemplo n.º 34
0
 internal LogEventArgs(LogEvents eventType, string message)
 {
   EventType = eventType;
   Message = message;
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Logs an event for an account.
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="eventType"></param>
 /// <param name="additionalInfo"></param>
 public static void logEvent(string userid, LogEvents eventType, string additionalInfo, Connector conn)
 {
     conn.Query_Execute("INSERT INTO bsa_user_log (userid, event_type, date, additional_info) VALUES('" + Utils.Escape(userid) + "', '" + (int)eventType + "', NOW(), " + (additionalInfo != null ? "'" + Utils.Escape(additionalInfo) + "'" : "NULL") + ")");
 }