Example #1
0
        protected override Base.DownloadCompletedEventArgs <MarketResult> ConvertDownloadCompletedEventArgs(Base.DefaultDownloadCompletedEventArgs <MarketResult> e)
        {
            MarketDownloadSettings set = (MarketDownloadSettings)e.Settings;

            if (set.Sectors != null)
            {
                SectorsDownloadCompletedEventArgs args = new SectorsDownloadCompletedEventArgs(e.UserArgs, (SectorResponse)e.Response, set);
                if (AsyncSectorsDownloadCompleted != null)
                {
                    AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(this);
                    asyncOp.Post(new SendOrPostCallback(delegate(object obj) { AsyncSectorsDownloadCompleted(this, (SectorsDownloadCompletedEventArgs)obj); }), args);
                }
                return(args);
            }
            else if (set.Industries != null)
            {
                IndustryDownloadCompletedEventArgs args = new IndustryDownloadCompletedEventArgs(e.UserArgs, (IndustryResponse)e.Response, set);
                if (AsyncIndustriesDownloadCompleted != null)
                {
                    AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(this);
                    asyncOp.Post(new SendOrPostCallback(delegate(object obj) { AsyncIndustriesDownloadCompleted(this, (IndustryDownloadCompletedEventArgs)obj); }), args);
                }
                return(args);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public override object Clone()
        {
            MarketDownloadSettings cln = new MarketDownloadSettings();

            if (this.Sectors != null)
            {
                cln.Sectors = this.Sectors;
            }
            if (this.Industries != null)
            {
                cln.Industries = this.Industries;
            }
            return(cln);
        }
Example #3
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <remarks></remarks>
 public MarketDownload()
 {
     this.Settings = new MarketDownloadSettings();
 }
Example #4
0
 internal IndustryDownloadCompletedEventArgs(object userArgs, IndustryResponse resp, MarketDownloadSettings settings)
     : base(userArgs, resp, settings)
 {
 }
Example #5
0
 internal SectorsDownloadCompletedEventArgs(object userArgs, SectorResponse resp, MarketDownloadSettings settings)
     : base(userArgs, resp, settings)
 {
 }
Example #6
0
        protected override MarketResult ConvertResult(Base.ConnectionInfo connInfo, System.IO.Stream stream, Base.SettingsBase settings)
        {
            MarketDownloadSettings set = (MarketDownloadSettings)settings;

            if (set.Sectors != null)
            {
                List <SectorData> sectors = new List <SectorData>();
                System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
                XParseDocument  doc     = MyHelper.ParseXmlDocument(stream);
                XParseElement[] results = XPath.GetElements("//sector", doc);
                foreach (XParseElement node in results)
                {
                    System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CurrentCulture;
                    if (culture != null)
                    {
                        ci = culture;
                    }
                    SectorData sect    = new SectorData();
                    string     nameAtt = MyHelper.GetXmlAttributeValue(node, FinanceHelper.NameMarketName);
                    if (nameAtt != string.Empty)
                    {
                        for (Sector s = 0; s <= Sector.Utilities; s++)
                        {
                            if (s.ToString().Replace("_", " ") == nameAtt)
                            {
                                sect.ID = s;
                                break; // TODO: might not be correct. Was : Exit For
                            }
                        }
                    }
                    foreach (XParseElement industryNode in node.Elements())
                    {
                        if (industryNode.Name.LocalName == "industry")
                        {
                            IndustryData ind = new IndustryData();
                            foreach (XParseAttribute att in industryNode.Attributes())
                            {
                                if (att.Name.LocalName == FinanceHelper.NameIndustryID)
                                {
                                    int i = 0;
                                    int.TryParse(att.Value, out i);
                                    if (i != 0)
                                    {
                                        ind.ID = (Industry)i;
                                    }
                                }
                                else if (att.Name.LocalName == FinanceHelper.NameMarketName)
                                {
                                    ind.Name = att.Value;
                                }
                            }
                            sect.Industries.Add(ind);
                        }
                    }
                    sectors.Add(sect);
                }
                return(new SectorResult(sectors.ToArray()));
            }
            else if (set.Industries != null)
            {
                List <IndustryData> industries           = new List <IndustryData>();
                System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
                XParseDocument  doc     = MyHelper.ParseXmlDocument(stream);
                XParseElement[] results = XPath.GetElements("//industry", doc);
                foreach (XParseElement node in results)
                {
                    IndustryData ind = new IndustryData();
                    foreach (XParseAttribute att in node.Attributes())
                    {
                        if (att.Name.LocalName == FinanceHelper.NameIndustryID)
                        {
                            int i = 0;
                            int.TryParse(att.Value, out i);
                            if (i != 0)
                            {
                                ind.ID = (Industry)i;
                            }
                        }
                        else if (att.Name.LocalName == FinanceHelper.NameMarketName)
                        {
                            ind.Name = att.Value;
                        }
                    }
                    foreach (XParseElement companyNode in node.Elements())
                    {
                        if (companyNode.Name.LocalName == "company")
                        {
                            CompanyInfoData comp = new CompanyInfoData();
                            foreach (XParseAttribute att in companyNode.Attributes())
                            {
                                if (att.Name.LocalName == FinanceHelper.NameCompanySymbol)
                                {
                                    comp.SetID(att.Value);
                                }
                                else if (att.Name.LocalName == FinanceHelper.NameMarketName)
                                {
                                    comp.Name = att.Value;
                                }
                            }
                            ind.Companies.Add(comp);
                        }
                    }
                    industries.Add(ind);
                }
                return(new IndustryResult(industries.ToArray()));
            }
            else
            {
                return(null);
            }
        }
Example #7
0
 public void DownloadAsync(MarketDownloadSettings settings, object userArgs)
 {
     base.DownloadAsync(settings, userArgs);
 }