示例#1
0
        public static string[] GetOEStringsForKey(string key, SourceProgram source)
        {
            var cache = source == SourceProgram.OE ? _lookupCacheOE : _lookupCacheOS;

            if (cache.ContainsKey(key))
            {
                return(cache[key]);
            }


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

            string file = source == SourceProgram.OE ? "LiveResults.Client.OLEinzel.mlf" : "LiveResults.Client.OLStaffel.mlf";

            using (var s = Assembly.GetExecutingAssembly().GetManifestResourceStream(file))
            {
                using (var sr = new StreamReader(s, Encoding.GetEncoding("iso-8859-1")))
                {
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        string[] parts = temp.Split(new string[] { "¦" }, StringSplitOptions.RemoveEmptyEntries);
                        if (parts[0] == key)
                        {
                            texts.AddRange(parts);
                            break;
                        }
                    }
                }
            }

            cache.Add(key, texts.ToArray());
            return(texts.ToArray());
        }
示例#2
0
        public virtual void StartCobolProgram(ProgramIdentification programIdentification, LibraryCopyCodeElement libraryCopy)
        {
            if (Program == null)
            {
                Program        = new SourceProgram(TableOfGlobals, programIdentification);
                programsStack  = new Stack <Program>();
                CurrentProgram = Program;
                Enter(CurrentProgram, programIdentification, CurrentProgram.SymbolTable);
            }
            else
            {
                var enclosing = CurrentProgram;
                CurrentProgram = new NestedProgram(enclosing, programIdentification);
                Enter(CurrentProgram, programIdentification, CurrentProgram.SymbolTable);
            }

            if (libraryCopy != null)
            { // TCRFUN_LIBRARY_COPY
                var cnode = new LibraryCopy(libraryCopy);
                Enter(cnode, libraryCopy, CurrentProgram.SymbolTable);
                Exit();
            }

            TableOfNamespaces.AddProgram(CurrentProgram); //Add Program to Namespace table.
        }
        public void ReturnEmptyCharWhenNoMoreSource()
        {
            var source = new SourceProgram(string.Empty);

            char next = source.Inspect();

            Assert.AreEqual('\0', next);
        }
        public void ReadCurrentCharShouldReturnNextCharAndAdvance()
        {
            var source = new SourceProgram("12");

            var next = source.ReadCurrentCharacter();

            Assert.AreEqual('1', next);

            next = source.ReadCurrentCharacter();
            Assert.AreEqual('2', next);
        }
        public void AdvanceShouldRemoveCharacter()
        {
            var source = new SourceProgram("Begin");

            for (int i = 0; i < 5; i++)
            {
                source.Advance();
            }

            Assert.AreEqual('\0', source.Inspect());
        }
示例#6
0
        public static string[] GetOEStringsForKey(string key, SourceProgram source)
        {
            var cache = source == SourceProgram.OE ? m_lookupCacheOE : m_lookupCacheOS;
            if (cache.ContainsKey(key))
                return cache[key];

            var texts = new List<string>();

            string file = source == SourceProgram.OE ? "LiveResults.Client.OLEinzel.mlf" : "LiveResults.Client.OLStaffel.mlf";

            using (var s = Assembly.GetExecutingAssembly().GetManifestResourceStream(file))
            {
                if (s != null)
                {
                    using (var sr = new StreamReader(s, Encoding.GetEncoding("iso-8859-1")))
                    {
                        string temp;
                        while ((temp = sr.ReadLine()) != null)
                        {
                            string[] parts = temp.Split(new string[]
                            {
                                "¦"
                            }, StringSplitOptions.RemoveEmptyEntries);
                            if (parts[0] == key)
                            {
                                texts.AddRange(parts);
                                break;
                            }
                        }
                    }
                }
            }

            cache.Add(key, texts.ToArray());
            return texts.ToArray();
        }
        public void AdvanceOnEmptyShouldFail()
        {
            var source = new SourceProgram(string.Empty);

            Assert.Throws <InvalidOperationException>(() => source.Advance());
        }
        public void AllowCreationWithEmptySource()
        {
            var source = new SourceProgram(string.Empty);

            Assert.IsNotNull(source);
        }
