예제 #1
0
        public static void InsertStatistic(string appName, string plugin, string command, string version, string doc)
        {
            Task.Run(() =>
            {
                try
                {
                    var db = new PluginStatisticDbContext();
                    db.Configuration.LazyLoadingEnabled       = false;
                    db.Configuration.AutoDetectChangesEnabled = false;
                    db.Configuration.ValidateOnSaveEnabled    = false;
                    db.C_PluginStatistics.Add(new C_PluginStatistic
                    {
                        Application = appName,
                        Plugin      = plugin ?? string.Empty,
                        Command     = command ?? string.Empty,
                        Build       = version.Truncate(40) ?? string.Empty,
                        Doc         = doc.Truncate(500) ?? string.Empty,
                        UserName    = Environment.UserName,
                        DateStart   = DateTime.Now,
                        DocName     = Path.GetFileName(doc)
                    });

                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex, $"PluginStatisticsHelper Insert. appName={appName}, plugin={plugin}, command={command}, version={version}, doc={doc}, docName={Path.GetFileName(doc)}");
                }

                if (!appName.EndsWith(" Run") && !appName.EndsWith(" Update"))
                {
                    YandexMetrica.ReportEvent($"{plugin} {command}");
                }
            });
        }
예제 #2
0
        public MainPage()
        {
            Location = new YandexMetrica.Location();
            InitializeComponent();

            Loaded   += (sender, args) => YandexMetrica.ReportEvent("Hello!");
            Unloaded += (sender, args) => YandexMetrica.ReportEvent("Bye!");

            LocationButton.Click += (sender, args) => YandexMetricaConfig.SetCustomLocation(Location);
            EventButton.Click    += (sender, args) => YandexMetrica.ReportEvent(EventNameTextBox.Text);
            CrashButton.Click    += (sender, args) => { throw new Exception(); };
            ErrorButton.Click    += (sender, args) =>
            {
                try
                {
                    throw new ArgumentException("Throw exception and catch it");
                }
                catch (Exception exception)
                {
                    YandexMetrica.ReportError(ErrorNameTextBox.Text, exception);
                }
            };

            ResetButton.Click += (sender, args) =>
            {
                YandexMetricaConfig.OfflineMode      = false;
                YandexMetricaConfig.CrashTracking    = true;
                YandexMetricaConfig.LocationTracking = true;
                YandexMetricaConfig.CustomAppVersion = null;
                YandexMetricaConfig.SetCustomLocation(null);
            };

            JsonButton.Click += (sender, args) => YandexMetrica.ReportEvent("abc", JsonData.GetObject());
            JsonButton.Click += (sender, args) => YandexMetrica.ReportEvent("abc", JsonData.GetDictionary());
        }
예제 #3
0
        private void LogItem(LoggedItem item)
        {
            try
            {
                lock (Sync)
                {
                    if (!Initialized)
                    {
                        LoggedItems.Add(item);
                        return;
                    }
                }

                if (item is LoggedEvent)
                {
                    var loggedEvent = (LoggedEvent)item;
                    YandexMetrica.ReportEvent(loggedEvent.Title, loggedEvent.Values);
                }
                else if (item is LoggedException)
                {
                    var loggedException = (LoggedException)item;
                    YandexMetrica.ReportError(loggedException.Message, loggedException.Exception);
                }
            }
            catch (Exception)
            {
            }
        }
예제 #4
0
        public static void TrackEvent(string eventName, Dictionary <string, object> parameters = null)
        {
            string jsonData = parameters != null?JsonConvert.SerializeObject(parameters) : null;

            YandexMetrica.ReportEvent(eventName, jsonData);

            Logger.Info("Analytics: " + eventName + " data: " + jsonData);
        }
예제 #5
0
 private static void Report(User.User user, string eventName)
 {
     YandexMetrica.ReportEvent(eventName, new Dictionary <string, string>
     {
         { "user", user.Info.UserId.ToString() },
         { "userIntent", Utils.CurrentIntent(user) }
     });
 }
