Beispiel #1
0
        public ActionResult OpenServiceDel(int id)
        {
            var         cpy = GetCurrentUser();
            OpenService op  = new OpenService()
            {
                Id        = id,
                CompanyId = cpy.Id
            };

            //先删开服表
            if (OpenServiceBll.Delete(op))
            {
                //归还条数
                if (OpenServiceBll.ReturnServiceNum(id, cpy.Id))
                {
                    return(Content("ok,恭喜:删除成功!条数已归还!"));
                }
                else
                {
                    return(Content("no,提示:开服表删除成功!条数归还失败!"));
                }
            }
            else
            {
                return(Content("no,开服表删除失败!"));
            }
        }
Beispiel #2
0
        public void TestGetInfoForNonRegisteredService()
        {
            OpenService os = new OpenService();

            os.ServiceName = "doesn't exists";
            OpenService.ServiceInfo info = os.GetInfo();
            Assert.IsNotNull(info);
            Assert.IsFalse(info.Installed);
            Assert.AreEqual(0, (int)info.WinState);
            Assert.AreEqual(os.ServiceName, info.Name);
            Assert.IsNull(info.DisplayName);
        }
Beispiel #3
0
        public void TestGetInfoForStandartService()
        {
            OpenService os = new OpenService();

            os.ServiceName = "Workstation";
            OpenService.ServiceInfo info = os.GetInfo();
            Assert.IsNotNull(info);
            Assert.IsTrue(info.Installed);
            Assert.AreEqual("Workstation", info.Name);
            Assert.AreEqual(ServiceControllerStatus.Running, info.WinState);
            Assert.IsNotNull(info.DisplayName);
            Console.WriteLine(info.DisplayName);
        }
Beispiel #4
0
        public static string GetWelcomeInfo()
        {
            // 统一通过 OpenService 获取用户名
            String userName = new OpenService().UserName(HttpContext.Current);

            if (userName == null)
            {
                return("用户不存在");
            }
            else
            {
                return(string.Format("欢迎你,{0}!", userName));
            }
        }
Beispiel #5
0
        private void importUserSingle(ImportUser u, List <string> picList)
        {
            OpenService os = new OpenService();

            //
            String pwd   = getRandomPwd();
            String email = pwd + "@xxx.com";
            String apps  = " home,blog,photo,microblog,friend,visitor,forumpost,about";

            // 注册
            Result result;

            if (strUtil.HasText(u.FriendlyUrl))
            {
                result = os.UserRegister(u.Name, pwd, email, u.FriendlyUrl, apps);
            }
            else
            {
                String uFriendlyUrl = getFriendlyUrl();
                result = os.UserRegister(u.Name, pwd, email, uFriendlyUrl, apps);
            }

            if (result.HasErrors)
            {
                return;
            }
            User user = result.Info as User;

            if (picList.Count > 0)
            {
                String randomPic = picList[0];

                // 上传头像
                Result saved = AvatarUploader.Save(randomPic, user.Id);

                // 更新头像信息
                user.Pic = saved.Info.ToString();
                user.update();

                picList.RemoveAt(0);
            }
        }
Beispiel #6
0
        public ActionResult AddOpenService()
        {
            var    currenCpy = GetCurrentUser();
            string type      = Request["rec_hot"];

            OpenService service = new OpenService()
            {
                CompanyId    = currenCpy.Id,
                GameName     = Request["gamename"],
                ServerName   = Request["serverName"],
                Url          = Request["url"],
                PackageId    = int.Parse(Request["packageId"].ToString()),
                Rec_Hot      = Request["rec_hot"],
                InTime       = DateTime.Now,
                Rec_Datetime = DateTime.Now,
                State        = "2",
                CheckName    = null,
                StartTime    = DateTime.Parse(Request["starttime"])
            };
            Recharge recharge;

            if (type == "2")//全天开服
            {
                recharge = RechargeBll.LoadEntities(r => r.CompanyId == currenCpy.Id && r.Num > r.Used && r.ComboName == "全天置顶").OrderBy(r => r.InTime).FirstOrDefault();
                if (recharge == null)
                {
                    return(Content("noNum,全天开服点数不足,请先充值"));
                }
                if (OpenServiceBll.Add(service) != null)
                {
                    RechargedUsed ru = new RechargedUsed()
                    {
                        RechargeId = recharge.Id, OpenServiceId = service.Id, InTime = DateTime.Now
                    };
                    RechargedUsedBll.Add(ru);
                    recharge.Used = recharge.Used + 1;
                    RechargeBll.Update(recharge);
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }//置顶开服
            else if (type == "1")
            {
                recharge = RechargeBll.LoadEntities(r => r.CompanyId == currenCpy.Id && r.Num > r.Used && r.ComboName != "全天置顶").OrderBy(r => r.InTime).FirstOrDefault();
                if (recharge == null)
                {
                    return(Content("noNum,点数不足,请先充值"));
                }
                if (OpenServiceBll.Add(service) != null)
                {
                    RechargedUsed ru = new RechargedUsed()
                    {
                        RechargeId = recharge.Id, OpenServiceId = service.Id, InTime = DateTime.Now
                    };
                    RechargedUsedBll.Add(ru);
                    recharge.Used = recharge.Used + 1;
                    RechargeBll.Update(recharge);
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
            else
            {
                return(Content("typeError,提示:请先选择开服类型"));
            }
        }