示例#9
0
        internal static void DetectOxCSVFormat(SourceProgram source, string[] fields, out int fldID, out int fldSI, out int fldFName, out int fldEName, out int fldClub,
                                               out int fldClass, out int fldStart, out int fldTime, out int fldStatus, out int fldFirstPost, out int fldLeg, out int fldFinish,
                                               out int fldTxt1, out int fldTxt2, out int fldTxt3, out int fldTotalTime)
        {
            string[] stoNoFieldNames     = GetOEStringsForKey("Stnr", source);
            string[] legFieldNames       = GetOEStringsForKey("Lnr", source);
            string[] chipNoFieldNames    = GetOEStringsForKey(source == SourceProgram.OE ? "Chipnr" : "ChipNr", source);
            string[] firstNameFieldNames = GetOEStringsForKey("Vorname", source);
            string[] lastNameFieldNames  = GetOEStringsForKey("Nachname", source);
            string[] clubFieldNames      = GetOEStringsForKey(source == SourceProgram.OE ? "Ort" : "Staffel", source);
            string[] classFieldNames     = GetOEStringsForKey("Kurz", source);
            string[] startFieldNames     = GetOEStringsForKey("Start", source);
            string[] finishFieldNames    = GetOEStringsForKey("Ziel", source);
            string[] timeFieldNames      = GetOEStringsForKey("Zeit", source);
            string[] statusFieldNames    = GetOEStringsForKey("Wertung", source);

            string[] noFieldNames  = GetOEStringsForKey("Nr", source);
            var      no1FieldNames = new string[noFieldNames.Length];

            for (int i = 0; i < no1FieldNames.Length; i++)
            {
                no1FieldNames[i] = noFieldNames[i] + "1";
            }
            string[] totalTimeFieldNames = GetOEStringsForKey("Gesamtzeit", source);

            string[] txtFields = GetOEStringsForKey("Text", source);

            var txt1Fields = new string[txtFields.Length];
            var txt2Fields = new string[txtFields.Length];
            var txt3Fields = new string[txtFields.Length];

            for (int i = 0; i < txtFields.Length; i++)
            {
                txt1Fields[i] = txtFields[i] + "1";
                txt2Fields[i] = txtFields[i] + "2";
                txt3Fields[i] = txtFields[i] + "3";
            }

            fldID    = GetFieldFromHeader(fields, stoNoFieldNames);
            fldLeg   = GetFieldFromHeader(fields, legFieldNames);
            fldSI    = GetFieldFromHeader(fields, chipNoFieldNames);
            fldFName = GetFieldFromHeader(fields, firstNameFieldNames);
            fldEName = GetFieldFromHeader(fields, lastNameFieldNames);
            fldClub  = GetFieldFromHeader(fields, clubFieldNames);

            fldClass  = GetFieldFromHeader(fields, classFieldNames);
            fldStart  = GetFieldFromHeader(fields, startFieldNames);
            fldFinish = GetFieldFromHeader(fields, finishFieldNames);
            fldTime   = GetFieldFromHeader(fields, timeFieldNames);
            fldStatus = GetFieldFromHeader(fields, statusFieldNames);

            fldFirstPost = GetFieldFromHeader(fields, no1FieldNames);
            fldTxt1      = GetFieldFromHeader(fields, txt1Fields);
            fldTxt2      = GetFieldFromHeader(fields, txt2Fields);
            fldTxt3      = GetFieldFromHeader(fields, txt3Fields);
            fldTotalTime = GetFieldFromHeader(fields, totalTimeFieldNames);

            if (fldID == -1 || fldSI == -1 || fldFName == -1 || fldEName == -1 || fldClub == -1 || fldClass == -1 ||
                fldStart == -1 || fldTime == -1 ||
                fldStart == -1 || fldFirstPost == -1 || (source == SourceProgram.OS && fldLeg == -1))
            {
                /*Try detect fixedFormat*/
                if (fields[0] == "OS0016")
                {
                    fldID        = 1;
                    fldLeg       = 4;
                    fldSI        = 14;
                    fldFName     = 7;
                    fldEName     = 6;
                    fldClub      = 18;
                    fldClass     = 20;
                    fldStart     = 10;
                    fldFinish    = 11;
                    fldTime      = 12;
                    fldStatus    = 13;
                    fldFirstPost = 32;
                    fldTotalTime = 30;
                }
                else if (fields[0] == "OS0012")
                {
                    fldID        = 1;
                    fldLeg       = 4;
                    fldSI        = 14;
                    fldFName     = 7;
                    fldEName     = 6;
                    fldClub      = 18;
                    fldClass     = 20;
                    fldStart     = 10;
                    fldFinish    = 11;
                    fldTime      = 12;
                    fldStatus    = 13;
                    fldFirstPost = 31;
                }
                else if (fields[0] == "OE0016")
                {
                    fldID        = 1;
                    fldLeg       = -1;
                    fldSI        = 3;
                    fldFName     = 6;
                    fldEName     = 5;
                    fldClub      = 20;
                    fldClass     = 25;
                    fldStart     = 11;
                    fldFinish    = 12;
                    fldTime      = 13;
                    fldStatus    = 14;
                    fldFirstPost = 59;
                }
            }
        }
