public void Single(object sender, EventArgs e) { My.Database.Reset(); Invoice invoice; using (var connection = My.ConnectionFactory()) { invoice = connection.QueryFirst <Invoice>(My.SqlText.Invoice_Select_ByID, new { InvoiceID = 1 }); invoice.Code = "Bulk_Update_0"; } using (var connection = My.ConnectionFactory()) { connection.Open(); var clock = new Stopwatch(); clock.Start(); connection.BulkUpdate(invoice); clock.Stop(); My.Result.Show(clock, 1); } }
public void Many(object sender, EventArgs e) { My.Database.Reset(10000); List <Invoice> invoices; using (var connection = My.ConnectionFactory()) { invoices = connection.Query <Invoice>(My.SqlText.Invoice_Select).ToList(); for (var i = 0; i < invoices.Count; i++) { invoices[i].Code = "Bulk_Update_" + i; } } using (var connection = My.ConnectionFactory()) { connection.Open(); var clock = new Stopwatch(); clock.Start(); connection.BulkUpdate(invoices); clock.Stop(); My.Result.Show(clock, invoices.Count); } }
public FiscalYear Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <FiscalYear>(My.Table_FiscalYear.SelectSingle, new { fscalYearId = id })); } }
public void Relation_OneToMany(object sender, EventArgs e) { My.Database.Reset(10000); var invoices = GetInvoiceWithItems(); invoices.ForEach(x => { x.Code += "z"; x.Items.ForEach(y => y.Code += "z"); }); using (var connection = My.ConnectionFactory()) { connection.Open(); var clock = new Stopwatch(); clock.Start(); connection.BulkUpdate(invoices, x => x.Items); clock.Stop(); My.Result.Show(clock, invoices.Count + invoices.Sum(x => x.Items.Count)); } }
public IndustryType Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <IndustryType>(My.Table_IndustryType.SelectSingle, new { industryTypeId = id })); } }
public IEnumerable <FiscalYear> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <FiscalYear>(My.Table_FiscalYear.Select).ToList()); } }
private void Many(object sender, EventArgs e) { My.Database.Reset(); using (var connection = My.ConnectionFactory()) { connection.Open(); var list = new List <InvoiceContrib> { new InvoiceContrib { InvoiceID = 1, Code = "Update_Many_1" }, new InvoiceContrib { InvoiceID = 2, Code = "Update_Many_2" }, new InvoiceContrib { InvoiceID = 3, Code = "Update_Many_3" } }; var isSuccess = connection.Update(list); My.Result.Show(isSuccess); } }
private void uiGroupJoin_LINQ_Execute_Click(object sender, EventArgs e) { string[] categories = { "Beverages", "Condiments", "Vegetables", "Dairy Products", "Seafood" }; var products = My.GetProductList(); dynamic q = categories.Execute("GroupJoin(products, c => c, p => p.Category, (c, ps) => new { Category = c, Products = ps })", new { products }); var sb = new StringBuilder(); foreach (var v in q) { sb.AppendLine(v.Category + ":"); foreach (var p in v.Products) { sb.AppendLine(" " + p.ProductName); } } My.Result.Show(My.LinqResultType.LinqExecute, uiResult, sb); }
static void Main(string[] args) { My s = new My(); s.Doing((int n) => n % 2 != 0,(int i)=>i*i); s.Print(); Console.ReadKey(); }
public IEnumerable <Township> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <Township>(My.Table_Township.Select).ToList()); } }
public Township Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <Township>(My.Table_Township.SelectSingle, new { townshipId = id })); } }
public void Relation_OneToOne(object sender, EventArgs e) { My.Database.Reset(10000); var invoices = GetInvoiceWithDetail(); invoices.ForEach(x => { x.Code += "z"; x.Detail.Detail += "z"; }); using (var connection = My.ConnectionFactory()) { connection.Open(); var clock = new Stopwatch(); clock.Start(); connection.BulkUpdate(invoices, x => x.Detail); clock.Stop(); My.Result.Show(clock, invoices.Count * 2); } }
public IEnumerable <City> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <City>(My.Table_City.Select).ToList()); } }
public IEnumerable <Language> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <Language>(My.Table_Language.Select).ToList()); } }
public IEnumerable <ProductType> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <ProductType>(My.Table_ProductType.Select).ToList()); } }
public ProductType Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <ProductType>(My.Table_ProductType.SelectSingle, new { productTypeId = id })); } }
void Start() { GameMain = FindObjectOfType <GameMain>(); GameClients = FindObjectOfType <GameClients>(); ItemsBase = FindObjectOfType <ItemsBase>(); //Смотрим страну int Country = GameClients.CurrentClient.GetComponent <Client>().ClientType; List <Place> CasePlaces = new List <Place>(); CasePlaces.AddRange(FindObjectsOfType <Place>()); List <GameObject> CountryItems = new List <GameObject>(); CountryItems.AddRange(ItemsBase.Elements[GameClients.CurrentCountry].Items); foreach (Place a in CasePlaces) //в каждой ячейке создаём каждый предмет { for (int i = 0; i < ItemsBase.Elements[GameClients.CurrentCountry].Items.Count; i++) { GameObject NewItem = Instantiate(CountryItems[i], a.transform); NewItem.transform.position = a.transform.position; NewItem.transform.eulerAngles = Vector3.zero; AllItems.Add(NewItem); } } //перемешиваем предметы AllItems = My.Shuffle(AllItems); //Сортируем по возрастанию необходимых ячеек AllItems = AllItems.ToArray().OrderBy(x => x.GetComponent <Item>().PlacesCountNeeded).ToList(); //переворачиваем, ибо нам нужно по убыванию ячеек AllItems.Reverse(); StartCoroutine(Prestart()); }
private List <Invoice> GetInvoiceWithItems() { var sql = My.SqlText.Invoice_Select_WithItem; using (var connection = My.ConnectionFactory()) { connection.Open(); var invoiceDictionary = new Dictionary <int, Invoice>(); var invoices = connection.Query <Invoice, InvoiceItem, Invoice>( sql, (invoice, invoiceItem) => { Invoice invoiceEntry; if (!invoiceDictionary.TryGetValue(invoice.InvoiceID, out invoiceEntry)) { invoiceEntry = invoice; invoiceEntry.Items = new List <InvoiceItem>(); invoiceDictionary.Add(invoiceEntry.InvoiceID, invoiceEntry); } invoiceEntry.Items.Add(invoiceItem); return(invoiceEntry); }, splitOn: "InvoiceItemID") .Distinct() .ToList(); return(invoices); } }
/// <summary> /// Convert input file to output file. /// </summary> /// <param name="inputPath">Path of input file</param> /// <param name="outputPath">Path of output file</param> /// <param name="filename">file name</param> /// <param name="src">source string</param> /// <param name="dst">destination string</param> private static void RouteConvertTool(string inputPath, string outputPath, string filename, string src, string dst) { var cnt = 0; var line = string.Empty; var inputfilename = inputPath + filename; var outputfilename = My.CheckPath(outputPath, filename); using (TextReader reader = new StreamReader(inputfilename)) { using (TextWriter writer = new StreamWriter(outputfilename)) { while ((line = reader.ReadLine()) != null) { var output = line.Replace(src, dst); writer.WriteLine(output); if (line != output) { ++cnt; } } } } Console.ForegroundColor = (cnt == 0) ? ConsoleColor.Red : ConsoleColor.White; Console.WriteLine($"Converting to: {outputfilename}."); totalCnt += (cnt > 0) ? 1 : 0; }
public Person Get(Guid id) { using (var db = My.ConnectionFactory()) { var persons = db.Query <Person, City, Township, City, Person>($@"SELECT * FROM dbo.Person LEFT OUTER JOIN dbo.City AS homeCity ON dbo.Person.homeCityId = homeCity.cityId LEFT OUTER JOIN dbo.Township ON dbo.Person.homeTownshipId = dbo.Township.townshipId LEFT OUTER JOIN dbo.City AS nativeCity ON dbo.Person.nativeCityId = nativeCity.cityId WHERE personId='{id.ToString()}'", (person, homeCity, homeTownship, nativeCity) => { person.homeCity = homeCity; person.homeTownship = homeTownship; person.nativeCity = nativeCity; return(person); }, splitOn: "cityId,townshipId,cityId").ToArray(); if (persons.Length == 1) { PersonBusinessController personBusinessController = new PersonBusinessController(); PersonLanguageController personLanguageController = new PersonLanguageController(); var p = persons[0]; p.personBusiness = personBusinessController.Get(p.personId.ToString()).ToArray(); p.personLanguage = personLanguageController.Get(p.personId.ToString()).ToArray(); personBusinessController.Dispose(); personLanguageController.Dispose(); return(p); } else { return(null); } } }
public IEnumerable <AppUser> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <AppUser>(My.Table_AppUser.Select).ToList()); } }
private void Execute_Many(object sender, EventArgs e) { My.Database.Reset(); var sql = My.SqlText.Proc_Invoice_Insert; var parameters = new List <DynamicParameters>(); for (var i = 0; i < 3; i++) { var p = new DynamicParameters(); p.Add("@Kind", InvoiceKind.WebInvoice, DbType.Int32, ParameterDirection.Input); p.Add("@Code", "Many_Insert_" + (i + 1), DbType.String, ParameterDirection.Input); p.Add("@RowCount", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); parameters.Add(p); } using (var connection = My.ConnectionFactory()) { connection.Open(); connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure ); var rowCount = parameters.Sum(x => x.Get <int>("@RowCount")); My.Result.Show(rowCount); } }
protected void ProcessSignInForum() { string validateCodeAction = "SignInForum"; MessageDisplay msgDisplay = CreateMessageDisplay(); if (CheckValidateCode(validateCodeAction, msgDisplay)) { string password = _Request.Get("Password", Method.Post, string.Empty); if (password == string.Empty) { msgDisplay.AddError("请输入版块密码"); return; } if (password == Forum.Password) { My.AddValidatedForumID(Forum.ForumID, password); //Response.Redirect(_Request.Get("UrlReferrer", Method.Post, BbsUrlHelper.GetForumUrl(Forum.CodeName))); int threadID = _Request.Get <int>("threadid", Method.Get, 0); if (threadID > 0) { Response.Redirect(BbsUrlHelper.GetThreadUrl(Forum.CodeName, threadID, 1)); } else { Response.Redirect(BbsUrlHelper.GetForumUrl(Forum.CodeName)); } } else { msgDisplay.AddError("密码不正确"); } } }
public AppUser Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <AppUser>(My.Table_AppUser.SelectSingle, new { userId = id })); } }
private void saveGameToolStripMenuItem_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { My.WriteToFile(saveFileDialog1.FileName, bord.Save() + notation.Save()); // V120 } }
public City Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <City>(My.Table_City.SelectSingle, new { cityId = id })); } }
public Language Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <Language>(My.Table_Language.SelectSingle, new { languageId = id })); } }
public static int Main(string[] args) { My fu = new My("Hello there"); fu.display(); return(0); }
public Position Get(Guid id) { using (var db = My.ConnectionFactory()) { return(db.QuerySingle <Position>(My.Table_Position.SelectSingle, new { positionId = id })); } }
private void uiGroupBy_Nested_LINQ_Execute_Click(object sender, EventArgs e) { var customers = My.GetCustomerList(); var customerOrderGroups = customers.Select(c => new { c.CompanyName, YearGroups = c.Orders.Execute <IEnumerable <IGrouping <int, My.Order> > >("GroupBy(o => o.OrderDate.Year)").Select(yg => new { Year = yg, MonthGroups = yg.Execute <IEnumerable <IGrouping <int, My.Order> > >("GroupBy(o => o.OrderDate.Month)").Select(mg => new { Month = mg.Key, Orders = mg }) }) }); var sb = new StringBuilder(); My.ObjectDumper.Write(sb, customerOrderGroups, 3); My.Result.Show(My.LinqResultType.LinqExecute, uiResult, sb); }
public IEnumerable <Position> Get() { using (var db = My.ConnectionFactory()) { return(db.Query <Position>(My.Table_Position.Select).ToList()); } }
private static int Main() { My[] s = new My[0]; IList<My> ls = (IList<My>)s; ReadOnlyCollection<My> roc = new ReadOnlyCollection<My>(ls); Console.WriteLine(roc.Count); return 100; }
My Callback(My p4, int x, My p5) { if (x == 0) { Console.WriteLine("Here!"); GC.Collect(); return p4; } p5.b.d.a.b.c.o = new Object(); return _callback(p4, x-1, p5); }
static void Main(string[] args) { My my = new My(); try { my.Go(); } catch (Exception e) { Console.WriteLine ("Unexpected exception: " + e.ToString()); Environment.Exit(1); } Environment.Exit(0); }
public static extern ulong VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, My.MemoryPageProtection NewProtect, [Out] My.MemoryPageProtection OldProtect);
void Start() { m = new My(); Thread t = new Thread(m.RunMe); t.Start(); }
public static int Main(string[] args) { My fu = new My("Hello there"); fu.display(); return 0; }
public static extern IntPtr OpenProcess(My.ProcessAccess dwDesiredAccess, bool bInheritHandle, int ProcessId);
public void RunMe() { My x; My y; int j = 123456789; Backward: if (j == 0) goto Forward; for (int i = 0; i < 5; i++) { x.b.d.a.b.c.o = new Object(); if ((j & 1) != 0) { x = _m; if (j < 0) break; y = _n; if (j < -1) continue; _m = y; if (j < -2) break; _n = x; } else { x = _m; y = _n; if ((j & 2) != 0) goto Q; if ((j & 4) != 0) _m = x; else _n = y; } x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; Q: x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; x = _m; _m = _n; _n = x; y = _m; _m = _n; _n = y; j = j >> 1; GC.Collect(); } j = 0; if (j == 0) goto Backward; Forward: _callback = new MyDelegate(Callback); _callback += new MyDelegate(Callback); _callback(_n, 5, _m); Console.WriteLine("Passed"); }
public static extern IntPtr OpenThread(My.ThreadAccess dwDesiredAccess, bool bInheritHandle, int ThreadId);
private void writeStreamInfo(object sender, My.Process.DataReceivedEventArgs e) { try { if(OnOutput!=null) OnOutput(this, new My.Event.MessageArgs(e.Text)); //this.textOutput.AppendText(e.Text + Environment.NewLine); int sd = e.Text.IndexOf("Duration: "); int st = e.Text.IndexOf("time="); if (sd != -1) Duration = TimeSpan.Parse(e.Text.Substring(sd + 10, 10)).TotalSeconds; if (st != -1) { string tt = e.Text.Substring(st + 5, e.Text.Length - (st + 5)); string[] ttt = tt.Split(' '); Time = System.Convert.ToDouble(ttt[0].Replace(" ", "").Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator)); //textOutput.AppendText("[" + Time.ToString() + "]\r\n"); } if (OnProgress != null) { int v = System.Convert.ToInt32((Time / Duration) * 100); int m = 100; if (v > m) m = v; OnProgress(this, new My.Event.ProgressArgs(v, m)); } } #if(DEBUG) catch (Exception ex) { My.Box.Errore(ex.Message); } #else catch{} #endif }
public static extern My.NtStatus NtQueryInformationProcess(IntPtr hProcess, My.ProcessInfo ProcessInformationClass, IntPtr ProcessInfoBuffer, uint ProcessInformationLength, IntPtr ReturnLength);
public static extern My.NtStatus NtQueryInformationThread(IntPtr hThread, My.ThreadInfo ThreadInformationClass, IntPtr ThreadInfoBuffer, uint ThreadInformationLength, IntPtr ReturnLength);
public static extern bool EnumProcessModulesEx(IntPtr hProcess, [Out, MarshalAs(UnmanagedType.AsAny)] object ModuleArray, int cb, [Out] int cbNeeded, My.ListModules FilterFlags);