예제 #1
0
    public string UserRegister(string Name, string Password, string Email, string RealityName)
    {

        long CpsID = -1;
        long CommenderID = -1;
        string Memo = "";
        Users user = new Users(1);
        user.Name = Name;
        user.Password = Password;
        user.Email = Email;
        user.RealityName = RealityName;
        user.UserType = 2;

        user.CommenderID = CommenderID;
        user.CpsID = CpsID;
        user.Memo = Memo;
        string ReturnDescription=string.Empty;
        int Result = user.Add(ref ReturnDescription); 
        if (Result < 0)
        {
            new Log("Users").Write("会员注册不成功:" + ReturnDescription);
            return "会员注册不成功:" + ReturnDescription;

        }
        Result = user.Login(ref ReturnDescription);
        if (Result < 0)
        {
            new Log("Users").Write("注册成功后登录失败:" + ReturnDescription);
            return "注册成功后登录失败:" + ReturnDescription;
        }
        return "1"; 
    }
예제 #2
0
        public AWSUsersModel GetUsers(string PaginationToken = "")
        {
            if (PaginationToken == null)
            {
                return(null);
            }
            string add = "";

            if (PaginationToken.Length == 0)
            {
                Users = new List <AWSUsersModel>();
                Users.Clear();
            }
            else
            {
                add = $"--pagination-token {PaginationToken}";
            }
            var users = JsonConvert.DeserializeObject <AWSUsersModel>(RunCommand($"list-users {add}").Item2);

            Users?.Add(users);
            return(users);
        }
예제 #3
0
    private string RegUser()
    {
        string userName = Request.Form["userName"];
        string pwd = Request.Form["pwd"];
        string email = Request.Form["email"];
        string trueName = Request.Form["trueName"];

        var u = new Users(1);
        u.Name = userName;
        u.Password = pwd;
        u.Email = email;
        u.RealityName = trueName;
        u.UserType = 1;

        string returnMsg = string.Empty;
        int r = u.Add(ref returnMsg);
        if (r < 0) {
            var msg = string.Format("注册失败!{0}", returnMsg);
            new Log("Users").Write(msg);
            return msg;
        }
        return r.ToString();
    }
예제 #4
0
 public async Task<IActionResult> Add([FromBody]UserFormModel model)
 {
     return Ok(await Users.Add(Mapper.Map<AddUserDTO>(model), model.IsAdmin));
 }
예제 #5
0
 public void Add_User(User user)
 {
     Users.Add(user);
     Serialize_System();
 }
예제 #6
0
파일: User.cs 프로젝트: hotmike49/PM
 internal static Users LoadProjectUsers(Project p)
 {
     if (p.ID != "")
     {
         SqlCommand cmd = new SqlCommand("select u.Firstname, u.Lastname, u.Username, u.Email from UserProject as up inner join [User] as u on up.Username = u.Username where ProjectID = @pid", Main.GetConnection());
         cmd.Parameters.Add(new SqlParameter("pid", p.ID));
         SqlDataReader reader = cmd.ExecuteReader();
         Users projectUsers = new Users();
         while (reader.Read())
         {
             User u = new User();
             u.Firstname = reader.GetString(0);
             u.Lastname = reader.GetString(1);
             u.Username = reader.GetString(2);
             u.Email = reader.GetString(3);
             projectUsers.Add(u);
         }
         return projectUsers;
     }
     else return null;
 }
예제 #7
0
        private void Seed()
        {
            Users.Add(new User {
                Name = "admin", Login = "******", PasswordHash = HashUtils.GetStringHash("admin"), Role = Role.Admin
            });
            Users.Add(new User
            {
                Name         = "Ольга",
                Surname      = "Павлова",
                MiddleName   = "Степановна",
                PasswordHash = HashUtils.GetStringHash("password"),
                Job          = new Clinic
                {
                    Name    = "Республиканский научно-практический центр «Кардиология»",
                    Address = "Республика Беларусь, г. Минск, ул. Р. Люксембург, 110"
                },
                Position = "Заведующая лабораторией артериальной гипертонии, " +
                           "кандидат медицинских наук, доцент, " +
                           "высшая категория по специальности кардиология",
                Role  = Role.User,
                Login = "******"
            });

            //            var testPatient = new Patient
            //            {
            //                Name = "Юрий",
            //                MiddleName = "Валентинович",
            //                Surname = "Петрашевич",
            //                Nationality = "белорус",
            //                BirthPlace = "Беларусь, г. Минск",
            //                Phone = "+375171234567",
            //                Address = "Республика Беларусь, г. Минск, пр. Независимости 187-35",
            //                BirthDate = new DateTime( 1978, 11, 11 ),
            //                Gender = GenderType.Male,
            //                Genes =
            //                {
            //                    new Gene { Name = "AGT", Value = 2 },
            //                    new Gene { Name = "AGTR2", Value = 3 }
            //                },
            //                PatientVisitDataHistory =
            //                {
            //                    new PatientVisitData
            //                        {
            //                            WaistCircumference = 124,
            //                            Height = 182,
            //                            Weight = 120,
            //                            PhysicalActivity = PhysicalActivity.OncePerWeekOrLess,
            //                            SaltSensitivity = new SaltSensitivityTest
            //                            {
            //                                SaltSensitivity = 1,
            //                                TestDate = DateTime.Today
            //                            },
            //                            AlcoholСonsumption = AlcoholСonsumption.Monthly,
            //                            BloodPressure = new BloodPressure
            //                            {
            //                                LeftShoulderSBP = 157,
            //                                LeftShoulderDBP = 113,
            //                                RightShoulderSBP = 168,
            //                                RightShoulderDBP = 111,
            //                                HeartRate = 81
            //                            },
            //                            DepressionPointsCES_D = 37,
            //                            StressPointsPSM_25 = 141,
            //                            Smoking = new Smoking
            //                            {
            //                                Type = SmokingType.Now,
            //                                CigarettesPerDay = 20,
            //                                DurationInYears = 5
            //                            }
            //                        }
            //                },
            //                Clinic = new Clinic
            //                {
            //                    Address = "Республика Беларусь, г. Минск, ул. Ломоносова, д. 3",
            //                    Name = "13 городская поликлиника"
            //                },
            //                Diagnosis = "Первичная АГ",
            //                TreatmentDuration = 4,
            //                HypertensionDuration = 5,
            //                Medicine =
            //                {
            //                    new Medicine
            //                    {
            //                        Name = "Карведилол",
            //                        Dose = "25 мг"
            //                    },
            //                    new Medicine
            //                    {
            //                        Name = "Бисопролол",
            //                        Dose = "5 мг"
            //                    }
            //                },
            //                HypertensionAncestralAnamnesis = HypertensionAncestralAnamnesis.Father
            //
            //            };
            //            context.Patients.Add( testPatient );

            var patients = ReadPatients();

            var models = new List <ClassificationModel>
            {
                new ClassificationModel
                {
                    LimitPoints = new List <LimitPoint> {
                        new LimitPoint {
                            Point = 0.5
                        }
                    },
                    Name            = "TestModel",
                    FreeCoefficient = -1.193050,
                    OptimalCutOff   = 0.654,
                    Properties      = new List <ModelProperty>
                    {
                        new ModelProperty
                        {
                            Name    = "Age",
                            Entries = new List <ModelScaleEntry>
                            {
                                new ModelScaleEntry {
                                    LowerBound = 45, Value = 1
                                }
                            },
                            ModelCoefficient = 1.095915
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.ObesityWaistCircumference",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.637895
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.ObesityBMI",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 1.380139
                        },
                        new ModelProperty
                        {
                            Name             = "Gender",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.668418
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.PhysicalActivity",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.668418
                        },
                        new ModelProperty
                        {
                            Name             = "AGT_AGTR2",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.423879
                        }
                    }
                },
                new ClassificationModel
                {
                    LimitPoints = new List <LimitPoint> {
                        new LimitPoint {
                            Point = 0.5
                        }
                    },
                    Name            = "TestModelNoGene",
                    FreeCoefficient = -0.819416,
                    OptimalCutOff   = 0.654,
                    Properties      = new List <ModelProperty>
                    {
                        new ModelProperty
                        {
                            Name    = "Age",
                            Entries = new List <ModelScaleEntry>
                            {
                                new ModelScaleEntry {
                                    LowerBound = 45, Value = 1
                                }
                            },
                            ModelCoefficient = 0.973776
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.ObesityWaistCircumference",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.582647
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.ObesityBMI",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 1.541386
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.PhysicalActivity",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.708104
                        },
                        new ModelProperty
                        {
                            Name             = "{PatientVisitData}.Smoking.Type",
                            Entries          = new List <ModelScaleEntry>(),
                            ModelCoefficient = 0.423879
                        }
                    }
                }
            };

//            var optimalCutOffCalculator = new OptimalCutOffCalculator(new PatientPropertyProvider());
//
//            foreach (var model in models)
//            {
//                model.OptimalCutOff = optimalCutOffCalculator.CalculateOptimalCutOff(model, patients);
//            }

            ClassificationModels.AddRange(models);
            Patients.AddRange(patients);

            SaveChanges();
        }
 async Task SaveUser(User user)
 {
     Users.Add(user);
     await UsersDataStore.AddAsync(user);
 }
예제 #9
0
        private void UpdateUsers(List <VRCUser> onlineUsers)
        {
            var onlineIndices = new List <int>();

            foreach (var user in onlineUsers)
            {
                if (m_userIdToIndex.ContainsKey(user.Id))
                {
                    onlineIndices.Add(m_userIdToIndex[user.Id]);
                }
            }

            onlineIndices.Sort();


            int checkIndex = 0;

            // Check offline.
            for (int i = 0; i < Users.Count; ++i)
            {
                if (checkIndex < onlineIndices.Count &&
                    onlineIndices[checkIndex] == i)
                {
                    ++checkIndex;

                    continue;
                }


                var user = Users[i];

                if (user.Location != "offline")
                {
                    user.Location         = "offline";
                    user.StatusText       = "Offline";
                    user.InstanceOccupant = "";
                    user.FriendsWith.Clear();

                    // Alarm offline.
                    if (user.IsTracked)
                    {
                        OnUserChanged(user.ImageUrl, user.Name, user.StatusText);
                    }
                }
            }

            foreach (var user in onlineUsers)
            {
                VRCUser target      = null;
                int     targetIndex = -1;

                if (m_userIdToIndex.ContainsKey(user.Id))
                {
                    targetIndex = m_userIdToIndex[user.Id];
                    target      = Users[targetIndex];
                }

                if (target == null)
                {
                    m_userIdToIndex[user.Id] = Users.Count;

                    Users.Add(user);

                    // Alarm online.
                    if (user.IsTracked)
                    {
                        OnUserChanged(user.ImageUrl, user.Name, $"Online ({user.StatusText})");
                    }
                }
                else
                {
                    if (target.IsTracked)
                    {
                        if (target.Name != user.Name)
                        {
                            // Alarm name changed.
                            OnUserChanged(user.ImageUrl, user.Name, $"{target.Name} → {user.Name}");
                        }

                        if (target.Status != user.Status)
                        {
                            // Alarm status changed.
                            OnUserChanged(user.ImageUrl, user.Name, user.StatusText);
                        }
                        else if (target.Star >= 2)
                        {
                            if (target.Location != user.Location)
                            {
                                // Alarm location changed.
                                if (string.IsNullOrWhiteSpace(user.InstanceNumber))
                                {
                                    OnUserChanged(user.ImageUrl, user.Name, user.StatusText);
                                }
                                else
                                {
                                    OnUserChanged(user.ImageUrl, user.Name,
                                                  string.Format("{0} {1}", user.StatusText, user.InstanceNumber));
                                }
                            }
                            else if (target.StatusDescription != user.StatusDescription &&
                                     string.IsNullOrWhiteSpace(user.StatusDescription) == false)
                            {
                                // Alarm status description changed.
                                OnUserChanged(user.ImageUrl, user.Name, user.StatusDescription);
                            }
                        }

                        if (target.Star >= 3)
                        {
                            if (target.ImageUrl != user.ImageUrl)
                            {
                                // Alarm image changed.
                                OnUserChanged(user.ImageUrl, user.Name, "Avatar changed");
                            }

                            if (target.Permission != user.Permission)
                            {
                                // Alarm permission changed.
                                OnUserChanged(user.ImageUrl, user.Name, "Permission changed");
                            }


                            var newFriends = new List <string>();

                            foreach (string friend in user.FriendsWith)
                            {
                                if (!target.FriendsWith.Contains(friend))
                                {
                                    newFriends.Add(friend);
                                }
                            }

                            if (newFriends.Count > 0)
                            {
                                var buffer = new StringBuilder("Now with ");

                                foreach (string friend in newFriends.Skip(1))
                                {
                                    buffer.Append(friend);
                                    buffer.Append(", ");
                                }

                                buffer.Append(newFriends.First());

                                // Alarm playmate changed.
                                OnUserChanged(user.ImageUrl, user.Name, buffer.ToString());
                            }
                        }
                    }


                    target.Update(user);
                }
            }
        }
예제 #10
0
 void CreateAndSelectExecute()
 {
     Users.Add(Selected = _userService.CreateUser());
 }
예제 #11
0
    protected void btnOK_Click(object sender, EventArgs e)
    {

        #region 验证
        if (tbName.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入用户名。");

            return;
        }

        if (tbTrueName.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page,"请输入真实姓名。");

            return;
        }

        if (tbPassword.Text == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入用户密码。");

            return;
        }

        if (tbPassword.Text.Length < 6)
        {
            Shove._Web.JavaScript.Alert(this.Page, "用户密码长度不足 6 位。");

            return;
        }

        if (tbPassword.Text != tbPassword2.Text)
        {
            Shove._Web.JavaScript.Alert(this.Page, "输入的两次密码不一致。");

            return;
        }

        if (tbEmail.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入您的邮箱。");

            return;
        }

        if (!Shove._String.Valid.isEmail(tbEmail.Text.Trim()))
        {
            Shove._Web.JavaScript.Alert(this.Page,"请正确输入您的邮箱。");

            return;
        }

        if (CheckCode.Visible)
        {
            if (tbCheckCode.Text.Trim() == "")
            {
                Shove._Web.JavaScript.Alert(this.Page, "请输入验证码!");

                return;
            }
            else
            {
                if (!ShoveCheckCode1.Valid(tbCheckCode.Text.Trim()))
                {
                    Shove._Web.JavaScript.Alert(this.Page, "验证码输入有误!");

                    return;
                }
            }

        }
        #endregion

        System.Threading.Thread.Sleep(500);

        Sites site = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()];

        if (site == null)
        {
            return;
        }

        Users user = new Users(site.ID);

        user.Name =Shove._Web.Utility.FilteSqlInfusion(tbName.Text.Trim());
        user.RealityName = Shove._Web.Utility.FilteSqlInfusion(tbTrueName.Text.Trim());
        user.Password = Shove._Web.Utility.FilteSqlInfusion(tbPassword.Text.Trim());
        user.PasswordAdv = Shove._Web.Utility.FilteSqlInfusion(tbPassword.Text.Trim());
        user.CityID = 1;
        user.ComeFrom = 4;
        user.Email = Shove._Web.Utility.FilteSqlInfusion(tbEmail.Text.Trim());
        user.isEmailValided = true;
        user.QQ = tbQQID.Text.Trim();
        user.UserType = 2;
        user.CommenderID = -1;
        user.isQQValided = true;

        string ReturnDescription = "";

        int UserID = user.Add(ref ReturnDescription);

        if (UserID < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription + "用户添加失败");

            return;
        }

        int Result = user.Login(ref ReturnDescription);

        if (Result < 0)
        {
            new Log("Users").Write("注册成功后登录失败:" + ReturnDescription);
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }
        Response.Redirect("UserRegSuccess.aspx",true);
    }
