示例#1
0
        public Task <Dictionary <string, object> > XmlDelAsyn(object name)
        {
            var result = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(name.ToStr().ToLower().Replace(".xml", "")))
            {
                result.Add("msg", "xml文件名填写不正确");
            }
            else
            {
                System.IO.File.Delete(name.ToStr());
                var map = BaseConfig.GetValue <SqlMap>("SqlMap", "map.json", false);
                if (map.Path.Exists(a => a.ToLower() == string.Format("map/{0}", name.ToStr().ToLower())))
                {
                    var dic = new Dictionary <string, object>();
                    map.Path.Remove("map/" + name.ToStr());
                    dic.Add("SqlMap", map);
                    var json = BaseJson.ModelToJson(dic);
                    System.IO.File.WriteAllText("map.json", json);

                    FastMap.InstanceMap();
                }

                result.Add("msg", "操作成功");
            }
            return(Task.FromResult(result));
        }
示例#2
0
        public HttpResponseMessage HelloWorld(string s)
        {
            BaseJson <string> resultMsg = new BaseJson <string> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(TestApiController), "", "测试是否连接成功-HelloWorld", () =>
            {
                if (!string.IsNullOrEmpty(s))
                {
                    //TODO Dosomething
                }
                else
                {
                    resultMsg = new BaseJson <string>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数有误。",
                        BackUrl = null
                    };
                }
            }, e =>
            {
                resultMsg = new BaseJson <string>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }
        /// <summary>
        /// 热门分类菜单查询
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage QueryArtHotMenu(ArtHotMenuParams artHotMenuParams)
        {
            BaseJson <List <HotMenuModel> > resultMsg = new BaseJson <List <HotMenuModel> > {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(GallerMangerApiController), artHotMenuParams.TryToJson(), "GallerMangerApi/QueryArtHotMenu链接成功", () =>
            {
                string[] itemName = { "A", "B", "C" };
                if (!string.IsNullOrEmpty(artHotMenuParams.ItemName))
                {
                    itemName = new string[] { artHotMenuParams.ItemName };
                }
                List <HotMenuModel> list = TKApiBLL.QueryHotMenu(itemName);
                resultMsg = new BaseJson <List <HotMenuModel> >
                {
                    Status  = (int)JsonObjectStatus.Success,
                    Data    = list,
                    Message = JsonObjectStatus.Success.GetEnumText(),
                    BackUrl = null
                };
            }, e =>
            {
                resultMsg = new BaseJson <List <HotMenuModel> >
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });
            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }
示例#4
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseExceptionHandler(error =>
            {
                error.Use(async(context, next) =>
                {
                    var contextFeature = context.Features.Get <IExceptionHandlerFeature>();
                    if (contextFeature != null)
                    {
                        BaseLog.SaveLog(contextFeature.Error.Message, "error");
                        context.Response.ContentType = "application/json;charset=utf-8";
                        context.Response.StatusCode  = 200;
                        var result = new Dictionary <string, object>();
                        result.Add("success", false);
                        result.Add("msg", contextFeature.Error.Message);
                        await context.Response.WriteAsync(BaseJson.ModelToJson(result));
                    }
                });
            });

            app.UseStaticFiles();
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
示例#5
0
        public IActionResult Del(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(Json(new { msg = "xml文件名不能为空" }));
            }
            else if (string.IsNullOrEmpty(name.ToLower().Replace(".xml", "")))
            {
                return(Json(new { msg = "xml文件名填写不正确" }));
            }
            else
            {
                var xmlPath = string.Format("map/{0}", name);
                System.IO.File.Delete(xmlPath);

                var map = BaseConfig.GetValue <SqlMap>("SqlMap", "map.json");
                if (map.Path.Exists(a => a.ToLower() == string.Format("map/{0}", name.ToLower())))
                {
                    var dic = new Dictionary <string, object>();
                    map.Path.Remove("map/" + name);
                    dic.Add("SqlMap", map);
                    var json = BaseJson.ModelToJson(dic);
                    System.IO.File.WriteAllText("map.json", json);

                    FastMap.InstanceMap();
                }

                return(Json(new { msg = "操作成功" }));
            }
        }