예제 #6
0
        public MainPage()
        {
            InitializeComponent();

            YandexMetrica.ReportEvent("MainPage Ctor");

            Loaded   += OnLoaded;
            Unloaded += OnUnloaded;
        }
예제 #7
0
 public static void Log(string msg)
 {
     try
     {
         YandexMetrica.ReportEvent(msg);
     }
     catch
     {
     }
 }
예제 #8
0
        public void LogEvent(string eventName, string json)
        {
#if !DEBUG
            try
            {
                YandexMetrica.ReportEvent(eventName, json);
            }
            catch (Exception) { }
#endif
        }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            //TODO: https://tech.yandex.com/metrica-mobile-sdk/doc/mobile-sdk-dg/tasks/winphone-quickstart-docpage/-->
            YandexMetrica.Config.LocationTracking = false;
            YandexMetrica.Activate("Yours Api Key");
            YandexMetrica.ReportEvent("Hello from background!");
            YandexMetrica.Snapshot();
            NotifyComplete();
        }
예제 #10
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            YandexMetrica.Config.LocationTracking = false;
            //TODO: https://tech.yandex.com/metrica-mobile-sdk/doc/mobile-sdk-dg/tasks/winphone-quickstart-docpage/
            YandexMetrica.Activate("Yours Api Key");
            YandexMetrica.ReportEvent("Hello from background!");
            YandexMetrica.Snapshot();
            deferral.Complete();
        }
예제 #11
0
 private static void Report(User.User user, string eventName, IEnumerable <KeyValuePair <string, string> > dict)
 {
     Logger.Debug($"Sending Yandex event: {eventName}");
     YandexMetrica.ReportEvent(eventName, dict
                               .Concat(new[]
     {
         new KeyValuePair <string, string>("user", user.Info.UserId.ToString()),
         new KeyValuePair <string, string>("intent", Utils.CurrentIntent(user))
     })
                               .ToDictionary(kv => kv.Key, kv => kv.Value)
                               );
 }
