public WhenTestingTheSellin()
 {
     var ioc = new Ioc();
     var updateStrategyFactory = ioc.Resolve<IUpdateItemStrategyFactory>();
     GildedRoseConsole = new Program(updateStrategyFactory);
 }
        public WhenTestingTheQuality()
        {
            var ioc = new Ioc();
            var updateStrategyFactory = ioc.Resolve<IUpdateItemStrategyFactory>();
            GildedRoseConsole = new Program(updateStrategyFactory);
            //GildedRoseConsole.SetUpdateItemStrategyFactory(updateStrategyFactory);

        }
        //[Ninject.Inject]
        //public void SetUpdateItemStrategyFactory(IUpdateItemStrategyFactory strategyFactory)
        //{
        //    UpdateStrategyFactory = strategyFactory;
        //}

        static void Main(string[] args)
        {
            System.Console.WriteLine("OMGHAI!");

            //Do IOC using Ninject
            var ioc = new Ioc();
            var updateStrategy = ioc.Resolve<IUpdateItemStrategyFactory>();

            var app = new Program(updateStrategy)
            {
                Items = GetDefaultInventory()
            };
            //app.SetUpdateItemStrategyFactory(updateStrategy);

            app.UpdateQuality();

            System.Console.ReadKey();
        }
示例#4
0
 public void Test()
 {
     var configs = new DefaultConfigParser().ParseFile(@"C:\svn\AwishWork\Awish.Lars\trunk\Awish.Lars.Data\hyperactive.config");
     Assert.AreEqual(1, configs.Count());
     var configOptions = configs.ElementAt(0);
     Assert.AreEqual(1, configOptions.Components.Count());
     var ioc = new Ioc(@"C:\svn\AwishWork\lib", configOptions.Components);
     var type = ioc.ResolveType("Awish.Common.ActiveRecordExtensions.AwishActiveRecordGenerator, Awish.Common.ActiveRecordExtensions");
     Assert.IsNotNull(type);
 }
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var ioc = new Ioc();
            var kernel = ioc.Kernel;
            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                return kernel;
            }
            catch (Exception ex)
            {
                kernel.Dispose();
                throw new Exception("Erro ao criar o Kernel do Ninject", ex);
            }
        }
示例#6
0
        public MvxIocFixture()
        {
            Setup();

            Ioc.RegisterSingleton <IMvxMessenger>(new MvxMessengerHub());
        }
示例#7
0
        /// <summary>
        ///     主库订单确认收货
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public ServiceResult ConfirmToMaster(ConfirmInput parameter)
        {
            if (TenantContext.CurrentTenant != "master")
            {
                return(ServiceResult.Failed);
            }

            var user = Resolve <IUserService>().GetUserDetail(parameter.UserId);

            if (user == null)
            {
                return(ServiceResult.Failure("用户不存在!"));
            }

            //if (user.Detail.PayPassword != parameter.PayPassword.ToMd5HashString())
            //{
            //    return ServiceResult.Failure("支付密码不正确!");
            //}

            var orderId = parameter.EntityId.ConvertToLong();
            var order   = Resolve <IOrderService>().GetSingle(r => r.Id == orderId);

            if (order == null)
            {
                return(ServiceResult.Failure("订单不存在!"));
            }

            if (order.OrderStatus == OrderStatus.WaitingReceiptProduct)
            {
                order.OrderStatus = OrderStatus.WaitingEvaluated;
            }
            else
            {
                return(ServiceResult.Failure("商品状态不支持收货确认操作!"));
            }

            var result = Resolve <IOrderService>().Update(order);

            if (result)
            {
                var orderAction = new OrderAction {
                    Intro           = "会员已确认收货",
                    OrderId         = order.Id,
                    ActionUserId    = order.UserId,
                    OrderActionType = OrderActionType.UserConfirmOrder
                };
                Resolve <IOrderActionService>().Add(orderAction);

                order.OrderExtension = order.Extension.ToObject <OrderExtension>();
                if (TenantContext.CurrentTenant == "master" && order?.OrderExtension?.TenantOrderInfo?.OrderId > 0)
                {
                    // 收货后如果是租户订单, 同步到租户的自提
                    var tenant = Resolve <ITenantService>().GetSingle(x => x.UserId == order.UserId);
                    if (tenant != null)
                    {
                        var sql =
                            $@"SELECT o.id OrderId ,p.* FROM Shop_Order o JOIN Shop_OrderProduct od ON o.Id = od.OrderId JOIN Shop_Product p ON p.Id = od.ProductId
                             WHERE o.Id = {order.Id} AND o.OrderStatus = 4 AND o.UserId = {order.UserId}";
                        var orderProductList = Ioc.Resolve <IUserRepository>().RepositoryContext
                                               .Fetch <PickUpProductView>(sql);
                        if (orderProductList.Count > 0)
                        {
                            var apiUrl    = tenant.ServiceUrl + "/Api/PickUpProduct/AddPickUpProduct";
                            var dicHeader = new Dictionary <string, string>
                            {
                                { "zk-tenant", tenant.Sign }
                            };

                            apiUrl.Post(orderProductList.ToJsons(), dicHeader);
                        }
                    }
                }
            }

            return(ServiceResult.Success);
        }
示例#8
0
 public FieldCodeGenerator(Ioc ioc, bool explicitLayout) : base(ioc)
 {
     this.explicitLayout = explicitLayout;
 }