示例#6
0
        /// <summary>
        /// 验证token
        /// </summary>
        /// <param name="item"></param>
        /// <param name="context"></param>
        private static bool CheckToken(ApiGatewayUrl item, HttpContext context, DataContext db, string urlParam)
        {
            var dic   = new Dictionary <string, object>();
            var token = GetUrlParamKey(urlParam, "token");

            if (FastRead.Query <ApiGatewayUser>(a => a.AccessToken.ToUpper() == token.ToUpper()).ToCount(db) == 0)
            {
                context.Response.StatusCode = 200;
                dic.Add("success", false);
                dic.Add("result", "token不存在");
                context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                return(false);
            }
            else
            {
                var tokenInfo = FastRead.Query <ApiGatewayUser>(a => a.AccessToken.ToUpper() == token.ToUpper()).ToItem <ApiGatewayUser>(db);
                if (DateTime.Compare(tokenInfo.AccessExpires, DateTime.Now) < 0)
                {
                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", "token过期");
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }

                if (tokenInfo.Ip != GetClientIp(context))
                {
                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", "token授权ip地址异常");
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }

                if (tokenInfo.Power.IndexOf(',') > 0)
                {
                    foreach (var temp in tokenInfo.Power.Split(','))
                    {
                        if (temp.ToLower() == item.Key.ToLower())
                        {
                            return(true);
                        }
                    }

                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", string.Format("{0}没有权限访问", item.Key));
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }
                else
                {
                    context.Response.StatusCode = 200;
                    dic.Add("success", false);
                    dic.Add("result", string.Format("{0}没有权限访问", item.Key));
                    context.Response.WriteAsync(BaseJson.ModelToJson(dic), Encoding.UTF8);
                    return(false);
                }
            }
        }
示例#7
0
        public IActionResult OnPostDel(DelParam item)
        {
            var result = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(item.name.ToLower().Replace(".xml", "")))
            {
                result.Add("msg", "xml文件名填写不正确");
            }
            else
            {
                System.IO.File.Delete(item.name);

                var map = BaseConfig.GetValue <SqlMap>("SqlMap", FastApiExtension.config.mapFile, false);
                if (!map.Path.Exists(a => string.Compare(a, item.name) == 0))
                {
                    var dic = new Dictionary <string, object>();
                    map.Path.Remove(item.name);
                    dic.Add("SqlMap", map);
                    var json = BaseJson.ModelToJson(dic);
                    System.IO.File.WriteAllText(FastApiExtension.config.mapFile, json);

                    FastMap.InstanceMap();
                }

                result.Add("msg", "操作成功");
            }
            return(new JsonResult(result));
        }
示例#8
0
        /// <summary>
        /// 缓存结果
        /// </summary>
        /// <param name="info"></param>
        /// <param name="item"></param>
        private static void CacheResult(ApiGatewayUrl item, DataContext db, ReturnModel info = null, Dictionary <string, object> dic = null)
        {
            var model = new ApiGatewayCache();

            model.Key     = item.Key.ToLower();
            model.TimeOut = DateTime.Now.AddDays(item.CacheTimeOut.ToStr().ToDouble(0)).AddHours(8);

            if (info != null)
            {
                model.result = BaseJson.ModelToJson(info.msg);
            }

            if (dic != null)
            {
                model.result = BaseJson.ModelToJson(dic);
            }

            if (FastRead.Query <ApiGatewayCache>(a => a.Key.ToUpper() == model.Key.ToUpper()).ToCount(db) <= 0)
            {
                FastWrite.Add(model);
            }
            else
            {
                FastWrite.Update <ApiGatewayCache>(model, a => a.Key.ToUpper() == model.Key.ToUpper(), a => new { a.result, a.TimeOut }, db);
            }
        }
示例#9
0
        public IActionResult Del(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(Json(new { msg = "xml文件名不能为空" }));
            }
            else if (string.IsNullOrEmpty(name.ToLower().Replace(".xml", "")))
            {
                return(Json(new { msg = "xml文件名填写不正确" }));
            }
            else
            {
                System.IO.File.Delete(name);

                var map = BaseConfig.GetValue <SqlMap>("SqlMap", FastApiExtension.config.mapFile);
                if (!map.Path.Exists(a => string.Compare(a, name) == 0))
                {
                    var dic = new Dictionary <string, object>();
                    map.Path.Remove(name);
                    dic.Add("SqlMap", map);
                    var json = BaseJson.ModelToJson(dic);
                    System.IO.File.WriteAllText(FastApiExtension.config.mapFile, json);

                    FastMap.InstanceMap();
                }

                return(Json(new { msg = "操作成功" }));
            }
        }