예제 #12
0
파일: UserOps.cs 프로젝트: cfmayer/Toketee
        public Users Lookup(List<long> UserIdList)
        {
            // Lookup function is limited to 100 id's at a time
            List<string> Lookups = new List<string>();

            for (int i = 0; i < UserIdList.Count(); i += 100)
            {
                var q = (from u in UserIdList
                         select u).Skip(i).Take(100);
                Lookups.Add(string.Join(",", q.ToArray()));
            }

            var user = new UserClient(CurrentUserId);
            var results = new List<WebClientResult<Users>>();
            var list = new Users();
            foreach (string IdSet in Lookups)
            {
                WebClientResult<Users> usersListReturn = user.Lookup(IdSet, null);

                foreach (var u in usersListReturn.Object)
                {
                    list.Add(u);
                }
            }

            return list;
        }
        private Users FindAllUsersAsync()
        {
            var usersVar = new Users
                                      {
                                          new User()
                                              {
                                                  Id = 1,
                                                  FirstName = "John",
                                                  LastName = "Smith",
                                                  Password = "******",
                                                  UserName= "******"
                                              },
                                          new User()
                                              {
                                                  Id = 2,
                                                  FirstName = "Bonnie",
                                                  LastName = "Skelly",
                                                  Password = "******",
                                                  UserName = "******"
                                              },
                                          new User()
                                              {
                                                  Id = 3,
                                                  FirstName = "Dana",
                                                  LastName = "Birkby",
                                                  Password = "******",
                                                  UserName = "******"
                                              },
                                          new User()
                                              {
                                                  Id = 4,
                                                  FirstName = "David",
                                                  LastName = "Probst",
                                                  Password = "******",
                                                  UserName = "******"
                                              },
                                          new User()
                                              {
                                                  Id = 4,
                                                  FirstName = "Rainaldo",
                                                  LastName = "Crosboune",
                                                  Password = "******",
                                                  UserName = "******"
                                              },
                                      };
            for (int i = 0; i < 1000000; i++)
            {
                usersVar.Add(new User()
                {
                    Id = i,
                    FirstName = "FirstName " + i,
                    LastName = "LastName " + i,
                    Password = "******",
                    UserName = "******" + i
                });
            }

            return usersVar;
        }
예제 #14
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (tbName.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入用户名。");

            return;
        }

        if (string.IsNullOrEmpty(tbRealityName.Text.Trim()))
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入真实姓名。");

            return;
        }

        if (CheckCode.Visible)
        {
            if (tbCheckCode.Text.Trim() == "")
            {
                Shove._Web.JavaScript.Alert(this.Page, "请输入验证码!");

                return;
            }
            else
            {
                if (!ShoveCheckCode1.Valid(tbCheckCode.Text.Trim()))
                {
                    Shove._Web.JavaScript.Alert(this.Page, "验证码输入有误!");

                    return;
                }
            }

        }

        System.Threading.Thread.Sleep(500);

        Sites site = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()];

        if (site == null)
        {
            return;
        }

        long CpsID = -1;
        string URL = new FirstUrl().Get();
        if (!URL.StartsWith("http://"))
        {
            URL = "http://" + URL;
            URL = URL.Split('?'.ToString().ToCharArray())[0];
        }
        DataTable dt = new DAL.Tables.T_Cps().Open("id, [ON], [Name]", "SiteID = " + _Site.ID.ToString() + " and DomainName = '" + URL + "' or DomainName='" + Shove._Web.Utility.GetUrl() + "'", "");

        if ((dt != null) && (dt.Rows.Count > 0))
        {
            if (Shove._Convert.StrToBool(dt.Rows[0]["ON"].ToString(), false))
            {
                CpsID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1);
            }
        }

        string Password = GetRandPassword();

        Users user = new Users(site.ID);

        user.Name = tbName.Text.Trim();
        user.RealityName = tbRealityName.Text.Trim();
        user.Password = Password;
        user.PasswordAdv = Password;
        user.CityID = 1;
        user.Email = labAccount.Text.Trim();
        user.ComeFrom = 4;
        user.UserType = 2;
        user.CpsID = CpsID;
        user.CommenderID = -1;

        string ReturnDescription = "";

        if (user.Add(ref ReturnDescription) < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription + "用户添加失败");

            return;
        }

        DAL.Tables.T_Users T_Users = new DAL.Tables.T_Users();
        T_Users.AlipayName.Value = labAccount.Text;
        T_Users.AlipayID.Value = hidUserID.Value;
        T_Users.isAlipayNameValided.Value = true;
        T_Users.Update("[ID] = " + user.ID.ToString());

        user.LoginDirect(ref ReturnDescription);

        this.Response.Redirect("UserRegSuccess.aspx", true);
    }
        public Users FindAll(int buId, int userId)
        {
            MySqlCommand.CommandType = CommandType.StoredProcedure;
            MySqlCommand.CommandText = FindAllStoredProcedure;
            MySqlCommand.Parameters.Clear();
            MySqlCommand.Parameters.AddWithValue("buid", userId);
            MySqlCommand.Parameters.AddWithValue("userid", userId);
            MySqlCommand.Parameters.Add(new MySqlParameter("@result", MySqlDbType.Int32));
            MySqlCommand.Parameters["@result"].Direction = ParameterDirection.Output;
            MySqlDataAdapter.SelectCommand = MySqlCommand;
            MySqlDataAdapter.Fill(UserDataSet);

            //Now lets return buis
            var users = new Users();
            DataTable dataTable = UserDataSet.Tables[0]; // Only 1 table

            for (var i = 0; i < dataTable.Rows.Count; i++)
            {
                #region Add to list
                users.Add(new User
                {
                    BuId =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)UserTableDefinition.BuId].ToString())
                    },
                    UserId =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)UserTableDefinition.UserId].ToString())
                    },
                    UserName =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.UserName].ToString())
                    },
                    Password =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Password].ToString())
                    },
                    Status =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Status].ToString())
                    },
                    JobTitle =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.JobTitle].ToString())
                    },
                    FirstName =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.FirstName].ToString())
                    },
                    MiddleName =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.MiddleName].ToString())
                    },
                    LastName =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.LastName].ToString())
                    },
                    DateOfBirth =
                    {
                        DataValue = DateTime.Parse((dataTable.Rows[i][(int)UserTableDefinition.DateOfBirth].ToString()))
                    },
                    EmailAddress =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.EmailAddress].ToString())
                    },
                    ContactNum1 =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.ContactNum1].ToString())
                    },
                    ContactNum2 =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.ContactNum2].ToString())
                    },
                    ContactNum3 =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.ContactNum3].ToString())
                    },
                    Address1 =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Address1].ToString())
                    },
                    Address2 =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Address2].ToString())
                    },
                    Address3 =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Address3].ToString())
                    },
                    Parish =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Parish].ToString())
                    },
                    Gender =
                    {
                        DataValue = (dataTable.Rows[i][(int)UserTableDefinition.Gender].ToString())
                    },
                    PhotoPath =
                    {
                        DataValue = GetAbsoluteFilePath(dataTable.Rows[i][(int)UserTableDefinition.PhotoPath].ToString())
                    },
                    CreatedAt =
                    {
                        DataValue = DateTime.Parse(dataTable.Rows[i][(int)UserTableDefinition.CreatedAt].ToString())
                    },
                    CreatedBy =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)UserTableDefinition.CreatedBy].ToString())
                    },
                    UpdatedAt =
                    {
                        DataValue = DateTime.Parse(dataTable.Rows[i][(int)UserTableDefinition.UpdatedAt].ToString())
                    },
                    UpdatedBy =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)UserTableDefinition.UpdatedBy].ToString())
                    }
                });
                #endregion

            }
            return users;
        }
 public async Task <bool> AddUser(User user)
 {
     Users.Add(user);
     return(await SaveChangesAsync() != 0);
 }
예제 #17
0
        protected Database()
        {
            User user1 = new User("Tom", "password");
            User user2 = new User("Alex", "password");
            User user3 = new User("Lisa", "password");
            User user4 = new User("Mario", "password");
            User user5 = new User("Lucia", "password");

            Users.Add(user1.UserName, user1);
            Users.Add(user2.UserName, user2);
            Users.Add(user3.UserName, user3);
            Users.Add(user4.UserName, user4);
            Users.Add(user5.UserName, user5);

            Location route1 = new Location("Ostpark, Munich", 48.112242, 11.630701, 5);
            Location route2 = new Location("Parco di Villa Borghese, Rome", 41.914614, 12.481987, 6);
            Location route3 = new Location("Parco degli Acquedotti, Rome", 41.853406, 12.557115, 10);
            Location route4 = new Location("Englischer Garten, Munich", 48.164334, 11.605598, 8);
            Location route5 = new Location("Parco Sempione, Milan", 45.474371, 9.171659, 4);

            RunningLocations.Add(route1.RouteName, route1);
            RunningLocations.Add(route2.RouteName, route2);
            RunningLocations.Add(route3.RouteName, route3);
            RunningLocations.Add(route4.RouteName, route4);
            RunningLocations.Add(route5.RouteName, route5);

            Event jogging1 = new InPersonEvent(new DateTime(2020, 08, 01, 08, 30, 00),
                                               11.0, "Jogging in the park", route3);
            Event jogging2 = new InPersonEvent(new DateTime(2020, 08, 09, 19, 00, 00),
                                               11.5, "After work jogging", route5);
            Event jogging3 = new VirtualEvent(new DateTime(2020, 8, 21, 09, 00, 00),
                                              10.0, "Jogging as a virtual group", 7.0);
            Event jogging4 = new InPersonEvent(new DateTime(2020, 06, 01, 10, 00, 00),
                                               12.0, "Morning jogging on 1st June", route1);
            Event jogging5 = new VirtualEvent(new DateTime(2020, 7, 28, 19, 00, 00),
                                              11.5, "Jogging in different locations", 5.0);
            Event jogging6 = new InPersonEvent(new DateTime(2020, 5, 15, 11, 00, 00),
                                               10.0, "Speed challenge", route5);
            Event jogging7 = new VirtualEvent(new DateTime(2020, 7, 31, 18, 30, 00),
                                              13.0, "Evening jogging", 5.0);


            Events.Add(jogging1.EventTitle, jogging1);
            Events.Add(jogging2.EventTitle, jogging2);
            Events.Add(jogging3.EventTitle, jogging3);
            Events.Add(jogging4.EventTitle, jogging4);
            Events.Add(jogging5.EventTitle, jogging5);
            Events.Add(jogging6.EventTitle, jogging6);
            Events.Add(jogging7.EventTitle, jogging7);

            Participant part1  = new Participant(user1, jogging1);
            Participant part2  = new Participant(user1, jogging3);
            Participant part3  = new Participant(user1, jogging4);
            Participant part4  = new Participant(user2, jogging4);
            Participant part5  = new Participant(user3, jogging4);
            Participant part6  = new Participant(user4, jogging4);
            Participant part7  = new Participant(user1, jogging5);
            Participant part8  = new Participant(user1, jogging6);
            Participant part9  = new Participant(user2, jogging6);
            Participant part10 = new Participant(user4, jogging6);

            part7.SetRunningLocation(route4);
            part8.SetRunningLocation(route2);

            part3.CheckInAtEvent();
            part4.CheckInAtEvent();
            part5.CheckInAtEvent();
            part6.CheckInAtEvent();
            part8.CheckInAtEvent();
            part9.CheckInAtEvent();
            part10.CheckInAtEvent();

            EventResults results1 = part3.UploadEventResults(TimeSpan.Parse("00:32:15", CultureInfo.InvariantCulture), 10.5, 166);
            EventResults results2 = part4.UploadEventResults(TimeSpan.Parse("00:31:09", CultureInfo.InvariantCulture), null, 170);
            EventResults results3 = part5.UploadEventResults(TimeSpan.Parse("00:34:38", CultureInfo.InvariantCulture), 9.8, null);
            EventResults results4 = part6.UploadEventResults(TimeSpan.Parse("00:35:00", CultureInfo.InvariantCulture), null, null);

            UserGroup group1 = new UserGroup(user1, "Munich Joggers");
            UserGroup group2 = new UserGroup(user2, "Milan Joggers");
            UserGroup group3 = new UserGroup(user3, "City joggers");

            UserGroups.Add(group1.GroupName, group1);
            UserGroups.Add(group2.GroupName, group2);
            UserGroups.Add(group3.GroupName, group3);

            group1.AddMember(user3);
            group1.AddMember(user4);
            group2.AddMember(user4);
            group2.AddMember(user5);
            group3.AddMember(user1);
        }
