Beispiel #1
0
        static void Main(string[] args)
        {
            var svr = ObjectService.GetObject <ILogService>();

            Console.WriteLine(svr.ToString());
            Console.ReadLine();
        }
Beispiel #2
0
        public ActionResult State()
        {
            var svr    = ObjectService.GetObject <PerformanceService>();
            var result = svr.GetPerformanceResult();

            return(this.Content(string.Format("|{0}|{1}|", result.ResultNo, result.ResultDescription)));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var svr = ObjectService.GetObject <IClassService>();

            Console.WriteLine(svr.HelloWorld());
            Console.ReadLine();
        }
Beispiel #4
0
        private static Binding CreateBinding(IObjectSetting setting, string url)
        {
            string bindingName = null;
            var    bc          = setting.ConfigSetting["binding"];

            if (bc != null)
            {
                bindingName = bc.Value.Value;
            }
            if (string.IsNullOrEmpty(bindingName))
            {
                var uri = new Uri(url, UriKind.Absolute);
                bindingName = uri.Scheme;
            }
            if (string.IsNullOrEmpty(bindingName))
            {
                throw new RemotingException("Binding not found");
            }
            var binding = ObjectService.GetObject <Binding>("Wcf." + bindingName);

            if (binding == null)
            {
                throw new RemotingException("Binding not found");
            }
            return(binding);
        }
Beispiel #5
0
        public ActionResult List(string id, bool query = false, int startIndex = 0, int length = 30)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(this.Content("Error Item Name"));
            }
            var svr  = ObjectService.GetObject <IDataManageService>();
            var item = svr.GetDataItem(id);

            if (item == null)
            {
                return(this.Content("Error Item"));
            }
            if (query || this.Request.HttpMethod == "POST")
            {
                var queryValues = GetDictionary(this.Request.Form);
                this.ViewBag.ItemColumns = item.GetListColumns();
                this.ViewBag.QueryValues = queryValues;
                this.ViewBag.ItemList    = item.GetList(queryValues, startIndex, length);
            }
            this.ViewBag.StartIndex   = startIndex;
            this.ViewBag.PageSize     = length;
            this.ViewBag.DataItem     = item;
            this.ViewBag.Title        = item.Title;
            this.ViewBag.QueryColumns = item.GetQueryColumns();
            return(this.View());
        }
        protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)
        {
            var authorized = base.AuthorizeCore(httpContext);

            if (authorized)
            {
                var filterContext    = (AuthorizationContext)httpContext.Items[typeof(AuthorizationContext)];
                var actionDescriptor = filterContext.ActionDescriptor;
                var ps   = actionDescriptor.GetCustomAttributes(typeof(PermissionAttribute), true) as PermissionAttribute[];
                var list = new List <IPermissionObject> {
                    this
                };
                if (ps != null && ps.Length > 0)
                {
                    list.AddRange(ps);
                }
                ps = actionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(PermissionAttribute), true) as PermissionAttribute[];
                if (ps != null && ps.Length > 0)
                {
                    list.AddRange(ps);
                }
                var svr = ObjectService.GetObject <IPermissionClientService>();
                authorized = svr.Authorize(false, list.ToArray());
            }
            return(authorized);
        }
Beispiel #7
0
        public string GetControl(Model.ControlTypes controlType, string relationName, string relationFields, string name, string value)
        {
            string html = string.Empty;

            switch (controlType)
            {
            case Model.ControlTypes.Text:
                html = string.Format("<input type='text' name='{0}' value='{1}' />", name, value);
                break;

            case Model.ControlTypes.Select:
                var svr = ObjectService.GetObject <IManageServer>();
                svr.TableName = relationName;
                var           dt     = svr.GetDataList(null, null);
                var           fields = relationFields.Split(',');
                StringBuilder select = new StringBuilder();
                select.AppendFormat("<select name='{0}'>", name);
                foreach (DataRow dr in dt.Rows)
                {
                    var selValue = dr[fields[0]].ToString();
                    var selText  = dr[fields[1]].ToString();
                    select.AppendFormat("<option {2} value='{0}'>{1}</option>", selValue, selText, selValue == value ? "selected='selected'" : string.Empty);
                }
                select.Append("</select>");
                html = select.ToString();
                break;

            default:
                html = string.Format("<input type='hidden' name='{0}' value='{1}' />", name, value);
                break;
            }

            return(html);
        }
Beispiel #8
0
        public void CorrectSubject()
        {
            var service = new ObjectService();
            var result  = service.GetObject(new List <OpenieTriple>(), new List <Token>(), SentenceType.Imperative);

            Assert.Null(result.Word);
        }