示例#10
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseExceptionHandler(error =>
            {
                error.Use(async(context, next) =>
                {
                    var contextFeature = context.Features.Get <IExceptionHandlerFeature>();
                    if (contextFeature != null)
                    {
                        BaseLog.SaveLog(contextFeature.Error.Message, "error");
                        context.Response.ContentType = "application/json;charset=utf-8";
                        context.Response.StatusCode  = 200;
                        var result = new Dictionary <string, object>();
                        result.Add("success", false);
                        result.Add("msg", contextFeature.Error.Message);
                        await context.Response.WriteAsync(BaseJson.ModelToJson(result));
                    }
                });
            });

            app.UseStaticFiles();
            app.UseMiddleware <FastApiHandler>();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{action=index}/{id?}");
            });
        }
示例#11
0
        public HttpResponseMessage GetSystemNotice(BaseParameterEntity arg)
        {
            BaseJson <string> resultMsg = new BaseJson <string> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(CommonController), arg.TryToJson(), "获取系统公告-GetSystemNotice", () =>
            {
                if (!string.IsNullOrEmpty(arg.t))
                {
                    if (arg.t.CheckTimeStamp())
                    {
                        resultMsg = new BaseJson <string>
                        {
                            Status  = (int)JsonObjectStatus.Success,
                            Data    = null,
                            Message = JsonObjectStatus.Success.GetEnumText(),
                            BackUrl = null
                        };
                    }
                    else
                    {
                        resultMsg = new BaseJson <string>
                        {
                            Status  = (int)JsonObjectStatus.Fail,
                            Data    = null,
                            Message = JsonObjectStatus.Fail.GetEnumText() + ",无效参数。",
                            BackUrl = null
                        };
                    }
                }
                else
                {
                    resultMsg = new BaseJson <string>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数为空。",
                        BackUrl = null
                    };
                }
            }, e =>
            {
                resultMsg = new BaseJson <string>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }
示例#12
0
        public IActionResult OnPostXml(SaveParam item)
        {
            var result = new Dictionary <string, object>();

            try
            {
                if (string.IsNullOrEmpty(item.name.ToLower().Replace(".xml", "")))
                {
                    result.Add("msg", "xml文件名填写不正确");
                    result.Add("Issuccess", false);
                }
                else
                {
                    var xmlPath = string.Format("map/{0}", item.name);
                    using (var xmlWrite = System.IO.File.Create(xmlPath))
                    {
                        xmlWrite.Write(Encoding.Default.GetBytes(item.xml));
                    }

                    if (IFast.CheckMap(xmlPath))
                    {
                        var map = BaseConfig.GetValue <SqlMap>("SqlMap", "map.json");

                        if (!map.Path.Exists(a => a.ToLower() == string.Format("map/{0}", item.name.ToLower())))
                        {
                            var dic = new Dictionary <string, object>();
                            map.Path.Add(string.Format("map/{0}", item.name));
                            dic.Add("SqlMap", map);
                            var json = BaseJson.ModelToJson(dic);
                            System.IO.File.WriteAllText("map.json", json);
                        }

                        FastMap.InstanceMap();
                        result.Add("msg", "操作成功");
                        result.Add("Issuccess", true);
                    }
                    else
                    {
                        result.Add("msg", "操作失败");
                        result.Add("Issuccess", false);
                    }
                }
                return(new JsonResult(result));
            }
            catch (Exception ex)
            {
                BaseLog.SaveLog(ex.StackTrace, "xml");
                result.Add("msg", ex.Message);
                result.Add("Issuccess", false);
                return(new JsonResult(result));
            }
        }
