Exemple #1
0
        public ActionResult RescueGm(Int32 id)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            if (id == 0)
            {
                return(Redirect("/GM/RecordList"));
            }

            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = String.Format("api/GM?token={0}&gid={1}", user.token, id),
            };
            var result = api.PostJsonToFromBody();
            var gm     = CommonHelper.Deserialize <GmManage>(result);

            if (gm.result == 1)
            {
                return(Redirect("/GM/RecordList"));
            }
            ViewBag.Error   = -1;
            ViewBag.Message = gm.message;
            return(Redirect("/GM/RecordList"));
        }
Exemple #2
0
        public ActionResult Approval(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            var platform = collection["platform"];
            var sid      = collection["server"];
            var type     = collection["type"];

            if (platform == "" || sid == "")
            {
                ViewBag.Error    = -1;
                ViewBag.Message  = "请选择平台和服务器";
                ViewBag.Platform = new List <Platform>();
                ViewBag.Resource = new List <Resource>();
                return(View());
            }
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Resource?token={0}&pid={1}&sid={2}&roleid={3}&state={4}", user.token, Convert.ToInt64(platform), Convert.ToInt64(sid), user.id, type),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var list = CommonHelper.Deserialize <List <Resource> >(result);

            ViewBag.Resource = list;
            var list2 = ApiPlatforms();

            ViewBag.Platform = list2;
            return(View());
        }
Exemple #3
0
        public ActionResult Delete(Int64 id)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            if (user == null)
            {
                return(Redirect("/Home/Login"));
            }

            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = String.Format("api/Resource?token={0}&id={1}&flag={2}", user.token, id, true),
            };

            var result = api.PostJsonToFromBody();

            api.Dispose();
            var rm = CommonHelper.Deserialize <Resource>(result);

            if (rm.result == 1)
            {
                return(Redirect("/Resource/Approval"));
            }
            ViewBag.Error   = -1;
            ViewBag.Message = rm.message;
            return(Redirect("/Resource/Approval"));
        }
Exemple #4
0
        /// <summary> 删除</summary>
        public ActionResult Delete(int id)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            if (user == null)
            {
                return(Redirect("/Home/Login"));
            }
            if (id == 0)
            {
                return(Redirect("/System/Account"));
            }

            //POST api/System/{id}?token={token}
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = String.Format("api/System/{0}?token={1}", id, user.token),
            };

            var result = api.PostJsonToFromBody();

            api.Dispose();
            var rm = CommonHelper.Deserialize <User>(result);

            if (rm.result == 1)
            {
                return(Redirect("/System/Account"));
            }
            ViewBag.Error   = -1;
            ViewBag.Message = rm.message;
            return(Redirect("/System/Account"));
        }