Beispiel #9
0
        public ActionResult Login(string userName, string password, string returnUrl)
        {
            if (this.Request.IsAuthenticated)
            {
                return(this.RedirectTo(returnUrl));
            }
            if (string.IsNullOrEmpty(userName))
            {
                this.ViewBag.Message = "请输入用户名";
                return(this.View());
            }
            this.ViewBag.UserName = userName;
            if (string.IsNullOrEmpty(password))
            {
                this.ViewBag.Message = "请输入密码";
                return(this.View());
            }
            var svr    = ObjectService.GetObject <IPassportServerService>();
            var result = svr.Login(this.HttpContext, userName, password, null);

            if (result.ResultNo != 0)
            {
                this.ViewBag.Message = "登录失败:" + result.ResultDescription;
                return(this.View());
            }
            return(this.RedirectTo(returnUrl));
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            try {
                throw new NotImplementedException();
            } catch { }

            /*var test = DispatchProxy.Create<ITestService, MyDispatchProxy>();
             * test.Hello("");*/
            var test = ObjectService.GetObject <ITestService>();
            var str  = test.Hello("1234");

            Console.WriteLine(str);
            var a = test.Test(10);

            Console.WriteLine(a);
            var result = test.GetEntity();

            Console.WriteLine(result.ResultAttachObject.Name);
            var entity = test.GetRawEntity();

            Console.WriteLine(entity.Name + "." + entity.Age);
            entity = test.SetRawEntity(entity);
            Console.WriteLine(entity.Name + "." + entity.Age);
            Console.ReadLine();
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            var svr = ObjectService.GetObject <IPeration>();
            var a   = svr.Add(3, 5);

            Console.WriteLine(a);
            Console.ReadKey();
        }
Beispiel #12
0
        public ActionResult Login(string returnUrl)
        {
            returnUrl = WebHelper.GetReturnUrl(returnUrl: returnUrl, uriKind: UriKind.Absolute);
            var svr      = ObjectService.GetObject <IPassportAuthentication>();
            var loginUrl = svr.Setting.LoginUrl;

            return(this.Redirect(string.Format(loginUrl, this.Server.UrlEncode(returnUrl))));
        }
Beispiel #13
0
        public ActionResult LogOn(string returnUrl)
        {
            returnUrl = WebHelper.UriCombine(this.Request.Url.GetLeftPart(UriPartial.Path), "~/Account/SignIn?returnUrl=" + this.Server.UrlEncode(returnUrl), true);
            var authService = ObjectService.GetObject <IAuthenticationService>();
            var url         = authService.GetAuthenticationUrl(this.HttpContext, returnUrl);

            return(this.Redirect(url));
        }
Beispiel #14
0
        public object CreateObject(IObjectSettingLite setting, Type objectType, string uri, params object[] parameters)
        {
            var contentType = setting.ConfigSetting.GetSetting("contentType") ?? string.Empty;
            var factory     = ObjectService.GetObject <IHttpRealProxyFactory>();
            var instance    = factory.GetProxyObject(objectType, uri, contentType);

            return(instance);
        }
        public void GetObject_Called_ReturnsObject()
        {
            _serv.Factory = _factoryMock.Object;

            IObjectModel newObj = _serv.GetObject(_someFirstName);

            Assert.Equal(_someFirstName + ", Cos", newObj.FullName);
        }
Beispiel #16
0
 public void Init(HttpApplication context)
 {
     this.currentModule = ObjectService.GetObject <HttpModuleWrapperInternal>();
     if (this.currentModule != null)
     {
         this.currentModule.Init(context);
     }
 }
Beispiel #17
0
        public DataTable GetDataList(Dictionary <string, string> search, Pager pager)
        {
            Dictionary <string, string> param;
            string sql = this.GetListSql(search, pager, out param);

            var svr = ObjectService.GetObject <IManageData>();

            return(svr.GetData(sql, param));
        }
Beispiel #18
0
        public static void PreApplicationStart()
        {
            var factory = ObjectService.GetObject <ServiceControllerFactory>();

            if (factory != null)
            {
                ControllerBuilder.Current.SetControllerFactory(factory);
            }
        }
Beispiel #19
0
 public Task StopAsync(CancellationToken cancellationToken)
 {
     if (StarterAttribute.IsEnabled <EnableRunnerAttribute>())
     {
         var host = ObjectService.GetObject <ServiceRunnerHost>();
         host.Stop();
     }
     return(Task.CompletedTask);
 }
Beispiel #20
0
        public static string SafeHtml(string html, bool allowMedia = false)
        {
            if (string.IsNullOrEmpty(html))
            {
                return(html);
            }
            var helper = ObjectService.GetObject <HtmlFilter>();

            return(helper.Filter(html, allowMedia));
        }
Beispiel #21
0
        public ActionResult Add(string name)
        {
            var svr = ObjectService.GetObject <IManageServer>();

            svr.TableName = name;
            var columns = svr.GetAddColumns();

            this.ViewBag.Columns = columns;
            return(View("~/Plugin/Joy.Admin.Extensions.dll/Joy.Admin.Extensions/DataManages.Views.Add.cshtml"));
        }
