示例#1
0
        public void DP_AppendDesc_Parse()
        {
            var res = DescriptionParser.ParseDescription("11111-111(+abc)");

            Assert.AreEqual("11111-111", res.BeforeDescription);
            Assert.AreEqual("abc", res.Description);
        }
示例#2
0
        private void createFromBoardCaptureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dlg = new ParseJoyDialog();

            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            var joy = new JoystickConfig();

            try
            {
                var parser = new DescriptionParser(joy);
                var data   = dlg.DescriptorText.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                parser.Parse(data.Select(s => uint.Parse(s, NumberStyles.HexNumber)).GetEnumerator());
            }
            catch (Exception exx)
            {
                ShowError(exx.Message, "Parsing error");
                return;
            }

            ShowJoystickDialog(joy);
        }
示例#3
0
        public void DP_AppendWithNormalBrackets_Parse()
        {
            var res = DescriptionParser.ParseDescription("11111-111(+abc(def)ghi)");

            Assert.AreEqual("11111-111", res.BeforeDescription);
            Assert.AreEqual("abc(def)ghi", res.Description);
        }
示例#4
0
        public void DP_StringEmpty_DoNothing()
        {
            var res = DescriptionParser.ParseDescription(string.Empty);

            Assert.IsEmpty(res.BeforeDescription);
            Assert.IsEmpty(res.Description);
        }
示例#5
0
        public void DP_NoDesc_Parse()
        {
            var res = DescriptionParser.ParseDescription("11111-111");

            Assert.AreEqual("11111-111", res.BeforeDescription);
            Assert.IsEmpty(res.Description);
        }
示例#6
0
        private void createFromBoardCaptureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dlg = new ParseJoyDialog();

            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            var joy = new JoystickConfig();

            try
            {
                var parser = new DescriptionParser(joy);
                var data   = SplitValues(dlg.DescriptorText);
                parser.Parse(data.Select(s => uint.Parse(s, NumberStyles.HexNumber)).GetEnumerator());
                joy.VendorID        = dlg.VendorID;
                joy.ProductID       = dlg.ProductID;
                joy.ReportStructure = dlg.DescriptorText;
            }
            catch (Exception exx)
            {
                ShowError(exx.Message, CommonResources.ParseError);
                return;
            }

            ShowJoystickDialog(joy);
        }
示例#7
0
        public void DP_Null_DoNothing()
        {
            var res = DescriptionParser.ParseDescription(null);

            Assert.IsEmpty(res.BeforeDescription);
            Assert.IsEmpty(res.Description);
        }
示例#8
0
        public List <Description> getFields(string dbName, string tableName)
        {
            string            pathToFile        = base.getPathToTableDescription(dbName, tableName);
            DescriptionParser descriptionParser = new DescriptionParser(pathToFile);

            return(descriptionParser.getFields());
        }
示例#9
0
        public IEnumerable <Inline> BuildDescriptionInlines()
        {
            if (string.IsNullOrEmpty(this.Description))
            {
                return(Empty <Inline> .Array);
            }

            var desc = new DescriptionParser(this.Description).ParseBody();

            this.RefreshProperties();
            return(desc.Inlines);
        }
示例#10
0
        private void LoadDeviceServices(UPnPDevice device)
        {
            foreach (UPnPService service in device.Services)
            {
                string descriptionXml = DescriptionLoader.LoadDescription(service.BaseUrl + service.ServiceDescriptionUrl).Result;
                DescriptionParser.ParseDescription(service, descriptionXml);
            }

            foreach (UPnPDevice deviceSubDevice in device.SubDevices)
            {
                LoadDeviceServices(deviceSubDevice);
            }
        }
示例#11
0
        static void LoadJsonShow()
        {
            string            json   = File.ReadAllText(Application.dataPath + "/Editor/data/test.json");
            var               d      = JsonConvert.DeserializeObject <DWindow>(json);
            DescriptionParser parser = new DescriptionParser(d);

            parser.Parse();
            var w = parser.GetWindow();

            if (Window2_instance == null)
            {
                Window2_instance = WindowPlayer.New(w);
            }
            Window2_instance.Show();
        }