Exemple #5
0
 public JsonResult PagerHandler(Int32 page, Int32 size, string pid, string sid, string start, string end, string type, string playername)
 {
     if (pid == "0" && sid == "0")
     {
         var api = new ApiReceive()
         {
             URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
             Resource = string.Format("api/Pay?token={0}&role={1}&pid={2}&index={3}&size={4}", user.token, user.role, user.pid, page, size),
         };
         var result = api.PostJsonToFromBody();
         api.Dispose();
         var totalpay = CommonHelper.Deserialize <PagerPay>(result);
         return(Json(totalpay, JsonRequestBehavior.AllowGet));
     }
     else
     {
         var pager = new PagerTotalPay();
         if (start != "" && start != "0" && end == "" || end == "0")
         {
             pager.result  = -1;
             pager.message = "没有选结束时间";
             return(Json(pager, JsonRequestBehavior.AllowGet));
         }
         if (end != "" && end != "0" && start == "" || start == "0")
         {
             pager.result  = -1;
             pager.message = "没有选开始时间";
             return(Json(pager, JsonRequestBehavior.AllowGet));
         }
         if (sid == "0")
         {
             pager.result  = -1;
             pager.message = "没有选服务器";
             return(Json(pager, JsonRequestBehavior.AllowGet));
         }
         if (playername == "")
         {
             pager.result  = -1;
             pager.message = "没有选玩家";
             return(Json(pager, JsonRequestBehavior.AllowGet));
         }
         Int64 stick = 0;
         Int64 etick = 0;
         if (start != "" && start != "0" && end != "" && end != "0")
         {
             stick = DateTime.Parse(start).Ticks;
             etick = DateTime.Parse(end).Ticks;
         }
         var api = new ApiReceive()
         {
             URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
             Resource = string.Format("api/Pay?token={0}&pid={1}&sid={2}&start={3}&end={4}&type={5}&playname={6}&userpid={7}&role={8}&index={9}&size={10}", user.token, Convert.ToInt32(pid), Convert.ToInt32(sid), stick, etick, Convert.ToInt32(type), playername, user.pid, user.role, page, size),
         };
         var result = api.PostJsonToFromBody();
         api.Dispose();
         var totalpay = CommonHelper.Deserialize <PagerPay>(result);
         return(Json(totalpay, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #6
0
        public ActionResult RegisterServer(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            try
            {
                var server_pid            = collection["server_pid"];
                var server_name           = collection["server_name"];
                var server_ip             = collection["server_ip"];
                var server_port           = collection["server_port"];
                var server_port_policy    = collection["server_port_policy"];
                var server_connect_string = collection["server_connect_string"];
                var server_tg_route       = collection["server_tg_route"];
                var server_tg_pay         = collection["server_tg_pay"];
                var server_game_domain    = collection["server_game_domain"];
                var server_game_pay       = collection["server_game_pay"];

                if (string.IsNullOrEmpty(server_pid) || string.IsNullOrEmpty(server_name) || string.IsNullOrEmpty(server_ip) ||
                    string.IsNullOrEmpty(server_port) || string.IsNullOrEmpty(server_port_policy) || string.IsNullOrEmpty(server_connect_string))
                {
                    ViewBag.Error    = -2;
                    ViewBag.Message  = "信息内容不完整";
                    ViewBag.Platform = ApiPlatforms();
                    return(View());
                }
                //POST api/System?token={token}&name={name}&ip={ip}&pid={pid}&port={port}&policy={policy}&connect={connect}&tg_route={tg_route}&tg_pay={tg_pay}&game_domain={game_domain}&game_pay={game_pay}

                var sc  = HttpUtility.UrlEncode(server_connect_string);
                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = String.Format("api/System?token={0}&name={1}&ip={2}&pid={3}&port={4}&policy={5}&connect={6}&tg_route={7}&tg_pay={8}&game_domain={9}&game_pay={10}"
                                             , user.token, server_name, server_ip, server_pid, server_port, server_port_policy, sc,
                                             server_tg_route, server_tg_pay, server_game_domain, server_game_pay),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <Server>(result);

                if (rm.result == 1)
                {
                    return(Redirect("/System/Server"));
                }

                ViewBag.Error    = -1;
                ViewBag.Message  = rm.message;
                ViewBag.Platform = ApiPlatforms();
                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemple #7
0
        public ActionResult RecordList(FormCollection collection)
        {
            try
            {
                if (!IsLogin)
                {
                    return(Redirect("/Home/Login"));
                }

                var pid   = collection["platform"];
                var sid   = collection["server"];
                var state = collection["state_type"];
                var type  = collection["user_type"];
                var value = collection["value"];
                ViewBag.Platform = ApiPlatforms();
                ViewBag.Role     = user.role;

                if (!string.IsNullOrEmpty(value))
                {
                    if (string.IsNullOrEmpty(pid) || string.IsNullOrEmpty(sid) || string.IsNullOrEmpty(state) || string.IsNullOrEmpty(type))
                    {
                        ViewBag.Error   = -1;
                        ViewBag.Message = "查询玩家信息请选择完整依据";
                        return(View(new PagerQuery <PagerInfo, List <GmManage> >(new PagerInfo(), new List <GmManage>())));
                    }
                }

                if (string.IsNullOrEmpty(sid))
                {
                    sid = "0";
                }

                //api?GM/token={token}&name={name}&pid={pid}&sid={sid}&state={state}&type={type}&value={value}
                var api = new ApiReceive()
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = string.Format("api/GM?token={0}&name={1}&pid={2}&sid={3}&state={4}&type={5}&value={6}", user.token, user.name, pid, sid, state, type, value),
                };

                var result = api.PostJsonToFromBody();
                var list   = CommonHelper.Deserialize <PageGmManage>(result);
                var query  = new PagerQuery <PagerInfo, List <GmManage> >(list.Pager, list.Gms);

                if (query.result < 0)
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = query.message;
                    return(View());
                }
                return(View(query));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemple #8
0
        public Resource ApiFindResource(Guid token, Int64 pid, Int64 sid, Int32 roleid, string playername, string gift, int gifttype, string g1, string g2, string g3, string g4, string g5, string reason, int type, string message)
        {
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Resource?token={0}&pid={1}&sid={2}&roleid={3}&playername={4}&gift={5}&gifttype={6}&g1={7}&g2={8}&g3={9}&g4={10}&g5={11}&reason={12}&type={13}&message={14}", token, pid, sid, roleid, playername, gift, gifttype, g1, g2, g3, g4, g5, reason, type, message),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            return(CommonHelper.Deserialize <Resource>(result));
        }
Exemple #9
0
        private List <Notice> ApiFindALLNotice(Guid token, Int64 roleid)
        {
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Message?token={0}&roleid={1}&flag={2}", token, roleid, true),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            return(CommonHelper.Deserialize <List <Notice> >(result));
        }
Exemple #10
0
        public ActionResult PlatformEdit(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            try
            {
                var pid     = collection["platform_id"];
                var pname   = collection["platfrom_name"];
                var token   = collection["platform_token"];
                var enctypy = collection["platform_encrtpy"];

                var platform = new Platform
                {
                    id      = Convert.ToInt32(pid),
                    name    = pname,
                    token   = new Guid(token),
                    encrypt = enctypy,
                };

                if (string.IsNullOrEmpty(pid) || string.IsNullOrEmpty(pname) || string.IsNullOrEmpty(token) || string.IsNullOrEmpty(enctypy))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "信息内容不完整";
                    return(View(platform));
                }
                //POST api/System?token={token}&pid={pid}&pname={pname}&encrypt={encrypt}&b={b}
                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = String.Format("api/System?token={0}&pid={1}&pname={2}&encrypt={3}&b={4}", user.token, pid, pname, enctypy, 0),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <BaseEntity>(result);

                if (rm.result == 1)
                {
                    return(Redirect("/System/Index"));
                }

                ViewBag.Error   = -2;
                ViewBag.Message = "修改平台信息失败";
                return(View(platform));
            }
            catch (Exception ex)
            {
                return(Redirect("/System/Index"));
            }
        }
Exemple #11
0
        private Notice ApiFindNotice(Guid token, string stime, string etime, Int64 roleid, int role, Int64 pid, Int64 sid, int interval, string content)
        {
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Message?token={0}&roleid={1}&role={2}&&pid={3}&sid={4}&start={5}&end={6}&space={7}&content={8}", token, roleid, role, pid, sid, stime, etime, interval, content),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var rm = CommonHelper.Deserialize <Notice>(result);

            return(rm);
        }
Exemple #12
0
        public ActionResult Register(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            try
            {
                var pid  = collection["pid"];
                var role = collection["role_type"];
                var name = collection["role_name"];
                var pwd  = collection["role_password"];
                var cpwd = collection["role_confirmpassword"];

                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(cpwd))
                {
                    ViewBag.Error   = -2;
                    ViewBag.Message = "用户名或密码为空";
                    return(View(user));
                }
                if (pwd != cpwd)
                {
                    ViewBag.Error   = -3;
                    ViewBag.Message = "两次密码不一致";
                    return(View(user));
                }
                //POST api/System?token={token}&name={name}&pid={pid}&role={role}&pwd={pwd}
                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = String.Format("api/System?token={0}&name={1}&pid={2}&role={3}&pwd={4}", user.token, name, pid, role, cpwd),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <User>(result);

                if (rm.result == 1)
                {
                    return(Redirect("/System/Account"));
                }

                ViewBag.Error   = -1;
                ViewBag.Message = rm.message;
                return(View(user));
            }
            catch (Exception ex)
            {
                return(View(ex));
            }
        }
Exemple #13
0
        /// <summary>请求邮件API</summary>
        private Email ApiFindMsg(Guid token, string sn, string title, string content)
        {
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Manage?token={0}&sn={1}&title={2}&content={3}", token, sn, title, content),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var entity = CommonHelper.Deserialize <Email>(result);

            return(entity);
        }
Exemple #14
0
        public ActionResult Reset(FormCollection collection)
        {
            try
            {
                if (!IsLogin)
                {
                    return(Redirect("/Home/Login"));
                }
                var name   = collection["Name"];
                var oldpwd = collection["OldPassWord"];
                var newpwd = collection["NewPassWord"];
                var cpwd   = collection["ConfirmPassWord"];

                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(oldpwd) || string.IsNullOrEmpty(newpwd))
                {
                    return(View());
                }
                if (newpwd != cpwd)
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "新密码与确认密码不一致";
                    return(View());
                }

                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource =
                        String.Format("api/System?token={0}&name={1}&old={2}&newpwd={3}", user.token, name, oldpwd,
                                      newpwd),
                };

                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <User>(result);
                if (rm.result == 1)
                {
                    ViewBag.Error = 0;
                    return(View());
                }
                ViewBag.Error   = -1;
                ViewBag.Message = rm.message;
                return(View());
            }
            catch (Exception ex)
            {
                return(View(ex));
            }
        }
Exemple #15
0
        public ActionResult AddGoodsType(FormCollection collection)
        {
            try
            {
                if (!IsLogin)
                {
                    return(Redirect("/Home/Login"));
                }

                var type = collection["type"];
                var name = collection["name"];

                if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(name))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "添加失败,信息不完整";
                    return(View());
                }
                if (!Regex.IsMatch(type, @"^\d+$"))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "福利卡枚举类型ID格式错误,请重新输入";
                    return(View());
                }

                //api/Goods?token={token}&type={type}&name={name}
                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = String.Format("api/Goods?token={0}&type={1}&name={2}", user.token, type, name),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <BaseEntity>(result);

                if (rm.result > 0)
                {
                    return(Redirect("/Goods/GoodsManage"));
                }

                ViewBag.Error   = rm.result;
                ViewBag.Message = rm.message;
                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemple #16
