private WebFormDownloadSettings GetDeletePortfolioViewDownloadSettings(string portfolioID, int viewIndex)
        {
            List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();

            lst.Add(new KeyValuePair <string, string>(".yficrumb", ""));
            lst.Add(new KeyValuePair <string, string>(".yfiuseajax", "0"));
            lst.Add(new KeyValuePair <string, string>(".yfisrc", ""));
            lst.Add(new KeyValuePair <string, string>(".yfidone", ""));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_id", portfolioID));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_symbol", ""));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_lot", ""));
            lst.Add(new KeyValuePair <string, string>("yfi_view_id", "v" + (viewIndex + 1).ToString()));
            lst.Add(new KeyValuePair <string, string>("yfi_quotes_symbols", ""));
            lst.Add(new KeyValuePair <string, string>("yfi_yes", ""));

            string view = "v" + (viewIndex + 1);
            WebFormDownloadSettings settings = new WebFormDownloadSettings();

            settings.Account            = this;
            settings.Url                = "http://finance.yahoo.com/portfolio/confirm/delete-view?view_id=" + view + "&portfolio_id=" + portfolioID;
            settings.RefererUrlPart     = "/quotes/view/" + view + "/delete";
            settings.AdditionalWebForms = lst;
            settings.SearchForWebForms  = null;
            settings.FormActionPattern  = "";
            settings.DownloadResponse   = true;
            return(settings);
        }
        private WebFormDownloadSettings GetEditPortfolioViewDownloadSettings(string portfolioID, int viewIndex, string name, IEnumerable <PortfolioColumnType> viewFields)
        {
            List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();

            lst.Add(new KeyValuePair <string, string>(".yficrumb", ""));
            lst.Add(new KeyValuePair <string, string>("id", (viewIndex > -1 ? "v" + (viewIndex + 1) : "")));
            lst.Add(new KeyValuePair <string, string>("from_view_id", ""));
            lst.Add(new KeyValuePair <string, string>("portfolio_id", portfolioID));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_fields_name", name));
            PortfolioColumnType[] enm = MyHelper.EnumToArray(viewFields);
            for (int i = 0; i < 14; i++)
            {
                if (enm.Length > i)
                {
                    lst.Add(new KeyValuePair <string, string>("yfi_pf_fields[]", enm[i].ToString()));
                }
                else
                {
                    lst.Add(new KeyValuePair <string, string>("yfi_pf_fields[]", ""));
                }
            }
            lst.Add(new KeyValuePair <string, string>("save", ""));

            WebFormDownloadSettings settings = new WebFormDownloadSettings();

            settings.Account            = this;
            settings.Url                = "http://finance.yahoo.com/quotes/view/" + (viewIndex > -1 ? "v" + (viewIndex + 1) : "new");
            settings.RefererUrlPart     = "/quotes/view/edit-save";
            settings.AdditionalWebForms = lst;
            settings.SearchForWebForms  = null;
            settings.FormActionPattern  = "";
            settings.DownloadResponse   = true;
            return(settings);
        }
