本文整理汇总了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));
}
}
示例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(),
});
}
);
}