示例#13
0
        public Task <Dictionary <string, object> > XmlSaveAsyn(object name, object xml)
        {
            var IFast  = ServiceContext.Engine.Resolve <IFastRepository>();
            var result = new Dictionary <string, object>();

            try
            {
                if (string.IsNullOrEmpty(name.ToStr().ToLower().Replace(".xml", "")))
                {
                    result.Add("msg", "xml文件名填写不正确");
                    result.Add("Issuccess", false);
                }
                else
                {
                    using (var xmlWrite = System.IO.File.Create(name.ToStr()))
                    {
                        xmlWrite.Write(Encoding.Default.GetBytes(xml.ToStr()));
                    }

                    if (IFast.CheckMap(name.ToStr()))
                    {
                        var map = BaseConfig.GetValue <SqlMap>("SqlMap", "map.json", false);

                        if (!map.Path.Exists(a => a.ToLower() == string.Format("map/{0}", name.ToStr().ToLower())))
                        {
                            var dic = new Dictionary <string, object>();
                            map.Path.Add(string.Format("map/{0}", name.ToStr()));
                            dic.Add("SqlMap", map);
                            var json = BaseJson.ModelToJson(dic);
                            System.IO.File.WriteAllText("map.json", json);
                        }

                        FastMap.InstanceMap();
                        result.Add("msg", "操作成功");
                        result.Add("Issuccess", true);
                    }
                    else
                    {
                        result.Add("msg", "操作失败");
                        result.Add("Issuccess", false);
                    }
                }
                return(Task.FromResult(result));
            }
            catch (Exception ex)
            {
                BaseLog.SaveLog(ex.StackTrace, "xml");
                result.Add("msg", ex.Message);
                result.Add("Issuccess", false);
                return(Task.FromResult(result));
            }
        }
示例#14
0
        public HttpResponseMessage RemoveCacheByKey(string type)
        {
            BaseJson <string> resultMsg = new BaseJson <string> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(CommonController), type, "根据key清除缓存-RemoveCacheByKey", () =>
            {
                if (!string.IsNullOrEmpty(type))
                {
                    //Cache.Factory.CacheFactory.Cache().RemoveCache(type);

                    //转换成系统枚举
                    bool isSucc = Enum.TryParse(type, false, out SCCLottery which);
                    Cache.Factory.CacheFactory.Cache().RemoveCache(isSucc ? which.ToString() : type);

                    resultMsg = new BaseJson <string>
                    {
                        Status  = (int)JsonObjectStatus.Success,
                        Data    = null,
                        Message = JsonObjectStatus.Success.GetEnumText(),
                        BackUrl = null
                    };
                }
                else
                {
                    resultMsg = new BaseJson <string>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数type为空。",
                        BackUrl = null
                    };
                }
            }, e =>
            {
                resultMsg = new BaseJson <string>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };

                //如果发生异常,则清除全部缓存
                //Cache.Factory.CacheFactory.Cache().RemoveCache();
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }
示例#15
0
        /// <summary>
        /// tvps
        /// </summary>
        /// <param name="cmd"></param>
        public static void InitTvps(DbCommand cmd, string TableName)
        {
            var sql = new StringBuilder();

            cmd.CommandText = string.Format("select a.name,(select top 1 name from sys.systypes c where a.xtype=c.xtype) as type,length,isnullable,prec,scale from syscolumns a where a.id=object_id('{0}') order by a.colid asc", TableName);
            var dr  = cmd.ExecuteReader();
            var dic = BaseJson.DataReaderToDic(dr);

            dr.Close();

            sql.AppendFormat("if not exists(SELECT 1 FROM sys.table_types where name='{0}')", TableName);
            sql.AppendFormat("CREATE TYPE {0} AS TABLE(", TableName);

            foreach (var item in dic)
            {
                switch (item.GetValue("type").ToStr())
                {
                case "char":
                case "nchar":
                case "varchar":
                case "nvarchar":
                case "varchar2":
                case "nvarchar2":
                    sql.AppendFormat("[{0}] [{1}]({2}) {3},", item.GetValue("name"), item.GetValue("type"), item.GetValue("length"), item.GetValue("isnullable").ToStr() == "1" ? "NULL" : "NOT NULL");
                    break;

                case "decimal":
                case "numeric":
                case "number":
                    if (item.GetValue("prec").ToStr() == "0" && item.GetValue("scale").ToStr() == "0")
                    {
                        sql.AppendFormat("[{0}] [{1}] {2},", item.GetValue("name"), item.GetValue("type"), item.GetValue("isnullable").ToStr() == "1" ? "NULL" : "NOT NULL");
                    }
                    else
                    {
                        sql.AppendFormat("[{0}] [{1}]({2},{3}) {4},", item.GetValue("name"), item.GetValue("type"), item.GetValue("prec"), item.GetValue("scale"), item.GetValue("isnullable").ToStr() == "1" ? "NULL" : "NOT NULL");
                    }
                    break;

                default:
                    sql.AppendFormat("[{0}] [{1}] {2},", item.GetValue("name"), item.GetValue("type"), item.GetValue("isnullable").ToStr() == "1" ? "NULL" : "NOT NULL");
                    break;
                }
            }

            sql.Append(")").Replace(",)", ")");
            cmd.CommandText = sql.ToString();
            cmd.ExecuteNonQuery();
        }
