Exemplo n.º 1
0
 public void LogifyCrashReport()
 {
     try
     {
         var         isEnabledReport = AppVariable.ReadBoolSetting(AppVariable.AutoSendReport);
         LogifyAlert client          = LogifyAlert.Instance;
         client.ApiKey                  = AppVariable.LogifyAPIKey;
         client.AppName                 = AppVariable.getAppName;
         client.AppVersion              = AppVariable.getAppVersion;
         client.OfflineReportsEnabled   = true;
         client.OfflineReportsCount     = 20;
         client.OfflineReportsDirectory = AppVariable.LogifyOfflinePath;
         client.SendOfflineReports();
         client.StartExceptionsHandling();
         if (isEnabledReport.Equals("True"))
         {
             client.StartExceptionsHandling();
         }
         else
         {
             client.StopExceptionsHandling();
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 2
0
        private void ShowCredentialDialog()
        {
            try
            {
                var isLogin = AppVariable.ReadBoolSetting(AppVariable.CredentialLogin);
                if (isLogin)
                {
                    using (CredentialDialog dialog = new CredentialDialog())
                    {
                        dialog.WindowTitle     = "ورود به نرم افزار";
                        dialog.MainInstruction = "لطفا نام کاربری و رمز عبور خود را وارد کنید";
                        //dialog.Content = "";
                        dialog.ShowSaveCheckBox          = true;
                        dialog.ShowUIForSavedCredentials = true;
                        // The target is the key under which the credentials will be stored.
                        dialog.Target = "Mahdi72_MoalemYar_www.127.0.0.1.com";

                        try
                        {
                            while (isLogin)
                            {
                                if (dialog.ShowDialog(this))
                                {
                                    using (var db = new DataClass.myDbContext())
                                    {
                                        var usr = db.Users.Where(x => x.Username == dialog.Credentials.UserName && x.Password == dialog.Credentials.Password);
                                        if (usr.Any())
                                        {
                                            dialog.ConfirmCredentials(true);
                                            isLogin = false;
                                        }
                                        else
                                        {
                                            dialog.Content = "مشخصات اشتباه است دوباره امتحان کنید";
                                        }
                                    }
                                }
                                else
                                {
                                    Environment.Exit(0);
                                }
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            main        = this;

            //Todo: Add Defualt School and Set Default Combo School
            //Todo: Remove RunAction
            appTitle = AppVariable.getAppTitle + AppVariable.getAppVersion + AppVariable.RunActionMeasurePerformance(() => getexHint()); // App Title with Version

            ShowCredentialDialog();

            LoadSettings();

            LogifyCrashReport();
        }
Exemplo n.º 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            #region This is for Change Database Location we change DataDirectory to Other Location

            string fileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            AppDomain.CurrentDomain.SetData("DataDirectory", System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\" + Assembly.GetExecutingAssembly().GetName().Name + @"\");

            #endregion This is for Change Database Location we change DataDirectory to Other Location

            #region Load Embedded Assembly

            AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
            var assembly = Assembly.GetExecutingAssembly();
            foreach (var name in assembly.GetManifestResourceNames())
            {
                if (name.ToLower()
                    .EndsWith(".resources") ||
                    !name.ToLower()
                    .EndsWith(".dll"))
                {
                    continue;
                }
                EmbeddedAssembly.Load(name,
                                      name);
            }

            #endregion Load Embedded Assembly

            #region Check AppData Folder Existen and Create Config.json

            string folder         = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string specificFolder = Path.Combine(folder, Assembly.GetExecutingAssembly().GetName().Name);
            if (!Directory.Exists(specificFolder))
            {
                Directory.CreateDirectory(specificFolder);
            }

            if (!System.IO.File.Exists(folder + @"\MoalemYar\config.json"))
            {
                AppVariable.InitializeSettings();
            }

            #endregion Check AppData Folder Existen and Create Config.json
        }
Exemplo n.º 5
0
        private void LoadSettings()
        {
            try
            {
                var color = (Color)ColorConverter.ConvertFromString(AppVariable.ReadSetting(AppVariable.SkinCode));
                var brush = new SolidColorBrush(color);
                BorderBrush = brush;

                var hb_Menu = AppVariable.ReadBoolSetting(AppVariable.HamburgerMenu);
                MainWindow.main.tab.IconMode = !hb_Menu;

                var vCode = AppVariable.ReadSetting(AppVariable.VersionCode);
                if (!vCode.Equals(AppVariable.getAppVersion))
                {
                    AppVariable.InitializeSettings();
                }
                //Todo: Import Database to new Version
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 6
0
 public void MenuItemShortCutCommandRestore(Object sender, ExecutedRoutedEventArgs e)
 {
     AppVariable.dbRestore();
 }
Exemplo n.º 7
0
 public void MenuItemShortCutCommandBackup(Object sender, ExecutedRoutedEventArgs e)
 {
     AppVariable.takeBackup();
 }