예제 #18
0
 protected void btnOK_Click(object sender, EventArgs e)
 {
     if (this.tbName.Text.Trim() == "")
     {
         JavaScript.Alert(this.Page, "请输入用户名。");
     }
     else if (this.tbPassword.Text == "")
     {
         JavaScript.Alert(this.Page, "请输入用户密码。");
     }
     else if (this.tbPassword.Text.Length < 6)
     {
         JavaScript.Alert(this.Page, "用户密码长度不足 6 位。");
     }
     else if (this.tbPassword.Text != this.tbPassword2.Text)
     {
         JavaScript.Alert(this.Page, "输入的两次密码不一致。");
     }
     else
     {
         if (this.CheckCode.Visible)
         {
             if (this.tbCheckCode.Text.Trim() == "")
             {
                 JavaScript.Alert(this.Page, "请输入验证码!");
                 return;
             }
             if (!this.ShoveCheckCode1.Valid(this.tbCheckCode.Text.Trim()))
             {
                 JavaScript.Alert(this.Page, "验证码输入有误!");
                 return;
             }
         }
         Thread.Sleep(500);
         Sites sites = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()];
         if (sites != null)
         {
             long num = -1L;
             string str = new FirstUrl().Get();
             if (!str.StartsWith("http://"))
             {
                 char ch = '?';
                 str = ("http://" + str).Split(ch.ToString().ToCharArray())[0];
             }
             DataTable table = new Tables.T_Cps().Open("id, [ON], [Name]", "SiteID = " + base._Site.ID.ToString() + " and DomainName = '" + str + "' or DomainName='" + Shove._Web.Utility.GetUrl() + "'", "");
             if (((table != null) && (table.Rows.Count > 0)) && _Convert.StrToBool(table.Rows[0]["ON"].ToString(), false))
             {
                 num = _Convert.StrToLong(table.Rows[0]["ID"].ToString(), -1L);
             }
             string str2 = Shove._Web.Utility.GetRequest("real_name").Trim();
             Users users = new Users(sites.ID)
             {
                 Name = this.tbName.Text.Trim(),
                 RealityName = str2,
                 Password = this.tbPassword.Text.Trim(),
                 PasswordAdv = this.tbPassword.Text.Trim(),
                 CityID = 1,
                 Email = this.labAccount.Text.Trim(),
                 ComeFrom = 4,
                 UserType = 2,
                 CpsID = num,
                 CommenderID = -1L
             };
             string returnDescription = "";
             if (users.Add(ref returnDescription) < 0)
             {
                 JavaScript.Alert(this.Page, returnDescription + "用户添加失败");
             }
             else
             {
                 Member member = new Member();
                 string realityName = "";
                 long num2 = member.Query(this.labAccount.Text, ref realityName);
                 if (num2 < 0L)
                 {
                     JavaScript.Alert(this.Page, "输入的账号在支付宝网站验证失败(不存在账号或者网络通讯故障," + num2.ToString() + "),请重新填写一个账号名称。");
                 }
                 else
                 {
                     new Tables.T_Users { AlipayID = { Value = this.tbAlipayID.Text }, AlipayName = { Value = this.labAccount.Text }, isAlipayNameValided = { Value = true } }.Update("[ID] = " + users.ID.ToString());
                     users.LoginDirect(ref returnDescription);
                     long buyID = -1L;
                     if ((base.Request.Url.AbsoluteUri.IndexOf("?BuyID") > 0) && (base.Request.Url.AbsoluteUri.IndexOf("&") > 0))
                     {
                         buyID = _Convert.StrToLong(HttpUtility.UrlDecode(base.Request.Url.AbsoluteUri).Split(new char[] { '?' })[1].Split(new char[] { '&' })[0].Replace("BuyID=", ""), -1L);
                     }
                     if (buyID > 0L)
                     {
                         this.GoBuy(buyID);
                     }
                     else
                     {
                         base.Response.Redirect("UserRegSuccess.aspx", true);
                     }
                 }
             }
         }
     }
 }
        private void DataFetcherOnDoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Context.Send(s =>
                {
                    // Save current settings
                    ConfigManager.Save(ConfigData);

                    // Get everything ready
                    StatusText = "Fetching users...";
                    Users.Clear();
                    TotalUsers    = 0;
                    MatchingUsers = 0;
                    FetchProgress = 0;
                }, null);

                // Stop caching
                if (_userConfigurationList.IsCaching)
                {
                    _userConfigurationList.StopCaching();
                }

                // Build query
                var query = _userConfigurationList.CreateQuerySettings();
                query.SetRightsFilterToAdmin();
                query.SetPropertiesToRetrieve(UserConfiguration.Property.Id, UserConfiguration.Property.NtDomainUser);

                // Get results
                _userConfigurationList.StartCaching(query);
                var users = _userConfigurationList.GetConfigurationList();

                // Update count
                Context.Send(s =>
                {
                    TotalUsers = users.Count;
                    StatusText = "Evaluating " + users.Count + " users...";
                }, null);

                // Make UI elements
                for (int i = 0; i < users.Count; i++)
                {
                    var user = users[i];

                    if (user.NtDomainUser.Value != null &&
                        user.NtDomainUser.Value.StartsWith(ConfigData.ExistingDomain + "\\",
                                                           StringComparison.InvariantCultureIgnoreCase))
                    {
                        Context.Send(s =>
                        {
                            try
                            {
                                var newUser         = new UserViewModel(user);
                                newUser.NewDomainId = ConfigData.NewDomain +
                                                      newUser.OldDomainId.Substring(ConfigData.ExistingDomain.Length);
                                Users.Add(newUser);

                                // Update count
                                MatchingUsers = Users.Count;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, "Error",
                                                MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }, null);
                    }

                    // Update progress
                    Context.Send(s => FetchProgress = (int)(((double)i / (double)users.Count) * 100), null);
                }

                Context.Send(s => StatusText = "Fetch complete.", null);

                // Run processor?
                if (e.Argument != null &&
                    e.Argument.ToString().Equals("process", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (!_processor.IsBusy)
                    {
                        _processor.RunWorkerAsync();
                    }

                    return;
                }
                else
                {
                    _userConfigurationList.StopCaching();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private Users CreateUsers(Game currentGame)
        {
            // Испытуемый
            var person = GameObjects["person"] as Person;

            if (person == null) throw new NullReferenceException("person");

            var users = new Users();

            foreach (var userInfo in currentGame.Users)
            {
                var user = new User
                               {
                                   CurrentGame = currentGame.Title,
                                   UserInfo = userInfo,
                                   TotalScore = userInfo.Score
                               };

                if (userInfo.UserType == UserTypeEnum.User)
                {
                    user.Person = person;
                }

                users.Add(user);
            }

            return users;

            //GameObjects["users"] = users;
        }
예제 #21
0
 public void AddUser(User user)
 {
     Users.Add(user);
 }
예제 #22
0
    protected void btnReg_Click(object sender, EventArgs e)
    {
        //检查输入
        string inputErrorInfo = "";
        if (!PF.CheckUserName(tbUserName.Text))
        {
            inputErrorInfo += "对不起用户名中含有禁止使用的字符.\r\n";
        }

        if (Shove._String.GetLength(tbUserName.Text) < 5 || Shove._String.GetLength(tbUserName.Text) > 16)
        {
            inputErrorInfo += "用户名长度在 5-16 个英文字符或数字、中文 3-8 之间.\r\n";
        }

        if (tbPassword.Text.Length < 6 || tbPassword.Text.Length > 16)
        {
            inputErrorInfo += "密码长度必须在 6-16 位之间.\r\n";
        }

        if (tbSiteName.Text.Trim().Length ==0 )
        {
            inputErrorInfo += "网站名称不能为空.\r\n";
        }
        if (tbSiteURL.Text.Trim().Length == 0)
        {
            inputErrorInfo += "网站地址不能为空.\r\n";
        }

        if (!Shove._String.Valid.isEmail(tbEmail.Text))
        {
            inputErrorInfo += "电子邮件地址格式不正确.\r\n";
        }
        if (!ckbAgree.Checked)
        {
            inputErrorInfo += "必须同意本站会员注册协议才能注册会员。\r\n";
        }

        if (CheckCode2.Visible)
        {
            if (tbCheckCode.Text.Trim() == "")
            {
                inputErrorInfo += "请输入验证码!\n";
            }
            else
            {
                if (!ShoveCheckCode1.Valid(tbCheckCode.Text.Trim()))
                {
                    inputErrorInfo += "验证码输入有误!\n";
                }
            }

        }

        if (inputErrorInfo != "")
        {
            lblInputError.Visible = true;
            lblInputError.Text = "输入资料错误:\r\n" + inputErrorInfo;
            return;
        }

        long CpsID = -1;
        long CommenderID = -1;

        if (Session[KeyPromotionUserID] != null)
        {
            CommenderID = Shove._Convert.StrToLong(Session[KeyPromotionUserID].ToString(), -1);
        }


        //检查推荐人是否为CPS商家,是就把此会员标记CSPID
        object tempOjb = Shove.Database.MSSQL.ExecuteScalar("select ID from T_Cps where OwnerUserID=" + CommenderID, new Shove.Database.MSSQL.Parameter[0]);
        if (tempOjb != null)
        {
            CpsID = Shove._Convert.StrToLong(tempOjb.ToString(), -1);
        }

        System.Threading.Thread.Sleep(500);

        string Name = tbUserName.Text.Trim();
        string Password = tbPassword.Text.Trim();
        string Email = tbEmail.Text.Trim();
        string Mobile = tbTel.Text.Trim();
        string QQ = tbQQ.Text.Trim();


        Users user = new Users(_Site.ID);
        user.Name = Name;
        user.Password = Password;
        user.Email = Email;
        user.Mobile = Mobile;
        user.QQ = QQ;
        user.UserType = 2;


        if (CpsID > 0)//推荐人为cps商家就填CpsID字段
        {
            user.CommenderID = -1;
            user.CpsID = CpsID;
        }
        else
        {
            user.CommenderID = CommenderID;
            user.CpsID = -1;
        }

        string ReturnDescription = "";
        int Result = user.Add(ref ReturnDescription);

        if (Result < 0)
        {
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }
        else //注册成功,加入CPS站长商家
        {
            double cpsBonusScale = 0.00;
            DataTable dtTemp = new DAL.Tables.T_Sites().Open("Opt_CpsBonusScale", "", "");
            if (dtTemp != null && dtTemp.Rows.Count > 0)
                cpsBonusScale = double.Parse(dtTemp.Rows[0]["Opt_CpsBonusScale"].ToString());
            user.cps.SiteID = 1;
            user.cps.CommendID = CommenderID;

            user.cps.Name = tbSiteName.Text;
            user.cps.Url = tbSiteURL.Text;
            user.cps.BonusScale = cpsBonusScale;
            user.cps.ON = true;

            user.cps.Telephone = tbTel.Text.Trim();
            user.cps.Email = Email;
            user.cps.QQ = QQ;
            user.cps.Type = 2;
            user.cps.DomainName = user.GetPromotionURL(0);

            if (user.cps.Add(ref ReturnDescription) < 0)
            {
                Shove._Web.JavaScript.Alert(this, ReturnDescription);

                return;
            }
        }

        Result = user.Login(ref ReturnDescription);

        if (Result < 0)
        {
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }

        Response.Redirect("../../Default.aspx");

        
    }
예제 #23
0
 public virtual void AddUser(User newUser)
 {
     //newAddress.Schools.Add(this);
     Users.Add(newUser);
 }
예제 #24
0
    protected void btnReg_Click(object sender, EventArgs e)
    {
        if (CheckCodeReg.Visible)
        {
            if (tbRegCheckCode.Text.Trim() == "")
            {
                Shove._Web.JavaScript.Alert(this.Page, "请输入验证码!");

                return;
            }
        }

        long CpsID = -1;
        long CommenderID = -1;
        string Memo = "";
        FirstUrl firstUrl = new FirstUrl();
        string URL = firstUrl.Get();

        if (!URL.StartsWith("http://"))
        {
            URL = "http://" + URL;
            URL = URL.Split('?'.ToString().ToCharArray())[0];
        }

        DataTable dt = new DAL.Tables.T_Cps().Open("id, [ON], [Name]", "SiteID = " + _Site.ID.ToString() + " and( DomainName = '" + URL + "' or DomainName='" + Shove._Web.Utility.GetUrl() + "')", "");

        if (Shove._Convert.StrToLong(firstUrl.CpsID, -1) > 0) //读取第一次访问页面时保存的CPS ID
        {
            CpsID = Shove._Convert.StrToLong(firstUrl.CpsID, -1);
        }
        else if ((dt != null) && (dt.Rows.Count > 0))
        {
            CpsID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1);
            Memo = firstUrl.PID;//联盟商推广URL的PID
        }

        System.Threading.Thread.Sleep(500);

        string Name = tbRegUserName.Text.Trim();
        string Password = tbFormPassword.Text.Trim();
        string Password2 = tbPassword2.Text.Trim();
        string Email = tbEmail.Text.Trim();
        string RealityName = tbRealityName.Text.Trim();
        //string IDCardNumber = tbIDCardNumber.Text.Trim();

        Users user = new Users(_Site.ID);

        user.Name = Name;
        user.Password = Password;
        user.Email = Email;
        user.RealityName = RealityName;
        //user.IDCardNumber = IDCardNumber;
        user.UserType = 2;
        user.CommenderID = CommenderID;
        user.CpsID = CpsID;
        user.Memo = Memo;

        string ReturnDescription = "";
        int Result = user.Add(ref ReturnDescription);

        if (Result < 0)
        {
            new Log("Users").Write("会员注册不成功:" + ReturnDescription);
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }

        Result = user.Login(ref ReturnDescription);

        if (Result < 0)
        {
            new Log("Users").Write("注册成功后登录失败:" + ReturnDescription);
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }
        //if (this.ckbHomePage.Checked == true)
        //{
 
        //}
        Response.Redirect("Home/Room/UserRegSuccess.aspx");
    }
예제 #25
0
 protected void btnReg_Click(object sender, EventArgs e)
 {
     if (this.CheckCodeReg.Visible)
     {
         if (this.tbRegCheckCode.Text.Trim() == "")
         {
             JavaScript.Alert(this.Page, "请输入验证码!");
             return;
         }
         if (!this.ShoveCheckCode2.Valid(this.tbRegCheckCode.Text.Trim()))
         {
             JavaScript.Alert(this.Page, "验证码输入有误!");
             return;
         }
     }
     long num = -1L;
     long num2 = -1L;
     string pID = "";
     FirstUrl url = new FirstUrl();
     string str2 = url.Get();
     if (!str2.StartsWith("http://"))
     {
         char ch = '?';
         str2 = ("http://" + str2).Split(ch.ToString().ToCharArray())[0];
     }
     DataTable table = new Tables.T_Cps().Open("id, [ON], [Name]", "SiteID = " + base._Site.ID.ToString() + " and( DomainName = '" + str2 + "' or DomainName='" + Shove._Web.Utility.GetUrl() + "')", "");
     if (_Convert.StrToLong(url.CpsID, -1L) > 0L)
     {
         num = _Convert.StrToLong(url.CpsID, -1L);
     }
     else if ((table != null) && (table.Rows.Count > 0))
     {
         num = _Convert.StrToLong(table.Rows[0]["ID"].ToString(), -1L);
         pID = url.PID;
     }
     Thread.Sleep(500);
     string str3 = this.tbRegUserName.Text.Trim();
     string str4 = this.tbFormPassword.Text.Trim();
     this.tbPassword2.Text.Trim();
     string str5 = this.tbEmail.Text.Trim();
     string str6 = this.tbRealityName.Text.Trim();
     Users users = new Users(base._Site.ID)
     {
         Name = str3,
         Password = str4,
         Email = str5,
         RealityName = str6,
         UserType = 2,
         CommenderID = num2,
         CpsID = num,
         Memo = pID
     };
     string returnDescription = "";
     if (users.Add(ref returnDescription) < 0)
     {
         new Log("Users").Write("会员注册不成功:" + returnDescription);
         JavaScript.Alert(this, returnDescription);
     }
     else if (users.Login(ref returnDescription) < 0)
     {
         new Log("Users").Write("注册成功后登录失败:" + returnDescription);
         JavaScript.Alert(this, returnDescription);
     }
     else
     {
         base.Response.Redirect("UserRegSuccess.aspx");
     }
 }
예제 #26
0
파일: Task.cs 프로젝트: hotmike49/PM
 // Laden aller User die einem Task zugeordnet sind
 public Users loadTaskUsers()
 {
     SqlCommand cmd = new SqlCommand("select u.Username, u.Firstname, u.Lastname, u.Email from UserTask as ut inner join [User] as u on ut.Username = u.Username where TaskID = @tid", Main.GetConnection());
     cmd.Parameters.Add(new SqlParameter("tid", mID));
     SqlDataReader reader = cmd.ExecuteReader();
     Users taskUsers = new Users();
     while (reader.Read())
     {
         User u = new User();
         u.Username = reader.GetString(0);
         u.Firstname = reader.GetString(1);
         u.Lastname = reader.GetString(2);
         u.Email = reader.GetString(3);
         taskUsers.Add(u);
     }
     return taskUsers;
 }
예제 #27
0
    protected void btnReg_Click(object sender, EventArgs e)
    {
        if (tbRegCheckCode.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入验证码!");

            return;
        }

        string RegCode = tbRegCheckCode.Text.Trim().ToLower();

        if (Shove._Web.Cache.GetCacheAsString("CheckCode_" + Request.Cookies["ASP.NET_SessionId"].Value, "") != Shove._Security.Encrypt.MD5(PF.GetCallCert() + RegCode))
        {
            Shove._Web.JavaScript.Alert(this.Page, "验证码输入错误,请重新输入!");

            return;
        }

        long CpsID = -1;
        long CommenderID = -1;
        string Memo = "";

        FirstUrl firstUrl = new FirstUrl();
        string URL = firstUrl.Get();

        if (!URL.StartsWith("http://"))
        {
            URL = "http://" + URL;
            URL = URL.Split('?'.ToString().ToCharArray())[0];
        }

        DataTable dt = new DAL.Tables.T_Cps().Open("id, [ON], [Name]", "SiteID = " + _Site.ID.ToString() + " and( DomainName = '" + URL + "' or DomainName='" + Shove._Web.Utility.GetUrl() + "')", "");

        if (Shove._Convert.StrToLong(firstUrl.CpsID, -1) > 0) //读取第一次访问页面时保存的CPS ID
        {
            CpsID = Shove._Convert.StrToLong(firstUrl.CpsID, -1);
        }
        else if ((dt != null) && (dt.Rows.Count > 0))
        {
            CpsID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1);
            Memo = firstUrl.PID;//联盟商推广URL的PID
        }

        System.Threading.Thread.Sleep(500);

        string Name = TBUserName.Text.Trim();
        string Password = TBPwdOne.Text.Trim();
        string Password2 = TBPwdTwo.Text.Trim();
        string Email = TBUserMail.Text.Trim();
        string RealityName = tbRealityName.Text.Trim();
        string Mobile = TBMobile.Text.Trim();

        Users user = new Users(_Site.ID);

        user.Name = Name;
        user.Password = Password;
        user.Email = Email;
        user.RealityName = RealityName;
        user.UserType = 2;
        user.Mobile = Mobile;

        if (!string.IsNullOrEmpty(hidCity.Value))
        {
            DataTable dtCity = new DAL.Views.V_Citys().Open("ID", "City='" + hidCity.Value.Substring(0, hidCity.Value.Length - 1) + "'", "");

            if (dtCity != null && dtCity.Rows.Count == 1)
            {
                user.CityID = Shove._Convert.StrToInt(dtCity.Rows[0]["ID"].ToString(), 1);
            }
        }

        dt = new DAL.Tables.T_Users().Open("", "id=" + Shove._Web.Utility.GetRequest("CID") + " and Name='" + Shove._Web.Utility.GetRequest("CN") + "'", "");

        if ((dt != null) && (dt.Rows.Count == 1))
        {
            CommenderID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("CID"), -1);
        }

        user.CommenderID = CommenderID;
        user.CpsID = CpsID;
        user.Memo = Memo;

        string ReturnDescription = "";
        int Result = user.Add(ref ReturnDescription);

        if (Result < 0)
        {
            new Log("Users").Write("会员注册不成功:" + ReturnDescription);
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }

        Result = user.Login(ref ReturnDescription);

        if (Result < 0)
        {
            new Log("Users").Write("注册成功后登录失败:" + ReturnDescription);
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }
     
        Response.Redirect("Home/Room/UserRegSuccess.aspx");
    }