示例#16
0
        /// <summary>
        /// 获取基础配置
        /// </summary>
        /// <returns></returns>
        public static BaseJson GetBaseJsonConfig()
        {
            string dirPath = GetDllRoot() + "BaseJson.txt";

            if (File.Exists(dirPath))
            {
                MyJsonUtil <BaseJson> myJsonUtil = new MyJsonUtil <BaseJson>();
                BaseJson baseJson = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath));
                return(baseJson);
            }
            else
            {
                return(new BaseJson());
            }
        }
示例#17
0
        public IActionResult Xml(string xml, string name)
        {
            try
            {
                if (string.IsNullOrEmpty(xml) || string.IsNullOrEmpty(name))
                {
                    return(Json(new { msg = "xml或文件名不能为空", Issuccess = false }));
                }
                else if (string.IsNullOrEmpty(name.ToLower().Replace(".xml", "")))
                {
                    return(Json(new { msg = "xml文件名填写不正确", Issuccess = false }));
                }
                else
                {
                    var xmlPath = string.Format("map/{0}", name);
                    using (var xmlWrite = System.IO.File.Create(xmlPath))
                    {
                        xmlWrite.Write(Encoding.Default.GetBytes(xml));
                    }

                    if (IFast.CheckMap(xmlPath))
                    {
                        var map = BaseConfig.GetValue <SqlMap>("SqlMap", "map.json");

                        if (!map.Path.Exists(a => a.ToLower() == string.Format("map/{0}", name.ToLower())))
                        {
                            var dic = new Dictionary <string, object>();
                            map.Path.Add(string.Format("map/{0}", name));
                            dic.Add("SqlMap", map);
                            var json = BaseJson.ModelToJson(dic);
                            System.IO.File.WriteAllText("map.json", json);
                        }

                        FastMap.InstanceMap();
                        return(Json(new { msg = "操作成功", Issuccess = true }));
                    }
                    else
                    {
                        return(Json(new { msg = "操作失败", Issuccess = false }));
                    }
                }
            }
            catch (Exception ex)
            {
                BaseLog.SaveLog(ex.StackTrace, "xml");
                return(Json(new { msg = ex.Message, Issuccess = false }));
            }
        }
示例#18
0
        public static TalkData FromJson(MeChat meChat, string toId, BaseJson <TalkJson> json)
        {
            var v = new TalkData()
            {
                ToId = toId
            };
            var cs = new List <Cell>();

            foreach (TalkJson t in json.data)
            {
                cs.Add(GetCell(t, meChat.Config.Id));
            }

            v.cells = cs;
            return(v);
        }
        /// <summary>
        /// 返回到客户端的消息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="statusCode"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private Task <HttpResponseMessage> CreateResponse(HttpRequestMessage request, HttpStatusCode statusCode, string message)
        {
            BaseJson <string> resultMsg = new BaseJson <string> {
                Status = (int)JsonObjectStatus.Fail, Message = message, Data = null
            };

            TaskCompletionSource <HttpResponseMessage> tsc = new TaskCompletionSource <HttpResponseMessage>();

            HttpResponseMessage response = resultMsg.TryToJson().ToHttpResponseMessage();

            //request.CreateResponse(statusCode);
            //response.ReasonPhrase = message;

            tsc.SetResult(response);
            return(tsc.Task);
        }
