Esempio n. 1
0
 private void ButtonInstall_Click(object sender, RoutedEventArgs e)
 {
     RegistryUtil.SetToConfig(GitIconOverlayHandler.RootFloderFiled, PathUtil.Base);
     TextBoxLog.Log("SetToRegeditConfig: " + GitIconOverlayHandler.RootFloderFiled + " = " + PathUtil.Base);
     TextBoxLog.Log(ProcessUtil.Run(_asmPath, _dllPath + " /codebase"));
     MessageBox.Show("安装完成,重启后生效,请保留此文件夹");
 }
Esempio n. 2
0
        private void Menu_Load(object sender, EventArgs e)
        {
            var textlog = new TextBoxLog(textBoxLog);
            var filelog = new FileLog();

            multilog = new MultiLogger(textlog, filelog);
        }
Esempio n. 3
0
 private void ButtonUninstall_Click(object sender, RoutedEventArgs e)
 {
     RegistryUtil.RemoveFromConfig(GitIconOverlayHandler.RootFloderFiled);
     TextBoxLog.Log("RemoveFromRegeditConfig: " + GitIconOverlayHandler.RootFloderFiled);
     TextBoxLog.Log(ProcessUtil.Run(_asmPath, _dllPath + " /u"));
     MessageBox.Show("卸载完成,重启后生效,重启后可手动删除此文件夹");
 }
Esempio n. 4
0
        private void ButtonClustering_Click(object sender, RoutedEventArgs e)
        {
            TextBoxLog.Clear();

            try
            {
                AlgorithmKMeans alg = new AlgorithmKMeans(clusterData, int.Parse(TextBoxNumberOfClusters.Text));
                alg.DistanceFunction = GetDistanceFunction();
                alg.MaxIterations    = int.Parse(TextBoxMaximumIterations.Text);
                alg.Iteration       += Alg_Iteration;

                alg.Run();

                PointChart.Data = clusterData;
                PointChart.Draw();

                DataGridClusterStats.ItemsSource = clusterData.GetClusterStatistics();
            }
            catch (NullReferenceException)
            {
                WPFMessageBox.MsgError("Empty dataset, please load a datafile.");
            }
            catch (InvalidOperationException)
            {
                WPFMessageBox.MsgError("An empty cluster created. Please run algorithm once more. The value of K is too big?");
            }
            catch (Exception ex)
            {
                WPFMessageBox.MsgError("An error occured!", ex);
            }
        }
Esempio n. 5
0
 // Scroll to bottom if TextBoxLog is visible
 private void TextBoxLog_VisibleChanged(object sender, EventArgs e)
 {
     if (TextBoxLog.Visible)
     {
         TextBoxLog.SelectionStart = TextBoxLog.TextLength;
         TextBoxLog.ScrollToCaret();
     }
 }
Esempio n. 6
0
 public void LogAdd(object sender, MyEventMessage e)
 {
     TextBoxLog.Invoke((Action) delegate
     {
         fullLog += e.Message + "\r\n";
         UpdateLog();
     });
 }
Esempio n. 7
0
 private void _vm_LogAppended(object sender, System.EventArgs e)
 {
     if (TextBoxLog.IsFocused)
     {
         return;
     }
     TextBoxLog.ScrollToEnd();
 }
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new ViewModel(msg =>
     {
         TextBoxLog.AppendText(msg + Environment.NewLine);
         TextBoxLog.ScrollToEnd();
     });
 }
Esempio n. 9
0
        private void AppendLog(string logs)
        {
            if (TextBoxLog.Text.Length > 20000)
            {
                TextBoxLog.Text = TextBoxLog.Text.Substring(10000);
            }

            TextBoxLog.AppendText(Environment.NewLine + logs);
        }
Esempio n. 10
0
 public void ClearLog()
 {
     this.Invoke(new MethodInvoker(delegate()
     {
         TextBoxLog.Clear();
         this.Refresh();
         this.Update();
     }));
 }
Esempio n. 11
0
 public void AddTextLog(string text)
 {
     this.Invoke(new MethodInvoker(delegate()
     {
         TextBoxLog.AppendText(string.Format("\r\n{0}", text));
         this.Refresh();
         this.Update();
     }));
 }
Esempio n. 12
0
        public HourlyLog(String time, AlertForm parent)
        {
            InitializeComponent();
            labelTime.Text = time;

            this.Time   = time;
            this.Parent = parent;

            //focus this window and the text box
            //Activate();  //doesn't work!
            TextBoxLog.Focus();
        }
