private void fbLogin(HttpContext context) { string token = context.Request.Params["token"]; Facebook.FacebookClient client = new Facebook.FacebookClient(token); //client.Post() client.UseFacebookBeta = client.IsSecureConnection = true; Facebook.JsonObject o = (Facebook.JsonObject)client.Get("/me"); var db = new PetaPoco.Database(Common.HairStyleConnectionString, "System.Data.SqlClient"); using (var scope = db.GetTransaction()) { try { string first_name = (string)o["first_name"]; string name = (string)o["name"]; decimal id = Convert.ToDecimal(o["id"]); POCOS.Facebook fb = new POCOS.Facebook(); fb.name = name; fb.first_name = first_name; fb.gender = (string)o["gender"]; fb.id = id; fb.last_name = (string)o["last_name"]; fb.link = (string)o["link"]; fb.locale = (string)o["locale"]; fb.timezone = Convert.ToDouble(o["timezone"]); string updatedtime = (string)o["updated_time"]; DateTime dt; if (DateTime.TryParse(updatedtime, out dt)) { fb.updated_time = dt; } if (db.Exists <POCOS.Facebook>(id)) { db.Update(fb); } else { db.Insert(fb); } POCOS.AppUser au = POCOS.AppUser.FirstOrDefault("Select top 1 * from AppUsers where facebookid=@0", id); if (au == null) { au = new POCOS.AppUser(); au.FirstName = first_name; au.facebookid = id; db.Insert(au); } scope.Complete(); CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false); CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false); } finally { scope.Dispose(); } } }
public int QuestionAdd(string question, bool shownOnlyForDoctors = false, bool hiddenFromUi = false) { var a = new Question(); a.text = question; a.shown_only_for_doctors = shownOnlyForDoctors; a.hidden_from_ui = hiddenFromUi; _db.Insert(a); return(a.question_id); }
/// <summary> /// 数据插入 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tbName"></param> /// <param name="primaryKey"></param> /// <param name="autoIncrement"></param> /// <param name="t"></param> /// <returns></returns> public int InsertModel <T>(string tbName, string primaryKey, bool autoIncrement, T t) { int _intRlt = 0; _intRlt = Convert.ToInt32(db.Insert(tbName, primaryKey, autoIncrement, t)); return(_intRlt); }
public int InsertEntityImage(EntityImage model) { using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection")) { return((int)context.Insert(model)); } }
public IHttpActionResult Post() { var file = HttpContext.Current.Request.Files[0]; if (file != null) { string filename = Guid.NewGuid().ToString() + file.FileName; string pic = System.IO.Path.GetFileName(filename); string path = System.IO.Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/Upload"), pic); // file is uploaded file.SaveAs(path); var db = new PetaPoco.Database("AGSoftware"); Entities.StorytimePost storytimepost = new Entities.StorytimePost(); storytimepost.DateCreated = System.DateTime.Now; storytimepost.ImagePath = filename; storytimepost.PostText = HttpContext.Current.Request.Form["posttext"]; storytimepost.UserId = Storytime.Providers.UserHelper.GetUserId(HttpContext.Current.User.Identity.Name); storytimepost.StorytimeId = int.Parse(HttpContext.Current.Request.Form["storytimeid"]); storytimepost.SeriesId = int.Parse(HttpContext.Current.Request.Form["SeriesId"]); db.Insert(storytimepost); return Ok(storytimepost.StorytimePostId); } else { return BadRequest("File upload missing."); } }
private static void Crud() { var petaPoco = new PetaPoco.Database("Chinook"); var customer = new Customer { FirstName = "Ian", LastName = "Russell", Email = "*****@*****.**" }; petaPoco.Insert(customer); var id = customer.CustomerId; customer = petaPoco.Single <Customer>(id); ObjectDumper.Write(customer); customer.Country = "United Kingdom"; petaPoco.Update(customer); customer = petaPoco.Single <Customer>(id); ObjectDumper.Write(customer); petaPoco.Delete <Customer>(id); customer = petaPoco.SingleOrDefault <Customer>(id); ObjectDumper.Write(customer); }
public int InsertLoveStory(OurLoveStory model) { using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection")) { return((int)context.Insert(model)); } }
public static bool AddLink(Models.Links model) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { return(db.Insert(model) != null); } }
private static void Crud() { var petaPoco = new PetaPoco.Database("Chinook"); var customer = new Customer { FirstName = "Ian", LastName = "Russell", Email = "*****@*****.**" }; petaPoco.Insert(customer); var id = customer.CustomerId; customer = petaPoco.Single<Customer>(id); ObjectDumper.Write(customer); customer.Country = "United Kingdom"; petaPoco.Update(customer); customer = petaPoco.Single<Customer>(id); ObjectDumper.Write(customer); petaPoco.Delete<Customer>(id); customer = petaPoco.SingleOrDefault<Customer>(id); ObjectDumper.Write(customer); }
public void AddMovie(Movie movie) { using (var db = new PetaPoco.Database(ConnectionString, providerName)) { db.Insert(movie); } }
public int InsertOurEvent(OurEvent model) { using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection")) { return((int)context.Insert(model)); } }
public ActionResult GetFinishApi() { var db = new PetaPoco.Database("LocalDBConnStr"); GetFinishTrade b = new GetFinishTrade(); b.MerchantID = Request["MerchantID"]; b.MerchantTradeNo = Request["MerchantTradeNo"]; b.PaymentDate = Request["PaymentDate"]; b.PaymentType = Request["PaymentType"]; b.PaymentTypeChargeFee = Request["PaymentTypeChargeFee"]; b.RtnCode = int.Parse(Request["RtnCode"].ToString()); b.RtnMsg = Request["RtnMsg"]; b.SimulatePaid = int.Parse(Request["SimulatePaid"].ToString()); b.TradeAmt = decimal.Parse(Request["TradeAmt"].ToString()); b.TradeDate = Request["TradeDate"]; b.TradeNo = Request["TradeNo"]; b.CheckMacValue = Request["CheckMacValue"]; b.TotalCount = (Request["TotalCount"] == null) ? 0 : int.Parse(Request["TotalCount"].ToString()); if (b.MerchantID != null) { db.Insert(b); return(Content("1|OK")); } else { return(Content("0|ErrorMessage")); } }
public static bool AddForum(Models.Forums form) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { return(db.Insert(form) != null); } }
public void InitDataBase(string connectionString) { var db = new PetaPoco.Database(connectionString, "System.Data.SqlClient"); db.Execute(Const.DBCreateScript); foreach (var province in ProvinceData.GetProvinces()) { db.Insert("Province", "Id", new{Name = province.Name, Code = province.Code}); } var provinces = db.Query<dynamic>(@"SELECT * from Province").ToList(); BulkUploadToSql bulk = BulkUploadToSql.Load( HomeData.GetHomes() .Select( i => new Bulk.Home { AddTime = DateTime.Now, BuildYear = i.BuildYear, City = i.City, Description = i.Description, Price = i.Price, Surface = i.Surface, ProvinceId = provinces.First(j => j.Code == i.HomeProvince.Code).Id, }), "Home", 10000, connectionString); bulk.Flush(); }
public IHttpActionResult Post() { var file = HttpContext.Current.Request.Files[0]; if (file != null) { string filename = Guid.NewGuid().ToString() + file.FileName; string pic = System.IO.Path.GetFileName(filename); string path = System.IO.Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/Upload"), pic); // file is uploaded file.SaveAs(path); var db = new PetaPoco.Database("AGSoftware"); Entities.StorytimePost storytimepost = new Entities.StorytimePost(); storytimepost.DateCreated = System.DateTime.Now; storytimepost.ImagePath = filename; storytimepost.PostText = HttpContext.Current.Request.Form["posttext"]; storytimepost.UserId = Storytime.Providers.UserHelper.GetUserId(HttpContext.Current.User.Identity.Name); storytimepost.StorytimeId = int.Parse(HttpContext.Current.Request.Form["storytimeid"]); storytimepost.SeriesId = int.Parse(HttpContext.Current.Request.Form["SeriesId"]); db.Insert(storytimepost); return(Ok(storytimepost.StorytimePostId)); } else { return(BadRequest("File upload missing.")); } }
public ActionResult Create(Personnel personnel, HttpPostedFileBase file) { if (ModelState.IsValid) { try { //image upload if (file == null || !isImageValid(file)) { ModelState.AddModelError(string.Empty, string.Empty); } else { isActivePersonel(personnel); db.Insert(personnel); //Save Image File to Local string imagePath = "~/Uploads/Images/" + "Image_" + personnel.ID + ".png"; saveImage(file, imagePath); //Save Image Path to DB and Update Personnel personnel.PhotoPath = imagePath; db.Update(personnel); return(RedirectToAction("Index")); } } catch (Exception) { throw; } } return(View(personnel)); }
public static int AddForum(Models.Forums form) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { int id = Convert.ToInt32(db.Insert(form)); return(id); } }
public static bool AddCategory(Category model) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { model.ListNum = 0; return(db.Insert(model) != null); } }
public static bool CreatUser(User user) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { user.Password = XBBS.Core.Utils.MD5(user.Password); return db.Insert(user) != null; } }
public static int AddForum(Models.Forums form) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { int id = Convert.ToInt32(db.Insert(form)); return id; } }
public static bool CreatUser(User user) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { user.Password = XBBS.Core.Utils.MD5(user.Password); return(db.Insert(user) != null); } }
/// <summary> /// Inserts a new snapshot /// </summary> /// <param name="snapshot">Snapshot instance</param> public void InsertSnapshot(SnapshotDetail snapshot) { CreateSnapshotTable(); using (var db = new PetaPoco.Database(_snapshotConnectionStringName)) { db.Insert(SnapshotTableName, "Id", snapshot); } }
/// <summary> /// Inserts a new event stream /// </summary> /// <param name="events">Events to insert</param> public void InsertEvents(EventStream events) { CreateEventTable(); using (var db = new PetaPoco.Database(_eventConnectionStringName)) { db.Insert(EventStreamTableName, "Id", events); } }
public int addSignature(Models.DigiSignature currentSignatureObject) { int currentObjectId = -1; var db = new PetaPoco.Database("Olgarsconnection"); db.Insert("DigiSignature", "DigiSignatureId", true, currentSignatureObject); currentObjectId = currentSignatureObject.DigiSignatureId; return(currentObjectId); }
private void CreateIfNotExists(DBObject.Configuration configuration) { string query = UseTableNameFix ? "SELECT * FROM \"tblConfiguration\" WHERE name='" : "SELECT * FROM tblConfiguration WHERE name='"; if (_database.Query <DBObject.Configuration>(query + configuration.name + "'").Count() == 0) { _database.Insert("tblConfiguration", "name", configuration); } }
public int InsertContactUs(ContactUs model) { ContactUs contactUs = new ContactUs(); using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection")) { contactUs = model; return((int)context.Insert(contactUs)); } }
public int addMessageLog(Models.OlgarsMessageLog newMessageLog) { int leadLogId = -1; var db = new PetaPoco.Database("Olgarsconnection"); db.Insert("OlgarsMessageLog", "OlgarsMessageLogId", true, newMessageLog); leadLogId = newMessageLog.OlgarsMessageLogId; return(leadLogId); }
public IHttpActionResult Post([FromUri] string id, [FromBody]Entities.Logs logs) { var db = new PetaPoco.Database("AGSoftware"); logs.EventDateTime = System.DateTime.Now; logs.UserName = this.User.Identity.Name; db.Insert(logs); return Ok(); }
public void BasicCRUD() { var db = new PetaPoco.Database("Chinook"); var newID = db.Insert(new Artist { Name = "Woot" }); var acdcnew = db.Update(new Artist { ArtistId = 1, Name = "AC/DC Blah" }); var acdc = db.Update(new Artist { ArtistId = 1, Name = "AC/DC" }); }
public IHttpActionResult Post([FromUri] string id, [FromBody] Entities.StorytimeSeries storytimeseries) { var db = new PetaPoco.Database("AGSoftware"); storytimeseries.StorytimeId = int.Parse(id); storytimeseries.DateCreated = System.DateTime.Now; storytimeseries.UserId = Storytime.Providers.UserHelper.GetUserId(this.User.Identity.Name); storytimeseries.UsersNotified = false; db.Insert(storytimeseries); return Ok(storytimeseries); }
public IHttpActionResult Post([FromUri] string id, [FromBody] Entities.StorytimeSeries storytimeseries) { var db = new PetaPoco.Database("AGSoftware"); storytimeseries.StorytimeId = int.Parse(id); storytimeseries.DateCreated = System.DateTime.Now; storytimeseries.UserId = Storytime.Providers.UserHelper.GetUserId(this.User.Identity.Name); storytimeseries.UsersNotified = false; db.Insert(storytimeseries); return(Ok(storytimeseries)); }
public IHttpActionResult Post([FromUri] string id, [FromBody] Entities.Logs logs) { var db = new PetaPoco.Database("AGSoftware"); logs.EventDateTime = System.DateTime.Now; logs.UserName = this.User.Identity.Name; db.Insert(logs); return(Ok()); }
public static bool AddUserGroup(string groupName) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { var model = new UserGroup() { GroupName = groupName, GroupType = 3, UserNum = 0 }; return(db.Insert(model) != null); } }
public object POST([FromBody] Novedad item) { try { var db = new PetaPoco.Database("jlapc"); if (item.NovedadID == 0) { db.Insert(item); } else { db.Update(item); } return (new JsonResult() { Data = new { ok = true, error = "" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data; } catch (Exception e) { return (new JsonResult() { Data = new { ok = false, error = e.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }).Data; } }
public static bool AddComment(Models.Comment comment) { var f = GetForum(comment.FId); if (f == null) return false; using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { f.LastReply = DateTime.Now; f.Comments++; f.Ruid = comment.UId; db.Update(f, new string[] { "lastreply", "comments","ruid" }); return db.Insert(comment) != null; } }
public ActionResult Create(ContactsMapper mContact) { IMapper mapper = AutoMapperInitializer.getMapper(); var contact = mapper.Map <Contacts>(mContact); var back = mapper.Map <ContactsMapper>(contact); var dataContext = new PetaPoco.Database("sqladdress"); dataContext.Insert(contact); return(RedirectToAction("Index")); }
public Show PostSave(Show show) { var db = new PetaPoco.Database("umbShow"); if (show.idShow > 0) { db.Update(show); } else { db.Insert(show); } return(show); }
// Add error response to database private void insertErrorResponse(string fullUrl) { var db = new PetaPoco.Database("myConnectionString"); var responseError = new pixResponseError(); responseError.url = fullUrl; try { db.Insert(responseError); db.CloseSharedConnection(); } catch (Exception e) { log.Fatal("Error inserting response error to DataBase", e); } }
public string create(HoiVien hv) { var db = new PetaPoco.Database("MyConnection"); hv.APK = Guid.NewGuid(); try { db.Insert(hv); } catch (Exception e) { if (e.Message.Contains("Violation of PRIMARY KEY")) { return "pk"; } return e.ToString(); } return "ok"; }
public void SaveCustomer(Customer customer) { if (!File.Exists(DbFile)) { CreateDatabase(); } using (var cnn = SimpleDbConnection()) { using (var db = new PetaPoco.Database(cnn)) { cnn.Open(); db.Insert(customer); } } }
public void Handle(AccountCreatedEvent domainEvent) { // Update the Read database Console.WriteLine("Inserting a new account record with a starting balance of {0}", domainEvent.Amount); using (var db = new PetaPoco.Database("DemoConnectionString")) { var account = new BankAccountReadModel { Id = domainEvent.Id, CurrentBalance = domainEvent.Amount }; db.Insert(account); } }
private void button2_Click(object sender, EventArgs e) { // Create a PetaPoco database object var db = new PetaPoco.Database("sqlite"); foo foo = new foo(); foo.name = "PetaPoco Insert Test"; try { db.Insert("foo", "Id", foo); } catch (Exception ex) { Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace); } this.fooQuery1.Refresh(); }
/// <summary> /// 插入标签 /// </summary> /// <param name="targTitle"></param> /// <param name="fid"></param> public static void AddTarg(string targTitle, int fid) { using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection")) { Models.Targs tag = db.SingleOrDefault<Models.Targs>("WHERE tag_title=@0", targTitle); if (tag == null) { tag = new Models.Targs(); tag.Forums = fid; tag.Title = targTitle; db.Save(tag); } Models.TargsRelation tagr = new Models.TargsRelation(); tagr.TagID = tag.TagID; tagr.ForumsId = fid; db.Insert(tagr); } }
public IHttpActionResult AddNewGroupUsers([FromBody]Entities.UserGroup usergroup) { var db = new PetaPoco.Database("AGSoftware"); var b = db.SingleOrDefault<Entities.UserGroup>("Select * from UserGroup Where UserGroupId = @0", usergroup.UserGroupId); Entities.UserGroupUser usergroupuser = null; foreach (Entities.AspNetUsers user in usergroup.Users) { //todo see if there is a better way to do this with normalization and/or one connection. var db2 = new PetaPoco.Database("AGSoftware"); usergroupuser = new Entities.UserGroupUser(); usergroupuser.UserGroupId = usergroup.UserGroupId; usergroupuser.UserId = db2.SingleOrDefault<Entities.AspNetUsers>("Select Id from AspNetUsers where Id = @0", user.Id).Id; ; db2.Insert(usergroupuser); } return Ok(); }
public IHttpActionResult Post([FromUri] string id, [FromBody]Entities.UserGroup usergroup) { var db = new PetaPoco.Database("AGSoftware"); usergroup.UserId = Storytime.Providers.UserHelper.GetUserId(this.User.Identity.Name); usergroup.DateCreated = System.DateTime.Now; db.Insert(usergroup); Entities.UserGroupUser usergroupuser = null; foreach (Entities.AspNetUsers user in usergroup.Users) { //todo see if there is a better way to do this with normalization and/or one connection. var db2 = new PetaPoco.Database("AGSoftware"); usergroupuser = new Entities.UserGroupUser(); usergroupuser.UserGroupId = usergroup.UserGroupId; usergroupuser.UserId = db2.SingleOrDefault<Entities.AspNetUsers>("Select Id from AspNetUsers where Id = @0", user.Id).Id; ; db2.Insert(usergroupuser); } return Ok(usergroup.UserGroupId); }
public ActionResult Create(Classes myClass) { if (ModelState.IsValid) { try { var db = new PetaPoco.Database("MissNancy"); myClass.Active = true; db.Insert("tblClasses", "ClassKey", myClass); return RedirectToAction("Index"); } catch (Exception e) { return View(myClass); } } else { return View(myClass); } }
public IHttpActionResult Post([FromUri] string id, [FromBody]Entities.Contact contact) { var db = new PetaPoco.Database("AGSoftware"); var a = db.SingleOrDefault<Entities.AspNetUsers>("Select * from AspNetUsers Where PhoneNumber = @0", contact.PhoneNumber); if (a != null) { Entities.ContactList contactlist = new Entities.ContactList(); contactlist.UserId = Storytime.Providers.UserHelper.GetUserId(this.User.Identity.Name); contactlist.ContactId = a.Id; contactlist.DateCreated = System.DateTime.Now; db.Insert(contactlist); return Ok(); } else { return NotFound(); } }
private void fbLogin(HttpContext context) { string token = context.Request.Params["token"]; Facebook.FacebookClient client = new Facebook.FacebookClient(token); //client.Post() client.UseFacebookBeta = client.IsSecureConnection = true; Facebook.JsonObject o = (Facebook.JsonObject)client.Get("/me"); var db = new PetaPoco.Database(Common.HairStyleConnectionString, "System.Data.SqlClient"); using (var scope = db.GetTransaction()) { try { string first_name = (string)o["first_name"]; string name = (string)o["name"]; decimal id = Convert.ToDecimal(o["id"]); POCOS.Facebook fb = new POCOS.Facebook(); fb.name = name; fb.first_name = first_name; fb.gender = (string)o["gender"]; fb.id = id; fb.last_name = (string)o["last_name"]; fb.link = (string)o["link"]; fb.locale = (string)o["locale"]; fb.timezone = Convert.ToDouble(o["timezone"]); string updatedtime = (string)o["updated_time"]; DateTime dt; if (DateTime.TryParse(updatedtime, out dt)) fb.updated_time = dt; if (db.Exists<POCOS.Facebook>(id)) db.Update(fb); else db.Insert(fb); POCOS.AppUser au = POCOS.AppUser.FirstOrDefault("Select top 1 * from AppUsers where facebookid=@0", id); if (au == null) { au = new POCOS.AppUser(); au.FirstName = first_name; au.facebookid = id; db.Insert(au); } scope.Complete(); CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false); CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false); } finally { scope.Dispose(); } } }
/// <summary> /// 文件保存操作 /// </summary> /// <param name="basePath"></param> private void SaveFile(string basePath, string ImageSession) { var name = string.Empty; basePath = (basePath.IndexOf("~") > -1) ? System.Web.HttpContext.Current.Server.MapPath(basePath) : basePath; HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; //如果目录不存在,则创建目录 if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } var suffix = files[0].ContentType.Split('/'); //获取文件格式 var _suffix = suffix[1].Equals("jpeg", StringComparison.CurrentCultureIgnoreCase) ? "jpg" : suffix[1]; //var _temp = System.Web.HttpContext.Current.Request["name"]; ////如果不修改文件名,则创建随机文件名 //if (!string.IsNullOrEmpty(_temp)) //{ // name = _temp; //} //else //{ // Random rand = new Random(24 * (int)DateTime.Now.Ticks); // name = rand.Next() + "." + _suffix; //} var _temp = Guid.NewGuid() + "." + _suffix; //文件保存 var full = basePath + _temp; files[0].SaveAs(full); T_ERP_Image img = new T_ERP_Image(); img.Guid = Guid.NewGuid(); img.Creator = img.Updator = "Sys"; img.CreateDate = img.UpdateDate = DateTime.Now; img.Reserved2 = img.Remark = string.Empty; img.Reserved3 = false; img.Session = Guid.Parse(ImageSession); img.SavedFileName = _temp; using (var db = new PetaPoco.Database(SQLCONN.Conn)) { db.Insert(img); } var _result = "{\"jsonrpc\" : \"2.0\", \"result\" : null, \"id\" : \"" + name + "\"}"; System.Web.HttpContext.Current.Response.Write(_result); }
public void Report(PayUReport report) { // steps // 1. Check if report sig is valid // 2. If valid ask for status // 3. Response: OK // sig = md5 ( pos_id + session_id + ts + key2 ) var sig = PayUHelper.GetSig(report.pos_id.ToString(), report.session_id, report.ts, _key2); if (sig != report.sig) { throw new Exception("Wrong sig!"); } try { var db = new PetaPoco.Database("appHarbor"); // sig = md5 ( pos_id + session_id + ts + key1 ) var ts = PayUHelper.TS.ToString(); sig = PayUHelper.GetSig(report.pos_id.ToString(), report.session_id, ts, _key1); // get using (var client = new WebClient()) { var url = string.Format("{0}/{1}", _payUUrl, _encoding); byte[] response = client.UploadValues(url + "/Payment/get", new NameValueCollection() { { "pos_id", report.pos_id.ToString() }, { "session_id", report.session_id }, {"ts", ts}, {"sig", sig}, }); var xmlResult = System.Text.Encoding.Default.GetString(response); // stroe xml in db db.Insert("reports", "id", new Report { Date = DateTime.Now, XmlReport = xmlResult }); } } catch (Exception ex) { var db = new PetaPoco.Database("appHarbor"); db.Insert("reports", "id", new Report { Date = DateTime.Now, XmlReport = ex.Message }); Response.Write(ex.Message); } Response.Write("OK"); }
private void DoBackgroundWork_Insert(object sender, System.ComponentModel.DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; // Create a PetaPoco database object var db = new PetaPoco.Database("sqlite"); using (var transaction = db.GetTransaction()) { for (int i = 0; i < count; i++) { foo foo = new foo(); foo.name = "PetaPoco Insert Test " + i; db.Insert("foo", "Id", foo); if (i % 500 == 0) worker.ReportProgress(i);//this.fooQuery1.AppendDisplay("."); } transaction.Complete(); } }
private static int InsertTest(string connectionString) { Home pocoHome; var db = new PetaPoco.Database(connectionString, "System.Data.SqlClient"); var provinces = db.Query<dynamic>(@"SELECT * from Province"); foreach (var home in HomeData.Get100Homes()) { pocoHome = new Home { BuildYear = home.BuildYear, City = home.City, Description = home.Description, ProvinceId = provinces.First(i => i.Code == home.HomeProvince.Code).Id, Price = home.Price, Surface = home.Surface, AddTime = DateTime.Now }; db.Insert("Home", "Id", pocoHome); } return 100; }
public bool Insert(UnitInfoModel unitInfoModel) { // if the work unit is not valid simply return if (!ValidateUnitInfo(unitInfoModel.UnitInfoData)) { return false; } // The Insert operation does not setup a WuHistory table if // it does not exist. This was already handled when the // the DatabaseFilePath was set. Debug.Assert(TableExists(SqlTable.WuHistory)); // ensure this unit is not written twice if (UnitInfoExists(unitInfoModel)) { return false; } var entry = AutoMapper.Mapper.Map<HistoryEntry>(unitInfoModel.UnitInfoData); // cannot map these two properties from a UnitInfo instance // they only live at the UnitInfoLogic level entry.FramesCompleted = unitInfoModel.FramesComplete; entry.FrameTimeValue = unitInfoModel.GetRawTime(PpdCalculationType.AllFrames); // copy protein values for insert entry.WorkUnitName = unitInfoModel.CurrentProtein.WorkUnitName; entry.KFactor = unitInfoModel.CurrentProtein.KFactor; entry.Core = unitInfoModel.CurrentProtein.Core; entry.Frames = unitInfoModel.CurrentProtein.Frames; entry.Atoms = unitInfoModel.CurrentProtein.NumberOfAtoms; entry.BaseCredit = unitInfoModel.CurrentProtein.Credit; entry.PreferredDays = unitInfoModel.CurrentProtein.PreferredDays; entry.MaximumDays = unitInfoModel.CurrentProtein.MaximumDays; using (var connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (var database = new PetaPoco.Database(connection)) { database.Insert(entry); } } return true; }