示例#9
0
        public IActionResult LineCallback(string code, string state, string error)
        {
            LineUser lineUser;

            try
            {
                string clientId     = config.Line.ClientId;
                string clientSecret = config.Line.ClientSecret;
                string redirectUrl  = config.Line.Callback;

                LineLoginClient lineMgr   = new LineLoginClient(clientId, clientSecret, redirectUrl);
                IUserService    userSrv   = Ioc.Get <IUserService>();
                TokenResponse   tokenData = lineMgr.GetToken(code).Result;
                if (tokenData == null)
                {
                    return(NotFound());
                }
                lineUser = lineMgr.GetLineUser(tokenData.AccessToken).Result;
                if (lineUser == null || string.IsNullOrEmpty(lineUser.UserId))
                {
                    return(Content("Error to login by Line."));
                }
                Member mem = userSrv.GetMember(lineUser.UserId);
                string accessToken;
                if (mem == null)
                {
                    mem = new Member
                    {
                        Name        = lineUser.UserId,
                        DisplayName = lineUser.DisplayName,
                        Picture     = lineUser.PictureUrl,
                        Status      = MemberStatus.Invalice,
                    };
                    bool success = userSrv.SaveMember(mem, out accessToken);
                }
                else
                {
                    accessToken = mem.AccessToken;
                    userSrv.UpdateMember(mem.Name);
                }
                if (mem.Status == MemberStatus.Invalice)
                {
                    return(Content("你沒有通過認證,請在Line上跟 unicorn 說一下。"));
                }
                if (string.IsNullOrEmpty(accessToken) == false)
                {
                    userSrv.ForceLogin(Response, accessToken, config.Login.CookieDays);
                }

                //line private
                var friendshipStatus = lineMgr.GetFriendshipStatus(tokenData.AccessToken).Result;

                if (string.IsNullOrEmpty(state) == false)
                {
                    return(Redirect(state));
                }
            }
            catch (Exception ex)
            {
                logger.Error("Line callback失敗.", ex);
                throw;
            }
            return(Content("Line: " + JsonConvert.SerializeObject(lineUser)));
            //return Content("Line User: "******" / " + friendshipStatus.FriendFlag);
        }