Esempio n. 13
0
        private void AppendLogText(string message)
        {
            if (CheckAndInvokeIfRequired(() => AppendLogText(message)))
            {
                return;
            }

            var logMessage = $"{DateTime.Now} - {message}";

            Debug.WriteLine(logMessage);
            TextBoxLog.AppendText($"{logMessage}\r\n");
        }
Esempio n. 14
0
 private void MenuOpen_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         LoadFile();
         TextBoxLog.Clear();
         DataGridClusterStats.ItemsSource = null;
     }
     catch (Exception ex)
     {
         WPFMessageBox.MsgError(ex.Message);
     }
 }
Esempio n. 15
0
 public void LogMessage(string message, Color color, Font font)
 {
     if (this.TextBoxLog.InvokeRequired)
     {
         LogMessageCallback CB = new LogMessageCallback(LogMessage);
         this.Invoke(CB, new object[] { message, color, font });
     }
     else
     {
         TextBoxLog.AppendText(message, color, font);
         TextBoxLog.ScrollToCaret();
     }
 }
Esempio n. 16
0
        public void UpdateLog()
        {
            TextBoxLog.Clear();
            var x = fullLog.Split(new [] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string str in x)
            {
                string pattern = comboBoxAccounts.SelectedItem.ToString();
                if (Regex.IsMatch(str, pattern))
                {
                    TextBoxLog.Text += str + "\r\n";
                }
            }
        }
Esempio n. 17
0
 public void AppendLog(string s)
 {
     TextBoxLog.Text += s;
     if (s.Last() == '\n')
     {
         if (TextBoxLog.LineCount > 50)
         {
             var index = TextBoxLog.Text.IndexOf("\r\n");
             if (index >= 0)
             {
                 TextBoxLog.Text = TextBoxLog.Text.Substring(index + 2);
             }
         }
         TextBoxLog.ScrollToEnd();
     }
 }
Esempio n. 18
0
 private async void CheckLoadLog_Checked(object sender, RoutedEventArgs e)
 {
     assistant.WriteLog("Log wird automatisch ausgelesen!");
     TextBoxLog.ScrollToEnd();
     while (CheckLoadLog.IsChecked == true)
     {
         if (File.Exists(assistant.GetLogPath()))
         {
             TextBoxLog.Text = File.ReadAllText(assistant.GetLogPath());
         }
         else
         {
             TextBoxLog.Text = "Keine Log-Datei gefunden...";
         }
         await Task.Delay(TimeSpan.FromMilliseconds(100));
     }
 }