예제 #12
0
        private async Task ReportDmp()
        {
            string pathToDmps = $@"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\My Games\Skyrim Special Edition\SKSE\Crashdumps\";

            if (!Directory.Exists(pathToDmps))
            {
                return;
            }
            try
            {
                DateTime dt       = ModVersion.LastDmpReported;
                string   fileName = "";
                foreach (FileSystemInfo fileSI in new DirectoryInfo(pathToDmps).GetFileSystemInfos())
                {
                    if (fileSI.Extension == ".dmp")
                    {
                        if (dt < Convert.ToDateTime(fileSI.CreationTime))
                        {
                            dt       = Convert.ToDateTime(fileSI.CreationTime);
                            fileName = fileSI.Name;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(fileName))
                {
                    if (await Net.ReportDmp(pathToDmps + fileName))
                    {
                        YandexMetrica.ReportEvent("CrashReported");
                    }
                    else
                    {
                        YandexMetrica.ReportEvent("CantReport");
                    }
                    ModVersion.LastDmpReported = dt;
                    ModVersion.Save();

                    await Task.Delay(3000);

                    File.Delete(pathToDmps + fileName);
                }
            }
            catch (Exception e)
            {
                if (!(e is WebException) && (e is SocketException))
                {
                    Logger.Error("ReportDmp", e);
                }
            }
        }
        private void OnNavigateToPage(NavigateToPageMessage message)
        {
            Type type = Type.GetType("Meridian.View." + message.Page.Substring(1), false);

            if (type == null)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
                return;
            }

            var frame = Application.Current.MainWindow.GetVisualDescendents().OfType <Frame>().FirstOrDefault();

            if (frame == null)
            {
                return;
            }

            if (Settings.Instance.SendStats)
            {
                YandexMetrica.ReportEvent("page" + message.Page);
            }

            if (typeof(Layout.PageBase).IsAssignableFrom(type))
            {
                var page = (Layout.PageBase)Activator.CreateInstance(type);
                page.NavigationContext.Parameters = message.Parameters;
                frame.Navigate(page);
            }
            else if (typeof(PageBase).IsAssignableFrom(type))
            {
                var page = (PageBase)Activator.CreateInstance(type);
                page.NavigationContext.Parameters = message.Parameters;
                frame.Navigate(page);
            }
            else if (typeof(Page).IsAssignableFrom(type))
            {
                frame.Navigate(Activator.CreateInstance(type));
            }

            UpdateCanGoBack();
        }
예제 #14
0
        public static async Task <bool> StartGame()
        {
            EnableDebug();

            StartInfo.FileName         = $"{Settings.PathToSkyrim}\\skse64_loader.exe";
            StartInfo.WorkingDirectory = $"{Settings.PathToSkyrim}";
            StartInfo.UseShellExecute  = false;
            StartInfo.CreateNoWindow   = true;
            StartInfo.Verb             = "runas";

            StartInfo.Domain = AppDomain.CurrentDomain.FriendlyName;

            GameProcess.StartInfo = StartInfo;

            Runing = true;
            GameProcess.Start();
            YandexMetrica.ReportEvent("StartedGame");

            int ParentPID = GameProcess.Id;

            await Task.Run(() => GameProcess.WaitForExit());

            foreach (var p in ProcessExtensions.FindChildrenProcesses(ParentPID))
            {
                GameProcess = p;
            }
            Microsoft.Win32.SafeHandles.SafeProcessHandle sh = GameProcess.SafeHandle;
            if (!GameProcess.HasExited)
            {
                await Task.Run(() => GameProcess.WaitForExit());
            }

            YandexMetrica.ReportEvent("ExitedGame");

            await Task.Delay(1000);

            await KillProcess();

            Runing = false;

            return(GameProcess.ExitCode != 0);
        }
예제 #15
0
        public static void InsertStatistic(string appName, string plugin, string command, string version, string doc)
        {
            Task.Run(() =>
            {
                try
                {
                    using (var pg = new C_PluginStatisticTableAdapter())
                    {
                        pg.Insert(appName, plugin ?? string.Empty, command ?? string.Empty, version ?? string.Empty,
                                  doc ?? string.Empty, Environment.UserName, DateTime.Now, null, Path.GetFileName(doc));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex, "PluginStatisticsHelper Insert.");
                }

                if (!appName.EndsWith(" Run") && !appName.EndsWith(" Update"))
                {
                    YandexMetrica.ReportEvent($"{plugin} {command}");
                }
            });
        }
예제 #16
0
 public static void ReportEvent(string text)
 {
     YandexMetrica.ReportEvent(text);
 }
예제 #17
0
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     YandexMetrica.ReportEvent("MainPage Loaded");
 }
예제 #18
0
 private void Button1Click(object sender, EventArgs e)
 {
     YandexMetrica.ReportEvent("Button click");
 }
예제 #19
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            YandexMetrica.ReportEvent("Form1 Loaded");
        }