Beispiel #22
0
 private ActionResult RedirectTo(string returnUrl)
 {
     returnUrl = ControllerExtensions.GetReturnUrl(returnUrl, false);
     if (string.IsNullOrEmpty(returnUrl))
     {
         var svr = ObjectService.GetObject <IPassportAuthentication>();
         returnUrl = svr.Setting.DefaultUrl;
     }
     return(this.Redirect(returnUrl));
 }
Beispiel #23
0
        public bool UpdateData(Dictionary <string, string> options)
        {
            Dictionary <string, string> param;
            string sql = this.GetUpdateSql(options, out param);

            var svr    = ObjectService.GetObject <IManageData>();
            var result = svr.ExecuteSql(sql, param);

            return(result > 0);
        }
Beispiel #24
0
        public static IWebHostBuilder UseEsb(this IWebHostBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            var service = ObjectService.GetObject <WebHostService>();

            service.Init(builder);
            return(builder);
        }
Beispiel #25
0
        public ActionResult SignIn(string ticket)
        {
            var authService = ObjectService.GetObject <IAuthenticationService>();
            var result      = authService.Validate(this.HttpContext, ticket);

            if (result.ResultNo == 0)
            {
                return(this.Redirect(result.ResultAttachObjectEx));
            }
            return(this.Content(result.ToString()));
        }
Beispiel #26
0
        public static bool TryParseVideo(string url, out VideoItem video)
        {
            var helper = ObjectService.GetObject <VideoHelper>();

            video = null;
            if (helper == null)
            {
                return(false);
            }
            return(helper.TryGetVideoItem(url, out video));
        }
Beispiel #27
0
        protected virtual void SendMessageInternal(IEventRepository repository, EventMessage subscriber)          //主动发送消息到订阅方
        {
            if (subscriber == null || string.IsNullOrEmpty(subscriber.MessageID))
            {
                return;
            }
            IEventCallback callback;

            if (!this.callbacks.TryGetValue(subscriber, out callback))
            {
                lock (this.callbacks) {
                    if (!this.callbacks.TryGetValue(subscriber, out callback))
                    {
                        callback = ObjectService.GetObject <IEventCallback>(subscriber.MessageID);
                        if (callback != null)
                        {
                            this.callbacks.Add(subscriber, callback);
                        }
                    }
                }
            }
            if (callback == null)
            {
                this.WriteLog("无法创建回调器");
                return;
            }
            var channelId = subscriber.ChannelID;

            do
            {
                var header = repository.PopFromSubscribeQueue(channelId);
                if (header == null || header.Message == null)
                {
                    break;
                }
                var message = header.Message;
                message.ChannelID = channelId;
                header.SentCount++;
                bool sentFailed;
                try {
                    var result = callback.OnMessageReceived(message);
                    this.WriteLog("回调结果:id={0}, channel={1}, result={2}", header.MessageGuid, channelId, result);
                    sentFailed = result.ResultNo != 0;
                } catch (Exception e) {
                    this.WriteLog("回调异常:id={0}, channel={1}\r\n{2}", header.MessageGuid, channelId, e);
                    sentFailed = true;
                }
                if (sentFailed)
                {
                    this.WriteLog("回调失败 {0} 次,放弃", 1);
                }
            } while(true);
        }
Beispiel #28
0
        public ActionResult Edit(string name, string Id)
        {
            var svr = ObjectService.GetObject <IManageServer>();

            svr.TableName = name;
            var options = new Dictionary <string, string>();

            options.Add(svr.KeyField, Id);
            var dt = svr.GetDataList(options, null);

            this.ViewBag.EditColumns = svr.GetEditColumns();
            this.ViewBag.Data        = dt;

            return(View("~/Plugin/Joy.Admin.Extensions.dll/Joy.Admin.Extensions/DataManages.Views.Edit.cshtml"));
        }
Beispiel #29
0
 protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
 {
     if (controllerType != null)
     {
         var setting = requestContext.HttpContext.Items[controllerType] as ServiceControllerSetting;
         if (setting != null && setting.Initialized && setting.ContractType != null)
         {
             var instance = string.IsNullOrEmpty(setting.ServiceTypeName) ? ObjectService.GetObject(setting.ContractType) : ObjectService.GetObject(setting.ServiceTypeName);
             if (instance != null)
             {
                 return((IController)Activator.CreateInstance(controllerType, new[] { instance }));
             }
         }
     }
     return(base.GetControllerInstance(requestContext, controllerType));
 }
        public void TestMethod1()
        {
            var svr = ObjectService.GetObject <InitClass>();

            Assert.IsNotNull(svr);
            Assert.IsNotNull(svr.Setting);
            Assert.AreEqual("123456", svr.Setting.Value);
            var svr1 = ObjectService.GetObject <InitClass1>();

            Assert.IsNotNull(svr1);
            Assert.IsNotNull(svr1.Setting);
            Assert.AreEqual("1:123456", svr1.Setting.Value);
            var svr2 = ObjectService.GetObject <InitClass2>();

            Assert.IsNotNull(svr2);
            Assert.IsNotNull(svr2.Setting);
            Assert.AreEqual("2:123456", svr2.Setting.Value);
        }