Esempio n. 1
0
        /// <summary>
        /// Init code to be called on the application startup.
        /// Return false if no merge utility was found and user wanted to quit the app.
        /// </summary>
        public bool Initialize()
        {
            // Verify the application default merge utility
            AppHelper app = new AppHelper(Properties.Settings.Default.MergeAppHelper);
            if (File.Exists(app.Path))
            {
                Configure(app);
                return true;
            }

            // Search for any of the predefined tools
            merge = GetDetected();

            // If none of the pre-set merge apps are present, show the missing merge dialog
            // and return with its selection of whether to continue or quit the app
            if (merge.Count == 0)
            {
                FormMergeMissing formMergeMissing = new FormMergeMissing();
                return formMergeMissing.ShowDialog() == DialogResult.OK;
            }

            // Otherwise, at least one merge app is present, select it as default
            Properties.Settings.Default.MergeAppHelper = merge[0].ToString();

            Configure(merge[0]);
            return true;
        }
 public MainPage()
 {
     this.InitializeComponent();
     DISPATCHER.Initialize();
     helper = new AppHelper();
     ShowLoadingBar();
     this.NavigationCacheMode = NavigationCacheMode.Required;
 }
Esempio n. 3
0
        /// <summary>
        /// Return a proper diff command.
        /// This function is called from the actual menu item to diff files.
        /// </summary>
        public static string GetDiffCmd()
        {
            // Get the application default visual diff utility
            AppHelper app = new AppHelper(Properties.Settings.Default.DiffAppHelper);
            string cmd = string.Format(" --tool={0} --no-prompt ", app.Name);

            return cmd;
        }