示例#10
0
        internal static void DetectOxCSVFormat(SourceProgram source, string[] fields, out int fldID, out int fldSI, out int fldFName, out int fldEName, out int fldClub, 
            out int fldClass, out int fldStart, out int fldTime, out int fldStatus, out int fldFirstPost, out int fldLeg, out int fldFinish,
            out int fldTxt1, out int fldTxt2, out int fldTxt3, out int fldTotalTime)
        {
            string[] stoNoFieldNames = GetOEStringsForKey("Stnr", source);
            string[] legFieldNames = GetOEStringsForKey("Lnr", source);
            string[] chipNoFieldNames = GetOEStringsForKey(source == SourceProgram.OE ? "Chipnr" : "ChipNr", source);
            string[] firstNameFieldNames = GetOEStringsForKey("Vorname", source);
            string[] lastNameFieldNames = GetOEStringsForKey("Nachname", source);
            string[] clubFieldNames = GetOEStringsForKey(source == SourceProgram.OE ? "Ort" : "Staffel", source);
            string[] classFieldNames = GetOEStringsForKey("Kurz", source);
            string[] startFieldNames = GetOEStringsForKey("Start", source);
            string[] finishFieldNames = GetOEStringsForKey("Ziel", source);
            string[] timeFieldNames =  GetOEStringsForKey("Zeit", source);
            string[] statusFieldNames = GetOEStringsForKey("Wertung", source);

            string[] noFieldNames = GetOEStringsForKey("Nr", source);
            var no1FieldNames = new string[noFieldNames.Length];
            for (int i = 0; i < no1FieldNames.Length; i++)
                no1FieldNames[i] = noFieldNames[i] + "1";
            string[] totalTimeFieldNames = GetOEStringsForKey("Gesamtzeit", source);

            string[] txtFields = GetOEStringsForKey("Text", source);

            var txt1Fields = new string[txtFields.Length];
            var txt2Fields = new string[txtFields.Length];
            var txt3Fields = new string[txtFields.Length];
            for (int i = 0; i < txtFields.Length; i++)
            {
                txt1Fields[i] = txtFields[i] + "1";
                txt2Fields[i] = txtFields[i] + "2";
                txt3Fields[i] = txtFields[i] + "3";
            }

            fldID = GetFieldFromHeader(fields, stoNoFieldNames);
            fldLeg = GetFieldFromHeader(fields, legFieldNames);
            fldSI = GetFieldFromHeader(fields, chipNoFieldNames);
            fldFName = GetFieldFromHeader(fields, firstNameFieldNames);
            fldEName = GetFieldFromHeader(fields, lastNameFieldNames);
            fldClub = GetFieldFromHeader(fields, clubFieldNames);

            fldClass = GetFieldFromHeader(fields, classFieldNames);
            fldStart = GetFieldFromHeader(fields, startFieldNames);
            fldFinish = GetFieldFromHeader(fields, finishFieldNames);
            fldTime = GetFieldFromHeader(fields, timeFieldNames);
            fldStatus = GetFieldFromHeader(fields, statusFieldNames);

            fldFirstPost = GetFieldFromHeader(fields, no1FieldNames);
            fldTxt1 = GetFieldFromHeader(fields, txt1Fields);
            fldTxt2 = GetFieldFromHeader(fields, txt2Fields);
            fldTxt3 = GetFieldFromHeader(fields, txt3Fields);
            fldTotalTime = GetFieldFromHeader(fields, totalTimeFieldNames);

            if (fldID == -1 || fldSI == -1 || fldFName == -1 || fldEName == -1 || fldClub == -1 || fldClass == -1
                || fldStart == -1 || fldTime == -1
                || fldStart == -1 || fldFirstPost == -1 || ( source == SourceProgram.OS || fldLeg == -1))
            {
                /*Try detect fixedFormat*/
                if (fields[0] == "OS0016")
                {
                    fldID = 1;
                    fldLeg = 4;
                    fldSI = 14;
                    fldFName = 7;
                    fldEName = 6;
                    fldClub = 18;
                    fldClass = 20;
                    fldStart = 10;
                    fldFinish = 11;
                    fldTime = 12;
                    fldStatus = 13;
                    fldFirstPost = 32;
                    fldTotalTime = 30;
                }
                else if (fields[0] == "OS0012")
                {
                    fldID = 1;
                    fldLeg = 4;
                    fldSI = 14;
                    fldFName = 7;
                    fldEName = 6;
                    fldClub = 18;
                    fldClass = 20;
                    fldStart = 10;
                    fldFinish = 11;
                    fldTime = 12;
                    fldStatus = 13;
                    fldFirstPost = 31;
                }
                else if (fields[0] == "OE0016")
                {
                    fldID = 1;
                    fldLeg = -1;
                    fldSI = 3;
                    fldFName = 6;
                    fldEName = 5;
                    fldClub = 20;
                    fldClass = 25;
                    fldStart = 11;
                    fldFinish = 12;
                    fldTime = 13;
                    fldStatus = 14;
                    fldFirstPost = 59;
                }
            }
        }
        private void GetProgramProperties(XmlNode node, ref SourceProgram sourceProgram)
        {
            foreach (XmlAttribute attribute in node.Attributes)
            {
                switch (attribute.Name)
                {
                case "Name":
                    sourceProgram.Name = attribute.Value;
                    break;

                case "Station":
                    sourceProgram.Station = attribute.Value;
                    break;

                case "Daypart":
                    sourceProgram.Daypart = attribute.Value;
                    break;

                case "Day":
                    sourceProgram.Day = attribute.Value;
                    break;

                case "Time":
                    sourceProgram.Time = attribute.Value;
                    break;
                }
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                case "Demo":
                    var demo = new Demo();
                    foreach (XmlAttribute attribute in childNode.Attributes)
                    {
                        switch (attribute.Name)
                        {
                        case "Source":
                            demo.Source = attribute.Value;
                            break;

                        case "DemoType":
                            int tempInt;
                            if (Int32.TryParse(attribute.Value, out tempInt))
                            {
                                demo.DemoType = (DemoType)tempInt;
                            }
                            break;

                        case "Name":
                            demo.Name = attribute.Value;
                            break;

                        case "Value":
                            demo.Value = attribute.Value;
                            break;
                        }
                    }
                    if (!String.IsNullOrEmpty(demo.Name) && !String.IsNullOrEmpty(demo.Source) && !String.IsNullOrEmpty(demo.Value))
                    {
                        sourceProgram.Demos.Add(demo);
                    }
                    break;
                }
            }
        }
        private void LoadStrategy()
        {
            SlideHeaders.Clear();
            SourcePrograms.Clear();
            Lengths.Clear();
            Stations.Clear();
            CustomDemos.Clear();
            Dayparts.Clear();
            Times.Clear();

            if (ResourceManager.Instance.MediaListsFile.ExistsLocal())
            {
                var document = new XmlDocument();
                document.Load(ResourceManager.Instance.MediaListsFile.LocalPath);

                XmlNode node = document.SelectSingleNode(String.Format(@"/{0}Strategy", XmlRootPrefix));
                if (node != null)
                {
                    foreach (XmlNode childeNode in node.ChildNodes)
                    {
                        switch (childeNode.Name)
                        {
                        case "SlideHeader":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value))
                                    {
                                        SlideHeaders.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "FlexFlightDatesAllowed":
                        {
                            bool temp;
                            if (Boolean.TryParse(childeNode.InnerText, out temp))
                            {
                                FlexFlightDatesAllowed = temp;
                            }
                        }
                        break;

                        case "Daypart":
                            var daypart = new Daypart();
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Name":
                                    daypart.Name = attribute.Value;
                                    break;

                                case "Code":
                                    daypart.Code = attribute.Value;
                                    break;
                                }
                            }
                            if (!string.IsNullOrEmpty(daypart.Name))
                            {
                                Dayparts.Add(daypart);
                            }
                            break;

                        case "CustomDemo":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!CustomDemos.Contains(attribute.Value))
                                    {
                                        CustomDemos.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "Lenght":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!string.IsNullOrEmpty(attribute.Value) && !SlideHeaders.Contains(attribute.Value))
                                    {
                                        Lengths.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "Station":
                            var station = new Station();
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Name":
                                    station.Name = attribute.Value;
                                    break;

                                case "Logo":
                                    if (!string.IsNullOrEmpty(attribute.Value))
                                    {
                                        station.Logo = new Bitmap(new MemoryStream(Convert.FromBase64String(attribute.Value)));
                                    }
                                    break;
                                }
                            }
                            if (!string.IsNullOrEmpty(station.Name))
                            {
                                Stations.Add(station);
                            }
                            break;

                        case "Program":
                            var sourceProgram = new SourceProgram();
                            GetProgramProperties(childeNode, ref sourceProgram);
                            if (!string.IsNullOrEmpty(sourceProgram.Name))
                            {
                                SourcePrograms.Add(sourceProgram);
                            }
                            break;

                        case "Status":
                            foreach (XmlAttribute attribute in childeNode.Attributes)
                            {
                                switch (attribute.Name)
                                {
                                case "Value":
                                    if (!Statuses.Contains(attribute.Value))
                                    {
                                        Statuses.Add(attribute.Value);
                                    }
                                    break;
                                }
                            }
                            break;

                        case "BroadcastMonthTemplate":
                            var monthTemplate = new MediaMonthTemplate();
                            monthTemplate.Deserialize(childeNode);
                            MonthTemplatesMondayBased.Add(monthTemplate);
                            MonthTemplatesSundayBased.Add(monthTemplate);
                            break;

                        case "DefaultWeeklyScheduleSettings":
                            DefaultWeeklyScheduleSettings.Deserialize(childeNode);
                            break;

                        case "DefaultMonthlyScheduleSettings":
                            DefaultMonthlyScheduleSettings.Deserialize(childeNode);
                            break;

                        case "DefaultSnapshotSettings":
                            DefaultSnapshotSettings.Deserialize(childeNode);
                            break;

                        case "DefaultSnapshotSummarySettings":
                            DefaultSnapshotSummarySettings.Deserialize(childeNode);
                            break;

                        case "DefaultOptionsSettings":
                            DefaultOptionsSettings.Deserialize(childeNode);
                            break;

                        case "DefaultOptionsSummarySettings":
                            DefaultOptionsSummarySettings.Deserialize(childeNode);
                            break;

                        case "DefaultBroadcastCalendarSettings":
                            DefaultBroadcastCalendarSettings.Deserialize(childeNode);
                            break;

                        case "DefaultCustomCalendarSettings":
                            DefaultCustomCalendarSettings.Deserialize(childeNode);
                            break;
                        }
                    }
                }
            }

            if (SourcePrograms.Count > 0)
            {
                Times.AddRange(SourcePrograms.Select(x => x.Time).Distinct().ToArray());
                Days.AddRange(SourcePrograms.Select(x => x.Day).Distinct().ToArray());
            }
        }