예제 #28
0
    protected void cmd_Save_Click(object sender, EventArgs e)
    {
        if (!CheckExistText(txt_UserName))
        {
            ShowPageMsg("請輸入使用者姓名");
            return;
        }
        if (!CheckExistText(txt_User_ID))
        {
            ShowPageMsg("請輸入使用者代號");
            return;
        }
        if (_operator == null)
        {
            _operator = new UserRole();
        }
        Security sec = new Security();
        Users user = new Users();
        bool suc = true;
        try
        {
                user.User_ID = this.txt_User_ID.Text.Trim();
                user.User_Name = this.txt_UserName.Text;
                if (txt_Password.Text.Length > 0)
                    user.User_Password = user.GetEncryptPassword(this.txt_Password.Text.Trim());
                user.Create_Time = DateTime.Now;
                //if (ddl_department.SelectedValue != "-1")
                //{
                //    user.DepartmentID = Convert.ToInt32(ddl_department.SelectedValue);
                //}
                user.Phone = txt_tel.Text;
                user.Email = txt_email.Text;
                user.Status = chk_Status.Checked;
                user.Expire_Time = DateTime.Now;
                user.Update_Time = DateTime.Now;

            if (this.hidden_Action.Value.Equals("add"))
            {
                //新增User
                if (user.Add())
                {
                    
                    sec.SaveLog(this.txt_User_ID.Text.Trim(), "add user", "AuthManage", "success", Session["LoginStaffID"].ToString());
                }
                else
                {
                    suc = false;
                    sec.SaveLog(this.txt_User_ID.Text.Trim(), "add user", "AuthManage", "fault", Session["LoginStaffID"].ToString());
                }

                //新增User Role
                string role = "";
                for (int i = 0; i < this.gv.Rows.Count; i++)
                {
                    CheckBox chk = (CheckBox)this.gv.Rows[i].Cells[0].Controls[1];
                    if (chk.Checked)
                    {
                        _operator.User_ID = this.txt_User_ID.Text.Trim();
                        _operator.Role_ID = this.gv.Rows[i].Cells[1].Text.Trim();
                        suc &= _operator.AddUserRole();
                        role += _operator.Role_ID + ",";
                    }
                }
                sec.SaveLog(this.txt_User_ID.Text.Trim(), "add userrole", "AuthManage", "role[" + role.TrimEnd(',') + "]", Session["LoginStaffID"].ToString());
            }
            else
            {
                //儲存User Role
                _operator.DeleteUserRole(this.hidden_ID.Value);
                string role = "";
                for (int i = 0; i < this.gv.Rows.Count; i++)
                {
                    CheckBox chk = (CheckBox)this.gv.Rows[i].Cells[0].Controls[1];
                    if (chk.Checked)
                    {
                        _operator.User_ID = this.hidden_ID.Value;
                        _operator.Role_ID = this.gv.Rows[i].Cells[1].Text.Trim();
                        suc &= _operator.AddUserRole();
                        role += _operator.Role_ID + ",";
                    }
                }
                sec.SaveLog(this.hidden_ID.Value, "save userrole", "AuthManage", "role[" + role.TrimEnd(',') + "]", Session["LoginStaffID"].ToString());

                //儲存狀態
                switch (this.chk_Status.Checked)
                {
                    case true:
                        user.SaveStatus(this.hidden_ID.Value, "1");
                        break;
                    case false:
                        user.SaveStatus(this.hidden_ID.Value, "0");
                        break;
                    default:
                        break;
                }
                suc = user.EditUser(user);
                
                
                sec.SaveLog(this.hidden_ID.Value, "save status", "AuthManage", "status[" + this.chk_Status.Checked + "]", Session["LoginStaffID"].ToString());
            }

            if (suc)
            {
                ShowMsgAndRedirect(UpdatePanel1, "修改成功", "AuthList.aspx");
                //ShowPageMsg("儲存成功");
            }
            else
            {
                ShowMsgAndRedirect(UpdatePanel1, "儲存失敗", "AuthList.aspx");
                //ShowPageMsg("儲存失敗");
            }
        }
        catch (Exception ex)
        {
            ShowMsgAndRedirect(UpdatePanel1, "儲存失敗", "AuthList.aspx");
        }
    }
예제 #29
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (tbName.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入用户名。");

            return;
        }

        if (tbPassword.Text == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入用户密码。");

            return;
        }

        if (tbPassword.Text.Length < 6)
        {
            Shove._Web.JavaScript.Alert(this.Page, "用户密码长度不足 6 位。");

            return;
        }

        if (tbPassword.Text != tbPassword2.Text)
        {
            Shove._Web.JavaScript.Alert(this.Page, "输入的两次密码不一致。");

            return;
        }

        System.Threading.Thread.Sleep(500);

        Sites site = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()];

        if (site == null)
        {
            return;
        }

        string RealityName = Shove._Web.Utility.GetRequest("real_name").Trim();

        Users user = new Users(site.ID);

        user.Name        = tbName.Text.Trim();
        user.RealityName = RealityName;
        user.Password    = tbPassword.Text.Trim();
        user.PasswordAdv = tbPassword.Text.Trim();
        user.CityID      = 1;
        user.Email       = labAccount.Text.Trim();
        user.UserType    = 1;
        user.CommenderID = -1;

        string ReturnDescription = "";

        if (user.Add(ref ReturnDescription) < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription + "用户添加失败");

            return;
        }

        Alipay.Gateway.Member member = new Alipay.Gateway.Member();

        DAL.Tables.T_Users T_Users = new DAL.Tables.T_Users();
        T_Users.AlipayID.Value            = tbAlipayID.Text;
        T_Users.AlipayName.Value          = labAccount.Text;
        T_Users.isAlipayNameValided.Value = true;
        T_Users.Update("[ID] = " + user.ID.ToString());

        user.LoginDirect(ref ReturnDescription);

        this.Response.Redirect("../../Index.aspx", true);
    }
 public Users FindAll(int buid, int userId)
 {
     #region FindAll
     var users = new Users();
     for (var i = 0; i < 10; i++)
     {
         users.Add(new User
         {
             BuId =
             {
                 DataValue = i
             },
             UserId =
             {
                 DataValue = i
             },
             UserName =
             {
                 DataValue = String.Format("UserName_{0}", i)
             },
             Password =
             {
                 DataValue = String.Format("Password_{0}", i)
             },
             Status =
             {
                 DataValue = Status.Active
             },
             JobTitle =
             {
                 DataValue = String.Format("JobTitle_{0}", i)
             },
             FirstName =
             {
                 DataValue = String.Format("FirstName_{0}", i)
             },
             MiddleName =
             {
                 DataValue = String.Format("MiddleName_{0}", i)
             },
             LastName =
             {
                 DataValue = String.Format("LastName_{0}", i)
             },
             DateOfBirth =
             {
                 DataValue = DateTime.Now
             },
             EmailAddress =
             {
                 DataValue = String.Format("emailaddress{0}@gmail.com", i)
             },
             ContactNum1 =
             {
                 DataValue = String.Format("1876443000{0}", i)
             },
             ContactNum2 =
             {
                 DataValue = String.Format("1876443000{0}", i)
             },
             ContactNum3 =
             {
                 DataValue = String.Format("1876443000{0}", i)
             },
             Address1 =
             {
                 DataValue = String.Format("MyAddress1_{0}", i)
             },
             Address2 =
             {
                 DataValue = String.Format("MyAddress2_{0}", i)
             },
             Address3 =
             {
                 DataValue = String.Format("MyAddress3_{0}", i)
             },
             Parish =
             {
                 DataValue = String.Format("Parish_{0}", i)
             },
             Gender =
             {
                 DataValue = Gender.Male
             },
             PhotoPath =
             {
                 DataValue = new Uri(String.Format("../UsersImage/{0}", i), UriKind.Relative).AbsolutePath
             },
             CreatedAt =
             {
                 DataValue = DateTime.Now
             },
             CreatedBy =
             {
                 DataValue = i
             },
             UpdatedAt =
             {
                 DataValue = DateTime.Now
             },
             UpdatedBy =
             {
                 DataValue = i
             }
         });
     }
     return users;
     #endregion
 }
 public void SaveUser(User user)
 {
     Users.Add(user);
     SerializeUsers();
 }
 protected void btnOK_Click(object sender, EventArgs e)
 {
     if (this.tbName.Text.Trim() == "")
     {
         JavaScript.Alert(this.Page, "请输入用户名。");
     }
     else if (this.tbTrueName.Text.Trim() == "")
     {
         JavaScript.Alert(this.Page, "请输入真实姓名。");
     }
     else if (this.tbPassword.Text == "")
     {
         JavaScript.Alert(this.Page, "请输入用户密码。");
     }
     else if (this.tbPassword.Text.Length < 6)
     {
         JavaScript.Alert(this.Page, "用户密码长度不足 6 位。");
     }
     else if (this.tbPassword.Text != this.tbPassword2.Text)
     {
         JavaScript.Alert(this.Page, "输入的两次密码不一致。");
     }
     else if (this.tbEmail.Text.Trim() == "")
     {
         JavaScript.Alert(this.Page, "请输入您的邮箱。");
     }
     else if (!_String.Valid.isEmail(this.tbEmail.Text.Trim()))
     {
         JavaScript.Alert(this.Page, "请正确输入您的邮箱。");
     }
     else
     {
         if (this.CheckCode.Visible)
         {
             if (this.tbCheckCode.Text.Trim() == "")
             {
                 JavaScript.Alert(this.Page, "请输入验证码!");
                 return;
             }
             if (!this.ShoveCheckCode1.Valid(this.tbCheckCode.Text.Trim()))
             {
                 JavaScript.Alert(this.Page, "验证码输入有误!");
                 return;
             }
         }
         Thread.Sleep(500);
         Sites sites = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()];
         if (sites != null)
         {
             Users users = new Users(sites.ID)
             {
                 Name = Shove._Web.Utility.FilteSqlInfusion(this.tbName.Text.Trim()),
                 RealityName = Shove._Web.Utility.FilteSqlInfusion(this.tbTrueName.Text.Trim()),
                 Password = Shove._Web.Utility.FilteSqlInfusion(this.tbPassword.Text.Trim()),
                 PasswordAdv = Shove._Web.Utility.FilteSqlInfusion(this.tbPassword.Text.Trim()),
                 CityID = 1,
                 ComeFrom = 4,
                 Email = Shove._Web.Utility.FilteSqlInfusion(this.tbEmail.Text.Trim()),
                 isEmailValided = true,
                 QQ = this.tbQQID.Text.Trim(),
                 UserType = 2,
                 CommenderID = -1L,
                 isQQValided = true
             };
             string returnDescription = "";
             if (users.Add(ref returnDescription) < 0)
             {
                 JavaScript.Alert(this.Page, returnDescription + "用户添加失败");
             }
             else if (users.Login(ref returnDescription) < 0)
             {
                 new Log("Users").Write("注册成功后登录失败:" + returnDescription);
                 JavaScript.Alert(this, returnDescription);
             }
             else
             {
                 base.Response.Redirect("UserRegSuccess.aspx", true);
             }
         }
     }
 }