Esempio n. 19
0
        /// <summary> команда разбивки </summary>
        private void ButtonSplit_Click(object sender, RoutedEventArgs e)
        {
            // выключаем кнопку во избежание случайного повторного запуска
            //ButtonSplit.IsEnabled = false;
            //очищем окно лога
            TextBoxLog.Clear();

            // достаём из текстовых блоков пути к файлу и консольному приложению
            var processpath = TextBoxMmgPath.Text;
            var inputpath   = TextBoxPath.Text;

            //проверяем адекватность текста в в блоках
            if (CheckingFileExisting(processpath, "mkvmerge.exe is not found."))
            {
                return;
            }
            if (CheckingFileExisting(inputpath, "Mediafile is not found"))
            {
                return;
            }

            // задаём название будущего файла
            var outputpath = GeneratingFileName(inputpath);



            // формируем строку аргументов для командной строки консольного приложения
            var argumentsstring = " -o " +
                                  "\"" + outputpath + "\" " +
                                  "\"" + inputpath + "\" " +
                                  MakingArgs();

            //MessageBox.Show(argumentsstring);

            // запуск консольного приложения
            consoleinterface.Start(processpath, argumentsstring, false);
        }
        public void PlotSEPro()
        {
            LoadNRecords();
            List <string> identifiedProt = new List <string>();

            if ((bool)CheckBoxUnique.IsChecked)
            {
                identifiedProt = (from p in pckg.MyProteins.MyProteinList
                                  where p.PeptideResults.Exists(x => x.MyMapableProteins.Count == 1)
                                  //where p.PeptideResults.Exists(b => b.NoMyMapableProteins == 1)
                                  select p.Locus).ToList();
            }
            else
            {
                identifiedProt = pckg.MyProteins.MyProteinList.Select(a => a.Locus).ToList();
            }


            //clean possible np tags
            //for (int i = 0; i < identifiedProt.Count; i++)
            //{
            //    identifiedProt[i] = Regex.Replace(identifiedProt[i], "nxp:NX_", "");
            //    identifiedProt[i] = Regex.Replace(identifiedProt[i], "-[0-9]+", "");
            //}

            LabelProteins.Content = identifiedProt.Count;

            List <NextProtRecord> identifiedRecords = (from rec in nRecords
                                                       where identifiedProt.Contains(rec.ID)
                                                       select rec).ToList();

            //Get all the proteins that did not map------------------------

            List <string> unmapped = (from p in pckg.MyProteins.MyProteinList
                                      where !identifiedRecords.Exists(a => a.ID.Contains(p.Locus))
                                      select p.Locus).ToList();

            TextBoxLog.AppendText("Unmapped IDs\n");
            TextBoxLog.AppendText(string.Join(", ", unmapped));

            //--------------------------------------------------------------



            Plot(identifiedRecords);


            var result = from r in identifiedRecords
                         from p in pckg.MyProteins.MyProteinList
                         where r.ID.Contains(p.Locus)
                         select new
            {
                ID = p.Locus,
                NoUniquePeptides = p.PeptideResults.Count(c => c.NoMyMapableProteins == 1),
                SequenceCount    = p.SequenceCount,
                Chr         = r.Chr,
                Antibody    = r.AntiBody,
                Proteomics  = r.Proteomics,
                Description = p.Description
            };

            //var result = from p in pckg.MyProteins.MyProteinList
            //                where identifiedRecords.Exists(b => p.Locus.Contains(b.ID))
            //                select new
            //                {
            //                    ID = p.Locus,
            //                    NoUniquePeptides = p.PeptideResults.Count(c => c.NoMyMapableProteins == 1),
            //                    SequenceCount = p.SequenceCount,
            //                    SpecCount = p.SpectrumCount,
            //                    Chr = identifiedIDs.Find(d => p.Locus.Contains(d.Item1)).Item2,
            //                    Antibody = identifiedIDs.Find(d => p.Locus.Contains(d.Item1)).Item3,
            //                    Proteomics = identifiedIDs.Find(d => p.Locus.Contains(d.Item1)).Item4,
            //                    Description = p.Description
            //                };

            DataGridInterestingProteins.ItemsSource = result;
        }