예제 #20
0
        public static async Task <bool> StartGame()
        {
            EnableDebug();

            StartInfo.FileName         = $"{Settings.PathToSkyrim}\\skse64_loader.exe";
            StartInfo.WorkingDirectory = $"{Settings.PathToSkyrim}\\";
            StartInfo.Verb             = "runas";

            StartInfo.Domain = AppDomain.CurrentDomain.FriendlyName;

            GameProcess.StartInfo = StartInfo;

            Runing = true;
            GameProcess.Start();
            YandexMetrica.ReportEvent("StartedGame");

            int ParentPID = GameProcess.Id;

            await Task.Run(() => GameProcess.WaitForExit());

            foreach (var p in ProcessExtensions.FindChildrenProcesses(ParentPID))
            {
                GameProcess = p;
            }
            Microsoft.Win32.SafeHandles.SafeProcessHandle sh = GameProcess.SafeHandle;
            if (!GameProcess.HasExited)
            {
                await Task.Run(() => GameProcess.WaitForExit());
            }

            YandexMetrica.ReportEvent("ExitedGame");

            await Task.Delay(500);

            Process[] SkyrimPlatformCEFs = Process.GetProcessesByName("SkyrimPlatformCEF");
            for (int i = 0; i < SkyrimPlatformCEFs.Length; i++)
            {
                try
                {
                    int tr = 0;
                    do
                    {
                        SkyrimPlatformCEFs[i].Kill();
                        await Task.Delay(200);
                    }while (!SkyrimPlatformCEFs[i].HasExited && tr++ < 5);
                }
                catch (Win32Exception)
                {
                    if (Settings.ExperimentalFunctions == true)
                    {
                        try
                        {
                            if (!SkyrimPlatformCEFs[i].HasExited)
                            {
                                ProcessKiller.KillProcess((IntPtr)SkyrimPlatformCEFs[i].Id);
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.Error("StartGame_Killer_SkyrimPlatformCEF", e);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("StartGame_KillSkyrimPlatformCEF", e);
                }
            }

            Runing = false;

            return(GameProcess.ExitCode != 0);
        }
예제 #21
0
        public Form1()
        {
            InitializeComponent();

            YandexMetrica.ReportEvent("Form1 Loaded");
        }
 private static void Watcher_Created(object sender, FileSystemEventArgs e)
 {
     YandexMetrica.ReportEvent($"WatcherCreated_{e?.Name}");
 }
 private static void Watcher_Changed(object sender, FileSystemEventArgs e)
 {
     YandexMetrica.ReportEvent($"WatcherChanged_{e?.Name}");
     AntiCheatAlert(e?.FullPath);
 }
 private static void Watcher_Renamed(object sender, RenamedEventArgs e)
 {
     YandexMetrica.ReportEvent($"WatcherRenamed_{e?.Name}");
 }
예제 #25
0
 private void OnClick(object sender, RoutedEventArgs e)
 {
     YandexMetrica.ReportEvent("Button click");
 }
예제 #26
0
        private async Task Play()
        {
            if (!File.Exists($"{Settings.PathToSkyrim}\\skse64_loader.exe"))
            {
                await CheckGame();

                return;
            }

            if (serverList.SelectedItem == null)
            {
                NotifyController.Show(PopupNotify.Error, Res.Warning, Res.SelectServer);
                return;
            }

            try
            {
                if (Directory.Exists(Path.GetDirectoryName(Settings.PathToSkympClientSettings)) && File.Exists(Settings.PathToSkympClientSettings))
                {
                    File.SetAttributes(Settings.PathToSkympClientSettings, FileAttributes.Normal);
                }

                SetServer();
                ServerModel server   = (ServerModel)serverList.SelectedItem;
                object      gameData = await Account.GetSession(server.Address);

                if (gameData == null)
                {
                    return;
                }
                SetSession(gameData);
            }
            catch (JsonSerializationException)
            {
                NotifyController.Show(PopupNotify.Error, Res.Error, Res.ErrorReadSkyMPSettings);
                return;
            }
            catch (JsonReaderException)
            {
                NotifyController.Show(PopupNotify.Error, Res.Error, Res.ErrorReadSkyMPSettings);
                return;
            }
            catch (UnauthorizedAccessException)
            {
                FileAttributes attr = new FileInfo(Settings.PathToSkympClientSettings).Attributes;
                Logger.Error("Play_UAException", new UnauthorizedAccessException($"UnAuthorizedAccessException: Unable to access file. Attributes: {attr}"));
                NotifyController.Show(PopupNotify.Error, Res.Error, "UnAuthorizedAccessException: Unable to access file");
                return;
            }
            catch (Exception e)
            {
                Logger.Error("Play", e);
                NotifyController.Show(PopupNotify.Error, Res.Error, e.Message);
                return;
            }

            SetMods();

            try
            {
                Hide();
                bool crash = await GameLauncher.StartGame();

                Show();

                if (crash)
                {
                    YandexMetrica.ReportEvent("CrashDetected");
                    await Task.Delay(500);
                    await ReportDmp();
                }
            }
            catch
            {
                YandexMetrica.ReportEvent("HasNotAccess");
                Close();
            }
        }