Exemplo n.º 1
0
        public int GetJumps(String CurrentPos, string WineName, XmlRemoteValueList Items)
        {
            int Jumps   = 0;
            int CurrPos = int.Parse(CurrentPos);

            if (WineName.Length == 0)
            {
                return(-1);
            }
            for (int ii = 0; ii < Items.List.Count; ii++)
            {
                String Name = ((PropertySet)Items.List[ii]).Entries["Wine"].ToString();

                bool StatOK = true;

                if (WineName.Length > 0 && !Name.ToLower().StartsWith(WineName.ToLower()))
                {
                    StatOK = false;
                }
                if (StatOK)
                {
                    Jumps = ii - CurrPos;
                    Jumps = ii;
                    break;
                }
            }

            return(Jumps);
        }
Exemplo n.º 2
0
        public XmlRemoteValueList FilterList(string WineName, string WineVintage, string WineType, string WineRegion, string WineCountry, XmlRemoteValueList Wines)
        {
            SortableList NewWines = new SortableList();

            for (int ii = 0; ii < Wines.List.Count; ii++)
            {
                bool   StatOK  = true;
                String Country = ((PropertySet)Wines.List[ii]).Entries["Locale"].ToString();
                String Type    = ((PropertySet)Wines.List[ii]).Entries["Type"].ToString();
                String Vintage = ((PropertySet)Wines.List[ii]).Entries["Vintage"].ToString();
                String Name    = ((PropertySet)Wines.List[ii]).Entries["Wine"].ToString();

                if (WineName.Length > 0 && !Name.ToLower().Contains(WineName.ToLower()))
                {
                    StatOK = false;
                }
                if (WineVintage.Length > 0 && !Vintage.ToLower().Contains(WineVintage.ToLower()))
                {
                    StatOK = false;
                }
                if (WineType.Length > 0 && !Type.ToLower().Contains(WineType.ToLower()))
                {
                    StatOK = false;
                }
                if (WineCountry.Length > 0 && !Country.ToLower().Contains(WineCountry.ToLower()))
                {
                    StatOK = false;
                }
                if (WineRegion.Length > 0 && !Country.ToLower().Contains(WineRegion.ToLower()))
                {
                    StatOK = false;
                }

                if (StatOK)
                {
                    NewWines.Add(Wines.List[ii]);
                }
            }
            Wines.List = NewWines;
            return(Wines);
        }
        public void Test()
        {
            RemoteResourceUri RRU = new RemoteResourceUri();

            RRU.Uri = new Uri("http://www.cellartracker.com/api_read.asp");
            Dictionary <string, string> Querys = new Dictionary <string, string>();

            Querys.Add("user", "gt1485a");
            Querys.Add("password", "Darwin1");
            Querys.Add("API", "list");
            Querys.Add("Format", "XML");
            Querys.Add("Page", "1");
            Querys.Add("Records", "2");
            RRU.QueryPairs       = Querys;
            XRR                  = new XmlRemoteResource();
            XRR.PropertyChanged += new PropertyChangedEventHandler(XRR_PropertyChanged);
            XRR.RequestUri       = RRU;

            XmlRemoteValueList Wines = new XmlRemoteValueList();

            Wines.Source = "//row";
            XmlRemoteValue Vintage = new XmlRemoteValue();

            Vintage.Source = "//row/Vintage";
            XmlRemoteValue Wine = new XmlRemoteValue();

            Wine.Source = "//row/Wine";
            XmlRemoteValue Type = new XmlRemoteValue();

            Type.Source = "//row/Type";
            ArrayList D = new ArrayList();

            D.Add(Type);
            D.Add(Vintage);
            D.Add(Wine);

            Wines.Mappings = D;


            //    <Mappings>
            //  <da:XmlRemoteValueList Name="Wines" RepeatedType="PropertySet" Source="//row">
            //    <Mappings>
            //      <da:XmlRemoteValue Property="Entries.#Wine" Source="//row/Wine"/>
            //      <da:XmlRemoteValue Property="Entries.#Vintage" Source="//row/Vintage"/>
            //      <da:XmlRemoteValue Property="Entries.#Type" Source="//row/Type"/>
            //    </Mappings>
            //  </da:XmlRemoteValueList>
            //</Mappings>
            PropertySet PS = new PropertySet();

            PS.Entries.Add("Wines", Wines);

            XRR.Mappings = PS;


            XRR.GetDataFromResource();

            ArrayListDataSet F = new ArrayListDataSet();

            F.Add(new EditableText());
        }