示例#1
0
        public ArrayList readRec(String date)
        {
            ArrayList   tag       = new ArrayList();
            ArrayList   details   = new ArrayList();
            ArrayList   descArray = new ArrayList();
            ArrayList   id        = new ArrayList();
            ArrayList   ret       = new ArrayList();
            TagProvider tp        = new TagProvider();
            var         li        = dbConnection.Query <Item>("select * from Item where date = '" + date + "'");

            if (li.Count != 0)
            {
                foreach (Item i in li)
                {
                    tag.Add(tp.getContentByID(i.tagDesc));
                    details.Add(i.time + " | " + i.amount);
                    descArray.Add(i.desc);
                    id.Add(i.id);
                }
                ret.Add(tag);
                ret.Add(details);
                ret.Add(descArray);
                ret.Add(id);
            }
            return(ret);
        }
        public ArrayList readRec(String date)
        {
            String x = "";//Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            //处理文件不存在的异常
            ArrayList tag       = new ArrayList();
            ArrayList al        = new ArrayList();
            ArrayList descArray = new ArrayList();

            if (!File.Exists(x + date + ".txt"))
            {
                return(al);
            }
            StreamReader s = new StreamReader(x + date + ".txt", Encoding.UTF8);
            string       nextLine, time = "", desc = "", tagPic = "";
            int          i  = 0;
            TagProvider  tp = new TagProvider();

            while ((nextLine = s.ReadLine()) != null)
            {
                if (i % 4 == 0)//time
                {
                    time = nextLine;
                    i++;
                }
                else if (i % 4 == 1)//tag
                {
                    tagPic = tp.getContentByID(nextLine);
                    i++;
                }
                else if (i % 4 == 2)//desc
                {
                    desc = nextLine;
                    i++;
                }
                else
                {
                    tag.Add(tagPic);
                    al.Add(time + " | " + nextLine);
                    descArray.Add(desc);
                    i = 0;
                }
            }
            s.Close();
            ArrayList ret = new ArrayList();

            ret.Add(tag);
            ret.Add(al);
            ret.Add(descArray);
            return(ret);
        }