示例#10
0
 private void copyButton_Click(object sender, RoutedEventArgs e)
 {
     Ioc.Get <ClipboardService>().SetText(this.exception.ToString());
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiControllerFactory"/> class.
 /// </summary>
 public ApiControllerFactory()
 {
     this.container = this.container ?? Ioc.Instance;
 }
示例#12
0
 /// <summary>
 /// Angular组件服务
 /// </summary>
 /// <param name="helper">HtmlHelper</param>
 public static IUiService Angular(this IHtmlHelper helper)
 {
     return(new UiService(helper, Ioc.Create <HtmlEncoder>()));
 }
示例#13
0
        /// <summary>
        /// Responsible for executing a <see cref="ICodeRunner"/> implementation for
        /// each of the configuration sections specified in the hyperactive config file.
        /// </summary>
        public void Run()
        {
            var configParser = new DefaultConfigParser();
            var configs = configParser.ParseXml(_contentsOfConfigFile);

            foreach (IConfigurationOptions config in configs)
            {
                EnsureOutputPath(config);
                EnsureEnumOutputPath(config);

                var assemblyDirectory = String.IsNullOrEmpty(config.AssemblyDirectory) ? _assemblyDirectory : config.AssemblyDirectory;
                Log.WriteLine("AssemblyDirectory: {0}", assemblyDirectory);

                var ioc = new Ioc(assemblyDirectory, config.Components, true);

                var cfg = new CodeRunnerConfig();
                cfg.DbProvider = ioc.Get<IDbProvider>();
                if (cfg.DbProvider == null)
                {
                    if (String.IsNullOrEmpty(config.ConnectionString))
                    {
                        Log.WriteLine("It seems as though no DbProvider component was specified in the config and no connectionstring was specified.");
                        Log.WriteLine("Either define <add key=\"connectionstring\" value=\"your connection string\" /> at the root of the config node");
                        Log.WriteLine("or define a DbProvider component in the components section.");
                        continue;
                    }
                    cfg.DbProvider = new SqlServerProvider(new DbHelper(config.ConnectionString));
                }
                Log.WriteLine("DbProvider -> {0}", cfg.DbProvider.GetType().Name);
                cfg.Generator = ioc.Get<ActiveRecordGenerator>() ?? new ConfigurableActiveRecordGenerator(config);
                if (cfg.Generator.ConfigOptions == null)
                {
                    cfg.Generator.ConfigOptions = config;
                }
                Log.WriteLine("Generator -> {0}", cfg.Generator.GetType().Name);

                cfg.NameProvider = InitializeNameProvider(config, ioc);
                cfg.Generator.NameProvider = cfg.NameProvider;

                cfg.Options = config;
                cfg.Writer =
                    (path) =>
                    {
                        return new StreamWriter(path, false);
                    };
                var codeRunner = new CodeRunnerImpl(cfg);
                codeRunner.VerboseLogging = true;
                codeRunner.Execute();
            }
        }
示例#14
0
 private static void RegisterDependencies(Ioc container)
 {
     container.Register<IService, Service>();
     container.Register<IRepository, Repository>();
     container.Register<IComplexTask, ComplexTask>();
 }
示例#15
0
        /// <summary>
        ///     设置默认值
        /// </summary>
        public void SetDefault()
        {
            var list = Ioc.Resolve <IAutoConfigService>().GetList <UserLevelConfig>();

            if (list.Count == 0)
            {
                var configs = new List <UserLevelConfig>();

                var config = new UserLevelConfig {
                    Name          = "普通",
                    Price         = 0m,
                    DeliveryPrice = 0m,
                    PreferePrice  = 0m,
                    PremiumPrice  = 300m,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000001"),
                    Intro         = "笔卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "笔卡",
                    Price         = 1000m,
                    DeliveryPrice = 25m,
                    PreferePrice  = 5,
                    PremiumPrice  = 300,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000002"),
                    Intro         = "笔卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "墨卡",
                    Price         = 2680m,
                    DeliveryPrice = 30m,
                    PreferePrice  = 10,
                    PremiumPrice  = 1072,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000003"),
                    Intro         = "墨卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "纸卡",
                    Price         = 8800,
                    DeliveryPrice = 40,
                    PreferePrice  = 10,
                    PremiumPrice  = 4400,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000004"),
                    Intro         = "纸卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "砚卡",
                    Price         = 26800,
                    DeliveryPrice = 50,
                    PreferePrice  = 10,
                    PremiumPrice  = 1608,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000005"),
                    Intro         = "砚卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "合伙人",
                    Price         = 200000,
                    DeliveryPrice = 60,
                    PreferePrice  = 20,
                    PremiumPrice  = 160000,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000006"),
                    Intro         = "合伙人消费级别"
                };
                configs.Add(config);

                var autoConfig = new AutoConfig {
                    Type        = config.GetType().FullName,
                    LastUpdated = DateTime.Now,
                    Value       = JsonConvert.SerializeObject(configs)
                };
                Ioc.Resolve <IAutoConfigService>().AddOrUpdate(autoConfig);
            }

            var userGrades = Ioc.Resolve <IAutoConfigService>().GetList <UserGradeConfig>();

            if (userGrades.Count < 1)
            {
                var config = new UserGradeConfig {
                    Id        = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366000"),
                    Name      = "书生",
                    Icon      = "/wwwroot/static/images/GradeIcon/User01.png",
                    IsDefault = true
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366001"),
                    Name       = "秀才",
                    Icon       = "/wwwroot/static/images/GradeIcon/User02.png",
                    IsDefault  = false,
                    Contribute = 10
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366002"),
                    Name       = "举人",
                    Icon       = "/wwwroot/static/images/GradeIcon/User03.png",
                    IsDefault  = false,
                    Contribute = 100
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id        = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366003"),
                    Name      = "贡士",
                    Icon      = "/wwwroot/static/images/GradeIcon/User01.png",
                    IsDefault = true
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366004"),
                    Name       = "进士",
                    Icon       = "/wwwroot/static/images/GradeIcon/User02.png",
                    IsDefault  = false,
                    Contribute = 1000
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366005"),
                    Name       = "状元",
                    Icon       = "/wwwroot/static/images/GradeIcon/User03.png",
                    IsDefault  = false,
                    Contribute = 10000
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366006"),
                    Name       = "大学士",
                    Icon       = "/wwwroot/static/images/GradeIcon/User03.png",
                    IsDefault  = false,
                    Contribute = 100000
                };
                userGrades.Add(config);

                var autoConfig = new AutoConfig {
                    Type        = config.GetType().FullName,
                    LastUpdated = DateTime.Now,
                    Value       = JsonConvert.SerializeObject(userGrades)
                };
                Ioc.Resolve <IAutoConfigService>().AddOrUpdate(autoConfig);
            }
        }
示例#16
0
        /// <summary>
        ///     更新分润执行结果
        /// </summary>
        /// <param name="resultList">The result list.</param>
        public void UpdatePriceTaskResult(IEnumerable <RuleResultItem> resultList)
        {
            var sqlList         = new List <string>();
            var dbParameterList = new List <DbParameter[]>();

            var  repositoryContext = RepositoryContext;
            long shareOrderId      = 0;
            var  sql = string.Empty;

            DbParameter[] parameters = null;

            IList <long> shareUsreIds = new List <long>();

            foreach (var shareResult in resultList)
            {
                shareUsreIds.Add(shareResult.ShareUser.Id);
            }

            var shareUsreAccounts =
                Ioc.Resolve <IAccountRepository>()
                .GetAccountByUserIds(shareUsreIds);     //获取所有分润用户的资产账户

            foreach (var shareResult in resultList)
            {
                if (shareOrderId == 0)
                {
                    shareOrderId = shareResult.ShareOrder.Id;
                }

                var account = shareUsreAccounts.FirstOrDefault(r =>
                                                               r.MoneyTypeId == shareResult.MoneyTypeId && r.UserId == shareResult.ShareUser.Id);
                if (account == null)
                {
                    break;
                }

                var afterAccount = account.Amount + shareResult.Amount; //账户金额
                //更新资产
                sql =
                    "update Asset_Account set Amount=Amount+@Amount, HistoryAmount=HistoryAmount+@Amount  where MoneyTypeId=@MoneyTypeId and  UserId=@UserId";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", shareResult.ShareUser.Id),
                    repositoryContext.CreateParameter("@MoneyTypeId", shareResult.MoneyTypeId),
                    repositoryContext.CreateParameter("@Amount", shareResult.Amount)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                //更新财务记录bill表
                sql =
                    @"INSERT INTO [dbo].[Asset_Bill]([UserId],[OtherUserId] ,[EntityId] ,[Type] ,[Flow],[MoneyTypeId],[Amount],[AfterAmount],[Intro],[CreateTime])
                                                    VALUES (@UserId,@OtherUserId ,@EntityId ,@Type ,@Flow,@MoneyTypeId,@Amount,@AfterAmount,@Intro,@CreateTime)";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", shareResult.ShareUser.Id),
                    repositoryContext.CreateParameter("@OtherUserId", shareResult.OrderUser.Id),
                    repositoryContext.CreateParameter("@EntityId", shareResult.ShareOrder.Id),
                    repositoryContext.CreateParameter("@Type", Convert.ToInt16(BillActionType.FenRun)),
                    repositoryContext.CreateParameter("@Flow", Convert.ToInt16(AccountFlow.Income)),
                    repositoryContext.CreateParameter("@MoneyTypeId", shareResult.MoneyTypeId),
                    repositoryContext.CreateParameter("@Amount", shareResult.Amount),
                    repositoryContext.CreateParameter("@AfterAmount", afterAccount),
                    repositoryContext.CreateParameter("@Intro", shareResult.Intro),
                    repositoryContext.CreateParameter("@CreateTime", DateTime.Now)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                //添加分润记录
                sql =
                    @"INSERT INTO [dbo].[Share_Reward] ([UserId] ,[OrderUserId],[OrderId],[MoneyTypeId],[Amount] ,[AfterAmount],[ModuleId],[RuleId],[Intro],[CreateTime],[Status])
                             VALUES (@UserId ,@OrderUserId,@OrderId,@MoneyTypeId,@Amount ,@AfterAmount,@ModuleId,@RuleId,@Intro,@CreateTime,@Status)";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", shareResult.ShareUser.Id),
                    repositoryContext.CreateParameter("@OrderUserId", shareResult.OrderUser.Id),
                    repositoryContext.CreateParameter("@OrderId", shareResult.ShareOrder.Id),
                    repositoryContext.CreateParameter("@MoneyTypeId", shareResult.MoneyTypeId),
                    repositoryContext.CreateParameter("@Amount", shareResult.Amount),
                    repositoryContext.CreateParameter("@AfterAmount", afterAccount),
                    repositoryContext.CreateParameter("@ModuleId", shareResult.ModuleId),
                    repositoryContext.CreateParameter("@RuleId", shareResult.RuleId.ToString()),
                    repositoryContext.CreateParameter("@Intro", shareResult.Intro),
                    repositoryContext.CreateParameter("@Status", 3), // 分润状态暂时设定为成功
                    repositoryContext.CreateParameter("@CreateTime", DateTime.Now)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                // 更新货币类型的账号金额,否则多个账号增加金额时会导致账号金额一样
                shareUsreAccounts.Foreach(r => {
                    if (r.MoneyTypeId == shareResult.MoneyTypeId)
                    {
                        r.Amount += shareResult.Amount;
                    }
                });

                //添加的短信队列
                if (shareResult.SmsNotification)
                {
                    if (RegexHelper.CheckMobile(shareResult.ShareUser.Mobile) && !shareResult.SmsIntro.IsNullOrEmpty())
                    {
                        sql =
                            @"INSERT INTO [dbo].[Basic_MessageQueue] ([TemplateCode],[Mobile],[Content] ,[Parameters] ,[Status],[Message] ,[Summary],[IpAdress],[RequestTime],[SendTime])
                                VALUES (@TemplateCode,@Mobile,@Content ,@Parameters ,@Status,@Message ,@Summary,@IpAdress,@RequestTime,@SendTime)";
                        parameters = new[]
                        {
                            repositoryContext.CreateParameter("@TemplateCode", 0),
                            repositoryContext.CreateParameter("@Mobile", shareResult.ShareUser.Mobile),
                            repositoryContext.CreateParameter("@Content", shareResult.SmsIntro),
                            repositoryContext.CreateParameter("@Parameters", string.Empty),
                            repositoryContext.CreateParameter("@Status", Convert.ToInt16(MessageStatus.Pending)),
                            repositoryContext.CreateParameter("@Message", string.Empty),
                            repositoryContext.CreateParameter("@Summary", string.Empty),
                            repositoryContext.CreateParameter("@IpAdress", "127.0.0.3"),
                            repositoryContext.CreateParameter("@RequestTime", DateTime.Now),
                            repositoryContext.CreateParameter("@SendTime", DateTime.Now)
                        };
                        sqlList.Add(sql);
                        dbParameterList.Add(parameters);
                    }

                    Ioc.Resolve <IObjectCache>().Set("MessageIsAllSend_Cache", false);
                }
            }

            #region //获取得到升级点的用户,并加入升级队列

            var upgradePointsUserIds = resultList
                                       .Where(r => r.MoneyTypeId == Guid.Parse("E97CCD1E-1478-49BD-BFC7-E73A5D699006"))
                                       .Select(r => r.ShareUser.Id).ToList();
            if (upgradePointsUserIds.Count > 0)
            {
                foreach (var userId in upgradePointsUserIds)
                {
                    var taskQueue = new TaskQueue {
                        UserId   = userId,
                        ModuleId = TaskQueueModuleId.UserUpgradeByUpgradePoints,
                        Type     = TaskQueueType.Once
                    };
                    sql =
                        "INSERT INTO [dbo].[Task_TaskQueue] ([UserId]  ,[Type],[ModuleId] ,[Parameter],[ExecutionTimes] ,[ExecutionTime],[CreateTime] ,[HandleTime] ,[MaxExecutionTimes],[Status] ,[Message]) " +
                        "VALUES (@UserId  ,@Type,@ModuleId ,@Parameter,@ExecutionTimes ,@ExecutionTime,@CreateTime ,@HandleTime ,@MaxExecutionTimes,@Status ,@Message)";
                    parameters = new[]
                    {
                        repositoryContext.CreateParameter("@UserId", taskQueue.UserId),
                        repositoryContext.CreateParameter("@Type", taskQueue.Type), // 升级只需执行一次
                        repositoryContext.CreateParameter("@ModuleId", taskQueue.ModuleId),
                        repositoryContext.CreateParameter("@Parameter", taskQueue.Parameter),
                        repositoryContext.CreateParameter("@ExecutionTimes", taskQueue.ExecutionTimes),
                        repositoryContext.CreateParameter("@ExecutionTime", taskQueue.ExecutionTime),
                        repositoryContext.CreateParameter("@CreateTime", taskQueue.CreateTime),
                        repositoryContext.CreateParameter("@HandleTime", taskQueue.HandleTime),
                        repositoryContext.CreateParameter("@MaxExecutionTimes", taskQueue.MaxExecutionTimes),
                        repositoryContext.CreateParameter("@Status", taskQueue.Status),
                        repositoryContext.CreateParameter("@Message", taskQueue.Message)
                    };
                    sqlList.Add(sql);
                    dbParameterList.Add(parameters);
                }
            }

            #endregion //获取得到升级点的用户,并加入升级队列

            try {
                sql = $"select Status from Things_Trade where Id={shareOrderId}";
                //Thread.Sleep(1); // 停留1,防止重复触发
                var shareOrderStatus = repositoryContext.ExecuteScalar(sql).ConvertToInt();
                // 如果订单状态==1,在执行数据操作
                if (shareOrderStatus == 1)
                {
                    repositoryContext.ExecuteBatch(sqlList, dbParameterList);
                }
            } catch (Exception ex) {
                sql        = "update Things_Trade set Summary=@Summary ,Status=@Status ,UpdateTime=GETDATE() where Id=@Id";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@Id", shareOrderId),
                    repositoryContext.CreateParameter("@Status", Convert.ToInt16(ShareOrderStatus.Error)),
                    repositoryContext.CreateParameter("@Summary", ex.Message)
                };
                repositoryContext.ExecuteNonQuery(sql, parameters);
            }
        }