示例#12
0
        public override async Task ProcessDataAsync()
        {
            var scrapedSaleAnnounces = new List <TransportSaleAnnounce>();

            while (ItemsCountForStep > scrapedSaleAnnounces.Count)
            {
                try
                {
                    var urlForScrapping = UrlForScrapping + $"&start={ScrappingPage}";
                    var htmlDocument    = await DataLoader.LoadHtmlDocumentAsync(urlForScrapping);

                    var previewOffers = StructureExtractor.GetPreviewOfferStructure(htmlDocument, ScrappingPage).ToList();

                    for (int i = 0; i < previewOffers.Count; i++)
                    {
tryAgain:

                        try
                        {
                            var sourceLink           = SourceLinkParser.GetLink(previewOffers[i], BaseUrl);
                            var detailedHtmlDocument = await DataLoader.LoadHtmlDocumentAsync(sourceLink);

                            var detailedOfferNode = StructureExtractor.GetDetailedOfferStructure(detailedHtmlDocument);

                            var(brandId, modelId) = BrandModelParser.ParseForDetailed(detailedOfferNode);

                            var saleAnnounce = new TransportSaleAnnounce()
                            {
                                SourceLink         = sourceLink,
                                TransmissionTypeId = TransmissionTypeParser.ParseForDetailed(detailedOfferNode),
                                AdNumber           = OfferNumberParser.ParseForDetailed(detailedOfferNode),
                                BodyTypeId         = BodyTypeParser.ParseForDetailed(detailedOfferNode),
                                CityId             = RegionParser.ParseForDetailed(detailedOfferNode).Id,
                                Description        = DescriptionParser.ParseForDetailed(detailedOfferNode),
                                DriveUnitId        = DriveUnitParser.ParseForDetailed(detailedOfferNode),
                                EngineVolumetric   = EngineVolumetricParser.ParseForDetailed(detailedOfferNode),
                                FuelTypeId         = FuelTypeParser.ParseForDetailed(detailedOfferNode),
                                PreviewImageLink   = ImageLinkParser.ParseForPreview(previewOffers[i]),
                                Mileage            = MileageParser.ParseForDetailed(detailedOfferNode),
                                BrandId            = brandId,
                                VehicleTypeId      = VehicleTypeParser.ParseForDetailed(detailedOfferNode),
                                ModelId            = modelId,
                                PriceInDollars     = PriceParser.ParseForDetailed(detailedOfferNode),
                                UpdateOfferTime    = PublishDateParser.ParseForDetailed(detailedOfferNode),
                                Year             = YearParser.ParseForDetailed(detailedOfferNode),
                                CreatedAt        = DateTime.Now,
                                SourceProviderId = (int)SourceProviderEnum.RST
                            };

                            var carConditionIds = CarConditionParser.ParseForPreview(previewOffers[i]);
                            foreach (var carConditionId in carConditionIds)
                            {
                                saleAnnounce.TransportConditions.Add(new TransportConditionInSaleAnnounce()
                                {
                                    TransportConditionId = carConditionId
                                });
                            }

                            scrapedSaleAnnounces.Add(saleAnnounce);

                            UnitOfWork.TransportSaleAnnouncesRepository.Add(saleAnnounce);
                            await UnitOfWork.SaveChangesAsync();

                            ScrappingPage++;
                        }
                        catch (WebException)
                        {
                            goto tryAgain;
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError($"{ex.Message}\n{ex.StackTrace}");
                }
            }

            //await UnitOfWork.TransportSaleAnnouncesRepository.InsertRangeSaleAnnounces(scrapedSaleAnnounces);
        }
示例#13
0
 private void Image_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     DescriptionParser.Image_MouseLeftButtonDown(sender, e);
 }
示例#14
0
        private bool GetWDTempItem(string wdItemString, out WorkItemTemp workItem, out string error, DateTime dateTime, ShortCut wholeDayShortcut)
        {
            bool success = false;

            workItem = null;
            error    = string.Empty;
            // check for pause item
            if (wdItemString.EndsWith(pauseChar.ToString()))
            {
                if (wdItemString.StartsWith(endTimeStartChar.ToString()))
                {
                    TimeItem ti;
                    var      parsePart          = wdItemString.Substring(1, wdItemString.Length - 2);
                    var      parsePartNoComment = parsePart.TokenReturnInputIfFail("(", 1);
                    if (TimeItem.TryParse(parsePartNoComment, out ti))
                    {
                        workItem = new WorkItemTemp(wdItemString);
                        workItem.DesiredEndtime = ti;
                        workItem.IsPause        = true;
                        success = true;
                    }
                }
                else
                {
                    double pauseDuration;
                    var    parsePart          = wdItemString.Substring(0, wdItemString.Length - 1);
                    var    parsePartNoComment = parsePart.TokenReturnInputIfFail("(", 1);
                    if (double.TryParse(parsePartNoComment, NumberStyles.Float, CultureInfo.InvariantCulture, out pauseDuration))
                    {
                        workItem           = new WorkItemTemp(wdItemString);
                        workItem.HourCount = pauseDuration;
                        workItem.IsPause   = true;
                        success            = true;
                    }
                }
            }
            else
            {
                // workitem: <count of hours|-endtime>;<projectnumber>-<positionnumber>[(<description>)]
                var timeString = wdItemString.Token(hourProjectInfoSeparator.ToString(), 1, wdItemString).Trim();
                if (!string.IsNullOrEmpty(timeString))
                {
                    if (timeString.StartsWith(endTimeStartChar.ToString()))
                    {
                        TimeItem ti;
                        if (TimeItem.TryParse(timeString.Substring(1), out ti))
                        {
                            workItem = new WorkItemTemp(wdItemString);
                            workItem.DesiredEndtime = ti;
                        }
                        else
                        {
                            error = string.Format("Die Endzeit kann nicht erkannt werden: {0}", timeString);
                        }
                    }
                    else
                    {
                        double hours;
                        if (double.TryParse(timeString, NumberStyles.Float, CultureInfo.InvariantCulture, out hours))
                        {
                            workItem           = new WorkItemTemp(wdItemString);
                            workItem.HourCount = hours;
                        }
                        else
                        {
                            error = string.Format("Die Stundeninfo kann nicht erkannt werden: {0}", timeString);
                        }
                    }
                    if (workItem != null)
                    {
                        var projectPosDescString = wdItemString.Substring(wdItemString.IndexOf(hourProjectInfoSeparator) + 1).Trim();
                        if (!string.IsNullOrEmpty(projectPosDescString))
                        {
                            // expand abbreviations
                            if (this.settings != null)
                            {
                                var      abbrevStringNoComment = projectPosDescString.TokenReturnInputIfFail("(", 1).Trim();
                                var      abbrevString          = abbrevStringNoComment.TokenReturnInputIfFail("-", 1).Trim();
                                var      posReplaceString      = abbrevStringNoComment.Token("-", 2).Trim();
                                ShortCut shortCut = this.settings.GetValidShortCuts(dateTime).Where(s => !s.WholeDayExpansion).FirstOrDefault(s => s.Key == abbrevString);
                                if (shortCut != null)
                                {
                                    workItem.ShortCut = shortCut;
                                    var expanded = shortCut.Expansion;
                                    // if there is an desc given use its value instead of the one in the abbrev
                                    var desc         = DescriptionParser.ParseDescription(projectPosDescString);
                                    var descExpanded = DescriptionParser.ParseDescription(expanded);
                                    if (!string.IsNullOrWhiteSpace(desc.Description) && desc.UsedAppendDelimiter)
                                    {
                                        // append description in expanded
                                        expanded = string.Format("{0}({1}{2})", this.replacePosIfNecessary(descExpanded.BeforeDescription, posReplaceString), descExpanded.Description, desc.Description);
                                    }
                                    else if (!string.IsNullOrWhiteSpace(desc.Description))
                                    {
                                        // replace to description in expanded
                                        expanded = string.Format("{0}({1})", this.replacePosIfNecessary(descExpanded.BeforeDescription, posReplaceString), desc.Description);
                                    }
                                    else
                                    {
                                        expanded = this.replacePosIfNecessary(expanded, posReplaceString);
                                    }
                                    projectPosDescString = expanded;
                                }
                                else if (wholeDayShortcut != null)
                                {
                                    workItem.ShortCut = wholeDayShortcut;
                                }
                            }

                            var projectPosString = projectPosDescString.TokenReturnInputIfFail("(", 1);
                            var parts            = projectPosString.Split(projectPositionSeparator).Select(s => s.Trim()).ToList();
                            if (parts.Any())
                            {
                                workItem.ProjectString = parts.ElementAtOrDefault(0);
                                workItem.PosString     = parts.ElementAtOrDefault(1) ?? string.Empty;
                                success = true;
                            }
                            else
                            {
                                error = string.Format("Projektnummer kann nicht erkannt werden: {0}", projectPosDescString);
                            }
                            var descNoExpand = DescriptionParser.ParseDescription(projectPosDescString);
                            if (!string.IsNullOrWhiteSpace(descNoExpand.Description))
                            {
                                workItem.Description = descNoExpand.Description;
                            }
                        }
                        else
                        {
                            error = string.Format("Projektnummer ist leer: {0}", wdItemString);
                        }
                    }
                }
                else
                {
                    error = string.Format("Stundenanzahl kann nicht erkannt werden: {0}", wdItemString);
                }
            }
            return(success);
        }