Esempio n. 21
0
        private void BindEvents()
        {
            Load += async(s, e) =>
            {
                StatusStripLabel.Text = "checking configs...";
                logger.Log("starting to CheckConfigs");
                await CheckConfigs();

                logger.Log("CheckConfigs finished");

                StatusStripLabel.Text = "load solr infomation...";
                await LoadSolrInfo();

                StatusStripLabel.Text = "finished";
            };

            FormClosed += (s, e) =>
            {
                logger.Log("application exit.");
                logger.Dispose();
            };

            timer.Tick += (s, e) =>
            {
                if (_timerExec)
                {
                    return;
                }

                _timerExec = true;
                var logs = logger.GetBufferLog();

                Action act = () =>
                {
                    AppendLog(logs);
                    TextBoxLog.Select(TextBoxLog.TextLength, 0);
                    TextBoxLog.ScrollToCaret();
                };

                if (logs.Length > 0)
                {
                    this.Invoke(act);
                }

                _timerExec = false;
            };

            ComboSolrCollection.SelectedIndexChanged += async(s, e) =>
            {
                var col   = ComboSolrCollection.Items[ComboSolrCollection.SelectedIndex].ToString();
                var files = await SolrHttpOperation.GetFiles(col);

                var dirs = files.Lst.FirstOrDefault(x => x.Name == "files").Lsts
                           .Where(x => x.Bool != null && x.Bool.Count > 0 && x.Bool.FirstOrDefault().Name == "directory")
                           .Select(x => x.Name);

                if (files.Lst.FirstOrDefault(x => x.Name == "files") != null)
                {
                    await GenTree(tree.Nodes, col);
                }
            };

            tree.AfterSelect += async(sender, treeArgs) =>
            {
                var selectedNode     = treeArgs.Node;
                var selectedNodeText = selectedNode.FullPath;

                if (selectedNode.Tag.ToString() == "d")
                {
                    await GenTree(selectedNode.Nodes, ComboSolrCollection.Items[ComboSolrCollection.SelectedIndex].ToString(), selectedNodeText);
                }
                if (selectedNode.Tag.ToString() == "f")
                {
                    var content = await SolrHttpOperation.GetFileContent(ComboSolrCollection.Items[ComboSolrCollection.SelectedIndex].ToString(), selectedNodeText);

                    TextBoxFileContent.Text = content;
                    TextBoxFileContent.Tag  = $"{ComboSolrCollection.Items[ComboSolrCollection.SelectedIndex].ToString()}/{ selectedNode.FullPath.Replace("\\", "/")}";
                }
            };

            tree.AfterExpand += async(s, e) =>
            {
                if (tree.SelectedNode != e.Node)
                {
                    tree.SelectedNode = e.Node;
                }
            };

            LinkLblCopy.Click += async(s, e) =>
            {
                Clipboard.SetText(TextBoxFileContent.Text);
                LinkLblCopy.Text = "复制成功";
                await Task.Delay(2000);

                LinkLblCopy.Text = "COPY";
            };

            //导出
            BtnExportAllFiles.Click += async(s, e) =>
            {
                BtnExportAllFiles.Enabled = false;
                var path = await ExportAllFiles(ComboSolrCollection.Items[ComboSolrCollection.SelectedIndex].ToString());

                BtnExportAllFiles.Enabled = true;

                var psi = new ProcessStartInfo("cmd.exe", $"/c \"explorer.exe {path}\"");
                psi.CreateNoWindow = true;
                Process.Start(psi);
            };

            BtnExportAllCollections.Click += async(s, e) =>
            {
                BtnExportAllCollections.Enabled = false;

                var path = "";
                ComboSolrCollection.SelectedIndex = 0;
                foreach (var item in ComboSolrCollection.Items)
                {
                    path = await ExportAllFiles(item.ToString());
                }
                var configPath = new DirectoryInfo(path).Parent.FullName;

                BtnExportAllCollections.Enabled = true;

                var psi = new ProcessStartInfo("cmd.exe", $"/c \"explorer.exe {configPath}\"");
                psi.CreateNoWindow = true;
                Process.Start(psi);
            };

            //文件更新
            BtnUpdateCurrentFile.Click += async(s, e) =>
            {
                var path = TextBoxFileContent.Tag?.ToString();
                if (string.IsNullOrWhiteSpace(path))
                {
                    MessageBox.Show("please select a node for update.");
                    return;
                }

                var dr = MessageBox.Show($"将更新文件:[{path}], 是否继续?", "提示", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    BtnUpdateCurrentFile.Enabled = false;
                    StatusStripLabel.Text        = "updateing config...";

                    await UpdateCurrentFile(path);

                    StatusStripLabel.Text        = "finished";
                    BtnUpdateCurrentFile.Enabled = true;
                    MessageBox.Show("更新成功");
                }
            };

            //重载
            BtnReoload.Click += async(s, e) =>
            {
                BtnReoload.Enabled = false;
                await LoadSolrInfo();

                BtnReoload.Enabled = true;
            };

            //创建配置
            BtnUploadConfig.Click += async(s, e) =>
            {
                BtnUploadConfig.Enabled = false;
                string confName = "", confFolder = "";
                var    frm = new FrmConfigUploadBox();
                frm.StartPosition = FormStartPosition.CenterParent;
                frm.FormClosing  += (sender, args) =>
                {
                    confFolder = frm.ConfigFolder;
                    confName   = frm.ConfigName;
                };
                frm.ShowDialog(this);
                if (confName != "" && confFolder != "")
                {
                    var client = SolrHttpClient.Create(
                        AppGlobalConfigs.AppConfig.Solr.BaseUrl,
                        AppGlobalConfigs.AppConfig.Solr.Auth.Username,
                        AppGlobalConfigs.AppConfig.Solr.Auth.Password
                        );

                    if (Directory.Exists(confFolder))
                    {
                        var tmpDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tmp");
                        if (!Directory.Exists(tmpDir))
                        {
                            Directory.CreateDirectory(tmpDir);
                        }

                        var file = Path.Combine(tmpDir, Guid.NewGuid().ToString("N") + ".zip");
                        using (var zip = new ZipFile())
                        {
                            zip.AddDirectory(confFolder);
                            zip.Save(file);
                        }
                        await SolrHttpOperation.CreateConfig(confName, file);
                    }
                }

                BtnUploadConfig.Enabled = true;
            };
        }
 public void MsgAddLog(String strToAdd)
 {
     TextBoxLog.Text = DateTime.Now.ToString() + " -- " + strToAdd + Environment.NewLine + TextBoxLog.Text;
     TextBoxLog.Refresh();
 }
Esempio n. 23
0
        public void RefreshDisplay()
        {
            //if (!panelControls.Visible)
            //    return;

            DateTime now = DateTime.Now;
            DateTime utc = now.ToUniversalTime();

            ASCOM.Utilities.Util u = new Utilities.Util();

            labelDate.Text          = utc.ToLongDateString();
            labelLTValue.Text       = now.TimeOfDay.ToString(@"hh\hmm\mss\.f\s");
            labelUTValue.Text       = utc.TimeOfDay.ToString(@"hh\hmm\mss\.f\s");
            labelSiderealValue.Text = wisesite.LocalSiderealTime.ToString();

            labelRightAscensionValue.Text = Angle.FromHours(wisetele.RightAscension).ToNiceString();
            labelDeclinationValue.Text    = Angle.FromDegrees(wisetele.Declination).ToNiceString();
            labelHourAngleValue.Text      = Angle.FromHours(wisetele.HourAngle, Angle.Type.HA).ToNiceString();

            labelNewRA.Text         = "";
            labelNewRARadians.Text  = Angle.FromHours(wisetele.RightAscension).Radians.ToString();
            labelNewDec.Text        = "";
            labelNewDecRadians.Text = Angle.FromDegrees(wisetele.Declination).Radians.ToString();

            labelAltitudeValue.Text = Angle.FromDegrees(wisetele.Altitude).ToNiceString();
            labelAzimuthValue.Text  = Angle.FromDegrees(wisetele.Azimuth).ToNiceString();

            labelHAEncValue.Text  = wisetele.HAEncoder.Value.ToString();
            labelDecEncValue.Text = wisetele.DecEncoder.Value.ToString();

            axisValue.Text = wisetele.HAEncoder.AxisValue.ToString();
            wormValue.Text = wisetele.HAEncoder.WormValue.ToString();

            string why;

            if (wisesite.computerControl == null)
            {
                labelTelescopeComputerControl.ForeColor = Color.Yellow;
                why = "Cannot read the computer control switch!";
            }
            else if (wisesite.computerControl.IsSafe)
            {
                labelTelescopeComputerControl.ForeColor = Color.Green;
                why = "Computer control is enabled.";
            }
            else
            {
                labelTelescopeComputerControl.ForeColor = Color.Red;
                why = why = "Computer control switch is OFF!";
            }
            toolTip.SetToolTip(labelTelescopeComputerControl, why);

            if (wisesite.safeToOpen == null)
            {
                labelTelescopeSafeToOpen.ForeColor = Color.Yellow;
                why = "Cannot connect to the safeToOpen driver!";
            }
            else if (wisesite.safeToOpen.IsSafe)
            {
                labelTelescopeSafeToOpen.ForeColor = Color.Green;
                why = "Conditions are safe to open the dome.";
            }
            else
            {
                labelTelescopeSafeToOpen.ForeColor = Color.Red;
                why = wisesite.safeToOpen.CommandString("unsafeReasons", false);
            }
            toolTip.SetToolTip(labelTelescopeSafeToOpen, why);

            if (wisesite.safeToImage == null)
            {
                labelTelescopeSafeToImage.ForeColor = Color.Yellow;
                why = "Cannot connect to the safeToImage driver!";
            }
            else if (wisesite.safeToImage.IsSafe)
            {
                labelTelescopeSafeToImage.ForeColor = Color.Green;
                why = "Conditions are safe to image.";
            }
            else
            {
                labelTelescopeSafeToImage.ForeColor = Color.Red;
                why = wisesite.safeToImage.CommandString("unsafeReasons", false);
            }
            toolTip.SetToolTip(labelTelescopeSafeToImage, why);

            checkBoxPrimaryIsActive.Checked   = wisetele.AxisIsMoving(TelescopeAxes.axisPrimary);
            checkBoxSecondaryIsActive.Checked = wisetele.AxisIsMoving(TelescopeAxes.axisSecondary);
            string activeSlewers = wisetele.slewers.ToString();

            checkBoxSlewingIsActive.Text     = (activeSlewers == string.Empty) ? "Slewing" : "Slewing (" + activeSlewers + ")";
            checkBoxSlewingIsActive.Checked  = wisetele.Slewing;
            checkBoxTrackingIsActive.Checked = wisetele.Tracking;

            WiseVirtualMotor m;

            m = null;
            if (wisetele.WestMotor.isOn)
            {
                m = wisetele.WestMotor;
            }
            else if (wisetele.EastMotor.isOn)
            {
                m = wisetele.EastMotor;
            }

            checkBoxPrimaryIsActive.Text = "Primary";
            if (m != null)
            {
                checkBoxPrimaryIsActive.Text += ": " + m.Name.Remove(m.Name.IndexOf('M')) + "@" +
                                                WiseTele.RateName(m.currentRate).Replace("rate", "");
            }

            m = null;
            if (wisetele.NorthMotor.isOn)
            {
                m = wisetele.NorthMotor;
            }
            else if (wisetele.SouthMotor.isOn)
            {
                m = wisetele.SouthMotor;
            }


            checkBoxSecondaryIsActive.Text = "Secondary";
            if (m != null)
            {
                checkBoxSecondaryIsActive.Text += ": " + m.Name.Remove(m.Name.IndexOf('M')) + "@" +
                                                  WiseTele.RateName(m.currentRate).Replace("rate", "");
            }

            checkBoxTrack.Checked = wisetele.Tracking;

            if (scopeBackgroundMover != null && scopeBackgroundMover.IsBusy)
            {
                TextBoxLog.Text = "Working ...";
            }

            if (resultsAvailable)
            {
                TextBoxLog.Clear();
                if (results.Count == 0)
                {
                    TextBoxLog.Text = "Cancelled by user!";
                }
                else
                {
                    TelescopeAxes axis = results[0].axis;

                    for (int i = 0; i < results.Count; i++)
                    {
                        TextBoxLog.Text += string.Format("[{0}]: ({2})\r\n{1}",
                                                         i, results[i].ToString(), results[i].cancelled ? "cancelled" : "completed");
                    }
                }
                resultsAvailable = false;
            }

            if (panelDome.Visible)
            {
                labelDomeAzimuthValue.Text       = domeSlaveDriver.Azimuth;
                labelDomeStatusValue.Text        = domeSlaveDriver.Status;
                labelDomeShutterStatusValue.Text = domeSlaveDriver.ShutterStatus;
                checkBoxVent.Checked             = WiseDome.Instance.Vent;
            }

            if (groupBoxWeather.Visible)
            {
                if (!wisesite.observingConditions.Connected)
                {
                    string nc = "???";

                    labelAgeValue.Text        = nc;
                    labelCloudCoverValue.Text = nc;
                    labelCloudCoverValue.Text = nc;
                    labelDewPointValue.Text   = nc;
                    labelSkyTempValue.Text    = nc;
                    labelTempValue.Text       = nc;
                    labelHumidityValue.Text   = nc;
                    labelPressureValue.Text   = nc;
                    labelRainRateValue.Text   = nc;
                    labelWindSpeedValue.Text  = nc;
                    labelWindDirValue.Text    = nc;
                }
                else
                {
                    try
                    {
                        ObservingConditions oc = wisesite.observingConditions;

                        labelAgeValue.Text = ((int)Math.Round(oc.TimeSinceLastUpdate(""), 2)).ToString() + "sec";

                        double d = oc.CloudCover;
                        if (d == 0.0)
                        {
                            labelCloudCoverValue.Text = "Clear";
                        }
                        else if (d == 50.0)
                        {
                            labelCloudCoverValue.Text = "Cloudy";
                        }
                        else if (d == 90.0)
                        {
                            labelCloudCoverValue.Text = "VeryCloudy";
                        }
                        else
                        {
                            labelCloudCoverValue.Text = "Unknown";
                        }

                        labelDewPointValue.Text  = oc.DewPoint.ToString() + "°C";
                        labelSkyTempValue.Text   = oc.SkyTemperature.ToString() + "°C";
                        labelTempValue.Text      = oc.Temperature.ToString() + "°C";
                        labelHumidityValue.Text  = oc.Humidity.ToString() + "%";
                        labelPressureValue.Text  = oc.Pressure.ToString() + "mB";
                        labelRainRateValue.Text  = (oc.RainRate > 0.0) ? "Wet" : "Dry";
                        labelWindSpeedValue.Text = oc.WindSpeed.ToString() + "m/s";
                        labelWindDirValue.Text   = oc.WindDirection.ToString() + "°";
                    }
                    catch (PropertyNotImplementedException e)
                    {
                        debugger.WriteLine(Debugger.DebugLevel.DebugLogic, "OC: exception: {0}", e.Message);
                    }
                }
            }

            if (panelFocuser.Visible)
            {
                labelFocusCurrentValue.Text = wisefocuser.position.ToString();;
            }
        }
