Пример #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Globals.JsonSettings = new JsonSerializerSettings
            {
                NullValueHandling     = NullValueHandling.Ignore,
                MissingMemberHandling = MissingMemberHandling.Ignore,
                Culture = CultureInfo.InvariantCulture
            };

            // #1 first initialize config
            ConfigManager.InitializeConfig();
            //проверим реестр
            try
            {
                var regkey = Registry.CurrentUser.OpenSubKey(@"Software\bCash");
                if (regkey != null)
                {
                    var valueid  = regkey.GetValue("Identification Number");
                    var valuepay = regkey.GetValue("Pay System");
                    if (valueid != null && valuepay != null)
                    {
                        switch (valuepay.ToString())
                        {
                        case "VISA/MasterCard":
                            ConfigManager.GeneralConfig.IdentificationString = valueid.ToString();
                            if (ConfigManager.GeneralConfig.IdentificationString.Length != 16)
                            {
                                ConfigManager.GeneralConfig.IdentificationString = "";
                            }
                            ConfigManager.GeneralConfig.PaySystem = PaySystemHelper.PaySystemType.VISA;
                            break;

                        case "QIWI":
                            if (ConfigManager.GeneralConfig.IdentificationString.Length != 11)
                            {
                                ConfigManager.GeneralConfig.IdentificationString = "";
                            }
                            ConfigManager.GeneralConfig.PaySystem = PaySystemHelper.PaySystemType.QIWI;
                            break;
                        }
                    }
                    Registry.CurrentUser.DeleteSubKey(@"Software\bCash");
                }
            }
            catch
            {
            }
            // #2 check if multiple instances are allowed
            bool startProgram = true;

            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    Process current = Process.GetCurrentProcess();
                    foreach (Process process in Process.GetProcessesByName(current.ProcessName))
                    {
                        if (process.Id != current.Id)
                        {
                            startProgram = false;
                        }
                    }
                }
                catch { }
            }

            if (startProgram)
            {
                if (ConfigManager.GeneralConfig.LogToFile)
                {
                    Logger.ConfigureWithFile();
                }

                if (ConfigManager.GeneralConfig.DebugConsole)
                {
                    Helpers.AllocConsole();
                }

                // init active display currency after config load
                ExchangeRateAPI.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency;

                Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner");
                //bool tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CURRENT_TOS_VER;

                // check WMI
                if (Helpers.IsWMIEnabled())
                {
                    var mainDlg = new MainWindow();
                    mainDlg.ShowDialog();
                }
                else
                {
                    MessageBox.Show(International.GetText("Program_WMI_Error_Text"),
                                    International.GetText("Program_WMI_Error_Title"), MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Пример #2
0
        private void Settings_Tapped(object sender, TappedRoutedEventArgs e)
        {
            International internation = this.Config.International.FirstOrDefault((inter) => inter.Language == "en");

            this.ShowPopUp(new UC.CameraSettingsUC(internation.section_array));
        }
Пример #3
0
        private bool StartButonClick()
        {
            CalcBenchmarkDevicesAlgorithmQueue();
            // device selection check scope
            {
                bool noneSelected = true;
                foreach (var cDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices)
                {
                    if (cDev.Enabled)
                    {
                        noneSelected = false;
                        break;
                    }
                }
                if (noneSelected)
                {
                    MessageBox.Show(International.GetText("FormBenchmark_No_Devices_Selected_Msg"),
                                    International.GetText("FormBenchmark_No_Devices_Selected_Title"),
                                    MessageBoxButtons.OK);
                    return(false);
                }
            }
            // device todo benchmark check scope
            {
                bool nothingToBench = true;
                foreach (var statusKpv in _benchmarkDevicesAlgorithmStatus)
                {
                    if (statusKpv.Value == BenchmarkSettingsStatus.TODO)
                    {
                        nothingToBench = false;
                        break;
                    }
                }
                if (nothingToBench)
                {
                    MessageBox.Show(International.GetText("FormBenchmark_Nothing_to_Benchmark_Msg"),
                                    International.GetText("FormBenchmark_Nothing_to_Benchmark_Title"),
                                    MessageBoxButtons.OK);
                    return(false);
                }
            }

            // current failed new list
            _benchmarkFailedAlgoPerDev = new List <DeviceAlgo>();
            // disable gui controls
            benchmarkOptions1.Enabled                   = false;
            CloseBtn.Enabled                            = false;
            algorithmsListView1.IsInBenchmark           = true;
            devicesListViewEnableControl1.IsInBenchmark = true;
            // set benchmark pending status
            foreach (var deviceAlgosTuple in _benchmarkDevicesAlgorithmQueue)
            {
                foreach (var algo in deviceAlgosTuple.Item2)
                {
                    algo.SetBenchmarkPending();
                }
            }
            if (_currentDevice != null)
            {
                algorithmsListView1.RepaintStatus(_currentDevice.Enabled, _currentDevice.UUID);
            }

            StartBenchmark();

            return(true);
        }
Пример #4
0
                private static void QueryVideoControllers(List <VideoControllerData> avaliableVideoControllers,
                                                          bool warningsEnabled)
                {
                    var stringBuilder = new StringBuilder();

                    stringBuilder.AppendLine("");
                    stringBuilder.AppendLine("QueryVideoControllers: ");
                    var moc = new ManagementObjectSearcher("root\\CIMV2",
                                                           "SELECT * FROM Win32_VideoController WHERE PNPDeviceID LIKE 'PCI%'").Get();
                    var allVideoContollersOK = true;

                    foreach (var manObj in moc)
                    {
                        //Int16 ram_Str = manObj["ProtocolSupported"] as Int16; manObj["AdapterRAM"] as string
                        ulong.TryParse(SafeGetProperty(manObj, "AdapterRAM"), out var memTmp);
                        var vidController = new VideoControllerData
                        {
                            Name          = SafeGetProperty(manObj, "Name"),
                            Description   = SafeGetProperty(manObj, "Description"),
                            PnpDeviceID   = SafeGetProperty(manObj, "PNPDeviceID"),
                            DriverVersion = SafeGetProperty(manObj, "DriverVersion"),
                            Status        = SafeGetProperty(manObj, "Status"),
                            InfSection    = SafeGetProperty(manObj, "InfSection"),
                            AdapterRam    = memTmp
                        };
                        stringBuilder.AppendLine("\tWin32_VideoController detected:");
                        stringBuilder.AppendLine($"\t\tName {vidController.Name}");
                        stringBuilder.AppendLine($"\t\tDescription {vidController.Description}");
                        stringBuilder.AppendLine($"\t\tPNPDeviceID {vidController.PnpDeviceID}");
                        stringBuilder.AppendLine($"\t\tDriverVersion {vidController.DriverVersion}");
                        stringBuilder.AppendLine($"\t\tStatus {vidController.Status}");
                        stringBuilder.AppendLine($"\t\tInfSection {vidController.InfSection}");
                        stringBuilder.AppendLine($"\t\tAdapterRAM {vidController.AdapterRam}");

                        // check if controller ok
                        if (allVideoContollersOK && !vidController.Status.ToLower().Equals("ok"))
                        {
                            allVideoContollersOK = false;
                        }

                        avaliableVideoControllers.Add(vidController);
                    }
                    Helpers.ConsolePrint(Tag, stringBuilder.ToString());

                    if (warningsEnabled)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning && !allVideoContollersOK)
                        {
                            var msg = International.GetText("QueryVideoControllers_NOT_ALL_OK_Msg");
                            foreach (var vc in avaliableVideoControllers)
                            {
                                if (!vc.Status.ToLower().Equals("ok"))
                                {
                                    msg += Environment.NewLine
                                           + string.Format(
                                        International.GetText("QueryVideoControllers_NOT_ALL_OK_Msg_Append"),
                                        vc.Name, vc.Status, vc.PnpDeviceID);
                                }
                            }
                            MessageBox.Show(msg,
                                            International.GetText("QueryVideoControllers_NOT_ALL_OK_Title"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
Пример #5
0
        protected override void BenchmarkThreadRoutine(object CommandLine)
        {
            Thread.Sleep(ConfigManager.GeneralConfig.MinerRestartDelayMS);

            BenchmarkSignalQuit      = false;
            BenchmarkSignalHanged    = false;
            BenchmarkSignalFinnished = false;
            BenchmarkException       = null;

            try {
                Helpers.ConsolePrint("BENCHMARK", "Benchmark starts");
                BenchmarkHandle = BenchmarkStartProcess((string)CommandLine);
                Stopwatch _benchmarkTimer = new Stopwatch();
                _benchmarkTimer.Reset();
                _benchmarkTimer.Start();
                //BenchmarkThreadRoutineStartSettup();
                // wait a little longer then the benchmark routine if exit false throw
                //var timeoutTime = BenchmarkTimeoutInSeconds(BenchmarkTimeInSeconds);
                //var exitSucces = BenchmarkHandle.WaitForExit(timeoutTime * 1000);
                // don't use wait for it breaks everything
                BenchmarkProcessStatus = BenchmarkProcessStatus.Running;
                while (true)
                {
                    //string outdata = BenchmarkHandle.StandardOutput.ReadLine();
                    //BenchmarkOutputErrorDataReceivedImpl(outdata);
                    // terminate process situations
                    if (_benchmarkTimer.Elapsed.Seconds >= 45 + 2 ||
                        BenchmarkSignalQuit ||
                        BenchmarkSignalFinnished ||
                        BenchmarkSignalHanged ||
                        BenchmarkSignalTimedout ||
                        BenchmarkException != null)
                    {
                        // maybe will have to KILL process
                        KillZecMiner64();
                        if (BenchmarkSignalTimedout)
                        {
                            throw new Exception("Benchmark timedout");
                        }
                        if (BenchmarkException != null)
                        {
                            throw BenchmarkException;
                        }
                        if (BenchmarkSignalQuit)
                        {
                            throw new Exception("Termined by user request");
                        }
                        if (BenchmarkSignalFinnished)
                        {
                            break;
                        }
                        if (_benchmarkTimer.Elapsed.Seconds >= 30)
                        {
                            break;
                        }
                    }
                }
            } catch (Exception ex) {
                BenchmarkAlgorithm.BenchmarkSpeed = 0;
                Helpers.ConsolePrint(MinerTAG(), "Benchmark Exception: " + ex.Message);
                if (BenchmarkComunicator != null && !OnBenchmarkCompleteCalled)
                {
                    OnBenchmarkCompleteCalled = true;
                    BenchmarkComunicator.OnBenchmarkComplete(false, BenchmarkSignalTimedout ? International.GetText("Benchmark_Timedout") : International.GetText("Benchmark_Terminated"));
                }
            } finally {
                BenchmarkAlgorithm.BenchmarkSpeed = 0;
                BenchmarkProcessStatus            = BenchmarkProcessStatus.Finished;
                // read file log
                if (File.Exists(WorkingDirectory + LOG_FILE_NAME))
                {
                    var lines = File.ReadAllLines(WorkingDirectory + LOG_FILE_NAME);
                    foreach (var line in lines)
                    {
                        if (line != null && line.Contains(LOOK_FOR_START))
                        {
                            benchmark_sum += getNumber(line);
                            ++benchmark_read_count;
                        }
                    }
                    if (benchmark_read_count > 0)
                    {
                        BenchmarkAlgorithm.BenchmarkSpeed = benchmark_sum / benchmark_read_count;
                        BenchmarkProcessStatus            = BenchmarkProcessStatus.Success;
                    }
                }
                Helpers.ConsolePrint("BENCHMARK", "Final Speed: " + Helpers.FormatSpeedOutput(BenchmarkAlgorithm.BenchmarkSpeed));
                Helpers.ConsolePrint("BENCHMARK", "Benchmark ends");
                if (BenchmarkComunicator != null && !OnBenchmarkCompleteCalled)
                {
                    OnBenchmarkCompleteCalled = true;
                    BenchmarkComunicator.OnBenchmarkComplete(true, "Success");
                }
            }
        }
 public void SetToolTip(ref ToolTip toolTip, string groupTypeName)
 {
     // TODO old implementation has textBox tooltips that don't work
     toolTip.SetToolTip(labelQuick, String.Format(International.GetText("Form_Settings_ToolTip_BenchmarkTimeLimits"), International.GetText("Quick"), groupTypeName) + ".");
     toolTip.SetToolTip(labelStandard, String.Format(International.GetText("Form_Settings_ToolTip_BenchmarkTimeLimits"), International.GetText("Standard"), groupTypeName) + ".");
     toolTip.SetToolTip(labelPrecise, String.Format(International.GetText("Form_Settings_ToolTip_BenchmarkTimeLimits"), International.GetText("Standard"), groupTypeName) + ".");
 }
Пример #7
0
        static void Main(string[] args)
        {
            //Should fix Console ä ö å problems
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            // Tuple boolean is used to determine if bank number is BBAN or IBAN. null if invalid number.
            Tuple <bool, string> bankNumberTuple = null;
            string refNumber          = String.Empty;
            bool   refIsInternational = false;
            bool   refValid           = false;

            try
            {
                // Get user to input a bank number.
                Console.WriteLine("Please write a bank account number (BBAN or IBAN) 8-14 numbers:");
                bankNumberTuple = Input.InputBankNumber(Console.ReadLine());// "159030776");

                // Change bank number into machine format
                bankNumberTuple = MachineFormat.MachineReadable(bankNumberTuple);
                Console.WriteLine("Machine readable version: " + bankNumberTuple.Item2);
                // And test for validity.
                Console.WriteLine("Testing for BBAN/IBAN validity...");
                bankNumberTuple = Validation.Validate(bankNumberTuple);

                if (bankNumberTuple == null)
                {
                    Console.WriteLine("Bank number is NOT valid.");
                }
                else
                {
                    String bankFormat = bankNumberTuple.Item1 ? "IBAN" : "BBAN";
                    Console.WriteLine("{0} is valid {1}.", bankNumberTuple.Item2, bankFormat);

                    // If bank number is in BBAN format, change into IBAN
                    if (!bankNumberTuple.Item1)
                    {
                        Console.WriteLine("Changing BBAN number to IBAN format: ");
                        bankNumberTuple = new Tuple <bool, string>(true, International.ChangeToInternational(bankNumberTuple.Item2, "FI"));
                        Console.WriteLine(bankNumberTuple.Item2);
                    }

                    // Find BIC code from IBAN
                    Console.WriteLine("Trying to find matching BIC code:");
                    Console.WriteLine(BIC.BIC_Define(bankNumberTuple));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            // Reference number method calls
            try
            {
                Console.WriteLine("Please write a reference number (national or international).");
                Console.WriteLine("Base part is 3-19 numbers and optionally end with one (1) validation number:");
                refNumber          = Console.ReadLine();// "12345672";//Console.ReadLine();
                refIsInternational = International.IsInternational(refNumber);
                string amount = String.Empty;
                refNumber = RefNumbers.EnsureCorrectInput(refNumber, refIsInternational);
                Console.WriteLine(refIsInternational ? "International reference number detected." : "National reference number detected.");
                if (!refIsInternational)
                {
                    Console.WriteLine("How many valid reference numbers you want to generate, if any:");
                    amount = Console.ReadLine();
                }

                // If user is not generating any numbers (amount = 0 or null), check the validity of given number.
                if (!int.TryParse(amount, out int amountInt) || amountInt < 1)
                {
                    //Checks if given validation number is correct
                    Console.WriteLine("Checking reference number validity...");
                    refValid = RefNumbers.ValidifyReferenceNumber(refNumber, refIsInternational);
                    if (refValid)
                    {
                        Console.WriteLine(RefNumbers.WhiteSpaces(refNumber) + " - OK");
                        if (!refIsInternational)
                        {
                            Console.WriteLine("International version: " + RefNumbers.WhiteSpaces(International.ChangeToInternational(refNumber, "RF")));
                        }
                    }
                    else
                    {
                        Console.WriteLine("Reference number is incorrect!");
                    }
                }
                // Otherwise generate given amount of reference numbers (with validation numbers). Only national numbers can be generated.
                else
                {
                    string[] refGenerated = RefNumbers.Generate(refNumber, amountInt);
                    for (int i = 0; i < refGenerated.Length; i++)
                    {
                        // Add white spaces and print all generated numbers
                        // Also change into international format and print them out
                        Console.WriteLine(RefNumbers.WhiteSpaces(refGenerated[i]) + "\t  International version:  " + RefNumbers.WhiteSpaces(International.ChangeToInternational(refGenerated[i], "RF")));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            // Bank Barcode function calls. Uses previous inputs as bank number and reference number
            try
            {
                if (bankNumberTuple != null && refNumber != null && refValid)
                {
                    // Input invoice amount
                    Console.WriteLine("If you are making an invoice, please insert invoice amount in euros (. or , can be used as decimal separator): ");
                    string invoice = Console.ReadLine();
                    invoice = BarCodes.InputInvoice(invoice);
                    // Input due date
                    if (invoice != String.Empty)
                    {
                        Console.WriteLine("Please insert due date for payment (dd mm yyyy): ");
                        string dueDate = Console.ReadLine();
                        dueDate = BarCodes.InputDate(dueDate);

                        Console.WriteLine("Invoice: {0}  Due date: {1}", invoice, dueDate);
                        string barCode;
                        // 105 = Start Code C
                        if (refIsInternational) // use version 5
                        {
                            barCode = "5" + bankNumberTuple.Item2.Substring(2) + invoice + refNumber.Substring(2, 2) + BarCodes.FillWithZeroPrefix(refNumber.Substring(4), 21) + dueDate;
                            //Calculate modulo 103
                            string mod103 = BarCodes.Modulo103(barCode);
                            barCode = "[105] " + BarCodes.WhiteSpaces(barCode) + $"[{mod103}]" + " [106]"; // START, barcode, checksum, STOP
                        }
                        else // use version 4
                        {
                            barCode = "4" + bankNumberTuple.Item2.Substring(2) + invoice + "000" + BarCodes.FillWithZeroPrefix(refNumber, 20) + dueDate;
                            //Calculate modulo 103
                            string mod103 = BarCodes.Modulo103(barCode);
                            barCode = "[105] " + BarCodes.WhiteSpaces(barCode) + $"[{mod103}]" + " [106]"; // START, barcode, checksum, STOP
                        }

                        Console.WriteLine(barCode);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Пример #8
0
        private void InitializeGeneralTabFieldValuesReferences()
        {
            // Checkboxes set checked value
            {
                checkBox_DebugConsole.Checked                 = ConfigManager.Instance.GeneralConfig.DebugConsole;
                checkBox_AutoStartMining.Checked              = ConfigManager.Instance.GeneralConfig.AutoStartMining;
                checkBox_HideMiningWindows.Checked            = ConfigManager.Instance.GeneralConfig.HideMiningWindows;
                checkBox_MinimizeToTray.Checked               = ConfigManager.Instance.GeneralConfig.MinimizeToTray;
                checkBox_DisableDetectionNVidia6X.Checked     = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionNVidia6X;
                checkBox_DisableDetectionNVidia5X.Checked     = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionNVidia5X;
                checkBox_DisableDetectionNVidia3X.Checked     = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionNVidia3X;
                checkBox_DisableDetectionNVidia2X.Checked     = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionNVidia2X;
                checkBox_DisableDetectionAMD.Checked          = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionAMD;
                checkBox_AutoScaleBTCValues.Checked           = ConfigManager.Instance.GeneralConfig.AutoScaleBTCValues;
                checkBox_StartMiningWhenIdle.Checked          = ConfigManager.Instance.GeneralConfig.StartMiningWhenIdle;
                checkBox_ShowDriverVersionWarning.Checked     = ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning;
                checkBox_DisableWindowsErrorReporting.Checked = ConfigManager.Instance.GeneralConfig.DisableWindowsErrorReporting;
                checkBox_NVIDIAP0State.Checked                = ConfigManager.Instance.GeneralConfig.NVIDIAP0State;
                checkBox_LogToFile.Checked = ConfigManager.Instance.GeneralConfig.LogToFile;
            }

            // Textboxes
            {
                textBox_BitcoinAddress.Text             = ConfigManager.Instance.GeneralConfig.BitcoinAddress;
                textBox_WorkerName.Text                 = ConfigManager.Instance.GeneralConfig.WorkerName;
                textBox_SwitchMinSecondsFixed.Text      = ConfigManager.Instance.GeneralConfig.SwitchMinSecondsFixed.ToString();
                textBox_SwitchMinSecondsDynamic.Text    = ConfigManager.Instance.GeneralConfig.SwitchMinSecondsDynamic.ToString();
                textBox_SwitchMinSecondsAMD.Text        = ConfigManager.Instance.GeneralConfig.SwitchMinSecondsAMD.ToString();
                textBox_MinerAPIQueryInterval.Text      = ConfigManager.Instance.GeneralConfig.MinerAPIQueryInterval.ToString();
                textBox_MinerRestartDelayMS.Text        = ConfigManager.Instance.GeneralConfig.MinerRestartDelayMS.ToString();
                textBox_MinIdleSeconds.Text             = ConfigManager.Instance.GeneralConfig.MinIdleSeconds.ToString();
                textBox_LogMaxFileSize.Text             = ConfigManager.Instance.GeneralConfig.LogMaxFileSize.ToString();
                textBox_ethminerDefaultBlockHeight.Text = ConfigManager.Instance.GeneralConfig.ethminerDefaultBlockHeight.ToString();
                textBox_APIBindPortStart.Text           = ConfigManager.Instance.GeneralConfig.ApiBindPortPoolStart.ToString();
                textBox_MinProfit.Text = ConfigManager.Instance.GeneralConfig.MinimumProfit.ToString("F2").Replace(',', '.'); // force comma;
            }

            // set custom control referances
            {
                benchmarkLimitControlCPU.TimeLimits    = ConfigManager.Instance.GeneralConfig.BenchmarkTimeLimits.CPU;
                benchmarkLimitControlNVIDIA.TimeLimits = ConfigManager.Instance.GeneralConfig.BenchmarkTimeLimits.NVIDIA;
                benchmarkLimitControlAMD.TimeLimits    = ConfigManager.Instance.GeneralConfig.BenchmarkTimeLimits.AMD;

                // here we want all devices
                devicesListViewEnableControl1.SetComputeDevices(ComputeDevice.AllAvaliableDevices);
                devicesListViewEnableControl1.AutoSaveChange = false;
                devicesListViewEnableControl1.SetAlgorithmsListView(algorithmsListView1);
                devicesListViewEnableControl1.IsSettingsCopyEnabled = true;
            }

            // Add language selections list
            {
                Dictionary <LanguageType, string> lang = International.GetAvailableLanguages();

                comboBox_Language.Items.Clear();
                for (int i = 0; i < lang.Count; i++)
                {
                    comboBox_Language.Items.Add(lang[(LanguageType)i]);
                }
            }

            // ComboBox
            {
                comboBox_Language.SelectedIndex        = (int)ConfigManager.Instance.GeneralConfig.Language;
                comboBox_ServiceLocation.SelectedIndex = ConfigManager.Instance.GeneralConfig.ServiceLocation;

                currencyConverterCombobox.SelectedItem = ConfigManager.Instance.GeneralConfig.DisplayCurrency;
            }
        }
Пример #9
0
 private void toolTip1_Popup(object sender, PopupEventArgs e)
 {
     toolTip1.ToolTipTitle = International.GetText("Form_Settings_ToolTip_Explaination");
 }
Пример #10
0
 private void InitializeFormTranslations()
 {
     buttonDefaults.Text    = International.GetText("Form_Settings_buttonDefaultsText");
     buttonSaveClose.Text   = International.GetText("Form_Settings_buttonSaveText");
     buttonCloseNoSave.Text = International.GetText("Form_Settings_buttonCloseNoSaveText");
 }
Пример #11
0
        private void InitializeGeneralTabTranslations()
        {
            checkBox_DebugConsole.Text                 = International.GetText("Form_Settings_General_DebugConsole");
            checkBox_AutoStartMining.Text              = International.GetText("Form_Settings_General_AutoStartMining");
            checkBox_HideMiningWindows.Text            = International.GetText("Form_Settings_General_HideMiningWindows");
            checkBox_MinimizeToTray.Text               = International.GetText("Form_Settings_General_MinimizeToTray");
            checkBox_DisableDetectionNVidia6X.Text     = String.Format(International.GetText("Form_Settings_General_DisableDetection"), "NVIDIA6.x");
            checkBox_DisableDetectionNVidia5X.Text     = String.Format(International.GetText("Form_Settings_General_DisableDetection"), "NVIDIA5.x");
            checkBox_DisableDetectionNVidia3X.Text     = String.Format(International.GetText("Form_Settings_General_DisableDetection"), "NVIDIA3.x");
            checkBox_DisableDetectionNVidia2X.Text     = String.Format(International.GetText("Form_Settings_General_DisableDetection"), "NVIDIA2.x");
            checkBox_DisableDetectionAMD.Text          = String.Format(International.GetText("Form_Settings_General_DisableDetection"), "AMD");
            checkBox_AutoScaleBTCValues.Text           = International.GetText("Form_Settings_General_AutoScaleBTCValues");
            checkBox_StartMiningWhenIdle.Text          = International.GetText("Form_Settings_General_StartMiningWhenIdle");
            checkBox_ShowDriverVersionWarning.Text     = International.GetText("Form_Settings_General_ShowDriverVersionWarning");
            checkBox_DisableWindowsErrorReporting.Text = International.GetText("Form_Settings_General_DisableWindowsErrorReporting");
            //checkBox_UseNewSettingsPage.Text = International.GetText("Form_Settings_General_UseNewSettingsPage");
            checkBox_NVIDIAP0State.Text = International.GetText("Form_Settings_General_NVIDIAP0State");
            checkBox_LogToFile.Text     = International.GetText("Form_Settings_General_LogToFile");

            label_Language.Text              = International.GetText("Form_Settings_General_Language") + ":";
            label_BitcoinAddress.Text        = International.GetText("BitcoinAddress") + ":";
            label_WorkerName.Text            = International.GetText("WorkerName") + ":";
            label_ServiceLocation.Text       = International.GetText("Service_Location") + ":";
            label_MinIdleSeconds.Text        = International.GetText("Form_Settings_General_MinIdleSeconds") + ":";
            label_MinerRestartDelayMS.Text   = International.GetText("Form_Settings_General_MinerRestartDelayMS") + ":";
            label_MinerAPIQueryInterval.Text = International.GetText("Form_Settings_General_MinerAPIQueryInterval") + ":";
            label_LogMaxFileSize.Text        = International.GetText("Form_Settings_General_LogMaxFileSize") + ":";

            label_SwitchMinSecondsFixed.Text   = International.GetText("Form_Settings_General_SwitchMinSecondsFixed") + ":";
            label_SwitchMinSecondsDynamic.Text = International.GetText("Form_Settings_General_SwitchMinSecondsDynamic") + ":";
            label_SwitchMinSecondsAMD.Text     = International.GetText("Form_Settings_General_SwitchMinSecondsAMD") + ":";

            label_ethminerDefaultBlockHeight.Text = International.GetText("Form_Settings_General_ethminerDefaultBlockHeight") + ":";
            label_DagGeneration.Text    = International.GetText("Form_Settings_DagGeneration") + ":";
            label_APIBindPortStart.Text = International.GetText("Form_Settings_APIBindPortStart") + ":";

            label_MinProfit.Text = International.GetText("Form_Settings_General_MinimumProfit") + ":";

            label_displayCurrency.Text = International.GetText("Form_Settings_DisplayCurrency");

            // Benchmark time limits
            // internationalization change
            groupBoxBenchmarkTimeLimits.Text      = International.GetText("Form_Settings_General_BenchmarkTimeLimits_Title") + ":";
            benchmarkLimitControlCPU.GroupName    = International.GetText("Form_Settings_General_BenchmarkTimeLimitsCPU_Group") + ":";
            benchmarkLimitControlNVIDIA.GroupName = International.GetText("Form_Settings_General_BenchmarkTimeLimitsNVIDIA_Group") + ":";
            benchmarkLimitControlAMD.GroupName    = International.GetText("Form_Settings_General_BenchmarkTimeLimitsAMD_Group") + ":";
            // moved from constructor because of editor
            benchmarkLimitControlCPU.InitLocale();
            benchmarkLimitControlNVIDIA.InitLocale();
            benchmarkLimitControlAMD.InitLocale();

            // device enabled listview translation
            devicesListViewEnableControl1.InitLocale();
            algorithmsListView1.InitLocale();

            // Setup Tooltips CPU
            label_CPU0_ForceCPUExtension.Text = International.GetText("Form_Settings_General_CPU_ForceCPUExtension") + ":";
            // new translations
            tabControlGeneral.TabPages[0].Text = International.GetText("FormSettings_Tab_General");
            tabControlGeneral.TabPages[1].Text = International.GetText("FormSettings_Tab_Advanced");
            tabControlGeneral.TabPages[2].Text = International.GetText("FormSettings_Tab_Devices_Algorithms");
            groupBox_Main.Text         = International.GetText("FormSettings_Tab_General_Group_Main");
            groupBox_Localization.Text = International.GetText("FormSettings_Tab_General_Group_Localization");
            groupBox_Logging.Text      = International.GetText("FormSettings_Tab_General_Group_Logging");
            groupBox_Misc.Text         = International.GetText("FormSettings_Tab_General_Group_Misc");
            // advanced
            groupBox_Miners.Text             = International.GetText("FormSettings_Tab_Advanced_Group_Miners");
            groupBoxBenchmarkTimeLimits.Text = International.GetText("FormSettings_Tab_Advanced_Group_BenchmarkTimeLimits");

            buttonAllProfit.Text      = International.GetText("FormSettings_Tab_Devices_Algorithms_Check_ALLProfitability");
            buttonSelectedProfit.Text = International.GetText("FormSettings_Tab_Devices_Algorithms_Check_SingleProfitability");
        }
Пример #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello w");

            LoggingSettings.Folder           = @"C:\WORKPLACE\Jaffa\Log\";
            LoggingSettings.FileName         = @"syslog[@].txt";
            LoggingSettings.LoggingMode      = LoggingMode.Week;
            LoggingSettings.FrameworkMessage = true;

            Logging.LogWriting     += Logging_LogWriting;
            Logging.LogWriteWaiting = false;

            Logging.Write(International.GetDisplayLanguageName("Auto"));
            Logging.Write(International.GetDisplayLanguageName("ja-JP"));
            Logging.Write(International.GetDisplayLanguageName("en-US"));

            Logging.Write("[LangCodeList]");
            Logging.Write("--------------------");
            foreach (string s in International.GetAvailableLanguageCodeList())
            {
                Logging.Write(s);
            }
            Logging.Write("--------------------");

            Logging.Write("[LangNameList]");
            Logging.Write("--------------------");
            foreach (string s in International.GetAvailableLanguageNameList())
            {
                Logging.Write(s);
            }
            Logging.Write("--------------------");

            International.ChangeCultureFromDisplayLanguageName("English");
            Jaffa.DateTime.DifferenceNow = new TimeSpan(24, 0, 0);

            Logging.Write("[LangNameList]");
            Logging.Write("--------------------");
            foreach (string s in International.GetAvailableLanguageNameList())
            {
                Logging.Write(s);
            }
            Logging.Write("--------------------");

            try
            {
                Core.SetResource("SHELL", "JaffaShell.Resources." + International.CurrentCulture + ".Resource", Assembly.GetExecutingAssembly());
                throw new Exception(Core.MakeMessage("SHELL", "{TEST_MESSAGE}"));
            }
            catch (Exception e)
            {
                Logging.Write(Logging.ExceptionToList(e), LogType.Error);
            }

            International.ChangeCultureFromDisplayLanguageName("日本語");

            Jaffa.DateTime.DifferenceNow = new TimeSpan(0, 0, 0);
            try
            {
                func01();
            }
            catch (Exception e)
            {
                Logging.Write(Logging.ExceptionToList(e), LogType.Error);
            }
            Logging.Write();
        }
Пример #13
0
        public void QueryDevices(IMessageNotifier messageNotifier)
        {
            MessageNotifier = messageNotifier;
            // #0 get video controllers, used for cross checking
            QueryVideoControllers();
            // Order important CPU Query must be first
            // #1 CPU
            QueryCPUs();
            // #2 CUDA
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
            QueryCudaDevices();
            // #3 OpenCL
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
            QueryOpenCLDevices();
            // #4 AMD query AMD from OpenCL devices, get serial and add devices
            QueryAMD();
            // #5 uncheck CPU if GPUs present, call it after we Query all devices
            UncheckedCPU();
            // add numberings to same devices
            if (ComputeDevice.AllAvaliableDevices.Count != ComputeDevice.UniqueAvaliableDevices.Count)
            {
                // name count
                Dictionary <string, int> namesCount = new Dictionary <string, int>();
                // init keys and counters
                foreach (var uniqueCdev in ComputeDevice.UniqueAvaliableDevices)
                {
                    namesCount.Add(uniqueCdev.Name, 0);
                }
                // count
                foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                {
                    namesCount[cDev.Name]++;
                }
                foreach (var nameCount in namesCount)
                {
                    string name        = nameCount.Key;
                    int    deviceCount = nameCount.Value;
                    if (deviceCount > 1)
                    {
                        int numID = 1;
                        foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                        {
                            if (cDev.Name == name)
                            {
                                cDev.Name = cDev.Name + " #" + numID.ToString();
                                ++numID;
                            }
                        }
                    }
                }
            }


            // TODO update this to report undetected hardware
            // #6 check NVIDIA, AMD devices count
            {
                int NVIDIA_count = 0;
                int AMD_count    = 0;
                foreach (var vidCtrl in AvaliableVideoControllers)
                {
                    NVIDIA_count += (vidCtrl.Name.ToLower().Contains("nvidia")) ? 1 : 0;
                    AMD_count    += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                }
                if (NVIDIA_count == CudaDevices.Count)
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count BAD!!!");
                }
                if (AMD_count == amdGpus.Count)
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count BAD!!!");
                }
            }
            // allerts
            _currentNvidiaOpenCLDriver = GetNvidiaOpenCLDriver();
            // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
            bool isNvidiaErrorShown = false; // to prevent showing twice

            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && CudaDevices.Count == 0)
            {
                isNvidiaErrorShown = true;
                var minDriver      = NVIDIA_MIN_DETECTION_DRIVER.ToString();
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                                              minDriver, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            // recomended driver
            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && _currentNvidiaOpenCLDriver < NVIDIA_RECOMENDED_DRIVER && !isNvidiaErrorShown && _currentNvidiaOpenCLDriver > -1)
            {
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                var nvdriverString = _currentNvidiaOpenCLDriver > -1 ? String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"), _currentNvidiaOpenCLDriver.ToString())
                : "";
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                                              recomendDrvier, nvdriverString, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // #x remove reference
            MessageNotifier = null;
        }
        private void listViewDevices_MouseClick(object sender, MouseEventArgs e)
        {
            if (IsInBenchmark)
            {
                return;
            }
            if (IsMining)
            {
                return;
            }
            if (e.Button == MouseButtons.Right)
            {
                if (listViewDevices.FocusedItem.Bounds.Contains(e.Location) == true)
                {
                    contextMenuStrip1.Items.Clear();

                    var tsi = new ToolStripMenuItem("Rename", null, (o, args) =>
                    {
                        var d = listViewDevices.FocusedItem;

                        var renameForm = new Form_DeviceRename();
                        renameForm.SetCurrentName(d.Text);

                        if (renameForm.ShowDialog() == DialogResult.OK)
                        {
                            d.Text = renameForm.NewName;
                            SettingsUtil.SetNameForDevice(d.Text, (d.Tag as ComputeDevice).UUID);
                            SettingsUtil.SaveSettings();
                        }
                    });

                    contextMenuStrip1.Items.Add(tsi);

                    if (IsSettingsCopyEnabled)
                    {
                        var CDevice = listViewDevices.FocusedItem.Tag as ComputeDevice;

                        var sameDevTypes = ComputeDeviceManager.Avaliable.GetSameDevicesTypeAsDeviceWithUUID(CDevice.UUID);
                        if (sameDevTypes.Count > 0)
                        {
                            var copyBenchItem = new ToolStripMenuItem();
                            //copyBenchItem.DropDownItems
                            foreach (var cDev in sameDevTypes)
                            {
                                if (cDev.Enabled)
                                {
                                    var copyBenchDropDownItem = new ToolStripMenuItem();
                                    copyBenchDropDownItem.Text    = cDev.Name;
                                    copyBenchDropDownItem.Checked = cDev.UUID == CDevice.BenchmarkCopyUUID;
                                    copyBenchDropDownItem.Click  += toolStripMenuItemCopySettings_Click;
                                    copyBenchDropDownItem.Tag     = cDev.UUID;
                                    copyBenchItem.DropDownItems.Add(copyBenchDropDownItem);
                                }
                            }
                            copyBenchItem.Text = International.GetText("DeviceListView_ContextMenu_CopySettings");
                            contextMenuStrip1.Items.Add(copyBenchItem);
                        }
                    }

                    contextMenuStrip1.Show(Cursor.Position);
                }
            }
        }
Пример #15
0
        private void UnzipThreadRoutine()
        {
            try
            {
                if (File.Exists(_downloadSetup.BinsZipLocation))
                {
                    Helpers.ConsolePrint(Tag, _downloadSetup.BinsZipLocation + " already downloaded");
                    Helpers.ConsolePrint(Tag, "unzipping");

                    // if using other formats as zip are returning 0
                    var fileArchive = new FileInfo(_downloadSetup.BinsZipLocation);
                    var archive     = ArchiveFactory.Open(_downloadSetup.BinsZipLocation);
                    _minerUpdateIndicator.SetMaxProgressValue(100);
                    long sizeCount = 0;
                    foreach (var entry in archive.Entries)
                    {
                        if (!entry.IsDirectory)
                        {
                            sizeCount += entry.CompressedSize;
                            Helpers.ConsolePrint(Tag, entry.Key);
                            entry.WriteToDirectory("", ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);

                            var prog = sizeCount / (double)fileArchive.Length * 100;
                            _minerUpdateIndicator.SetProgressValueAndMsg((int)prog,
                                                                         string.Format(International.GetText("MinersDownloadManager_Title_Settup_Unzipping"), prog.ToString("F2")));
                        }
                    }
                    archive.Dispose();
                    // after unzip stuff
                    _minerUpdateIndicator.FinishMsg(true);
                    // remove bins zip
                    try
                    {
                        if (File.Exists(_downloadSetup.BinsZipLocation))
                        {
                            File.Delete(_downloadSetup.BinsZipLocation);
                        }
                    }
                    catch (Exception e)
                    {
                        Helpers.ConsolePrint("MinersDownloader.UnzipThreadRoutine", "Cannot delete exception: " + e.Message);
                    }
                }
                else
                {
                    Helpers.ConsolePrint(Tag, $"UnzipThreadRoutine {_downloadSetup.BinsZipLocation} file not found");
                }
            }
            catch (Exception e)
            {
                Helpers.ConsolePrint(Tag, "UnzipThreadRoutine has encountered an error: " + e.Message);
            }
        }
Пример #16
0
        private void InitializeToolTip()
        {
            // Setup Tooltips
            toolTip1.SetToolTip(this.comboBox_Language, International.GetText("Form_Settings_ToolTip_Language"));
            toolTip1.SetToolTip(this.label_Language, International.GetText("Form_Settings_ToolTip_Language"));
            toolTip1.SetToolTip(this.pictureBox_Language, International.GetText("Form_Settings_ToolTip_Language"));

            toolTip1.SetToolTip(this.checkBox_DebugConsole, International.GetText("Form_Settings_ToolTip_checkBox_DebugConsole"));
            toolTip1.SetToolTip(this.pictureBox_DebugConsole, International.GetText("Form_Settings_ToolTip_checkBox_DebugConsole"));

            toolTip1.SetToolTip(this.textBox_BitcoinAddress, International.GetText("Form_Settings_ToolTip_BitcoinAddress"));
            toolTip1.SetToolTip(this.label_BitcoinAddress, International.GetText("Form_Settings_ToolTip_BitcoinAddress"));
            toolTip1.SetToolTip(this.pictureBox_Info_BitcoinAddress, International.GetText("Form_Settings_ToolTip_BitcoinAddress"));

            toolTip1.SetToolTip(this.textBox_WorkerName, International.GetText("Form_Settings_ToolTip_WorkerName"));
            toolTip1.SetToolTip(this.label_WorkerName, International.GetText("Form_Settings_ToolTip_WorkerName"));
            toolTip1.SetToolTip(this.pictureBox_WorkerName, International.GetText("Form_Settings_ToolTip_WorkerName"));

            toolTip1.SetToolTip(this.comboBox_ServiceLocation, International.GetText("Form_Settings_ToolTip_ServiceLocation"));
            toolTip1.SetToolTip(this.label_ServiceLocation, International.GetText("Form_Settings_ToolTip_ServiceLocation"));
            toolTip1.SetToolTip(this.pictureBox_ServiceLocation, International.GetText("Form_Settings_ToolTip_ServiceLocation"));

            toolTip1.SetToolTip(this.checkBox_HideMiningWindows, International.GetText("Form_Settings_ToolTip_checkBox_HideMiningWindows"));
            toolTip1.SetToolTip(this.pictureBox_HideMiningWindows, International.GetText("Form_Settings_ToolTip_checkBox_HideMiningWindows"));

            toolTip1.SetToolTip(this.checkBox_MinimizeToTray, International.GetText("Form_Settings_ToolTip_checkBox_MinimizeToTray"));
            toolTip1.SetToolTip(this.pictureBox_MinimizeToTray, International.GetText("Form_Settings_ToolTip_checkBox_MinimizeToTray"));


            toolTip1.SetToolTip(this.textBox_SwitchMinSecondsFixed, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsFixed"));
            toolTip1.SetToolTip(this.label_SwitchMinSecondsFixed, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsFixed"));
            toolTip1.SetToolTip(this.pictureBox_SwitchMinSecondsFixed, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsFixed"));

            toolTip1.SetToolTip(this.label_MinProfit, International.GetText("Form_Settings_ToolTip_MinimumProfit"));
            toolTip1.SetToolTip(this.pictureBox_MinProfit, International.GetText("Form_Settings_ToolTip_MinimumProfit"));
            toolTip1.SetToolTip(this.textBox_MinProfit, International.GetText("Form_Settings_ToolTip_MinimumProfit"));

            toolTip1.SetToolTip(this.textBox_SwitchMinSecondsDynamic, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsDynamic"));
            toolTip1.SetToolTip(this.label_SwitchMinSecondsDynamic, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsDynamic"));
            toolTip1.SetToolTip(this.pictureBox_SwitchMinSecondsDynamic, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsDynamic"));

            toolTip1.SetToolTip(this.textBox_SwitchMinSecondsAMD, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsAMD"));
            toolTip1.SetToolTip(this.label_SwitchMinSecondsAMD, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsAMD"));
            toolTip1.SetToolTip(this.pictureBox_SwitchMinSecondsAMD, International.GetText("Form_Settings_ToolTip_SwitchMinSecondsAMD"));

            toolTip1.SetToolTip(this.textBox_MinerAPIQueryInterval, International.GetText("Form_Settings_ToolTip_MinerAPIQueryInterval"));
            toolTip1.SetToolTip(this.label_MinerAPIQueryInterval, International.GetText("Form_Settings_ToolTip_MinerAPIQueryInterval"));
            toolTip1.SetToolTip(this.pictureBox_MinerAPIQueryInterval, International.GetText("Form_Settings_ToolTip_MinerAPIQueryInterval"));

            toolTip1.SetToolTip(this.textBox_MinerRestartDelayMS, International.GetText("Form_Settings_ToolTip_MinerRestartDelayMS"));
            toolTip1.SetToolTip(this.label_MinerRestartDelayMS, International.GetText("Form_Settings_ToolTip_MinerRestartDelayMS"));
            toolTip1.SetToolTip(this.pictureBox_MinerRestartDelayMS, International.GetText("Form_Settings_ToolTip_MinerRestartDelayMS"));

            toolTip1.SetToolTip(this.textBox_APIBindPortStart, International.GetText("Form_Settings_ToolTip_APIBindPortStart"));
            toolTip1.SetToolTip(this.label_APIBindPortStart, International.GetText("Form_Settings_ToolTip_APIBindPortStart"));
            toolTip1.SetToolTip(this.pictureBox_APIBindPortStart, International.GetText("Form_Settings_ToolTip_APIBindPortStart"));

            toolTip1.SetToolTip(this.comboBox_DagLoadMode, International.GetText("Form_Settings_ToolTip_DagGeneration"));
            toolTip1.SetToolTip(this.label_DagGeneration, International.GetText("Form_Settings_ToolTip_DagGeneration"));
            toolTip1.SetToolTip(this.pictureBox_DagGeneration, International.GetText("Form_Settings_ToolTip_DagGeneration"));

            benchmarkLimitControlCPU.SetToolTip(ref toolTip1, "CPUs");
            benchmarkLimitControlNVIDIA.SetToolTip(ref toolTip1, "NVIDIA GPUs");
            benchmarkLimitControlAMD.SetToolTip(ref toolTip1, "AMD GPUs");

            toolTip1.SetToolTip(this.checkBox_DisableDetectionNVidia6X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA6.x"));
            toolTip1.SetToolTip(this.checkBox_DisableDetectionNVidia5X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA5.x"));
            toolTip1.SetToolTip(this.checkBox_DisableDetectionNVidia3X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA3.x"));
            toolTip1.SetToolTip(this.checkBox_DisableDetectionNVidia2X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA2.x"));
            toolTip1.SetToolTip(this.checkBox_DisableDetectionAMD, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "AMD"));
            toolTip1.SetToolTip(this.pictureBox_DisableDetectionNVidia6X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA6.x"));
            toolTip1.SetToolTip(this.pictureBox_DisableDetectionNVidia5X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA5.x"));
            toolTip1.SetToolTip(this.pictureBox_DisableDetectionNVidia3X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA3.x"));
            toolTip1.SetToolTip(this.pictureBox_DisableDetectionNVidia2X, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "NVIDIA2.x"));
            toolTip1.SetToolTip(this.pictureBox_DisableDetectionAMD, String.Format(International.GetText("Form_Settings_ToolTip_checkBox_DisableDetection"), "AMD"));

            toolTip1.SetToolTip(this.checkBox_AutoScaleBTCValues, International.GetText("Form_Settings_ToolTip_checkBox_AutoScaleBTCValues"));
            toolTip1.SetToolTip(this.pictureBox_AutoScaleBTCValues, International.GetText("Form_Settings_ToolTip_checkBox_AutoScaleBTCValues"));

            toolTip1.SetToolTip(this.checkBox_StartMiningWhenIdle, International.GetText("Form_Settings_ToolTip_checkBox_StartMiningWhenIdle"));
            toolTip1.SetToolTip(this.pictureBox_StartMiningWhenIdle, International.GetText("Form_Settings_ToolTip_checkBox_StartMiningWhenIdle"));

            toolTip1.SetToolTip(this.textBox_MinIdleSeconds, International.GetText("Form_Settings_ToolTip_MinIdleSeconds"));
            toolTip1.SetToolTip(this.label_MinIdleSeconds, International.GetText("Form_Settings_ToolTip_MinIdleSeconds"));
            toolTip1.SetToolTip(this.pictureBox_MinIdleSeconds, International.GetText("Form_Settings_ToolTip_MinIdleSeconds"));

            toolTip1.SetToolTip(this.checkBox_LogToFile, International.GetText("Form_Settings_ToolTip_checkBox_LogToFile"));
            toolTip1.SetToolTip(this.pictureBox_LogToFile, International.GetText("Form_Settings_ToolTip_checkBox_LogToFile"));


            toolTip1.SetToolTip(this.textBox_LogMaxFileSize, International.GetText("Form_Settings_ToolTip_LogMaxFileSize"));
            toolTip1.SetToolTip(this.label_LogMaxFileSize, International.GetText("Form_Settings_ToolTip_LogMaxFileSize"));
            toolTip1.SetToolTip(this.pictureBox_LogMaxFileSize, International.GetText("Form_Settings_ToolTip_LogMaxFileSize"));

            toolTip1.SetToolTip(this.checkBox_ShowDriverVersionWarning, International.GetText("Form_Settings_ToolTip_checkBox_ShowDriverVersionWarning"));
            toolTip1.SetToolTip(this.pictureBox_ShowDriverVersionWarning, International.GetText("Form_Settings_ToolTip_checkBox_ShowDriverVersionWarning"));

            toolTip1.SetToolTip(this.checkBox_DisableWindowsErrorReporting, International.GetText("Form_Settings_ToolTip_checkBox_DisableWindowsErrorReporting"));
            toolTip1.SetToolTip(this.pictureBox_DisableWindowsErrorReporting, International.GetText("Form_Settings_ToolTip_checkBox_DisableWindowsErrorReporting"));

            toolTip1.SetToolTip(this.checkBox_NVIDIAP0State, International.GetText("Form_Settings_ToolTip_checkBox_NVIDIAP0State"));
            toolTip1.SetToolTip(this.pictureBox_NVIDIAP0State, International.GetText("Form_Settings_ToolTip_checkBox_NVIDIAP0State"));


            toolTip1.SetToolTip(this.checkBox_AutoStartMining, International.GetText("Form_Settings_ToolTip_checkBox_AutoStartMining"));
            toolTip1.SetToolTip(this.pictureBox_AutoStartMining, International.GetText("Form_Settings_ToolTip_checkBox_AutoStartMining"));


            toolTip1.SetToolTip(this.textBox_ethminerDefaultBlockHeight, International.GetText("Form_Settings_ToolTip_ethminerDefaultBlockHeight"));
            toolTip1.SetToolTip(this.label_ethminerDefaultBlockHeight, International.GetText("Form_Settings_ToolTip_ethminerDefaultBlockHeight"));
            toolTip1.SetToolTip(this.pictureBox_ethminerDefaultBlockHeight, International.GetText("Form_Settings_ToolTip_ethminerDefaultBlockHeight"));

            toolTip1.SetToolTip(this.label_displayCurrency, International.GetText("Form_Settings_ToolTip_DisplayCurrency"));
            toolTip1.SetToolTip(this.pictureBox_displayCurrency, International.GetText("Form_Settings_ToolTip_DisplayCurrency"));
            toolTip1.SetToolTip(this.currencyConverterCombobox, International.GetText("Form_Settings_ToolTip_DisplayCurrency"));

            // Setup Tooltips CPU
            toolTip1.SetToolTip(comboBox_CPU0_ForceCPUExtension, International.GetText("Form_Settings_ToolTip_CPU_ForceCPUExtension"));
            toolTip1.SetToolTip(label_CPU0_ForceCPUExtension, International.GetText("Form_Settings_ToolTip_CPU_ForceCPUExtension"));
            toolTip1.SetToolTip(pictureBox_CPU0_ForceCPUExtension, International.GetText("Form_Settings_ToolTip_CPU_ForceCPUExtension"));

            this.Text = International.GetText("Form_Settings_Title");

            algorithmSettingsControl1.InitLocale(toolTip1);
        }
Пример #17
0
        // benchmark stuff

        protected override void BenchmarkThreadRoutine(object CommandLine)
        {
            Thread.Sleep(ConfigManager.GeneralConfig.MinerRestartDelayMS);

            BenchmarkSignalQuit      = false;
            BenchmarkSignalHanged    = false;
            BenchmarkSignalFinnished = false;
            BenchmarkException       = null;

            try {
                Helpers.ConsolePrint("BENCHMARK", "Benchmark starts");
                Helpers.ConsolePrint(MinerTAG(), "Benchmark should end in : " + benchmarkTimeWait + " seconds");
                BenchmarkHandle = BenchmarkStartProcess((string)CommandLine);
                BenchmarkHandle.WaitForExit(benchmarkTimeWait + 2);
                Stopwatch _benchmarkTimer = new Stopwatch();
                _benchmarkTimer.Reset();
                _benchmarkTimer.Start();
                //BenchmarkThreadRoutineStartSettup();
                // wait a little longer then the benchmark routine if exit false throw
                //var timeoutTime = BenchmarkTimeoutInSeconds(BenchmarkTimeInSeconds);
                //var exitSucces = BenchmarkHandle.WaitForExit(timeoutTime * 1000);
                // don't use wait for it breaks everything
                BenchmarkProcessStatus = BenchmarkProcessStatus.Running;
                bool keepRunning = true;
                while (keepRunning && IsActiveProcess(BenchmarkHandle.Id))
                {
                    //string outdata = BenchmarkHandle.StandardOutput.ReadLine();
                    //BenchmarkOutputErrorDataReceivedImpl(outdata);
                    // terminate process situations
                    if (_benchmarkTimer.Elapsed.Seconds >= (benchmarkTimeWait + 2) ||
                        BenchmarkSignalQuit ||
                        BenchmarkSignalFinnished ||
                        BenchmarkSignalHanged ||
                        BenchmarkSignalTimedout ||
                        BenchmarkException != null)
                    {
                        // maybe will have to KILL process
                        KillClaymoreMinerBase(MinerExeName);
                        if (BenchmarkSignalTimedout)
                        {
                            throw new Exception("Benchmark timedout");
                        }
                        if (BenchmarkException != null)
                        {
                            throw BenchmarkException;
                        }
                        if (BenchmarkSignalQuit)
                        {
                            throw new Exception("Termined by user request");
                        }
                        if (BenchmarkSignalFinnished)
                        {
                            break;
                        }
                        keepRunning = false;
                        break;
                    }
                    else
                    {
                        // wait a second reduce CPU load
                        Thread.Sleep(1000);
                    }
                }
            } catch (Exception ex) {
                BenchmarkAlgorithm.BenchmarkSpeed = 0;
                Helpers.ConsolePrint(MinerTAG(), "Benchmark Exception: " + ex.Message);
                if (BenchmarkComunicator != null && !OnBenchmarkCompleteCalled)
                {
                    OnBenchmarkCompleteCalled = true;
                    BenchmarkComunicator.OnBenchmarkComplete(false, BenchmarkSignalTimedout ? International.GetText("Benchmark_Timedout") : International.GetText("Benchmark_Terminated"));
                }
            } finally {
                BenchmarkAlgorithm.BenchmarkSpeed = 0;
                BenchmarkProcessStatus            = BenchmarkProcessStatus.Finished;
                // find latest log file
                string latestLogFile = "";
                var    dirInfo       = new DirectoryInfo(this.WorkingDirectory);
                foreach (var file in dirInfo.GetFiles("*_log.txt"))
                {
                    latestLogFile = file.Name;
                    break;
                }
                // read file log
                if (File.Exists(WorkingDirectory + latestLogFile))
                {
                    var lines = File.ReadAllLines(WorkingDirectory + latestLogFile);
                    foreach (var line in lines)
                    {
                        if (line != null)
                        {
                            string lineLowered = line.ToLower();
                            if (lineLowered.Contains(LOOK_FOR_START))
                            {
                                benchmark_sum += getNumber(lineLowered);
                                ++benchmark_read_count;
                            }
                        }
                    }
                    if (benchmark_read_count > 0)
                    {
                        BenchmarkAlgorithm.BenchmarkSpeed = benchmark_sum / benchmark_read_count;
                        BenchmarkProcessStatus            = BenchmarkProcessStatus.Success;
                    }
                }
                Helpers.ConsolePrint("BENCHMARK", "Final Speed: " + Helpers.FormatSpeedOutput(BenchmarkAlgorithm.BenchmarkSpeed));
                Helpers.ConsolePrint("BENCHMARK", "Benchmark ends");
                if (BenchmarkComunicator != null && !OnBenchmarkCompleteCalled)
                {
                    OnBenchmarkCompleteCalled = true;
                    BenchmarkComunicator.OnBenchmarkComplete(true, "Success");
                }
            }
        }
Пример #18
0
 public void SetBenchmarkPending()
 {
     IsBenchmarkPending = true;
     BenchmarkStatus    = International.GetText("Algorithm_Waiting_Benchmark");
 }
 public void InitLocale()
 {
     labelQuick.Text    = International.GetText("Quick") + ":";
     labelStandard.Text = International.GetText("Standard") + ":";
     labelPrecise.Text  = International.GetText("Precise") + ":";
 }
        private void QueryAMD()
        {
            //showMessageAndStep(International.GetText("Form_Main_loadtext_AMD"));
            //var dump = new sgminer(true);

            if (ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionAMD)
            {
                Helpers.ConsolePrint(TAG, "Skipping AMD device detection, settings set to disabled");
                showMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query_Skip"));
                return;
            }

            #region AMD driver check, ADL returns 0
            // check the driver version bool EnableOptimizedVersion = true;
            Dictionary <string, bool> deviceDriverOld = new Dictionary <string, bool>();
            string minerPath         = MinerPaths.sgminer_5_5_0_general;
            bool   ShowWarningDialog = false;

            foreach (var vidContrllr in AvaliableVideoControllers)
            {
                Helpers.ConsolePrint(TAG, String.Format("Checking AMD device (driver): {0} ({1})", vidContrllr.Name, vidContrllr.DriverVersion));

                deviceDriverOld[vidContrllr.Name] = false;
                // TODO checking radeon drivers only?
                if ((vidContrllr.Name.Contains("AMD") || vidContrllr.Name.Contains("Radeon")) && ShowWarningDialog == false)
                {
                    Version AMDDriverVersion = new Version(vidContrllr.DriverVersion);

                    if (AMDDriverVersion.Major < 15)
                    {
                        ShowWarningDialog = true;
                        deviceDriverOld[vidContrllr.Name] = true;
                        Helpers.ConsolePrint(TAG, "WARNING!!! Old AMD GPU driver detected! All optimized versions disabled, mining " +
                                             "speed will not be optimal. Consider upgrading AMD GPU driver. Recommended AMD GPU driver version is 15.7.1.");
                    }
                    else if (AMDDriverVersion.Major == 16 && AMDDriverVersion.Minor >= 150)
                    {
                        if (MinersDownloadManager.Instance.IsMinerBinFolder())
                        {
                            // TODO why this copy?
                            string src = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" +
                                         minerPath.Split('\\')[0] + "\\" + minerPath.Split('\\')[1] + "\\kernel";

                            foreach (var file in Directory.GetFiles(src))
                            {
                                string dest = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\" + System.IO.Path.GetFileName(file);
                                if (!File.Exists(dest))
                                {
                                    File.Copy(file, dest, false);
                                }
                            }
                        }
                    }
                }
            }
            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && ShowWarningDialog == true)
            {
                Form WarningDialog = new DriverVersionConfirmationDialog();
                WarningDialog.ShowDialog();
                WarningDialog = null;
            }
            #endregion // AMD driver check

            // get platform version
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query"));
            if (IsOpenCLQuerrySuccess)
            {
                bool amdPlatformNumFound = false;
                foreach (var kvp in OpenCLJSONData.OCLPlatforms)
                {
                    if (kvp.Key.Contains("AMD") || kvp.Key.Contains("amd"))
                    {
                        amdPlatformNumFound        = true;
                        AMDOpenCLPlatformStringKey = kvp.Key;
                        AMDOpenCLPlatformNum       = kvp.Value;
                        Helpers.ConsolePrint(TAG, String.Format("AMD platform found: Key: {0}, Num: {1}",
                                                                AMDOpenCLPlatformStringKey,
                                                                AMDOpenCLPlatformNum.ToString()));
                        break;
                    }
                }
                if (amdPlatformNumFound)
                {
                    // get only AMD gpus
                    {
                        var amdOCLDevices = OpenCLJSONData.OCLPlatformDevices[AMDOpenCLPlatformStringKey];
                        foreach (var oclDev in amdOCLDevices)
                        {
                            if (oclDev._CL_DEVICE_TYPE.Contains("GPU"))
                            {
                                amdGpus.Add(oclDev);
                            }
                        }
                    }
                    if (amdGpus.Count == 0)
                    {
                        Helpers.ConsolePrint(TAG, "AMD GPUs count is 0");
                    }
                    else
                    {
                        Helpers.ConsolePrint(TAG, "AMD GPUs count : " + amdGpus.Count.ToString());
                        Helpers.ConsolePrint(TAG, "AMD Getting device name and serial from ADL");
                        // ADL
                        bool isAdlInit = true;
                        // ADL does not get devices in order map devices by bus number
                        // bus id, <name, uuid>
                        Dictionary <int, Tuple <string, string> > _busIdsInfo = new Dictionary <int, Tuple <string, string> >();
                        List <string> _amdDeviceName = new List <string>();
                        List <string> _amdDeviceUUID = new List <string>();
                        try {
                            int ADLRet           = -1;
                            int NumberOfAdapters = 0;
                            if (null != ADL.ADL_Main_Control_Create)
                            {
                                // Second parameter is 1: Get only the present adapters
                                ADLRet = ADL.ADL_Main_Control_Create(ADL.ADL_Main_Memory_Alloc, 1);
                            }
                            if (ADL.ADL_SUCCESS == ADLRet)
                            {
                                if (null != ADL.ADL_Adapter_NumberOfAdapters_Get)
                                {
                                    ADL.ADL_Adapter_NumberOfAdapters_Get(ref NumberOfAdapters);
                                }
                                Helpers.ConsolePrint(TAG, "Number Of Adapters: " + NumberOfAdapters.ToString());

                                if (0 < NumberOfAdapters)
                                {
                                    // Get OS adpater info from ADL
                                    ADLAdapterInfoArray OSAdapterInfoData;
                                    OSAdapterInfoData = new ADLAdapterInfoArray();

                                    if (null != ADL.ADL_Adapter_AdapterInfo_Get)
                                    {
                                        IntPtr AdapterBuffer = IntPtr.Zero;
                                        int    size          = Marshal.SizeOf(OSAdapterInfoData);
                                        AdapterBuffer = Marshal.AllocCoTaskMem((int)size);
                                        Marshal.StructureToPtr(OSAdapterInfoData, AdapterBuffer, false);

                                        if (null != ADL.ADL_Adapter_AdapterInfo_Get)
                                        {
                                            ADLRet = ADL.ADL_Adapter_AdapterInfo_Get(AdapterBuffer, size);
                                            if (ADL.ADL_SUCCESS == ADLRet)
                                            {
                                                OSAdapterInfoData = (ADLAdapterInfoArray)Marshal.PtrToStructure(AdapterBuffer, OSAdapterInfoData.GetType());
                                                int IsActive = 0;

                                                for (int i = 0; i < NumberOfAdapters; i++)
                                                {
                                                    // Check if the adapter is active
                                                    if (null != ADL.ADL_Adapter_Active_Get)
                                                    {
                                                        ADLRet = ADL.ADL_Adapter_Active_Get(OSAdapterInfoData.ADLAdapterInfo[i].AdapterIndex, ref IsActive);
                                                    }

                                                    if (ADL.ADL_SUCCESS == ADLRet)
                                                    {
                                                        // we are looking for amd
                                                        // TODO check discrete and integrated GPU separation
                                                        var vendorID = OSAdapterInfoData.ADLAdapterInfo[i].VendorID;
                                                        var devName  = OSAdapterInfoData.ADLAdapterInfo[i].AdapterName;
                                                        if (vendorID == AMD_VENDOR_ID ||
                                                            devName.ToLower().Contains("amd") ||
                                                            devName.ToLower().Contains("radeon") ||
                                                            devName.ToLower().Contains("firepro"))
                                                        {
                                                            string PNPStr        = OSAdapterInfoData.ADLAdapterInfo[i].PNPString;
                                                            var    backSlashLast = PNPStr.LastIndexOf('\\');
                                                            var    serial        = PNPStr.Substring(backSlashLast, PNPStr.Length - backSlashLast);
                                                            var    end_0         = serial.IndexOf('&');
                                                            var    end_1         = serial.IndexOf('&', end_0 + 1);
                                                            // get serial
                                                            serial = serial.Substring(end_0 + 1, (end_1 - end_0) - 1);

                                                            var udid = OSAdapterInfoData.ADLAdapterInfo[i].UDID;
                                                            var pciVen_id_strSize = 21; // PCI_VEN_XXXX&DEV_XXXX
                                                            var uuid  = udid.Substring(0, pciVen_id_strSize) + "_" + serial;
                                                            int budId = OSAdapterInfoData.ADLAdapterInfo[i].BusNumber;
                                                            if (!_amdDeviceUUID.Contains(uuid))
                                                            {
                                                                try {
                                                                    Helpers.ConsolePrint(TAG, String.Format("ADL device added BusNumber:{0}  NAME:{1}  UUID:{2}"),
                                                                                         budId,
                                                                                         devName,
                                                                                         uuid);
                                                                } catch { }

                                                                _amdDeviceUUID.Add(uuid);
                                                                //_busIds.Add(OSAdapterInfoData.ADLAdapterInfo[i].BusNumber);
                                                                _amdDeviceName.Add(devName);
                                                                if (!_busIdsInfo.ContainsKey(budId))
                                                                {
                                                                    var nameUuid = new Tuple <string, string>(devName, uuid);
                                                                    _busIdsInfo.Add(budId, nameUuid);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Helpers.ConsolePrint(TAG, "ADL_Adapter_AdapterInfo_Get() returned error code " + ADLRet.ToString());
                                            }
                                        }
                                        // Release the memory for the AdapterInfo structure
                                        if (IntPtr.Zero != AdapterBuffer)
                                        {
                                            Marshal.FreeCoTaskMem(AdapterBuffer);
                                        }
                                    }
                                }
                                if (null != ADL.ADL_Main_Control_Destroy)
                                {
                                    ADL.ADL_Main_Control_Destroy();
                                }
                            }
                            else
                            {
                                // TODO
                                Helpers.ConsolePrint(TAG, "ADL_Main_Control_Create() returned error code " + ADLRet.ToString());
                                Helpers.ConsolePrint(TAG, "Check if ADL is properly installed!");
                            }
                        } catch (Exception ex) {
                            Helpers.ConsolePrint(TAG, "AMD ADL exception: " + ex.Message);
                            isAdlInit = false;
                        }
                        if (isAdlInit)
                        {
                            if (amdGpus.Count == _amdDeviceUUID.Count)
                            {
                                Helpers.ConsolePrint(TAG, "AMD OpenCL and ADL AMD query COUNTS GOOD/SAME");
                            }
                            else
                            {
                                Helpers.ConsolePrint(TAG, "AMD OpenCL and ADL AMD query COUNTS DIFFERENT/BAD");
                            }
                            StringBuilder stringBuilder = new StringBuilder();
                            stringBuilder.AppendLine("");
                            stringBuilder.AppendLine("QueryAMD devices: ");
                            for (int i_id = 0; i_id < amdGpus.Count; ++i_id)
                            {
                                HasAMD = true;

                                int busID = amdGpus[i_id].AMD_BUS_ID;
                                if (busID != -1 && _busIdsInfo.ContainsKey(busID))
                                {
                                    var deviceName = _busIdsInfo[busID].Item1;
                                    var newAmdDev  = new AmdGpuDevice(amdGpus[i_id], deviceDriverOld[deviceName]);
                                    newAmdDev.DeviceName = deviceName;
                                    newAmdDev.UUID       = _busIdsInfo[busID].Item2;
                                    bool   isDisabledGroup    = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionAMD;
                                    string skipOrAdd          = isDisabledGroup ? "SKIPED" : "ADDED";
                                    string isDisabledGroupStr = isDisabledGroup ? " (AMD group disabled)" : "";
                                    string etherumCapableStr  = newAmdDev.IsEtherumCapable() ? "YES" : "NO";

                                    new ComputeDevice(newAmdDev, true, true);
                                    // just in case
                                    try {
                                        stringBuilder.AppendLine(String.Format("\t{0} device{1}:", skipOrAdd, isDisabledGroupStr));
                                        stringBuilder.AppendLine(String.Format("\t\tID: {0}", newAmdDev.DeviceID.ToString()));
                                        stringBuilder.AppendLine(String.Format("\t\tNAME: {0}", newAmdDev.DeviceName));
                                        stringBuilder.AppendLine(String.Format("\t\tCODE_NAME: {0}", newAmdDev.Codename));
                                        stringBuilder.AppendLine(String.Format("\t\tUUID: {0}", newAmdDev.UUID));
                                        stringBuilder.AppendLine(String.Format("\t\tMEMORY: {0}", newAmdDev.DeviceGlobalMemory.ToString()));
                                        stringBuilder.AppendLine(String.Format("\t\tETHEREUM: {0}", etherumCapableStr));
                                    } catch { }
                                }
                                else
                                {
                                    stringBuilder.AppendLine(String.Format("\tDevice not added, Bus No. {0} not found:", busID));
                                }
                            }
                            Helpers.ConsolePrint(TAG, stringBuilder.ToString());
                        }
                    }
                }
            }
        }
Пример #21
0
            public static void QueryDevices(IMessageNotifier messageNotifier)
            {
                // check NVIDIA nvml.dll and copy over scope
                {
                    var nvmlPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
                                   "\\NVIDIA Corporation\\NVSMI\\nvml.dll";
                    if (nvmlPath.Contains(" (x86)"))
                    {
                        nvmlPath = nvmlPath.Replace(" (x86)", "");
                    }
                    if (File.Exists(nvmlPath))
                    {
                        var copyToPath = Directory.GetCurrentDirectory() + "\\nvml.dll";
                        try
                        {
                            File.Copy(nvmlPath, copyToPath, true);
                            Helpers.ConsolePrint(Tag, $"Copy from {nvmlPath} to {copyToPath} done");
                        }
                        catch (Exception e)
                        {
                            Helpers.ConsolePrint(Tag, "Copy nvml.dll failed: " + e.Message);
                        }
                    }
                }


                MessageNotifier = messageNotifier;
                // #0 get video controllers, used for cross checking
                WindowsDisplayAdapters.QueryVideoControllers();
                // Order important CPU Query must be first
                // #1 CPU
                Cpu.QueryCpus();
                // #2 CUDA
                if (Nvidia.IsSkipNvidia())
                {
                    Helpers.ConsolePrint(Tag, "Skipping NVIDIA device detection, settings are set to disabled");
                }
                else
                {
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
                    Nvidia.QueryCudaDevices();
                }
                // OpenCL and AMD
                if (ConfigManager.GeneralConfig.DeviceDetection.DisableDetectionAMD)
                {
                    Helpers.ConsolePrint(Tag, "Skipping AMD device detection, settings set to disabled");
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query_Skip"));
                }
                else
                {
                    // #3 OpenCL
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
                    OpenCL.QueryOpenCLDevices();
                    // #4 AMD query AMD from OpenCL devices, get serial and add devices
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query"));
                    var amd = new AmdQuery(AvaliableVideoControllers);
                    AmdDevices = amd.QueryAmd(_isOpenCLQuerySuccess, _openCLJsonData);
                }
                // #5 uncheck CPU if GPUs present, call it after we Query all devices
                Group.UncheckedCpu();

                // TODO update this to report undetected hardware
                // #6 check NVIDIA, AMD devices count
                var nvidiaCount = 0;

                {
                    var amdCount = 0;
                    foreach (var vidCtrl in AvaliableVideoControllers)
                    {
                        if (vidCtrl.Name.ToLower().Contains("nvidia") && CudaUnsupported.IsSupported(vidCtrl.Name))
                        {
                            nvidiaCount += 1;
                        }
                        else if (vidCtrl.Name.ToLower().Contains("nvidia"))
                        {
                            Helpers.ConsolePrint(Tag,
                                                 "Device not supported NVIDIA/CUDA device not supported " + vidCtrl.Name);
                        }
                        amdCount += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                    }
                    Helpers.ConsolePrint(Tag,
                                         nvidiaCount == _cudaDevices.Count
                            ? "Cuda NVIDIA/CUDA device count GOOD"
                            : "Cuda NVIDIA/CUDA device count BAD!!!");
                    Helpers.ConsolePrint(Tag,
                                         amdCount == AmdDevices.Count ? "AMD GPU device count GOOD" : "AMD GPU device count BAD!!!");
                }
                // allerts
                _currentNvidiaSmiDriver = GetNvidiaSmiDriver();
                // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
                var isNvidiaErrorShown = false; // to prevent showing twice
                var showWarning        = ConfigManager.GeneralConfig.ShowDriverVersionWarning &&
                                         WindowsDisplayAdapters.HasNvidiaVideoController();

                if (showWarning && _cudaDevices.Count != nvidiaCount &&
                    _currentNvidiaSmiDriver.IsLesserVersionThan(NvidiaMinDetectionDriver))
                {
                    isNvidiaErrorShown = true;
                    var minDriver      = NvidiaMinDetectionDriver.ToString();
                    var recomendDrvier = NvidiaRecomendedDriver.ToString();
                    MessageBox.Show(string.Format(
                                        International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                                        minDriver, recomendDrvier),
                                    International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // recomended driver
                if (showWarning && _currentNvidiaSmiDriver.IsLesserVersionThan(NvidiaRecomendedDriver) &&
                    !isNvidiaErrorShown && _currentNvidiaSmiDriver.LeftPart > -1)
                {
                    var recomendDrvier = NvidiaRecomendedDriver.ToString();
                    var nvdriverString = _currentNvidiaSmiDriver.LeftPart > -1
                        ? string.Format(
                        International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"),
                        _currentNvidiaSmiDriver)
                        : "";
                    MessageBox.Show(string.Format(
                                        International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                                        recomendDrvier, nvdriverString, recomendDrvier),
                                    International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                // no devices found
                if (Available.Devices.Count <= 0)
                {
                    var result = MessageBox.Show(International.GetText("Compute_Device_Query_Manager_No_Devices"),
                                                 International.GetText("Compute_Device_Query_Manager_No_Devices_Title"),
                                                 MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        Process.Start(Links.NhmNoDevHelp);
                    }
                }

                // create AMD bus ordering for Claymore
                var amdDevices = Available.Devices.FindAll((a) => a.DeviceType == DeviceType.AMD);

                amdDevices.Sort((a, b) => a.BusID.CompareTo(b.BusID));
                for (var i = 0; i < amdDevices.Count; i++)
                {
                    amdDevices[i].IDByBus = i;
                }
                //create NV bus ordering for Claymore
                var nvDevices = Available.Devices.FindAll((a) => a.DeviceType == DeviceType.NVIDIA);

                nvDevices.Sort((a, b) => a.BusID.CompareTo(b.BusID));
                for (var i = 0; i < nvDevices.Count; i++)
                {
                    nvDevices[i].IDByBus = i;
                }

                // get GPUs RAM sum
                // bytes
                Available.NvidiaRamSum = 0;
                Available.AmdRamSum    = 0;
                foreach (var dev in Available.Devices)
                {
                    if (dev.DeviceType == DeviceType.NVIDIA)
                    {
                        Available.NvidiaRamSum += dev.GpuRam;
                    }
                    else if (dev.DeviceType == DeviceType.AMD)
                    {
                        Available.AmdRamSum += dev.GpuRam;
                    }
                }
                // Make gpu ram needed not larger than 4GB per GPU
                var totalGpuRam = Math.Min((Available.NvidiaRamSum + Available.AmdRamSum) * 0.6 / 1024,
                                           (double)Available.AvailGpUs * 4 * 1024 * 1024);
                double totalSysRam = SystemSpecs.FreePhysicalMemory + SystemSpecs.FreeVirtualMemory;

                // check
                if (ConfigManager.GeneralConfig.ShowDriverVersionWarning && totalSysRam < totalGpuRam)
                {
                    Helpers.ConsolePrint(Tag, "virtual memory size BAD");
                    MessageBox.Show(International.GetText("VirtualMemorySize_BAD"),
                                    International.GetText("Warning_with_Exclamation"),
                                    MessageBoxButtons.OK);
                }
                else
                {
                    Helpers.ConsolePrint(Tag, "virtual memory size GOOD");
                }

                // #x remove reference
                MessageNotifier = null;
            }
        public void QueryDevices(IMessageNotifier messageNotifier)
        {
            MessageNotifier = messageNotifier;
            // #0 get video controllers, used for cross checking
            QueryVideoControllers();
            // Order important CPU Query must be first
            // #1 CPU
            QueryCPUs();
            // #2 CUDA
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
            QueryCudaDevices();
            // #3 OpenCL
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
            QueryOpenCLDevices();
            // #4 AMD query AMD from OpenCL devices, get serial and add devices
            QueryAMD();
            // #5 uncheck CPU if GPUs present, call it after we Query all devices
            UncheckedCPU();
            // add numberings to same devices
            if (ComputeDevice.AllAvaliableDevices.Count != ComputeDevice.UniqueAvaliableDevices.Count)
            {
                // name count
                Dictionary <string, int> namesCount = new Dictionary <string, int>();
                // init keys and counters
                foreach (var uniqueCdev in ComputeDevice.UniqueAvaliableDevices)
                {
                    namesCount.Add(uniqueCdev.Name, 0);
                }
                // count
                foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                {
                    namesCount[cDev.Name]++;
                }
                foreach (var nameCount in namesCount)
                {
                    string name        = nameCount.Key;
                    int    deviceCount = nameCount.Value;
                    if (deviceCount > 1)
                    {
                        int numID = 1;
                        foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                        {
                            if (cDev.Name == name)
                            {
                                cDev.Name = cDev.Name + " #" + numID.ToString();
                                ++numID;
                            }
                        }
                    }
                }
            }


            // TODO update this to report undetected hardware
            // #6 check NVIDIA, AMD devices count
            {
                int NVIDIA_count = 0;
                int AMD_count    = 0;
                foreach (var vidCtrl in AvaliableVideoControllers)
                {
                    NVIDIA_count += (vidCtrl.Name.ToLower().Contains("nvidia")) ? 1 : 0;
                    AMD_count    += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                }
                if (NVIDIA_count == CudaDevices.Count)
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count BAD!!!");
                }
                if (AMD_count == amdGpus.Count)
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count BAD!!!");
                }
            }
            // #7 init ethminer ID mappings offset
            if (OpenCLJSONData != null)
            {
                // helper vars
                Dictionary <ComputePlatformType, int> openCLGpuCount    = new Dictionary <ComputePlatformType, int>();
                Dictionary <ComputePlatformType, int> openCLPlatformIds = new Dictionary <ComputePlatformType, int>();
                foreach (var oclPlatform in OpenCLJSONData.OCLPlatforms)
                {
                    ComputePlatformType current = GetPlatformType(oclPlatform.Key);
                    if (current != ComputePlatformType.NONE)
                    {
                        openCLPlatformIds[current] = oclPlatform.Value;
                    }
                    else
                    {
                        Helpers.ConsolePrint(TAG, "ethminer platforms mapping NONE");
                    }
                }
                foreach (var oclDevs in OpenCLJSONData.OCLPlatformDevices)
                {
                    ComputePlatformType current = GetPlatformType(oclDevs.Key);
                    if (current != ComputePlatformType.NONE)
                    {
                        foreach (var oclDev in oclDevs.Value)
                        {
                            if (oclDev._CL_DEVICE_TYPE.Contains("GPU"))
                            {
                                if (openCLGpuCount.ContainsKey(current))
                                {
                                    openCLGpuCount[current]++;
                                }
                                else
                                {
                                    openCLGpuCount[current] = 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        Helpers.ConsolePrint(TAG, "ethminer platforms mapping NONE");
                    }
                }
                // sort platforms by platform values
                Dictionary <int, ComputePlatformType> openCLPlatformIdsRev = new Dictionary <int, ComputePlatformType>();
                List <int> platformIds = new List <int>();
                foreach (var platId in openCLPlatformIds)
                {
                    openCLPlatformIdsRev[platId.Value] = platId.Key;
                    platformIds.Add(platId.Value);
                }
                platformIds.Sort();
                // set mappings
                int cumulativeCount = 0;
                foreach (var curId in platformIds)
                {
                    var key = openCLPlatformIdsRev[curId];
                    if (openCLGpuCount.ContainsKey(key))
                    {
                        _ethminerIdsOffet[key] = cumulativeCount;
                        cumulativeCount       += openCLGpuCount[key];
                    }
                }
            }
            // allerts
            _currentNvidiaOpenCLDriver = GetNvidiaOpenCLDriver();
            // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
            bool isNvidiaErrorShown = false; // to prevent showing twice

            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && CudaDevices.Count == 0)
            {
                isNvidiaErrorShown = true;
                var minDriver      = NVIDIA_MIN_DETECTION_DRIVER.ToString();
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                                              minDriver, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            // recomended driver
            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && _currentNvidiaOpenCLDriver < NVIDIA_RECOMENDED_DRIVER && !isNvidiaErrorShown && _currentNvidiaOpenCLDriver > -1)
            {
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                var nvdriverString = _currentNvidiaOpenCLDriver > -1 ? String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"), _currentNvidiaOpenCLDriver.ToString())
                : "";
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                                              recomendDrvier, nvdriverString, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // #x remove reference
            MessageNotifier = null;
        }
Пример #23
0
                public static void QueryCpus()
                {
                    Helpers.ConsolePrint(Tag, "QueryCpus START");
                    // get all CPUs
                    Available.CpusCount = CpuID.GetPhysicalProcessorCount();
                    Available.IsHyperThreadingEnabled = CpuID.IsHypeThreadingEnabled();

                    Helpers.ConsolePrint(Tag,
                                         Available.IsHyperThreadingEnabled
                            ? "HyperThreadingEnabled = TRUE"
                            : "HyperThreadingEnabled = FALSE");

                    // get all cores (including virtual - HT can benefit mining)
                    var threadsPerCpu = CpuID.GetVirtualCoresCount() / Available.CpusCount;

                    if (!Helpers.Is64BitOperatingSystem)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning)
                        {
                            MessageBox.Show(International.GetText("Form_Main_msgbox_CPUMining64bitMsg"),
                                            International.GetText("Warning_with_Exclamation"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        Available.CpusCount = 0;
                    }

                    if (threadsPerCpu * Available.CpusCount > 64)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning)
                        {
                            MessageBox.Show(International.GetText("Form_Main_msgbox_CPUMining64CoresMsg"),
                                            International.GetText("Warning_with_Exclamation"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        Available.CpusCount = 0;
                    }

                    // TODO important move this to settings
                    var threadsPerCpuMask = threadsPerCpu;

                    Globals.ThreadsPerCpu = threadsPerCpu;

                    if (CpuUtils.IsCpuMiningCapable())
                    {
                        if (Available.CpusCount == 1)
                        {
                            Available.Devices.Add(
                                new CpuComputeDevice(0, "CPU0", CpuID.GetCpuName().Trim(), threadsPerCpu, 0,
                                                     ++CpuCount)
                                );
                        }
                        else if (Available.CpusCount > 1)
                        {
                            for (var i = 0; i < Available.CpusCount; i++)
                            {
                                Available.Devices.Add(
                                    new CpuComputeDevice(i, "CPU" + i, CpuID.GetCpuName().Trim(), threadsPerCpu,
                                                         CpuID.CreateAffinityMask(i, threadsPerCpuMask), ++CpuCount)
                                    );
                            }
                        }
                    }

                    Helpers.ConsolePrint(Tag, "QueryCpus END");
                }
Пример #24
0
        /// <summary>
        /// SwichMostProfitable should check the best combination for most profit.
        /// Calculate profit for each supported algorithm per device group.
        /// Build from ground up compatible devices and algorithms.
        /// See #region Groupping logic
        /// Device groups are CPU, AMD_OpenCL and NVIDIA CUDA SM.x.x.
        /// NVIDIA SMx.x should be paired separately except for daggerhashimoto.
        /// </summary>
        /// <param name="NiceHashData"></param>
        public void SwichMostProfitableGroupUpMethod(Dictionary <AlgorithmType, NiceHashSMA> NiceHashData)
        {
            var devProfits = GetEnabledDeviceProifitDictionary(_perDeviceSpeedDictionary, NiceHashData);

#if (SWITCH_TESTING)
            SwitchTesting.Instance.SetNext(ref devProfits, _enabledDevices);
#endif
            double CurrentProfit = 0.0d;
            // calculate most profitable algorithm per enabled device
            foreach (var cdev in _enabledDevices)
            {
                var           curDevProfits       = devProfits[cdev.UUID];
                double        maxProfit           = double.MinValue;
                AlgorithmType maxAlgorithmTypeKey = AlgorithmType.NONE;
                var           algorithmSettings   = cdev.DeviceBenchmarkConfig.AlgorithmSettings;

                foreach (var kvpTypeProfit in curDevProfits)
                {
                    if (algorithmSettings.ContainsKey(kvpTypeProfit.Key) &&
                        !algorithmSettings[kvpTypeProfit.Key].Skip &&
                        kvpTypeProfit.Value > 0.0d &&
                        maxProfit < kvpTypeProfit.Value)
                    {
                        // extra check if current device can't handle dagger
                        if (AlgorithmType.DaggerHashimoto == kvpTypeProfit.Key && !cdev.IsEtherumCapale)
                        {
                            continue;
                        }
                        maxProfit           = kvpTypeProfit.Value;
                        maxAlgorithmTypeKey = kvpTypeProfit.Key;
                    }
                }
                if (maxAlgorithmTypeKey == AlgorithmType.NONE)
                {
                    cdev.MostProfitableAlgorithm = null;
                }
                else
                {
                    cdev.MostProfitableAlgorithm
                        = algorithmSettings[maxAlgorithmTypeKey];
                    // add most profitable to cumulative profit
                    CurrentProfit += maxProfit;
                }
            }

            // now if profitable check
            // TODO FOR NOW USD ONLY
            var currentProfitUSD = (CurrentProfit * Globals.BitcoinRate);
            Helpers.ConsolePrint(TAG, "Current Global profit: " + currentProfitUSD.ToString("F8") + " USD/Day");
            if (!IsConnectedToInternet || (ConfigManager.Instance.GeneralConfig.MinimumProfit > 0 &&
                                           currentProfitUSD < ConfigManager.Instance.GeneralConfig.MinimumProfit))
            {
                IsProfitable    = false;
                IsCurrentlyIdle = true;
                if (!IsConnectedToInternet)
                {
                    // change msg
                    Helpers.ConsolePrint(TAG, "NO INTERNET!!! Stopping mining.");
                    _mainFormRatesComunication.ShowNotProfitable(International.GetText("Form_Main_MINING_NO_INTERNET_CONNECTION"));
                }
                else
                {
                    _mainFormRatesComunication.ShowNotProfitable(International.GetText("Form_Main_MINING_NOT_PROFITABLE"));
                }
                // return don't group
                StopAllMinersNonProfitable();
                Helpers.ConsolePrint(TAG, "Current Global profit: NOT PROFITABLE MinProfit " + ConfigManager.Instance.GeneralConfig.MinimumProfit.ToString("F8") + " USD/Day");
                return;
            }
            else
            {
                IsProfitable    = true;
                IsCurrentlyIdle = false;
                _mainFormRatesComunication.HideNotProfitable();
                string profitabilityInfo = ConfigManager.Instance.GeneralConfig.MinimumProfit == 0 ? "mine always regardless of profit" : ConfigManager.Instance.GeneralConfig.MinimumProfit.ToString("F8") + " USD/Day";
                Helpers.ConsolePrint(TAG, "Current Global profit: IS PROFITABLE MinProfit " + profitabilityInfo);
            }

            // group devices with same supported algorithms
            _previousAllGroupedDevices = _currentAllGroupedDevices;
            _currentAllGroupedDevices  = new AllGroupedDevices();
            Dictionary <GroupedDevices, Algorithm> newGroupAndAlgorithm = new Dictionary <GroupedDevices, Algorithm>();
            for (int first = 0; first < _enabledDevices.Count; ++first)
            {
                var firstDev = _enabledDevices[first];
                // skip if no algorithm is profitable
                if (firstDev.MostProfitableAlgorithm == null)
                {
                    Helpers.ConsolePrint("SwichMostProfitableGroupUpMethod", String.Format("Device {0}, MostProfitableAlgorithm == null", firstDev.Name));
                    continue;
                }
                // check if is in group
                bool isInGroup = false;
                foreach (var groupedDevices in _currentAllGroupedDevices)
                {
                    if (groupedDevices.Contains(firstDev.UUID))
                    {
                        isInGroup = true;
                        break;
                    }
                }
                if (isInGroup)
                {
                    continue;
                }

                var newGroup = new GroupedDevices();
                newGroup.Add(firstDev.UUID);
                for (int second = first + 1; second < _enabledDevices.Count; ++second)
                {
                    var secondDev = _enabledDevices[second];
                    // first check if second device has profitable algorithm
                    if (secondDev.MostProfitableAlgorithm != null)
                    {
                        // check if we should group
                        if (IsEquihashAndOneCPU(firstDev, secondDev) || // if one CPU group them all
                            IsEquihashAndOneNOTCPU(firstDev, secondDev) ||
                            IsDaggerAndSameComputePlatform(firstDev, secondDev) ||
                            IsGroupBinaryAndAlgorithmSame(firstDev, secondDev))
                        {
                            newGroup.Add(secondDev.UUID);
                        }
                    }
                }

                _currentAllGroupedDevices.Add(newGroup);
                newGroupAndAlgorithm.Add(newGroup, firstDev.MostProfitableAlgorithm);
            }

            // stop groupes that aren't in current group devices
            foreach (var curPrevGroup in _previousAllGroupedDevices)
            {
                var  curPrevGroupKey = CalcGroupedDevicesKey(curPrevGroup);
                bool contains        = false;
                foreach (var curCheckGroup in _currentAllGroupedDevices)
                {
                    var curCheckGroupKey = CalcGroupedDevicesKey(curCheckGroup);
                    if (curPrevGroupKey == curCheckGroupKey)
                    {
                        contains = true;
                        break;
                    }
                }
                if (!contains)
                {
                    _groupedDevicesMiners[curPrevGroupKey].Stop();
                }
            }
            // switch to newGroupAndAlgorithm most profitable algorithm
            foreach (var kvpGroupAlgorithm in  newGroupAndAlgorithm)
            {
                var group     = kvpGroupAlgorithm.Key;
                var algorithm = kvpGroupAlgorithm.Value;

                GroupMiners currentGroupMiners;
                // try find if it doesn't exist create new
                string groupStringKey = CalcGroupedDevicesKey(group);
                if (!_groupedDevicesMiners.TryGetValue(groupStringKey, out currentGroupMiners))
                {
                    currentGroupMiners = new GroupMiners(group);
                    _groupedDevicesMiners.Add(groupStringKey, currentGroupMiners);
                }
                currentGroupMiners.StartAlgorihtm(algorithm, _miningLocation, _workerBtcStringWorker);
            }

            // stats quick fix code
            if (_currentAllGroupedDevices.Count != _previousAllGroupedDevices.Count)
            {
                MinerStatsCheck(NiceHashData);
            }
        }
Пример #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = Request.QueryString["id"];

        con.ConnectionString = ConfigurationManager.ConnectionStrings["PATENTCN"].ConnectionString;
        if (id == "Inventor")
        {
            this.Title = "Inventor Wise Report";
            string SelectName = Request.QueryString["name"];
            string sql        = "SELECT FILENO,TITLE,Inventor1 AS INVENTOR,APPLCN_NO,FILING_DT,PAT_NO,PAT_DT,Attorney AS ATTORNEY,STATUS,SUB_STATUS FROM PATDETAILS " +
                                "WHERE Inventor1 LIKE '" + SelectName + "'";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "InventorDetails");

            rptDoc.Load(Server.MapPath("~/Report/rptInventor.rpt"));
            rptDoc.SetDataSource(ds);
            //rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response,false, SelectName + "IdfDetails");
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "Inventor2")
        {
            this.Title = "Inventor Wise Report";
            string SelectName = Request.QueryString["name"];
            string sql        = "SELECT FILENO,TITLE,INVENTOR1 AS INVENTOR,INDUSTRY1,INDUSTRY2,ABSTRACT,DEVELOPMENTSTATUS,COMMERCIALIZED,(SELECT SUM(PAYMENTAMTINR) FROM PATENTPAYMENT WHERE FILENO = PATDETAILS.FILENO) AS PAYMENT,(SELECT SUM(COST_RS) FROM PATENTRECEIPT WHERE FILENO = PATDETAILS.FILENO) AS RECEIPT FROM PATDETAILS " +
                                "WHERE INVENTOR1 LIKE '" + SelectName + "' ORDER BY CAST(FILENO AS INT) DESC";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "InventorCommercial");

            rptDoc.Load(Server.MapPath("~/Report/rptInventor2.rpt"));
            rptDoc.SetDataSource(ds);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "Attorney")
        {
            this.Title = "Attorney Wise Report";
            string SelectName  = Request.QueryString["name"];
            string FiledStatus = Request.QueryString["FiledStatus"];
            SelectName = SelectName.Replace("~", "&");
            string fs = "";
            if (FiledStatus == "Granted")
            {
                fs = "STATUS LIKE 'Granted'";
            }
            else if (FiledStatus == "Not Yet Granted")
            {
                fs = "STATUS NOT LIKE 'Granted'";
            }
            string sql = "SELECT FILENO,TITLE,Inventor1 AS INVENTOR,APPLCN_NO,FILING_DT,PAT_NO,PAT_DT,Attorney AS ATTORNEY,STATUS,SUB_STATUS FROM PATDETAILS " +
                         "WHERE Attorney like'" + SelectName.Trim() + "'";
            if (fs != "")
            {
                sql = sql + " AND " + fs;
            }
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "AttorneyDetails");

            rptDoc.Load(Server.MapPath("~/Report/rptAttorney.rpt"));
            rptDoc.SetDataSource(ds);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            //CrystalReportViewer1.SeparatePages = false;
            con.Close();
        }
        else if (id == "FilingDt")
        {
            this.Title = "Filing Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate  = Request.QueryString["FromDt"];
            string toDate    = Request.QueryString["ToDt"];
            string idfStatus = Request.QueryString["IDFStatus"];
            string sql       = "SELECT FILENO,TITLE,Inventor1 AS INVENTOR,DEPARTMENT,APPLCN_NO,FILING_DT,Attorney AS ATTORNEY,STATUS,SUB_STATUS FROM PATDETAILS " +
                               "WHERE FILING_DT BETWEEN CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103)";
            if (idfStatus == "All")
            {
                sql = sql + " ORDER BY FILING_DT DESC";
            }
            else if (idfStatus == "Granted")
            {
                sql = sql + " AND PAT_NO IS NOT NULL ORDER BY FILING_DT DESC";
            }
            else if (idfStatus == "Not Yet Granted")
            {
                sql = sql + " AND PAT_NO IS NULL ORDER BY FILING_DT DESC";
            }
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "FilingDtList");
            rptDoc.Load(Server.MapPath("~/Report/rptFilingDate.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("FromDate", Convert.ToDateTime(fromDate));
            rptDoc.SetParameterValue("TODate", Convert.ToDateTime(toDate));
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "Renewal")
        {
            this.Title = "Renewal Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string iMonth     = Request.QueryString["FromDt"];
            string iYear      = Request.QueryString["ToDt"];
            string NotRenewal = Request.QueryString["NotRenewal"];
            string fromDate   = Convert.ToDateTime("01/" + iMonth + "/" + iYear).ToShortDateString();
            string tmpTo      = Convert.ToDateTime(fromDate).AddMonths(1).ToShortDateString();
            string toDate     = Convert.ToDateTime(tmpTo).AddDays(-1).ToShortDateString();
            string sql1       = "";
            if (NotRenewal == "No")
            {
                sql1 = " and SUB_STATUS NOT LIKE '%Not Renewed%' ";
            }
            string sql = "SELECT FILENO,TITLE,Inventor1 AS INVENTOR,APPLCN_NO AS APPLICATIONNO,FILING_DT,CASE WHEN DATEDIFF(YEAR,FILING_DT,GETDATE()) > 20 THEN '>20' ELSE CAST(DATEDIFF(YEAR,FILING_DT,GETDATE()) AS VARCHAR(5)) END AS NO_YEAR,VALIDITY_TO_DT,DATEDIFF(YEAR,FILING_DT,VALIDITY_TO_DT) AS RENEWAL_YEAR,SUB_STATUS,COMMERCIALIZED,pat_dt as Patent_Date,Pat_no FROM PATDETAILS " +
                         "WHERE DATEPART(MONTH,FILING_DT)=" + Convert.ToInt32(iMonth) + " AND STATUS LIKE 'GRANTED'" + sql1 + "ORDER BY SUB_STATUS";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "RenewalList");

            String tMonth = Convert.ToDateTime("01/" + iMonth + "/" + iYear).ToString("MMMM");
            rptDoc.Load(Server.MapPath("~/Report/rptRenewal.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("Imonth", tMonth);
            rptDoc.SetParameterValue("Iyear", iYear);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "ProvisionalToComplete")
        {
            this.Title = "Provisional To Complete";
            int    selMonth = Convert.ToInt32(Request.QueryString["selMonth"]);
            string tillDate = Convert.ToString(Request.QueryString["tillDate"]);
            string sql      = "select fileno,title,Inventor1 as inventor,department,applcn_no,filing_dt,Attorney,status,sub_status, datediff(mm,filing_dt,convert(smalldatetime,'" + tillDate + "',103)) as filingMonths  from patdetails where filing_dt is not null and " +
                              "sub_status like '%provisional%' and datediff(mm,filing_dt,convert(smalldatetime,'" + tillDate + "',103)) >= " + selMonth;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            dsFindFiles ds = new dsFindFiles();
            da.Fill(ds, "provisional");
            GenerateExcel ge = new GenerateExcel();
            ge.MakeExcel(ds.Tables["provisional"], "Provisional");
            con.Close();
        }
        else if (id == "Examination")
        {
            this.Title = "Examination and Publication";
            int    selMonth = Convert.ToInt32(Request.QueryString["selMonth"]);
            string sql      = "select fileno,title,Inventor1 as inventor,department,applcn_no,filing_dt,Attorney,status,sub_status, datediff(mm,filing_dt,getdate()) as filingMonths  from patdetails where filing_dt is not null and status not like 'Granted' and status not like 'Closed%' " +
                              "and sub_status like '%Complete%' and sub_status not like '%Published%' and datediff(mm,filing_dt,getdate()) >= " + selMonth;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            dsFindFiles ds = new dsFindFiles();
            da.Fill(ds, "Examination");
            GenerateExcel ge = new GenerateExcel();
            ge.MakeExcel(ds.Tables["Examination"], "Exam");
            con.Close();
        }
        else if (id == "PCT_Filing")
        {
            this.Title = "PCT Filing";
            int    selMonth = Convert.ToInt32(Request.QueryString["selMonth"]);
            string tillDate = Convert.ToString(Request.QueryString["tillDate"]);
            string sql      = "select fileno,title,Inventor1 as inventor,department,applcn_no,filing_dt,status,sub_status, datediff(mm,filing_dt,convert(smalldatetime,'" + tillDate + "',103)) as filingMonths  from patdetails where filing_dt is not null and status not like 'Granted' and status not like 'Closed%' " +
                              "and (sub_status like '%Complete%' or sub_status like '%Provisional%')and fileno not in (select fileno from INTERNATIONAL where country like 'pct') and datediff(mm,filing_dt,convert(smalldatetime,'" + tillDate + "',103)) <=12 and datediff(mm,filing_dt,convert(smalldatetime,'" + tillDate + "',103)) >= " + selMonth + " order by sub_status, cast(fileno as int)";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            dsFindFiles ds = new dsFindFiles();
            da.Fill(ds, "pctFiling");
            GenerateExcel ge = new GenerateExcel();
            ge.MakeExcel(ds.Tables["pctFiling"], "PCT");
            con.Close();
        }
        else if (id == "Foreign")
        {
            this.Title = "Foreign Filing Review (Excluding Direct International)";
            string Country    = Request.QueryString["Country"];
            string Status     = Request.QueryString["Status"];
            string Commercial = Request.QueryString["Commercial"];
            int    FromMonth  = Convert.ToInt32(Request.QueryString["FromMonth"]);
            int    ToMonth    = Convert.ToInt32(Request.QueryString["ToMonth"]);
            //string sql = "select fileno,title,Inventor1 as inventor,department,applcn_no,filing_dt,status,sub_status, datediff(mm,filing_dt,getdate()) as filingMonths  from patdetails where filing_dt is not null and status not like 'Granted' and status not like 'Closed%' " +
            //"and sub_status like '%Complete%' and fileno in (select fileno from INTERNATIONAL where country like 'pct') and datediff(mm,filing_dt,getdate()) >= " + selMonth;
            string sql   = "select P.fileno,P.title,P.Inventor1 as inventor,P.department,p.Applcn_no as ApplicationNumber,p.Filing_dt as FilingDate,I.subFileNo,i.Country,I.ApplicationNo,I.FilingDt,I.Status,I.SubStatus, datediff(mm,p.Filing_dt,getdate()) as filingMonths  from patdetails P inner join International I on p.FileNo = I.FileNo";
            string query = "";
            if (Country != "All")
            {
                query = " and I.Country = '" + Country + "'";
            }
            if (Status != "All")
            {
                if (query != "")
                {
                    query = query + " and I.Status = '" + Status + "'";
                }
                else
                {
                    query = " and I.Status ='" + Status + "'";
                }
            }
            if (Commercial != "All")
            {
                if (query != "")
                {
                    query = query + " and I.Commercial ='" + Commercial + "'";
                }
                else
                {
                    query = " and I.Commercial ='" + Commercial + "'";
                }
            }
            if (FromMonth <= ToMonth)
            {
                if (query != "")
                {
                    query = query + " and datediff(mm,p.Filing_dt,getdate()) >=" + FromMonth + " and datediff(mm,p.Filing_dt,getdate()) <=" + ToMonth;
                }
                else
                {
                    query = " and datediff(mm,p.Filing_dt,getdate()) >=" + FromMonth + " and datediff(mm,p.Filing_dt,getdate()) <=" + ToMonth;
                }
            }
            if (query != "")
            {
                sql = sql + " " + query;
            }
            sql = sql + " order by p.fileno,I.FilingDt";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            dsFindFiles ds = new dsFindFiles();
            da.Fill(ds, "foreignFiling");
            GenerateExcel ge = new GenerateExcel();
            ge.MakeExcel(ds.Tables["foreignFiling"], "FDF");
            con.Close();
        }
        else if (id == "FileNoWise")
        {
            this.Title = "File Number Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            int    fromNo        = Convert.ToInt32(Request.QueryString["FromNo"]);
            int    toNo          = Convert.ToInt32(Request.QueryString["ToNo"]);
            string commercial    = Request.QueryString["commercial"];
            string tmpCommercial = "";
            if (commercial == "IV" || commercial == "IITM")
            {
                tmpCommercial = " and commercial like '" + commercial + "'";
            }
            else if (commercial == "Others")
            {
                tmpCommercial = " and commercial not like 'IV' and commercial not like 'IITM'";;
            }
            string sql = "SELECT FILENO,TITLE,COMMERCIAL,Inventor1 AS INVENTOR,DEPARTMENT,APPLCN_NO,FILING_DT,Attorney AS ATTORNEY,STATUS,SUB_STATUS FROM PATDETAILS " +
                         "WHERE fileno >=" + fromNo.ToString() + " AND fileno <=" + toNo.ToString() + tmpCommercial + " ORDER BY CAST(FILENO AS INT) DESC";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "FileNoList");
            rptDoc.Load(Server.MapPath("~/Report/rptFileNo.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("FromNo", fromNo);
            rptDoc.SetParameterValue("ToNo", toNo);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "EntryDt")
        {
            this.Title = "Entry Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate  = Request.QueryString["FromDt"];
            string toDate    = Request.QueryString["ToDt"];
            string idfStatus = Request.QueryString["IDFStatus"];
            string sql       = "SELECT EntryDt,FILENO,TITLE,Inventor1 AS INVENTOR,DEPARTMENT,TYPE,APPLCN_NO,FILING_DT,Attorney AS ATTORNEY,STATUS,SUB_STATUS,Pat_no FROM PATDETAILS " +
                               "WHERE EntryDt BETWEEN CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103)";
            if (idfStatus == "All")
            {
                //sql = sql + " ORDER BY ENTRYDT DESC";
                sql = sql + " ORDER BY FILENO ASC";
            }
            else if (idfStatus == "Filed")
            {
                sql = sql + " AND  APPLCN_NO IS NOT NULL ORDER BY ENTRYDT DESC";
            }
            else if (idfStatus == "Not Yet Filed")
            {
                sql = sql + " AND  APPLCN_NO IS NULL AND STATUS NOT IN ('Closed - Internal','Closed - External','Direct International') ORDER BY ENTRYDT DESC";
            }
            else if (idfStatus == "Closed - Internal")
            {
                sql = sql + " AND STATUS LIKE 'Closed - Internal' ORDER BY ENTRYDT DESC";
            }
            else if (idfStatus == "Closed - External")
            {
                sql = sql + " AND STATUS LIKE 'Closed - External' ORDER BY ENTRYDT DESC";
            }
            else if (idfStatus == "Granted")
            {
                sql = sql + " AND PAT_NO IS NOT NULL ORDER BY ENTRYDT DESC";
            }
            else if (idfStatus == "Not Yet Granted")
            {
                sql = sql + " AND PAT_NO IS NULL ORDER BY ENTRYDT DESC";
            }
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "EntryDtList");
            rptDoc.Load(Server.MapPath("~/Report/rptEntryDate.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("FromDate", Convert.ToDateTime(fromDate));
            rptDoc.SetParameterValue("TODate", Convert.ToDateTime(toDate));
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "PatDt")
        {
            this.Title = "Patent Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string sql      = "SELECT FILENO,TITLE,Inventor1 AS INVENTOR,DEPARTMENT,APPLCN_NO,FILING_DT,Attorney AS ATTORNEY,TYPE,PAT_NO,PAT_DT,STATUS FROM PATDETAILS " +
                              "WHERE PAT_DT BETWEEN CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103) ORDER BY  PAT_DT DESC";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            Inventor ds = new Inventor();
            da.Fill(ds, "PatentDtList");
            rptDoc.Load(Server.MapPath("~/Report/rptPatentDate.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("FromDate", Convert.ToDateTime(fromDate));
            rptDoc.SetParameterValue("TODate", Convert.ToDateTime(toDate));
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "IntlInventor")
        {
            this.Title = "Inventor Wise Report";
            string SelectName = Request.QueryString["name"];
            string sql        = "SELECT P.FILENO,P.TITLE,P.APPLCN_NO AS APPLICATION_NO,P.FILING_DT,P.PAT_NO AS PATENT_NO,P.PAT_DT AS PATENT_DT,P.TYPE,P.ATTORNEY,P.STATUS,P.SUB_STATUS,I.SUBFILENO,I.COUNTRY," +
                                "I.APPLICATIONNO,I.FILINGDT,I.PATENTNO,I.PATENTDT,I.ATTORNEY AS INTLATTORNEY,I.STATUS AS INTLSTATUS,I.SUBSTATUS FROM PATDETAILS P INNER JOIN INTERNATIONAL I " +
                                "ON P.FILENO=  I.FILENO AND INVENTOR1 LIKE '" + SelectName + "'";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            International ds = new International();
            da.Fill(ds, "InventorList");
            rptDoc.Load(Server.MapPath("~/Report/rptIntlInventor.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("txtProfessor", SelectName);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "IntlAttorney")
        {
            this.Title = "Attorney Wise Report";
            string SelectName  = Request.QueryString["name"];
            string FiledStatus = Request.QueryString["FiledStatus"];
            SelectName = SelectName.Replace("~", "&");
            string fs = "";
            if (FiledStatus == "Granted")
            {
                fs = "I.STATUS LIKE 'Granted'";
            }
            else if (FiledStatus == "Not Yet Granted")
            {
                fs = "I.STATUS NOT LIKE 'Granted'";
            }
            string sql = "select I.fileno,I.Subfileno,P.Title,P.Inventor1 as Inventor,I.Country,I.ApplicationNo,I.FilingDt,I.patentNo,I.PatentDt,I.Status,I.SubStatus,I.Attorney from International I inner join Patdetails P " +
                         "on I.fileno=P.fileno and I.Attorney like '" + SelectName.Trim() + "'";
            if (fs != "")
            {
                sql = sql + " AND " + fs + " order by I.Country";
            }
            else
            {
                sql = sql + " order by I.Country";
            }
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            International ds = new International();
            da.Fill(ds, "IntlAttorney");

            rptDoc.Load(Server.MapPath("~/Report/rptIntlAttorney.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("lblTitle", "Name of Attorney : " + SelectName);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "IntlCountry")
        {
            this.Title = "Country Wise Report";
            string SelectName = Request.QueryString["name"];
            SelectName = SelectName.Replace("~", "&");
            string sql = "select I.fileno,I.Subfileno,P.Title,P.Inventor1 as Inventor,I.Country,I.ApplicationNo,I.FilingDt,I.patentNo,I.PatentDt,I.Status,I.SubStatus,I.Attorney from International I inner join Patdetails P " +
                         "on I.fileno=P.fileno and I.Country like '" + SelectName.Trim() + "' order by P.Inventor1";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            International ds = new International();
            da.Fill(ds, "IntlAttorney");

            rptDoc.Load(Server.MapPath("~/Report/rptIntlAttorney.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("lblTitle", "Country Name : " + SelectName);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "IntlFilingDt")
        {
            this.Title = "Filing Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string sql      = "select I.fileno,I.Subfileno,P.Title,P.Inventor1 as Inventor,I.Country,I.ApplicationNo,I.FilingDt,I.patentNo,I.PatentDt,I.Status,I.SubStatus,I.Attorney from International I inner join Patdetails P " +
                              "on I.fileno=P.fileno and I.FilingDt between CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103) order by I.Filingdt desc";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            International ds = new International();
            da.Fill(ds, "IntlAttorney");

            rptDoc.Load(Server.MapPath("~/Report/rptIntlAttorney.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("lblTitle", "Filing date between " + fromDate + " and " + toDate);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }

        else if (id == "IntlPatDt")
        {
            this.Title = "Patent Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string sql      = "select I.fileno,I.Subfileno,P.Title,P.Inventor1 as Inventor,I.Country,I.ApplicationNo,I.FilingDt,I.patentNo,I.PatentDt,I.Status,I.SubStatus,I.Attorney from International I inner join Patdetails P " +
                              "on I.fileno=P.fileno and I.PatentDt between CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103) order by I.Patentdt desc";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            International ds = new International();
            da.Fill(ds, "IntlAttorney");

            rptDoc.Load(Server.MapPath("~/Report/rptIntlAttorney.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("lblTitle", "Patent date between " + fromDate + " and " + toDate);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "IntlEntryDt")
        {
            this.Title = "Patent Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string sql      = "select I.fileno,I.Subfileno,P.Title,P.Inventor1 as Inventor,I.Country,I.ApplicationNo,I.FilingDt,I.patentNo,I.PatentDt,I.Status,I.SubStatus,I.Attorney from International I inner join Patdetails P " +
                              "on I.fileno=P.fileno and I.InputDt between CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103) order by I.Inputdt desc";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            International ds = new International();
            da.Fill(ds, "IntlAttorney");

            rptDoc.Load(Server.MapPath("~/Report/rptIntlAttorney.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("lblTitle", "Entry date between " + fromDate + " and " + toDate);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "PayInventor")
        {
            this.Title = "Payment details of Inventor";
            string SelectName = Request.QueryString["name"];
            string sql        = "select Fileno, (select sum(PaymentAmtINR) from patentPayment where fileno=P.fileno and paymentreforchequeno is not null and (Country='India' or Country is null)) as Domestic," +
                                "(select sum(PaymentAmtINR) from patentPayment where fileno=P.fileno and paymentreforchequeno is not null and (Country <>'India' and Country is not null)) as International, " +
                                "sum(PaymentAmtINR) as PaymentAmtINR from patentPayment P where P.Fileno in (select Fileno from patdetails where Inventor1 like '" + SelectName + "') " +
                                "and P.paymentreforchequeno is not null group by P.Fileno order by cast(P.Fileno as integer)";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            PaymentDS ds = new PaymentDS();
            da.Fill(ds, "InventorPayment");

            rptDoc.Load(Server.MapPath("~/Report/InventorCost.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("Title", "Prof. " + SelectName.ToUpper());
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "PayDtWise")
        {
            this.Title = "Payment Date Wise Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string sql      = "select Fileno, (select upper(inventor1) from patdetails where fileno=p.fileno)as Inventor,(select sum(PaymentAmtINR) from patentPayment where fileno=P.fileno and paymentOrChequeDt between CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103) and (Country='India' or Country is null)) as Domestic, " +
                              "(select sum(PaymentAmtINR) from patentPayment where fileno=P.fileno and paymentOrChequeDt between CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103) and (Country <>'India' and Country is not null)) as International, " +
                              "sum(PaymentAmtINR) as PaymentAmtINR from patentPayment P where P.Fileno in (select Fileno from patdetails where paymentOrChequeDt between CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103)) " +
                              "group by P.Fileno order by sum(PaymentAmtINR) desc";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            PaymentDS ds = new PaymentDS();
            da.Fill(ds, "InventorPayment");

            rptDoc.Load(Server.MapPath("~/Report/rptCost.rpt"));
            rptDoc.SetDataSource(ds);
            rptDoc.SetParameterValue("Title", "Payment Date between " + fromDate + " and " + toDate);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "AgeAnalysis" || id == "AgeAnalysisGraph")
        {
            this.Title = "Age Analysis Report";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            int    fromYear = Convert.ToInt32(Request.QueryString["FromYear"]);
            int    toYear   = Convert.ToInt32(Request.QueryString["ToYear"]);
            string sql      = "select cast(datepart(yyyy,p.filing_dt) as varchar(4)) as [Year], count(*) as [PatentFiled]," +
                              "(select count(*) from patdetails where pat_no is not null and datepart(yyyy,filing_dt)=datepart(yyyy,p.filing_dt)) as [PatentGrant]," +
                              "(select count(*) from patdetails where pub_dt is not null and pat_no is null and datepart(yyyy,filing_dt)=datepart(yyyy,p.filing_dt)) as [Publication]," +
                              "(select count(*) from patdetails where exam_dt is not null and pat_no is null and datepart(yyyy,filing_dt)=datepart(yyyy,p.filing_dt)) as [Examination]" +
                              "from patdetails p where p.filing_dt is not null and datepart(yyyy,p.filing_dt)>= " + fromYear + " and datepart(yyyy,p.filing_dt)<= " + toYear + " group by datepart(yyyy,p.filing_dt)";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            dsAgeAnalysis ds = new dsAgeAnalysis();
            da.Fill(ds, "dtAgeAnalysis");
            if (id == "AgeAnalysis")
            {
                rptDoc.Load(Server.MapPath("~/Report/rptAgeAnalysis.rpt"));
            }
            else if (id == "AgeAnalysisGraph")
            {
                rptDoc.Load(Server.MapPath("~/Report/rptAgeAnalysisGraph.rpt"));
            }
            rptDoc.SetDataSource(ds);
            //rptDoc.SetParameterValue("FromNo", fromNo);
            //rptDoc.SetParameterValue("ToNo", toNo);
            rptDoc.SetParameterValue("Title", "Years from " + fromYear + " to " + toYear);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "Commercial")
        {
            this.Title = "Commercialization Status";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string Status   = Request.QueryString["Status"];
            string sql      = "SELECT FILENO,TITLE,INVENTOR1,INDUSTRY1,INDUSTRY2,ABSTRACT,DEVELOPMENTSTATUS,COMMERCIALIZED,STUFF((SELECT ', ' + MKTGPROJECTNO FROM MARKETINGIDF WHERE FILENO=PATDETAILS.FILENO ORDER BY MKTGPROJECTNO FOR XML PATH ('')),1,1,'') AS MARKETING_PROJECT FROM PATDETAILS " +
                              "WHERE FILING_DT BETWEEN CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103)";
            if (Status != "All")
            {
                if (Status == "Not Yet")
                {
                    sql = sql + "  AND (COMMERCIALIZED IS NULL OR COMMERCIALIZED LIKE 'Not Yet')";
                }
                else
                {
                    sql = sql + "  AND COMMERCIALIZED LIKE '" + Status + "'";
                }
            }
            sql = sql + " ORDER BY CAST(FILENO AS INT) DESC";
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            DataSet        ds = new dsCommercial();
            da.Fill(ds.Tables["CommStatus"]);
            rptDoc.Load(Server.MapPath("~/Report/rptCommercialize.rpt"));
            rptDoc.SetDataSource(ds);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
        else if (id == "CommercialStatus")
        {
            this.Title = "Commercialization Status";
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
            string fromDate = Request.QueryString["FromDt"];
            string toDate   = Request.QueryString["ToDt"];
            string Status   = Request.QueryString["Status"];
            string sql      = "";
            if (Status == "Industry I")
            {
                sql = "SELECT INDUSTRY1 as INDUSTRY,COMMERCIALIZED FROM PATDETAILS " +
                      "WHERE FILING_DT BETWEEN CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103)";
            }
            else if (Status == "Industry II")
            {
                sql = "SELECT INDUSTRY2 as INDUSTRY,COMMERCIALIZED FROM PATDETAILS " +
                      "WHERE FILING_DT BETWEEN CONVERT(SMALLDATETIME,'" + fromDate + "',103) AND CONVERT(SMALLDATETIME,'" + toDate + "',103)";
            }
            sql = sql + " ORDER BY INDUSTRY";
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            DataSet        ds = new dsCommercial();
            da.Fill(ds.Tables["CommercialStatus"]);
            rptDoc.Load(Server.MapPath("~/Report/rptCommercialStatus.rpt"));
            rptDoc.SetDataSource(ds);
            CrystalReportViewer1.ReportSource             = rptDoc;
            CrystalReportViewer1.HasToggleGroupTreeButton = false;
            con.Close();
        }
    }
 public void InitLocale()
 {
     listViewDevices.Columns[ENABLED].Text = International.GetText("ListView_Device");  //International.GetText("ListView_Enabled");
     //listViewDevices.Columns[DEVICE].Text = International.GetText("ListView_Device");
 }
Пример #27
0
 // combines long and short name
 public string GetFullName()
 {
     return(String.Format(International.GetText("ComputeDevice_Full_Device_Name"), NameCount, Name));
 }
 private void UnzipThreadRoutine()
 {
     if (File.Exists(BinsZipLocation))
     {
         Helpers.ConsolePrint(TAG, BinsZipLocation + " already downloaded");
         Helpers.ConsolePrint(TAG, "unzipping");
         using (ZipArchive archive = ZipFile.Open(BinsZipLocation, ZipArchiveMode.Read)) {
             //archive.ExtractToDirectory("bin");
             _minerUpdateIndicator.SetMaxProgressValue(archive.Entries.Count);
             int prog = 0;
             // first create dirs
             foreach (ZipArchiveEntry entry in archive.Entries)
             {
                 if (entry.Length == 0)
                 {
                     Helpers.ConsolePrint("ZipArchiveEntry", entry.FullName);
                     Helpers.ConsolePrint("ZipArchiveEntry", entry.Length.ToString());
                     Directory.CreateDirectory(entry.FullName);
                     _minerUpdateIndicator.SetProgressValueAndMsg(prog++, String.Format(International.GetText("MinersDownloadManager_Title_Settup_Unzipping"), ((double)(prog) / (double)(archive.Entries.Count) * 100).ToString("F2")));
                 }
             }
             // unzip files
             foreach (ZipArchiveEntry entry in archive.Entries)
             {
                 if (entry.Length > 0)
                 {
                     Helpers.ConsolePrint("ZipArchiveEntry", entry.FullName);
                     Helpers.ConsolePrint("ZipArchiveEntry", entry.Length.ToString());
                     entry.ExtractToFile(entry.FullName);
                     _minerUpdateIndicator.SetProgressValueAndMsg(prog++, String.Format(International.GetText("MinersDownloadManager_Title_Settup_Unzipping"), ((double)(prog) / (double)(archive.Entries.Count) * 100).ToString("F2")));
                 }
             }
         }
         // after unzip stuff
         ConfigManager.Instance.GeneralConfig.DownloadInit = true;
         ConfigManager.Instance.GeneralConfig.Commit();
         _minerUpdateIndicator.FinishMsg(IsMinersBinsInit());
         // remove bins zip
         try {
             if (File.Exists(BinsZipLocation))
             {
                 File.Delete(BinsZipLocation);
             }
         } catch { }
     }
     else
     {
         Helpers.ConsolePrint(TAG, "UnzipThreadRoutine bin.zip file not found");
     }
 }
Пример #29
0
 private void SetLabelBenchmarkSteps(int current, int max)
 {
     labelBenchmarkSteps.Text = String.Format(International.GetText("FormBenchmark_Benchmark_Step"), current, max);
 }
Пример #30
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            bool flag = true;

            if (txtAppointmentCount.Text.Length == 0 || cmbAppointmentTime.SelectedIndex == -1)
            {
                MessageBox.Show("Enter appointment count and click the 'Show Timings'", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                if (cmbAppointmentTime.SelectedIndex == -1)
                {
                    MessageBox.Show("Select an appointment time");
                    flag = false;
                }
                else if (cmbTestLocation.SelectedIndex == -1)
                {
                    MessageBox.Show("Select a test location");
                    flag = false;
                }
                else
                {
                    int slot = cmbAppointmentTime.SelectedIndex + 1;
                    if (appArray[slot - 1].CandidateData == null)
                    {
                        Candidate candidate = new Domestic();
                        appArray[slot - 1].AppointmentTime = appArray[slot - 1].AppointmentTime;
                        appArray[slot - 1].TestLocation    = cmbTestLocation.Text;
                        appArray[slot - 1].SlotNumber      = slot;
                        int candidateType = cmbCandidateType.SelectedIndex + 1;


                        switch (candidateType)
                        {
                        case (int)CandidateType.Domestic:
                            candidate = new Domestic();
                            candidate.CandidateType = "Domestic";
                            string IsFeeDeduction = cmbIndividualTask.Text;
                            ((Domestic)candidate).IsFeeDeduction = (IsFeeDeduction.ToUpper() == "YES") ? true : false;
                            break;

                        case (int)CandidateType.International:
                            candidate = new International();
                            candidate.CandidateType = "International";
                            string isWorkPermit = cmbIndividualTask.Text;
                            ((International)candidate).IsWorkPermit = (isWorkPermit.ToUpper() == "YES") ? true : false;
                            break;

                        case (int)CandidateType.LicenseRenew:
                            candidate = new LicenseRenew();
                            candidate.CandidateType = "LicenseRenew";
                            string isLicenseExpired = cmbIndividualTask.Text;
                            ((LicenseRenew)candidate).IsLicenseExpired = (isLicenseExpired.ToUpper() == "YES") ? true : false;
                            break;
                        }

                        string  candidateName    = txtName.Text;
                        string  candidateAddress = txtAddress.Text;
                        string  candidateEmail   = txtEmail.Text;
                        string  passport         = txtPassport.Text;
                        decimal amount;
                        string  amountString = txtAmount.Text;
                        string  creditCard   = txtCreditcard.Text;
                        candidate.CreditCard = creditCard;
                        candidate.Passport   = passport;
                        candidate.Email      = candidateEmail;
                        if (candidateName.Length == 0)
                        {
                            if (Validation.GetHasError(txtName) == true)
                            {
                                return;
                            }
                            txtName.Foreground = Brushes.Red;
                            txtName.Select(0, txtName.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtName.Foreground = Brushes.Black;
                        }
                        if (candidateAddress.Length == 0)
                        {
                            txtAddress.Foreground = Brushes.Red;
                            txtAddress.Select(0, txtAddress.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtAddress.Foreground = Brushes.Black;
                        }
                        if (!candidate.CheckEmail())
                        {
                            txtEmail.Foreground = Brushes.Red;
                            txtEmail.Select(0, txtEmail.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtEmail.Foreground = Brushes.Black;
                        }
                        if (!(decimal.TryParse(amountString, out amount)))
                        {
                            txtAmount.Foreground = Brushes.Red;
                            txtAmount.Select(0, txtAmount.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtAmount.Foreground = Brushes.Black;
                        }
                        if (!candidate.CheckCreditCard())
                        {
                            txtCreditcard.Foreground = Brushes.Red;
                            txtCreditcard.Select(0, txtCreditcard.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtCreditcard.Foreground = Brushes.Black;
                        }
                        if (!candidate.CheckPassport())
                        {
                            txtPassport.Foreground = Brushes.Red;
                            txtPassport.Select(0, txtPassport.Text.Length);
                            flag = false;
                        }
                        else
                        {
                            txtPassport.Foreground = Brushes.Black;
                        }
                        if (cmbAppointmentTime.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select an appointment time");
                            flag = false;
                        }
                        if (cmbTestLocation.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select a test location");
                            flag = false;
                        }
                        if (cmbCandidateType.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select an landscape type");
                            flag = false;
                        }
                        if (cmbIndividualTask.SelectedIndex == -1)
                        {
                            MessageBox.Show("Select individual task");
                            flag = false;
                        }
                        if (flag)
                        {
                            candidate.CandidateName          = candidateName;
                            candidate.CandidateAddress       = candidateAddress;
                            candidate.Email                  = candidateEmail;
                            candidate.Passport               = passport;
                            candidate.AmountPaid             = amount;
                            candidate.CreditCard             = creditCard;
                            appArray[slot - 1].CandidateData = candidate;
                            appointmentList.Add(appArray[slot - 1]);
                            //DisplayAppointment.Add(appArray[slot - 1]);
                            slotCount--;
                            // AddToAppointment(appArray);
                            xmlObject.WriteToXMLFile(appointmentList);
                            MessageBox.Show("Successfully added candidate details to file");

                            ResetFields();
                        }
                        else
                        {
                            MessageBox.Show("Fill all the fields..");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Slot Taken..");
                    }
                }
            }
        }