示例#20
0
        private static void DoCommand3()
        {
            string data;

            byte[] bytes = new byte[256];
            int    i;

            while ((i = ListeningStream.Read(bytes, 0, bytes.Length)) != 0)
            {
                data = Encoding.ASCII.GetString(bytes, 0, i);

                BaseJson <SlotViewJson> JSON = new BaseJson <SlotViewJson>();
                SlotViewModel.SlotJson = JSON.Deserializer(data);
                return;
            }
        }
示例#21
0
        //添加处理
        private void handleConnected(string text)
        {
            DuelistInfo duelistInfo = new DuelistInfo();

            duelistInfo.name = "星瓜";
            //duelistInfo.cardBack = BitmapImagehandle.BitmapImageToByteArray(DuelOperate.getInstance().myself.cardback);
            String contentJson = JsonConvert.SerializeObject(duelistInfo);

            BaseJson bj = new BaseJson();

            bj.guid   = Guid.NewGuid();
            bj.cid    = "";
            bj.action = ActionCommand.GAME_SET_DUELST_INFO;
            bj.json   = contentJson;

            String json = JsonConvert.SerializeObject(bj);

            sendMsg(json);
            //conteneJson



            ////传送己方设定的玩家名字
            //sendMsg(DuelOperate.getInstance().sendmyself());
            ////sendMsg("2," + mainwindow.tb_Duelist.Text + "," + "-1");

            ////如果存在卡背则传送卡背
            //string path = AppConfigOperate.getInstance().Custom_path+"\\cardback0.jpg";
            ////BitmapImage cardback = DuelOperate.getInstance().myself.cardback.CloneCurrentValue();
            //if (System.IO.File.Exists(path))
            //{
            //    try
            //    {
            //        BitmapImage cardback = BitmapImagehandle.GetBitmapImage(path);
            //        sendMsg(BitmapImagehandle.BitmapImageToByteArray(cardback));
            //    }
            //    catch (ArgumentNullException ex)
            //    {
            //        throw ex;
            //    }
            //    finally
            //    {

            //    }
            //}
        }
示例#22
0
        private void DoCommand5()
        {
            string data;

            byte[] bytes = new byte[256];
            int    i;

            while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
            {
                data = Encoding.ASCII.GetString(bytes, 0, i);
                Console.WriteLine("{1}: Received: {0}", data, Thread.CurrentThread.Name);
                BaseJson <MenuViewJson> JSON = new BaseJson <MenuViewJson>();

                Server.GameBoard.MenuSon = JSON.Deserializer(data);
                return;
            }
        }
示例#23
0
        private static void DoCommand1()
        {
            string data;

            byte[] bytes = new byte[256];
            int    i;

            while ((i = ListeningStream.Read(bytes, 0, bytes.Length)) != 0)
            {
                data = Encoding.ASCII.GetString(bytes, 0, i);
                BaseJson <MsgViewJson> JSON     = new BaseJson <MsgViewJson>();
                MsgViewJson            _CopySon = MsgViewModel.MsgSon;
                MsgViewJson            _MsgSon  = JSON.Deserializer(data);
                _CopySon.Nick       = _MsgSon.Nick;
                MsgViewModel.MsgSon = _CopySon;
                return;
            }
        }
示例#24
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            if (actionContext.Request.RequestUri.Scheme != Uri.UriSchemeHttps)
            {
                BaseJson <string> resultMsg = new BaseJson <string>
                {
                    Status  = (int)JsonObjectStatus.HttpRequestError,
                    Message = "请求不合法,请求地址:" + actionContext.Request.RequestUri + "必须是Https请求。",
                    Data    = ""
                };

                actionContext.Response = resultMsg.ToJson().ToHttpResponseMessage();
                base.OnAuthorization(actionContext);
            }
            else
            {
                base.OnAuthorization(actionContext);
            }
        }
示例#25
0
 /// <summary>
 /// 获取值 item asy
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="key">键</param>
 /// <returns></returns>
 public static async Task <T> GetAsy <T>(string key, int db = 0) where T : class, new()
 {
     try
     {
         db = db == 0 ? _db : db;
         if (string.IsNullOrEmpty(key))
         {
             return(new T());
         }
         else
         {
             return(BaseJson.JsonToModel <T>(await Context.GetDatabase(db).StringGetAsync(key).ConfigureAwait(false)) ?? new T());
         }
     }
     catch (RedisException ex)
     {
         SaveLog <T>(ex, "Get<T>");
         return(new T());
     }
 }