示例#17
0
 private NameProvider InitializeNameProvider(IConfigurationOptions config, Ioc ioc)
 {
     Log.WriteLine("Initializing NameProvider");
     var nameProvider = ioc.Get<NameProvider>() ?? new NameProvider();
     nameProvider.TablePrefixes.AddRange(config.OnlyTablesWithPrefix);
     nameProvider.TablePrefixes.AddRange(config.SkipTablesWithPrefix);
     nameProvider.EnumReplacements = config.EnumReplacements;
     return nameProvider;
 }
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom)
        {
            base.ShowInView(htmlView, variables, redirectedFrom);
            View.NavigationCompleted += NavigationCompletedEventHandler;
            IRepositoryStorageService repositoryService = Ioc.GetOrCreate <IRepositoryStorageService>();

            _scrollToNote = variables?.GetValueOrDefault(ControllerParameters.NoteId);

            RepositoryStorageLoadResult loadResult = repositoryService.LoadRepositoryOrDefault(out _);

            if (loadResult != RepositoryStorageLoadResult.InvalidRepository)
            {
                _viewModel = new NoteRepositoryViewModel(
                    Ioc.GetOrCreate <INavigationService>(),
                    Ioc.GetOrCreate <ILanguageService>(),
                    Ioc.GetOrCreate <ISvgIconService>(),
                    Ioc.GetOrCreate <IThemeService>(),
                    Ioc.GetOrCreate <IBaseUrlService>(),
                    Ioc.GetOrCreate <IStoryBoardService>(),
                    Ioc.GetOrCreate <IFeedbackService>(),
                    Ioc.GetOrCreate <ISettingsService>(),
                    Ioc.GetOrCreate <IEnvironmentService>(),
                    Ioc.GetOrCreate <ICryptoRandomService>(),
                    repositoryService);

                Bindings.BindCommand("NewNote", _viewModel.NewNoteCommand);
                Bindings.BindCommand("NewChecklist", _viewModel.NewChecklistCommand);
                Bindings.BindCommand("Synchronize", _viewModel.SynchronizeCommand);
                Bindings.BindCommand("ShowTransferCode", _viewModel.ShowTransferCodeCommand);
                Bindings.BindCommand("ShowRecycleBin", _viewModel.ShowRecycleBinCommand);
                Bindings.BindCommand("ShowSettings", _viewModel.ShowSettingsCommand);
                Bindings.BindCommand("ShowInfo", _viewModel.ShowInfoCommand);
                Bindings.BindCommand("OpenSafe", _viewModel.OpenSafeCommand);
                Bindings.BindCommand("CloseSafe", _viewModel.CloseSafeCommand);
                Bindings.BindCommand("ChangeSafePassword", _viewModel.ChangeSafePasswordCommand);
                Bindings.BindCommand("FilterButtonCancel", _viewModel.ClearFilterCommand);
                Bindings.BindText("TxtFilter", () => _viewModel.Filter, (value) => _viewModel.Filter = value, _viewModel, nameof(_viewModel.Filter), HtmlViewBindingMode.TwoWay);
                Bindings.BindVisibility("FilterButtonMagnifier", () => string.IsNullOrEmpty(_viewModel.Filter), _viewModel, nameof(_viewModel.FilterButtonMagnifierVisible), HtmlViewBindingMode.OneWayToView);
                Bindings.BindVisibility("FilterButtonCancel", () => !string.IsNullOrEmpty(_viewModel.Filter), _viewModel, nameof(_viewModel.FilterButtonCancelVisible), HtmlViewBindingMode.OneWayToView);
                Bindings.BindGeneric <object>(
                    NotesChangedEventHandler,
                    null,
                    null,
                    null,
                    new HtmlViewBindingViewmodelNotifier(_viewModel, "Notes"),
                    HtmlViewBindingMode.OneWayToView);
                Bindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler;

                // Load html page and content (notes)
                string html      = _viewService.GenerateHtml(_viewModel);
                string htmlNotes = _viewContentService.GenerateHtml(_viewModel);
                html = html.Replace("<ul id=\"note-repository\"></ul>", htmlNotes); // Replace node "note-repository" with content
                View.LoadHtml(html);
            }
            else
            {
                // Show error message and stop loading the application
                _stopViewModel = new StopViewModel(
                    Ioc.GetOrCreate <INavigationService>(),
                    Ioc.GetOrCreate <ILanguageService>(),
                    Ioc.GetOrCreate <ISvgIconService>(),
                    Ioc.GetOrCreate <IThemeService>(),
                    Ioc.GetOrCreate <IBaseUrlService>());
                string html = _viewStop.GenerateHtml(_stopViewModel);
                View.LoadHtml(html);
            }
        }
