当前位置: 首页>>代码示例>>C#>>正文


C# CommandManager.Create方法代码示例

本文整理汇总了C#中CommandManager.Create方法的典型用法代码示例。如果您正苦于以下问题:C# CommandManager.Create方法的具体用法?C# CommandManager.Create怎么用?C# CommandManager.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandManager的用法示例。


在下文中一共展示了CommandManager.Create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT");
            var endpoint = new IPEndPoint(IPAddress.Loopback, 1113);
            var esCon = EventStoreConnection.Create(endpoint);
            esCon.Connect();

            var credentials = new EventStore.ClientAPI.SystemData.UserCredentials("admin", "changeit");

            var cm = new CommandManager(esCon);
            var pm = new MyBudget.Projections.ProjectionManager(endpoint, credentials, new MyBudget.Infrastructure.EventStoreAdapter(endpoint, credentials));
            pm.Run();

            var tu = pm.GetUsersList().AllUsers();
            tu.Wait();
            userId = tu.Result.Select(s => s.Id).FirstOrDefault();
            budgetId = pm.GetBudgetsList().GetBudgetsUserCanView(new MyBudget.Domain.Users.UserId(userId)).Select(s => s.Id).FirstOrDefault();

            using (var con = new System.Data.SqlClient.SqlConnection(_cs))
            {
                con.Open();
                var movements = LoadMovements(con);

                foreach (var anno in movements.GroupBy(g=> g.DateTime.Year))
                {
                    
                    var str = ServiceStack.Text.CsvSerializer.SerializeToCsv(anno.OrderBy(d=> d.DateTime));
                    System.IO.File.WriteAllText(@"c:\temp\Year_"+anno.Key + ".csv", str);
                }
                var importer = new ImportManager(cm, pm);
                importer.ImportCategoriesByName(movements.Select(s => s.Category), budgetId, userId);

                var categories = pm.GetCategories().GetBudgetsCategories(budgetId);

                var handler = cm.Create<CreateLine>();
                foreach (var m in movements)
                    handler(m.ToCreateLine(new BudgetId(budgetId), userId, categories));
            }
        }
开发者ID:valeriob,项目名称:MyBudget,代码行数:39,代码来源:Program.cs

示例2: CreateLines

        static void CreateLines(int numberOfLines, IEventStoreConnection esCon, string userId)
        {
            var cm = new CommandManager(esCon);
    
            var budgetId = MyBudget.Domain.Budgets.BudgetId.Create();
            var currency = Currencies.Euro();
            var random = new Random();
            var categories = new[] { "C1", "C2", "C3", "C4" };
            var mindate = new DateTime(2010, 1, 1);

            //var cb = cm.Create<CreateBudget>();
            //cb.Handle(new CreateBudget
            //{
            //    BudgetId = budgetId.ToString(),
            //    UserId = userId,
            //    BudgetName = "test 1. #" + numberOfLines
            //});

            var cl = cm.Create<CreateLine>();
            var po = new ParallelOptions { MaxDegreeOfParallelism = 10 };
            Parallel.For(0, numberOfLines,po, i =>
            //for (int i = 0; i < numberOfLines; i++)
            {
                cl(new CreateLine
                {
                    UserId = userId,
                    BudgetId = budgetId.ToString(),
                    Expense = new Expense(
                        new Amount(currency, random.Next(100)), 
                        mindate.AddDays(random.Next(365 * 3)),
                        categories[random.Next(categories.Length)], "nothing special" ),

                    LineId = MyBudget.Domain.Lines.LineId.Create(budgetId).ToString(),
                });
            }
            );
        }
开发者ID:valeriob,项目名称:MyBudget,代码行数:37,代码来源:Program.cs


注:本文中的CommandManager.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。