Exemplo n.º 1
0
 public void MessageTest()
 {
     AppMessage target = new AppMessage(); // TODO: Initialize to an appropriate value
     string expected = "test";
     string actual;
     target.Message = expected;
     actual = target.Message;
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 处理ConfigBean
 /// </summary>
 /// <param name="name"></param>
 /// <param name="serializer"></param>
 /// <returns></returns>
 private string DoConfigBean(string name, ISerializer serializer)
 {
     var request = HttpContext.Current.Request;
     IReader reader = null;
     var tname = ContextHelper.GetCategory(name);
     switch (name)
     {
         case "files":
             reader = tname.Length > 0 ? ConfigManager.Current.GetFileReader(name) : ConfigManager.Current.GetConfigCollection("files");
             break;
         case "beans":
             reader = tname.Length > 0 ? GetConfigurationReader(request, name, tname) : ConfigManager.Current.GetConfigCollection("beans");
             break;
         default:
             reader = ConfigManager.Current.GetConfigCollection();
             break;
     }
     if (reader == null)
     {
         AppMessage app = new AppMessage();
         app.Message = "Not found action : " + tname;
         app.MsgType = "Error";
         reader = app;
     }
     return reader.Read(serializer);
 }
Exemplo n.º 3
0
        private string DoFeatureContingencyEntity(string name, ISerializer serializer)
        {

            if (name.Equals("Sync", StringComparison.CurrentCultureIgnoreCase))
            {
                if (PermissionValidate.Instance.CheckChangePermission())
                {
                    #region Sync
                    var msg = new Result();

                    if (FeatureContingency.FCManager.Current.SynFeatureContingencies())
                    {
                        msg.IsSuccess = true;
                        msg.Message = "Success";
                    }
                    else
                    {
                        msg.IsSuccess = false;
                        msg.Message = "Data synchrony fail";
                    }

                    return msg.Read(serializer);
                    #endregion
                }
                else
                {
                    var msg = new Result();
                    msg.IsSuccess = false;
                    msg.Message = "Sorry,Data synchrony fail, You doesn't have the Sync  permission.";
                    return msg.Read(serializer);
                }

            }
            else
            {

                var request = HttpContext.Current.Request;
                string action = request.QueryString[AppConst.QueryAction] ?? "";
                var bean = FeatureContingency.FCManager.Current.FeatureContingency(name);
                if (bean != null)
                {
                    switch (action.ToLowerInvariant())
                    {
                        case "change":
                            {
                                UpdateConfigBean(bean, request);
                                var menus = MenusContainer.Current.GetMenus();
                                string url = menus.Components.Where(m => m.Name == AppConst.FeatureContingencyTitle).First().Url;
                                HttpContext.Current.Response.Redirect(url);
                                HttpContext.Current.Response.End();
                            }
                            return "";
                        //return UpdateConfigBean(bean, request).Read(serializer);
                        default:
                            return bean.Read(serializer);
                    }
                }
                else
                {
                    AppMessage app = new AppMessage();
                    app.Message = "Not found action : " + name;
                    app.MsgType = "Error";
                    return app.Read(serializer);
                }

            }
        }
Exemplo n.º 4
0
 public void AppMessageConstructorTest()
 {
     AppMessage target = new AppMessage();
     Assert.IsNotNull(target);
 }
Exemplo n.º 5
0
 private AppMessage GetExceptionMessage(Exception ex)
 {
     AppMessage msg = new AppMessage();
     msg.MsgType = "Exception";
     StringBuilder sb = new StringBuilder();
     for (var e = ex; e != null; e = e.InnerException)
     {
         sb.AppendFormat("Message : {0}\r\n", e.Message);
         sb.AppendFormat("StackTrace : {0}\r\n", e.StackTrace);
     }
     msg.Message = sb.ToString();
     return msg;
 }
Exemplo n.º 6
0
 private AppMessage GetMessage(string msgs)
 {
     var msg = new AppMessage();
     msg.Message = msgs;
     msg.MsgType = "Input Error";
     return msg;
 }