Beispiel #1
0
        public static Feed ToFeed(XElement channel)
        {
            if (channel.Name.LocalName.ToLower() == "channel")
            {
                Feed feed = new Feed();
                foreach (XElement prpNode in channel.Elements())
                {
                    try
                    {
                        switch (prpNode.Name.LocalName.ToLower())
                        {
                        case "category":
                            feed.Category      = new Category();
                            feed.Category.Name = prpNode.Value;
                            if (MyHelper.EnumToArray(prpNode.Attributes()).Length == 1)
                            {
                                feed.Category.Domain = new Uri(prpNode.Attribute(XName.Get("domain")).Value);
                            }
                            break;

                        case "cloud":
                            feed.Cloud = new Cloud();
                            foreach (XAttribute att in prpNode.Attributes())
                            {
                                switch (att.Name.LocalName.ToLower())
                                {
                                case "domain":
                                    feed.Cloud.Domain = new Uri(att.Value);
                                    break;

                                case "path":
                                    feed.Cloud.Path = att.Value;
                                    break;

                                case "registerprocedure":
                                    feed.Cloud.RegisterProcedure = att.Value;
                                    break;

                                case "protocol":
                                    feed.Cloud.Protocol = att.Value;
                                    break;

                                case "port":
                                    int n;
                                    if (int.TryParse(att.Value, out n))
                                    {
                                        feed.Cloud.Port = n;
                                    }
                                    break;
                                }
                            }

                            break;

                        case "copyright":
                            feed.Copyright = prpNode.Value;
                            break;

                        case "description":
                            feed.Description = prpNode.Value;
                            break;

                        case "docs":
                            feed.Documentation = new Uri(prpNode.Value);
                            break;

                        case "generator":
                            feed.Generator = prpNode.Value;
                            break;

                        case "link":
                            feed.Link = new Uri(prpNode.Value);
                            break;

                        case "language":
                            feed.Language = new System.Globalization.CultureInfo(prpNode.Value);
                            break;

                        case "lastbuilddate":
                            feed.LastBuildDate = RFC822DateFromString(prpNode.Value);
                            break;

                        case "managingeditor":
                            feed.ManagingEditor = Rss2MailToMailAddress(prpNode.Value);
                            break;

                        case "name":
                            feed.Name = prpNode.Value;
                            break;

                        case "image":
                            feed.Image = new Image();
                            foreach (XElement nodeChild in prpNode.Elements())
                            {
                                switch (nodeChild.Name.LocalName.ToLower())
                                {
                                case "url":
                                    feed.Image.URL = new Uri(nodeChild.Value);
                                    break;

                                case "link":
                                    feed.Image.Link = new Uri(nodeChild.Value);
                                    break;

                                case "title":
                                    feed.Image.Title = nodeChild.Value;
                                    break;

                                case "description":
                                    feed.Image.Description = nodeChild.Value;
                                    break;

                                case "width":
                                    int n;
                                    if (int.TryParse(nodeChild.Value, out n))
                                    {
                                        feed.Image.Width = n;
                                    }
                                    break;

                                case "height":
                                    if (int.TryParse(nodeChild.Value, out n))
                                    {
                                        feed.Image.Height = n;
                                    }
                                    break;
                                }
                            }

                            break;

                        case "item":
                            FeedItem rssItem = ToFeedItem(prpNode);
                            if (rssItem != null)
                            {
                                feed.Items.Add(rssItem);
                            }
                            break;

                        case "pubdate":
                            feed.PublishDate = RFC822DateFromString(prpNode.Value);
                            break;

                        case "rating":
                            feed.Rating = prpNode.Value;
                            break;

                        case "skiphours":
                            List <int> lst1 = new List <int>();
                            foreach (XElement nodeChild in prpNode.Elements())
                            {
                                if (nodeChild.Name.LocalName.ToLower() == "hour")
                                {
                                    int @int = 0;
                                    if (int.TryParse(nodeChild.Value, out @int))
                                    {
                                        lst1.Add(@int);
                                    }
                                }
                            }

                            feed.Skiphours = lst1.ToArray();
                            break;

                        case "skipdays":
                            List <DayOfWeek> lst2 = new List <DayOfWeek>();
                            foreach (XElement nodeChild in prpNode.Elements())
                            {
                                if (nodeChild.Name.LocalName.ToLower() == "day")
                                {
                                    for (int i = 0; i <= (int)DayOfWeek.Saturday; i++)
                                    {
                                        if (((DayOfWeek)i).ToString().ToUpper() == nodeChild.Value.ToUpper())
                                        {
                                            lst2.Add((DayOfWeek)i);
                                            break;     // TODO: might not be correct. Was : Exit For
                                        }
                                    }
                                }
                            }

                            feed.Skipdays = lst2.ToArray();
                            break;

                        case "textinput":
                            feed.TextInput = new TextInputBox();
                            foreach (XElement nodeChild in prpNode.Elements())
                            {
                                switch (nodeChild.Name.LocalName.ToLower())
                                {
                                case "name":
                                    feed.TextInput.Name = nodeChild.Value;
                                    break;

                                case "link":
                                    feed.TextInput.Link = new Uri(nodeChild.Value);
                                    break;

                                case "title":
                                    feed.TextInput.Title = nodeChild.Value;
                                    break;

                                case "description":
                                    feed.TextInput.Description = nodeChild.Value;
                                    break;
                                }
                            }


                            break;

                        case "title":
                            feed.Title = prpNode.Value;
                            break;

                        case "ttl":
                            feed.Ttl = Convert.ToInt32(prpNode.Value);

                            break;

                        case "webmaster":
                            feed.Webmaster = Rss2MailToMailAddress(prpNode.Value);
                            break;

                        default:
                            break;
                            //Debug.WriteLine(node.Name)
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                return(feed);
            }
            else
            {
                return(null);
            }
        }
 protected override void BecauseOf()
 {
     _diagnostics = MyHelper.RunAnalyser(Code, Sut);
 }
Beispiel #3
0
        public static FeedItem ToFeedItem(XElement item)
        {
            if (item.Name.LocalName == "item")
            {
                FeedItem rssItem = new FeedItem();
                foreach (XElement itemNode in item.Elements())
                {
                    try
                    {
                        switch (itemNode.Name.LocalName.ToLower())
                        {
                        case "title":
                            rssItem.Title = itemNode.Value;
                            break;

                        case "link":
                            rssItem.Link = new Uri(itemNode.Value);
                            break;

                        case "description":
                            rssItem.Description = itemNode.Value;
                            break;

                        case "author":
                            rssItem.Author = itemNode.Value;
                            break;

                        case "category":
                            rssItem.Category      = new Category();
                            rssItem.Category.Name = itemNode.Value;
                            if (MyHelper.EnumToArray(itemNode.Attributes()).Length == 1)
                            {
                                rssItem.Category.Domain = new Uri(itemNode.Attribute(XName.Get("domain")).Value);
                            }
                            break;

                        case "comments":
                            rssItem.Comments = new Uri(itemNode.Value);
                            break;

                        case "enclosure":
                            rssItem.Enclosure     = new Enclosure();
                            rssItem.Enclosure.Url = new Uri(itemNode.Attribute(XName.Get("url")).Value);
                            long l;
                            if (long.TryParse(itemNode.Attribute(XName.Get("length")).Value, out l))
                            {
                                rssItem.Enclosure.Length = l;
                            }
                            rssItem.Enclosure.Type = itemNode.Attribute(XName.Get("type")).Value;
                            break;

                        case "guid":
                            rssItem.GUID    = new GUID();
                            rssItem.GUID.ID = itemNode.Value;
                            if (MyHelper.EnumToArray(itemNode.Attributes()).Length == 1)
                            {
                                rssItem.GUID.IsPermaLink = Convert.ToBoolean(itemNode.Attribute(XName.Get("isPermaLink")).Value);
                            }
                            break;

                        case "pubdate":
                            rssItem.PublishDate = RFC822DateFromString(itemNode.Value);
                            break;

                        case "insertdate":
                            rssItem.InsertDate = RFC822DateFromString(itemNode.Value);
                            break;

                        case "source":
                            rssItem.Source       = new Source();
                            rssItem.Source.Title = itemNode.Value;
                            rssItem.Source.Url   = new Uri(itemNode.Attribute(XName.Get("url")).Value);
                            break;

                        default:
                            break;
                            //Debug.WriteLine(itemNode.Name.LocalName)
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                return(rssItem);
            }
            return(null);
        }
Beispiel #4
0
        public async void OnSingUp()
        {
            user.firstname = user.firstname.Trim();
            user.lastname  = user.lastname.Trim();
            user.email     = user.email.Trim();
            user.phone     = user.phone.Trim();

            if (IsMale)
            {
                user.gender = "Male";
            }
            else if (IsFemale)
            {
                user.gender = "Female";
            }

            if (user.firstname.Length == 0 || user.lastname.Length == 0 || user.email.Length == 0 || user.password.Length == 0 || user.phone.Length == 0)
            {
                await App.Current.MainPage.DisplayAlert("Empty field", "You must fill all the fields.", "OK");
            }
            else if (!MyHelper.IsValidEmail(user.email))
            {
                await App.Current.MainPage.DisplayAlert("Invalid email", "Enter a valid email : [email protected]", "OK");
            }
            else
            {
                try
                {
                    JObject jRes = await myHttpClient.sendHttpPostAsyncJson(Constants.ClientCheckEmail, user);

                    if ((bool)jRes["HttpClient error"])
                    {
                        await App.Current.MainPage.DisplayAlert("Connection failed", "Connection failed.", "OK");
                    }
                    else if ((bool)jRes["HttpClient parsing error"])
                    {
                    }
                    else
                    {
                        if (!(bool)jRes["Error"])
                        {
                            if ((bool)jRes["email_already_used"])
                            {
                                await App.Current.MainPage.DisplayAlert("Change the email address", "This email address is in use by another account.", "OK");
                            }
                            else
                            {
                                jRes = await myHttpClient.sendHttpPostAsyncJson(Constants.ApiSignUp, user);

                                if ((bool)jRes["HttpClient error"])
                                {
                                    await App.Current.MainPage.DisplayAlert("Connection failed", "Connection failed.", "OK");
                                }
                                else if ((bool)jRes["HttpClient parsing error"])
                                {
                                }
                                else
                                {
                                    if (!(bool)jRes["Error"])
                                    {
                                        await App.Current.MainPage.Navigation.PopAsync();
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Connection failed", "Connection failed.", "OK");
                }
            }
        }
Beispiel #5
0
        protected override CompanyProfileResult ConvertResult(Base.ConnectionInfo connInfo, System.IO.Stream stream, Base.SettingsBase settings)
        {
            CompanyProfileData res = null;

            System.Globalization.CultureInfo convCulture = new System.Globalization.CultureInfo("en-US");
            if (stream != null)
            {
                XDocument doc        = MyHelper.ParseXmlDocument(stream);
                XElement  resultNode = XPath.GetElement("//table[@id=\"yfncsumtab\"]/tr[2]", doc);

                if (resultNode != null)
                {
                    res = new CompanyProfileData();
                    res.SetID(FinanceHelper.CleanIndexID(((CompanyProfileDownloadSettings)settings).ID.ToUpper()));

                    XElement nameNode = XPath.GetElement("td[1]/b[1]", resultNode);
                    if (nameNode != null)
                    {
                        res.CompanyName = nameNode.Value;
                    }

                    XElement addressNode = XPath.GetElement("td[1]", resultNode);
                    if (addressNode != null)
                    {
                        System.Text.StringBuilder formattedAddress = new System.Text.StringBuilder();
                        try
                        {
                            string addNodeStr = addressNode.ToString();
                            if (addNodeStr != string.Empty)
                            {
                                addNodeStr = addNodeStr.Substring(addNodeStr.IndexOf("/>") + 2);
                                string[] rawAddress = addNodeStr.Substring(0, addNodeStr.IndexOf("Website")).Split(new string[] { "<b>", "<br />", "</b>", "\r", "\n", " - ", "</a>" }, StringSplitOptions.RemoveEmptyEntries);
                                if (rawAddress.Length >= 7)
                                {
                                    foreach (string line in rawAddress)
                                    {
                                        string l = line.Trim();
                                        if (l != string.Empty && !l.StartsWith("<a") && l != "Map")
                                        {
                                            formattedAddress.AppendLine(l);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        res.Address = formattedAddress.ToString().TrimEnd();
                    }

                    XElement indicesNode = XPath.GetElement("td[1]/table[2]/tr/td/table/tr/td[2]", resultNode);
                    if (indicesNode != null)
                    {
                        List <KeyValuePair <string, string> > lstIndices = new List <KeyValuePair <string, string> >();
                        foreach (XElement indexLink in indicesNode.Elements())
                        {
                            if (indexLink.Name.LocalName == "a")
                            {
                                string indexID = Uri.UnescapeDataString(MyHelper.GetXmlAttributeValue(indexLink, "href").ToUpper().Replace("HTTP://FINANCE.YAHOO.COM/Q?S=", "").Replace("&D=T", ""));
                                string name    = string.Empty;
                                foreach (string p in indexLink.Value.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                                {
                                    name += p.Trim() + " ";
                                }
                                lstIndices.Add(new KeyValuePair <string, string>(indexID, name.TrimEnd()));
                            }
                        }
                        res.Details.IndexMembership = lstIndices.ToArray();
                    }

                    XElement sectorsNode = XPath.GetElement("td[1]/table[2]/tr/td/table/tr[2]/td[2]", resultNode);
                    if (sectorsNode != null)
                    {
                        foreach (XElement sectorLink in sectorsNode.Elements())
                        {
                            if (sectorLink.Name.LocalName == "a")
                            {
                                foreach (Sector sect in Enum.GetValues(typeof(Sector)))
                                {
                                    string name = string.Empty;
                                    foreach (string p in sectorLink.Value.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                                    {
                                        name += p.Trim() + " ";
                                    }
                                    name = name.TrimEnd();
                                    if (sect.ToString().Replace("_", " ") == name)
                                    {
                                        res.Details.Sector = sect;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    XElement industryNode = XPath.GetElement("td[1]/table[2]/tr/td/table/tr[3]/td[2]", resultNode);
                    if (industryNode != null)
                    {
                        foreach (XElement industryLink in industryNode.Elements())
                        {
                            if (industryLink.Name.LocalName == "a")
                            {
                                int indIndex = 0;
                                if (int.TryParse(MyHelper.GetXmlAttributeValue(industryLink, "href").Replace("http://biz.yahoo.com/ic/", "").Replace(".html", ""), out indIndex))
                                {
                                    res.Details.Industry = (Industry)indIndex;
                                }
                            }
                        }
                    }

                    XElement employeesNode = XPath.GetElement("td[1]/table[2]/tr/td/table/tr[4]/td[2]", resultNode);
                    if (employeesNode != null)
                    {
                        int fte;
                        if (int.TryParse(employeesNode.Value.Trim(), System.Globalization.NumberStyles.Any, convCulture, out fte))
                        {
                            res.Details.FullTimeEmployees = fte;
                        }
                    }

                    XElement summaryNode = XPath.GetElement("td[1]/p[1]", resultNode);
                    if (summaryNode != null)
                    {
                        System.Text.StringBuilder summaryText = new System.Text.StringBuilder();
                        foreach (string line in summaryNode.Value.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                        {
                            summaryText.Append(line.Trim() + " ");
                        }
                        res.BusinessSummary = summaryText.ToString().TrimEnd();
                    }

                    XElement websitesNodes = XPath.GetElement("td[1]/table[5]/tr/td", resultNode);
                    if (websitesNodes != null)
                    {
                        List <Uri> lstWebsites = new List <Uri>();
                        foreach (XElement linkNode in websitesNodes.Elements())
                        {
                            if (linkNode.Name.LocalName == "a")
                            {
                                lstWebsites.Add(new Uri(MyHelper.GetXmlAttributeValue(linkNode, "href")));
                            }
                        }
                        res.CompanyWebsites = lstWebsites.ToArray();
                    }



                    XElement governanceNode   = null;
                    XElement governanceHeader = XPath.GetElement("td[3]/table[1]/tr/th/span", resultNode);
                    if (governanceHeader != null && governanceHeader.Value.Contains("Governance"))
                    {
                        governanceNode = XPath.GetElement("td[3]/table[2]/tr/td", resultNode);
                    }
                    if (governanceNode != null)
                    {
                        System.Text.StringBuilder governanceText = new System.Text.StringBuilder();
                        foreach (string line in governanceNode.Value.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                        {
                            governanceText.Append(line.Trim() + " ");
                        }
                        res.CorporateGovernance = governanceText.ToString().TrimEnd();
                    }



                    XElement executivesNode   = null;
                    XElement executivesHeader = XPath.GetElement("td[3]/table[3]/tr/th/span", resultNode);
                    if (executivesHeader != null && executivesHeader.Value.Contains("Executives"))
                    {
                        executivesNode = XPath.GetElement("td[3]/table[4]/tr/td/table", resultNode);
                    }
                    else
                    {
                        executivesNode = XPath.GetElement("td[3]/table[2]/tr/td/table", resultNode);
                    }

                    if (executivesNode != null)
                    {
                        List <ExecutivePersonInfo> lst = new List <ExecutivePersonInfo>();
                        bool isFirst = true;
                        foreach (XElement row in executivesNode.Elements())
                        {
                            if (!isFirst)
                            {
                                if (row.Name.LocalName == "tr")
                                {
                                    XElement[] enm = MyHelper.EnumToArray(row.Elements());
                                    if (enm.Length >= 3)
                                    {
                                        ExecutivePersonInfo exec = new ExecutivePersonInfo();

                                        string name = string.Empty;

                                        foreach (string l in MyHelper.EnumToArray(enm[0].Elements())[0].Value.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                                        {
                                            name += l.Trim() + " ";
                                        }

                                        exec.Name = name.TrimEnd();

                                        string position = string.Empty;

                                        var enm2 = MyHelper.EnumToArray(enm[0].Elements());
                                        foreach (string l in enm2[enm2.Length - 1].Value.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                                        {
                                            position += l.Trim() + " ";
                                        }

                                        exec.Position = position.Trim();


                                        string payStr = enm[1].Value.Replace("\r\n", "").Trim();
                                        if (!payStr.Contains("N/A"))
                                        {
                                            exec.Pay = FinanceHelper.GetMillionValue(payStr) * 1000000;
                                        }

                                        string exercisedStr = enm[2].Value.Replace("\r\n", "").Trim();
                                        if (!exercisedStr.Contains("N/A"))
                                        {
                                            double d = FinanceHelper.GetMillionValue(exercisedStr);
                                            exec.Exercised = (int)(d * 1000000);
                                        }

                                        lst.Add(exec);
                                    }
                                }
                            }
                            else
                            {
                                isFirst = false;
                            }
                        }
                        res.KeyExecutives = lst.ToArray();
                    }
                    if (res.BusinessSummary.StartsWith("There is no "))
                    {
                        res = null;
                    }
                }
            }

            return(new CompanyProfileResult(res));
        }
Beispiel #6
0
 public static XParseDocument Load(System.IO.Stream stream)
 {
     return(Load(MyHelper.StreamToString(stream, System.Text.Encoding.UTF8)));
 }
        protected override void BecauseOf()
        {
            Console.WriteLine(Code);

            _diagnostics = MyHelper.RunAnalyser(Code, Sut);
        }
Beispiel #8
0
        protected override BondScreenerInfoResult ConvertResult(Base.ConnectionInfo connInfo, System.IO.Stream stream, Base.SettingsBase settings)
        {
            BondScreenerInfoDownloadSettings set = (BondScreenerInfoDownloadSettings)settings;

            BondScreenerInfoData res = new BondScreenerInfoData();

            System.Globalization.CultureInfo convCulture = new System.Globalization.CultureInfo("en-US");
            //XDocument doc = MyHelper.ParseXmlDocument(stream);
            XParseDocument doc = MyHelper.ParseXmlDocument(stream);

            XParseElement[] resultsNodes = XPath.GetElements("//results", doc);
            if (resultsNodes.Length > 0)
            {
                XParseElement resultNode = resultsNodes[0];
                if (MyHelper.EnumToArray(resultNode.Elements()).Length > 0)
                {
                    XParseElement tdNode     = null;// MyHelper.EnumToArray(resultNode.Elements())[0];
                    int           tableIndex = 0;
                    foreach (XParseElement tableNode in tdNode.Elements())
                    {
                        XParseElement[] tableEnm = MyHelper.EnumToArray(tableNode.Elements());
                        switch (tableIndex)
                        {
                        case 0:
                            XParseElement trNode = tableEnm[1];
                            //res.Title = MyHelper.EnumToArray<XElement>(MyHelper.EnumToArray<XElement>(trNode.Elements())[0].Elements())[0].Value;
                            DateTime d;
                            //if (System.DateTime.TryParseExact(trNode.LastNode.FirstNode.Value.Replace("As of ", ""), "dd-MMM-yyyy", convCulture, System.Globalization.DateTimeStyles.None, out d)) res.AsOf = d;

                            break;

                        case 3:
                            XParseElement innerTableNode = null;    //tableNode.FirstNode.FirstNode.FirstNode;
                            int           innerIndex     = 0;
                            foreach (XParseElement innerTrNode in innerTableNode.Elements())
                            {
                                switch (innerIndex)
                                {
                                case 0:
                                    double t;
                                    //if (double.TryParse(innerTrNode.LastNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) res.Price = t;
                                    break;

                                case 1:
                                    //if (double.TryParse(innerTrNode.LastNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) res.CouponInPercent = t;
                                    break;

                                case 2:
                                    //if (System.DateTime.TryParseExact(innerTrNode.LastNode.Value, "dd-MMM-yyyy", convCulture, System.Globalization.DateTimeStyles.None, out d)) res.Maturity = d;
                                    break;

                                case 3:
                                    //if (double.TryParse(innerTrNode.LastNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) res.YieldToMaturityInPercent = t;
                                    break;

                                case 4:
                                    //if (double.TryParse(innerTrNode.LastNode.Value, System.Globalization.NumberStyles.Any, convCulture, out t)) res.CurrentYieldInPercent = t;
                                    break;

                                case 5:
                                    //res.CouponPaymentFrequency = innerTrNode.LastNode.Value;
                                    break;

                                case 6:
                                    //if (System.DateTime.TryParseExact(innerTrNode.LastNode.Value, "dd-MMM-yyyy", convCulture, System.Globalization.DateTimeStyles.None, out d)) res.FirstCouponDate = d;
                                    break;

                                case 7:
                                    /* switch (innerTrNode.LastNode.Value)
                                     * {
                                     *  case "Treasury":
                                     *      res.Type = BondType.Treasury;
                                     *      break;
                                     *  case "Treasury Zero":
                                     *      res.Type = BondType.TreasuryZeroCoupon;
                                     *      break;
                                     *  case "Corporate":
                                     *      res.Type = BondType.Corporate;
                                     *      break;
                                     *  case "Municipal":
                                     *      res.Type = BondType.Municipal;
                                     *      break;
                                     * }
                                     */
                                    break;

                                case 8:
                                    //res.Callable = Convert.ToBoolean((innerTrNode.LastNode.Value == "Yes" ? true : false));
                                    break;
                                }
                                innerIndex += 1;
                            }


                            break;

                        case 7:
                            innerTableNode = null;     // tableNode.FirstNode.FirstNode.FirstNode;
                            innerIndex     = 0;
                            foreach (XParseElement innerTrNode in innerTableNode.Elements())
                            {
                                switch (innerIndex)
                                {
                                case 0:
                                    int n;
                                    //if (int.TryParse(innerTrNode.LastNode.Value, System.Globalization.NumberStyles.Any, convCulture, out n)) res.AvailableQuantity = n;
                                    break;

                                case 1:
                                    //if (int.TryParse(innerTrNode.LastNode.Value, System.Globalization.NumberStyles.Any, convCulture, out n)) res.MinimumTradeQuantity = n;
                                    break;

                                case 2:
                                    //if (System.DateTime.TryParseExact(innerTrNode.LastNode.Value, "dd-MMM-yyyy", convCulture, System.Globalization.DateTimeStyles.None, out d)) res.DatedDate = d;
                                    break;

                                case 3:
                                    //if (System.DateTime.TryParseExact(innerTrNode.LastNode.Value, "dd-MMM-yyyy", convCulture, System.Globalization.DateTimeStyles.None, out d)) res.SettlementDate = d;
                                    break;
                                }
                                innerIndex += 1;
                            }

                            break;
                        }
                        tableIndex += 1;
                    }
                    res.Issue       = new Link(set.Data.Issue.Title, set.Data.Issue.Url);
                    res.FitchRating = set.Data.FitchRating;
                }
            }
            return(new BondScreenerInfoResult(res));
        }
        public void Then_there_should_be_no_Diagnostics(string code, int numberOfDiagnostics)
        {
            var diagnostics = MyHelper.RunAnalyser(code, Sut);

            diagnostics.Length.Should().Be(numberOfDiagnostics);
        }
        protected override CompanyInfoResult ConvertResult(Base.ConnectionInfo connInfo, System.IO.Stream stream, Base.SettingsBase settings)
        {
            List <CompanyInfoData> companies = new List <CompanyInfoData>();

            System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
            XParseDocument doc = MyHelper.ParseXmlDocument(stream);

            XParseElement[] results = XPath.GetElements("//stock", doc);
            foreach (XParseElement node in results)
            {
                CompanyInfoData stk  = new CompanyInfoData();
                string          name = MyHelper.GetXmlAttributeValue(node, FinanceHelper.NameCompanySymbol);
                if (name != string.Empty)
                {
                    stk.SetID(name.ToUpper());
                }
                foreach (XParseElement propertyNode in node.Elements())
                {
                    switch (propertyNode.Name.LocalName)
                    {
                    case FinanceHelper.NameCompanyCompanyName:
                        stk.Name = propertyNode.Value;
                        break;

                    case FinanceHelper.NameCompanyStart:
                        System.DateTime dte1 = default(System.DateTime);
                        if (System.DateTime.TryParse(propertyNode.Value.Replace(FinanceHelper.NameCompanyNotAvailable, "1"), culture, System.Globalization.DateTimeStyles.AssumeUniversal, out dte1))
                        {
                            stk.StartDate = dte1;
                        }
                        break;

                    case FinanceHelper.NameCompanyEnd:
                        string dateStr = string.Empty;
                        if (propertyNode.Value.IndexOf(FinanceHelper.NameCompanyNotAvailable) > -1)
                        {
                            string[] dates = propertyNode.Value.Split('-');
                            if (dates.Length >= 3)
                            {
                                if (dates[0].IndexOf(FinanceHelper.NameCompanyNotAvailable) > -1)
                                {
                                    dateStr += System.DateTime.Now.Year.ToString() + "-";
                                }
                                else
                                {
                                    dateStr += dates[0] + "-";
                                }
                                if (dates[1].IndexOf(FinanceHelper.NameCompanyNotAvailable) > -1)
                                {
                                    dateStr += System.DateTime.Now.Month.ToString() + "-";
                                }
                                else
                                {
                                    dateStr += dates[1] + "-";
                                }
                                if (dates[2].IndexOf(FinanceHelper.NameCompanyNotAvailable) > -1)
                                {
                                    dateStr += System.DateTime.Now.Day.ToString() + "-";
                                }
                                else
                                {
                                    dateStr += dates[2];
                                }
                                if (dates.Length > 3)
                                {
                                    dateStr += "-";
                                    for (int i = 3; i <= dates.Length - 1; i++)
                                    {
                                        dateStr += dates[i] + "-";
                                    }
                                }
                            }
                            else
                            {
                                dateStr = propertyNode.Value.Replace(FinanceHelper.NameCompanyNotAvailable, System.DateTime.Now.Month.ToString());
                            }
                        }
                        System.DateTime dte2;
                        if (System.DateTime.TryParse(dateStr, culture, System.Globalization.DateTimeStyles.AssumeUniversal, out dte2))
                        {
                            stk.EndDate = dte2;
                        }
                        break;

                    case FinanceHelper.NameCompanySector:
                        stk.SectorName = propertyNode.Value;
                        break;

                    case FinanceHelper.NameCompanyIndustry:
                        stk.IndustryName = propertyNode.Value;
                        break;

                    case FinanceHelper.NameCompanyFullTimeEmployees:
                        int i2 = 0;
                        if (int.TryParse(propertyNode.Value, System.Globalization.NumberStyles.Any, culture, out i2))
                        {
                            stk.FullTimeEmployees = i2;
                        }
                        break;
                    }
                }
                companies.Add(stk);
            }
            return(new CompanyInfoResult(companies.ToArray()));
        }
        public override string GetTickerFromUrl(string url)
        {
            var ticker = MyHelper.ExtractPattern(url, @".*getprices\?q=(?<ticker>\w*)&.*");

            return(ticker);
        }
Beispiel #12
0
        public override string GetTickerFromUrl(string url)
        {
            var ticker = MyHelper.ExtractPattern(url, @".*symbol/(?<ticker>\w*)/earnings-forecast$");

            return(ticker);
        }