示例#19
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CustomerService()
 {
     Repository      = (CustomerRepository)Ioc.Get <CustomerRepository>();
     RepositoryJob   = (JobRepository)Ioc.Get <JobRepository>();
     storeRepository = (StoreRepository)Ioc.Get <StoreRepository>();
 }
 protected override void AdditionalSetup()
 {
     MockDispatcher = new BaseMvxDispatcher();
     Ioc.RegisterSingleton <IMvxViewDispatcher>(MockDispatcher);
     Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(MockDispatcher);
 }
示例#21
0
 private static void RegisterServices()
 {
     Ioc.RegisterFactory <IEnvironmentService>(() => new EnvironmentService(OperatingSystem.Windows));
     Ioc.RegisterFactory <IBaseUrlService>(() => new BaseUrlService());
     Ioc.RegisterFactory <ILanguageService>(() => new LanguageService(new LanguageServiceResourceReader(), "SilentNotes", new LanguageCodeService().GetSystemLanguageCode()));
     Ioc.RegisterFactory <ISvgIconService>(() => new SvgIconService());
     Ioc.RegisterFactory <INavigationService>(() => new NavigationService(
                                                  Ioc.GetOrCreate <IHtmlView>()));
     Ioc.RegisterFactory <INativeBrowserService>(() => new NativeBrowserService());
     Ioc.RegisterFactory <IXmlFileService>(() => new XmlFileService());
     Ioc.RegisterFactory <IVersionService>(() => new VersionService());
     Ioc.RegisterFactory <ISettingsService>(() => new SettingsService(
                                                Ioc.GetOrCreate <IXmlFileService>(),
                                                Ioc.GetOrCreate <IDataProtectionService>()));
     Ioc.RegisterFactory <IRepositoryStorageService>(() => new RepositoryStorageService(
                                                         Ioc.GetOrCreate <IXmlFileService>(),
                                                         Ioc.GetOrCreate <ILanguageService>()));
     Ioc.RegisterFactory <ICryptoRandomService>(() => new CryptoRandomService());
     Ioc.RegisterFactory <INoteRepositoryUpdater>(() => new NoteRepositoryUpdater());
     Ioc.RegisterFactory <IStoryBoardService>(() => new StoryBoardService());
     Ioc.RegisterFactory <IDataProtectionService>(() => new DataProtectionService());
     Ioc.RegisterFactory <IInternetStateService>(() => new InternetStateService());
     Ioc.RegisterFactory <IAutoSynchronizationService>(() => new AutoSynchronizationService(
                                                           Ioc.GetOrCreate <IInternetStateService>(),
                                                           Ioc.GetOrCreate <ISettingsService>(),
                                                           Ioc.GetOrCreate <IRepositoryStorageService>(),
                                                           Ioc.GetOrCreate <INavigationService>()));
     Ioc.RegisterFactory <IThemeService>(() => new ThemeService(
                                             Ioc.GetOrCreate <ISettingsService>(), Ioc.GetOrCreate <IEnvironmentService>()));
     Ioc.RegisterFactory <IFolderPickerService>(() => new FolderPickerService());
     Ioc.RegisterFactory <IFilePickerService>(() => new FilePickerService());
 }
 public GuidConstantCodeGenerator(Ioc ioc) : base(ioc)
 {
 }
