public void GenCalStockInfoArchive() { try { CheckIsDone(); LogHelper.doLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, "Start Done " + GetDate.ToString("yyyy-MM-dd")); using (StockEntities db = new StockEntities()) { db.Database.ExecuteSqlCommand("GenCalStockInfoArchive @BackupDate ", new SqlParameter("BackupDate", GetDate.ToString("yyyy-MM-dd"))); } if (!System.IO.Directory.Exists(CheckDoneDirPath)) { System.IO.Directory.CreateDirectory(CheckDoneDirPath); } System.IO.File.WriteAllText(this.CheckDoneFullPath, "done"); LogHelper.doLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, "Archive Done"); } catch (Exception e) { LogHelper.doLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, "[Exception]" + e.Message); } }
// GET: Order public ActionResult Index() { if (Session["CustId"] == null || Session["CustId"].ToString() == "") { return(RedirectToAction("Register", "Home")); } StockEntities db = new StockEntities(); int usrId = Convert.ToInt32(Session["CustId"]); var q = from s in db.CustomerInfoes where s.CustId == usrId select s; var result = q.ToList(); return(View(result)); // StockEntities db = new StockEntities(); // int usrId = Convert.ToInt32(Session["CustId"]); // var q = from s in db.VW_OrderAndDetailAndCust // where s.CustId == usrId // select s; // var result = q.ToList(); // return View(result); //// return View(); }
public static List <HighQualityListModel> QueryQuality() { List <QueryHighQualityList_Result> SpHighQualityList = new List <QueryHighQualityList_Result>(); List <HighQualityListModel> HighQualityList = new List <HighQualityListModel>(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <QueryHighQualityList_Result, HighQualityListModel>(); }); IMapper iMapper = config.CreateMapper(); using (StockEntities db = new StockEntities()) { db.Database.ExecuteSqlCommand(" GenStockInfo @StockNum ", new SqlParameter("StockNum", "")); SpHighQualityList = db.QueryHighQualityList(0.05).ToList(); } SpHighQualityList.ForEach(t => { HighQualityListModel r = iMapper.Map <QueryHighQualityList_Result, HighQualityListModel>(t); HighQualityList.Add(r); }); LogHelper.doLog("StableStockServices_QueryQuality", JsonConvert.SerializeObject(HighQualityList)); return(HighQualityList); }
/// <summary> /// 取得最近更新時間 /// </summary> /// <returns></returns> internal DateTime GetLastUpdateTime() { using (var db = new StockEntities()) { var result = db.ForeignOwn.Where(c => c.Code == 50).OrderByDescending(c => c.Date).Take(1).Select(c => c.Date).Single(); return(result); } }
public ActionResult MyOrder() { //取得目前登入使用者Id int userId = Convert.ToInt32(Session["CustId"]); using (StockEntities db = new StockEntities()) { var result = (from s in db.OrderInfoes where s.CustId == userId select s).ToList(); return(View(result)); } }
/// <summary> /// 新增法人持股 /// </summary> /// <param name="models"></param> /// <returns></returns> internal int InsertForeignOwn(List <ForeignOwn> models) { var count = 0; using (var db = new StockEntities()) { // 有相同日期不上傳 if (models.Count > 0 && models[0] != null && !db.ForeignOwn.AsEnumerable().Any(c => c.Date == models[0].Date)) { db.ForeignOwn.AddRange(models); count = db.SaveChanges(); } } return(count); }
/// <summary> /// 新增三大買賣超 /// </summary> /// <param name="models"></param> /// <returns></returns> internal int Insert3BigBuySell(List <ThreeBigBuySell> models) { var count = 0; using (var db = new StockEntities()) { // 有相同日期不上傳 if (models.Count > 0 && models[0] != null && !db.ThreeBigBuySell.AsEnumerable().Any(c => c.Date == models[0].Date)) { db.ThreeBigBuySell.AddRange(models); count = db.SaveChanges(); } } return(count); }
//stockremain stockremain = new stockremain(); private async void btnAPI_Click(object sender, EventArgs e) { DateTime currentTime = System.DateTime.Now.AddDays(0); string strYMD = currentTime.ToString("yyyy-MM-dd"); string str = strYMD.Replace("-", ""); dataModel dataModel = new dataModel(); //計算執行時間 Stopwatch System.Diagnostics.Stopwatch watcher = new System.Diagnostics.Stopwatch(); watcher.Start(); Modelview.dataModelview.stockData res = await dataModel.Read(str); StockEntities stock = new StockEntities(); this.dataGridView1.DataSource = stock.data.ToList(); watcher.Stop(); this.label3.Text = $"非同步共耗時 {watcher.Elapsed.TotalSeconds} 秒,共{stock.data.Count()}筆資料"; this.dataGridView1.Columns.Remove("id"); //取得更新收盤價 if (db.stockremain.Count() != 0) { var price = (from d in db.data join s in db.stockremain on d.證券代號 equals s.證券代號 select d.收盤價).ToList(); dataModel.Update(price); } //更新自選清單 if (db.datasave.Count() != 0) { var save = (from d in db.data join ds in db.datasave on d.證券代號 equals ds.證券代號 select d).ToList(); dataModel.Updatedatasave(save); } }
public ActionResult MyOrderDetail(int id) { using (StockEntities db = new StockEntities()) { var result = (from s in db.OrderDetails where s.OrderId == id select s).ToList(); if (result.Count == 0) { return(RedirectToAction("Index")); } else { return(View(result)); } } }
public static List <HighQualityListModel> QueryHighQualityListForSlot() { List <QueryHighQualityListForSlot_Result> SpHighQualityList = new List <QueryHighQualityListForSlot_Result>(); List <HighQualityListModel> HighQualityList = new List <HighQualityListModel>(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <QueryHighQualityList_Result, HighQualityListModel>(); }); IMapper iMapper = config.CreateMapper(); using (StockEntities db = new StockEntities()) { SpHighQualityList = db.QueryHighQualityListForSlot(0.05).ToList(); } SpHighQualityList.ForEach(t => { HighQualityListModel r = iMapper.Map <QueryHighQualityListForSlot_Result, HighQualityListModel>(t); HighQualityList.Add(r); }); for (int i = 0; i < HighQualityList.Count; i = i + 100) { var items = HighQualityList.Skip(i).Take(100); ReceiveByHighQualityListReqModel r = new ReceiveByHighQualityListReqModel(); r.HighQualityStock = items.ToList <HighQualityListModel>(); var jsonText = "{\"ReqParam\" : " + JsonConvert.SerializeObject(r) + @"}"; LogHelper.doLog("StableStockServices_QueryHighQualityListForSlot", "==發送(" + r.HighQualityStock.Count().ToString() + "筆)==\r\n" + jsonText); WebClient client = new WebClient(); client.Encoding = Encoding.UTF8; client.Headers.Add(HttpRequestHeader.ContentType, "application/json"); client.Headers.Add("PowerAdmin", Setting.AppSettings("PowerAdmin")); var response = client.UploadData(Common.Tools.Setting.AppSettings("ReceiveByHighQualityList"), "POST", Encoding.UTF8.GetBytes(jsonText)); string resResult = Encoding.UTF8.GetString(response); LogHelper.doLog("StableStockServices_QueryHighQualityListForSlot", "==接收==\r\n" + resResult); } LogHelper.doLog("StableStockServices_QueryHighQualityListForSlot", JsonConvert.SerializeObject(HighQualityList)); return(HighQualityList); }
public ActionResult MyOrderDetail(Ship postback) { //Cart cart = new Cart(); if (this.ModelState.IsValid) //取得目前購物車 { var currentcart = Cart.Operation.GetCurrentCart(); //取得目前登入使用者Id int userId = Convert.ToInt32(Session["CustId"]); using (StockEntities db = new StockEntities()) { //建立Order物件 var order = new OrderInfo() { // UserId = userId, // RecieverName = postback.RecieverName, // RecieverPhone = postback.RecieverPhone, // RecieverAddress = postback.RecieverAddress CustId = userId, OrderTotal = currentcart.TotalAmount, //cartitem.Price, OrderTime = DateTime.Now, }; ////加其入Orders資料表後,儲存變更 db.OrderInfoes.Add(order); db.SaveChanges(); //取得購物車中OrderDetai物件 var orderDetails = currentcart.ToOrderDetail(order.OrderId); //將其加入OrderDetails資料表後,儲存變更 db.OrderDetails.AddRange(orderDetails); db.SaveChanges(); } return(Content("訂購成功")); } return(View()); }
public ActionResult Index(Ship postback) { StockEntities db = new StockEntities(); int usrId = Convert.ToInt32(Session["CustId"]); var q = from s in db.CustomerInfoes where s.CustId == usrId select s; var result = q.ToList(); var q1 = (from s in db.OrderInfoes orderby s.OrderId descending select s.OrderId).FirstOrDefault(); int orderId = q1 + 1; //StockEntities db = new StockEntities(); //int usrId = Convert.ToInt32(Session["CustId"]); // var q = from s in db.VW_OrderAndDetailAndCust // where s.CustId == usrId // select s; // var result = q.ToList(); //Cart cart = new Cart(); if (this.ModelState.IsValid == false) { /*if (this.ModelState.IsValid) {*/ //取得目前購物車 var currentcart = Cart.Operation.GetCurrentCart(); var q2 = (from s in db.OrderInfoes orderby s.OrderId descending select s.OrderId).FirstOrDefault(); int orderid = q2 + 1; //取得目前登入使用者Id //int userId = Convert.ToInt32(Session["CustId"]); //int userId = Convert.ToInt32(Session["CustId"]); using (StockEntities db1 = new StockEntities()) { //建立Order物件 var order = new OrderInfo() { // UserId = userId, // RecieverName = postback.RecieverName, // RecieverPhone = postback.RecieverPhone, // RecieverAddress = postback.RecieverAddress OrderId = orderid, CustId = usrId, OrderTotal = currentcart.TotalAmount, //cartitem.Price, OrderTime = DateTime.Now, }; ////加其入Orders資料表後,儲存變更 db1.OrderInfoes.Add(order); db1.SaveChanges(); //var q2 = (from s in db.OrderInfoes // orderby s.OrderId descending // select s.OrderId).FirstOrDefault(); //int orderid = q2 + 1; //取得購物車中OrderDetai物件 //var orderDetails = currentcart.ToOrderDetail(order.OrderId); var orderDetails = currentcart.ToOrderDetail(orderid); //將其加入OrderDetails資料表後,儲存變更 db1.OrderDetails.AddRange(orderDetails); db1.SaveChanges(); } var qTotal = (from s in db.OrderDetails where s.OrderId == orderid select s).ToList(); int sum = 0; foreach (var item in qTotal) { sum += item.ProdPrice * item.ProdQuantity; } //var order = new OrderInfo() { // // UserId = userId, // // RecieverName = postback.RecieverName, // // RecieverPhone = postback.RecieverPhone, // // RecieverAddress = postback.RecieverAddress // //OrderId =orderId, // CustId = usrId, // OrderTotal = sum, //cartitem.Price, // OrderTime = DateTime.Now, //}; //////加其入Orders資料表後,儲存變更 //db.OrderInfoes.Add(order); //db.SaveChanges(); //return Content("訂購成功"); return(RedirectToAction("MyOrder", "Home")); } return(View(result)); }
public CategorieService(StockEntities context) { Context = context; }
public ProduitService(StockEntities context) { Context = context; }
public MouvementService(StockEntities context) { Context = context; }
public StockEntities Init() { return(dbContext ?? (dbContext = new StockEntities())); }