public IHttpActionResult EditOpenTime(int id, [Bind(Include = "Id,Date,Status,SDateTime,EDateTimeDate,OpenDate,Location")] OpenTime openTime) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } OpenTime open = new OpenTime(); open = db.OpenTimes.FirstOrDefault(x => x.Id == id); open.Date = openTime.Date; open.Location = openTime.Location; open.SDateTime = openTime.SDateTime; open.EDateTimeDate = openTime.EDateTimeDate; open.OpenDate = openTime.OpenDate; open.Status = openTime.Status; db.Entry(open).State = EntityState.Modified; db.SaveChanges(); return(Ok(new { result = true, message = "營業時間更改成功" })); }
public IHttpActionResult PutOpenTime(int id, OpenTime openTime) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != openTime.Id) { return(BadRequest()); } db.Entry(openTime).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OpenTimeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private async Task AutoSave(bool synchronous) { Logger?.ConditionalTrace($"AutoSave(synchronous:{synchronous})"); // If the AutoSave path has not been set, set it now. AutoSavePath ??= OnTempFilePathRequest(OpenTime.ToString("yyyy-MM-dd-T-HH-mm-ss-fff") + ".sav"); // Ensure that auto-save is still enabled & that the content has been modified. if ((AutoSaveEnabled || synchronous) && IsDataModifiedSinceAutoSave) { Logger?.ConditionalTrace("Requesting _packageOperationSemaphore"); // Ensure we are not already saving. await _packageOperationSemaphore.WaitAsync(); Logger?.ConditionalTrace("Acquired _packageOperationSemaphore"); var saveResult = await SaveInternal(true); if (saveResult == PackageSaveResult.Success) { // Set the internal variable to ensure that we do not auto-save more than what is required. IsDataModifiedSinceAutoSave = false; } else { Logger?.Error(saveResult.Exception, $"Could not successfully auto-save package {saveResult.SaveResult}"); } } }
public override string ToString() { string tradeString = ""; if (CloseTime != null) { tradeString = Asset + "," + OpenTime.ToString("yyyy-MM-dd HH:mm:ss") + "," + ((DateTime)CloseTime).ToString("yyyy-MM-dd HH:mm:ss") + "," + OpenLevel + "," + CloseLevel + "," + Profit + "," + Size + "," + SpreadPoints + "," + SpreadCost + "," + Commission; } else { tradeString = Asset + "," + OpenTime.ToString("yyyy-MM-dd HH:mm:ss") + ",," + OpenLevel + "," + CloseLevel + "," + Profit + "," + Size + "," + SpreadPoints + "," + Commission; } //add in the trade data if any was tagged to the trade open - used for post analysis if (TradeData != null) { foreach (double val in TradeData) { tradeString += "," + val; } } return(tradeString); }
public override string ToString() { var date = OpenTime.ToDefaultString(); var chars = 8; var vol = Volume > 0 ? $" [v:{Volume.ToString().PadLeft(chars)}]" : ""; return($"{date} o:{Open.ToString().PadRight(chars, '0')} h:{High.ToString().PadRight(chars, '0')} l:{Low.ToString().PadRight(chars, '0')} c:{Close.ToString().PadRight(chars, '0')}{vol}"); }
internal void AddDataPointAtTime(DateTime time) { OpenTime.Add(time); foreach (var ds in AllDataSeries) { ds.Add(); } }
private void FoodDecision() { DateTime CurrentTime, OpenTime, ClosingTime, DinnerTime; string dinnerTime = "3:00 pm"; Boolean timefound = false; CurrentTime = DateTime.Now; DinnerTime = Convert.ToDateTime(dinnerTime); //dinnerTime OpenTime = CurrentTime; ClosingTime = CurrentTime; mssg = String.Format("The Current Time: {0}", CurrentTime.ToString("t")); Debug.WriteLine(mssg); if (opentime.ToLower().Contains("am")) { OpenTime = Convert.ToDateTime(opentime); // opentime timeconv[0] mssg = String.Format("The Open Time: {0}", OpenTime.ToString("t")); Debug.WriteLine(mssg); } if (closetime.ToLower().Contains("pm")) { ClosingTime = Convert.ToDateTime(closetime); // opentime timeconv[0] mssg = String.Format("The Close Time: {0}", ClosingTime.ToString("t")); Debug.WriteLine(mssg); } if (!timefound && CurrentTime.TimeOfDay < OpenTime.TimeOfDay) { foodDecision = String.Format(" Oh No, Ted's not open yet! "); timefound = true; } if (!timefound && CurrentTime.TimeOfDay > ClosingTime.TimeOfDay) { foodDecision = String.Format(" Oh No, Ted's closed up! "); timefound = true; } if (!timefound && CurrentTime.TimeOfDay < DinnerTime.TimeOfDay) { foodDecision = String.Format(" It is time to go to Ted’s for lunch! "); timefound = true; } if (!timefound && CurrentTime.TimeOfDay > DinnerTime.TimeOfDay) { foodDecision = String.Format("It is time to go to Ted’s for dinner!"); timefound = true; } if (timefound) { Debug.WriteLine("The time selection chose foodDecision! "); } else { Debug.WriteLine(" The time remains uncertain "); } }
public List <DateTime> GetCurrentOpenCloseTimes() { OpenTime time = Model.OpenTimes.ToList().LastOrDefault(); List <DateTime> list = new List <DateTime>() { time.WeekdayStart, time.WeekendEnd, time.WeekendStart, time.WeekendEnd }; return(list); }
public string ToString(int decimalPlaces) { var date = OpenTime.ToDefaultString(); var padChar = ' '; //var padChar = '0'; var vol = Volume > 0 ? $" [v:{Volume.ToString().PadLeft(decimalPlaces)}]" : ""; return($"{date} o:{Open.ToString().PadRight(decimalPlaces, padChar)} h:{High.ToString().PadRight(decimalPlaces, padChar)} l:{Low.ToString().PadRight(decimalPlaces, padChar)} c:{Close.ToString().PadRight(decimalPlaces, padChar)}{vol}"); }
public IHttpActionResult GetOpenTime(int id) { OpenTime openTime = db.OpenTimes.Find(id); if (openTime == null) { return(NotFound()); } return(Ok(openTime)); }
public List <Tuple <int, int> > DropdownSetterWeekend() { OpenTime time = Model.OpenTimes.ToList().LastOrDefault(); List <Tuple <int, int> > list = new List <Tuple <int, int> >() { Tuple.Create(time.WeekendStart.Hour, time.WeekendStart.Minute) }; while (time.WeekendStart.Hour != time.WeekendEnd.Hour || time.WeekendStart.Minute != time.WeekendEnd.Minute) { time.WeekendStart = time.WeekendStart.AddMinutes(30); list.Add(Tuple.Create(time.WeekendStart.Hour, time.WeekendStart.Minute)); } return(list); }
public IHttpActionResult DeleteOpenTime(int id) { OpenTime openTime = db.OpenTimes.Find(id); if (openTime == null) { return(NotFound()); } db.OpenTimes.Remove(openTime); db.SaveChanges(); return(Ok(new { result = true, message = "營業時間刪除成功" })); }
//save picture and upload public void OnClick4() { byte[] bytes = texture.EncodeToPNG(); //save to local directory //File.WriteAllBytes(Application.dataPath + "/../SavedScreen.png", bytes); string shopID = "02"; string shopName = "麥當勞"; string shopAddress = "公園北路3號"; string telephone = "091234"; Gps gps = new Gps("12.3", "2.4"); List <TimePeriod> timePeriod = new List <TimePeriod>(); timePeriod.Add(new TimePeriod("10", "30", "15", "00")); List <Item> item = new List <Item>(); item.Add(new Item(true, timePeriod)); OpenTime openTime = new OpenTime(item); List <Item2> item2 = new List <Item2>(); item2.Add(new Item2("哈哈", "笑你")); InfoList infoList = new InfoList(item2); List <Item4> item4 = new List <Item4>(); item4.Add(new Item4(bytes, "png")); Picture1 picture = new Picture1(item4); WWWForm formData = new WWWForm(); formData.AddField("shopID", shopID); formData.AddField("shopName", shopName); formData.AddField("shopAddress", shopAddress); formData.AddField("telephone", telephone); formData.AddField("gps", JsonUtility.ToJson(gps)); formData.AddField("openTime", JsonUtility.ToJson(openTime)); formData.AddField("infoList", JsonUtility.ToJson(infoList)); formData.AddField("picture", JsonUtility.ToJson(picture)); StartCoroutine(Upload(formData)); }
public IHttpActionResult PostOpenTime(OpenTime openTime) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OpenTimes.Add(openTime); db.SaveChanges(); return(Ok(new { result = true, message = "營業時間新增成功" })); //CreatedAtRoute //("DefaultApi", new { id = openTime.Id }, openTime); }
public WrapReaderData TermianlID_46(string strRecvData) { WrapReaderData readData = new WrapReaderData(); readData.TranResult = 0; //先判断包头和包尾 //第1位至2位 string strCode = strRecvData.Substring(0, 2); if (!strCode.Equals("02")) { readData.TranResult = -1; return(readData); } //第29位至30位,结束符 if (strRecvData.Length == 46) { strCode = strRecvData.Substring(44, 2); } if (!strCode.Equals("03")) { readData.TranResult = -1; return(readData); } //第3位至8位,阅读器ID //第3位至4位 strCode = strRecvData.Substring(2, 2); //阅读器ID头,默认为 54,不用转10进制,直接转为 'T' if (strCode.Equals("54")) //转为'T' { strCode = "T"; readData.ReaderID = strCode; } else { readData.ReaderID = "X"; } strCode = strRecvData.Substring(4, 8); strCode = "0000000000" + Convert.ToString(Convert.ToInt64(strCode, 16)); readData.ReaderID = readData.ReaderID + strCode.Substring(strCode.Length - 9, 9); //第13位至14位 strCode = strRecvData.Substring(12, 2); //模智宝ID头,默认为 43,不用转10进制,直接转为 'C' if (strCode.Equals("43")) //转为'C { strCode = "C"; readData.PID = strCode; } else { readData.PID = "Y"; } strCode = strRecvData.Substring(14, 10); strCode = "000000000000" + Convert.ToString(Convert.ToInt64(strCode, 16)); readData.PID = readData.PID + strCode.Substring(strCode.Length - 11, 11); if ("C00000000000".Equals(readData.PID)) { readData.PID = "C20011600001"; } //第9位至14位,模智宝ID //wrapReaderData.PID = strRecvData.Substring(8, 6); //wrapReaderData.PID = Convert.ToString(Convert.ToInt32(wrapReaderData.PID, 16)); //第15位至16位 模智宝拆除标志 if (strRecvData.Substring(24, 2).Equals("00")) { readData.RemoveTimes = 0;//正常状态 } else { readData.RemoveTimes = 1;//除拆状态 } //第17位至18位 模智宝电量标志 if (strRecvData.Substring(26, 2).Equals("00")) { readData.BatteryAlarm = "H"; //"0";//电池有电 } else { readData.BatteryAlarm = "E"; // "1";//只有10%以下的电量 //模智宝状态 } if (strRecvData.Substring(28, 2).Equals("00")) { readData.Status = 0;//工作 } else { readData.Status = 1;//休眠 } //第31位至38位 strCode = strRecvData.Substring(30, 8);//模次 strCode = Convert.ToString(Convert.ToInt32(strCode, 16)); int matchtimes; int.TryParse(strCode, out matchtimes); readData.MatchTimes = matchtimes; //第39位至40位 strCode = strRecvData.Substring(38, 2); //成型周期 Close Open strCode = Convert.ToString(Convert.ToInt32(strCode, 16)); int closeTime; int.TryParse(strCode, out closeTime); string thisCloseTime = closeTime.ToString(); readData.MatchRemain_s = closeTime; //第41位至42位 strCode = strRecvData.Substring(40, 2); //平均成型周期 Open Time strCode = Convert.ToString(Convert.ToInt32(strCode, 16)); int OpenTime; int.TryParse(strCode, out OpenTime); string ThisOpenTime = OpenTime.ToString(); readData.OpenRemain_s = OpenTime; //第43位至44位 strCode = strRecvData.Substring(42, 2); //上传失败次数 strCode = Convert.ToString(Convert.ToInt32(strCode, 16)); int lostTime; int.TryParse(strCode, out lostTime); string LostTime = lostTime.ToString(); readData.LostCnt = lostTime; string nowTimeStr = DateTime.Now.ToString("yyyy,MM,dd HH:mm:ss", new System.Globalization.DateTimeFormatInfo()); string strbuf = ("成功读取时间:" + nowTimeStr); readData.allMsg = (String.Format("{0}; Terminal-{1} Counter-{2} SC-{3} REMOVE-{4} Vot-{5} State-{6} Time-{7} 2MatchTime {8} OpenTime {9} LostTime {10}" + strRecvData + "\r\n", strRecvData, readData.ReaderID, readData.PID, readData.MatchTimes, readData.RemoveTimes, readData.BatteryAlarm, readData.Status, nowTimeStr, thisCloseTime, ThisOpenTime, LostTime)); readData.allParams = string.Empty; string strOneIDAllParam = string.Empty; strOneIDAllParam += "at=" + "CDATA"; //-----1 数据类型 --- strOneIDAllParam += "&sn=" + string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now).Substring(3, 10); //-----1 通信序列号--- strOneIDAllParam += "&ti=" + readData.ReaderID; //-----1 reader id---- strOneIDAllParam += "&tv=" + "1.0"; //-----2 终端版本--- strOneIDAllParam += "&rc=" + "2"; //-----1 路由器数 0--- strOneIDAllParam += "&bs=" + readData.BatteryAlarm; //-----1 电池状态----- strOneIDAllParam += "&ci=" + readData.PID; //---1 计数器id-------- strOneIDAllParam += "&lst=" + string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now).Substring(0, 14); //-1 最终shot 时间--- strOneIDAllParam += "&rt=" + string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now).Substring(0, 14); //---1 通信接收时间--生成此命令时间 strOneIDAllParam += "&ct=" + readData.MatchRemain_s; //-----1 周期时间 ----- strOneIDAllParam += "&cf=" + "1"; //-----1 通信类型 长期 手动--- strOneIDAllParam += "&sc=" + (readData.MatchTimes.ToString()); //-----1 最终shot 数-------- strOneIDAllParam += "&cs=" + readData.Status; //-----1 计数器状态 strOneIDAllParam += "&rm=" + readData.RemoveTimes; //-----1 移除状态 strOneIDAllParam += ("&et=0," + readData.OpenRemain_s.ToString() + "," + readData.OpenRemain_s.ToString()); readData.allParams = strOneIDAllParam; return(readData); }
public bool Add(OpenTime ot) { Model.OpenTimes.Add(ot); return(SaveChanges()); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { string confirmationToken = WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }, true); Restaurant restaurant = new Restaurant() { Name = model.RestaurantName, Username = model.UserName, Active = false, Email = model.Email }; restaurant.OpenTimes = new List <OpenTime>(); restaurant.ClosedDates = new List <CloseDate>(); foreach (Days day in (Days[])Enum.GetValues(typeof(Days))) { OpenTime openTime = new OpenTime() { Day = day }; restaurant.OpenTimes.Add(openTime); } using (EFContext db = new EFContext()) { db.Restaurants.Add(restaurant); db.SaveChanges(); } //dynamic email = new Email("RegEmail"); //email.To = model.Email; //email.UserName = model.UserName; //email.ConfirmationToken = confirmationToken; //email.Send(); var mail = new MailMessage("*****@*****.**", model.Email); mail.IsBodyHtml = true; var subject = "Aktivering av konto"; var body = "<h2>Hej " + model.UserName + "</h2>!<br/>"; body += "För att aktivera ditt konto och registrera en restaurang, vänligen klicka på följande länk:<br/>"; //Länk till aktivering, typ "Acivate", "User" Uri uri = System.Web.HttpContext.Current.Request.Url; String host = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port; var myLink = host + "/Account/RegisterConfirmation/" + confirmationToken; mail.Subject = subject; mail.Body = body + Environment.NewLine + myLink; SmtpClient _client = new SmtpClient(); _client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; _client.PickupDirectoryLocation = HttpRuntime.AppDomainAppPath + "EmailContent"; _client.Send(mail); return(RedirectToAction("RegisterStepTwo", "Account")); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return(View(model)); }
public override string ToString() { return(OpenTime.ToString("yyyy-MM-dd HH:mm:ss") + "," + BidOpen + "," + BidClose + "," + BidHigh + "," + BidLow + "," + AskOpen + "," + AskClose + "," + AskHigh + "," + AskLow + "," + Volume); }