示例#23
0
 private static void RegisterServicesWithMainPage(MainPage mainPage)
 {
     Ioc.RegisterFactory <IHtmlView>(() => mainPage);
     Ioc.RegisterFactory <IFeedbackService>(() => new FeedbackService(
                                                mainPage, Ioc.GetOrCreate <ILanguageService>()));
 }
示例#24
0
 protected T Resolve <T>()
     where T : IService
 {
     return(Ioc.Resolve <T>());
 }
示例#25
0
 public virtual void SynchronousIndex(string fileName, byte[] fileByte)
 {
     Ioc.Resolve <ISearchApplicationService>().SynchronousIndex(fileName, fileByte);
 }
示例#26
0
 protected ExpressionPlatformMultiCodeGeneratorBase(Ioc ioc) : base(ioc)
 {
 }
示例#27
0
 public virtual void UpdateIndexCache(string indexName)
 {
     Ioc.Resolve <ISearchApplicationService>().UpdateIndexCache(indexName);
 }
示例#28
0
        public PickersService()
        {
            this.pickers = new ObservableCollection <PickerViewModel>();
            List <Picker> storedPickers       = PickerStorage.PickerList;
            var           unmodifiedPickers   = storedPickers.Where(picker => !picker.IsModified);
            Picker        modifiedPicker      = storedPickers.FirstOrDefault(picker => picker.IsModified);
            int           modifiedPickerIndex = -1;

            Picker nonePicker = new Picker();

            nonePicker.IsNone = true;
            this.pickers.Add(new PickerViewModel(nonePicker));

            this.WhenAnyValue(x => x.SelectedPicker.DisplayNameWithStar)
            .Select(displayName =>
            {
                return(string.Format(PickerRes.PickerButtonFormat, displayName));
            })
            .ToProperty(this, x => x.PickerButtonText, out this.pickerButtonText);

            this.WhenAnyValue(x => x.SelectedPicker.Picker.UseEncodingPreset)
            .Select(useEncodingPreset =>
            {
                return(useEncodingPreset ? PickerRes.PresetDisabledForPickerToolTip : null);
            })
            .ToProperty(this, x => x.PresetDisabledToolTip, out this.presetDisabledToolTip);

            // When the picker preset changes, we need to update the selected preset.
            this.WhenAnyValue(x => x.SelectedPicker.Picker.EncodingPreset).Subscribe(pickerPreset =>
            {
                if (pickerPreset != null)
                {
                    var presetsService     = Ioc.Get <PresetsService>();
                    PresetViewModel preset = presetsService.AllPresets.FirstOrDefault(p => p.Preset.Name == pickerPreset);
                    if (preset == null)
                    {
                        preset = presetsService.AllPresets.First();
                    }

                    presetsService.SelectedPreset = preset;
                }
            });

            foreach (Picker storedPicker in unmodifiedPickers)
            {
                PickerViewModel pickerVM;
                if (modifiedPicker != null && modifiedPicker.Name == storedPicker.Name)
                {
                    modifiedPickerIndex     = this.pickers.Count;
                    pickerVM                = new PickerViewModel(modifiedPicker);
                    pickerVM.OriginalPicker = storedPicker;
                }
                else
                {
                    pickerVM = new PickerViewModel(storedPicker);
                }

                this.pickers.Add(pickerVM);
            }

            int pickerIndex;

            if (modifiedPickerIndex >= 0)
            {
                pickerIndex = modifiedPickerIndex;
            }
            else
            {
                pickerIndex = Config.LastPickerIndex;
            }

            if (pickerIndex >= this.pickers.Count)
            {
                pickerIndex = 0;
            }

            this.selectedPicker = this.pickers[pickerIndex];
        }
示例#29
0
 public virtual void RemoveIndex(string indexName)
 {
     Ioc.Resolve <ISearchApplicationService>().RemoveIndex(indexName);
 }