Esempio n. 24
0
 private void txtBoxClearMenuItem_Click(object sender, RoutedEventArgs e)
 {
     TextBoxLog.Clear();
 }
Esempio n. 25
0
 private void TextBoxLog_TextChanged(object sender, TextChangedEventArgs e)
 {
     TextBoxLog.ScrollToEnd();
 }
Esempio n. 26
0
        private void Alg_Iteration(object sender, AlgorithmEventArgs e)
        {
            string log = $"Iteration: {e.IterationNumber}, Sum of errors: {e.SumOfErrors}, Sum of squared errors: {e.SumOfSquaredErrors}";

            TextBoxLog.AppendText(log + Environment.NewLine);
        }
Esempio n. 27
0
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     TextBoxLog.Log("Overlay Priority:" + GitIconOverlayHandler.Priority);
     TextBoxLog.Log("FirstAccessStatus:" + GitIconOverlayHandler.FirstAccessStatus);
 }
Esempio n. 28
0
        private void ButtonTransmitir_Click(object sender, EventArgs e)
        {
            try
            {
                ButtonProcurar.Enabled   = false;
                ButtonTransmitir.Enabled = false;
                TextBoxLog.Clear();

                ProgressBarSecundaria.Value = 0;
                ProgressBarPrimaria.Value   = 0;

                dispatcher.DoEvents();

                // Instancia a classe que irá assinar o arquivo
                var assinador = new AssinadorXML(dispatcher, ProgressBarSecundaria);

                var dirZipDescompactado = Guid.NewGuid().ToString();

                // Descompacta o arquivo .intech
                if (!Directory.Exists(dirZipDescompactado))
                {
                    Directory.CreateDirectory(dirZipDescompactado);
                }

                Zip.Descompacta(TextBoxArquivo.Text, dirZipDescompactado);

                var arquivos     = Directory.GetFiles(dirZipDescompactado);
                var contadorLote = 0;
                var totalLotes   = arquivos.Length;

                ProgressBarPrimaria.Maximum = arquivos.Length;

                // Processa cada xml contido no arquivo .intech
                foreach (var arquivo in arquivos)
                {
                    contadorLote++;

                    LabelProgressBarPrimaria.Text = $"Processando lote {contadorLote} de {totalLotes}...";

                    // Assina o xml do lote utilizando o certificado digital selecionado
                    LabelProgressBarSecundaria.Text = "Assinando lote...";
                    ProgressBarSecundaria.Value     = 0;
                    dispatcher.DoEvents();
                    var xml = assinador.AssinarEventosDoArquivo(Global.Certificado, arquivo);

                    if (xml == null)
                    {
                        return;
                    }

                    var tipoEvento = assinador.BuscarElementoAssinar(xml);

                    var ambiente = BuscarAmbiente(xml, tipoEvento);

                    if (ambiente == "1")
                    {
                        webServices = new WebServicesRF(true);
                    }
                    else
                    {
                        webServices = new WebServicesRF(false);
                    }

                    LabelProgressBarSecundaria.Text = "Enviando lote...";
                    ProgressBarSecundaria.Value     = 0;
                    ProgressBarSecundaria.Maximum   = 1;
                    dispatcher.DoEvents();

                    var retorno = webServices.ReceberLoteEvento(XElement.Parse(xml.InnerXml)).ToXmlNode();

                    ProgressBarSecundaria.Value = 1;
                    dispatcher.DoEvents();

                    //if (tipoEvento.Tag == "evtServTom")
                    //{
                    var sucesso = true;
                    var eventos = BuscaEventosRetorno(retorno);

                    LabelProgressBarSecundaria.Text = "Atualizando status dos registros...";
                    ProgressBarSecundaria.Value     = 0;
                    ProgressBarSecundaria.Maximum   = eventos.Count;
                    dispatcher.DoEvents();

                    if (eventos.Count == 0)
                    {
                        var resultado = BuscaResultadoEventoUnico(retorno);

                        if (resultado == "ERRO")
                        {
                            var mensagem = BuscaMensagemEventoUnico(retorno);

                            // Atualiza a ocorrência no banco utilizando a API
                            //ServiceEfdReinf.UpdateRecibo(oidArquivoUpload, numRecibo);
                            AdicionarLog("Erro: " + mensagem);
                            sucesso = false;
                            dispatcher.DoEvents();
                        }
                    }

                    for (int i = 0; i < eventos.Count; i++)
                    {
                        var resultado = BuscaResultadoEvento(eventos[i]);

                        if (resultado == "ERRO")
                        {
                            // Mostra um dialogo para salvar o retorno
                            //SalvarArquivoRetorno(eventos[i]);

                            var mensagem = BuscaMensagemEvento(eventos[i]);

                            try
                            {
                                // Atualiza a ocorrência no banco utilizando a API
                                //ServiceEfdReinf.UpdateRecibo(oidArquivoUpload, numRecibo);
                                AdicionarLog("Erro ao atualizar ocorrência: " + mensagem);
                                sucesso = false;
                                dispatcher.DoEvents();
                            }
                            catch (Exception ex)
                            {
                                AdicionarLog("Erro ao atualizar ocorrência: " + mensagem);
                            }
                        }
                        else
                        {
                            if (tipoEvento.Tipo != DMN_TIPO_REGISTRO.R1000)
                            {
                                try
                                {
                                    var idEvento = BuscaIDEvento(eventos[i]);
                                    var oid      = Convert.ToDecimal(idEvento.Substring(31));

                                    // Atualiza o status e o nº do recibo no banco utilizando a API
                                    var numRecibo = BuscaRecibo(eventos[i]);
                                    ServiceEfdReinf.UpdateRecibo(tipoEvento.Tipo, oid, numRecibo);
                                }
                                catch (Exception ex)
                                {
                                    // Mostra um dialogo para salvar o retorno
                                    //SalvarArquivoRetorno(eventos[i]);

                                    AdicionarLog("Erro ao atualizar movimento: " + ex.Message);
                                }
                            }
                        }

                        ProgressBarSecundaria.Increment(1);
                        dispatcher.DoEvents();
                    }

                    LabelProgressBarPrimaria.Text = string.Empty;

                    if (sucesso)
                    {
                        LabelProgressBarSecundaria.Text = "Arquivo enviado com sucesso!";
                    }
                    else
                    {
                        LabelProgressBarSecundaria.Text = "Arquivo enviado com erros.";
                    }
                    //}
                    //else
                    //{
                    //    var resultado = BuscaResultado(retorno);

                    //    if (resultado == "ERRO")
                    //    {
                    //        // Mostra um dialogo para salvar o retorno
                    //        //SalvarArquivoRetorno(retorno);

                    //        AdicionarLog("Erro: " + BuscaMensagem(retorno));
                    //    }
                    //    else
                    //    {
                    //        LabelProgressBarPrimaria.Text = string.Empty;
                    //        LabelProgressBarSecundaria.Text = "Arquivo enviado com sucesso!";
                    //        var numRecibo = BuscaRecibo(retorno);
                    //        MessageBox.Show("Arquivo enviado com sucesso!\nNúmero do recibo: " + numRecibo);

                    //        // Atualiza o status e o nº do recibo no banco
                    //        //ServiceEfdReinf.UpdateRecibo(oidArquivoUpload, numRecibo);
                    //    }
                    //}

                    ProgressBarPrimaria.Increment(1);
                    dispatcher.DoEvents();
                }

                Directory.Delete(dirZipDescompactado, true);
            }
            catch (Exception ex)
            {
                AdicionarLog("Erro: " + ex.Message);
                VerificarInnerException(ex);
            }
            finally
            {
                ButtonProcurar.Enabled   = true;
                ButtonTransmitir.Enabled = true;

                if (salvar)
                {
                    TextWriter writer = new StreamWriter(nomeArquivoLog);
                    writer.Write(logEventos);
                    writer.Flush();
                    writer.Close();
                }
            }
        }
Esempio n. 29
0
 private void ButtonTest_Click(object sender, RoutedEventArgs e)
 {
     ConsoleUtil.Print(KeysUtil.ChinaInnovation);
     TextBoxLog.Insert(ConsoleUtil.Print(KeysUtil.ChinaInnovation));
 }
Esempio n. 30
0
 private void ClearLog_Click(object sender, EventArgs e)
 {
     TextBoxLog.Clear();
 }