Esempio n. 1
0
        /// <summary>
        /// 根据广告ID获取广告商品信息
        /// 根据热卖ID获取热卖商品信息
        ///
        /// (首页是广告类型、热卖推荐时,点击调用的服务,两种类型用这一个服务)
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryAdvGoodsByIdRes Any(QueryAdvGoodsByIdReq req)
        {
            var res = new QueryAdvGoodsByIdRes();

            try
            {
                var m_req = Mapper.Map <QueryAdvGoodsByIdReq, M_QueryAdvGoodsByIdReq>(req);
                var ptcp  = ServiceImpl.QueryAdvGoodsById(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.AdvGoodsModels.IsHasRow())
                {
                    res.Total          = ptcp.ReturnValue.Total;
                    res.Portrait       = ptcp.ReturnValue.Portrait;
                    res.NickName       = ptcp.ReturnValue.NickName;
                    res.AdvGoodsModels = Mapper.MapperGeneric <M_AdvGoodsModel, AdvGoodsModel>(ptcp.ReturnValue.AdvGoodsModels).ToList();
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
		public void Same_Interface_on_target_and_mixin_should_forward_to_target()
		{
			var target = new ServiceImpl();
			var mixin = new AlwaysThrowsServiceImpl();
			var proxy = generator.CreateInterfaceProxyWithTarget(typeof (IService), Type.EmptyTypes, target, MixIn(mixin)) as IService;
			Assert.DoesNotThrow(() => proxy.Sum(1, 2));
		}
Esempio n. 3
0
        /// <summary>
        /// 领取优惠劵
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public ReceiveCouponRes Any(ReceiveCouponReq req)
        {
            var res = new ReceiveCouponRes();

            try
            {
                var ptcp = ServiceImpl.ReceiveCoupon(req.UserId, req.RecSysNo);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.CouponMoney = ptcp.ReturnValue.CouponMoney;
                    res.ReceiveType = ptcp.ReturnValue.ReceiveType;
                    res.ReceiveUrl  = ptcp.ReturnValue.ReceiveUrl;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 4
0
        /// <summary>
        /// 获取首页的数据
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryIndexDataPageRes Any(QueryIndexDataPageReq req)
        {
            var res = new QueryIndexDataPageRes();

            try
            {
                var m_req = Mapper.Map <QueryIndexDataPageReq, M_QueryIndexDataPageReq>(req);
                var ptcp  = ServiceImpl.QueryIndexDataPage(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.PageDatas.IsHasRow())
                {
                    res.Total     = ptcp.ReturnValue.Total;
                    res.PageDatas = Mapper.MapperGeneric <M_IndexPageData, IndexPageData>(ptcp.ReturnValue.PageDatas).ToList();
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 5
0
        /// <summary>
        /// 广告互动领取现金红包
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public ReceiveRedRes Any(ReceiveRedReq req)
        {
            var res = new ReceiveRedRes();

            try
            {
                var ptcp = ServiceImpl.ReceiveRed(req.UserId, req.GoodsId);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.Title         = ptcp.ReturnValue.Title;
                    res.ReceiveAmount = ptcp.ReturnValue.ReceiveAmount;
                    res.SurplusCount  = ptcp.ReturnValue.SurplusCount;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 6
0
        /// <summary>
        /// 查询邀请好友(用于首页点击 DataType = 2 时的明细页面)
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryInvitingFriendsRes Any(QueryInvitingFriendsReq req)
        {
            var res = new QueryInvitingFriendsRes();

            try
            {
                var ptcp = ServiceImpl.QueryInvitingFriends(req.UserId, req.RecSysNo);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.InvitingFriends = Mapper.Map <M_InvitingFriendsModel, InvitingFriendsModel>(ptcp.ReturnValue.InvitingFriends);
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            // Create Service and add data
            ServiceImpl s = new ServiceImpl();

            s.CreateOrder(36, 4, 35, new DateTime(2018, 1, 12, 5, 10, 0), 10, "R4C877FF", 1, 92.00, 1);
            s.CreateOrder(37, 4, 243, new DateTime(2018, 2, 15, 5, 10, 0), 10, "R47077FF", 1, 43.00, 1);
            s.CreateOrder(38, 4, 35, new DateTime(2018, 1, 31, 5, 10, 0), 10, "R6453FF", 2, 120.00, 1);
            s.CreateOrder(39, 4, 35, new DateTime(2018, 1, 31, 5, 10, 0), 10, "R4C877DS", 4, 15.00, 1);
            s.CreateOrder(40, 4, 35, new DateTime(2018, 1, 31, 5, 10, 0), 10, "R4C9999F", 1, 111.00, 1);
            s.CreateOrder(41, 67, 35, new DateTime(2018, 1, 31, 5, 10, 0), 10, "R4C87S32", 1, 54.00, 1);
            s.CreateOrder(42, 4, 35, new DateTime(2018, 1, 31, 5, 10, 0), 10, "R4C87123", 1, 92.00, 1);
            s.CreateOrder(43, 4, 35, new DateTime(2018, 2, 15, 5, 10, 0), 10, "R42G77FF", 1, 40.00, 1);
            s.CreateOrder(44, 4, 35, new DateTime(2018, 1, 31, 5, 10, 0), 20, "R4002WFF", 3, 23.00, 2);
            s.CreateOrder(45, 4, 35, new DateTime(2018, 1, 31, 5, 10, 0), 20, "R400KHFF", 3, 23.00, 1);
            s.CreateOrder(46, 24, 35, new DateTime(2018, 1, 31, 5, 10, 0), 61, "R4C437FF", 1, 92.00, 1);
            s.CreateOrder(47, 121, 35, new DateTime(2018, 3, 1, 5, 10, 0), 10, "R422AQF", 1, 66.00, 2);

            // Get orders and print
            var result = s.GetOrdersByFields(36, 1, 10, new DateTime(2018, 1, 31, 5, 10, 0));

            foreach (OrderInfo orderInfo in result)
            {
                Console.WriteLine("OrderId : " + orderInfo.OrderId);
                Console.WriteLine("ShipperId : " + orderInfo.ShipperId);
                Console.WriteLine("DriverId : " + orderInfo.DriverId);
                Console.WriteLine("CompletionDate : " + orderInfo.CompletionDate);
                Console.WriteLine("Status : " + orderInfo.Status);
                Console.WriteLine("Code : " + orderInfo.Code);
                Console.WriteLine("MSA : " + orderInfo.MSA);
                Console.WriteLine("Duration : " + orderInfo.Duration);
                Console.WriteLine("OfferType : " + orderInfo.OfferType);
                Console.WriteLine("***************************");
            }
        }
        public void Same_Interface_on_target_and_additionalInterface_should_forward_to_target()
        {
            var target = new ServiceImpl();
            var proxy  = generator.CreateInterfaceProxyWithTarget(typeof(IService), new[] { typeof(IService) }, target) as IService;

            Assert.DoesNotThrow(() => proxy.Sum(1, 2));
        }
Esempio n. 9
0
        /// <summary>
        /// 根据店铺ID查询店铺信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryShopInfoRes Any(QueryShopInfoReq req)
        {
            var res = new QueryShopInfoRes();

            try
            {
                var ptcp = ServiceImpl.QueryShopInfo(req.ShopId);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.ShopInfo.IsNotNull())
                {
                    res.ShopInfo = Mapper.Map <M_ShopInfo, ShopInfo>(ptcp.ReturnValue.ShopInfo);
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 10
0
        /// <summary>
        /// 根据ID查询分享的标题
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryShareTitleRes Any(QueryShareTitleReq req)
        {
            var res = new QueryShareTitleRes();

            try
            {
                var ptcp = ServiceImpl.QueryShareTitle(req.SysNo);

                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.PageData.IsNotNull())
                {
                    res.PageData = Mapper.Map <M_HomePageData, HomePageData>(ptcp.ReturnValue.PageData);
                }
                res.DoResult = ptcp.DoResult;
            }
            catch (Exception ex)
            {
            }

            return(res);
        }
Esempio n. 11
0
        /// <summary>
        /// 获取兑换或个人账户中心未读取消息数量
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryNoReadInfoRes Any(QueryNoReadInfoReq req)
        {
            var res = new QueryNoReadInfoRes();

            try
            {
                var ptcp = ServiceImpl.QueryNoReadInfo(req.UserId);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.AccountCount = ptcp.ReturnValue.AccountCount;
                    res.ScoreCount   = ptcp.ReturnValue.ScoreCount;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
		public void Same_Interface_on_proxy_with_target_interface_and_mixin_should_forward_to_target()
		{
			var target = new ServiceImpl();
			var mixin = new AlwaysThrowsServiceImpl();
			var proxy = generator.CreateInterfaceProxyWithTargetInterface(typeof (IService), target, MixIn(mixin));
			Assert.DoesNotThrow(() => (proxy as IService).Sum(2, 2));
		}
        public static void SyncContentTable(ServiceImpl service)
        {
            if (!IsContentTable(service))
            {
                return;
            }

            var tableName = service.ContentTableName;

            var tableColumns = new List <TableColumn>();

            tableColumns.AddRange(DataProvider.ContentDao.TableColumns);
            tableColumns.AddRange(service.ContentTableColumns);

            if (!DataProvider.DatabaseDao.IsTableExists(tableName))
            {
                DataProvider.ContentDao.CreateContentTable(tableName, tableColumns);
            }
            else
            {
                DataProvider.DatabaseDao.AlterSystemTable(tableName, tableColumns, ContentAttribute.DropAttributes.Value);
            }

            ContentTableCreateOrUpdateStyles(tableName, service.ContentTableColumns);
        }
Esempio n. 14
0
 protected override void OnStart(string[] args)
 {
     // start JobConsumer
     this.FileLogger().Debug($"{ServiceName} starting");
     ServiceImpl = UnityContainer.Resolve <ServiceImpl>();
     ServiceImpl.OnStart(args);
 }
Esempio n. 15
0
        /// <summary>
        /// 会员注册
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public MemberRegisterRes Any(MemberRegisterReq req)
        {
            var res = new MemberRegisterRes();

            try
            {
                var m_req = Mapper.Map <MemberRegisterReq, M_MemberRegisterReq>(req);
                var ptcp  = ServiceImpl.MemberRegister(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.AuthorSysNo  = ptcp.ReturnValue.AuthorSysNo;
                    res.ArticleSysNo = ptcp.ReturnValue.ArticleSysNo;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }
            return(res);
        }
Esempio n. 16
0
        /// <summary>
        /// 查询会员信息
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public QueryMemberInfoRes Any(QueryMemberInfoReq req)
        {
            var res = new QueryMemberInfoRes();

            try
            {
                var m_req = Mapper.Map <QueryMemberInfoReq, M_QueryMemberInfoReq>(req);
                var ptcp  = ServiceImpl.QueryMemberInfo(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.MemberEntity.IsNotNull())
                {
                    res.MemberEntity = Mapper.Map <M_MemberEntity, MemberEntity>(ptcp.ReturnValue.MemberEntity);
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 17
0
        public static void SyncContentTable(ServiceImpl service)
        {
            if (!IsContentTable(service))
            {
                return;
            }

            var tableName = service.ContentTableName;

            if (!DataProvider.TableDao.IsExists(tableName))
            {
                ContentTableCreateMetadatas(service.Metadata, tableName, service.ContentTableColumns);
            }
            else
            {
                ContentTableUpdateMetadatas(tableName, service.ContentTableColumns);
            }

            if (!DataProvider.DatabaseDao.IsTableExists(tableName))
            {
                DataProvider.TableDao.CreateDbTable(tableName);
            }
            else
            {
                DataProvider.TableDao.SyncDbTable(tableName);
            }

            ContentTableCreateOrUpdateStyles(tableName, service.ContentTableColumns);
        }
Esempio n. 18
0
        /// <summary>
        /// 检查会员是否存在
        /// </summary>
        /// <param name="req"></param>
        /// <returns> DoFlag = true 存在,DoFlag = false 不存在 </returns>
        public CheckMemberIsExistRes Any(CheckMemberIsExistReq req)
        {
            var res = new CheckMemberIsExistRes();

            try
            {
                Ptcp <string> ptcp;
                if (req.SelectType == (int)Enums.SelectCustomer.UserId)
                {
                    ptcp = ServiceImpl.CheckMemberIsExist(Enums.SelectCustomer.UserId, req.SelectValue);
                }
                else if (req.SelectType == (int)Enums.SelectCustomer.Mobile)
                {
                    ptcp = ServiceImpl.CheckMemberIsExist(Enums.SelectCustomer.Mobile, req.SelectValue);
                }
                else
                {
                    res.DoResult = "查询类型错误";
                    return(res);
                }

                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
            public IService <A, B> Create <B>(A a)
            {
                var service = new ServiceImpl <A, B>();

                service.Initialize(a);
                return(service);
            }
Esempio n. 20
0
        /// <summary>
        /// 检查是否已经收藏了
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public CheckFavoritesRes Any(CheckFavoritesReq req)
        {
            var res = new CheckFavoritesRes();

            try
            {
                var ptcp = ServiceImpl.CheckFavorites(req.UserId, req.DataType, req.InforSysNo);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }


                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.CheckRes = ptcp.ReturnValue.CheckRes;
                }
                res.DoResult = ptcp.DoResult;
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
                res.DoFlag   = -8;
            }

            return(res);
        }
Esempio n. 21
0
        public static void SyncTable(ServiceImpl service)
        {
            if (service.DatabaseTables == null || service.DatabaseTables.Count <= 0)
            {
                return;
            }

            foreach (var tableName in service.DatabaseTables.Keys)
            {
                var tableColumns = service.DatabaseTables[tableName];
                if (tableColumns == null || tableColumns.Count == 0)
                {
                    continue;
                }

                if (!DatoryUtils.IsTableExists(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString, tableName))
                {
                    DatoryUtils.CreateTable(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString, tableName, tableColumns);
                }
                else
                {
                    DatoryUtils.AlterTable(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString, tableName, tableColumns, null);
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// 获取所有的分类信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryCategoryRes Any(QueryCategoryReq req)
        {
            var res = new QueryCategoryRes();

            try
            {
                var ptcp = ServiceImpl.QueryCategory();
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.Entities.IsHasRow())
                {
                    res.Entities = Mapper.MapperGeneric <M_CategoryEntity, CategoryEntity>(ptcp.ReturnValue.Entities).ToList();
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 23
0
        /// <summary>
        /// 获取账户的交易流水
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryAccountRecordRes Any(QueryAccountRecordReq req)
        {
            var res = new QueryAccountRecordRes();

            try
            {
                var m_req = Mapper.Map <QueryAccountRecordReq, M_QueryAccountRecordReq>(req);
                var ptcp  = ServiceImpl.QueryAccountRecord(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.Entities.IsHasRow())
                {
                    res.Entities = Mapper.MapperGeneric <M_AccountRecordEntity, AccountRecordEntity>(ptcp.ReturnValue.Entities).ToList();
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 24
0
        /// <summary>
        /// 我的抵用劵列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryMyCouponRes Any(QueryMyCouponReq req)
        {
            var res = new QueryMyCouponRes();

            try
            {
                var m_req = Mapper.Map <QueryMyCouponReq, M_QueryMyCouponReq>(req);
                var ptcp  = ServiceImpl.QueryMyCoupon(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.ExcCoupons.IsNotNull())
                {
                    res.Total      = ptcp.ReturnValue.Total;
                    res.ExcCoupons = Mapper.MapperGeneric <M_ExcCouponInfo, ExcCouponInfo>(ptcp.ReturnValue.ExcCoupons).ToList();
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
        public static void SyncTable(ServiceImpl service)
        {
            if (service.DatabaseTables == null || service.DatabaseTables.Count <= 0)
            {
                return;
            }

            foreach (var tableName in service.DatabaseTables.Keys)
            {
                var tableColumns = service.DatabaseTables[tableName];
                if (tableColumns == null || tableColumns.Count == 0)
                {
                    continue;
                }

                if (!DataProvider.DatabaseDao.IsTableExists(tableName))
                {
                    DataProvider.DatabaseDao.CreatePluginTable(service.PluginId, tableName, tableColumns);
                }
                else
                {
                    DataProvider.DatabaseDao.AlterPluginTable(service.PluginId, tableName, tableColumns);
                }
            }
        }
Esempio n. 26
0
            private static PluginInstance ActiveAndAdd(PackageMetadata metadata, Type type)
            {
                if (metadata == null || type == null)
                {
                    return(null);
                }

                if (StringUtils.EqualsIgnoreCase(metadata.Id, "SS.Home"))
                {
                    return(null);
                }

                var s = Stopwatch.StartNew();

                //var plugin = (IPlugin)Activator.CreateInstance(type);

                var plugin = (PluginBase)Activator.CreateInstance(type);

                plugin.Initialize(metadata);

                var service = new ServiceImpl(metadata);

                plugin.Startup(service);

                PluginContentTableManager.SyncContentTable(service);
                PluginDatabaseTableManager.SyncTable(service);

                return(new PluginInstance(metadata, service, plugin, s.ElapsedMilliseconds));
            }
Esempio n. 27
0
        static void Main(string[] args)
        {
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();

            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
            IDictionary props = new Hashtable();

            props["port"] = 55555;
            TcpChannel channel = new TcpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel, false);

            ClientRepository clientRepository = new ClientRepository();
            MatchRepository  matchRepository  = new MatchRepository();
            SellerRepository sellerRepository = new SellerRepository();
            TicketRepository ticketRepository = new TicketRepository();
            var server = new ServiceImpl(clientRepository, matchRepository, sellerRepository, ticketRepository);

            //var server = new ChatServerImpl();
            RemotingServices.Marshal(server, "Chat");
            //RemotingConfiguration.RegisterWellKnownServiceType(typeof(ChatServerImpl), "Chat",
            //    WellKnownObjectMode.Singleton);

            // the server will keep running until keypress.
            Console.WriteLine("Server started ...");
            Console.WriteLine("Press <enter> to exit...");
            Console.ReadLine();
        }
        public void InterfaceProxyWithTargetInterface_MethodInvocationTarget_should_be_updated_when_target_changes()
        {
            MethodInfo invocationTarget1 = null;
            MethodInfo invocationTarget2 = null;
            var        target1           = new AlwaysThrowsServiceImpl();
            var        target2           = new ServiceImpl();
            MethodInfo methodOnTarget1   = target1.GetType().GetMethod("Sum", new[] { typeof(int), typeof(int) });
            MethodInfo methodOnTarget2   = target2.GetType().GetMethod("Sum", new[] { typeof(int), typeof(int) });
            var        proxy             = generator.CreateInterfaceProxyWithTargetInterface(
                typeof(IService),
                target1,
                new WithCallbackInterceptor(i =>
            {
                invocationTarget1 = i.MethodInvocationTarget;
                i.Proceed();
            }),
                new ChangeTargetInterceptor(target2),
                new WithCallbackInterceptor(i =>
            {
                invocationTarget2 = i.MethodInvocationTarget;
                i.Proceed();
            })) as IService;

            proxy.Sum(2, 2);

            Assert.AreNotEqual(invocationTarget1, invocationTarget2);
            Assert.AreSame(methodOnTarget1, invocationTarget1);
            Assert.AreSame(methodOnTarget2, invocationTarget2);
        }
Esempio n. 29
0
        /// <summary>
        /// 查询作者下面所有的文章信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryAuthorArticleRes Any(QueryAuthorArticleReq req)
        {
            var res = new QueryAuthorArticleRes();

            try
            {
                var m_req = Mapper.Map <QueryAuthorArticleReq, M_QueryAuthorArticleReq>(req);
                var ptcp  = ServiceImpl.QueryAuthorArticle(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull() && ptcp.ReturnValue.ArticleEntities.IsNotNull() && ptcp.ReturnValue.AuthorEntity.IsNotNull())
                {
                    res.ArticleEntities = Mapper.MapperGeneric <M_ArticleEntity, ArticleEntity>(ptcp.ReturnValue.ArticleEntities).ToList();
                    res.AuthorEntity    = Mapper.Map <M_AuthorEntity, AuthorEntity>(ptcp.ReturnValue.AuthorEntity);
                    res.Total           = ptcp.ReturnValue.Total;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
Esempio n. 30
0
        /// <summary>
        /// 获取首页的红点数量
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public QueryHomePageRedDotRes Any(QueryHomePageRedDotReq req)
        {
            var res = new QueryHomePageRedDotRes();

            try
            {
                var m_req = Mapper.Map <QueryHomePageRedDotReq, M_QueryHomePageRedDotReq>(req);
                var ptcp  = ServiceImpl.QueryHomePageRedDot(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.RedCount = ptcp.ReturnValue.RedCount;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
        /// <summary>
        /// Unregisters any previously registered program index map info and registers the provided map info.
        /// </summary>
        /// <param name="programIndexMapInfo">A buffer containing the program map info to register.</param>
        /// <param name="programCount">The number of programs to register. The provided buffer must be
        /// large enough to hold this many <see cref="ProgramIndexMapInfo"/> entries.</param>
        /// <returns><see cref="Result.Success"/>: The operation was successful.<br/>
        /// <see cref="ResultFs.PermissionDenied"/>: Insufficient permissions.<br/>
        /// <see cref="ResultFs.InvalidSize"/>: The buffer was too small to hold the specified
        /// number of <see cref="ProgramIndexMapInfo"/> entries.</returns>
        public Result RegisterProgramIndexMapInfo(InBuffer programIndexMapInfo, int programCount)
        {
            // Verify the caller's permissions
            Result rc = GetProgramInfo(out ProgramInfo programInfo, ProcessId);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!programInfo.AccessControl.CanCall(OperationType.RegisterProgramIndexMapInfo))
            {
                return(ResultFs.PermissionDenied.Log());
            }

            // Return early if the program count is 0 so we leave any previously
            // registered entries as they were
            if (programCount == 0)
            {
                return(Result.Success);
            }

            // Verify that the provided buffer is large enough to hold "programCount" entries
            ReadOnlySpan <ProgramIndexMapInfo>
            mapInfo = MemoryMarshal.Cast <byte, ProgramIndexMapInfo>(programIndexMapInfo.Buffer);

            if (mapInfo.Length < programCount)
            {
                return(ResultFs.InvalidSize.Log());
            }

            // Register the map info
            return(ServiceImpl.RegisterProgramIndexMapInfo(mapInfo.Slice(0, programCount)));
        }
Esempio n. 32
0
        /// <summary>
        /// 发起支付,预下单,构建订单数据
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public CreatePaymentRes Any(CreatePaymentReq req)
        {
            var res = new CreatePaymentRes();

            try
            {
                var m_req = Mapper.Map <CreatePaymentReq, M_CreatePaymentReq>(req);
                var ptcp  = ServiceImpl.CreatePayment(m_req);
                if (ptcp.DoFlag == PtcpState.Success)
                {
                    res.DoFlag = (int)PtcpState.Success;
                }
                res.DoResult = ptcp.DoResult;

                if (ptcp.ReturnValue.IsNotNull())
                {
                    res.ApiParam = ptcp.ReturnValue.ApiParam;
                    res.OrderNo  = ptcp.ReturnValue.OrderNo;
                }
            }
            catch (Exception ex)
            {
                res.DoResult = "系统繁忙,请稍后再试";
            }

            return(res);
        }
		public void Same_Interface_on_target_of_proxy_with_target_interface_and_mixin_should_forward_to_target()
		{
			var target = new ServiceImpl();
			var mixin = new ServiceImpl();
			IInterceptor interceptor = new WithCallbackInterceptor(i=>
			                                                       	{
			                                                       		Assert.AreSame(target,i.InvocationTarget);
			                                                       		i.ReturnValue = 0;
			                                                       	});
			var proxy = generator.CreateInterfaceProxyWithTargetInterface(typeof(IService), target, MixIn(mixin),interceptor);
			Assert.DoesNotThrow(() => (proxy as IService).Sum(2, 2));
		}
		public void Same_Interface_on_target_and_additionalInterface_should_forward_to_target()
		{
			var target = new ServiceImpl();
			var proxy = generator.CreateInterfaceProxyWithTarget(typeof (IService), new[] {typeof (IService)}, target) as IService;
			Assert.DoesNotThrow(() => proxy.Sum(1, 2));
		}