Example #1
0
        public User(Guid guid)
        {
            _uniqueid = guid;
            _birthday = DateTime.Now;
            _location = new GeoLocation();
            _description = new Description();
            _preferences = new List<Description>();

            _alteredfields = new Dictionary<string, bool>();
            SetAlteredFields(false);
        }
Example #2
0
        //private Boolean _ispreference;
        // Contructor
        public DescriptionForm(Description description, Boolean ispreference)
        {
            InitializeComponent();

            _description = description;

            txt_guid.Text = _description.UniqueID.ToString().ToUpper();
            txt_timestamp.Text = _description.TimeStamp.ToLongTimeString();
            if (ispreference) { txt_title.Text = _description.Title; }
            else { txt_title.Enabled = false; }
            num_age.Value = _description.Age;
            if (ispreference) { num_agemax.Value = _description.Age.Max; }
            else { num_age.Enabled = false; num_agemax.Enabled = false; }

            enum_gender.SetValues(_description.Gender.EnumToStringList, _description.Gender, ispreference);
            enum_sexuality.SetValues(_description.Sexuality.EnumToStringList, _description.Sexuality, ispreference);
            enum_region.SetValues(_description.Area.EnumToStringList, _description.Area, ispreference);
            enum_smoking.SetValues(_description.Smoking.EnumToStringList, _description.Smoking, ispreference);
            enum_drinking.SetValues(_description.Drinking.EnumToStringList, _description.Drinking, ispreference);
        }
Example #3
0
        private void btn_pref_add_Click(object sender, EventArgs e)
        {
            Description pref = new Description();
            DescriptionForm form = new DescriptionForm(pref, true);
            DialogResult dr = form.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                _user.Preferences.Add(pref);
                //DBINSERT
                RedrawPreferences();
            }
        }
Example #4
0
        private static User UserFromStringV01(String s)
        {
            User u = null;
            try
            {
                String[] parts = s.Split("\\{".ToCharArray());
                String[] ss = parts[0].Split("\\|".ToCharArray());

                u = new User(new Guid(ss[0]));
                u.Email = ss[1];
                u.Username = ss[2];
                u.Password = ss[3];
                u.FirstName = ss[4];
                u.LastName = ss[5];
                u.Birthday = Tools.DTfromTS(Convert.ToInt32(ss[6]));
                u.Location = new GeoLocation(
                    Convert.ToSingle(ss[7]),
                    Convert.ToSingle(ss[8]),
                    Tools.DTfromTS(Convert.ToInt32(ss[9]))
                );
                Description d = new Description(new Guid(ss[0]));
                d.TimeStamp = Tools.DTfromTS(Convert.ToSingle(ss[10]));
                d.Title = ss[11];
                d.Age.Set(Convert.ToInt16(ss[12]), (Convert.ToInt16(ss[13])));
                d.Gender = EnumList<GenderType>.FromString(ss[14]);
                d.Sexuality = EnumList<SexualityType>.FromString(ss[15]);
                d.Area = EnumList<AreaType>.FromString(ss[16]);
                d.Smoking = EnumList<SmokingType>.FromString(ss[17]);
                d.Drinking = EnumList<DrinkingType>.FromString(ss[18]);
                u.Description = d;

                // Add preference descriptions if available
                if (parts.Length > 1)
                {
                    for (int i = 1; i < parts.Length; i++)
                    {
                        ss = parts[i].Split("\\|".ToCharArray());

                        Description p = new Description(new Guid(ss[0]));
                        p.TimeStamp = Tools.DTfromTS(Convert.ToSingle(ss[1]));
                        p.Title = ss[2];
                        p.Age.Set(Convert.ToInt16(ss[3]), (Convert.ToInt16(ss[4])));
                        p.Gender = EnumList<GenderType>.FromString(ss[5]);
                        p.Sexuality = EnumList<SexualityType>.FromString(ss[6]);
                        p.Area = EnumList<AreaType>.FromString(ss[7]);
                        p.Smoking = EnumList<SmokingType>.FromString(ss[8]);
                        p.Drinking = EnumList<DrinkingType>.FromString(ss[9]);
                        u.Preferences.Add(p);
                    }
                }
            }
            catch (Exception e)
            {
                u = null;
            }

            return u;
        }
Example #5
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            long now = Tools.DTtoTS(DateTime.Now);

            for (int i = 0; i < num_amount.Value; i++)
            {
                User user = new User();

                //user.UniqueID;
                user.Username = GenerateUsername(user.UniqueID);
                user.Password = "******";
                user.Email = GenerateEmail(user.Username);
                user.FirstName = GenerateFirstname();
                user.LastName = GenerateLastname();
                user.Birthday = Tools.DTfromTS(now - (_rng.Next(18, 80) * _rng.Next(30758400, 31000000)));

                user.Location = new GeoLocation(	Convert.ToSingle((_rng.NextDouble() * (double)(num_latmax.Value - num_latmin.Value)) + (double)num_latmin.Value),
                                                    Convert.ToSingle((_rng.NextDouble() * (double)(num_lonmax.Value - num_lonmin.Value)) + (double)num_lonmin.Value));

                user.Description = new Description();
                //user.Description.UniqueID;
                user.Description.TimeStamp = DateTime.Now;
                user.Description.Title = "Description";
                user.Description.SetAge(_rng.Next(18, 99));
                user.Description.Gender = EnumList<GenderType>.FromString(GenerateBinaryString(1, 5));
                user.Description.Sexuality = EnumList<SexualityType>.FromString(GenerateBinaryString(1, 4));
                user.Description.Area = EnumList<AreaType>.FromString(GenerateBinaryString(1, 5));
                user.Description.Smoking = EnumList<SmokingType>.FromString(GenerateBinaryString(1, 3));
                user.Description.Drinking = EnumList<DrinkingType>.FromString(GenerateBinaryString(1, 2));

                Description p = new Description();
                //user.Description.UniqueID;
                p.TimeStamp = DateTime.Now;
                p.Title = "pref" + _rng.Next(1, 9999).ToString("0000");
                p.SetAge(_rng.Next(18, 99), _rng.Next(18, 99));
                p.Gender = EnumList<GenderType>.FromString(GenerateBinaryString(5, 5));
                p.Sexuality = EnumList<SexualityType>.FromString(GenerateBinaryString(4, 4));
                p.Area = EnumList<AreaType>.FromString(GenerateBinaryString(5, 5));
                p.Smoking = EnumList<SmokingType>.FromString(GenerateBinaryString(3, 3));
                p.Drinking = EnumList<DrinkingType>.FromString(GenerateBinaryString(2, 2));
                user.Preferences.Add(p);

                string result = _db.SaveUser(user);

                if (!result.Equals("E10"))
                {
                    MessageBox.Show("Couldn't save user at iteration (Errorcode: " + result + ") " + (i+1), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            Close();
        }