Example #3
0
        private WebFormDownloadSettings GetLoginDownloadSettings(System.Net.NetworkCredential user)
        {
            List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();

            lst.Add(new KeyValuePair <string, string>(".tries", "1"));
            lst.Add(new KeyValuePair <string, string>(".src", "/"));
            lst.Add(new KeyValuePair <string, string>(".md5", ""));
            lst.Add(new KeyValuePair <string, string>(".hash", ""));
            lst.Add(new KeyValuePair <string, string>(".js", ""));
            lst.Add(new KeyValuePair <string, string>(".last", ""));
            lst.Add(new KeyValuePair <string, string>("promo", ""));
            lst.Add(new KeyValuePair <string, string>(".intl", "en"));
            lst.Add(new KeyValuePair <string, string>(".lang", "en-US"));
            lst.Add(new KeyValuePair <string, string>(".bypass", ""));
            lst.Add(new KeyValuePair <string, string>(".partner", ""));
            lst.Add(new KeyValuePair <string, string>(".u", ""));
            lst.Add(new KeyValuePair <string, string>(".v", ""));
            lst.Add(new KeyValuePair <string, string>(".challenge", ""));
            lst.Add(new KeyValuePair <string, string>(".yplus", ""));
            lst.Add(new KeyValuePair <string, string>(".emailCode", ""));
            lst.Add(new KeyValuePair <string, string>("pkg", ""));
            lst.Add(new KeyValuePair <string, string>("stepid", ""));
            lst.Add(new KeyValuePair <string, string>(".ev", ""));
            lst.Add(new KeyValuePair <string, string>("hasMsgr", "0"));
            lst.Add(new KeyValuePair <string, string>(".chkP", "Y"));
            lst.Add(new KeyValuePair <string, string>(".done", ""));
            lst.Add(new KeyValuePair <string, string>(".pd", ""));
            lst.Add(new KeyValuePair <string, string>(".ws", ""));
            lst.Add(new KeyValuePair <string, string>(".cp", ""));
            lst.Add(new KeyValuePair <string, string>("pad", ""));
            lst.Add(new KeyValuePair <string, string>("aad", ""));
            lst.Add(new KeyValuePair <string, string>("login", user.UserName));
            lst.Add(new KeyValuePair <string, string>("passwd", user.Password));
            lst.Add(new KeyValuePair <string, string>(".persistent", "y"));
            lst.Add(new KeyValuePair <string, string>(".save", ""));
            lst.Add(new KeyValuePair <string, string>("passwd_raw", ""));

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

            lstSearchFor.Add(".u");
            lstSearchFor.Add(".v");
            lstSearchFor.Add(".challenge");
            lstSearchFor.Add(".pd");
            lstSearchFor.Add("pad");
            lstSearchFor.Add("aad");
            lstSearchFor.Add(".ws");
            lstSearchFor.Add(".cp");

            WebFormDownloadSettings settings = new WebFormDownloadSettings();

            settings.Account            = this;
            settings.Url                = "https://login.yahoo.com/config/login";
            settings.RefererUrlPart     = "https://login.yahoo.com/config/login";
            settings.AdditionalWebForms = lst;
            settings.SearchForWebForms  = lstSearchFor.ToArray();
            settings.FormActionPattern  = "action=\"https://login.yahoo.com/config/login.*?\"";
            return(settings);
        }
        private WebFormDownloadSettings GetEditPortfolioDownloadSettings(string portfolioID, string name, CurrencyInfo currency, bool symbolSorting, bool symbolCollapsing, IEnumerable <YID> items, IEnumerable <YIndexID> indices)
        {
            List <KeyValuePair <string, string> > lst = this.GetPortfolioDict(name, currency, symbolSorting, symbolCollapsing, items, indices, portfolioID);
            WebFormDownloadSettings settings          = new WebFormDownloadSettings();

            settings.Account            = this;
            settings.Url                = "http://finance.yahoo.com/portfolio/" + portfolioID + "/edit";
            settings.RefererUrlPart     = "/portfolio/" + portfolioID + "/save-edit";
            settings.AdditionalWebForms = lst;
            settings.SearchForWebForms  = null;
            settings.FormActionPattern  = "";
            return(settings);
        }
        private WebFormDownloadSettings GetDeletePortfolioItemDownloadSettings(string portfolioID, string itemID, int idIndex)
        {
            List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();

            lst.Add(new KeyValuePair <string, string>(".yfiuseajax", "1"));
            lst.Add(new KeyValuePair <string, string>(".yfisrc", "/"));
            lst.Add(new KeyValuePair <string, string>(".yfidone", ""));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_id", portfolioID));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_symbol", itemID));
            lst.Add(new KeyValuePair <string, string>("yfi_pf_lot", idIndex.ToString()));
            lst.Add(new KeyValuePair <string, string>("yfi_yes", "1"));
            WebFormDownloadSettings settings = new WebFormDownloadSettings();

            settings.Account            = this;
            settings.Url                = "http://finance.yahoo.com" + "/portfolio/" + portfolioID + "/view/v1";
            settings.RefererUrlPart     = "/portfolio/" + portfolioID + "/holdings/delete/" + Uri.EscapeDataString(itemID);
            settings.AdditionalWebForms = lst;
            settings.SearchForWebForms  = null;
            settings.FormActionPattern  = "action=\"/portfolio/delete_symbols\"";
            settings.DownloadResponse   = true;
            return(settings);
        }
        private WebFormDownloadSettings GetEditHoldingsDownloadSettings(string portfolioID, Holding[] holdings)
        {
            List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();

            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
            lst.Add(new KeyValuePair <string, string>("yfi_pf_action", "add_holdings"));
            lst.Add(new KeyValuePair <string, string>(".yfisrc", "/"));
            lst.Add(new KeyValuePair <string, string>(".yfidone", ""));
            lst.Add(new KeyValuePair <string, string>(".yficurr", ""));
            lst.Add(new KeyValuePair <string, string>(".yficrumb", ""));
            foreach (Holding holding in holdings)
            {
                lst.Add(new KeyValuePair <string, string>("yfi_pf_symbol[]", holding.ID));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_lot[]", holding.Lot.ToString()));
                lst.Add(new KeyValuePair <string, string>("date[]", ""));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_trade_date_day[]", holding.TradeDate.HasValue ? holding.TradeDate.Value.Day.ToString() : DateTime.Today.Day.ToString()));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_trade_date_month[]", holding.TradeDate.HasValue ? holding.TradeDate.Value.Month.ToString() : DateTime.Today.Month.ToString()));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_trade_date_year[]", holding.TradeDate.HasValue ? holding.TradeDate.Value.Year.ToString() : DateTime.Today.Year.ToString()));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_shares_owned[]", holding.Shares != 0 ? holding.Shares.ToString() : ""));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_price_paid[]", holding.PricePaid != 0 ? holding.PricePaid.ToString(ci) : ""));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_commission[]", holding.Commission != 0 ? holding.Commission.ToString(ci) : ""));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_low_limit[]", holding.LowLimit != 0 ? holding.LowLimit.ToString(ci) : ""));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_high_limit[]", holding.HighLimit != 0 ? holding.HighLimit.ToString(ci) : ""));
                lst.Add(new KeyValuePair <string, string>("yfi_pf_comment[]", holding.Notes != string.Empty ? holding.Notes : ""));
            }
            lst.Add(new KeyValuePair <string, string>("save", "Save"));
            string urlPart = "/portfolio/" + portfolioID + "/holdings";
            WebFormDownloadSettings settings = new WebFormDownloadSettings();

            settings.Account            = this;
            settings.Url                = "http://finance.yahoo.com" + urlPart + "/edit";
            settings.RefererUrlPart     = urlPart + "/update";
            settings.AdditionalWebForms = lst;
            settings.SearchForWebForms  = null;
            settings.FormActionPattern  = "";
            settings.DownloadResponse   = true;
            return(settings);
        }