Example #1
0
        public JsonResult UpdatePost()
        {
            var id      = RequestHelper.GetValue("id");
            var name    = RequestHelper.GetValue("name");
            var ip      = RequestHelper.GetValue("ip");
            var cname   = RequestHelper.GetValue("cname");
            var des     = RequestHelper.GetValue("des");
            var status  = RequestHelper.GetInt("status");
            var sortnum = RequestHelper.GetInt("sortnum");

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(ip))
            {
                return(Json(new { result = false, info = "缺少必要参数" }, JsonRequestBehavior.DenyGet));
            }
            var dto = new ServerNodeDto()
            {
                Id          = id,
                Name        = name,
                IP          = ip,
                CNAME       = cname,
                Description = des,
                Status      = (sbyte)status,
                SortNum     = sortnum
            };
            var result = ServerNodeService.Update(dto);

            LogService.Info($"ServerNodeService.Update >>> {result} --- {id}:{ip}");
            return(Json(new { result = result }, JsonRequestBehavior.DenyGet));
        }
Example #2
0
        public async Task <IHttpActionResult> ReloadSrsConf(string id)
        {
            try
            {
                var node = ServerNodeService.FindByIdAsync(ThreadStaticObject.UserId, id);
                if (node != null)
                {
                    var models = await ServerNodeService.UpdateSrsConf(ThreadStaticObject.UserId, id);

                    return(Json(new DjLiveResponse <dynamic>(models)));
                }
                else
                {
                    return(Json(new DjLiveResponse <dynamic>()
                    {
                        ApiCode = ApiCode.NotFound,
                        Message = "服务器对象不存在."
                    }));
                }
            }
            catch (Exception e)
            {
                var errorId = Guid.NewGuid().Str();
                LogHelper.Error(errorId, e);
                return(Json(new DjLiveResponse <dynamic>()
                {
                    ApiCode = ApiCode.UnExceptError, Message = $@"发生未知错误,请联系管理员,错误代码:{errorId}"
                }));
            }
        }
Example #3
0
        public ActionResult AddPost()
        {
            var id      = Guid.NewGuid().ToString("n");
            var name    = RequestHelper.GetValue("servername");
            var ip      = RequestHelper.GetValue("serverip");
            var cname   = RequestHelper.GetValue("servercname");
            var des     = RequestHelper.GetValue("serverdes");
            var status  = 1;
            var sortnum = RequestHelper.GetInt("serversortnum");

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(ip))
            {
                return(RedirectToAction("Add"));
            }
            var dto = new ServerNodeDto()
            {
                Id          = id,
                Name        = name,
                IP          = ip,
                CNAME       = cname,
                Description = des,
                Status      = (sbyte)status,
                SortNum     = sortnum
            };
            var result = ServerNodeService.Add(dto);

            LogService.Info($"ServerNodeService.Add >>> {result} --- {id}:{ip}");
            return(RedirectToAction("List"));
        }
Example #4
0
        public JsonResult GetList()
        {
            var offset = RequestHelper.GetInt("offset");
            var limit  = RequestHelper.GetInt("limit");
            var key    = RequestHelper.GetValue("search");
            int total;
            var list = ServerNodeService.GetList(offset, limit, out total, key);

            return(Json(new { rows = list, total = total }, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public JsonResult DeletePost()
        {
            var id = RequestHelper.GetValue("id");

            if (string.IsNullOrEmpty(id))
            {
                return(Json(new { result = false }, JsonRequestBehavior.DenyGet));
            }
            var result = ServerNodeService.Delete(id);

            LogService.Info($"ServerNodeService.Delete >>> {result} --- {id}");
            return(Json(new { result = result }, JsonRequestBehavior.DenyGet));
        }
Example #6
0
        public void TestInitialize()
        {
            string conn = "Data Source=agile_config.db";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.Sqlite, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            freeSqlContext = new FreeSqlContext(fsq);

            service = new ServerNodeService(freeSqlContext);
            fsq.Delete <ServerNode>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
Example #7
0
        public void TestInitialize()
        {
            string conn = "Database=agile_config_test;Data Source=localhost;User Id=root;Password=dev@123;port=3306";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.MySql, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            freeSqlContext = new FreeSqlContext(fsq);

            service = new ServerNodeService(freeSqlContext);
            fsq.Delete <ServerNode>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
Example #8
0
        public void TestInitialize()
        {
            string conn = "Persist Security Info = False; User ID =dev; Password =dev@123,; Initial Catalog =agile_config_test; Server =xxx";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.SqlServer, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            FluentApi.Config(fsq);
            freeSqlContext = new FreeSqlContext(fsq);

            service = new ServerNodeService(freeSqlContext);
            fsq.Delete <ServerNode>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
Example #9
0
        public void TestInitialize()
        {
            string conn = "user id=CLINIC;password=CLINIC;data source=192.168.0.91/orcl";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.Oracle, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            FluentApi.Config(fsq);
            freeSqlContext = new FreeSqlContext(fsq);

            service = new ServerNodeService(freeSqlContext);
            fsq.Delete <ServerNode>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
Example #10
0
        public void TestInitialize()
        {
            string conn = "Host=127.0.0.1;Database=agile_config;Username=postgres;Password=dev@123";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.PostgreSQL, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            FluentApi.Config(fsq);
            freeSqlContext = new FreeSqlContext(fsq);

            service = new ServerNodeService(freeSqlContext);
            fsq.Delete <ServerNode>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
        /// <summary>
        /// 我的服务
        /// </summary>
        public ActionResult My()
        {
            var email = CookieHelper.Email;
            var user  = UserCache.Cache.GetValue(email);
            var my    = ProductService.MyInfo(user.Id);

            if (my == null || !my.status)
            {
                //服务不存在 或 已过期
                my = new MyProductDto();
            }
            var nodes = ServerNodeService.GetAll(my);

            ViewData["My"]    = my;
            ViewData["Nodes"] = nodes;
            return(View());
        }
Example #12
0
 public NodeController(ServerNodeService service, UserManager <VanguardUser> userManager)
 {
     _service     = service;
     _userManager = userManager;
 }