Beispiel #1
0
        public string ShowAwards(int id)
        {
            string       pathusersandawards = AppDomain.CurrentDomain.BaseDirectory + "usersandawards.txt";
            StreamReader input      = new StreamReader(pathusersandawards);
            string       str        = input.ReadToEnd();
            string       idfromfile = string.Empty;

            input.Close();
            string   awards   = string.Empty;
            AwardDao awarddao = new AwardDao();

            for (int i = 0; i < str.Length; i++)
            {
                if ((str[0] + string.Empty).Equals(id.ToString()) & i == 0)
                {
                    awards = awarddao.GetById(int.Parse(str[i + 2] + string.Empty)) + " ";
                }

                if (i == str.Length - 2)
                {
                    break;
                }

                if (str[i].Equals((char)13) & str[i + 1].Equals((char)10))
                {
                    idfromfile = str[i + 2] + string.Empty;
                    if (idfromfile.Equals(id.ToString()))
                    {
                        awards += awarddao.GetById(int.Parse(str[i + 4] + string.Empty)) + " ";
                    }
                }
            }

            return(awards);
        }
Beispiel #2
0
        public string ShowAwards(int id)
        {
            string       pathusersandawards = System.IO.Path.GetTempPath() + "usersandawards.txt";
            StreamWriter output             = new StreamWriter(pathusersandawards, true);

            output.Close();
            StreamReader input      = new StreamReader(pathusersandawards);
            string       str        = input.ReadToEnd();
            string       idfromfile = string.Empty;

            input.Close();
            string   awards   = string.Empty;
            AwardDao awarddao = new AwardDao();

            for (int i = 0; i < str.Length; i++)
            {
                if ((str[0] + string.Empty).Equals(id.ToString()) & i == 0)
                {
                    awards = awarddao.GetById(int.Parse(str[i + 2] + string.Empty)) + " ";
                }

                if (i == str.Length - 2)
                {
                    break;
                }

                if (str[i].Equals((char)13) & str[i + 1].Equals((char)10))
                {
                    idfromfile = str[i + 2] + string.Empty;
                    if (idfromfile.Equals(id.ToString()))
                    {
                        awards += awarddao.GetById(int.Parse(str[i + 4] + string.Empty)) + " ";
                    }
                }
            }

            return(awards);
        }