Example #1
0
        private static PledgeLog CreateFileProcessPledgeLog(IConfiguration configuration, IRemoteJob job, Dictionary<string, string> loggingOptions)
        {
            string sessionId = Guid.Empty.ToString();
            string fileName = null;

            loggingOptions?.TryGetValue(PledgeGlobal.SessionId, out sessionId);
            loggingOptions?.TryGetValue(PledgeGlobal.InputFileName, out fileName);

            PledgeLog logEntry = new PledgeLog()
            {
                ConfigId = configuration.Id.ToString(),
                StartTime = DateTime.UtcNow,
                DateCreated = DateTime.UtcNow,
                SessionId = sessionId,
                RunType = sessionId == Guid.Empty.ToString() ? RunType.ScheduledJobRun : RunType.WebsiteRun
            };

            if (job != null)
            {
                logEntry.JobId = job.JobId.ToString();
                var propertyBag = job.IngestMediumSettings;
                if (string.IsNullOrWhiteSpace(fileName))
                {
                    var sourceFolder = propertyBag.GetProperty(PledgeGlobal.ImportFolderKey);
                    var filePattern = propertyBag.GetProperty(PledgeGlobal.FilePatternKey);
                    try
                    {
                        fileName = Directory.GetFiles(sourceFolder, filePattern).FirstOrDefault();
                    }
                    catch
                    {
                        fileName = $"{filePattern} (in) {sourceFolder}";
                    }

                }
                logEntry.Write(propertyBag, nameof(job.IngestMediumSettings));
                logEntry.Write(job.EgestHandlerType.ToString(), nameof(job.EgestHandlerType));
                logEntry.Write(job.IngestHandlerType.ToString(), nameof(job.IngestHandlerType));
                logEntry.Write(loggingOptions, nameof(loggingOptions));
            }

            logEntry.Subject = $"Process File: {fileName}";

            return logEntry;
        }
Example #2
0
        /// <summary>
        /// Erzeugt eine neue Beschreibung.
        /// </summary>
        /// <param name="recording">Die Aufzeichnung, deren Daten ├╝bernommen werden sollen.</param>
        /// <param name="fileMap">Alle Dateien zur Gesamtaktivit├Ąt.</param>
        /// <returns>Die neue Beschreibung.</returns>
        public static ScheduleInfo Create( VCRRecordingInfo recording, Dictionary<Guid, string[]> fileMap )
        {
            // Find files
            string[] files = null;
            if (recording.ScheduleUniqueID.HasValue)
                fileMap?.TryGetValue( recording.ScheduleUniqueID.Value, out files );

            // Create new
            return
                new ScheduleInfo
                {
                    ScheduleUniqueID = recording.ScheduleUniqueID.HasValue ? recording.ScheduleUniqueID.Value.ToString( "N" ).ToUpper() : null,
                    JobUniqueID = recording.JobUniqueID.HasValue ? recording.JobUniqueID.Value.ToString( "N" ).ToUpper() : null,
                    StartsAt = recording.StartsAt.GetValueOrDefault( DateTime.UtcNow ),
                    TotalSize = recording.TotalSize,
                    Source = recording.Source,
                    EndsAt = recording.EndsAt,
                    Files = files ?? _NoFiles,
                    Name = recording.Name,
                };
        }