0
        public JsonResult AjaxServer(Int32 id)
        {
            var api = new ApiReceive()
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Common?token={0}&pid={1}&flag={2}", user.token, id, true),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var list       = CommonHelper.Deserialize <List <Server> >(result);
            var jsonResult = Json(list, JsonRequestBehavior.AllowGet);

            return(jsonResult);
        }
Exemple #17
0
        public JsonResult AjaxCodeTypes(Int32 id)
        {
            //POST api/Common?token={token}&name={name}&pid={pid}&b={b}
            var api = new ApiReceive()
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Common?token={0}&name={1}&pid={2}&b={3}", user.token, user.name, id, 0),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var list       = CommonHelper.Deserialize <List <GoodsType> >(result);
            var jsonResult = Json(list, JsonRequestBehavior.AllowGet);

            return(jsonResult);
        }
Exemple #18
0
        public JsonResult AjaxSkills(Int32 sid, Int64 rid)
        {
            var api = new ApiReceive()
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Player?token={0}&sid={1}&rid={2}", user.token, sid, rid),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var list = CommonHelper.Deserialize <RoleSkill>(result);

            var jsonResult = Json(list, JsonRequestBehavior.AllowGet);

            return(jsonResult);
        }
Exemple #19
0
        public ActionResult Paylist(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            var pid        = collection["platform"];
            var sid        = collection["server"];
            var start      = collection["starttime"];
            var end        = collection["endtime"];
            var type       = collection["type"];
            var playername = collection["playname"];


            if (sid == "" || sid == "0" || pid == "" || pid == "0")
            {
                return(View());
            }
            if (playername == "")
            {
                return(View());
            }

            Int64 stick = 0;
            Int64 etick = 0;

            if (start != "" && start != "0" && end != "" && end != "0")
            {
                stick = DateTime.Parse(start).Ticks;
                etick = DateTime.Parse(end).Ticks;
            }

            var api = new ApiReceive()
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Pay?token={0}&pid={1}&sid={2}&start={3}&end={4}&type={5}&playname={6}&index={7}&size={8}", user.token, Convert.ToInt32(pid), Convert.ToInt32(sid), stick, etick, type, playername, 0, 0),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var totalpay = CommonHelper.Deserialize <List <SingleRecordPay> >(result);

            ViewBag.Platform  = ApiPlatforms();
            ViewBag.Recordpay = totalpay;
            return(View());
        }