예제 #33
0
        private async Task Save(string mode)
        {
            if (User == null)
            {
                User = new User
                {
                    Username   = NewUsername,
                    Password   = NewPassword,
                    Savings    = NewSavings,
                    UpdateDate = Convert.ToDateTime(Globals.phoneDate),
                    isNotify   = IsNotify
                };
            }
            if (SelectedUser != null)
            {
                if (SelectedUser.Password != NewPassword || SelectedUser.UserName != NewUsername || SelectedUser.Savings != NewSavings || SelectedUser.IsNotify != IsNotify)
                {
                    User.Savings    = NewSavings;
                    User.Password   = NewPassword;
                    User.Username   = NewUsername;
                    User.UpdateDate = Convert.ToDateTime(Globals.phoneDate);
                    User.isNotify   = IsNotify;
                }
            }
            if (string.IsNullOrWhiteSpace(NewUsername) || string.IsNullOrWhiteSpace(NewPassword) || NewSavings == 0)
            {
                await _pageService.DisplayAlert("ERROR", "Please complete user details", "OK");

                //ErrorMessage = "Registration Failed : Please complete the username, password and savings";
                return;
            }
            if (IsNotify == false)
            {
                if (await _pageService.DisplayAlert("Warning", "You are about to save a user without turning on the notification setting, are you sure you want to continue?", "YES", "NO"))
                {
                    goto PostDetails;
                }
                else
                {
                    return;
                }
            }
PostDetails:
            if (User.Id == 0)
            {
                if (mode == "setting")
                {
                    ErrorMessage = "Registration is not allowed in settings mode.";
                    goto ResetDetails;
                }
                else
                {
                    await _sqlUser.AddUser(User);

                    Users.Add(new UserViewModel(User));
                    ErrorMessage = "Registration Successful: " + $"User {User.Username} is added.";
                    MessagingCenter.Send(this, Events.UserAdded, User);
                }
            }
            else
            {
                await _sqlUser.UpdateUser(User);

                var UserInList = Users.Single(c => c.Id == User.Id);

                UserInList.Id         = User.Id;
                UserInList.UserName   = User.Username;
                UserInList.Password   = User.Password;
                UserInList.Savings    = User.Savings;
                UserInList.UpdateDate = User.UpdateDate;
                UserInList.IsNotify   = User.isNotify;

                if (Globals.currentUser.Id == User.Id)
                {
                    Globals.currentUser.Id       = User.Id;
                    Globals.currentUser.Savings  = User.Savings;
                    Globals.currentUser.Username = User.Username;
                    Globals.currentUser.isNotify = User.isNotify;
                }
                if (User.isNotify == false)
                {
                    DeactivateNotification();
                }
                ErrorMessage = "Update Successful: " + $"User {User.Username} is updated.";
                MessagingCenter.Send(this, Events.UserUpdated, User);
            }


ResetDetails:
            SelectedUser = null;
            User         = null;
            NewUsername  = null;
            NewPassword  = null;
            NewSavings   = 0;
            IsNotify     = false;
            //await _pageService.PopAsync();
        }
예제 #34
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!CheckInput())
        {
            return;
        }

        string url = tbUrl.Text;

        if (!url.StartsWith("http://"))
        {
            url = "http://" + url;
        }

        Regex regex = new Regex(@"^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        Match m = regex.Match(url);

        if (!m.Success)
        {
            Shove._Web.JavaScript.Alert(this.Page, "网址填写错误");

            return;
        }

        if(!Shove._String.Valid.isMobile(tbMobile.Text.Trim()))
        {
            Shove._Web.JavaScript.Alert(this.Page, "手机号码填写错误");

            return;
        }

        if (!Shove._String.Valid.isEmail(tbEmail.Text.Trim()))
        {
            Shove._Web.JavaScript.Alert(this.Page, "Email填写错误");

            return;
        }

        string urlName = tbUrlName.Text;
        string contactPerson = tbContactPerson.Text;
        string telephone = tbPhone.Text;
        string mobile = tbMobile.Text;
        string qq = tbQQNum.Text;
        string email = tbEmail.Text;
        long parentID = _User.cps.ID;

        string ReturnDescription = "";

        Users user = new Users(_Site.ID);

        user.Name = tbUserName.Text;
        user.Password = tbPassword.Text;
        user.RealityName = contactPerson;
        user.Email = email;
        user.QQ = qq;
        user.Telephone = telephone;
        user.Mobile = mobile;
        user.CpsID = parentID;
        user.UserType = 2;

        if (user.Add(ref ReturnDescription) < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription);

            return;
        }
        else
        {
            user.cps.DomainName = "";
            user.cps.Url = url;
            user.cps.Type = 1;
            user.cps.Name = urlName;
            user.cps.ContactPerson = contactPerson;
            user.cps.Telephone = telephone;
            user.cps.Mobile = mobile;
            user.cps.QQ = qq;
            user.cps.Email = email;
            user.cps.ParentID = parentID;
            user.cps.BonusScale = 0.02;
            user.cps.ON = true;

            long newCpsID = user.cps.Add(ref ReturnDescription);
            if (newCpsID < 0)
            {
                Shove._Web.JavaScript.Alert(this.Page, ReturnDescription);

                return;
            }

            //设置推广链接
            user.cps.DomainName = Shove._Web.Utility.GetUrl() + "/Default.aspx?cpsid=" + newCpsID.ToString();
            
            if (user.cps.EditByID(ref ReturnDescription) < 0)
            {
                Shove._Web.JavaScript.Alert(this.Page, ReturnDescription);

                return;
            }
        }

        Shove._Web.Cache.ClearCache("CPS_Admin_PromoterList" + _User.cps.ID.ToString());

        Response.Redirect("PromoterList.aspx");
    }
예제 #35
0
파일: OmbiContext.cs 프로젝트: sonicos/Ombi
        public void Seed()
        {
            // Add the tokens
            var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);

            if (fanArt == null)
            {
                ApplicationConfigurations.Add(new ApplicationConfiguration
                {
                    Type  = ConfigurationTypes.FanartTv,
                    Value = "4b6d983efa54d8f45c68432521335f15"
                });
                SaveChanges();
            }
            var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);

            if (movieDb == null)
            {
                ApplicationConfigurations.Add(new ApplicationConfiguration
                {
                    Type  = ConfigurationTypes.TheMovieDb,
                    Value = "b8eabaf5608b88d0298aa189dd90bf00"
                });
                SaveChanges();
            }
            var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);

            if (notification == null)
            {
                ApplicationConfigurations.Add(new ApplicationConfiguration
                {
                    Type  = ConfigurationTypes.Notification,
                    Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
                });
                SaveChanges();
            }

            // VACUUM;
            Database.ExecuteSqlCommand("VACUUM;");

            // Make sure we have the roles
            var roles = Roles.Where(x => x.Name == OmbiRoles.RecievesNewsletter);

            if (!roles.Any())
            {
                Roles.Add(new IdentityRole(OmbiRoles.RecievesNewsletter)
                {
                    NormalizedName = OmbiRoles.RecievesNewsletter.ToUpper()
                });
                SaveChanges();
            }

            // Make sure we have the API User
            var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase));

            if (!apiUserExists)
            {
                Users.Add(new OmbiUser
                {
                    UserName           = "******",
                    UserType           = UserType.SystemUser,
                    NormalizedUserName = "******",
                });
                SaveChanges();
            }

            //Check if templates exist
            var templates = NotificationTemplates.ToList();

            var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast <NotificationAgent>().ToList();
            var allTypes  = Enum.GetValues(typeof(NotificationType)).Cast <NotificationType>().ToList();

            foreach (var agent in allAgents)
            {
                foreach (var notificationType in allTypes)
                {
                    if (templates.Any(x => x.Agent == agent && x.NotificationType == notificationType))
                    {
                        // We already have this
                        continue;
                    }
                    NotificationTemplates notificationToAdd;
                    switch (notificationType)
                    {
                    case NotificationType.NewRequest:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! The user '{UserName}' has requested the {Type} '{Title}'! Please log in to approve this request. Request Date: {RequestedDate}",
                            Subject          = "{ApplicationName}: New {Type} request for {Title}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.Issue:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! The user '{UserName}' has reported a new issue for the title {Title}! </br> {IssueCategory} - {IssueSubject} : {IssueDescription}",
                            Subject          = "{ApplicationName}: New issue for {Title}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.RequestAvailable:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! You   {Title} on {ApplicationName}! This is now available! :)",
                            Subject          = "{ApplicationName}: {Title} is now available!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.RequestApproved:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! Your request for {Title} has been approved!",
                            Subject          = "{ApplicationName}: your request has been approved",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.Test:
                        continue;

                    case NotificationType.RequestDeclined:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! Your request for {Title} has been declined, Sorry!",
                            Subject          = "{ApplicationName}: your request has been declined",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.ItemAddedToFaultQueue:
                        continue;

                    case NotificationType.WelcomeEmail:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! You have been invited to use {ApplicationName}! You can login here: {ApplicationUrl}",
                            Subject          = "Invite to {ApplicationName}",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.IssueResolved:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello {UserName} Your issue for {Title} has now been resolved.",
                            Subject          = "{ApplicationName}: Issue has been resolved for {Title}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.IssueComment:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello, There is a new comment on your issue {IssueSubject}, The comment is: {NewIssueComment}",
                            Subject          = "{ApplicationName}: New comment on issue {IssueSubject}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.AdminNote:
                        continue;

                    case NotificationType.Newsletter:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Here is a list of Movies and TV Shows that have recently been added!",
                            Subject          = "{ApplicationName}: Recently Added Content!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    NotificationTemplates.Add(notificationToAdd);
                }
            }
            SaveChanges();
        }
예제 #36
0
        // Constructor indeholder parametrene
        public Repository()
        {
            Teacher t1 = new Teacher(1, "Lone Sørensen", "*****@*****.**", "jflkwjkw23", 33, 145f);
            Teacher t2 = new Teacher(1, "Knud Johansen", "*****@*****.**", "hweuidh123", 38, 165f);
            Teacher t3 = new Teacher(3, "Poul Andersen", "*****@*****.**", "fwihioh2hi", 33, 165f);

            Student s1  = new Student(4, "Stefan Jensen", "*****@*****.**", "pass123", new DateTime(1990, 09, 21));
            Student s2  = new Student(5, "Michael Poulsen", "*****@*****.**", "sdfg32sdg", new DateTime(1991, 12, 11));
            Student s3  = new Student(6, "Karsten Kristensen", "*****@*****.**", "werwert32", new DateTime(1990, 02, 07));
            Student s4  = new Student(7, "Alex Hansen", "*****@*****.**", "dfgoupu23", new DateTime(1990, 01, 30));
            Student s5  = new Student(8, "Gunnar Thomsen", "*****@*****.**", "dpfgejporgj65", new DateTime(1990, 07, 20));
            Student s6  = new Student(9, "Nanna Olsen", "*****@*****.**", "oregpojr09", new DateTime(1990, 11, 20));
            Student s7  = new Student(10, "Tove Trollsen", "*****@*****.**", "ehi23hioh", new DateTime(1990, 03, 10));
            Student s8  = new Student(11, "Marie Kasttrup", "*****@*****.**", "kp12kkppb", new DateTime(1990, 01, 19));
            Student s9  = new Student(12, "Hanne Holst Jensen", "*****@*****.**", "fehwiohq11", new DateTime(1990, 03, 04));
            Student s10 = new Student(13, "Line Yding Poulsen", "*****@*****.**", "dw12dwwda", new DateTime(1990, 10, 03));

            Course c1 = new Course(1, "Matematik", new DateTime(2016, 08, 20), new DateTime(2017, 06, 26), t1);
            Course c2 = new Course(2, "Engelsk", new DateTime(2016, 08, 22), new DateTime(2017, 06, 24), t2);
            Course c3 = new Course(3, "Kemi", new DateTime(2015, 08, 14), new DateTime(2016, 06, 08), t3);
            Course c4 = new Course(4, "Idræt", new DateTime(2016, 08, 22), new DateTime(2017, 06, 26), t2);

            // Tilføjer alle teachers til liste
            Teachers.Add(t1);
            Teachers.Add(t2);
            Teachers.Add(t3);

            // Lave courses for teachers
            t1.AddCourse(c1);
            t2.AddCourse(c2);
            t2.AddCourse(c4);
            t3.AddCourse(c3);
            // t1.Courses.Add(c1)  -Tilføje uden Method i Course

            // Tilføjer alle courses til liste
            Courses.Add(c1);
            Courses.Add(c2);
            Courses.Add(c3);
            Courses.Add(c4);

            // Tilføjer alle studenter til liste
            Students.Add(s1);
            Students.Add(s2);
            Students.Add(s3);
            Students.Add(s4);
            Students.Add(s5);
            Students.Add(s6);
            Students.Add(s7);
            Students.Add(s8);
            Students.Add(s9);
            Students.Add(s10);

            // For hver student i vores list tilføjer vi et course. Alternativt er 3*10 for at tilføje hver enkelt. DRY
            foreach (Student student in Students)
            {
                student.AddCourse(c1);  // Tilføjer course til student
                c1.AddStudent(student); // Tilføjer student til course

                student.AddCourse(c2);
                c2.AddStudent(student);

                student.AddCourse(c3);
                c3.AddStudent(student);

                Users.Add(student);
            }

            // For loop. Laver variabel "i" og sætter til 0. Så længe "i" er mindre end Students.Count(som er 10)
            // Første gang er i = 0. Anden gang ligges der 2 til osv. Hermed hver anden student tilføjes til idræt.
            for (int i = 0; i < Students.Count; i += 2)
            {
                Students[i].AddCourse(c4);  // tilføjer idræt til hver 2. student
                c4.AddStudent(Students[i]); // tilføjer hver 2. student til idræt
            }

            foreach (Teacher teacher in Teachers)
            {
                Users.Add(teacher);
            }
        }
