예제 #1
0
        private async Task HandleClearCache()
        {
            if (await MessageBox.ConfirmAsync("Do you really want to clear server cache?"))
            {
                await MaintenanceFacade.ClearCache();

                Messenger.AddInformation("Server cache cleared.");
            }
        }
예제 #2
0
        public async Task Consume(ConsumeContext <Message> context)
        {
            //1. Get Json
            await _service.ServiceTheThing(context.Message.Value);

            dynamic jsonObject = JsonConvert.DeserializeObject(context.Message.Value);
            //var json2  = JsonConvert.DeserializeObject<string>(context.Message.Value);

            JObject o       = JObject.Parse(context.Message.Value);
            JArray  arrBody = (JArray)o["Body"];

            var msg = new WB.MESSAGE.Message();

            msg.ObjectName = jsonObject.ObjectName;
            msg.MsgAction  = jsonObject.MsgAction;

            //msg.Body = (ArrayList)jsonObject.Body;
            msg.Body = SysUtils.String2Arrray(arrBody.ToString().Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace("\"", ""), ",");

            //2.Process business
            if (jsonObject.MsgType == Constants.MSG_MNT_TYPE)
            {
                MaintenanceFacade maintenanceFacade = new MaintenanceFacade();
                maintenanceFacade.Process(ref msg);
            }
            else if (jsonObject.MsgType == Constants.MSG_MISC_TYPE)
            {
                MiscellaneousFacade miscellaneousFacade = new MiscellaneousFacade();
                miscellaneousFacade.Process(ref msg);
            }

            //3.Return
            var order = new
            {
                Value = msg.Body
            };
            var json = JsonConvert.SerializeObject(order);

            await context.RespondAsync <Message>(new
            {
                Value = $"Tra ve tu host"
                        //Value = json
            });
        }
예제 #3
0
        public async Task <string> Consume(string json)
        {
            try
            {
                dynamic jsonObject = JsonConvert.DeserializeObject(json);

                //1.genaral
                var msg = new WB.MESSAGE.Message();
                msg.ObjectName = jsonObject.ObjectName;
                msg.MsgAction  = jsonObject.MsgAction;
                try
                {
                    string modid = jsonObject.ModId;
                    if (!string.IsNullOrEmpty(modid))
                    {
                        msg.ModId = modid.Trim();
                    }
                }
                catch { }

                //2. Get body
                try
                {
                    List <ModuleFieldInfo> modfld = jsonObject.Body.ToObject <List <ModuleFieldInfo> >();
                    foreach (ModuleFieldInfo moduleFieldInfo in modfld)
                    {
                        if (!string.IsNullOrEmpty(moduleFieldInfo.Value))
                        {
                            msg.Body.Add(moduleFieldInfo.FieldName);
                            msg.Body.Add(moduleFieldInfo.Value.TrimEnd(','));

                            if (msg.ModId == null)
                            {
                                msg.ModId = moduleFieldInfo.ModuleID;
                            }
                        }
                    }
                }
                catch { }

                if (msg.Body == null || msg.Body.Count == 0)
                {
                    JObject obj     = JObject.Parse(json);
                    JArray  arrBody = (JArray)obj["Body"];
                    msg.Body = SysUtils.String2Arrray(arrBody.ToString().Replace("[", "").Replace("]", "").Replace("\r\n", "").Replace("\"", ""), ",");
                }

                //3.Process business
                if (jsonObject.MsgType == Constants.MSG_MNT_TYPE)
                {
                    MaintenanceFacade maintenanceFacade = new MaintenanceFacade();
                    maintenanceFacade.Process(ref msg);
                }
                else if (jsonObject.MsgType == Constants.MSG_MISC_TYPE)
                {
                    MiscellaneousFacade miscellaneousFacade = new MiscellaneousFacade();
                    miscellaneousFacade.Process(ref msg);
                }

                //4.Return
                var order = new {
                    Value = msg.Body
                };

                //json = JsonConvert.SerializeObject(order);
                json = JsonConvert.SerializeObject(msg.Body);
            }
            catch (RequestTimeoutException ex)
            {
                ErrorHandler.Process(ex);
            }
            catch (ErrorMessage ex)
            {
                ErrorHandler.Process(ex);
            }
            catch (Exception ex)
            {
                ErrorHandler.Process(ex);
            }

            return(json);
        }