Exemple #20
0
        public ActionResult Index(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            var pid   = collection["platform"];
            var sid   = collection["server"];
            var start = collection["starttime"];
            var end   = collection["endtime"];

            if (pid == "")
            {
                ViewBag.Error    = -1;
                ViewBag.Message  = "请选择平台";
                ViewBag.Platform = ApiPlatforms();;
                return(View());
            }
            if (sid == "")
            {
                sid = "0";
            }
            Int64 stick = 0;
            Int64 etick = 0;

            if (start != "" && start != "0" && end != "" && end != "0")
            {
                stick = DateTime.Parse(start).Ticks;
                etick = DateTime.Parse(end).Ticks;
            }

            var api = new ApiReceive()
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = string.Format("api/Pay?token={0}&pid={1}&sid={2}&start={3}&end={4}", user.token, Convert.ToInt32(pid), Convert.ToInt32(sid), stick, etick),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var totalpay = CommonHelper.Deserialize <List <TotalRecordPay> >(result);

            ViewBag.Platform = ApiPlatforms();
            return(View(totalpay));
        }
Exemple #21
0
        public ActionResult GoodsCodeProvide(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }

            try
            {
                var pid   = collection["platform"];
                var type  = collection["give_type"];
                var sid   = collection["server"];
                var order = collection["order_number"];
                ViewBag.Platform = ApiPlatforms();

                if (string.IsNullOrEmpty(pid) || string.IsNullOrEmpty(sid) || string.IsNullOrEmpty(order) || string.IsNullOrEmpty(type))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "信息不完整,请填写完整信息";
                    return(View());
                }

                //POST api/System?token={token}&pid={pid}&sid={sid}&order={order}&type={type}&b={b}
                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = String.Format("api/System?token={0}&pid={1}&sid={2}&order={3}&type={4}&b={5}", user.token, pid, sid, order, type, 0),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <BaseEntity>(result);

                ViewBag.Error   = rm.result;
                ViewBag.Message = rm.message;
                return(View());
            }
            catch (Exception ex)
            {
                return(Redirect("/System/GameGoods"));
            }
        }
Exemple #22
0
        public ActionResult ServerEdit(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }
            try
            {
                var serverid              = collection["serverid"];
                var server_name           = collection["server_name"];
                var server_ip             = collection["server_ip"];
                var server_port           = collection["server_port"];
                var server_port_policy    = collection["server_port_policy"];
                var server_connect_string = collection["server_connect_string"];
                var server_tg_route       = collection["server_tg_route"];
                var server_tg_pay         = collection["server_tg_pay"];
                var server_game_domain    = collection["server_game_domain"];
                var server_game_pay       = collection["server_game_pay"];

                var server = new Server
                {
                    id             = Convert.ToInt32(serverid),
                    name           = server_name,
                    ip             = server_ip,
                    port_server    = Convert.ToInt32(server_port),
                    port_policy    = Convert.ToInt32(server_port_policy),
                    connect_string = server_connect_string,
                    tg_route       = server_tg_route,
                    tg_pay         = server_tg_pay,
                    game_domain    = server_game_domain,
                    game_pay       = server_game_pay,
                };

                if (string.IsNullOrEmpty(serverid) || string.IsNullOrEmpty(server_name) || string.IsNullOrEmpty(server_ip) ||
                    string.IsNullOrEmpty(server_port) || string.IsNullOrEmpty(server_port_policy) || string.IsNullOrEmpty(server_connect_string))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "信息内容不完整";
                    return(View(server));
                }
                //  POST api/System?token={token}&id={id}&name={name}&ip={ip}&port={port}&policy={policy}&connect={connect}
                //  &tgroute={tgroute}&tgpay={tgpay}&gamedomain={gamedomain}&gamepay={gamepay}

                var sc = HttpUtility.UrlEncode(server_connect_string);

                var api = new ApiReceive
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = String.Format("api/System?token={0}&id={1}&name={2}&ip={3}&port={4}&policy={5}&connect={6}&tgroute={7}&tgpay={8}&gamedomain={9}&gamepay={10}",
                                             user.token, server.id, server_name, server_ip, server_port, server_port_policy, sc,
                                             server_tg_route, server_tg_pay, server_game_domain, server_game_pay),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var rm = CommonHelper.Deserialize <BaseEntity>(result);

                if (rm.result == 1)
                {
                    return(Redirect("/System/Server"));
                }

                ViewBag.Error   = -2;
                ViewBag.Message = "修改服务器信息失败";
                return(View(server));
            }
            catch
            {
                return(Redirect("/System/Server"));
            }
        }
Exemple #23
0
        public ActionResult Index(FormCollection collection)
        {
            try
            {
                if (!IsLogin)
                {
                    return(Redirect("/Home/Login"));
                }

                var platform = collection["run_platform"];
                var sserver  = collection["server_select"];
                var search   = collection["search_type"];
                var value    = collection["search"];
                var type     = collection["silent_type"];
                var time     = collection["time"];
                var reason   = collection["reason"];
                ViewBag.Platform = ApiPlatforms();

                if (string.IsNullOrEmpty(platform) || string.IsNullOrEmpty(sserver) || string.IsNullOrEmpty(search) || string.IsNullOrEmpty(value) || string.IsNullOrEmpty(type) || string.IsNullOrEmpty(reason))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "请将信息填写完整";
                    return(View());
                }
                if (Convert.ToInt32(type) == 1)
                {
                    if (string.IsNullOrEmpty(time))
                    {
                        ViewBag.Error   = -1;
                        ViewBag.Message = "冻结玩家请输入冻结时间";
                        return(View());
                    }
                    if (!Regex.IsMatch(time, @"^\d+$"))
                    {
                        ViewBag.Error   = -1;
                        ViewBag.Message = "时间控制输入格式错误,请重新输入";
                        return(View());
                    }
                    if (Convert.ToInt32(time) < 0 || Convert.ToInt32(time) > 10000)
                    {
                        ViewBag.Error   = -1;
                        ViewBag.Message = "时间设置错误或时间过大,请重新设置";
                        return(View());
                    }
                }
                else
                {
                    time = "0";
                }
                //POST api/GM?token={token}&name={name}&platform={platform}&sid={sid}&
                //search={search}&value={value}&type={type}&time={time}&reason={reason}
                var api = new ApiReceive()
                {
                    URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                    Resource = string.Format("api/GM?token={0}&name={1}&pid={2}&sid={3}&search={4}&value={5}&type={6}&time={7}&reason={8}",
                                             user.token, user.name, platform, sserver, search, value, type, time, reason),
                };
                var result = api.PostJsonToFromBody();
                api.Dispose();
                var gm = CommonHelper.Deserialize <GmManage>(result);
                if (gm.result == -1)
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = gm.message;
                    return(View());
                }
                return(Redirect("/GM/RecordList"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemple #24
0
        public ActionResult ManageServerState(FormCollection collection)
        {
            if (!IsLogin)
            {
                return(Redirect("/Home/Login"));
            }

            var sid        = collection["serverid"];
            var serverName = collection["server_name"];
            var stateName  = collection["state_name"];
            var state      = collection["server_state"];
            var startTime  = collection["start_time"];
            var stateType  = collection["state_type"];

            var nowServer = new Server()
            {
                name         = serverName,
                id           = Convert.ToInt32(sid),
                state_name   = stateName,
                server_state = Convert.ToInt32(state),
            };

            if (string.IsNullOrEmpty(serverName) || string.IsNullOrEmpty(state) || string.IsNullOrEmpty(stateType) || string.IsNullOrEmpty(sid) || string.IsNullOrEmpty(stateName))
            {
                ViewBag.Error   = -1;
                ViewBag.Message = "信息内容不完整!";
                return(View(nowServer));
            }
            if (Convert.ToInt32(state) == Convert.ToInt32(stateType))
            {
                ViewBag.Error   = 1;
                ViewBag.Message = "服务器状态未更改!";
                return(View(nowServer));
            }
            if (Convert.ToInt32(stateType) == (int)ServerOpenState.启服)
            {
                if (string.IsNullOrEmpty(startTime))
                {
                    ViewBag.Error   = -1;
                    ViewBag.Message = "服务器启服,请选择启服时间!";
                    return(View(nowServer));
                }
                //var date = DateTime.Now;
                //var start = Convert.ToDateTime(startTime);
                //if (start <= date)
                //{
                //    ViewBag.Error = -1;
                //    ViewBag.Message = "启服时间应大于或略大于当前时间!";
                //    return View(nowServer);
                //}
            }
            //api/System?token={token}&sid={sid}&stateType={stateType}&startTime={startTime}&b={b}
            var api = new ApiReceive
            {
                URL      = string.Format("{0}", ConfigHelper.GetApiUrl()),
                Resource = String.Format("api/System?token={0}&sid={1}&stateType={2}&startTime={3}&b={4}", user.token, sid, stateType, startTime, 0),
            };
            var result = api.PostJsonToFromBody();

            api.Dispose();
            var rm = CommonHelper.Deserialize <BaseEntity>(result);

            if (rm.result == 1)
            {
                return(Redirect("/System/Server"));
            }

            ViewBag.Error   = rm.result;
            ViewBag.Message = rm.message;
            return(View(nowServer));
        }