public static Result Register(String username, String password,Boolean supper) { Result result = new Result(); if (string.IsNullOrEmpty(username)) { result.Add("Sorry,管理员账号不能为空"); } else if (string.IsNullOrEmpty(password)) { result.Add("Sorry,管理员密码不能为空"); } else { if (password.Length != 32) { password = Encryptor.Md5Encryptor32(Encryptor.Md5Encryptor32(password)); } result.Join(System.IO.XMLHelper.AddData(PathHelper.Map("~/xcenter/data/wechat/manager.xml"), "Manager", System.IO.XMLHelper.CreateInsertParameter("Username", username), System.IO.XMLHelper.CreateInsertParameter("Password", password), System.IO.XMLHelper.CreateInsertParameter("Supper", supper ? "true" : "false"))); } return result; }
public void ElasticThreadPool_Multi_Staged_Fibonacci_Min_1_Max_30() { const int test = 4; // initialize data structures ElasticThreadPool[] stp = new ElasticThreadPool[test]; Result<int>[] results = new Result<int>[test]; for(int i = 0; i < test; ++i) { stp[i] = new ElasticThreadPool(1, 30); results[i] = new Result<int>(TimeSpan.MaxValue, TaskEnv.New(stp[i])); } // start test var sw = Stopwatch.StartNew(); for(int i = 0; i < results.Length; ++i) { _log.DebugFormat("--- FIBONACCI KICK-OFF: {0}", i); Fibonacci(stp[i], 30, TimeSpan.Zero, results[i]); Thread.Sleep(TimeSpan.FromSeconds(1)); } results.Join(new Result(TimeSpan.MaxValue)).Wait(); sw.Stop(); TimeSpan elapsed = sw.Elapsed; // check results for(int i = 0; i < test; ++i) { Assert.AreEqual(832040, results[i].Value, "result {0} did not match", i); } _log.Debug("Time: " + elapsed); _log.Debug("Work items processed: " + _counter); for(int i = 0; i < test; ++i) { stp[i].Dispose(); Assert.AreEqual(0, stp[i].WorkItemCount, "WorkQueue[{0}] items", i); Assert.AreEqual(0, stp[i].ThreadCount, "WorkQueue[{0}] threads", i); } }
public virtual User Register( User user, Result errors, ISiteConfig sconfig ) { if (isNameReserved( user.Name, sconfig )) { errors.Add( lang.get( "exNameFound" ) ); return null; } if (isUrlReserved( user.Url, sconfig )) { errors.Add( lang.get( "exUrlFound" ) ); return null; } if (validateUnique( user, errors ) == false) return null; setProfileAndTemplateAndHashPasswork( user, sconfig ); user.RoleId = sconfig.NormalRoleId; Result result = db.insert( user ); if (result.HasErrors) { db.delete( user.Profile ); errors.Join( result ); return null; } if (strUtil.IsNullOrEmpty( user.Url )) { user.Url = "user" + user.Id; db.update( user, "Url" ); } sendMsg( user, sconfig ); userIncomeService.InitUserIncome( user ); if (isFirstUser()) { user.RoleId = sconfig.AdministratorId; db.update( user, "RoleId" ); } return user; }