Example #3
0
        public Event GetTennisEventInformation(string id)
        {
            Subscribe(id);

            var header = new WebHeaderCollection {{"method", "1"}};
            var requestPow = powRequest(2, header);
            if (requestPow.Length < 50)
            {
                Debug.Write("Error. Repsonse from server" + requestPow);
                Unsubscribe(id);
                GetTennisEventInformation(id);
            }
            var eventExpandedData = requestPow.Split((char) 0x01);
            eventExpandedData = eventExpandedData[eventExpandedData.Length - 1].Split((char) 0x7c);

            var resultList = new List<Dictionary<string, string>>();
            var currentRoot = new Dictionary<string, string>();

            resultList.Add(new Dictionary<string, string>());
            resultList.Add(new Dictionary<string, string>());

            var firstItem = true;

            string currentKey = null;
            string competitionType = null;
            string eventName = null;

            string team1Score = null;
            string team2Score = null;

            string name1Player = null;
            string name2Player = null;

            foreach (var anEventExpandedData in eventExpandedData)
            {
                var parsedLine = parameterizeLine(anEventExpandedData);

                if (parsedLine == null)
                    continue;

                if (parsedLine.ContainsKey("EV"))
                {
                    //Event
                    parsedLine.TryGetValue("EV", out currentRoot);
                    Debug.Assert(currentRoot != null, "currentRoot != null");
                    currentRoot?.TryGetValue("CT", out competitionType);
                    currentRoot?.TryGetValue("NA", out eventName);
                }
                else if (parsedLine.ContainsKey("SC"))
                {
                    parsedLine.TryGetValue("SC", out currentRoot);
                    if (firstItem)
                    {
                        currentKey = "name";
                        firstItem = false;
                    }
                    else
                    {
                        Debug.Assert(currentRoot != null, "currentRoot != null");
                        currentRoot.TryGetValue("NA", out currentKey);
                    }
                }
                else if (parsedLine.ContainsKey("TE"))
                {
                    parsedLine.TryGetValue("TE", out currentRoot);
                    var equelsValue = "";
                    currentRoot.TryGetValue("OR", out equelsValue);
                    if (string.Equals(equelsValue, "0"))
                    {
                        currentRoot.TryGetValue("PO", out team1Score);
                        currentRoot.TryGetValue("NA", out name1Player);
                    }
                    else
                    {
                        currentRoot.TryGetValue("NA", out name2Player);
                        currentRoot.TryGetValue("PO", out team2Score);
                    }
                }
            }
            Unsubscribe(id);
            if (competitionType == null)
            {
                Debug.WriteLine("[Bet365] Competition Type null");
                Debug.Write("Repsonse from server" + requestPow);
                return null;
            }
            var team1 = new Team(name1Player, team1Score);
            var team2 = new Team(name2Player, team2Score);
            var eEvent = new Event(id, competitionType, team1, team2);
            return eEvent;
        }
            public CustomStartupSequence BuildSequence(string targetPath, Dictionary<string, string> bspDict, Dictionary<string, string> debugMethodConfig, LiveMemoryLineHandler lineHandler)
            {
                if (!File.Exists(targetPath))
                    throw new Exception(targetPath + " not found. Debugging will not be possible.");

                bool stubFound = false;
                using (var elf = new ELFFile(targetPath))
                {
                    foreach (var sym in elf.LoadAllSymbols())
                    {
                        if (sym.Name == "gdbstub_init")
                        {
                            stubFound = true;
                            break;
                        }
                    }
                }

                if (!stubFound)
                {
                    var wrp = new ResultWrapper();
                    _SyncContext.Send(o => ((ResultWrapper)o).Result = MessageBox.Show("The programmed image does not contain the GDB stub. Do you want to open instructions on debugging with ESP8266 GDB stub?", "VisualGDB", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information), wrp);
                    switch(wrp.Result)
                    {
                        case DialogResult.Yes:
                            Process.Start("http://visualgdb.com/KB/esp8266gdbstub");
                            goto case DialogResult.Cancel;
                        case DialogResult.No:
                            break;
                        case DialogResult.Cancel:
                            throw new OperationCanceledException();
                    }
                }

                string val;
                if (!debugMethodConfig.TryGetValue("com.sysprogs.esp8266.program_flash", out val) || val != "0")
                {
                    var wrp = new ResultWrapper();
                    _SyncContext.Send(o => ((ResultWrapper)o).Result = MessageBox.Show("Please reboot your ESP8266 into the bootloader mode and press OK.", "VisualGDB", MessageBoxButtons.OKCancel, MessageBoxIcon.Information), wrp);
                    if (wrp.Result != DialogResult.OK)
                        throw new OperationCanceledException();

                    using (var serialPort = new SerialPortStream(debugMethodConfig["com.sysprogs.esp8266.gdbstub.com_port"], int.Parse(debugMethodConfig["com.sysprogs.esp8266.gdbstub.bl_baud"]), System.IO.Ports.Handshake.None))
                    {
                        serialPort.AllowTimingOutWithZeroBytes = true;
                        int resetDelay;
                        if (!debugMethodConfig.TryGetValue("com.sysprogs.esp8266.reset_delay", out val) || !int.TryParse(val, out resetDelay))
                            resetDelay = 25;

                        string seq;
                        debugMethodConfig.TryGetValue("com.sysprogs.esp8266.gdbstub.reset_sequence", out seq);
                        ESP8266BootloaderClient client = new ESP8266BootloaderClient(serialPort, resetDelay, seq);
                        client.Sync();
                        var regions = ESP8266StartupSequence.BuildFLASHImages(targetPath, bspDict, debugMethodConfig, lineHandler);

                        ProgramProgressForm frm = null;
                        _SyncContext.Post(o => { frm = new ProgramProgressForm(); frm.ShowDialog(); }, null);
                        int totalSize = 0;
                        foreach (var r in regions)
                            totalSize += r.Size;

                        ESP8266BootloaderClient.BlockWrittenHandler handler = (s, a, len) => frm.UpdateProgressAndThrowIfCanceled(a, len, totalSize);
                        bool useDIO = false;

                        try
                        {
                            client.BlockWritten += handler;
                            foreach (var r in regions)
                            {
                                var data = File.ReadAllBytes(r.FileName);
                                if (r.Offset == 0 && data.Length >= 4)
                                    useDIO = (data[2] == 2);

                                client.ProgramFLASH((uint)r.Offset, data);
                            }
                        }
                        finally
                        {
                            client.BlockWritten -= handler;
                            _SyncContext.Post(o => { frm.Close(); frm.Dispose(); }, null);
                        }

                        client.RunProgram(useDIO, false);
                    }
                }

                string tmp = null;
                if (debugMethodConfig?.TryGetValue("SYS:PROGRAM_WITHOUT_DEBUGGING", out tmp) == true && tmp == "1")
                    return null;    //Suppress connecting to gdb

                return new CustomStartupSequence
                {
                    Steps = new List<CustomStartStep> {
                        new CustomStartStep("set serial baud $$com.sysprogs.esp8266.gdbstub.baud$$"),
                        new CustomStartStep(@"target remote \\.\$$com.sysprogs.esp8266.gdbstub.com_port$$"),
                    }
                };
            }