예제 #37
0
 public void AddUser(AppUser u)
 {
     Users.Add(u);
 }
예제 #38
0
        private void InitialInitialization()
        {
            List <CategoryEntity> categories = new List <CategoryEntity>()
            {
                new CategoryEntity()
                {
                    Name = "Категория-1"
                },
                new CategoryEntity()
                {
                    Name = "Категория-2"
                },
                new CategoryEntity()
                {
                    Name = "Категория-3"
                }
            };



            List <RoleEntity> roles = new List <RoleEntity>()
            {
                new RoleEntity()
                {
                    Name = "Operator"
                },
                new RoleEntity()
                {
                    Name = "Customer"
                }
            };

            List <GenderEntity> genders = new List <GenderEntity>()
            {
                new GenderEntity()
                {
                    Name = "Male"
                },
                new GenderEntity()
                {
                    Name = "Female"
                }
            };

            UserEntity user = new UserEntity()
            {
                Email    = "*****@*****.**",
                Password = "******", //TODO hash этого пароля test
                Role     = roles[1],
                Name     = "Test",
                LastName = "Test",
                Gender   = genders[0]
            };

            Categories.AddRange(categories);


            Roles.AddRange(roles);
            Genders.AddRange(genders);
            Users.Add(user);
            SaveChanges();

            List <SubCategoryEntity> subCategories = new List <SubCategoryEntity>()
            {
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-1-1", CategoryId = categories[0].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-1-2", CategoryId = categories[0].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-1-3", CategoryId = categories[0].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-2-1", CategoryId = categories[1].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-2-2", CategoryId = categories[1].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-2-3", CategoryId = categories[1].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-3-1", CategoryId = categories[2].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-3-2", CategoryId = categories[2].Id
                },
                new SubCategoryEntity()
                {
                    Name = "Подкатегория-3-3", CategoryId = categories[2].Id
                }
            };

            SubCategories.AddRange(subCategories);
            SaveChanges();
        }
        public bool Refresh()
        {
            /**
             * Note: checking if cache has changed after refresh
             *
             *  Algorithm:
             *      checking if the sequence had changed (by sequenceEqual).
             *      if it had changed - an update occur. and isChanged = true;
             *
             *  Author:
             *      Idan Izicovich.
             * */

            /* ---------- Cache Dictionaries ---------- */

            // Users
            bool isUserChanged = false;

            if (!UserManager.Users.SequenceEqual(Users))
            {
                Users.Clear();
                UserManager.Users.ToList().ForEach(userPair => Users.Add(userPair.Key, userPair.Value));
                isUserChanged = true;
            }

            // Players
            bool isPlayersChanged = false;

            if (!GameCenter.Players.SequenceEqual(Players.Values, new AddressComparer <Player>()))
            {
                Players.Clear();
                GameCenter.Players.ToList().ForEach(player => Players.Add(player.GetHashCode(), player));
                isPlayersChanged = true;
            }

            // Rooms
            bool isRoomChanged = false;

            if (!GameCenter.Rooms.SequenceEqual(Rooms.Values))
            {
                Rooms.Clear();
                GameCenter.Rooms.ToList().ForEach(room => Rooms.Add(room.GetHashCode(), room));
                isRoomChanged = true;
            }

            // Leagues
            //Undone: idan - make sure this is the right dictionary key needed for mapping the leagues at the cache
            bool isLeagueChange = false;

            if (!GameCenter.Leagues.SequenceEqual(Leagues.Values))
            {
                Leagues.Clear();
                GameCenter.Leagues.ToList().ForEach(league => Leagues.Add(league.GetHashCode(), league));
                isLeagueChange = true;
            }


            /* ------- link-cache dictionaries ---------- */

            // PlayerToRoom
            if (isPlayersChanged | isRoomChanged)
            {
                PlayerToRoom.Clear();
                GameCenter.PlayerToRoom.ToList().ForEach(pair => PlayerToRoom.Add(pair.Key, pair.Value));
            }

            // RoomToLeague
            if (isRoomChanged | isLeagueChange)
            {
                RoomToLeague.Clear();
                GameCenter.RoomToLeague.ToList().ForEach(pair => RoomToLeague.Add(pair.Key, pair.Value));
            }

            return(isLeagueChange | isPlayersChanged | isRoomChanged | isUserChanged);
        }
예제 #40
0
 public static void AddUser(string name)
 {
     Users.Add(new User(name));
 }
예제 #41
0
 /// <summary>
 /// Adds a new user to the group.
 /// </summary>
 /// <param name="u">User to be added.</param>
 public void AddUser(User u)
 {
     Users.Add(u.Name);
 }
예제 #42
0
        public void Bootstrap()
        {
            var _fs = new Filesystem(Directory.GetCurrentDirectory());

            Console.WriteLine("[I] Bootstrap...");
            AccessProvider.ProviderResponse     += Handle_Provider_Event;
            ServerProvider.ProviderResponse     += Handle_Provider_Event;
            ClientProvider.ProviderResponse     += Handle_Provider_Event;
            UserProvider.ProviderResponse       += Handle_Provider_Event;
            NewsProvider.ProviderResponse       += Handle_Provider_Event;
            NavigationProvider.ProviderResponse += Handle_Provider_Event;

            if (!Directory.Exists(Path.Combine(_fs.Root, "Providers")))
            {
                Directory.CreateDirectory(Path.Combine(_fs.Root, "Providers"));
                Console.WriteLine("[I] Provider installation needed..., Bootstrapping them...");
            }

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "System",
                Level    = ulong.MaxValue,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Server-Administratoren",
                Level    = byte.MaxValue,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Server-Operatoren",
                Level    = 250,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Seiten-Administroren",
                Level    = 245,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Seiten-Operatoren",
                Level    = 240,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "News-Administratoren",
                Level    = 235,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "News-Operatoren",
                Level    = 230,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Sendeplan-Administratoren",
                Level    = 225,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Sendeplan-Operatoren",
                Level    = 220,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Stream-Administratoren",
                Level    = 215,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Stream-Operatoren",
                Level    = 210,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Seiten-Mitglied",
                Level    = 1,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            AccessProvider.Add(Guid.NewGuid(), new GroupEntry <Guid>()
            {
                Active   = true,
                Name     = "Unregistriert",
                Level    = byte.MinValue,
                Locked   = true,
                Provider = AccessProvider.Name,
            });

            #region "News Provider - Installation"


            var news_user = Guid.Empty;
            var xmlDoc    = new XmlDocument();
            xmlDoc.Load(NewsProvider.InstallScript);
            var newsEntries = xmlDoc.SelectNodes("Namiono/Install/Users/User");

            for (var i = 0; i < newsEntries.Count; i++)
            {
                var res_level = ulong.MinValue;


                var user = new UserEntry <Guid>
                {
                    Id                                 = newsEntries[i].Attributes["Id"] == null?Guid.NewGuid() : Guid.Parse(newsEntries[i].Attributes["Id"].Value),
                                             Name      = newsEntries[i].Attributes["Name"].Value,
                                             Service   = bool.Parse(newsEntries[i].Attributes["Service"].Value == "0" ? "false" : "true"),
                                             Moderator = bool.Parse(newsEntries[i].Attributes["Moderator"].Value == "0" ? "false" : "true"),
                                             Locked    = bool.Parse(newsEntries[i].Attributes["Locked"].Value == "0" ? "false" : "true"),
                                             Password  = MD5.GetMD5Hash(newsEntries[i].Attributes["Password"].Value),
                                             Provider  = UserProvider.Name
                };

                if (newsEntries[i].Attributes["Level"] != null)
                {
                    ulong.TryParse(newsEntries[i].Attributes["Level"].Value, out res_level);
                    user.Level = res_level;
                }

                news_user = user.Id;

                UserProvider.Add(user.Id, user);
            }

            newsEntries = xmlDoc.SelectNodes("Namiono/Install/Entries/Entry");

            for (var i = 0; i < newsEntries.Count; i++)
            {
                var res_level = ulong.MinValue;

                var news = new NewsEntry <Guid>
                {
                    Name      = newsEntries[i].Attributes["Name"].Value,
                    Service   = bool.Parse(newsEntries[i].Attributes["Service"].Value == "0" ? "false" : "true"),
                    Moderator = bool.Parse(newsEntries[i].Attributes["Moderator"].Value == "0" ? "false" : "true"),
                    Locked    = bool.Parse(newsEntries[i].Attributes["Locked"].Value == "0" ? "false" : "true"),
                    OutPut    = newsEntries[i].Attributes["Output"].Value.Replace("[[NL]]", "<br />"),
                    Url       = newsEntries[i].Attributes["Url"].Value,
                    Author    = news_user
                };

                if (newsEntries[i].Attributes["Level"] != null)
                {
                    ulong.TryParse(newsEntries[i].Attributes["Level"].Value, out res_level);
                    news.Level = res_level;
                }


                NewsProvider.Add(Guid.NewGuid(), news);
            }

            #endregion

            #region "Navigation Provider - Installation"
            xmlDoc.Load(NavigationProvider.InstallScript);

            var navEntries = xmlDoc.SelectNodes("Namiono/Install/Entries/Entry");

            for (var i = 0; i < navEntries.Count; i++)
            {
                var res_level = ulong.MinValue;

                var nav = new NavigationEntry <Guid>
                {
                    Name      = navEntries[i].Attributes["Name"].Value,
                    Service   = bool.Parse(navEntries[i].Attributes["Service"].Value == "0" ? "false" : "true"),
                    Moderator = bool.Parse(navEntries[i].Attributes["Moderator"].Value == "0" ? "false" : "true"),
                    Locked    = bool.Parse(navEntries[i].Attributes["Locked"].Value == "0" ? "false" : "true"),
                    OutPut    = navEntries[i].Attributes["Output"].Value.Replace("[[NL]]", "<br />"),
                    Url       = navEntries[i].Attributes["Url"].Value,
                    Author    = Guid.Empty
                };

                if (navEntries[i].Attributes["Level"] != null)
                {
                    ulong.TryParse(navEntries[i].Attributes["Level"].Value, out res_level);
                    nav.Level = res_level;
                }


                NavigationProvider.Add(Guid.NewGuid(), nav);
            }


            NavigationProvider.Add(Guid.NewGuid(), new NavigationEntry <Guid>()
            {
                Name = "Mitglieder", Active = true, Locked = false, Level = 1, Frame = "#content", Provider = UserProvider.Name, Action = "show"
            });
            NavigationProvider.Add(Guid.NewGuid(), new NavigationEntry <Guid>()
            {
                Name = "News", Active = true, Locked = false, Level = 1, Frame = "#content", Provider = NewsProvider.Name, Action = "show"
            });

            #endregion
            AccessProvider.Bootstrap();
            ServerProvider.Bootstrap();
            ClientProvider.Bootstrap();
            UserProvider.Bootstrap();
            NewsProvider.Bootstrap();
            NavigationProvider.Bootstrap();



            Console.WriteLine("[I] Starting ...");
        }