示例#30
0
        public EncodeDetailsWindowViewModel()
        {
            ProcessingService processingService = Ioc.Get <ProcessingService>();

            this.progressObservable = processingService.WhenAnyValue(x => x.EncodeProgress);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.OverallProgressFraction * 100)
            .ToProperty(this, x => x.OverallProgressPercent, out this.overallProgressPercent);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.TaskNumber + "/" + encodeProgress.TotalTasks)
            .ToProperty(this, x => x.TaskNumberDisplay, out this.taskNumberDisplay);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.OverallElapsedTime))
            .ToProperty(this, x => x.OverallElapsedTime, out this.overallElapsedTime);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.OverallEta))
            .ToProperty(this, x => x.OverallEta, out this.overallEta);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.FileName)
            .ToProperty(this, x => x.FileName, out this.fileName);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.FileProgressFraction * 100)
            .ToProperty(this, x => x.FileProgressPercent, out this.fileProgressPercent);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatFileSize(encodeProgress.FileSizeBytes))
            .ToProperty(this, x => x.FileSize, out this.fileSize);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.FileElapsedTime))
            .ToProperty(this, x => x.FileElapsedTime, out this.fileElapsedTime);

            this.GetPropertyWatcher(encodeProgress => Utilities.FormatTimeSpan(encodeProgress.FileEta))
            .ToProperty(this, x => x.FileEta, out this.fileEta);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.CurrentFps)
            .ToProperty(this, x => x.CurrentFps, out this.currentFps);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.AverageFps)
            .ToProperty(this, x => x.AverageFps, out this.averageFps);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.HasScanPass || encodeProgress.TwoPass)
            .ToProperty(this, x => x.ShowPassProgress, out this.showPassProgress);

            this.GetPropertyWatcher(encodeProgress => encodeProgress.PassProgressFraction * 100)
            .ToProperty(this, x => x.PassProgressPercent, out this.passProgressPercent);

            this.GetPropertyWatcher(encodeProgress =>
            {
                switch (encodeProgress.CurrentPassId)
                {
                case -1:
                    return(EncodeDetailsRes.ScanPassLabel);

                case 0:
                    return(EncodeDetailsRes.EncodePassLabel);

                case 1:
                    return(EncodeDetailsRes.FirstPassLabel);

                case 2:
                    return(EncodeDetailsRes.SecondPassLabel);

                default:
                    return(null);
                }
            }).ToProperty(this, x => x.PassProgressLabel, out this.passProgressLabel);
        }
 protected MemberCodeGeneratorBase(Ioc ioc) : base(ioc)
 {
 }
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            ResetPanels();

            TopicService   tourService    = new TopicService(Ioc.GetInstance <ITopicRepository>());
            SongService    songService    = new SongService(Ioc.GetInstance <ISongRepository>());
            SetService     setService     = new SetService(Ioc.GetInstance <ISetRepository>());
            SetSongService setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>());

            bool success         = false;
            bool compiledSuccess = true;

            if (string.IsNullOrEmpty(hdnId.Value))
            {
                Bind();
                return;
            }

            var set = (Set)setService.GetSet(new Guid(hdnId.Value));

            if (set == null)
            {
                Bind();
                return;
            }

            if (lstSongs.Items.Count <= 0)
            {
                Bind();
                return;
            }

            using (IUnitOfWork uow = TheCore.Infrastructure.UnitOfWork.Begin())
            {
                foreach (ListItem item in lstSongs.Items)
                {
                    if (!item.Selected)
                    {
                        continue;
                    }

                    var song = songService.GetSong(new Guid(item.Value));

                    if (song == null)
                    {
                        continue;
                    }

                    short?order = 1;

                    if (set.SetSongs.Count > 0)
                    {
                        order = set.SetSongs.OrderBy(x => x.Order).Last().Order;
                        order++;
                    }

                    SetSong setSong = new SetSong()
                    {
                        Album       = song.Album,
                        CreatedDate = DateTime.UtcNow,
                        SetSongId   = Guid.NewGuid(),
                        SongId      = song.SongId,
                        SongName    = song.SongName,
                        Order       = order,
                        Set         = set,
                        SetId       = set.SetId,
                        Segue       = chkSegue.Checked
                    };

                    setSongService.Save(setSong, out success);

                    compiledSuccess = compiledSuccess && success;
                }

                if (compiledSuccess)
                {
                    uow.Commit();
                    phSuccess.Visible = true;
                    phError.Visible   = false;
                }
                else
                {
                    phError.Visible   = true;
                    phSuccess.Visible = false;
                }
            }

            Bind();
        }
示例#33
0
 /// <summary>
 /// 初始化Ioc
 /// </summary>
 public static void InitIoc(Assembly assembly)
 {
     Ioc.Register(assembly, new IocConfig());
     logger.Debug("依赖注入初始化完成");
 }