Esempio n. 4
0
        /// <summary>
        /// Apply changed settings
        /// </summary>
        public void ApplyChanges()
        {
            if (comboBoxPath.Tag != null || textArgs.Tag !=null)
            {
                string name = Path.GetFileNameWithoutExtension(comboBoxPath.Text.Trim());
                AppHelper app = new AppHelper(name, comboBoxPath.Text, textArgs.Text.Trim());
                Properties.Settings.Default.DiffAppHelper = app.ToString();

                ClassDiff.Configure(app);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Initialize pertinent settings
        /// </summary>
        /// <param name="options">All git global settings</param>
        public void Init(string[] options)
        {
            // Detect all diff utilities on the system and populate a listbox
            helpers = ClassDiff.GetDetected();
            comboBoxPath.Items.Clear();
            foreach (var appHelper in helpers)
                comboBoxPath.Items.Add(appHelper.Path);

            // Get our program default diff tool and set the listbox text
            AppHelper app = new AppHelper(Properties.Settings.Default.DiffAppHelper);
            comboBoxPath.Text = app.Path;
            textArgs.Text = app.Args;

            // Add the dirty (modified) value changed helper
            comboBoxPath.TextChanged += ControlDirtyHelper.ControlDirty;
            textArgs.TextChanged += ControlDirtyHelper.ControlDirty;
        }
Esempio n. 6
0
        /// <summary>
        /// Configure a given application helper to be a Git diff utility
        /// </summary>
        public static void Configure(AppHelper app)
        {
            // Configure application only if it is valid
            if (app.Name!=string.Empty)
            {
                string path = app.Path.Replace('\\', '/');
                string usr = app.Args.
                    Replace("%1", "$LOCAL").
                    Replace("%2", "$REMOTE");
                string arg = "'" + path + "' " + usr;
                ClassConfig.SetGlobal("difftool." + app.Name + ".path", path);
                ClassConfig.SetGlobal("difftool." + app.Name + ".cmd", arg);

                // TODO: This might be an option: Set our default tool to be the Git gui tool?
                // ClassConfig.SetGlobal("diff.guitool", app.Name);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Configure a given application helper to be a Git merge utility
        /// </summary>
        public static void Configure(AppHelper app)
        {
            // Configure application only if it is valid
            if (app.Name != string.Empty)
            {
                string path = app.Path.Replace('\\', '/');
                string usr = app.Args.
                    Replace("%1", "$BASE").
                    Replace("%2", "$LOCAL").
                    Replace("%3", "$REMOTE").
                    Replace("%4", "$MERGED");
                string arg = "'" + path + "' " + usr;
                ClassConfig.SetGlobal("mergetool." + app.Name + ".path", path);
                ClassConfig.SetGlobal("mergetool." + app.Name + ".cmd", arg);
                ClassConfig.SetGlobal("mergetool." + app.Name + ".trustExitCode", "false");

                // Set the default merge tool
                ClassConfig.SetGlobal("merge.tool", app.Name);
                ClassConfig.SetGlobal("mergetool.keepBackup", "false");
            }
        }
Esempio n. 8
0
 public AltaRefacciones()
 {
     InitializeComponent();
     AppHelper.AddTextBoxOnlyNumbersValidation(ref this.anioTextBox);
 }
Esempio n. 9
0
        public void save(FaktorBorongan dbitem, int id, FaktorBoronganHistory fbh)
        {
            string hstq = "INSERT INTO dbo.\"FaktorBoronganHistory\" (\"IdFaktorBorongan\", \"IdMasterPool\", \"IdJenisTruck\", \"RasioDlmKota\", \"RasioDlmKota2\", \"RasioJawaBali\", \"RasioSumatra\", \"RasioKosong\", " +
                          "\"RasioSolar\", \"UangMakanJawaBali\", \"UangMakanSumatra\", \"FaktorPengaliGaji\", \"FaktorPengaliTips\", \"PotonganDriver1\", \"PotonganDriver2\", \"BiayaKapalBali\", \"BiayaKapalBaliNTB\", " +
                          "\"BiayaKapalSumatra\", \"BiayaKapalKalimantan\", \"BiayaKapalSulawesi\", \"Tanggal\", username) VALUES (" + fbh.IdFaktorBorongan + ", " + fbh.IdMasterPool + ", " + fbh.IdJenisTruck + ", " + fbh.RasioDlmKota +
                          ", " + fbh.RasioDlmKota2 + ", " + fbh.RasioJawaBali + ", " + fbh.RasioSumatra + ", " + fbh.RasioKosong + ", " + fbh.RasioSolar + ", " + fbh.UangMakanJawaBali + ", " + fbh.UangMakanSumatra + ", " +
                          fbh.FaktorPengaliGaji + ", " + fbh.FaktorPengaliTips + ", " + fbh.PotonganDriver1 + ", " + fbh.PotonganDriver2 + ", " + fbh.BiayaKapalBali + ", " + fbh.BiayaKapalBaliNTB + ", " + fbh.BiayaKapalSumatra + ", " +
                          fbh.BiayaKapalKalimantan + ", " + fbh.BiayaKapalSulawesi + ", " + fbh.Tanggal + ", " + fbh.username + ");";

            if (dbitem.Id == 0) //create
            {
                context.FaktorBorongan.Add(dbitem);
                var query = "INSERT INTO dbo.\"FaktorBorongan\" (\"IdMasterPool\", \"IdJenisTruck\", \"RasioDlmKota\", \"RasioDlmKota2\", \"RasioJawaBali\", \"RasioSumatra\", \"RasioKosong\", \"UangMakanJawaBali\", " +
                            "\"UangMakanSumatra\", \"FaktorPengaliGaji\", \"FaktorPengaliTips\", \"PotonganDriver1\", \"PotonganDriver2\", \"BiayaKapalBali\", \"BiayaKapalBaliNTB\", \"BiayaKapalSumatra\", " +
                            "\"BiayaKapalKalimantan\", \"BiayaKapalSulawesi\") VALUES (" + dbitem.IdMasterPool + ", " + dbitem.IdJenisTruck + ", " + dbitem.RasioDlmKota + ", " + dbitem.RasioDlmKota2 + ", " + dbitem.RasioJawaBali +
                            ", " + dbitem.RasioSumatra + ", " + dbitem.RasioKosong + ", " + dbitem.UangMakanJawaBali + ", " + dbitem.UangMakanSumatra + ", " + dbitem.FaktorPengaliGaji + ", " + dbitem.FaktorPengaliTips + ", " +
                            dbitem.PotonganDriver1 + ", " + dbitem.PotonganDriver2 + ", " + dbitem.BiayaKapalBali + ", " + dbitem.BiayaKapalBaliNTB + ", " + dbitem.BiayaKapalSumatra + ", " + dbitem.BiayaKapalKalimantan + ", " +
                            dbitem.BiayaKapalSulawesi + ");";
                var auditrail = new Auditrail {
                    Actionnya = "Add", EventDate = DateTime.Now, Modulenya = "Faktor Borongan", QueryDetail = query + hstq, RemoteAddress = AppHelper.GetIPAddress(), IdUser = id
                };
                context.Auditrail.Add(auditrail);
            }
            else //edit
            {
                context.FaktorBorongan.Attach(dbitem);
                var query = "UPDATE dbo.\"FaktorBorongan\" SET \"IdMasterPool\" = " + dbitem.IdMasterPool + ", \"IdJenisTruck\" = " + dbitem.IdJenisTruck + ", \"RasioDlmKota\" = " + dbitem.RasioDlmKota +
                            ", \"RasioDlmKota2\" = " + dbitem.RasioDlmKota2 + ", \"RasioJawaBali\" = " + dbitem.RasioJawaBali + ", \"RasioSumatra\" = " + dbitem.RasioSumatra + ", \"RasioKosong\" = " + dbitem.RasioKosong +
                            ", \"UangMakanJawaBali\" = " + dbitem.UangMakanJawaBali + ", \"UangMakanSumatra\" = " + dbitem.UangMakanSumatra + ", \"FaktorPengaliGaji\" = " + dbitem.FaktorPengaliGaji + ", \"FaktorPengaliTips\" = " +
                            dbitem.FaktorPengaliTips + ", \"PotonganDriver1\" = " + dbitem.PotonganDriver1 + ", \"PotonganDriver2\" = " + dbitem.PotonganDriver2 + ", \"BiayaKapalBali\" = " + dbitem.BiayaKapalBali +
                            ", \"BiayaKapalBaliNTB\" = " + dbitem.BiayaKapalBaliNTB + ", \"BiayaKapalSumatra\" = " + dbitem.BiayaKapalSumatra + ", \"BiayaKapalKalimantan\" = " + dbitem.BiayaKapalKalimantan +
                            ", \"BiayaKapalSulawesi\" = " + dbitem.BiayaKapalSulawesi + " WHERE \"Id\" = " + dbitem.Id + ";";
                var auditrail = new Auditrail {
                    Actionnya = "Edit", EventDate = DateTime.Now, Modulenya = "Faktor Borongan", QueryDetail = query + hstq, RemoteAddress = AppHelper.GetIPAddress(), IdUser = id
                };
                context.Auditrail.Add(auditrail);
                var entry = context.Entry(dbitem);
                entry.State = EntityState.Modified;
            }
            context.SaveChanges();
        }
Esempio n. 10
0
        /// <summary>
        /// Maneja el evento KeyUp en la caja de texto NumeroEconomico
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NumeroEconomicoTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                //  Al hacer enter en "NumeroEconomico" o "Unidad"
                // Validar dato de unidad
                if (NumeroEconomicoTextBox.Text != ""
                        && e.KeyData == Keys.Enter)
                {
                    //  Consultar la información y desplegarla mediante el binding ya configurado                    
                    int numeroeconomico = DB.GetNullableInt32(NumeroEconomicoTextBox.Text).Value;

                    //  Obtenemos la estación
                    int estacion;
                    if (this.estacion_IDComboBox.SelectedItem != null)
                    {
                        estacion = Convert.ToInt32(this.estacion_IDComboBox.SelectedValue);
                    }
                    else
                    {
                        throw new Exception("Debe seleccionar una estación");
                    }

                    //  Buscamos la unidad
                    Entities.Unidades unidad =
                        Entities.Unidades.Read(
                            DB.Param("NumeroEconomico", numeroeconomico),
                                DB.Param("EstatusUnidad_ID",2),
                                    DB.Param("Estacion_ID", estacion));

                    //  Verificamos que exista
                    if (unidad == null) throw new Exception("Unidad no existe o no tiene contrato activo");

                    //  Consultamos el contrato
                    Entities.Contratos contrato = 
                        Entities.Contratos.Read(DB.Param("Unidad_ID", unidad.Unidad_ID), DB.Param("EstatusContrato_ID", 1));

                    //  Verificamos que exista el contrato
                    if (contrato == null) throw new Exception("El contrato de la unidad no está activo");

                    //  Obtenemos el conductor
                    Entities.Conductores conductor =
                        Entities.Conductores.Read(contrato.Conductor_ID);

                    //  Verifcamos que la configuración del contrato
                    //  concuerde
                    if (Sesion.Empresa_ID != null)
                    {
                        if (contrato.Empresa_ID != Sesion.Empresa_ID.Value)
                        {
                            throw new Exception("No tiene permisos para consultar la unidad");
                        }
                        else
                        {
                            if (Sesion.Estacion_ID != null)
                            {
                                if (contrato.Estacion_ID != Sesion.Estacion_ID.Value)
                                {
                                    throw new Exception("No tiene permisos para consultar la unidad");
                                }
                            }
                        }
                    }

                    //  Configuramos el conductor y la unidad
                    Conductor_ID = conductor.Conductor_ID;
                    Unidad_ID = unidad.Unidad_ID;

                    //  Actualizamos el nombre
                    this.ConductorTextBox.Text = conductor.Apellidos + " " + conductor.Nombre;

                    //  Consultar los saldos
                    get_SaldosConductorTableAdapter.Fill(sICASCentralQuerysDataSet.Get_SaldosConductor, Conductor_ID);

                    //  Colorear los saldos
                    ColorGrid();
                } 
            }
            catch (Exception ex)
            {
                AppHelper.Error(ex.Message);
            }
        }        
Esempio n. 11
0
        void ScanGames(object state)
        {
            string[] paths = null;
            Invoke((MethodInvoker) delegate()
            {
                ScanProgressLabel.Visible = true;
                ScanGamesButton.Enabled   = false;
                paths = MainForm.Current.OptionsPanel.GameScanLocationsListBox.Items.Cast <string>().ToArray();
                ScanProgressLabel.Text = "Scanning...";
            });
            var skipped = 0;
            var added   = 0;
            var updated = 0;

            for (int i = 0; i < paths.Length; i++)
            {
                var path = (string)paths[i];
                // Don't allow to scan windows folder.
                var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                if (path.StartsWith(winFolder))
                {
                    continue;
                }
                var di = new System.IO.DirectoryInfo(path);
                // Skip folders if don't exists.
                if (!di.Exists)
                {
                    continue;
                }
                var exes = new List <FileInfo>();
                AppHelper.GetFiles(di, ref exes, "*.exe", true);
                for (int f = 0; f < exes.Count; f++)
                {
                    var exe     = exes[f];
                    var exeName = exe.Name.ToLower();
                    var program = SettingManager.Programs.Items.FirstOrDefault(x => x.FileName.ToLower() == exeName);
                    // If file doesn't exist in the game list then continue.
                    if (program == null)
                    {
                        skipped++;
                    }
                    else
                    {
                        // Get game by executable name.
                        var game = SettingManager.Games.Items.FirstOrDefault(x => x.FileName.ToLower() == exeName);
                        // If file doesn't exist in the game list then continue.
                        if (game == null)
                        {
                            Invoke((MethodInvoker) delegate()
                            {
                                game = x360ce.Engine.Data.UserGame.FromDisk(exe.FullName);
                                game.LoadDefault(program);
                                SettingManager.Games.Items.Add(game);
                                added++;
                            });
                        }
                        else
                        {
                            game.FullPath = exe.FullName;
                            if (string.IsNullOrEmpty(game.FileProductName) && !string.IsNullOrEmpty(program.FileProductName))
                            {
                                game.FileProductName = program.FileProductName;
                            }
                            updated++;
                        }
                    }
                    Invoke((MethodInvoker) delegate()
                    {
                        ScanProgressLabel.Text = string.Format("Scanning Path ({0}/{1}): {2}\r\nSkipped = {3}, Added = {4}, Updated = {5}", i + 1, paths.Length, path, skipped, added, updated);
                    });
                }
                SettingManager.Save();
            }
            Invoke((MethodInvoker) delegate()
            {
                ScanGamesButton.Enabled   = true;
                ScanProgressLabel.Visible = false;
                ShowHideAndSelectGridRows();
            });
        }
        private void getSavedOptions()
        {
            appSettings = AppHelper.LoadOptions();

            // Reading Saved Options:
            switch (appSettings.TimeIntervalMode)
            {
            default:
            case 1:
                timer1.Interval = appSettings.TimeInterval * 1000;
                break;

            case 2:
                timer1.Interval = appSettings.TimeInterval * 1000 * 60;
                break;

            case 3:
                timer1.Interval = appSettings.TimeInterval * 1000 * 3600;
                break;
            }

            if (appSettings.AutoStart)
            {
                timer1.Enabled         = true;
                timer2.Enabled         = true;
                scanButton.Visible     = false;
                stopScanButton.Visible = true;
            }
            else
            {
                timer1.Enabled         = false;
                timer2.Enabled         = false;
                scanButton.Visible     = true;
                stopScanButton.Visible = false;
            }

            switch (appSettings.IPService)
            {
            case 1:
                urlForIPCheck = "https://dynamix.run/ip.php";
                break;

            case 3:
                urlForIPCheck = "http://dinofly.com/misc/ipcheck.php";
                break;

            case 2:
                urlForIPCheck = "http://grabip.tk";
                break;

            default:
                urlForIPCheck = "https://dynamix.run/ip.php";
                break;
            }


            if (File.Exists(phpPathFile))
            {
                phpPath = File.ReadAllText(phpPathFile);
            }

            if (appSettings.RunDynamicServices)
            {
                XpertDNSSettings  = XpertDNSHelper.LoadOptions();
                dynamixSettings   = DynamixHelper.LoadOptions();
                afraidDNSSettings = AfraidDNSHelper.LoadOptions();
                noIPDNSSettings   = NoIPHelper.LoadOptions();
            }
        }
 /// <summary>
 /// Al hacer clic en "Buscar", consultamos el reporte en la base de datos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BuscarButton_Click(object sender, EventArgs e)
 {
     AppHelper.DoMethod(DoQuery, this);
 }
        /// <summary>
        /// Enable or disable virtual controllers depending on game settings.
        /// </summary>
        /// <param name="game"></param>
        void UpdateVirtualDevices(UserGame game)
        {
            // Allow if not testing or testing with option enabled.
            var o     = SettingsManager.Options;
            var allow = !o.TestEnabled || o.TestSetXInputStates;

            if (!allow)
            {
                return;
            }
            // If virtual driver is missing then return.
            if (!ViGEmClient.isVBusExists(true))
            {
                return;
            }
            var isVirtual = ((EmulationType)game.EmulationType).HasFlag(EmulationType.Virtual);

            // If game does not use virtual emulation then...
            if (!isVirtual)
            {
                ViGEmClient.DisposeCurrent();
                return;
            }
            var client = ViGEmClient.Current;

            if (client.Targets == null)
            {
                client.Targets = new Xbox360Controller[4];
                for (int i = 0; i < 4; i++)
                {
                    var controller = new Xbox360Controller(client);
                    client.Targets[i]            = controller;
                    controller.FeedbackReceived += Controller_FeedbackReceived;
                }
            }
            for (uint i = 1; i <= 4; i++)
            {
                var mapTo          = (MapTo)i;
                var flag           = AppHelper.GetMapFlag(mapTo);
                var value          = (MapToMask)game.EnableMask;
                var virtualEnabled = value.HasFlag(flag);
                var feedingState   = FeedingState[i - 1];
                if (virtualEnabled)
                {
                    // If feeding status unknown or not enabled then...
                    if (!feedingState.HasValue || !feedingState.Value || !client.IsControllerConnected(i))
                    {
                        var success = EnableFeeding(i) == VirtualError.None;
                        if (!success)
                        {
                            return;
                        }
                        FeedingState[i - 1] = true;
                    }
                    FeedDevice(i);
                }
                else
                {
                    // If feeding status unknown or enabled then...
                    if (!feedingState.HasValue || feedingState.Value || client.IsControllerConnected(i))
                    {
                        var success = DisableFeeding(i) == VirtualError.None;
                        if (!success)
                        {
                            return;
                        }
                        FeedingState[i - 1] = false;
                    }
                }
            }
        }
Esempio n. 15
0
		/// <summary>
		/// Maneja el evento "Click" del botón "Buscar"
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void BuscarButton_Click(object sender, EventArgs e)
		{
			AppHelper.DoMethod(new AppHelper.HelperDelegate(DoQuery), this);
		}
Esempio n. 16
0
        public SmartCrawler()
        {
            Http                 = new HttpItem();
            CrawlItems           = new ObservableCollection <CrawlItem>();
            helper               = new HttpHelper();
            URL                  = "";
            HtmlDoc              = new HtmlDocument();
            SelectText           = "";
            IsMultiData          = ScriptWorkMode.List;
            IsAttribute          = true;
            URL                  = "www.cnblogs.com";
            ShareCookie          = new TextEditSelector();
            ShareCookie.GetItems = AppHelper.GetAllCrawlerNames(null);
            Commands2            = CommandBuilder.GetCommands(
                this,
                new[]
            {
                new Command(GlobalHelper.Get("key_302"), obj => AddNewItem(),
                            obj =>
                            string.IsNullOrEmpty(SelectName) == false && string.IsNullOrEmpty(SelectXPath) == false,
                            "add"),
                new Command(GlobalHelper.Get("search"), obj => GetXPathAsync(),
                            obj =>
                            currentXPaths != null, "magnify"),
                new Command(GlobalHelper.Get("feellucky"),
                            obj => FeelLucky(),
                            obj => IsMultiData != ScriptWorkMode.NoTransform && isBusy == false, "smiley_happy"
                            ),
                new Command(GlobalHelper.Get("key_624"), obj =>
                {
                    if (!(CrawlItems.Count > 0).SafeCheck(GlobalHelper.Get("key_625")))
                    {
                        return;
                    }

                    if (IsMultiData == ScriptWorkMode.List && CrawlItems.Count < 2)
                    {
                        MessageBox.Show(GlobalHelper.Get("key_626"), GlobalHelper.Get("key_99"));
                        return;
                    }
                    if (string.IsNullOrEmpty(this.URLHTML))
                    {
                        this.VisitUrlAsync();
                    }

                    var datas =
                        HtmlDoc.DocumentNode.GetDataFromXPath(CrawlItems, IsMultiData, RootXPath, RootFormat).Take(20)
                        .ToList();
                    var view = PluginProvider.GetObjectInstance <IDataViewer>(GlobalHelper.Get("key_230"));

                    var r = view.SetCurrentView(datas);
                    ControlExtended.DockableManager.AddDockAbleContent(
                        FrmState.Custom, r, GlobalHelper.Get("key_627"));

                    var rootPath =
                        XPath.GetMaxCompareXPath(CrawlItems.Select(d => d.XPath));
                    if (datas.Count > 1 && string.IsNullOrEmpty(RootXPath) && rootPath.Length > 0 &&
                        IsMultiData == ScriptWorkMode.List &&
                        MessageBox.Show(string.Format(GlobalHelper.Get("key_628"), rootPath), GlobalHelper.Get("key_99"),
                                        MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        RootXPath  = rootPath;
                        RootFormat = SelectorFormat.XPath;
                        HtmlDoc.CompileCrawItems(CrawlItems);
                        OnPropertyChanged("RootXPath");
                    }
                }, icon: "page_search")
            });
        }
        // Check game settings against folder.
        public GameRefreshStatus GetGameStatus(x360ce.Engine.Data.UserGame game, bool fix = false)
        {
            var fi = new FileInfo(game.FullPath);

            // Check if game file exists.
            if (!fi.Exists)
            {
                return(GameRefreshStatus.ExeNotExist);
            }
            // Check if game is not enabled.
            else if (!game.IsEnabled)
            {
                return(GameRefreshStatus.OK);
            }
            else
            {
                var gameVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(fi.FullName);
                var xiValues    = ((XInputMask[])Enum.GetValues(typeof(XInputMask))).Where(x => x != XInputMask.None).ToArray();
                // Create dictionary from XInput type and XInput file name.
                var dic = new Dictionary <XInputMask, string>();
                foreach (var value in xiValues)
                {
                    dic.Add(value, Attributes.GetDescription(value));
                }
                var xiFileNames = dic.Values.Distinct();
                // Loop through all files.
                foreach (var xiFileName in xiFileNames)
                {
                    var x64Value       = dic.First(x => x.Value == xiFileName && x.ToString().Contains("x64")).Key;
                    var x86Value       = dic.First(x => x.Value == xiFileName && x.ToString().Contains("x86")).Key;
                    var xiFullPath     = System.IO.Path.Combine(fi.Directory.FullName, xiFileName);
                    var xiFileInfo     = new System.IO.FileInfo(xiFullPath);
                    var xiArchitecture = ProcessorArchitecture.None;
                    var x64Enabled     = ((uint)game.XInputMask & (uint)x64Value) != 0;;
                    var x86Enabled     = ((uint)game.XInputMask & (uint)x86Value) != 0;;
                    if (x86Enabled && x64Enabled)
                    {
                        xiArchitecture = ProcessorArchitecture.MSIL;
                    }
                    else if (x86Enabled)
                    {
                        xiArchitecture = ProcessorArchitecture.X86;
                    }
                    else if (x64Enabled)
                    {
                        xiArchitecture = ProcessorArchitecture.Amd64;
                    }
                    // If x360ce emulator for this game is disabled or both CheckBoxes are disabled or then...
                    if (xiArchitecture == ProcessorArchitecture.None)                     // !game.IsEnabled ||
                    {
                        // If XInput file exists then...
                        if (xiFileInfo.Exists)
                        {
                            if (fix)
                            {
                                // Delete unnecessary XInput file.
                                xiFileInfo.Delete();
                                continue;
                            }
                            else
                            {
                                return(GameRefreshStatus.UnnecessaryLibraryFile);
                            }
                        }
                    }
                    else
                    {
                        // If XInput file doesn't exists then...
                        if (!xiFileInfo.Exists)
                        {
                            // Create XInput file.
                            if (fix)
                            {
                                AppHelper.WriteFile(EngineHelper.GetXInputResoureceName(xiArchitecture), xiFileInfo.FullName);
                                continue;
                            }
                            else
                            {
                                return(GameRefreshStatus.XInputFilesNotExist);
                            }
                        }
                        // Get current architecture.
                        var xiCurrentArchitecture = PEReader.GetProcessorArchitecture(xiFullPath);
                        // If processor architectures doesn't match then...
                        if (xiArchitecture != xiCurrentArchitecture)
                        {
                            // Create XInput file.
                            if (fix)
                            {
                                AppHelper.WriteFile(EngineHelper.GetXInputResoureceName(xiArchitecture), xiFileInfo.FullName);
                                continue;
                            }
                            else
                            {
                                return(GameRefreshStatus.XInputFilesWrongPlatform);
                            }
                        }
                        bool byMicrosoft;
                        var  dllVersion     = EngineHelper.GetDllVersion(xiFullPath, out byMicrosoft);
                        var  embededVersion = EngineHelper.GetEmbeddedDllVersion(xiCurrentArchitecture);
                        // If file on disk is older then...
                        if (dllVersion < embededVersion)
                        {
                            // Overwrite XInput file.
                            if (fix)
                            {
                                AppHelper.WriteFile(EngineHelper.GetXInputResoureceName(xiArchitecture), xiFileInfo.FullName);
                                continue;
                            }
                            return(GameRefreshStatus.XInputFilesOlderVersion);
                        }
                        else if (dllVersion > embededVersion)
                        {
                            // Allow new version.
                            // return GameRefreshStatus.XInputFileNewerVersion;
                        }
                    }
                }
            }
            return(GameRefreshStatus.OK);
        }
Esempio n. 18
0
        protected List <ArticleJson> ArticleListInfo(List <Article> list, string usernumber = "")
        {
            if (list == null)
            {
                return(new List <ArticleJson>());
            }
            if (list.Count == 0)
            {
                return(new List <ArticleJson>());
            }


            //文章编号集合
            var array        = list.Select(x => x.Number).ToArray();
            var articletypes = AppHelper.GetArticleType();
            var parts        = new SubSonic.Query.Select(provider).From <ArticlePart>().Where <ArticlePart>(x => x.Types == Enum_ArticlePart.Pic).And("ArticleNumber").In(array).OrderAsc("SortID").ExecuteTypedList <ArticlePart>();

            List <string> userids = new List <string>();

            list.ForEach(x =>
            {
                userids.Add(x.CreateUserNumber);
            });

            List <string> articleids = new List <string>();

            list.ForEach(x =>
            {
                articleids.Add(x.Number);
            });

            var users = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Cover", "Signature", "Number", "IsPay").From <User>().Where("Number").In(userids.ToArray()).ExecuteTypedList <User>();

            var comments = new SubSonic.Query.Select(provider, "ID", "ArticleNumber", "ParentCommentNumber").From <Comment>().Where("ArticleNumber").In(articleids.ToArray()).And("ParentCommentNumber").IsEqualTo("").ExecuteTypedList <Comment>();

            //判断是否关注、判断是否点赞、判断是否收藏
            var fans  = new List <Fan>();
            var zans  = new List <ArticleZan>();
            var keeps = new List <Keep>();

            if (!string.IsNullOrWhiteSpace(usernumber))
            {
                fans  = db.Find <Fan>(x => x.CreateUserNumber == usernumber).ToList();
                zans  = db.Find <ArticleZan>(x => x.CreateUserNumber == usernumber).ToList();
                keeps = db.Find <Keep>(x => x.CreateUserNumber == usernumber).ToList();
            }

            var tags = GetTag();

            List <ArticleJson> newlist = new List <ArticleJson>();

            list.ForEach(x =>
            {
                var user = users.FirstOrDefault(y => y.Number == x.CreateUserNumber);
                if (user != null)
                {
                    ArticleJson model   = new ArticleJson();
                    var articletype     = articletypes.FirstOrDefault(y => y.ID == x.TypeID);
                    model.UserID        = user.ID;
                    model.NickName      = user.NickName;
                    model.Avatar        = user.Avatar;
                    model.UserCover     = user.Cover;
                    model.Signature     = user.Signature;
                    model.IsPay         = user.IsPay;
                    model.ArticleID     = x.ID;
                    model.ArticleNumber = x.Number;
                    model.Title         = x.Title;
                    model.Views         = x.Views;
                    model.Goods         = x.Goods;

                    //标签
                    model.TagList = new List <Tag>();
                    if (!string.IsNullOrWhiteSpace(x.Tag))
                    {
                        var tag = x.Tag.Split(',').ToList();
                        tag.ForEach(y =>
                        {
                            var id   = Tools.SafeInt(y);
                            var item = tags.FirstOrDefault(z => z.ID == id);
                            if (item != null)
                            {
                                model.TagList.Add(item);
                            }
                        });
                    }
                    model.Comments     = comments.Count(y => y.ArticleNumber == x.Number);
                    model.IsFollow     = fans.Count(y => y.ToUserNumber == x.CreateUserNumber);
                    model.IsZan        = zans.Count(y => y.ArticleNumber == x.Number);
                    model.IsKeep       = keeps.Count(y => y.ArticleNumber == x.Number);
                    model.UserNumber   = x.CreateUserNumber;
                    model.Cover        = x.Cover;
                    model.CreateDate   = FormatTime(x.CreateDate);
                    model.TypeName     = articletype == null ? "" : articletype.Name;
                    model.ArticlePart  = parts.Where(y => y.ArticleNumber == x.Number).OrderBy(y => y.ID).Take(3).ToList();
                    model.ArticlePower = x.ArticlePower;
                    model.Recommend    = x.Recommend;
                    model.Province     = x.Province;
                    model.City         = x.City;
                    model.Submission   = x.Submission;
                    newlist.Add(model);
                }
            });

            return(newlist);
        }
Esempio n. 19
0
        public ActionResult Index()
        {
            // get me all objects inside a given folder
            Dictionary <string, double> images = null;

            var request = new ListObjectsRequest();

            request.BucketName = AWSBucket;
            request.WithPrefix(AWSFolder);

            using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey))
            {
                using (ListObjectsResponse response = client.ListObjects(request))
                {
                    images = response.S3Objects.Where(x => x.Key != AWSFolder).ToDictionary(obj => obj.Key, obj => AppHelper.ConvertBytesToMegabytes(obj.Size));
                }
            }

            return(View(images));
        }
Esempio n. 20
0
        public JsonResult GetConsignNowImages(string tmpID)
        {
            string path = ImageRepository.GetTempImagePath(tmpID);

            return(JSON(Directory.GetFiles(path, "thmb_*.*").Select(file => new FileInfo(file)).Select(fileInfo => new { ID = 0, Title = fileInfo.Name.Remove(0, 5), Description = AppHelper.TempImage(tmpID, fileInfo.Name) })));
        }
Esempio n. 21
0
 public ActionResult ConsignNow(ConsignNowForm form)
 {
     try
     {
         form.FileLinks   = Directory.GetFiles(ImageRepository.GetTempImagePath(form.ID), "sf_*.*").Select(file => new FileInfo(file)).Select(fileInfo => string.Format("{0}{1}", Consts.ResourceHostName, AppHelper.TempImage(form.ID, fileInfo.Name))).ToList();
         form.Attachments = Directory.GetFiles(ImageRepository.GetTempImagePath(form.ID), "thmb_*.*").ToList();
         var isValidCaptchaValue = CaptchaController.IsValidCaptchaValue(form.CaptchaValue);
         if (!isValidCaptchaValue)
         {
             throw new Exception("Invalid captcha!");
         }
         string        sendEmails = ConfigurationManager.AppSettings["ConsignorMessagesEmail"];
         List <string> emails     = new List <string>(sendEmails.Split(','));
         foreach (string email in emails.Where(t => !string.IsNullOrEmpty(t)).Distinct())
         {
             Mail.SendMessageFromConsignor(email, form);
         }
         InitCurrentEvent();
     }
     catch (Exception ex)
     {
         ViewData["Error"] = ex.Message;
         form.CaptchaValue = string.Empty;
         return(View(form));
     }
     return(View("ConsignNowSuccess"));
 }
        /*
         * Esta region contiene los eventos
         * de los controles de la forma
         */
        #region Eventos

        /// <summary>
        /// Al teclear el nombre de la zona,
        /// buscamos sus coincidencias y las
        /// desplegamos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NombreZonaTextBox_TextChanged(object sender, EventArgs e)
        {
            this.buscarZonasBindingSource.DataSource = Entities.BuscarZonas.Get(AppHelper.IsNull(this.NombreZonaTextBox.Text, "").ToString());
        }
Esempio n. 23
0
        public Bitmap CreatePDF()
        {
            Document     doc          = _pdfHelper.CreateDocumentA4(10, 10, 30, 10);
            MemoryStream memoryStream = new MemoryStream();
            PdfWriter    writer       = PdfWriter.GetInstance(doc, memoryStream);

            doc.Open();
            doc.NewPage();
            doc.Add(_pdfHelper.CreateTitleParagraph($"机动车牌证申请表", BoldFont));
            doc.Add(_pdfHelper.CreateTitleParagraph($" 排队票号:{_ticketNo}", NormalFont));

            PdfPCell  pdfPCell = null;
            PdfPTable table    = _pdfHelper.CreateTable(new float[] { 2, 3, 3, 3, 3, 3 }, doc);

            table.AddCell(_pdfHelper.CreateCell("申请人信息栏", NormalFont, Element.ALIGN_CENTER, 6));

            pdfPCell         = _pdfHelper.CreateCell("机动车所有人", NormalFont, Element.ALIGN_CENTER);
            pdfPCell.Rowspan = 3;
            table.AddCell(pdfPCell);

            table.AddCell(_pdfHelper.CreateCell("姓名/名称", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell(_carInfo?.Owner, NormalFont, Element.ALIGN_CENTER, 2));
            table.AddCell(_pdfHelper.CreateCell("邮政编码", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("100010", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("邮寄地址", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("", NormalFont, Element.ALIGN_CENTER, 4));
            table.AddCell(_pdfHelper.CreateCell("手机号码", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("", NormalFont, Element.ALIGN_CENTER, 2));
            table.AddCell(_pdfHelper.CreateCell("固定电话", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("", NormalFont, Element.ALIGN_CENTER));

            table.AddCell(_pdfHelper.CreateCell("代理人", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("姓名/名称", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("手机号码", NormalFont, Element.ALIGN_CENTER, 1));
            table.AddCell(_pdfHelper.CreateCell("", NormalFont, Element.ALIGN_CENTER, 2));
            table.AddCell(_pdfHelper.CreateCell("申请业务事项", NormalFont, Element.ALIGN_CENTER, 6));
            doc.Add(table);

            table = _pdfHelper.CreateTable(new float[] { 0.3F, 0.7F, 1, 1, 1, 1 }, doc);
            table.AddCell(_pdfHelper.CreateCell("号牌种类", NormalFont, Element.ALIGN_CENTER, 2));
            table.AddCell(_pdfHelper.CreateCell(AppHelper.GetNameByCode(_carInfo?.PlateType, "HPZL"), NormalFont, Element.ALIGN_CENTER, 2));
            table.AddCell(_pdfHelper.CreateCell("号牌号码", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell(_carInfo?.PlateNo, NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("申请事项", NormalFont, Element.ALIGN_CENTER, 2));
            table.AddCell(_pdfHelper.CreateCell("申请原因及声明", NormalFont, Element.ALIGN_CENTER, 4));

            PdfPTable table1;

            pdfPCell         = _pdfHelper.CreateCell("号牌", NormalFont, Element.ALIGN_CENTER);
            pdfPCell.Rowspan = 2;
            table.AddCell(pdfPCell);
            table.AddCell(_pdfHelper.CreateCell("□补领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("□丢失        □灭失         □前号牌          □后号牌 ", NormalFont, Element.ALIGN_LEFT, 4));

            table.AddCell(_pdfHelper.CreateCell("□换领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("□前号牌        □后号牌 ", NormalFont, Element.ALIGN_LEFT, 4));



            pdfPCell         = _pdfHelper.CreateCell("行驶证", NormalFont, Element.ALIGN_CENTER);
            pdfPCell.Rowspan = 2;
            table.AddCell(pdfPCell);

            table.AddCell(_pdfHelper.CreateCell("□补领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("□丢失        □灭失   ", NormalFont, Element.ALIGN_LEFT, 4));

            table.AddCell(_pdfHelper.CreateCell("□换领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell(" ", NormalFont, Element.ALIGN_CENTER, 4));

            pdfPCell         = _pdfHelper.CreateCell("登记证书", NormalFont, Element.ALIGN_CENTER);
            pdfPCell.Rowspan = 3;
            table.AddCell(pdfPCell);

            table.AddCell(_pdfHelper.CreateCell("□申领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("  ", NormalFont, Element.ALIGN_CENTER, 4));

            table.AddCell(_pdfHelper.CreateCell("□补领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("□丢失        □灭失        □未获得", NormalFont, Element.ALIGN_LEFT, 4));

            table.AddCell(_pdfHelper.CreateCell("□换领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("", NormalFont, Element.ALIGN_CENTER, 4));

            pdfPCell         = _pdfHelper.CreateCell("检验合格标志", NormalFont, Element.ALIGN_CENTER);
            pdfPCell.Rowspan = 3;
            table.AddCell(pdfPCell);

            table.AddCell(_pdfHelper.CreateCell("□申请", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("□在登记地车辆管理所申请        □在登记地以外车辆管理所申请 ", NormalFont, Element.ALIGN_LEFT, 4));

            table.AddCell(_pdfHelper.CreateCell("□补领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("□丢失        □灭失        ", NormalFont, Element.ALIGN_LEFT, 4));

            table.AddCell(_pdfHelper.CreateCell("□换领", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell(" ", NormalFont, Element.ALIGN_CENTER, 4));
            doc.Add(table);

            table = _pdfHelper.CreateTable(new float[] { 3, 3 }, doc);
            table.AddCell(_pdfHelper.CreateCell("  机动车所有人及代理人对申请材料的真实有效性负责", NormalFont, Element.ALIGN_LEFT));
            table.AddCell(_pdfHelper.CreateCell("机动车所有人(代理人签字):" + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "                     " + DateTime.Now.ToString("yyyy年MM月dd日").PadLeft("机动车所有人(代理人签字):".Length * 3, ' '), NormalFont, Element.ALIGN_LEFT));

            //table1 = _pdfHelper.CreateTable(new float[] { 1 }, doc);
            //table1.AddCell(_pdfHelper.CreateNoWidthCell("机动车所有人(代理人签字):", NormalFont, Element.ALIGN_LEFT));
            //table1.AddCell(_pdfHelper.CreateNoWidthCell("", NormalFont, Element.ALIGN_LEFT));
            //table1.AddCell(_pdfHelper.CreateNoWidthCell(DateTime.Now.ToString("yyyy年MM月dd日"), NormalFont, Element.ALIGN_LEFT));
            //PdfPCell cell1 = new PdfPCell(table1);
            //table.AddCell(cell1);
            doc.Add(table);

            table = _pdfHelper.CreateTable(new float[] { 1, 4 }, doc);
            table.AddCell(_pdfHelper.CreateCell("公安交警" + Environment.NewLine + "部门提示", NormalFont, Element.ALIGN_CENTER));
            table.AddCell(_pdfHelper.CreateCell("       《中华人民共和国道路交通安全法》第十六条规定,任何单位或者个人不得" +
                                                "拼装机动车或者擅自改变机动车已登记的结构、构造或者特征。构造或者特征。《机动车登记规公安交管定》" +
                                                " (公安部令第124号)第五十七条规定,擅自改变机动车外形和已登记的有部门提示关技术数据的, 由公安机关交通管理部门责令恢复原状," +
                                                "并处警告或者五百元以下罚款。擅自改装机动车属于违法行为,应承担法律责任,因非法改装造成交通事故的," +
                                                "还应承担相应交通事故责任。", NormalFont, Element.ALIGN_LEFT));

            doc.Add(table);
            doc.Close();

            MemoryStream memoryStream1 = new MemoryStream(memoryStream.ToArray());

            O2S.Components.PDFRender4NET.PDFFile pdfFile = O2S.Components.PDFRender4NET.PDFFile.Open(memoryStream1);
            System.Drawing.Bitmap pageImage = pdfFile.GetPageImage(0, 56 * (int)PdfHelper.Definition.Six);

            PrinterSettings settings = new PrinterSettings();
            PrintDocument   pd       = new PrintDocument();

            settings.PrinterName = AppHelper.AppSetting.PrinterName;
            settings.PrintToFile = false;
            PDFPrintSettings pdfPrintSettings = new PDFPrintSettings(settings);

            pdfPrintSettings.PageScaling            = PageScaling.MultiplePagesPerSheetProportional;
            pdfPrintSettings.PrinterSettings.Copies = 1;
            LogHelper.Trace("开始打印" + AppHelper.AppSetting.PrinterName);
            pdfFile.Print(pdfPrintSettings);
            LogHelper.Trace("打印完成" + AppHelper.AppSetting.PrinterName);

            memoryStream.Close();
            memoryStream.Dispose();
            memoryStream1.Close();
            memoryStream1.Dispose();

            return(pageImage);
        }
Esempio n. 24
0
 public IEnumerable <DataAccess.App> Get(string id) => AppHelper.RetrievesByRoleId(id);
 private void GuardarButton_Click(object sender, EventArgs e)
 {
     AppHelper.DoMethod(new AppHelper.HelperDelegate(DoSave), this);
 }
 /// <summary>
 /// Al hacer clic en "Expotar", exportamos la información
 /// del reporte a formato MS Excel
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ExportarButton_Click(object sender, EventArgs e)
 {
     AppHelper.ExportDataGridViewExcel(this.reporte_CobranzaAtencionYControlDataGridView, this);
 }
Esempio n. 27
0
        /// <summary>
        /// Asigna las comisiones correspondientes al servicio a partir de la configuración por zona
        /// </summary>
        private void GetComisiones()
        {
            //  Instanciamos el listado
            Comisiones = new List <Entities.Servicios_Comisiones>();

            //  Configuramos el pago a 0
            Servicio.PagoComisiones = 0;

            //  Configuramos el pago al conductor como el precio total del boleto
            Servicio.PagoConductor = Servicio.Precio;

            //  Obtenemos la zona
            Entities.Zonas zona = Entities.Zonas.Read((int)Servicio.Zona_ID);

            //  Si es comisionada
            if (!AppHelper.IsNullOrEmpty(zona.ComisionServicio_ID))
            {
                //  Obtenemos la comisión
                Entities.ComisionesServicios comisionServicio = Entities.ComisionesServicios.Read((int)zona.ComisionServicio_ID);
                //  Calcular comision
                CalcularComision(comisionServicio);
                switch (zona.Zona_ID)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 11:
                case 12:
                case 13:
                case 14:
                    break;

                default:
                    //  Calculamos Comision pronatura
                    Entities.ComisionesServicios comisionPronatura = Entities.ComisionesServicios.Read(COMISIONPRONATURA_ID);
                    //  Calcular comision
                    CalcularComision(comisionPronatura);
                    //  Comision de regresos
                    Entities.ComisionesServicios comisionRegresos = Entities.ComisionesServicios.Read(COMISIONREGRESOS_ID);
                    //  Calcular comision
                    CalcularComision(comisionRegresos);
                    break;
                }
            }
            else
            {
                //  Comision de regresos
                Entities.ComisionesServicios comisionRegresos = Entities.ComisionesServicios.Read(COMISIONREGRESOS_ID);
                //  Calcular comision
                CalcularComision(comisionRegresos);

                //  Calculamos Comision pronatura
                Entities.ComisionesServicios comisionPronatura = Entities.ComisionesServicios.Read(COMISIONPRONATURA_ID);
                //  Calcular comision
                CalcularComision(comisionPronatura);
            }
            //  Asignar el porcentaje a la unidad
            Entities.VariablesNegocio varneg = Entities.VariablesNegocio.Read("PorcentajeBoletosRegresos");
            decimal porcentajeregresos       = Convert.ToDecimal(varneg.Valor);

            Servicio.ComisionRegreso   = Servicio.Precio * (porcentajeregresos / 100);
            Servicio.PorcentajeRegreso = porcentajeregresos;
        }
Esempio n. 28
0
        public static void SendReport(string exceptionMessage, int crashLocation, string[] logs, string threadName)
        {
            var crashReport = new CrashReportData
            {
                ["Application"]       = "GameStudio",
                ["UserEmail"]         = "",
                ["UserMessage"]       = "",
                ["XenkoVersion"]      = XenkoVersion.NuGetVersion,
                ["GameStudioVersion"] = DebugVersion.ToString(),
                ["ThreadName"]        = string.IsNullOrEmpty(threadName) ? "" : threadName,
#if DEBUG
                ["CrashLocation"] = crashLocation.ToString(),
                ["ProcessID"]     = Process.GetCurrentProcess().Id.ToString()
#endif
            };

            try
            {
                // Add session-specific information in this try/catch block
                var gameSettingsAsset = SessionViewModel.Instance?.CurrentProject?.Package.GetGameSettingsAsset();
                if (gameSettingsAsset != null)
                {
                    crashReport["DefaultGraphicProfile"] = gameSettingsAsset.GetOrCreate <RenderingSettings>().DefaultGraphicsProfile.ToString();
                }
            }
            catch (Exception e)
            {
                e.Ignore();
            }

            // opened assets
            try
            {
                var manager = SessionViewModel.Instance?.Dialogs?.AssetEditorsManager as AssetEditorsManager;
                if (manager != null)
                {
                    var sb = new StringBuilder();
                    foreach (var asset in manager.GetCurrentlyOpenedAssets())
                    {
                        sb.AppendLine($"{asset.Id}:{asset.Name} ({asset.TypeDisplayName})");
                    }
                    crashReport["OpenedAssets"] = sb.ToString();
                }
            }
            catch (Exception e)
            {
                e.Ignore();
            }

            // action history
            try
            {
                // Add session-specific information in this try/catch block
                var actionsViewModel = SessionViewModel.Instance?.ActionHistory;
                if (actionsViewModel != null)
                {
                    var actions = actionsViewModel.Transactions.ToList();
                    var sb      = new StringBuilder();
                    for (var i = Math.Max(0, actions.Count - 5); i < actions.Count; ++i)
                    {
                        ExpandAction(actions[i], sb, 4);
                    }
                    crashReport["LastActions"] = sb.ToString();
                }
            }
            catch (Exception e)
            {
                e.Ignore();
            }

            // transaction in progress
            try
            {
                // Add session-specific information in this try/catch block
                var actionService = SessionViewModel.Instance?.UndoRedoService;
                if (actionService != null && actionService.TransactionInProgress)
                {
                    // FIXME: expose some readonly properties/methods from ITransactionStack or ITransaction to reduce reflection
                    var stackField = typeof(UndoRedoService).GetField("stack", BindingFlags.Instance | BindingFlags.NonPublic);
                    if (stackField != null)
                    {
                        var transactionsInProgressField = typeof(ITransactionStack).Assembly.GetType("Xenko.Core.Transactions.TransactionStack")?.GetField("transactionsInProgress", BindingFlags.Instance | BindingFlags.NonPublic);
                        if (transactionsInProgressField != null)
                        {
                            var stack = stackField.GetValue(actionService);
                            var transactionsInProgress = transactionsInProgressField.GetValue(stack) as IEnumerable <IReadOnlyTransaction>;
                            if (transactionsInProgress != null)
                            {
                                var sb = new StringBuilder();
                                sb.AppendLine("Transactions in progress:");
                                foreach (var transaction in transactionsInProgress)
                                {
                                    PrintTransaction(transaction, sb, 4);
                                }
                                crashReport["TransactionInProgress"] = sb.ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                e.Ignore();
            }

            crashReport["CurrentDirectory"] = Environment.CurrentDirectory;
            crashReport["CommandArgs"]      = string.Join(" ", AppHelper.GetCommandLineArgs());
            var osVersion = CrashReportUtils.GetOsVersionAndCaption();

            crashReport["OsVersion"]      = $"{osVersion.Key} {osVersion.Value} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}";
            crashReport["ProcessorCount"] = Environment.ProcessorCount.ToString();
            crashReport["Exception"]      = exceptionMessage;
            var videoConfig = AppHelper.GetVideoConfig();

            foreach (var conf in videoConfig)
            {
                crashReport.Data.Add(Tuple.Create(conf.Key, conf.Value));
            }

            var nonFatalReport = new StringBuilder();

            for (var index = 0; index < logs.Length; index++)
            {
                var log = logs[index];
                nonFatalReport.AppendFormat($"{index + 1}: {log}\r\n");
            }

            crashReport["Log"] = nonFatalReport.ToString();

            // Try to anonymize reports
            // It also makes it easier to copy and paste paths
            for (var i = 0; i < crashReport.Data.Count; i++)
            {
                var data = crashReport.Data[i].Item2;

                data = Regex.Replace(data, Regex.Escape(Environment.GetEnvironmentVariable("USERPROFILE")), Regex.Escape("%USERPROFILE%"), RegexOptions.IgnoreCase);
                data = Regex.Replace(data, $@"\b{Regex.Escape(Environment.GetEnvironmentVariable("USERNAME"))}\b", Regex.Escape("%USERNAME%"), RegexOptions.IgnoreCase);

                crashReport.Data[i] = Tuple.Create(crashReport.Data[i].Item1, data);
            }

            var reporter = new CrashReportForm(crashReport, new ReportSettings());
            var result   = reporter.ShowDialog();
        }
Esempio n. 29
0
 private void btnExportar_Click(object sender, EventArgs e)
 {
     AppHelper.ExportDataGridViewExcel(this.dgvConductores, this);
 }
Esempio n. 30
0
 /// <summary>
 /// Crea una nueva instancia del reporte de servicios de sesion
 /// </summary>
 public ServiciosDeSesion()
 {
     InitializeComponent();
     AppHelper.SetStylish(this);
 }
Esempio n. 31
0
 /// <summary>
 /// 保存上载文件的内容。
 /// </summary>
 /// <param name="filename">保存的文件的名称(必须是绝对路径,不能是网址。)。</param>
 public void SaveAs(string filename)
 {
     AppHelper.DeleteFile(filename);
     System.IO.StreamExtensions.ToFile(_inputStream, filename);
     //System.IO.File.WriteAllBytes(filename, _inputStream.ToArray());
 }
Esempio n. 32
0
 private void InitializeForm()
 {
     AppHelper.ApplyVisualStyle(this.Controls);
     // transaction type
     ModulePrefix = TransactionTypes.TX_SALES_PAYMENT;
     // grid event handlers
     _grid.Enter           += new EventHandler(_grid_Enter);
     _grid.AfterEdit       += new RowColEventHandler(_grid_AfterEdit);
     _grid.GetUnboundValue += new UnboundValueEventHandler(_grid_GetUnboundValue);
     _grid.AfterAddRow     += new RowColEventHandler(_grid_AfterAddRow);
     _grid.KeyDownEdit     += new KeyEditEventHandler(_grid_KeyDownEdit);
     _grid.CellButtonClick += new RowColEventHandler(_grid_CellButtonClick);
     _grid.BeforeAddRow    += new RowColEventHandler(_grid_BeforeAddRow);
     // grid column setting
     try
     {
         // column headers
         _grid.Cols["ID"].Caption             = "ID";
         _grid.Cols["OrderID"].Caption        = "Order ID";
         _grid.Cols["ItemID"].Caption         = "Item ID";
         _grid.Cols["ItemCode"].Caption       = "Item Code";
         _grid.Cols["ItemName"].Caption       = "Item Name";
         _grid.Cols["Quantity"].Caption       = "Quantity";
         _grid.Cols["MeasureCode"].Caption    = "UoM";
         _grid.Cols["MeasureName"].Caption    = "Measure Name";
         _grid.Cols["UnitPrice"].Caption      = "Payment";
         _grid.Cols["TrxType"].Caption        = "Trx Type";
         _grid.Cols["TaxPct"].Caption         = "Tax (%)";
         _grid.Cols["ReferenceID"].Caption    = "Invoice ID";
         _grid.Cols["ReferenceNo"].Caption    = "Invoice Num.";
         _grid.Cols["ReferenceDate"].Caption  = "Invoice Date";
         _grid.Cols["ReferenceValue"].Caption = "Outstanding";
         // read only columns
         _grid.Cols["ID"].AllowEditing             = false;
         _grid.Cols["OrderID"].AllowEditing        = false;
         _grid.Cols["ItemID"].AllowEditing         = false;
         _grid.Cols["ItemName"].AllowEditing       = false;
         _grid.Cols["MeasureCode"].AllowEditing    = false;
         _grid.Cols["MeasureName"].AllowEditing    = false;
         _grid.Cols["ReferenceID"].AllowEditing    = false;
         _grid.Cols["ReferenceNo"].AllowEditing    = false;
         _grid.Cols["ReferenceDate"].AllowEditing  = false;
         _grid.Cols["ReferenceValue"].AllowEditing = false;
         // hide columns
         _grid.Cols["ID"].Visible             = false;
         _grid.Cols["ItemID"].Visible         = false;
         _grid.Cols["ItemCode"].Visible       = false;
         _grid.Cols["ItemName"].Visible       = false;
         _grid.Cols["OrderID"].Visible        = false;
         _grid.Cols["MeasureCode"].Visible    = false;
         _grid.Cols["MeasureName"].Visible    = false;
         _grid.Cols["UnitPrice"].Visible      = true;
         _grid.Cols["TaxPct"].Visible         = false;
         _grid.Cols["TrxType"].Visible        = true;
         _grid.Cols["Quantity"].Visible       = false;
         _grid.Cols["ReferenceID"].Visible    = false;
         _grid.Cols["ReferenceNo"].Visible    = true;
         _grid.Cols["ReferenceDate"].Visible  = true;
         _grid.Cols["ReferenceValue"].Visible = true;
         // number format
         _grid.Cols["ID"].Format             = "N2";
         _grid.Cols["OrderID"].Format        = "N2";
         _grid.Cols["ItemID"].Format         = "N2";
         _grid.Cols["Quantity"].Format       = "N2";
         _grid.Cols["UnitPrice"].Format      = "N2";
         _grid.Cols["TaxPct"].Format         = "N2";
         _grid.Cols["ReferenceValue"].Format = "N2";
         // COmbo option
         _grid.Cols["ItemCode"].ComboList    = "|...";
         _grid.Cols["ReferenceNo"].ComboList = "...";
         // column width
         _grid.Cols["ID"].Width             = -1;
         _grid.Cols["OrderID"].Width        = -1;
         _grid.Cols["ItemID"].Width         = -1;
         _grid.Cols["ItemCode"].Width       = 120;
         _grid.Cols["ItemName"].Width       = 150;
         _grid.Cols["Quantity"].Width       = 70;
         _grid.Cols["MeasureCode"].Width    = 50;
         _grid.Cols["MeasureName"].Width    = -1;
         _grid.Cols["UnitPrice"].Width      = 120;
         _grid.Cols["ReferenceNo"].Width    = 120;
         _grid.Cols["ReferenceValue"].Width = 120;
         _grid.Cols["TrxType"].Width        = 70;
         _grid.Cols["TaxPct"].Width         = 50;
     }
     catch (Exception ex)
     {
         Logger.ErrorRoutine(ex);
         RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message);
     }
 }
Esempio n. 33
0
        public void delete(FaktorBorongan dbitem, int id)
        {
            context.FaktorBorongan.Remove(dbitem);
            var query     = "DELETE FROM dbo.\"FaktorBorongan\" WHERE \"Id\" = " + dbitem.Id + ";";
            var auditrail = new Auditrail {
                Actionnya = "Delete", EventDate = DateTime.Now, Modulenya = "Faktor Borongan", QueryDetail = query, RemoteAddress = AppHelper.GetIPAddress(), IdUser = id
            };

            context.Auditrail.Add(auditrail);
            context.SaveChanges();
        }
Esempio n. 34
0
 /// <summary>
 /// Selecciona el valor del tipo de servicio
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TiposServiciosComboBox_SelectedValueChanged(object sender, EventArgs e)
 {
     AppHelper.Try(delegate { SelectTipoServicio(); });
 }
Esempio n. 35
0
        void ShowDeviceInfo(Joystick device, UserDevice dInfo)
        {
            if (device == null)
            {
                // clean everything here.
                AppHelper.SetText(DeviceProductNameTextBox, "");
                AppHelper.SetText(DeviceVendorNameTextBox, "");
                AppHelper.SetText(DeviceProductGuidTextBox, "");
                AppHelper.SetText(DeviceInstanceGuidTextBox, "");
                AppHelper.SetText(DiCapFfStateTextBox, "");
                AppHelper.SetText(DiCapAxesTextBox, "");
                AppHelper.SetText(DiCapButtonsTextBox, "");
                AppHelper.SetText(DiCapDPadsTextBox, "");
                if (DiEffectsTable.Rows.Count > 0)
                {
                    DiEffectsTable.Rows.Clear();
                }
                return;
            }
            lock (MainForm.XInputLock)
            {
                var isLoaded = XInput.IsLoaded;
                if (isLoaded)
                {
                    XInput.FreeLibrary();
                }
                device.Unacquire();
                device.SetCooperativeLevel(MainForm.Current, CooperativeLevel.Foreground | CooperativeLevel.Exclusive);
                effects = new List <EffectInfo>();
                try
                {
                    device.Acquire();
                    var forceFeedback = device.Capabilities.Flags.HasFlag(DeviceFlags.ForceFeedback);
                    forceFeedbackState = forceFeedback ? "YES" : "NO";
                    effects            = device.GetEffects(EffectType.All);
                }
                catch (Exception)
                {
                    forceFeedbackState = "ERROR";
                }
                DiEffectsTable.Rows.Clear();
                foreach (var eff in effects)
                {
                    DiEffectsTable.Rows.Add(new object[] {
                        eff.Name,
                        ((EffectParameterFlags)eff.StaticParameters).ToString(),
                        ((EffectParameterFlags)eff.DynamicParameters).ToString()
                    });
                }
                device.Unacquire();
                device.SetCooperativeLevel(MainForm.Current, CooperativeLevel.Background | CooperativeLevel.NonExclusive);
                if (isLoaded)
                {
                    Exception error;
                    XInput.ReLoadLibrary(XInput.LibraryName, out error);
                }
            }
            AppHelper.SetText(DiCapFfStateTextBox, forceFeedbackState);
            AppHelper.SetText(DiCapButtonsTextBox, device.Capabilities.ButtonCount.ToString());
            AppHelper.SetText(DiCapDPadsTextBox, device.Capabilities.PovCount.ToString());
            var objects = AppHelper.GetDeviceObjects(device);

            DiObjectsDataGridView.DataSource = objects;
            var actuators = objects.Where(x => x.Flags.HasFlag(DeviceObjectTypeFlags.ForceFeedbackActuator));

            AppHelper.SetText(ActuatorsTextBox, actuators.Count().ToString());
            var di           = device.Information;
            var slidersCount = objects.Where(x => x.GuidValue.Equals(SharpDX.DirectInput.ObjectGuid.Slider)).Count();

            // https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.dijoystate2(v=vs.85).aspx
            AppHelper.SetText(DiCapAxesTextBox, (device.Capabilities.AxeCount - slidersCount).ToString());
            AppHelper.SetText(SlidersTextBox, slidersCount.ToString());
            // Update PID and VID always so they wont be overwritten by load settings.
            short vid = BitConverter.ToInt16(di.ProductGuid.ToByteArray(), 0);
            short pid = BitConverter.ToInt16(di.ProductGuid.ToByteArray(), 2);

            AppHelper.SetText(DeviceVidTextBox, "0x{0:X4}", vid);
            AppHelper.SetText(DevicePidTextBox, "0x{0:X4}", pid);
            AppHelper.SetText(DeviceProductNameTextBox, di.ProductName);
            AppHelper.SetText(DeviceVendorNameTextBox, dInfo == null ? "" : dInfo.HidManufacturer);
            AppHelper.SetText(DeviceRevTextBox, "0x{0:X4}", dInfo == null ? 0 : dInfo.HidRevision);
            AppHelper.SetText(DeviceProductGuidTextBox, di.ProductGuid.ToString());
            AppHelper.SetText(DeviceInstanceGuidTextBox, di.InstanceGuid.ToString());
            AppHelper.SetText(DeviceTypeTextBox, di.Type.ToString());
        }
Esempio n. 36
0
        private void simpleButtonConnect_Click(object sender, EventArgs e)
        {
            if (xtraTabControlMain.SelectedTabPageIndex == 0) // Postgresql
            {
                var model = new DbConnectionModel();
                model.Alias    = textEditAliasPostgres.Text.Trim();
                model.Database = textEditDatabasePostgres.Text.Trim();
                model.HostOrIp = textEditHostOrIPPostgres.Text.Trim();
                model.Password = textEditPasswordPostgres.Text.Trim();
                model.Port     = int.Parse(textEditPortPostgres.Text.Trim());
                model.Username = textEditUsernamePostgres.Text.Trim();

                string _connectionString = "Server = " + model.HostOrIp + "; Port = " + model.Port + "; Database = " + model.Database + "; User Id = " + model.Username + "; Password = "******";";
                try
                {
                    using (NpgsqlConnection cnn = new NpgsqlConnection(_connectionString))
                    {
                        cnn.Open();
                        NpgsqlDataAdapter da = new NpgsqlDataAdapter("Select 1", cnn);
                        DataTable         dt = new DataTable();
                        da.Fill(dt);

                        if (dt.Rows.Count > 0)
                        {
                            if (toggleSwitchSaveConnectionPostgres.IsOn)
                            {
                                if (!string.IsNullOrEmpty(_selectedConnectionId))
                                {
                                    AppHelper.RemoveConnection(_selectedConnectionId);
                                }
                                model.DatabaseType = Models.DbType.PostgreSQL;
                                AppHelper.SaveConnection(model);
                                this.Close();
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show("Cannot connect to database. Please check");
                            this.DialogResult = DialogResult.None;
                        }
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show("Cannot connect to database. Please check");
                    this.DialogResult = DialogResult.None;
                }
            }
            else if (xtraTabControlMain.SelectedTabPageIndex == 1) // Oracle
            {
                var tns = DxHelper.GetSelectedItem(comboBoxEditTnsNamesOracle);
                if (tns.Value.ToString() != "-1")
                {
                    var model = new DbConnectionModel();
                    model.Alias    = textEditAliasOracle.Text.Trim();
                    model.HostOrIp = tns.Text.Trim();
                    model.Password = textEditPasswordOracle.Text.Trim();
                    model.Username = textEditUsernameOracle.Text.Trim();

                    string _connectionString = "User Id=" + model.Username + ";Password="******";Data Source=" + model.HostOrIp + ";";
                    try
                    {
                        using (OracleConnection cnn = new OracleConnection(_connectionString))
                        {
                            cnn.Open();
                            OracleDataAdapter da = new OracleDataAdapter("Select 1 from dual", cnn);
                            DataTable         dt = new DataTable();
                            da.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                if (toggleSwitchIsSaveConnectionOracle.IsOn)
                                {
                                    if (!string.IsNullOrEmpty(_selectedConnectionId))
                                    {
                                        AppHelper.RemoveConnection(_selectedConnectionId);
                                    }
                                    model.DatabaseType = Models.DbType.Oracle;
                                    AppHelper.SaveConnection(model);
                                    this.Close();
                                }
                            }
                            else
                            {
                                XtraMessageBox.Show("Cannot connect to database. Please check");
                                this.DialogResult = DialogResult.None;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show("Cannot connect to database. Please check");
                        this.DialogResult = DialogResult.None;
                    }
                }
            }
        }
Esempio n. 37
0
 public ActionResult Index()
 {
     ViewData["Title"] = AppHelper.GetResource("DEVTREKS_TITLE");
     return(View());
 }