예제 #43
0
        public void Seed()
        {
            // Make sure we have the API User
            var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase));

            if (!apiUserExists)
            {
                Users.Add(new OmbiUser
                {
                    UserName           = "******",
                    UserType           = UserType.SystemUser,
                    NormalizedUserName = "******",
                });
                SaveChanges();
            }

            //Check if templates exist
            var templates = NotificationTemplates.ToList();

            var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast <NotificationAgent>().ToList();
            var allTypes  = Enum.GetValues(typeof(NotificationType)).Cast <NotificationType>().ToList();

            foreach (var agent in allAgents)
            {
                foreach (var notificationType in allTypes)
                {
                    if (templates.Any(x => x.Agent == agent && x.NotificationType == notificationType))
                    {
                        // We already have this
                        continue;
                    }
                    NotificationTemplates notificationToAdd;
                    switch (notificationType)
                    {
                    case NotificationType.NewRequest:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! The user '{UserName}' has requested the {Type} '{Title}'! Please log in to approve this request. Request Date: {RequestedDate}",
                            Subject          = "{ApplicationName}: New {Type} request for {Title}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.Issue:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! The user '{UserName}' has reported a new issue for the title {Title}! </br> {IssueCategory} - {IssueSubject} : {IssueDescription}",
                            Subject          = "{ApplicationName}: New issue for {Title}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.RequestAvailable:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! Your request for {Title} on {ApplicationName}! This is now available! :)",
                            Subject          = "{ApplicationName}: {Title} is now available!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.RequestApproved:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! Your request for {Title} has been approved!",
                            Subject          = "{ApplicationName}: your request has been approved",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.Test:
                        continue;

                    case NotificationType.RequestDeclined:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! Your request for {Title} has been declined, Sorry!",
                            Subject          = "{ApplicationName}: your request has been declined",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.ItemAddedToFaultQueue:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! The user '{UserName}' has requested {Title} but it could not be added. This has been added into the requests queue and will keep retrying",
                            Subject          = "Item Added To Retry Queue",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.WelcomeEmail:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello! You have been invited to use {ApplicationName}! You can login here: {ApplicationUrl}",
                            Subject          = "Invite to {ApplicationName}",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.IssueResolved:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello {UserName} Your issue for {Title} has now been resolved.",
                            Subject          = "{ApplicationName}: Issue has been resolved for {Title}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.IssueComment:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Hello, There is a new comment on your issue {IssueSubject}, The comment is: {NewIssueComment}",
                            Subject          = "{ApplicationName}: New comment on issue {IssueSubject}!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    case NotificationType.AdminNote:
                        continue;

                    case NotificationType.Newsletter:
                        notificationToAdd = new NotificationTemplates
                        {
                            NotificationType = notificationType,
                            Message          = "Here is a list of Movies and TV Shows that have recently been added!",
                            Subject          = "{ApplicationName}: Recently Added Content!",
                            Agent            = agent,
                            Enabled          = true,
                        };
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    NotificationTemplates.Add(notificationToAdd);
                }
            }
            SaveChanges();
        }
        public JsonResult RegisterAjax(string userName, string realName, bool sexual, string password, string ConfirmPassword, bool hasReadRegister)
        {
            if (hasReadRegister == false)
            {
                return(Json(new Result(false, "请先阅读《用户注册协议》,同意后方可注册!"), JsonRequestBehavior.AllowGet));
            }

            if (realName.Length == 0)
            {
                return(Json(new Result(false, "请输入昵称"), JsonRequestBehavior.AllowGet));
            }

            if (realName.Length > 10)
            {
                return(Json(new Result(false, "昵称不要超过10个字"), JsonRequestBehavior.AllowGet));
            }

            if (realName.ToLower().Contains("admin"))
            {
                return(Json(new Result(false, "昵称不要包含admin"), JsonRequestBehavior.AllowGet));
            }


            if (!password.Equals(ConfirmPassword))
            {
                return(Json(new Result(false, "两次输入的密码不一致"), JsonRequestBehavior.AllowGet));
            }

            lock (lockRegister)
            {
                bool flage = ServiceHelper.GetUsersService.Exists(t => t.UserName == userName);
                if (flage)
                {
                    return(Json(new Result(false, "账号已经被注册,请更换"), JsonRequestBehavior.AllowGet));
                }
                Users user = new Users();
                user.UserName = userName;
                user.RealName = realName;
                user.Sexual   = sexual;
                user.Password = password;
                //添加账号PasswordSalt随机
                user.PasswordSalt = Common.TextFilter.GetPasswordSalt();//Common.TextFilter.Substring(Guid.NewGuid().ToString("N"), 10, false);
                string endPassword = user.Password + user.PasswordSalt;
                //计算密码
                user.Password = Common.SecureHelper.MD5(endPassword);

                //user的必填字段
                user.NeedAccount = true;
                Users adminUser = ServiceHelper.GetUsersService.GetEntity(5);
                user.ShopsID        = adminUser.ShopsID;
                user.DefaultStoreID = adminUser.DefaultStoreID;
                user.LoginTimes     = 1;
                user.IsIntention    = false;
                user.CreateTime     = DateTime.Now;
                user.CreateUserID   = adminUser.ID;

                bool success = user.Add() == null ? false : true;
                if (success)
                {
                    //Admin.Controllers.HomeController ach = new Admin.Controllers.HomeController();
                    //ach.LoginAjax(userName, password, false);
                    //return RedirectToAction("Index", "Home", new { area = "Admin" });
                    return(Json(new Result(true, "注册成功,正在登录"), JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new Result(false, "注册失败,请联系管理员"), JsonRequestBehavior.AllowGet));
                }

                //    LoginAjax("afb4b11b25864820b8e42f4b583d46ff", "afb4b11b25864820b8e42f4b583d46ff", false);
                //    return RedirectToAction("Index", "Home", new { area = "Admin" });

                //return View();
                return(null);
            }
        }
예제 #45
0
    protected void btnReg_Click(object sender, EventArgs e)
    {
        if (!cbAgree.Checked)
        {
            Shove._Web.JavaScript.Alert(this.Page, "必须同意注册协议!");

            return;
        }

        if (CheckCode.Visible)
        {
            if (tbCheckCode.Text.Trim() == "")
            {
                Shove._Web.JavaScript.Alert(this.Page, "请输入验证码!");

                return;
            }
            else
            {
                if (!ShoveCheckCode1.Valid(tbCheckCode.Text.Trim()))
                {
                    Shove._Web.JavaScript.Alert(this.Page, "验证码输入有误!");

                    return;
                }
            }
        }

        string url = tbWebUrl.Text;

        if (!url.StartsWith("http://"))
        {
            url = "http://" + url;
        }

        Regex regex = new Regex(@"([\w-]+\.)+[\w-]+.([^a-z])(/[\w- ./?%&=]*)?|[a-zA-Z0-9\-\.][\w-]+.([^a-z])(/[\w- ./?%&=]*)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        Match m = regex.Match(url);

        if (!m.Success && url.IndexOf("http") == 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "网址填写错误");

            return;
        }

        double scale = scale = _Site.SiteOptions["Opt_CpsBonusScale"].ToDouble(0);

        if (_User == null)  //没有登录注册
        {
            Users user = new Users(_Site.ID);

            user.Name = tbUserName.Text.Trim();
            user.Password = tbPassword.Text.Trim();
            user.Email = tbEmail.Text.Trim();
            user.RealityName = tbRealyName.Text.Trim();
            user.Mobile = tbPhone.Text.Trim();
            user.QQ = tbQQ.Text.Trim();
            user.UserType = 2;

            string ReturnDescription = "";
            long Result = user.Add(ref ReturnDescription);

            if (Result < 0)
            {
                Shove._Web.JavaScript.Alert(this, ReturnDescription);

                return;
            }

            //登录
            Result = user.Login(ref ReturnDescription);

            if (Result < 0)
            {
                Shove._Web.JavaScript.Alert(this, ReturnDescription);

                return;
            }

            user.cps.BonusScale = scale;
            user.cps.ON = true;
            user.cps.ResponsiblePerson = tbRealyName.Text.Trim();
            user.cps.ContactPerson = tbRealyName.Text.Trim();
            user.cps.Mobile = tbPhone.Text.Trim();
            user.cps.Email = tbEmail.Text.Trim();
            user.cps.QQ = tbQQ.Text.Trim();
            user.cps.Type = Shove._Convert.StrToShort(ddlCpsType.SelectedValue, 1);
            user.cps.OwnerUserID = user.ID;
            user.cps.Url = tbWebUrl.Text.Trim();
            user.cps.Name = tbSiteName.Text.Trim();
            user.cps.MD5Key = tbMD5.Text.Trim();
            user.cps.Content = "";

            ReturnDescription = "";
            Result = user.cps.Try(ref ReturnDescription);

            if (Result < 0)
            {
                Shove._Web.JavaScript.Alert(this, ReturnDescription);

                return;
            }

            Shove._Web.Cache.ClearCache("Cps_Administrator_CpsTry");
            Response.Redirect("Default.aspx");
        }
        else
        {
            if (_User.cps.ID != -1)
            {

                Shove._Web.JavaScript.Alert(this.Page, "您已注册成商家!");

                return;
            }

            if (new DAL.Tables.T_CpsTrys().GetCount("HandleResult = 0 and UserID=" + _User.ID.ToString()) > 0)
            {
                Shove._Web.JavaScript.Alert(this.Page, "您已申请过CPS,正在审核中。");

                return;
            }

            _User.cps.BonusScale = scale;
            _User.cps.ON = true;
            _User.cps.ResponsiblePerson = _User.RealityName;
            _User.cps.ContactPerson = _User.RealityName;
            _User.cps.Mobile = tbPhone.Text.Trim();
            _User.cps.Email = tbEmail.Text.Trim();
            _User.cps.QQ = tbQQ.Text.Trim();
            _User.cps.Type = Shove._Convert.StrToShort(ddlCpsType.SelectedValue, 1);
            _User.cps.OwnerUserID = _User.ID;
            _User.cps.Url = tbWebUrl.Text.Trim();
            _User.cps.Name = tbSiteName.Text.Trim();
            _User.cps.MD5Key = tbMD5.Text.Trim();
            _User.cps.Content = "";

            string ReturnDescription = "";
            int Result = _User.cps.Try(ref ReturnDescription);

            if (Result < 0)
            {
                Shove._Web.JavaScript.Alert(this, ReturnDescription);

                return;
            }

            Shove._Web.Cache.ClearCache("Cps_Administrator_CpsTry");

            Shove._Web.JavaScript.Alert(this.Page, "已经提交申请成功,工作人员会尽快处理!", "Default.aspx");
        }
    }
예제 #46
0
 async Task IPermissionConfig.AddUser(IGuildUser user)
 {
     Users.Add(await AddUserInternal(user));
     await SaveChangesAsync().ConfigureAwait(false);;
 }
예제 #47
0
 public void AddUser(User user) =>
 Users.Add(user);
예제 #48
0
        public void HandleEvent(object sender, IEvent evt)
        {
            switch (evt)
            {
            case ChannelUpdateEvent update:     // Owner?
                lock (Sync) {
                    if (update.HasName)
                    {
                        Name = update.Name;
                    }
                    if (update.HasTopic)
                    {
                        Topic = update.Topic;
                    }
                    if (update.IsTemporary.HasValue)
                    {
                        IsTemporary = update.IsTemporary.Value;
                    }
                    if (update.MinimumRank.HasValue)
                    {
                        MinimumRank = update.MinimumRank.Value;
                    }
                    if (update.HasPassword)
                    {
                        Password = update.Password;
                    }
                    if (update.AutoJoin.HasValue)
                    {
                        AutoJoin = update.AutoJoin.Value;
                    }
                    if (update.MaxCapacity.HasValue)
                    {
                        MaxCapacity = update.MaxCapacity.Value;
                    }
                    if (update.Order.HasValue)
                    {
                        Order = update.Order.Value;
                    }
                }
                break;

            case ChannelUserJoinEvent cuje:
                lock (Sync) {
                    Sessions.Add(cuje.SessionId, cuje.UserId);
                    Users.Add(cuje.UserId);
                }
                break;

            case ChannelSessionJoinEvent csje:
                lock (Sync)
                    Sessions.Add(csje.SessionId, csje.UserId);
                break;

            case ChannelUserLeaveEvent cule:
                lock (Sync) {
                    Users.Remove(cule.UserId);
                    Queue <string> delete = new Queue <string>(Sessions.Where(s => s.Value == cule.UserId).Select(s => s.Key));
                    while (delete.TryDequeue(out string sessionId))
                    {
                        Sessions.Remove(sessionId);
                    }
                }
                break;

            case ChannelSessionLeaveEvent csle:
                lock (Sync)
                    Sessions.Remove(csle.SessionId);
                break;
            }
        }
 protected void btnReg_Click(object sender, EventArgs e)
 {
     string str = "";
     if (!PF.CheckUserName(this.tbUserName.Text))
     {
         str = str + "对不起用户名中含有禁止使用的字符.\r\n";
     }
     if ((_String.GetLength(this.tbUserName.Text) < 5) || (_String.GetLength(this.tbUserName.Text) > 0x10))
     {
         str = str + "用户名长度在 5-16 个英文字符或数字、中文 3-8 之间.\r\n";
     }
     if ((this.tbPassword.Text.Length < 6) || (this.tbPassword.Text.Length > 0x10))
     {
         str = str + "密码长度必须在 6-16 位之间.\r\n";
     }
     if (this.tbSiteName.Text.Trim().Length == 0)
     {
         str = str + "网站名称不能为空.\r\n";
     }
     if (this.tbSiteURL.Text.Trim().Length == 0)
     {
         str = str + "网站地址不能为空.\r\n";
     }
     if (!_String.Valid.isEmail(this.tbEmail.Text))
     {
         str = str + "电子邮件地址格式不正确.\r\n";
     }
     if (!this.ckbAgree.Checked)
     {
         str = str + "必须同意本站会员注册协议才能注册会员。\r\n";
     }
     if (this.CheckCode2.Visible)
     {
         if (this.tbCheckCode.Text.Trim() == "")
         {
             str = str + "请输入验证码!\n";
         }
         else if (!this.ShoveCheckCode1.Valid(this.tbCheckCode.Text.Trim()))
         {
             str = str + "验证码输入有误!\n";
         }
     }
     if (str != "")
     {
         this.lblInputError.Visible = true;
         this.lblInputError.Text = "输入资料错误:\r\n" + str;
     }
     else
     {
         long num = -1L;
         long num2 = -1L;
         if (this.Session[this.KeyPromotionUserID] != null)
         {
             num2 = _Convert.StrToLong(this.Session[this.KeyPromotionUserID].ToString(), -1L);
         }
         object obj2 = MSSQL.ExecuteScalar("select ID from T_Cps where OwnerUserID=" + num2, new MSSQL.Parameter[0]);
         if (obj2 != null)
         {
             num = _Convert.StrToLong(obj2.ToString(), -1L);
         }
         Thread.Sleep(500);
         string str2 = this.tbUserName.Text.Trim();
         string str3 = this.tbPassword.Text.Trim();
         string str4 = this.tbEmail.Text.Trim();
         string str5 = this.tbTel.Text.Trim();
         string str6 = this.tbQQ.Text.Trim();
         Users users = new Users(base._Site.ID)
         {
             Name = str2,
             Password = str3,
             Email = str4,
             Mobile = str5,
             QQ = str6,
             UserType = 2
         };
         if (num > 0L)
         {
             users.CommenderID = -1L;
             users.CpsID = num;
         }
         else
         {
             users.CommenderID = num2;
             users.CpsID = -1L;
         }
         string returnDescription = "";
         if (users.Add(ref returnDescription) < 0)
         {
             JavaScript.Alert(this, returnDescription);
         }
         else
         {
             double num4 = 0.0;
             DataTable table = new Tables.T_Sites().Open("Opt_CpsBonusScale", "", "");
             if ((table != null) && (table.Rows.Count > 0))
             {
                 num4 = double.Parse(table.Rows[0]["Opt_CpsBonusScale"].ToString());
             }
             users.cps.SiteID = 1L;
             users.cps.CommendID = num2;
             users.cps.Name = this.tbSiteName.Text;
             users.cps.Url = this.tbSiteURL.Text;
             users.cps.BonusScale = num4;
             users.cps.ON = true;
             users.cps.Telephone = this.tbTel.Text.Trim();
             users.cps.Email = str4;
             users.cps.QQ = str6;
             users.cps.Type = 2;
             users.cps.DomainName = users.GetPromotionURL(0);
             if (users.cps.Add(ref returnDescription) < 0)
             {
                 JavaScript.Alert(this, returnDescription);
             }
             else if (users.Login(ref returnDescription) < 0)
             {
                 JavaScript.Alert(this, returnDescription);
             }
             else
             {
                 base.Response.Redirect("../../Default.aspx");
             }
         }
     }
 }
