protected void Page_Load(object sender, EventArgs e) { // var resp = Request["data"]; MyDB db = new MyDB(); //string f_dedcoll = Session["dedcolname"].ToString(); string f_dedcoll = "bakkupavankumar7382476952"; var f_coll = db.GetBColl(f_dedcoll); string offerlist = ""; var offerquery = Query<Product>.EQ(x => x.offer, "1"); foreach (BsonDocument bdoff in f_coll.Find(offerquery)) { bdoff.Remove("_id"); string offerlist1 = bdoff.ToString(); offerlist = offerlist + offerlist1 + ","; } string offrlist3 = offerlist.Remove(offerlist.Length - 1, 1); string offerlist3 = "[{" + "\"items\":[" + offrlist3 + "]" + "}]"; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(offerlist3); //Valid User Response.End(); }
/// <summary> /// Première série de tests /// </summary> /// <remarks>Code non optimisé afin de montrer la possibilité d'imbrications des consultations</remarks> static void Test1(MyDB BD) { Console.Clear(); Console.WriteLine("'Test1' démarre ..."); if (BD.IsConnected) { Console.WriteLine("\nLa connexion au serveur MySql est établie."); foreach (MyDB.IRecord Enregistrement in BD.Read("SELECT * FROM oenologue")) { Console.WriteLine("\nOenologue {0} :\n* id : {1}\n* nom : {2}\n* indice_confiance : {3}\n* cotation_minimale : {4}\n* cotation_maximale : {5}", Enregistrement.Result.RecordCount, Enregistrement["id"], Enregistrement["nom"], Enregistrement["indice_confiance"], Enregistrement["cotation_minimale"], Enregistrement["cotation_maximale"]); foreach (MyDB.IRecord Enregistrement2 in BD.Read("SELECT * FROM avis WHERE ref_oenologue = {0}", Enregistrement["id"]).Take(5)) { if (Enregistrement2.Result.RecordCount == 1) Console.WriteLine("* premiers avis :"); Console.WriteLine(" - cote n° {0} :\n - valeur : {1}\n - attribuée à : {2}", Enregistrement2.Result.RecordCount, Enregistrement2["cote"], BD.GetValue<short>("SELECT nom FROM vin WHERE id = {0}", Enregistrement2["ref_vin"])); } } foreach (MyDB.IRecord Enregistrement in BD.Read("SELECT * FROM vin")) { Console.WriteLine("\nVin {0} :\n* id : {1}\n* nom : {2}", Enregistrement.Result.RecordCount, Enregistrement["id"], Enregistrement["nom"], Enregistrement["indice_confiance"], Enregistrement["cotation_minimale"], Enregistrement["cotation_maximale"]); } } Console.WriteLine("\nNombre d'objets de consultation (utilisés/existants) : {0} / {1}", MyDB.UsedReadersCount, MyDB.ReadersCount); Console.WriteLine("\n'Test1' est terminé."); Console.WriteLine("\nAppuyez sur ESCAPE pour continuer"); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["objid"] != null) { var ordercheck = Session["objid"].ToString(); var db = new MyDB(); var regcol = db.GetBColl("registration"); var merchantquery = new QueryDocument("_id", ObjectId.Parse(ordercheck)); if (Session["storename"] != null) { foreach (BsonDocument b in regcol.Find(merchantquery)) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("12"); // For Merchant Response.End(); } } var col = db.GetBColl("orders"); var queryorders = new QueryDocument("user", ordercheck); foreach (BsonDocument b in col.Find(queryorders)) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("11"); Response.End(); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("1"); Response.End(); } else { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Session["pleaselogin"] = "******"; Response.End(); } } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { var forgot = Request["forgotEmail"]; MyDB db = new MyDB(); var regcoll = db.GetBColl("registration"); var query = new QueryDocument("email", forgot); var count = regcoll.Find(query).Count(); if (count > 0) { foreach (BsonDocument buns in regcoll.Find(query)) { //string ActivationUrl = Server.HtmlEncode("http://*****:*****@gmail.com", "9885139782"); //from address and password sc.Port = 587; sc.Host = "smtp.gmail.com"; sc.EnableSsl = true; MailMessage mm = new MailMessage(); mm.From = new MailAddress("*****@*****.**", "Confirmation", System.Text.Encoding.UTF8); mm.To.Add(forgot.ToString()); mm.Subject = "Confirmation"; mm.Body = "Welcome to N B T C private limited<br/>" + "Hi " + forgot + "<br/>Please <a href=" + ActivationUrl + ">click here to reset your password</a> <br/>\nThanks!"; //mm.Body = "<a href=\"" + ActivationUrl + "\""; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; sc.Send(mm); Session["resetEmail"] = forgot; } } else { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/text"; Response.Write(0); Response.End(); } } catch (ThreadAbortException te) { } catch (Exception ee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/text"; Response.Write(2); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { string mob = Request.QueryString["UserID"]; //string email = Request.QueryString["Email"]; MyDB md = new MyDB(); var col = md.GetBColl("registration"); IMongoQuery qd = new QueryDocument("mobile", Convert.ToInt64(mob)); IMongoUpdate ud = Update.Set("status", 1); col.Update(qd, ud); }
protected void Page_Load(object sender, EventArgs e) { string filetoread = Session["filename"].ToString(); string mypath = Server.MapPath("~/Files/") + filetoread; StreamReader sr; sr = new StreamReader(mypath); string line = sr.ReadLine(); var columnNames = Regex.Split(line, ","); string jsonstr = ""; while ((line = sr.ReadLine()) != null) { string[] cols = Regex.Split(line, ","); BsonDocument mybson = new BsonDocument(); for (int i = 0; i <= columnNames.Length - 1; i++) { mybson.Add(columnNames[i], cols[i]); } jsonstr += mybson + ","; } BsonDocument bboth = new BsonDocument(); bboth.Add("csvdata", "[" + jsonstr.Remove(jsonstr.Length - 1, 1) + "]"); string dedcoll = Session["dedcolname"].ToString(); MyDB db = new MyDB(); var coll = db.GetBColl(dedcoll); var countdocs = coll.Count(); if (coll.Exists() && countdocs > 0) { var orgjson = ""; foreach (BsonDocument bibi in coll.FindAll()) { bibi.Remove("_id"); orgjson += bibi + ","; } bboth.Add("orginaldata", "[" + orgjson.Remove(orgjson.Length - 1, 1) + "]"); } else { bboth.Add("orginaldata", ""); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(bboth); Response.End(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (MyDB BD = new MyDB("u_oenologue", "mZTbURtCucb92Grf", "oenologie")) { BD.Connect(); Console.BufferHeight = 5000; Test1(BD); Test2(BD); Test3(BD); FinDesTests(); } }
protected void Page_Load(object sender, EventArgs e) { try { var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow); DateTime dt = DateTime.Now; var dateto = dt; var gj = Request["reqdata"]; string gorder = Session["order"].ToString(); string ordersend = "[" + gorder + "]"; MyDB md = new MyDB(); var gcol = md.GetBColl("guests"); BsonDocument bd = new BsonDocument(); BsonDocument desjson = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(gj); var desorder = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonArray>(ordersend); BsonValue gname = desjson.GetElement("gname").Value; BsonValue gmobile = desjson.GetElement("gmobile").Value; BsonValue gaddress = desjson.GetElement("gaddress").Value; //bd.Add("gshipadd", desjson); bd.Add("name", gname); bd.Add("mobile", gmobile); bd.Add("ISODate", dateto); bd.Add("shipadd", gaddress); bd.Add("order", desorder); bd.Add("orderstatus", "undelivered"); gcol.Insert(bd); gcol.Save(bd); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Session.Remove("order"); Response.Write("1"); Response.End(); } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { var orderesarray = Request["z"]; if (orderesarray != "") { string[] ord = orderesarray.Split(','); var x = (from a in ord group a by a into groups where groups.Count() == 1 || groups.Count() == 3 || groups.Count() == 5 || groups.Count() == 7 || groups.Count() == 9 select groups.Key ).ToArray(); MyDB db = new MyDB(); var orderscoll = db.GetBColl("orders"); var guestcoll = db.GetBColl("guests"); foreach (var ids in x) { IMongoQuery qd = new QueryDocument("_id", ObjectId.Parse(ids.ToString())); //407 IMongoUpdate ud = Update.Set("orderstatus", "delivered"); var count = orderscoll.Find(qd).Count(); if (count > 0) { orderscoll.Update(qd, ud); } else { guestcoll.Update(qd, ud); } } } } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { var userid = Request["reqdata"]; MyDB db= new MyDB(); var col = db.GetBColl("registration"); QueryDocument foremail = new QueryDocument("email", userid.ToString()); foreach (BsonDocument items in col.Find(foremail)) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("1"); Response.End(); goto hihi; } QueryDocument fordet = new QueryDocument("mobile", Convert.ToInt64(userid)); foreach (BsonDocument items in col.Find(fordet)) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("1"); Response.End(); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); hihi: string dummy = null; } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { //var itemname = "Apricot"; var itemname = Request["reqdata"]; //var userid = "52cd1e8977a74312d0203b49"; var userid = Session["objid"].ToString(); MyDB db = new MyDB(); var coll = db.GetBColl("Test3"); var userquery = Query.EQ("user", userid); var userres = coll.Find(userquery); var finalString = ""; foreach (var obj in userres) { var objc = obj.Count(); var order = obj.GetElement("order").Value; //.GetElement("Items"); BsonArray p1 = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonArray>(order.ToJson()); var odate = p1[0].ToBsonDocument().GetElement("OrderedDate").Value; var p1c = p1[0].ToBsonDocument().GetElement("Items").Value.AsBsonArray; var p1ccount = p1c.Count(); for (int i = 0; i < p1c.Count(); i++) { var citem = p1c[i].ToBsonDocument().GetElement("Name").Value; if (citem == itemname) { double cquan = Convert.ToDouble(p1c[i].ToBsonDocument().GetElement("Quantity").Value); p1c[i].ToBsonDocument().Add("OrderedDate", odate); finalString += p1c[i] + ","; //Response.Write(p1c[i]); //Response.Write("<br />"); //Response.Write("<br />"); } } } var finalString1 = "{\"Prudhvi\":[" + finalString.Remove(finalString.Length - 1, 1) + "]}"; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(finalString1); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { MyDB db = new MyDB(); //var storesession = Session["storename"].ToString(); var usersess = Session["objid"].ToString(); var getcoll = db.GetBColl("Test4" + usersess); var newcollstore = db.GetBColl("storecoll" + usersess); var newcoll = db.GetBColl("collstore" + usersess); //.InsertBatch(coll.Find(userq)); var userItems = db.GetBColl("useritems1" + usersess); getcoll.Drop(); newcollstore.Drop(); newcoll.Drop(); userItems.Drop(); Session.Abandon(); Session.Clear(); Response.Redirect("~/index.html"); }
/// <summary> /// Seconde série de tests /// </summary> /// <remarks>Utilisation du modèle d'entité Oenologue - version 1</remarks> static void Test2(MyDB BD) { Console.Clear(); Console.WriteLine("'Test2' démarre ..."); if (BD.IsConnected) { Console.WriteLine("\nLa connexion au serveur MySql est établie."); List<OenologueV1> Oenologues = new List<OenologueV1>(OenologueV1.Lister(BD, OenologueV1.Listing.Tous)); foreach (OenologueV1 Oenologue in Oenologues) { Console.WriteLine("\n{0}", Oenologue); } } Console.WriteLine("\n"); Test2a(BD); Console.WriteLine("\nNombre d'objets de consultation (utilisés/existants) : {0} / {1}", MyDB.UsedReadersCount, MyDB.ReadersCount); Console.WriteLine("\n'Test2' est terminé."); Console.WriteLine("\nAppuyez sur ESCAPE pour continuer"); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; }
protected void Page_Load(object sender, EventArgs e) { try { var valto = Request["forgotEmail"]; //update this pwd in database and reidrect the user to login page and ask him to login with new password. MyDB db = new MyDB(); var regcoll = db.GetBColl("registration"); var email=Session["resetEmail"].ToString(); IMongoQuery q = new QueryDocument("email",email); myEncryption enc=new myEncryption(); var mdfhashpwd = enc.getMD5Hash(valto.ToString()); IMongoUpdate u=Update.Set("password",mdfhashpwd); regcoll.Update(q,u); } catch { } }
protected void Page_Load(object sender, EventArgs e) { try { var useremail = Request["reqdata"]; MyDB md = new MyDB(); var collection = md.GetBColl("registration"); var emailquery = new QueryDocument("email", useremail); foreach (BsonDocument items in collection.Find(emailquery)) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); goto hi; } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("1"); Response.End(); hi: string dummy = null; } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { var usermobile = Request["reqdata"]; MyDB md = new MyDB(); var collection = md.GetBColl("registration"); var mobilequery = new QueryDocument("mobile", Convert.ToInt64(usermobile)); foreach (BsonDocument items in collection.Find(mobilequery)) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); goto hi; } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("1"); Response.End(); hi: string dummy = null; } catch (ThreadAbortException) { } catch (Exception e3) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("INVALID MOBILE"); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { string objectidvalue = Session["objid"].ToString(); string ordervalue = Session["order"].ToString(); MyDB md = new MyDB(); var col = md.GetBColl("registration"); var queryid = new QueryDocument("_id", ObjectId.Parse(objectidvalue)); BsonDocument baddress = new BsonDocument(); foreach (BsonDocument bits in col.Find(queryid)) { baddress.Add("mobileNo", bits.GetElement("mobile").Value.ToDouble()); baddress.Add("address", bits.GetElement("address").Value.ToString()); baddress.Add("city", bits.GetElement("city").Value.ToString()); baddress.Add("pincode", bits.GetElement("pincode").Value.ToDouble()); baddress.Add("order", ordervalue); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(baddress.ToString()); //Valid User Response.End(); } catch (ThreadAbortException ee) { } catch (Exception e3) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); Response.End(); } }
public OenologueV1(MyDB BD, string Nom, double IndiceConfiance, short CotationMinimale, short CotationMaximale) : this(BD, 0, Nom, IndiceConfiance, CotationMinimale, CotationMaximale) { }
protected void Page_Load(object sender, EventArgs e) { var loginjson = Request["reqdata"]; BsonDocument t = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(loginjson); int startindex = Convert.ToInt32(t.GetElement("si1").Value); int limitindex = Convert.ToInt32(t.GetElement("li1").Value); var storesession = Session["storename"].ToString(); var usersess = Session["objid"].ToString(); var gquery = Query.EQ("order.storeName", storesession); int restartindex = startindex - 20; MyDB db = new MyDB(); var coll = db.GetBColl("Test3"); var coll3 = db.GetBColl("Test4" + usersess); if (restartindex == 0&& !(coll3.Exists())){ if (coll.Find(gquery).Count() > 0) { coll3.InsertBatch(coll.Find(gquery)); } } var totalorders = coll3.Count(); var totalorders1 = totalorders - 1; if (totalorders == 0) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); } var query = from person in coll3.FindAll() orderby person.ToBsonDocument().GetElement("ISODate") descending select person; var mc = query.ToArray(); var obj = ""; var obj1 = ""; BsonElement my_id = null; for (int i = restartindex; i < limitindex; i++) { if (i < totalorders) // 60 61 { var tobson = mc[i].ToBsonDocument(); my_id = tobson.GetElement("_id"); tobson.Add("orderid", my_id.ToString().Substring(4)); tobson.Remove("ISODate"); tobson.Remove("_id"); BsonElement bmob = tobson.GetElement("mobile"); tobson.Remove("mobile"); tobson.Add("mobile", Convert.ToDouble(bmob.Value)); var myf = tobson.ToJson(); if (i == totalorders1) { var jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(myf.ToString()); obj += jsonoffer.ToString(); obj1 = obj; var obj22 = obj1; var finalString1 = "{\"orders\":[" + obj22 + "]}"; BsonDocument bie = new BsonDocument(); bie.Add("obj", finalString1); bie.Add("resp", Convert.ToDouble(totalorders)); var myresp = bie.ToJson(); var lastresp = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(myresp.ToString()); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(lastresp.ToString()); Response.End(); } else { var jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(myf.ToString()); obj += jsonoffer.ToString() + ","; obj1 = obj; } } } var obj2 = obj1; var objrem = obj2.Remove(obj2.Length - 1, 1); var finalString = "{\"orders\":[" + objrem + "]}"; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(finalString); Response.End(); }
public AccountModel() { context = new MyDB(); }
protected void Page_Load(object sender, EventArgs e) { try { var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow); DateTime dt = DateTime.Now; var dateto = dt; string objectidvalue = Session["objid"].ToString(); MyDB md = new MyDB(); var registration = md.GetBColl("registration"); var orders = md.GetBColl("Test3"); var temporders = md.GetBColl("temporders"); var queryid = new QueryDocument("_id", ObjectId.Parse(objectidvalue)); var queryidwithvalue = new QueryDocument("user", objectidvalue); var sss = Session["order"]; BsonElement bshipmobformer = null; foreach (BsonDocument borg in registration.Find(queryid)) { bshipmobformer = borg.GetElement("mobile"); } if (sss == null) { BsonDocument bd1 = new BsonDocument(); foreach (BsonDocument bits in temporders.Find(queryidwithvalue)) { bits.Remove("regtoship"); string username = Session["username"].ToString(); bits.Add("name", username); bits.Add("user", objectidvalue); bits.Add("ISODate", dateto); bits.Add("mobile", bshipmobformer.Value); bits.Add("shipadd", "Pick at Store"); bits.Add("orderstatus", "undeliver"); orders.Insert(bits); orders.Save(bits); temporders.Remove(queryidwithvalue); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Session["order"] = null; Session.Remove("order"); Response.Write(1.ToString()); //Valid User Response.End(); } else { string orderdet = Session["order"].ToString(); string omedet = "[" + orderdet + "]"; var res = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonArray>(omedet); BsonDocument bd = new BsonDocument(); bd.Add("user", objectidvalue); string username = Session["username"].ToString(); bd.Add("name", username); bd.Add("ISODate", dateto); bd.Add("mobile", bshipmobformer.Value); bd.Add("shipadd", "Pick at Store"); bd.Add("orderstatus", "undeliver"); bd.Add("order", res); orders.Insert(bd); orders.Save(bd); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Session["order"] = null; Session.Remove("order"); Response.Write(1.ToString()); //Valid User Response.End(); } } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { var userid = Session["objid"].ToString(); //var userid = "52ca747eeb12480278147796"; var loginjson = Request["reqdata"]; BsonDocument t = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(loginjson); int startindex = Convert.ToInt32(t.GetElement("si1").Value); int limitindex = Convert.ToInt32(t.GetElement("li1").Value); int restartindex = startindex - 20; MyDB db = new MyDB(); var coll = db.GetBColl("Test3"); var userq = Query.EQ("user", userid); var collord = coll.Find(userq); var totalorders = collord.Count(); var totalorders1 = totalorders - 1; if (totalorders == 0) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); } var query = from person in coll.Find(userq) orderby person.ToBsonDocument().GetElement("ISODate") descending select person; var mc = query.ToArray(); var obj = ""; var obj1 = ""; BsonElement my_id = null; for (int i = restartindex; i < limitindex; i++) { if (i < totalorders) // 21 { var tobson = mc[i].ToBsonDocument(); my_id = tobson.GetElement("_id"); tobson.Add("orderid", my_id.ToString().Substring(4)); tobson.Remove("ISODate"); tobson.Remove("_id"); BsonElement bmob = tobson.GetElement("mobile"); tobson.Remove("mobile"); tobson.Add("mobile", Convert.ToDouble(bmob.Value)); var myf = tobson.ToJson(); if (i == totalorders1) // 20 == 20 { var jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(myf.ToString()); obj += jsonoffer.ToString(); obj1 = obj; var obj22 = obj1; //var objrem1 = obj22.Remove(obj22.Length - 1, 1); var finalString1 = "{\"orders\":[" + obj22 + "]}"; BsonDocument bie = new BsonDocument(); bie.Add("obj", finalString1); bie.Add("resp", Convert.ToDouble(totalorders)); var myresp = bie.ToJson(); var lastresp = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(myresp.ToString()); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(lastresp.ToString()); Response.End(); } else { var jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(myf.ToString()); obj += jsonoffer.ToString() + ","; obj1 = obj; } } //if (i == totalorders) //62 == 62 //{ // var obj22 = obj1; // //var objrem1 = obj22.Remove(obj22.Length - 1, 1); // var finalString1 = "{\"orders\":[" + objrem1 + "]}"; // Response.Clear(); // Response.CacheControl = "no-cache"; // Response.ContentType = "application/json"; // Response.Write(finalString1); // Response.End(); // //Response.Clear(); // //Response.CacheControl = "no-cache"; // //Response.ContentType = "application/json"; // //string str = null; // //Response.Write(str); // //Response.End(); //} } var obj2 = obj1; var objrem = obj2.Remove(obj2.Length - 1, 1); //var myres = "[" + objrem + "]"; //var ome = '{' + "Data" + myres + '}'; var finalString = "{\"orders\":[" + objrem + "]}"; //var stringremove = "{" + finalString; //var obj2 = obj1; //var objrem = obj2.Remove(obj2.Length - 1, 1); //objrem = "{\"Prudhvi\":[" + objrem + "]}"; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; //coll3.Drop(); Response.Write(finalString); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { try { var obj = Request["reqdata"]; BsonDocument t = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(obj); BsonValue objOrg = t.GetElement("originalGridData").Value; BsonValue objDummy = t.GetElement("dummyGridData").Value; MyDB db = new MyDB(); string merchatsess = Session["dedcolname"].ToString(); string merchdummycoll = Session["dummycol"].ToString(); var coll = db.GetBColl(merchatsess); var dummycoll = db.GetBColl(merchdummycoll); if (coll.Count() > 0) { coll.Drop(); } List<object> orgList = new List<object>(); BsonDocument bexp = new BsonDocument(); var coll77 = db.GetBColl(merchatsess); for (int i = 0; i <= objOrg.AsBsonArray.Count - 1; i++) { bexp = new BsonDocument(); var bids = objOrg[i].AsBsonDocument; bexp.AddRange(bids); orgList.Add(bexp); bexp = null; } coll77.InsertBatch(orgList); BsonDocument bdums = new BsonDocument(); BsonDocument bdums1 = new BsonDocument(); var dummycount = dummycoll.Count(); if (dummycoll.Exists() && dummycount > 0) { var maxsnosno = dummycoll.FindAll().SetSortOrder(SortBy.Descending("sno")).SetLimit(1).FirstOrDefault(); var bsonsno = maxsnosno.GetElement("sno").Value; var longsno = Convert.ToInt64(bsonsno); for (int i = 0; i <= objDummy.AsBsonArray.Count - 1; i++) { longsno++; bdums = new BsonDocument(); Dictionary<string, long> dict = new Dictionary<string, long>(); dict.Add("sno", longsno); var biddums = objDummy[i].AsBsonDocument; bdums.AddRange(biddums); bdums.AddRange(dict); dummycoll.Insert(bdums); bdums = null; } } else { var longsno1 = 0; for (int i = 0; i <= objDummy.AsBsonArray.Count - 1; i++) { longsno1++; bdums1 = new BsonDocument(); Dictionary<string, long> mydict = new Dictionary<string, long>(); mydict.Add("sno", longsno1); var biddums1 = objDummy[i].AsBsonDocument; bdums1.AddRange(biddums1); bdums1.AddRange(mydict); dummycoll.Insert(bdums1); bdums1 = null; } } string f_dedcoll = Session["dedcolname"].ToString(); var f_coll = db.GetBColl(f_dedcoll); IEnumerable<BsonValue> typesregex = f_coll.Distinct("type"); var outjson = ""; var outjsonconcat = ""; var varjson = ""; BsonElement btype = null; BsonValue btypevalue = null; BsonElement bmeasures = null; string dums = null; var jsonoffer = ""; foreach (string str in typesregex) { dums = null; var query = new QueryDocument("type", str); foreach (BsonDocument docs in f_coll.Find(query)) { btype = docs.GetElement("type"); btypevalue = btype.Value; bmeasures = docs.GetElement("measures"); string bmes = bmeasures.ToString(); var s = bmes.Replace(";", "\",\""); var squareconcat = "[" + "\"" + s.Substring(9) + "\"" + "]"; var addtobson = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonValue>(squareconcat); docs.Remove("_id"); docs.Remove("measures"); docs.Add("measures", addtobson); varjson = docs.ToJson(); jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(varjson.ToString()).ToString(); dums += jsonoffer.ToString() + ","; } outjsonconcat = "{\"category\":" + "\"" + btypevalue + "\"" + ",\"items\":[" + dums.Remove(dums.Length - 1, 1) + "]}" + ","; outjson += outjsonconcat; } var stringremove = "[" + outjson.Remove(outjson.Length - 1, 1) + "]"; string fstore = Session["storename"].ToString(); string path = Server.MapPath("~/inventory/") + fstore + ".json"; if (!File.Exists(path)) { FileStream fs = new FileStream(path, FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(fs); str11.WriteLine(stringremove.ToArray()); str11.Flush(); str11.Close(); fs.Dispose(); fs.Close(); } else if (File.Exists(path)) { FileStream fs = new FileStream(path, FileMode.Open); StreamWriter str12 = new StreamWriter(fs); str12.WriteLine(stringremove.ToArray()); str12.Flush(); str12.Close(); fs.Dispose(); fs.Close(); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("777"); Response.End(); } catch (ThreadAbortException e4) { } catch (IOException e3) { } catch (Exception e2) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); Response.End(); } finally { } }
public async Task <IActionResult> Index() { var mydb = new MyDB(); var message = new List <Message>(); try { message = await mydb.Messages.ToListAsync(); } catch { } var usr = "******"; if (HttpContext.User.Identity.IsAuthenticated) { usr = HttpContext.User.Identity.Name; } string userX = HttpContext.Request.Query["user"]; string GrpNameX = "room";// HttpContext.Request.Query["Group"]; if (usr == "Unknow User" && !string.IsNullOrEmpty(userX) && userX != "undefined" && !userX.Equals("null")) { usr = userX; } // Imyhub.Clients.All.SendAsync("RecOnline", usr, DateTime.Now.ToString()).Wait(); var GrpName = "A"; if (GrpName == "A" && !string.IsNullOrEmpty(GrpNameX) && GrpNameX != "undefined" && !GrpNameX.Equals("null")) { GrpName = GrpNameX; } if (HttpContext.User.Identity.IsAuthenticated) { usr = HttpContext.User.Identity.Name; var currUser = mydb.MyUsers.FirstOrDefault(x => x.UserName == usr); if (currUser != null) { } } var res = new List <Message>(); //Imyhub.Clients.All.SendToRecOnline( DateTime.Now.ToString()).Wait(); // Imyhub.Clients.All.Send(""); try { if (message.Count() != 0) { var msg = message.Where(x => x.GroupName == GrpName); if (msg.Count() != 0) { res = msg.ToList(); } } } catch { } ViewData["UserName"] = usr; ViewData["GrpName"] = GrpName; if (res == null) { res = new List <Message>(); } return(View(res)); }
public NotificationHub(MyDB mydbX) : base(mydbX) { }
public SANPHAMFunction() { context = new MyDB(); }
private static void TestTransaction() { AdoHelper db = MyDB.GetDBHelper(); EntityQuery <AuctionOperationLog> query = new EntityQuery <AuctionOperationLog>(db); AuctionOperationLog optLog = new AuctionOperationLog(); optLog.OperaterID = 1000; optLog.Module = "Login"; optLog.Operation = "登录成功1"; optLog.LogSource = "PC"; db.BeginTransaction(); try { query.Insert(optLog); //必须设置为全部属性已经修改,否则仅会更新 Operation 字段 optLog.ResetChanges(true); optLog.Operation = "退出登录"; query.Insert(optLog); //optLog.Module = "Login"; //OQL q = OQL.From(optLog).Select().Where(optLog.Module).END; OQL q = new OQL(optLog); //q.Select().Where(q.Condition.AND(optLog.Operation, "like", "%登录%")); q.Select().Count(optLog.OperaterID, "");//使用空字符串参数,这样统计的值将放到 OperaterID 属性中 //必须指定db参数,否则不再一个事务中,无法进行统计查询 optLog = EntityQuery <AuctionOperationLog> .QueryObject(q, db); int allCount = optLog.OperaterID; //optLog 已经使用过,在生成OQL的查询前,必须使用新的实体对象, // 否则下面的查询仅会使用OperaterID 字段从而导致分页查询出错 optLog = new AuctionOperationLog(); q = new OQL(optLog); q.Select().OrderBy(optLog.Module, "asc").OrderBy(optLog.AtDateTime, "desc"); q.Limit(10, 2); q.PageEnable = true; q.PageWithAllRecordCount = allCount; //查询列表并更新到数据库 List <AuctionOperationLog> list = EntityQuery <AuctionOperationLog> .QueryList(q, db); foreach (AuctionOperationLog logItem in list) { logItem.AtDateTime = DateTime.Now; } query.Update(list); db.Commit(); Console.WriteLine("事务操作成功。"); } catch (Exception ex) { Console.WriteLine("Error:" + ex.Message); db.Rollback(); } }
static void Main(string[] args) { Console.WriteLine("====**************** PDF.NET SOD 控制台测试程序 **************===="); Assembly coreAss = Assembly.GetAssembly(typeof(AdoHelper));//获得引用程序集 Console.WriteLine("框架核心程序集 PWMIS.Core Version:{0}", coreAss.GetName().Version.ToString()); Console.WriteLine(); Console.WriteLine(" 应用程序配置文件默认的数据库配置信息:\r\n 当前使用的数据库类型是:{0}\r\n 连接字符串为:{1}\r\n 请确保数据库服务器和数据库是否有效且已经初始化过建表脚本(项目下的2个sql脚本文件),\r\n继续请回车,退出请输入字母 Q ." , MyDB.Instance.CurrentDBMSType.ToString(), MyDB.Instance.ConnectionString); Console.WriteLine("=====Power by Bluedoctor,2015.2.8 http://www.pwmis.com/sqlmap ===="); string read = Console.ReadLine(); if (read.ToUpper() == "Q") { return; } Console.WriteLine("当前机器的分布式ID:{0}", CommonUtil.CurrentMachineID()); Console.WriteLine("测试分布式ID:秒级有序"); for (int i = 0; i < 50; i++) { Console.Write(CommonUtil.NewSequenceGUID()); Console.Write(","); } Console.WriteLine(); Console.WriteLine("测试分布式ID:唯一且有序"); for (int i = 0; i < 20000; i++) { long seq = CommonUtil.NewUniqueSequenceGUID(); if (i <= 50) { Console.Write(CommonUtil.NewUniqueSequenceGUID()); Console.Write(","); } } Console.WriteLine(); IDataParameter[] paraArr = new IDataParameter[] { MyDB.Instance.GetParameter("P1", 111), MyDB.Instance.GetParameter("P2", "abc'ee<edde/>e"), MyDB.Instance.GetParameter("P3", DBNull.Value), }; string str = DbParameterSerialize.Serialize(paraArr); Console.WriteLine("测试参数序列化:{0}", str); IDataParameter[] paraArr2 = DbParameterSerialize.DeSerialize(str, MyDB.Instance); Console.WriteLine("测试反序列化成功!"); LocalDbContext localDb = new LocalDbContext(); var entitys = localDb.ResolveAllEntitys(); localDb.CurrentDataBase.RegisterCommandHandle(new TransactionLogHandle()); Table_User user = new Table_User(); user.Name = "zhang san"; user.Height = 1.8f; user.Birthday = new DateTime(1980, 1, 1); user.Sex = true; localDb.Add(user); user.Name = "lisi"; user.Height = 1.6f; user.Birthday = new DateTime(1982, 3, 1); user.Sex = false; localDb.Add(user); Console.WriteLine("测试 生成事务日志 成功!(此操作将写入事务日志信息到数据库中。)"); //var logList = localDb.QueryList<MyCommandLogEntity>(OQL.From(new MyCommandLogEntity()).Select().END); AdoHelper db = MyDB.GetDBHelperByConnectionName("local"); var logList = OQL.From <MyCommandLogEntity>().Select().END.ToList(db); foreach (MyCommandLogEntity log in logList) { var paras = DbParameterSerialize.DeSerialize(log.ParameterInfo, db); int count = db.ExecuteNonQuery(log.CommandText, log.CommandType, paras); Console.WriteLine("执行语句:{0} \r\n 受影响行数:{1}", log.CommandText, count); } Console.WriteLine("测试 运行事务日志 成功!(此操作将事务日志的操作信息回放执行。)"); //写入10000条日志,有缓存,可能不会写完 Console.WriteLine("测试日志写入10000 条信息..."); CommandLog loger = new CommandLog(); for (int t = 0; t <= 1; t++) { System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(WriteLog)); thread.Name = "thread" + t; thread.Start(loger); } loger.Flush(); Console.WriteLine("按任意键继续"); Console.ReadLine(); EntityUser etu = new EntityUser(); ITable_User itu = etu.AsEntity(); DateTime dtt = itu.Birthday; //测试 AdoHelper的并发能力 //for (int i = 0; i < 100; i++) //{ // System.Threading.Thread t = new System.Threading.Thread( // new System.Threading.ParameterizedThreadStart(TestDataSetAndOQL)); // t.Name = "thread "+i; // t.Start(); //} //测试生成列的脚本 EntityCommand ecmd = new EntityCommand(new Table_User(), new SqlServer()); string table_script = ecmd.CreateTableCommand; Console.Write("1,测试 OpenSession 长连接数据库访问..."); TestDataSetAndOQL(null); Console.WriteLine("OK"); // Console.WriteLine("2,测试OQL 转SQL..."); RoadTeam.Model.CS.TbCsEvent CsEvent = new RoadTeam.Model.CS.TbCsEvent(); CsEvent.EventID = 1; OQL oql = OQL.From(CsEvent) .Select(CsEvent.EventCheck, CsEvent.EventCheckInfo, CsEvent.EventCheckor, CsEvent.EventCheckTime) .Where(CsEvent.EventID) .END; Console.WriteLine(oql.ToString()); Console.WriteLine("-----------------------"); RoadTeam.Model.CS.TbCsEvent CsEvent2 = new RoadTeam.Model.CS.TbCsEvent(); CsEvent.EventID = 1; OQL oql2 = OQL.From(CsEvent2) .Select(true, CsEvent2.EventCheck, CsEvent2.EventCheckInfo, CsEvent2.EventCheckor, CsEvent2.EventCheckTime) .Where(CsEvent2.EventID) .END; Console.WriteLine(oql2.ToString()); Console.WriteLine("-----------------------"); Console.WriteLine("OK"); // Console.Write("3,测试实体类动态增加虚拟属性..."); UserModels um1 = new UserModels(); um1.AddPropertyName("TestName"); um1["TestName"] = 123; int testi = (int)um1["TestName"]; um1["TestName"] = "abc"; string teststr = (string)um1["TestName"]; Console.WriteLine("OK"); // Console.Write("4,测试缓存..."); var cache = PWMIS.Core.MemoryCache <EntityBase> .Default; cache.Add("UserModels", um1); var cacheData = cache.Get("UserModels"); cache.Remove("UserModels"); Console.WriteLine("OK"); // Console.Write("5,测试自动创建实体类数据库表..."); AutoCreateEntityTable <LT_Users>(); AutoCreateEntityTable <LT_UserRoles>(); Console.WriteLine("OK"); Console.WriteLine("------------测试暂时停止,回车继续运行------"); Console.ReadLine(); //return; Console.Write("6,测试实体类的外键查询..."); TestEntityFK(); Console.WriteLine("OK"); Console.Write("7,测试实体类批量插入..."); OqlInTest(); Console.WriteLine("OK"); Console.WriteLine("8,测试SOD POCO实体类性能..."); Console.WriteLine("SELECT top 100000 UID,Sex,Height,Birthday,Name FROM Table_User"); for (int i = 0; i < 10; i++) { Console.WriteLine("-------------Testt No.{0}----------------", i + 1); TestPocoQuery(); } Console.WriteLine("--------OK---------------"); Console.Write("9,测试OQL IN 子查询..."); TestInChild(); Console.WriteLine("OK"); //TestFun(1, 2, 3); Console.WriteLine("10,测试泛型 OQL --GOQL"); TestGOQL(); Console.WriteLine("OK"); Console.WriteLine("11,测试OQL 批量更新(带条件更新)..."); UpdateTest(); Console.WriteLine("OK"); Console.WriteLine("12,测试批量数据插入性能...."); //InsertTest(); Console.WriteLine("13,OQL 自连接..."); OqlJoinTest(); // Console.Write("14,根据接口类型,自动创建实体类测试..."); TestDynamicEntity(); Console.WriteLine("OK"); // Console.WriteLine("15,Sql 格式化查询测试( SOD 微型ORM功能)..."); AdoHelper dbLocal = new SqlServer(); dbLocal.ConnectionString = MyDB.Instance.ConnectionString; //DataSet ds = dbLocal.ExecuteDataSet("SELECT * FROM Table_User WHERE UID={0} AND Height>={1:5.2}", 1, 1.80M); /* * 下面的写法过时 * var dataList = dbLocal.GetList(reader => * { * return new * { * UID=reader.GetInt32(0), * Name=reader.GetString(1) * }; * }, "SELECT UID,Name FROM Table_User WHERE Sex={0} And Height>={0:5.2}",1, 1.60); */ var dataList = dbLocal.ExecuteMapper("SELECT UID,Name FROM Table_User WHERE Sex={0} And Height>={1:5.2}", 1, 1.60) .MapToList(reader => new { UID = reader.GetInt32(0), Name = reader.GetString(1) }); Console.WriteLine("OK"); // Console.Write("16,测试属性拷贝..."); V_UserModels vum = new V_UserModels(); vum.BIGTEAM_ID = 123;//可空属性,如果目标对象不是的话,无法拷贝 vum.REGION_ID = 456; vum.SMALLTEAM_ID = 789; UserModels um = vum.CopyTo <UserModels>(); Console.WriteLine("OK"); // Console.Write("17,测试【自定义查询】的实体类..."); UserPropertyView up = new UserPropertyView(); OQL q11 = new OQL(up); OQLOrder order = new OQLOrder(q11); q11.Select() .Where(q11.Condition.AND(up.PropertyName, "=", "总成绩").AND(up.PropertyValue, ">", 1000)) .OrderBy(order.Asc(up.UID)); AdoHelper db11 = MyDB.GetDBHelperByConnectionName("local"); var result = EntityQuery <UserPropertyView> .QueryList(q11, db11); //下面2行不是必须 q11.Dispose(); Console.WriteLine("OK"); //EntityContainer ec = new EntityContainer(q11); //var ecResult = ec.MapToList(() => { // return new { AAA = ec.GetItemValue<int>(0), BBB = ec.GetItemValue<string>(1) }; //}); ///////////////////////////////////////////////////// Console.WriteLine("18,测试实体类【自动保存】数据..."); TestAutoSave(); Console.WriteLine("19,测试OQL上使用聚合函数..."); OQLAvgTest(); /////////////////测试事务//////////////////////////////////// Console.WriteLine("20,测试测试事务..."); TestTransaction(); TestTransaction2(); Console.WriteLine("事务测试完成!"); Console.WriteLine("-------PDF.NET SOD 测试全部完成-------"); Console.ReadLine(); }
private static OenologueV1 Creer(MyDB.IRecord Enregistrement) { try { return new OenologueV1(Enregistrement.Result.DB, (int)Enregistrement["id"], (string)Enregistrement["nom"], (double)Enregistrement["indice_confiance"], (short)Enregistrement["cotation_minimale"], (short)Enregistrement["cotation_maximale"]); } catch (Exception Erreur) { System.Diagnostics.Debug.WriteLine(string.Format("\nErreur de création d'une entité oenologue à partir d'un enregistrement : {0}\n{1}\n", Enregistrement, Erreur.Message)); return null; } }
protected void CreateButtonOnClick(object sender, EventArgs e) { MyDB.CreateProject(TextBox_Title.Text, TextBox_Subheading.Text, TextBox_Description.Text, TextBox_Details.Text, FU_Image); Response.Redirect("~/Default.aspx"); }
public static OenologueV1 Selectionner(MyDB BD, int Id) { return BD.Read("SELECT * FROM oenologue WHERE id = {0}", Id).Select<MyDB.IRecord, OenologueV1>(Enregistrement => Creer(Enregistrement)).FirstOrDefault(); }
public override void SupprimerEnCascade(MyDB Connexion) { Connexion.Executer("DELETE FROM vehicule_caracteristique WHERE id_vehicule_caracteristique = {0}", Id); Connexion.Executer("DELETE FROM caracteristique WHERE id_caracteristique = {0}", Caracteristique.Id); }
protected void Page_Load(object sender, EventArgs e) { var s = Convert.ToInt32(Session["forajax"]); MyDB db = new MyDB(); var usersess = Session["objid"].ToString(); var collstorecoll = db.GetBColl("collstore" + usersess); try { var itemname = Request["reqdata"]; var storesession = Session["storename"].ToString(); var gquery = Query.EQ("order.storeName", storesession); var coll = db.GetBColl("Test3"); //var collstore = coll.Find(gquery); if (s == 0) { collstorecoll.InsertBatch(coll.Find(gquery)); } //var options = new MapReduceOptionsBuilder(); //options.SetOutput(MapReduceOutput.Inline); //options.SetQuery(Query.EQ("OrderedDate", "15 April 2014")); //var itemname = "Acorn"; //var query = new QueryDocument("order[0].Items[0].Name",itemname); //foreach (BsonDocument bids in coll.FindAll()) //{ // BsonArray docs = bids.GetElement("order"); // var items = docs.AsBsonDocument.GetElement("Name").Value; //} //BsonDocument bids = new BsonDocument(); //bids.Add("date", new DateTime()) var mapFunction2 = @"function() { for (var idx = 0; idx < this.order[0].Items.length; idx++) { var key = this.order[0].Items[idx].Name+'_'+this.name; var value = { count: 1, qty: parseFloat(this.order[0].Items[idx].Quantity), price: parseFloat(this.order[0].Items[idx].Price), odate: this.order[0].OrderedDate, name: this.name }; emit(key, value); } }"; var reduceFunction2 = @"function(keySKU, countObjVals) { reducedVal = { count: 0, qty: 0, price: 0, odate: 0, name: 0}; for (var idx = 0; idx < countObjVals.length; idx++) { reducedVal.count += countObjVals[idx].count; reducedVal.qty += countObjVals[idx].qty; reducedVal.price += countObjVals[idx].price; reducedVal.odate = countObjVals[idx].odate; reducedVal.name = countObjVals[idx].name; } return reducedVal; }"; var mr = collstorecoll.MapReduce(mapFunction2, reduceFunction2); string finalstr = ""; string mystr = ""; foreach (var document in mr.GetResults()) { string str = document.ToJson(); BsonDocument p1 = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(str); string i1 = p1.GetElement("_id").Value.ToString(); string[] words = i1.ToString().Split('_'); string nameee = words[0]; if (nameee == itemname) { mystr = document.ToJson(); finalstr += mystr + ","; //Response.Write("_id=" + words[1].Replace(" ", "") + " " + p2.GetElement("value")); } //Response.Write(document[0] + " " + document[1]); //Response.Write("<br />"); } var finalString1 = "{\"Prudhvi\":[" + finalstr.Remove(finalstr.Length - 1, 1) + "]}"; Session["forajax"] = 1; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; // collstorecoll.Drop(); Response.Write(finalString1); Response.End(); } catch (Exception e1) { } finally { //collstorecoll.Drop(); } }
/// <summary> /// 处理当前流程实例节点 /// 1.判断节点类型 /// 2.如果是处理节点,则取活动CODE,找到下一个节点,调用推入 /// 3.如果是分支节点,则计算表达式,找到下一个节点,调用推入 /// 4.如果是结束节点,完成结束必须的工作 /// </summary> /// <param name="instNodeID">当前流程实例节点ID</param> /// <param name="ctx">HTTP上下文</param> private void process(string instNodeID, HttpContextBase ctx) { using (MyDB mydb = new MyDB()) { WFInstNode current = mydb.WFInstNodes.Find(instNodeID); WFInst inst = current.WFInst; if (current.WFNode is WFNodeHandle) { string actionID = Request.Form["actionID"]; string UserID = ctx.User.Identity.Name; WFNodeAction action = mydb.WFNodeActions.Find(actionID); WFNode next = action.NextNode; if (next != null) { Type t = getType(inst.WFTemplate); PropertyInfo[] PropertyInfos = t.GetProperties().ToArray(); foreach (string key in Request.Form.Keys) { PropertyInfo pi = t.GetProperty(key); if (pi != null) { DisplayAttribute[] attrs = pi.GetCustomAttributes(typeof(DisplayAttribute), true) as DisplayAttribute[]; if (attrs.Length > 0) { pi.SetValue( inst, //Request.Form[key], Convert.ChangeType(Request.Form[key], pi.PropertyType.UnderlyingSystemType), null); } } } // 当前节点处理完成,准备转入下一节点 current.State = "已处理"; current.LeaveTime = DateTime.Now; current.Summary = string.Format("节点名称:{0},处理人:{1},动作:{2}", current.WFNode.Name, mydb.Subjects.Find(UserID).Name, action.Name); // 节点处理人 WFInstNodeHandler handler = current.WFInstNodeHandlers.First(h => h.Handler.ID.Equals(UserID)); handler.HandleTime = DateTime.Now; handler.Opinion = action.Name; handler.State = "已处理"; // 其他的处理人置为失效 foreach (WFInstNodeHandler other in current.WFInstNodeHandlers.Where(h => !h.Handler.ID.Equals(UserID))) { handler.State = "已失效"; } mydb.SaveChanges(); this.entry(inst.ID, next.ID, ctx); return; } } else if (current.WFNode is WFNodeXORSplit) { WFNodeXORSplit Split = current.WFNode as WFNodeXORSplit; Type t = getType(inst.WFTemplate); PropertyInfo[] PropertyInfos = t.GetProperties().ToArray(); IEnumerable <WFNodeExpression> exps = Split.WFNodeExpressions.OrderBy(exp => exp.OrderNO).Select(exp => exp); foreach (WFNodeExpression exp in exps) { string expString = exp.Expression; foreach (PropertyInfo pi in PropertyInfos) { DisplayAttribute[] attrs = pi.GetCustomAttributes(typeof(DisplayAttribute), true) as DisplayAttribute[]; if (attrs.Length > 0) { string Name = attrs[0].Name; expString = expString.Replace( string.Format("{{{0}}}", Name), pi.Name ); } } expString = string.Format("select count(*) as v from {2}s where ID=\"{0}\" and {1}", current.WFInst.ID, expString, inst.WFTemplate.BuizCode); //int count = mydb.WFInsts.Where(expString).Count(); int count = mydb.Database.SqlQuery <int>(expString, new object[] { }).ToArray()[0]; if (count > 0)// 条件满足,短路,找下一节点 { current.Summary = string.Format("节点名称:{0},满足条件:{1}", current.WFNode.Name, exp.Expression); current.LeaveTime = DateTime.Now; current.State = "已处理"; mydb.SaveChanges(); this.entry(inst.ID, exp.Next.ID, ctx); return; } } } else if (current.WFNode is WFNodeFinish) { current.Summary = "流程结束"; current.LeaveTime = DateTime.Now; current.State = "已处理"; inst.State = "已处理"; mydb.SaveChanges(); return; } else { } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["objid"] != null) { string type_user = Session["typeofuser"].ToString(); string objectidvalue = Session["objid"].ToString(); MyDB md = new MyDB(); var orders = md.GetBColl("orders"); var queryid = new QueryDocument("user", objectidvalue); BsonDocument borders = new BsonDocument(); string str1 = null; string str2 = null; string str3 = null; bool val = Convert.ToBoolean(orders.Find(queryid).Count()); string strusertomer = Session["mertouser"].ToString(); if (strusertomer == "205") { foreach (BsonDocument bit in orders.Find(queryid)) { borders = null; borders = new BsonDocument(); borders.Add("mobile", bit.GetElement("mobile").Value.ToDouble()); borders.Add("order", bit.GetElement("order").Value); str2 += borders.ToJson() + ","; str3 = str2; } if (str2 != null) { str1 = str2.Remove(str2.Length - 1, 1); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(str1); Session["mertouser"] = "******"; Response.End(); } else { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("407"); Session["mertouser"] = "******"; Response.End(); } } if (type_user == "merchant") { Response.Write("105"); Response.End(); //goto letsgo; } if (val) { foreach (BsonDocument bit in orders.Find(queryid)) { borders = null; borders = new BsonDocument(); borders.Add("mobile", bit.GetElement("mobile").Value.ToDouble()); borders.Add("order", bit.GetElement("order").Value); str2 += borders.ToJson() + ","; str3 = str2; } str1 = str2.Remove(str2.Length - 1, 1); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(str1); Response.End(); } else { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); } } else { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("77"); Response.End(); } } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
public SPGIAMGIAFunction() { context = new MyDB(); }
/// <summary> /// URL: /workflow/Instance/handle /// id: 流程实例节点ID /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult handle() { string UserID = this.User.Identity.Name; string TemplateID = Request.Form["TemplateID"]; string instNodeID = Request.Form["instNodeID"]; string nodeID = Request.Form["nodeID"]; string actionID = Request.Form["actionID"]; using (MyDB mydb = new MyDB()) { WFInstNode instNode = mydb.WFInstNodes.FirstOrDefault(n => n.ID.Equals(instNodeID)); WFTemplate template = mydb.WFTemplates.Find(TemplateID); Type t = getType(template); if (instNode == null) { EntityObjectLib.WFInst inst = Activator.CreateInstance(t) as EntityObjectLib.WFInst; //Object inst = Activator.CreateInstance(t); foreach (string key in Request.Form.Keys) { PropertyInfo pi = t.GetProperty(key); if (pi != null) { pi.SetValue( inst, //Request.Form[key], Convert.ChangeType(Request.Form[key], pi.PropertyType.UnderlyingSystemType), null); } } inst.WFTemplate = template; inst.State = "处理中"; inst.Creator = mydb.Users.Find(UserID); inst.CreateTime = DateTime.Now; instNode = new WFInstNode { ID = instNodeID, WFNode = mydb.WFNodes.Find(nodeID), State = "处理中", EntryTime = DateTime.Now, WFInst = inst, WFInstNodeHandlers = new List <WFInstNodeHandler>() { new WFInstNodeHandler { Handler = mydb.Users.Find(UserID), State = "待处理" //如果是"处理中",即表明一个人已经接收,准备处理,其他人不能处理 } } }; mydb.WFInstNodes.Add(instNode); mydb.SaveChanges(); } } this.process(instNodeID, this.HttpContext); return(View("handleSuccess")); }
/// <summary> /// 返回用户基本信息,按 LoginName /// </summary> public static dynamic GetUserByLoginName(string LoginName) { var db = MyDB.Open(); return(db.QuerySingle("Select * From Users Where LoginName = @0", LoginName)); }
void TestOqlPage() { UserEntity ue = new UserEntity(); OQL q = OQL.From(ue) .Select(ue.ID, ue.Name, ue.Age) .Where(cmp => cmp.Comparer(ue.Age, ">", 20)) .OrderBy(ue.Age) .END; q.Limit(2, 3, true); Console.WriteLine("q:Page SQL is \r\n{0}", q); Console.WriteLine(q.PrintParameterInfo()); //当前测试总记录数5,查询后,OQL会得到总记录数 AdoHelper db = MyDB.GetDBHelperByConnectionName("conn2"); var list = EntityQuery <UserEntity> .QueryList(q, db); q = OQL.From(ue) .Select(ue.Age).Sum(ue.Age, "sum_age") .GroupBy(ue.Age) .OrderBy(ue.Age) .END; q.Limit(2); var list2 = EntityQuery <UserEntity> .QueryList(q, db); Users user = new Users() { NickName = "pdf.net", RoleID = RoleNames.Admin, Age = 20 }; UserRoles roles = new UserRoles() { RoleName = "role1" }; //测试字段直接比较 OQL q00 = OQL.From(user) .Select(user.ID, user.NickName, user.LastLoginIP) .Where(cmp => cmp.Comparer(user.AddTime, "=", user.LastLoginTime)) .OrderBy(o => o.Desc(user.LastLoginTime)) .END; Console.WriteLine("q00:one table and select all fields \r\n{0}", q00); Console.WriteLine(q00.PrintParameterInfo()); string pageSql = SQLPage.MakeSQLStringByPage(DBMSType.SqlServer, q00.ToString(), "", 10, 2, 999); Console.WriteLine("Page SQL"); Console.WriteLine(pageSql); OQL q2 = OQL.From(user) .InnerJoin(roles).On(user.RoleID, roles.ID) .Select(user.RoleID, roles.RoleName) .Where(user.NickName, roles.RoleName) .GroupBy(user.RoleID, roles.RoleName) .OrderBy(user.ID) .END; Console.WriteLine("q2:two table query use join\r\n{0}", q2); Console.WriteLine(q2.PrintParameterInfo()); pageSql = SQLPage.MakeSQLStringByPage(DBMSType.SqlServer, q2.ToString(), "", 10, 2, 999); Console.WriteLine("Page SQL"); Console.WriteLine(pageSql); }
/// <summary> /// 返回用户基本信息,按 Email /// </summary> public static dynamic GetUserByEmail(string Email) { var db = MyDB.Open(); return(db.QuerySingle("Select * From Users Where Email = @0", Email)); }
protected void Page_Load(object sender, EventArgs e) { MyDB db = new MyDB(); //var usersess = "52ca747eeb12480278147796"; var usersess = Session["objid"].ToString(); var userq = Query.EQ("user", usersess); var coll = db.GetBColl("Test3"); var newcoll = db.GetBColl("useritems1" + usersess); //.InsertBatch(coll.Find(userq)); List<BsonDocument> lord = new List<BsonDocument>(); var cord = coll.Find(userq).Count(); if (cord == 0) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("0"); Response.End(); } foreach (var objord in coll.Find(userq)) { lord.Add(objord); } if (!(newcoll.Exists())) { newcoll.InsertBatch(lord); } BsonDocument bids = new BsonDocument(); var mapFunction2 = @"function() { for (var idx = 0; idx < this.order[0].Items.length; idx++) { var key = this.order[0].Items[idx].Name; var value = { count: 1, //name: this.order[1].Items[idx].Name, qty: parseFloat(this.order[0].Items[idx].Quantity), price:parseFloat(this.order[0].Items[idx].Price), //user : this.user, //orderdate: new Date(this.OrderedDate) }; emit(key, value); } }"; var reduceFunction2 = @"function(keySKU, countObjVals) { reducedVal = { count: 0, qty: 0, price: 0}; for (var idx = 0; idx < countObjVals.length; idx++) { reducedVal.count += countObjVals[idx].count; reducedVal.qty += countObjVals[idx].qty; reducedVal.price += countObjVals[idx].price; //reducedVal.OrderedDate = countObjVals[idx].OrderedDate; //reducedVal.user = countObjVals[idx].user; } //reducedVal.price.toFixed(2); return reducedVal; }"; var mr = newcoll.MapReduce(mapFunction2, reduceFunction2); //foreach (var v99 in mr.GetResults()) //{ // var vv4 = v99.ToJson(); // var vv5 = v99.ToBsonDocument(); //} var linq = from docs in mr.GetResults() orderby docs.GetElement("value").Value.ToBsonDocument().GetElement("qty").Value descending //where docs.GetElement("value").Value.ToBsonDocument().GetElement("user").Value == usersess select docs; var linqcount = linq.Count(); string finalString = ""; foreach (var document in linq) { string str = document.ToJson(); finalString += str + ","; } var count = mr.GetResults().Count(); var finalString1 = "{\"Prudhvi\":[" + finalString.Remove(finalString.Length - 1, 1) + "]}"; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(finalString1); Response.End(); }
/// <summary> /// 返回用户基本信息,按 Mobile /// </summary> public static dynamic GetUserByMobile(string Mobile) { var db = MyDB.Open(); return(db.QuerySingle("Select * From Users Where Mobile = @0", Mobile)); }
public OenologueV1(MyDB BD) { m_BD = BD; m_Nom = string.Empty; m_IndiceConfiance = IndiceConfianceMinimal; m_CotationMinimale = MinimumCotation; m_CotationMaximale = MaximumCotation; }
public CreateModel(MyDB context) { _context = context; }
public OenologueV1(MyDB BD, int Id, string Nom, double IndiceConfiance, short CotationMinimale, short CotationMaximale) { m_BD = BD; m_Id = Id; m_Nom = string.IsNullOrWhiteSpace(Nom) ? string.Empty : Nom.Trim(); m_IndiceConfiance = IndiceConfiance; m_CotationMinimale = CotationMinimale; m_CotationMaximale = CotationMaximale; }
public override void SupprimerEnCascade(MyDB Connexion) { Connexion.Executer(@"DELETE FROM subfaction WHERE sf_fk_faction_id = {0}; DELETE FROM faction WHERE fa_id = {0};" , Id); }
public static IEnumerable<OenologueV1> Lister(MyDB BD, Listing Modalite) { string Requete = "SELECT * FROM oenologue"; if (Modalite == Listing.UniquementNonReferences) Requete += " WHERE id NOT IN (SELECT DISTINCT ref_oenologue FROM avis)"; return BD.Read(Requete).Select<MyDB.IRecord, OenologueV1>(Enregistrement => Creer(Enregistrement)); }
protected void Page_Load(object sender, EventArgs e) { try { var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow); DateTime dt = DateTime.Now; var dateto = dt; string objectidvalue = Session["objid"].ToString(); MyDB md = new MyDB(); var registration = md.GetBColl("registration"); var orders = md.GetBColl("Test3"); var temporders = md.GetBColl("temporders"); var queryid = new QueryDocument("_id", ObjectId.Parse(objectidvalue)); var queryidwithvalue = new QueryDocument("user", objectidvalue); var sss = Session["order"]; BsonElement bshipmobformer = null; foreach (BsonDocument borg in registration.Find(queryid)) { bshipmobformer = borg.GetElement("mobile"); } if (sss == null) { BsonDocument bd1 = new BsonDocument(); foreach (BsonDocument bits in temporders.Find(queryidwithvalue)) { bits.Remove("regtoship"); string username = Session["username"].ToString(); bits.Add("name", username); bits.Add("user", objectidvalue); bits.Add("ISODate", dateto); bits.Add("mobile", bshipmobformer.Value); bits.Add("shipadd", "Pick at Store"); bits.Add("orderstatus", "undeliver"); orders.Insert(bits); orders.Save(bits); temporders.Remove(queryidwithvalue); } Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Session["order"] = null; Session.Remove("order"); Response.Write(1.ToString()); //Valid User Response.End(); } else { string orderdet = Session["order"].ToString(); string omedet = "[" + orderdet + "]"; var res = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonArray>(omedet); BsonDocument bd = new BsonDocument(); bd.Add("user", objectidvalue); string username = Session["username"].ToString(); bd.Add("name", username); bd.Add("ISODate", dateto); bd.Add("mobile", bshipmobformer.Value); bd.Add("shipadd", "Pick at Store"); bd.Add("orderstatus", "undeliver"); bd.Add("order", res); orders.Insert(bd); orders.Save(bd); Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Session["order"] = null; Session.Remove("order"); Response.Write(1.ToString()); //Valid User Response.End(); } } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
//public List<Member> selectMember() public Member selectMemberByMem_id(Member memberDTO) { MyDB mydb = new MyDB(); Member mem = new Member(); MySqlConnection con = null; MySqlDataReader rd = null; try { con = mydb.GetCon(); string Sql = "SELECT * FROM toourshared.member as mem WHERE mem.mem_id = @mem_id"; MySqlCommand cmd = new MySqlCommand(Sql, con); cmd.Parameters.AddWithValue("@mem_id", memberDTO.Mem_id); con.Open(); rd = cmd.ExecuteReader(); if (rd.Read()) { mem = new Member(); mem.Mem_id = rd["mem_id"].ToString(); mem.Mem_state = rd["mem_state"].ToString(); mem.Mem_phone = rd["mem_phone"].ToString(); mem.Mem_pw = rd["mem_pw"].ToString(); mem.Mem_name = rd["mem_name"].ToString(); mem.Mem_sex = rd["mem_sex"].ToString(); mem.Mem_ques = rd["mem_ques"].ToString(); mem.Mem_answer = rd["mem_answer"].ToString(); mem.Mem_birth = rd["mem_birth"].ToString(); mem.Mem_email = rd["mem_email"].ToString(); mem.Mem_reg_datetime = rd["mem_reg_datetime"].ToString(); mem.Mem_timestmap = rd["mem_timestmap"].ToString(); mem.Mem_img_url = rd["mem_img_url"].ToString(); // mem_img_url 컬럼에 NULL or EMPTY or "noImage" 일 경우 "./img/memberNoImage.png" 로 속성 값 적용 if (string.IsNullOrEmpty(mem.Mem_img_url) || mem.Mem_img_url == "noImage") { mem.Mem_img_url = "./img/memberNoImage.png"; } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace.ToString()); if (rd != null) { rd.Close(); } if (con != null) { con.Close(); } } finally { if (rd != null) { rd.Close(); } if (con != null) { con.Close(); } } return(mem); }
public void InitData() { clear(); using (MyDB mydb = new MyDB()) { WFTemplate wft = new WFTemplate { ID = Guid.NewGuid().ToString(), Name = "费用申请流程", BuizCode = "ApplyExpense", BuizName = "费用申请", Creator = mydb.Users.First(u => u.Code.Equals("chw")), CreateTime = DateTime.Now, Nodes = new WFNode[] { new WFNodeStart { Name = "开始", Next = null }, new WFNodeHandle { Name = "创建申请", ViewCode = "createForm", ViewName = "创建表单", Actions = new [] { new WFNodeAction { Code = "save", Name = "保存", NextNode = null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code = "submit", Name = "提交", NextNode = null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("chw")), mydb.Users.First(u => u.Code.Equals("lilin")) } }, new WFNodeHandle { Name = "部门确认", ViewCode = "auditForm", ViewName = "审核表单", Actions = new [] { new WFNodeAction { Code = "pass", Name = "确认", NextNode = null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code = "deny", Name = "否决", NextNode = null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("chw")) } }, new WFNodeHandle { Name = "副总审核", ViewCode = "auditForm", ViewName = "审核表单", Actions = new [] { new WFNodeAction { Code = "pass", Name = "确认", NextNode = null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code = "deny", Name = "否决", NextNode = null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("chw")) } }, new WFNodeXORSplit { Name = "费用金额分支", //Next = null, //缺省节点 WFNodeExpressions = new [] { new WFNodeExpression { Expression = "{费用金额}>10000", Description = "费用金额大于10000元时,需要总经理审核", Next = null, OrderNO = 1 }, new WFNodeExpression { Expression = "{费用金额}>5000", Description = "费用金额大于5000元时,需要通知监察科", Next = null, OrderNO = 3 } } }, new WFNodeHandle { Name = "总经理审核", ViewCode = "auditForm", ViewName = "审核表单", Actions = new [] { new WFNodeAction { Code = "pass", Name = "同意", NextNode = null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code = "deny", Name = "不同意", NextNode = null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("lxx")) } }, new WFNodeFinish { ID = Guid.NewGuid().ToString(), Name = "结束" } } }; mydb.WFTemplates.Add(wft); wft.Nodes.OfType <WFNodeStart>().First().Next = wft.Nodes.First(n => n.Name.Equals("创建申请")); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("创建申请")).Actions.First(a => a.Code.Equals("submit")).NextNode = wft.Nodes.First(n => n.Name.Equals("部门确认")); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("部门确认")).Actions.First(a => a.Code.Equals("pass")).NextNode = wft.Nodes.First(n => n.Name.Equals("副总审核")); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("部门确认")).Actions.First(a => a.Code.Equals("deny")).NextNode = wft.Nodes.OfType <WFNodeFinish>().First(); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("副总审核")).Actions.First(a => a.Code.Equals("pass")).NextNode = wft.Nodes.First(n => n.Name.Equals("费用金额分支")); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("副总审核")).Actions.First(a => a.Code.Equals("deny")).NextNode = wft.Nodes.OfType <WFNodeFinish>().First(); //wft.Nodes.OfType<WFNodeXORSplit>().First(n => n.Name.Equals("费用金额分支")).Next = wft.Nodes.OfType<WFNodeFinish>().First(); wft.Nodes.OfType <WFNodeXORSplit>().First(n => n.Name.Equals("费用金额分支")).WFNodeExpressions.First(exp => exp.Expression.Equals("{费用金额}>10000")).Next = wft.Nodes.First(n => n.Name.Equals("总经理审核")); wft.Nodes.OfType <WFNodeXORSplit>().First(n => n.Name.Equals("费用金额分支")).WFNodeExpressions.First(exp => exp.Expression.Equals("{费用金额}>5000")).Next = wft.Nodes.First(n => n.Name.Equals("总经理审核")); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("总经理审核")).Actions.First(a => a.Code.Equals("pass")).NextNode = wft.Nodes.OfType <WFNodeFinish>().First(); wft.Nodes.OfType <WFNodeHandle>().First(n => n.Name.Equals("总经理审核")).Actions.First(a => a.Code.Equals("deny")).NextNode = wft.Nodes.OfType <WFNodeFinish>().First(); try { mydb.SaveChanges(); } catch (Exception e) { } } }
public UserDao() { db = new MyDB(); }
public static DataSet FillDataSetTaiKhoan() { return(MyDB.FillDataSet("SELECT * FROM viewGetTaiKhoan", CommandType.Text)); }
public ProductDetailsDao() { db = new MyDB(); }
public FooObject(MyDB dbContext) { _db = dbContext; }
static void Main(string[] args) { Console.WriteLine("====**************** PDF.NET SOD ORM 控制台测试程序 **************===="); Assembly coreAss = Assembly.GetAssembly(typeof(AdoHelper));//获得引用程序集 Console.WriteLine("框架核心程序集 PWMIS.Core Version:{0}", coreAss.GetName().Version.ToString()); Console.WriteLine(); Console.WriteLine(@"====应用程序配置文件默认的数据库配置信息:=========================== 当前使用的数据库类型是:{0} 连接字符串为:{1} 请确保数据库服务器和数据库是否有效(SqlServer,Access 会自动创建数据库), 继续请回车,退出请输入字母 Q ." , MyDB.Instance.CurrentDBMSType.ToString(), MyDB.Instance.ConnectionString); Console.WriteLine("=====Power by Bluedoctor,2015.3.1 http://www.pwmis.com/sqlmap ======="); string read = Console.ReadLine(); if (read.ToUpper() == "Q") { return; } Console.WriteLine(); Console.WriteLine("-------PDF.NET SOD ORM 测试 开始 ---------"); //自动创建数据库和表 LocalDbContext context = new LocalDbContext(); int count = 0; //测试查询&&更新 User zhang_san = new User() { Name = "zhang san" }; User dbZhangSan = EntityQuery <User> .QueryObject( OQL.From(zhang_san) .Select(zhang_san.ID, zhang_san.Name, zhang_san.Pwd) .Where(cmp => cmp.EqualValue(zhang_san.Name)) .END ); if (dbZhangSan != null) { dbZhangSan.Pwd = "111111"; dbZhangSan.RegistedDate = DateTime.Now; int updateCount = EntityQuery <User> .Instance.Update(dbZhangSan); Console.WriteLine("测试:用户{0} 的密码和注册日期已经更新", zhang_san.Name); } else { Console.WriteLine("测试:用户{0} 的记录不存在,如果需要测试查询和更新,请先添加一条记录。继续测试,请按任意键。", zhang_san.Name); Console.Read(); } System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); //删除 测试数据----------------------------------------------------- User user = new User(); OQL deleteQ = OQL.From(user) .Delete() .Where(cmp => cmp.Comparer(user.ID, ">", 0)) //为了安全,不带Where条件是不会全部删除数据的 .END; count = EntityQuery <User> .ExecuteOql(deleteQ, context.CurrentDataBase); Console.WriteLine("--删除 {0}条数据--", count); //----------------------------------------------------------------- //插入 测试数据----------------------------------------------------- count = 0; zhang_san = new User() { Name = "zhang san", Pwd = "123" }; count += context.Add <User>(zhang_san);//采用 DbContext 方式插入数据 User li_si = new User() { Name = "li si", Pwd = "123" }; OQL insertQ = OQL.From(li_si) .Insert(li_si.Name); //仅仅插入用户名,不插入密码 //采用OQL方式插入指定的数据 //同时演示事务使用方法 AdoHelper db = MyDB.GetDBHelperByConnectionName("local"); EntityQuery <User> userQuery = new EntityQuery <User>(db); //db.BeginTransaction(); //try //{ // count += userQuery.ExecuteOql(insertQ); // // userQuery.GetInsertIdentity(insertQ); 获取插入标识,用词方法代替下面的方式 // //OQL 方式没法取得自增数据,所以下面单独查询 // object obj_id = db.ExecuteScalar(db.InsertKey); // db.Commit(); // li_si.ID = Convert.ToInt32( obj_id); //} //catch (Exception ex) //{ // Console.WriteLine("AdoHelper 执行事务异常:"+ex.Message ); // db.Rollback(); // Console.WriteLine("按任意键退出!"); // return; //} //上面的代码注释,采用下面封装的代码:ExecuteInsrtOql li_si.ID = userQuery.ExecuteInsrtOql(insertQ); for (int i = 0; i < 1000; i++) { User zhang_yeye = new User() { ID = 1000 + i, Name = "zhang yeye" + i, Pwd = "pwd" + i }; count += EntityQuery <User> .Instance.Insert(zhang_yeye);//采用泛型 EntityQuery 方式插入数据 } Console.WriteLine("--插入 {0}条数据--", count); //----------------------------------------------------------------- //修改 测试数据---------------------------------------------------- li_si.Pwd = "123123"; count = context.Update <User>(li_si);//采用 DbContext 方式更新数据 li_si.Pwd = "123456"; OQL updateQ = OQL.From(li_si) .Update(li_si.Pwd) //仅仅更新密码 .END; count += EntityQuery <User> .Instance.ExecuteOql(updateQ);//采用OQL方式更新指定的数据 li_si.Pwd = "888888"; count += EntityQuery <User> .Instance.Update(li_si);//采用泛型 EntityQuery 方式修改数据 Console.WriteLine("--修改 {0}次数据,User ID:{1}--", count, li_si.ID); //----------------------------------------------------------------- //查询数据--------------------------------------------------------- Console.WriteLine("SOD ORM的 6种 查询方式,开始----"); UserLoginService service = new UserLoginService(); Console.WriteLine("Login0:{0}", service.Login(zhang_san)); Console.WriteLine("Login1:{0}", service.Login1(zhang_san)); Console.WriteLine("Login2:{0}", service.Login2("zhang san", "123")); Console.WriteLine("Login3:{0}", service.Login3("zhang san", "123")); Console.WriteLine("Login4:{0}", service.Login4("zhang san", "123")); Console.WriteLine("Login5:{0}", service.Login5("zhang san", "123")); Console.WriteLine("Login6:{0}", service.Login6("zhang yeye", "pwd100")); //查询列表 var users = service.FuzzyQueryUser("zhang"); Console.WriteLine("模糊查询姓 张 的用户,数量:{0}", users.Count); //----------------------------------------------------------------- Console.WriteLine("-------PDF.NET SOD ORM 测试 全部结束----- "); watch.Stop(); Console.WriteLine("耗时:(ms)" + watch.ElapsedMilliseconds); Console.Read(); }
public void updateSQLTags() { if (fit_first_load) { logger.Logged("Info", "Загрузка данных в расходомеров.", "", ""); var list_sum_id = new List <int> { 721 }; for (int i = 0; i < list_sum_id.Count; i++) { logger.Logged("Info", "Расходомер fit0" + i + " с суммарным тегом " + list_sum_id[i] + ".", "", ""); var startDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 2, 0, 0); var startLastDay = startDay.AddDays(-1); var now2Hour = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0); now2Hour = now2Hour.Hour % 2 > 0 ? now2Hour.AddHours(-1) : now2Hour; var last2Hour = now2Hour.AddHours(-2); logger.Logged("Info", "Загрузка дат: начало предыдущих суток {" + startLastDay + "},начало текущих суток {" + startDay + "}," + "начало предыдущих 2 часов {" + last2Hour + "},начало текущих 2 часов {" + now2Hour + "}." + " Текущее время {" + DateTime.Now + "}.", "", ""); var sumBeforeLastDay = Convert.ToDouble(ProcFl(MyDB.sql_query_local(GetTop1ValBeforeDatesById(list_sum_id[i], startLastDay)).GetValue(0, 0), 1)); logger.Logged("Info", "Расход на начало предыдущих суток: " + sumBeforeLastDay + "/{" + startLastDay + "}.", "", ""); var sumLastDay = Convert.ToDouble(ProcFl(MyDB.sql_query_local(GetTop1ValBeforeDatesById(list_sum_id[i], startDay)).GetValue(0, 0), 1)); logger.Logged("Info", "Расход на начало текущих суток: " + sumLastDay + "/{" + startDay + "}.", "", ""); var sumLast2Hour = Convert.ToDouble(ProcFl(MyDB.sql_query_local(GetTop1ValBeforeDatesById(list_sum_id[i], last2Hour)).GetValue(0, 0), 1)); logger.Logged("Info", "Расход на начало предыдущих 2 часов: " + sumLast2Hour + "/{" + last2Hour + "}.", "", ""); var sumNow2Hour = Convert.ToDouble(ProcFl(MyDB.sql_query_local(GetTop1ValBeforeDatesById(list_sum_id[i], last2Hour)).GetValue(0, 0), 1)); logger.Logged("Info", "Расход на начало текущих 2 часов: " + sumNow2Hour + "/{" + startDay + "}.", "", ""); var sumNow = Convert.ToDouble(ProcFl(MyDB.sql_query_local(GetTop1ValBeforeDatesById(list_sum_id[i], DateTime.Now)).GetValue(0, 0), 1)); logger.Logged("Info", "Расход на текущее время: " + sumNow + "/{" + DateTime.Now + "}.", "", ""); _fitList.Add(new FitValueContainer { Name = "fit0" + i, Id = list_sum_id[i], sumNow = (float)(sumNow), summlastDay = (float)(sumBeforeLastDay), summtoDay = (float)(sumLastDay), summlast2H = (float)(sumLast2Hour), summto2H = (float)(sumNow2Hour), lastDay_Time = startDay, last2H_Time = last2Hour, to2H_Time = now2Hour, lastDay = (float)(sumLastDay - sumBeforeLastDay), toDay = (float)(sumNow - sumLastDay), last2H = (float)(sumNow2Hour - sumLast2Hour), to2H = (float)(sumNow - sumNow2Hour) }); } fit_first_load = false; } else { foreach (var fit in _fitList) { var sumNow = Convert.ToDouble(ProcFl(MyDB.sql_query_local(GetTop1ValBeforeDatesById(fit.Id, DateTime.Now)).GetValue(0, 0), 1)); fit.sumNow = (float)sumNow; // fit.toDay = fit.sumNow - fit.summtoDay; fit.to2H = fit.sumNow - fit.summto2H; /* * //if (DateTime.Now > fit.lastDay_Time.AddDays(1)) * if (DateTime.Now > fit.lastDay_Time.AddMinutes(2)) * { * fit.lastDay = fit.toDay; * fit.summlastDay = fit.summtoDay; * fit.summtoDay = fit.sumNow; * * fit.last2H = fit.to2H; * fit.summlast2H = fit.summto2H; * fit.summto2H = fit.sumNow; * * //fit.lastDay_Time = fit.lastDay_Time.AddDays(1); * fit.lastDay_Time = DateTime.Now; * * } */ //if (DateTime.Now > fit.to2H_Time.AddHours(2)) if (DateTime.Now > fit.to2H_Time.AddSeconds(60)) { fit.last2H = fit.to2H; fit.summlast2H = fit.summto2H; fit.summto2H = fit.sumNow; //fit.to2H_Time = fit.to2H_Time.AddHours(2); fit.to2H_Time = DateTime.Now; } OnUpdate(new TagId { PollerId = 0, TagName = fit.Name + ".lastDay" }, Convert.ToString(fit.last2H), DateTime.Now, 192); OnUpdate(new TagId { PollerId = 0, TagName = fit.Name + ".last2H" }, Convert.ToString(fit.last2H), DateTime.Now, 192); OnUpdate(new TagId { PollerId = 0, TagName = fit.Name + ".toDay" }, Convert.ToString(fit.toDay), DateTime.Now, 192); OnUpdate(new TagId { PollerId = 0, TagName = fit.Name + ".to2H" }, Convert.ToString(fit.to2H), DateTime.Now, 192); } } }
protected void Page_Load(object sender, EventArgs e) { try { MyDB md = new MyDB(); var gcoll = md.GetBColl("guests"); string gdums = null; var gjson = ""; var gjsonconcat = ""; var storesession = Session["storename"].ToString(); //var gquery = new QueryDocument("order.storeName", storesession); var gquery = Query.EQ("order.storeName", storesession); var mc = gcoll.Find(gquery).ToArray(); for (var i = 0; i < mc.Count(); i++) { BsonDocument bgdoc = mc[i].ToBsonDocument(); BsonElement objectid = bgdoc.GetElement("_id"); bgdoc.Add("orderid", objectid.Value.ToString()); bgdoc.Remove("_id"); gjson = bgdoc.ToJson(); var jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(gjson.ToString()); gdums += jsonoffer.ToString() + ","; } gjsonconcat = gdums; var gstringremove = gjsonconcat; string dums = null; var outjson = ""; var outjsonconcat = ""; var varjson = ""; var coll = md.GetBColl("orders"); BsonElement buser = null; BsonValue buservalue = null; BsonElement bcname = null; BsonElement bmob = null; BsonValue busernamevalue = null; BsonElement my_id = null; dums = null; var mcord = coll.Find(gquery).ToArray(); for (var j = 0; j < mcord.Count(); j++) { BsonDocument bids = mcord[j].ToBsonDocument(); my_id = bids.GetElement("_id"); bids.Add("orderid", my_id.ToString().Substring(4)); buser = bids.GetElement("user"); buservalue = buser.Value; bmob = bids.GetElement("mobile"); bids.Remove("mobile"); var regcoll = md.GetBColl("registration"); var query1 = new QueryDocument("_id", ObjectId.Parse(buservalue.ToString())); foreach (BsonDocument bc in regcoll.Find(query1)) { bcname = bc.GetElement("name"); } busernamevalue = bcname.Value; bids.Add("mobile", Convert.ToDouble(bmob.Value)); bids.Add("name", busernamevalue); bids.Remove("_id"); //bids.Remove("shipadd"); bids.Remove("user"); varjson = bids.ToJson(); var jsonoffer = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(varjson.ToString()); dums += jsonoffer.ToString() + ","; } outjsonconcat = dums + gstringremove; outjson += outjsonconcat; var finalString = "\"Prudhvi\":[" + outjson.Remove(outjson.Length - 1, 1) + "]}" + ","; var stringremove = "{" + finalString.Remove(finalString.Length - 1, 1); //var stringremove = "{Prudhvi:[" + outjson.Remove(outjson.Length - 1, 1) + "]}"; Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write(stringremove.ToString()); Response.End(); } catch (ThreadAbortException ee) { } catch (Exception eee) { Response.Clear(); Response.CacheControl = "no-cache"; Response.ContentType = "application/json"; Response.Write("exception"); //Valid User Response.End(); } }
/// <summary> /// Méthode appelée lorsqu'un changement d'état de la connexion au serveur MySQL se produit /// </summary> /// <param name="ConnexionEmetrice">Connexion concernée par le changement d'état</param> /// <param name="EtatPrecedent">Etat précédant ce changement</param> /// <param name="NouvelEtat">Nouvel état résultant de ce changement</param> private static void BD_SurChangementEtatConnexion(MyDB ConnexionEmetrice, MyDB.EtatConnexion EtatPrecedent, MyDB.EtatConnexion NouvelEtat) { System.Diagnostics.Debug.WriteLine(string.Format("\nCONNEXION BD :\nChangement d'état : {0} ==>> {1}\n", EtatPrecedent, NouvelEtat)); }
/// <summary> /// 更新最后登录时间为当前时间 /// </summary> public static void UpdateLastLoginTime(int UserID) { var db = MyDB.Open(); db.Execute("Update Users Set LastLoginTime = GetDate() Where UserID = @0", UserID); }
public EFBigliettoService(MyDB context) { this.context = context; }