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); }
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 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 override string ToString() { return(OpenTime.ToString("yyyy-MM-dd HH:mm:ss") + "," + BidOpen + "," + BidClose + "," + BidHigh + "," + BidLow + "," + AskOpen + "," + AskClose + "," + AskHigh + "," + AskLow + "," + Volume); }