예제 #50
0
        public void LoadConf(XmlNode root)
        {
            XmlNode xn = null;

            try
            {
                // 读取显示属性

                log.WriteFileLog("读取产品信息");

                type       = root.Attributes["type"].InnerText;
                product_id = root.Attributes["product_id"].InnerText;
                enable     = bool.Parse(root.Attributes["enable"].InnerText);
                name       = root.Attributes["name"].InnerText;
                funclist   = root.Attributes["funclist"].InnerText;

                // 读取节点配置明细
                log.WriteFileLog("读取配置库信息");
                xn         = root.SelectSingleNode("Repository");
                Repository = xn.Attributes["repo"].InnerText;
                WorkSpace  = xn.Attributes["workspace"].InnerText;
                // OutDir 如果以 \ 结尾,会导致编译前台Drp时,批处理里会出现 "C:\src\", \"会被认为是转义,就报错了,
                // 这里如果,结尾是\,去掉
                if (WorkSpace[WorkSpace.Length - 1] == '\\')
                {
                    WorkSpace = WorkSpace.Substring(0, WorkSpace.Length - 1);
                }
                SvnRepo           = new SvnPort(name, Repository);
                SvnRepo.Workspace = WorkSpace;

                // 读取修改单配置明细
                log.WriteFileLog("读取开发工具信息");
                xn      = root.SelectSingleNode("Develop");
                DevTool = xn.Attributes["devtool"].InnerText;
                Rar     = xn.Attributes["rar"].InnerText;
                OutDir  = xn.Attributes["outdir"].InnerText;
                // OutDir 如果以 \ 结尾,会导致编译前台Drp时,批处理里会出现 "C:\src\", \"会被认为是转义,就报错了,
                // 这里如果,结尾是\,去掉
                if (OutDir[OutDir.Length - 1] == '\\')
                {
                    OutDir = OutDir.Substring(0, OutDir.Length - 1);
                }

                // 读取Ssh连接配置
                log.WriteFileLog("读取Ssh连接配置");
                xn   = root.SelectSingleNode("SSHConn");
                Conn = new ReSSH(xn.Attributes["name"].InnerText,
                                 xn.Attributes["host"].InnerText,
                                 int.Parse(xn.Attributes["port"].InnerText),
                                 xn.Attributes["user"].InnerText,
                                 xn.Attributes["pass"].InnerText,
                                 bool.Parse(xn.Attributes["restartas"].InnerText));
                Conn.localdir = OutDir;

                // 读取小球FTP路径递交配置
                log.WriteFileLog("读取小球FTP路径递交配置");
                xn           = root.SelectSingleNode("CommitFtp");
                fc           = new FtpConf();
                fc.host      = xn.Attributes["host"].InnerText;
                fc.port      = int.Parse(xn.Attributes["port"].InnerText);
                fc.user      = xn.Attributes["user"].InnerText;
                fc.pass      = xn.Attributes["pass"].InnerText;
                fc.ServerDir = xn.Attributes["remotedir"].Value;
                fc.LocalDir  = xn.Attributes["localdir"].Value;
                if (fc.LocalDir[fc.LocalDir.Length - 1] == '\\')
                {
                    fc.LocalDir = fc.LocalDir.Substring(0, fc.LocalDir.Length - 1);
                }

                // 初始化 ftp配置
                ftp = new FTPConnection();
                ftp.ServerAddress   = fc.host;
                ftp.ServerPort      = fc.port;
                ftp.UserName        = fc.user;
                ftp.Password        = fc.pass;
                ftp.TransferType    = FTPTransferType.BINARY;         // 指定 BINARY 传输,否则对于压缩包会失败
                ftp.CommandEncoding = Encoding.GetEncoding("gb2312"); // 重要,否则乱码且连接不

                log.WriteFileLog("读取对比参数");
                xn         = root.SelectSingleNode("Diff");
                DiffEnable = bool.Parse(xn.Attributes["enable"].Value);
                DiffBin    = xn.Attributes["bin"].Value;
                DiffArgs   = xn.Attributes["args"].Value;

                log.WriteFileLog("读取Delphi编译版本配置");
                xn      = root.SelectSingleNode("SpecialCom");
                SpeComs = new ArrayList();
                XmlNodeList xnl = xn.ChildNodes;
                foreach (XmlNode x in xnl)
                {
                    if (x.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    ComInfo com = new ComInfo(x.Attributes["lang"].Value,
                                              int.Parse(x.Attributes["ver"].Value),
                                              x.Attributes["coms"].Value);
                    SpeComs.Add(com);
                }

                // 读取数据库连接属性
                xn  = root.SelectSingleNode("DB");
                xnl = xn.ChildNodes;
                foreach (XmlNode x in xnl)
                {
                    DBUser u = new DBUser(x.Attributes["name"].InnerText,
                                          x.Attributes["pass"].InnerText,
                                          x.Attributes["dbtns"].InnerText,
                                          x.Attributes["note"].InnerText);
                    Users.Add(u);
                }


                // 读取公用递交配置
                try
                {
                    xn         = root.SelectSingleNode("CommitPublic");
                    logmessage = xn.Attributes["logmessage"].Value;
                    xnl        = xn.ChildNodes;
                    foreach (XmlNode x in xnl)
                    {
                        CommitPublic.Add(x.Attributes["dir"].InnerText);
                    }
                }
                catch
                {
                    log.WriteLog("无法读取公共递交资源CommitPublic!,请检查MAConf.xml配置");
                }
            }
            catch (Exception e)
            {
                log.WriteLog("加载配置失败,活动节点:" + xn.Name + e.Message, LogLevel.Error);
                throw new MissingFieldException("LoadConf");
            }
        }
예제 #51
0
파일: User.cs 프로젝트: hotmike49/PM
 internal static Users LoadAllUsers()
 {
     SqlCommand cmd = new SqlCommand("select Firstname, Lastname, Username, Email from [User]", Main.GetConnection());
     SqlDataReader reader = cmd.ExecuteReader();
     Users allUsers = new Users();
     while (reader.Read())
     {
         User u = new User();
         u.Firstname = reader.GetString(0);
         u.Lastname = reader.GetString(1);
         u.Username = reader.GetString(2);
         u.Email = reader.GetString(3);
         allUsers.Add(u);
     }
     return allUsers;
 }
예제 #52
0
 public void AddUsersToGame(string username)
 {
     Users.Add(new User(username, 0));
     NumberOfPlayersJoined++;
 }
예제 #53
0
파일: User.cs 프로젝트: hotmike49/PM
        /************************************************************************************************************
        STATISCHE METHODEN
        internal bedeutet, dass sie nur von Klassen aus BOKunden (aus dem eigenem Namespace) aufgerufen werden können
        - also nicht direkt aus dem PL

        Die Methoden sind im BOKunde-Objekt, damit der BO-Programmierer alle SQL-Statements, die Kunden betreffen, an einer Stelle hat
        Der PL-Programmierer sieht diese Implementation aber nicht. Er sieht die Methoden, von wo aus er diese Objekte "bekommt"
        (also entsprechend der Navigability). Man hätte diese Methoden technisch aber problemlos auch in die cMain geben können!
        */
        // Laden aller Tasks die einem User zugeordnet sind
        internal static Users LoadTaskUsers(Task t)
        {
            if (t.ID != "")
            {
                SqlCommand cmd = new SqlCommand("select u.Firstname, u.Lastname, u.Username, u.Email from UserTask as ut inner join User as t on ut.Username = u.Username where TaskID = @tid", Main.GetConnection());
                cmd.Parameters.Add(new SqlParameter("tid", t.ID));
                SqlDataReader reader = cmd.ExecuteReader();
                Users taskUsers = new Users();
                while (reader.Read())
                {
                    User u = new User();
                    u.Firstname = reader.GetString(0);
                    u.Lastname = reader.GetString(1);
                    u.Username = reader.GetString(2);
                    u.Email = reader.GetString(3);
                    taskUsers.Add(u);
                }
                return taskUsers;
            }
            else return null;
        }
예제 #54
0
    protected void btnReg_Click(object sender, EventArgs e)
    {
        if (tbRegCheckCode.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入验证码!");

            return;
        }

        string RegCode = tbRegCheckCode.Text.Trim().ToLower();

        if (Shove._Web.Cache.GetCacheAsString("CheckCode_" + Request.Cookies["ASP.NET_SessionId"].Value, "") != Shove._Security.Encrypt.MD5(PF.GetCallCert() + RegCode))
        {
            Shove._Web.JavaScript.Alert(this.Page, "验证码输入错误,请重新输入!");

            return;
        }
        // 通过验证

        long CpsID = -1;
        long CommenderID = -1;
        long HongbaoPromotionID = -1;

        if (Session[KeyPromotionUserID] != null)
        {
            CommenderID = Shove._Convert.StrToLong(Session[KeyPromotionUserID].ToString(), -1);
        }
        if (Session[KeyHongbaoPromotionID] != null)
        {
            HongbaoPromotionID = Shove._Convert.StrToLong(Session[KeyHongbaoPromotionID].ToString(), -1);
        }

        //检查推荐人是否为CPS商家,是就把此会员标记CSPID
        object tempOjb = Shove.Database.MSSQL.ExecuteScalar("select ID from T_Cps where OwnerUserID=" + CommenderID, new Shove.Database.MSSQL.Parameter[0]);
        if (tempOjb != null)
        {
            CpsID = Shove._Convert.StrToLong(tempOjb.ToString(), -1);
        }

        System.Threading.Thread.Sleep(500);

        string Name = TBUserName.Text.Trim();
        string Password = TBPwdOne.Text.Trim();

        Users user = new Users(_Site.ID);
        user.Name = Name;
        user.Password = Password;
        user.UserType = 2;

        if (CpsID > 0)//推荐人为cps商家就填CpsID字段
        {
            user.CommenderID = -1;
            user.CpsID = CpsID;
        }
        else
        {
            user.CommenderID = CommenderID;
            user.CpsID = -1;
        }

        //添加会员
        string ReturnDescription = "";
        int Result = user.Add(ref ReturnDescription);
        if (Result < 0)
        {
            Shove._Web.JavaScript.Alert(this, ReturnDescription);
            return;
        }


        string regReultInfo = "<span style='font-size: 14px; color: #CC3300; font-weight: bold;'>注册成功,恭喜您成为" + _Site.Name + "的高级会员!让我们一起共同搏击1000万大奖!</span><br/>";

        //注册成功,领取推荐人的红包
        if (HongbaoPromotionID > 0)
        {
            //判断当前红包推荐是否可用
            DataTable dtPromotion = Shove.Database.MSSQL.Select("select * from T_UserHongbaoPromotion where ID=" + HongbaoPromotionID + " and UserID=" + CommenderID, new Shove.Database.MSSQL.Parameter[0]);
            if (dtPromotion != null && dtPromotion.Rows.Count > 0)
            {
                double hongbaoMoney = 0;    //红包钱数
                hongbaoMoney = Shove._Convert.StrToDouble(dtPromotion.Rows[0]["Money"].ToString(), 0);
                int returnValue = -1;
                DAL.Procedures.P_AcceptUserHongbaoPromotion(CommenderID, user.ID, HongbaoPromotionID, ref returnValue, ref ReturnDescription);
                if (returnValue != 0)
                {
                    regReultInfo = "<span style='font-size: 14px; color: #CC3300; font-weight: bold;'>注册成功,恭喜您成为" + _Site.Name + "的高级会员!</span><br/>由以下原因未能获得推荐者的彩票红包:" + ReturnDescription + "<br/>";
                }
                else
                {
                    regReultInfo = "<span style='font-size: 14px; color: #CC3300; font-weight: bold;'>注册成功,恭喜您成为" + _Site.Name + "的高级会员,并获得" + hongbaoMoney.ToString() + "元彩票红包!" + hongbaoMoney.ToString() + "元已注入您的" + _Site.Name + "现金帐户,您可以到我们的购彩页面购买彩票啦,祝君好运!" + "</span><br/>";
                }
            }
        }


        //登录
        Result = user.Login(ref ReturnDescription);

        if (Result < 0)
        {
            Shove._Web.JavaScript.Alert(this, ReturnDescription);

            return;
        }

        //显示注册结果信息
        //MultiView1.ActiveViewIndex = 1;
        //divRegResultInfo.InnerHtml = regReultInfo;

        #region
        //long CpsID = -1;
        //long CommenderID = -1;
        //string Memo = "";

        //FirstUrl firstUrl = new FirstUrl();
        //string URL = firstUrl.Get();

        //if (!URL.StartsWith("http://"))
        //{
        //    URL = "http://" + URL;
        //    URL = URL.Split('?'.ToString().ToCharArray())[0];
        //}

        //DataTable dt = new DAL.Tables.T_Cps().Open("id, [ON], [Name]", "SiteID = " + _Site.ID.ToString() + " and( DomainName = '" + URL + "' or DomainName='" + Shove._Web.Utility.GetUrl() + "')", "");

        //if (Shove._Convert.StrToLong(firstUrl.CpsID, -1) > 0) //读取第一次访问页面时保存的CPS ID
        //{
        //    CpsID = Shove._Convert.StrToLong(firstUrl.CpsID, -1);
        //}
        //else if ((dt != null) && (dt.Rows.Count > 0))
        //{
        //    CpsID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1);
        //    Memo = firstUrl.PID;//联盟商推广URL的PID
        //}

        //System.Threading.Thread.Sleep(500);

        //string Name = TBUserName.Text.Trim();
        //string Password = TBPwdOne.Text.Trim();
        //string Password2 = TBPwdTwo.Text.Trim();

        //Users user = new Users(_Site.ID);

        //user.Name = Name;
        //user.Password = Password;
        //user.UserType = 2;

        //dt = new DAL.Tables.T_Users().Open("", "id=" + Shove._Web.Utility.GetRequest("CID") + " and Name='" + Shove._Web.Utility.GetRequest("CN") + "'", "");

        //if ((dt != null) && (dt.Rows.Count == 1))
        //{
        //    CommenderID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("CID"), -1);
        //}

        //user.CommenderID = CommenderID;
        //user.CpsID = CpsID;
        //user.Memo = Memo;

        //string ReturnDescription = "";
        //int Result = user.Add(ref ReturnDescription);

        //if (Result < 0)
        //{
        //    new Log("Users").Write("会员注册不成功:" + ReturnDescription);
        //    Shove._Web.JavaScript.Alert(this, ReturnDescription);

        //    return;
        //}

        //Result = user.Login(ref ReturnDescription);

        //if (Result < 0)
        //{
        //    new Log("Users").Write("注册成功后登录失败:" + ReturnDescription);
        //    Shove._Web.JavaScript.Alert(this, ReturnDescription);

        //    return;
        //}
        #endregion
        Response.Redirect("/Home/Room/UserRegSuccess.aspx");
    }