示例#34
0
        /// <summary>
        ///     执行分润执行结果
        /// </summary>
        /// <param name="resultList">The result list.</param>
        public void UpdateUpgradeTaskResult(IEnumerable <UserGradeChangeResult> resultList)
        {
            var sqlList           = new List <string>();
            var dbParameterList   = new List <DbParameter[]>();
            var repositoryContext = RepositoryContext;

            IList <long> shareUsreIds = new List <long>();

            foreach (var gradeResult in resultList)
            {
                //更新等级
                var sql        = "update User_User set GradeId=@GradeId  where  Id=@Id";
                var parameters = new[]
                {
                    repositoryContext.CreateParameter("@Id", gradeResult.Result.UserId),
                    repositoryContext.CreateParameter("@GradeId", gradeResult.Result.GradeId)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                #region 添加的短信队列

                //添加的短信队列
                //if (shareResult.SmsNotification) {
                //    if (RegexHelper.CheckMobile(shareResult.ShareUser.Mobile) && !shareResult.SmsIntro.IsNullOrEmpty()) {
                //        sql = @"INSERT INTO [dbo].[Basic_MessageQueue] ([TemplateCode],[Mobile],[Content] ,[Parameters] ,[Status],[Message] ,[Summary],[IpAdress],[RequestTime],[SendTime])
                //                VALUES (@TemplateCode,@Mobile,@Content ,@Parameters ,@Status,@Message ,@Summary,@IpAdress,@RequestTime,@SendTime)";
                //        parameters = new[]
                //        {
                //            repositoryContext.CreateParameter("@TemplateCode", 0),
                //            repositoryContext.CreateParameter("@Mobile", shareResult.ShareUser.Mobile),
                //            repositoryContext.CreateParameter("@Content", shareResult.SmsIntro),
                //            repositoryContext.CreateParameter("@Parameters",string.Empty),
                //            repositoryContext.CreateParameter("@Status", Convert.ToInt16(MessageStatus.Pending)),
                //            repositoryContext.CreateParameter("@Message", string.Empty),
                //            repositoryContext.CreateParameter("@Summary", string.Empty),
                //            repositoryContext.CreateParameter("@IpAdress", "127.0.0.3"),
                //            repositoryContext.CreateParameter("@RequestTime", DateTime.Now),
                //            repositoryContext.CreateParameter("@SendTime",DateTime.Now),
                //     };
                //        sqlList.Add(sql);
                //        dbParameterList.Add(parameters);
                //    }
                //}

                #endregion 添加的短信队列

                #region 团队等级自动更新模块

                //等级触发时,添加推荐等级,间接推荐等级,团队等级自动更新
                var taskQueue = new TaskQueue {
                    UserId   = gradeResult.Result.UserId,
                    ModuleId = TaskQueueModuleId.TeamUserGradeAutoUpdate, //团队等级自动更新模块
                    Type     = TaskQueueType.Once
                };
                sql =
                    "INSERT INTO [dbo].[Task_TaskQueue] ([UserId]  ,[Type],[ModuleId] ,[Parameter],[ExecutionTimes] ,[ExecutionTime],[CreateTime] ,[HandleTime] ,[MaxExecutionTimes],[Status] ,[Message]) " +
                    "VALUES (@UserId  ,@Type,@ModuleId ,@Parameter,@ExecutionTimes ,@ExecutionTime,@CreateTime ,@HandleTime ,@MaxExecutionTimes,@Status ,@Message)";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", taskQueue.UserId),
                    repositoryContext.CreateParameter("@Type", taskQueue.Type), // 升级只需执行一次
                    repositoryContext.CreateParameter("@ModuleId", taskQueue.ModuleId),
                    repositoryContext.CreateParameter("@Parameter", taskQueue.Parameter),
                    repositoryContext.CreateParameter("@ExecutionTimes", taskQueue.ExecutionTimes),
                    repositoryContext.CreateParameter("@ExecutionTime", taskQueue.ExecutionTime),
                    repositoryContext.CreateParameter("@CreateTime", taskQueue.CreateTime),
                    repositoryContext.CreateParameter("@HandleTime", taskQueue.HandleTime),
                    repositoryContext.CreateParameter("@MaxExecutionTimes", taskQueue.MaxExecutionTimes),
                    repositoryContext.CreateParameter("@Status", taskQueue.Status),
                    repositoryContext.CreateParameter("@Message", taskQueue.Message)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                #endregion 团队等级自动更新模块

                //清除用户缓存,不然会员查看不到等级的变化
                Ioc.Resolve <IUserService>().DeleteUserCache(gradeResult.Result.UserId, gradeResult.Result.UserName);

                // 添加升级记录
                UpgradeRecord upgradeRecord = new UpgradeRecord {
                    UserId        = gradeResult.Result.UserId,
                    BeforeGradeId = gradeResult.Result.OldGradeId,
                    AfterGradeId  = gradeResult.Result.GradeId,
                    Type          = UpgradeType.UpgradePoint,
                };
                Ioc.Resolve <IUpgradeRecordService>().Add(upgradeRecord);
            }

            if (sqlList.Count > 0)
            {
                try {
                    var excuteResult = repositoryContext.ExecuteBatch(sqlList, dbParameterList);
                } catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#35
0
        public void Test_Ioc_ServicesNotConfigured()
        {
            var ioc = new Ioc();

            Assert.ThrowsException <InvalidOperationException>(() => ioc.GetService <IServiceProvider>());
        }
        /// <inheritdoc/>
        protected override void SetHtmlViewBackgroundColor(IHtmlView htmlView)
        {
            IThemeService themeService = Ioc.GetOrCreate <IThemeService>();

            htmlView.SetBackgroundColor(ColorExtensions.HexToColor(themeService.SelectedTheme.ImageTint));
        }
示例#37
0
 /// <summary>
 /// 得到App
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 protected virtual IPaylineApplicationService GetPaylineApp(PaylineType type)
 {
     return(Ioc.Resolve <IPaylineApplicationService>(string.Format("Beeant.Application.Services.Finance.I{0}PaylineApplicationService", type)));
 }
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom)
        {
            base.ShowInView(htmlView, variables, redirectedFrom);
            IRepositoryStorageService repositoryService = Ioc.GetOrCreate <IRepositoryStorageService>();

            _scrollToNote = variables?.GetValueOrDefault(ControllerParameters.NoteId);

            RepositoryStorageLoadResult loadResult = repositoryService.LoadRepositoryOrDefault(out _);

            if (loadResult != RepositoryStorageLoadResult.InvalidRepository)
            {
                _viewModel = new NoteRepositoryViewModel(
                    Ioc.GetOrCreate <INavigationService>(),
                    Ioc.GetOrCreate <ILanguageService>(),
                    Ioc.GetOrCreate <ISvgIconService>(),
                    Ioc.GetOrCreate <IThemeService>(),
                    Ioc.GetOrCreate <IBaseUrlService>(),
                    Ioc.GetOrCreate <IStoryBoardService>(),
                    Ioc.GetOrCreate <IFeedbackService>(),
                    Ioc.GetOrCreate <ISettingsService>(),
                    Ioc.GetOrCreate <IEnvironmentService>(),
                    Ioc.GetOrCreate <ICryptoRandomService>(),
                    repositoryService);

                VueBindingShortcut[] shortcuts = new[]
                {
                    new VueBindingShortcut("s", nameof(_viewModel.SynchronizeCommand))
                    {
                        Ctrl = true
                    },
                    new VueBindingShortcut("n", nameof(_viewModel.NewNoteCommand))
                    {
                        Ctrl = true
                    },
                    new VueBindingShortcut("l", nameof(_viewModel.NewChecklistCommand))
                    {
                        Ctrl = true
                    },
                    new VueBindingShortcut("r", nameof(_viewModel.ShowRecycleBinCommand))
                    {
                        Ctrl = true
                    },
                    new VueBindingShortcut("i", nameof(_viewModel.ShowInfoCommand))
                    {
                        Ctrl = true
                    },
                    new VueBindingShortcut(VueBindingShortcut.KeyHome, "ScrollToTop")
                    {
                        Ctrl = true
                    },
                    new VueBindingShortcut(VueBindingShortcut.KeyEnd, "ScrollToBottom")
                    {
                        Ctrl = true
                    },
                };
                VueBindings = new VueDataBinding(_viewModel, View, shortcuts);
                VueBindings.DeclareAdditionalVueMethod("ScrollToTop", "scrollToTop();");
                VueBindings.DeclareAdditionalVueMethod("ScrollToBottom", "scrollToBottom();");
                _viewModel.VueDataBindingScript        = VueBindings.BuildVueScript();
                VueBindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler;
                VueBindings.ViewLoadedEvent           += ViewLoadedEventHandler;
                VueBindings.StartListening();

                _viewModel.PropertyChanged += ViewmodelPropertyChangedEventHandler;

                string html = _viewService.GenerateHtml(_viewModel);
                View.LoadHtml(html);
            }
            else
            {
                // Show error message and stop loading the application
                _stopViewModel = new StopViewModel(
                    Ioc.GetOrCreate <INavigationService>(),
                    Ioc.GetOrCreate <ILanguageService>(),
                    Ioc.GetOrCreate <ISvgIconService>(),
                    Ioc.GetOrCreate <IThemeService>(),
                    Ioc.GetOrCreate <IBaseUrlService>());
                string html = _viewStop.GenerateHtml(_stopViewModel);
                View.LoadHtml(html);
            }
        }
 public SyncDataController()
 {
     service = Ioc.GetService <IAppSyncService>();
 }