示例#26
0
 /// <summary>
 /// 获取值 item
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="key">键</param>
 /// <returns></returns>
 public static T Get <T>(string key, int db = 0) where T : class, new()
 {
     try
     {
         db = db == 0 ? _db : db;
         if (string.IsNullOrEmpty(key))
         {
             return(new T());
         }
         else
         {
             return(BaseJson.JsonToModel <T>(Context.GetDatabase(db).StringGet(key)) ?? new T());
         }
     }
     catch (RedisException ex)
     {
         SaveLog <T>(ex, "Get<T>");
         return(new T());
     }
 }
示例#27
0
 /// <summary>
 /// 设置值 item asy
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="key">键</param>
 /// <param name="model">值</param>
 /// <param name="hours">存期限</param>
 /// <returns></returns>
 public static async Task <bool> SetAsy <T>(string key, T model, int hours = 24 * 30 * 12, int db = 0)
 {
     try
     {
         db = db == 0 ? _db : db;
         if (!string.IsNullOrEmpty(key))
         {
             return(await Context.GetDatabase(db).StringSetAsync(key, BaseJson.ModelToJson(model), TimeSpan.FromHours(hours)).ConfigureAwait(false));
         }
         else
         {
             return(false);
         }
     }
     catch (RedisException ex)
     {
         SaveLog <T>(ex, "Set<T>");
         return(false);
     }
 }
示例#28
0
        private void Click_Start(object sender, RoutedEventArgs e)
        {
            MenuViewJson MenuCopy = MenuViewModel.MainMenu;

            if (MainWindow.PlayerName == SlotViewModel.SlotJson.Left.Nick)
            {
                MenuCopy.LeftPlayer.Accept = true;
            }
            else if (MainWindow.PlayerName == SlotViewModel.SlotJson.Right.Nick)
            {
                MenuCopy.RightPlayer.Accept = true;
            }
            MenuViewModel.MainMenu = MenuCopy;

            BaseJson <MenuViewJson> JSON = new BaseJson <MenuViewJson>();

            string msg = JSON.Serializer(MenuViewModel.MainMenu);

            CoreClientConnect.ConnCommand(5, msg);
        }
示例#29
0
 /// <summary>
 /// 设置值 item
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="key">键</param>
 /// <param name="model">值</param>
 /// <param name="hours">存期限</param>
 /// <returns></returns>
 public static bool Set <T>(string key, T model, TimeSpan timeSpan, int db = 0)
 {
     try
     {
         db = db == 0 ? _db : db;
         if (!string.IsNullOrEmpty(key))
         {
             return(Context.GetDatabase(db).StringSet(key, BaseJson.ModelToJson(model), timeSpan));
         }
         else
         {
             return(false);
         }
     }
     catch (RedisException ex)
     {
         SaveLog <T>(ex, "Set<T>");
         return(false);
     }
 }
        public HttpResponseMessage QueryArtInfo(ArtInfoParams artInfoParams)
        {
            BaseJson <ImageInfoModel> resultMsg = new BaseJson <ImageInfoModel> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(GallerMangerApiController), artInfoParams.TryToJson(), "GallerMangerApi/QueryArtInfo链接成功", () =>
            {
                if (string.IsNullOrEmpty(artInfoParams.GalleryId) && string.IsNullOrEmpty(artInfoParams.ID) && string.IsNullOrEmpty(artInfoParams.PeriodsNumber))
                {
                    resultMsg = new BaseJson <ImageInfoModel>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + "GallerMangerApi/QueryArtInfo参数错误: ",
                        BackUrl = null
                    };
                }
                ImageInfoModel data = TKApiBLL.QueryArtInfo(artInfoParams);
                resultMsg           = new BaseJson <ImageInfoModel>
                {
                    Status  = (int)JsonObjectStatus.Success,
                    Data    = data,
                    Message = JsonObjectStatus.Success.GetEnumText(),
                    BackUrl = null
                };
            }, e =>
            {
                resultMsg = new BaseJson <ImageInfoModel>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }