public int Compare(string x, string y) { FileDate a = new FileDate(x); FileDate b = new FileDate(y); return(a.CompareTo(b)); } // Compare
static FileDate parseBoardFile() { FileDate fd = new FileDate(); fd.board = new String[9]; FileStream fs = null; try { fs = File.OpenRead("board.txt"); StreamReader sr = new StreamReader(fs); fd.player = sr.ReadLine(); for (int i = 0; i < 9; i++) { fd.board[i] = sr.ReadLine(); } fs.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); Environment.Exit(0); } return(fd); }
} // ToString public int CompareTo(FileDate a) { if (Year != a.Year) { return(Year.CompareTo(a.Year)); } if (Month != a.Month) { return(Month.CompareTo(a.Month)); } if (Day != a.Day) { return(Day.CompareTo(a.Day)); } return(a.FileNo.CompareTo(FileNo)); } // CompareTo
/* Tail starts here */ static void Main(String[] args) { String player; String[] board = new String[9]; if (File.Exists("board.txt")) { FileDate fd = parseBoardFile(); board = fd.board; player = fd.player; } else { player = Console.ReadLine(); for (int i = 0; i < 9; i++) { board[i] = Console.ReadLine(); } } nextMove(player, board); }
public override async Task <List <OberloOrder> > GetCombinedUpdatedAndExistingAsync(IMyConfiguration configuration, TextWriter writer, FileDate lastCacheFileInfo, DateTime from, DateTime to) { // we have to combine two files: // the original cache file and the new transactions file await writer.WriteLineAsync(string.Format("Finding Oberlo Orders from {0:yyyy-MM-dd} to {1:yyyy-MM-dd}", from, to)); var newOberloOrders = Oberlo.ScrapeOberloOrders(configuration, from, to); var originalOberloOrders = Utils.ReadCacheFile <OberloOrder>(lastCacheFileInfo.FilePath); // copy all the original Oberlo orders into a new file, except entries that are // from the from date or newer var updatedOberloOrders = originalOberloOrders.Where(p => p.CreatedDate < from).ToList(); // and add the new orders to beginning of list updatedOberloOrders.InsertRange(0, newOberloOrders); return(updatedOberloOrders); }
public override string ToString() { return(string.Format("{0}. DetailID {1}. {2}", base.ToString(), DetailID, FileDate.ToString("dd MMM yy"))); }
private bool DatabaseContainsData() { FileDate = _binaryReader.ReadInt32(); if (FileDate < 20191105) { _logger?.Log(string.Format("Outdated osu!.db version({0}). Load failed.", FileDate.ToString())); return(false); } ExpectedNumberOfMapSets = _binaryReader.ReadInt32(); _logger?.Log(string.Format("Expected number of mapSets: {0}", ExpectedNumberOfMapSets)); try { bool something = _binaryReader.ReadBoolean(); DateTime a = GetDate().ToLocalTime(); _binaryReader.BaseStream.Seek(1, SeekOrigin.Current); Username = _binaryReader.ReadString(); ExpectedNumOfBeatmaps = _binaryReader.ReadInt32(); _logger?.Log(string.Format("Expected number of beatmaps: {0}", ExpectedNumOfBeatmaps)); if (ExpectedNumOfBeatmaps < 0) { return(false); } } catch { return(false); } return(true); }
private string GetDestinationFilePath() { string destinationFilePath = Job.DestinationPath; destinationFilePath = Regex.Replace(destinationFilePath, "%date:([^%]+)%", match => FileDate.ToString(match.Groups[1].Value)); const string fileNamePattern = "%file:name%"; if (Regex.IsMatch(destinationFilePath, fileNamePattern)) { destinationFilePath = Regex.Replace(destinationFilePath, fileNamePattern, Path.GetFileNameWithoutExtension(FileName)); destinationFilePath = Regex.Replace(destinationFilePath, "%file:ext%", Path.GetExtension(FileName)); } else { destinationFilePath = Path.Combine(destinationFilePath, FileName); } return(destinationFilePath); }
public override async Task <List <StripeTransaction> > GetCombinedUpdatedAndExistingAsync(IMyConfiguration configuration, TextWriter writer, FileDate lastCacheFileInfo, DateTime from, DateTime to) { // we have to combine two files: // the original cache file and the new transactions file await writer.WriteLineAsync(string.Format("Finding Stripe payout transactions from {0:yyyy-MM-dd} to {1:yyyy-MM-dd}", from, to)); var newStripePayoutTransactions = await Stripe.GetStripePayoutTransactionsAsync(configuration, from, to); var originalStripePayoutTransactions = Utils.ReadCacheFile <StripeTransaction>(lastCacheFileInfo.FilePath); // copy all the original stripe transactions into a new file, except entries that are // from the from date or newer var updatedStripePayoutTransactions = originalStripePayoutTransactions.Where(p => p.Created < from).ToList(); // and add the new transactions to beginning of list updatedStripePayoutTransactions.InsertRange(0, newStripePayoutTransactions); return(updatedStripePayoutTransactions); }
protected void ReadFolder() { List <FileDateAndItemIDs> FileDateAndItemIDsList = new List <FileDateAndItemIDs>(); IEnumerable <IGrouping <string, FileDateAndItemIDs> > FileDateGroup = FileDateAndItemIDsList.GroupBy(f => f.FileDate); string strFolderPath = Server.MapPath("/LogSample/"); string[] LogFiles = new string[] {}; AppendMessage("檢查一下Folder" + strFolderPath); try { LogFiles = Directory.GetFiles(strFolderPath); } catch (Exception ex) { AppendMessage("Catch - 2 : " + ex.Message); } AppendMessage("一共有" + LogFiles.Length.ToString() + "個檔案"); if (LogFiles.Length > 0) { #region MyRegion AppendMessage("來看一下有哪些檔案"); try { foreach (string f in LogFiles) { try { string strFilePath = f; string strFileName = Path.GetFileName(f); AppendMessage(strFileName); //這段很奇怪XD 可以再改一下 FileDateAndItemIDs ofi = CheckFileNeed(strFileName); ofi.FileFullPath = strFilePath; if (ofi.ItemIDs.Count() > 0) { FileDateAndItemIDsList.Add(ofi); } } catch (Exception ex2) { AppendMessage("Catch 檔案格式有誤:" + f + "(" + ex2.Message + ")"); } } } catch (Exception ex) { AppendMessage("Catch - 3 :" + ex.Message); } //整理一下列出我認得的file AppendMessage("列出認得的檔案 " + FileDateAndItemIDsList.Count.ToString() + " 個"); foreach (FileDateAndItemIDs fi in FileDateAndItemIDsList) { AppendMessage(fi.FileName); } AppendMessage("把檔案依日期Group 列出來 "); FileDateGroup = FileDateAndItemIDsList.GroupBy(f => f.FileDate); foreach (IGrouping <string, FileDateAndItemIDs> FileDate in FileDateGroup) { GroupTransMsg = ""; GroupAppendMessage(FileDate.Key + " 有 " + FileDate.Count() + " 個"); List <FileDateAndItemIDs> SameFileDateFileDateAndItemIDsList = FileDateAndItemIDsList.Where(fi => fi.FileDate == FileDate.Key && fi.IsMainItem == true).ToList(); GroupAppendMessage("主要介接項目" + SameFileDateFileDateAndItemIDsList.Count().ToString() + "個"); foreach (FileDateAndItemIDs fi in SameFileDateFileDateAndItemIDsList) { GroupAppendMessage(fi.FileName); } //主要介接項目 if (SameFileDateFileDateAndItemIDsList.Count > 0) { int CheckFileID = Convert.ToInt32(DBUtil.DBOp("ConnDB", "INSERT INTO [dbo].[L_LogCheckFileCount] ([FileDate] ,[MustCount] ,[ActuallyCount],CheckStatus ) VALUES ({0},{1},{2},{3} ) ;select @@identity ", new string[] { FileDate.Key, TotalNeedLogItem.ToString(), SameFileDateFileDateAndItemIDsList.Count().ToString(), (TotalNeedLogItem != SameFileDateFileDateAndItemIDsList.Count()? "2" :"1") }, NSDBUtil.CmdOpType.ExecuteScalar)); try { HandleFile(SameFileDateFileDateAndItemIDsList, CheckFileID, FileDate.Key); } catch (Exception ex) { GroupAppendMessage("Catch - 4 :" + ex.Message); } try { GroupAppendMessage("開始轉置"); ExecByOrder(CheckFileID); } catch (Exception ex) { GroupAppendMessage("Catch - ExecByOrder :" + ex.Message); } DBUtil.DBOp("ConnDB", "UPDATE [dbo].[L_LogCheckFileCount] set [TransferMsg] = {0},FinishDate=getdate() where id={1} ", new string[] { TransMsg + GroupTransMsg, CheckFileID.ToString() }, NSDBUtil.CmdOpType.ExecuteNonQuery); } } /** * AppendMessage("把檔案依日期Group 列出來"); * * * foreach (IGrouping<string, FileDateAndItemName> FileDate in FileDateGroup) * { * Response.Write(FileDate.Key + ":" + FileDate.Count() + " "); * AppendMessage(FileDate.Key + " 有 " + FileDate.Count() +" 個"); * //YOBHP 才 寫log * string[] SameFileDateLogFile = LogFiles.Where(f => f.Contains(FileDate.Key.Replace("/", "")) && f.Contains("YOBHP")).ToArray(); * if (SameFileDateLogFile.Length > 0) * { * * int CheckFileID = Convert.ToInt32(DBUtil.DBOp("ConnDB", "INSERT INTO [dbo].[L_LogCheckFileCount] ([FileDate] ,[MustCount] ,[ActuallyCount] ) VALUES ({0},{1},{2} ) ;select @@identity ", new string[] { FileDate.Key, "26", FileDate.Count().ToString() }, NSDBUtil.CmdOpType.ExecuteScalar)); * Response.Write("CheckFileID=" + CheckFileID.ToString() + "<br/>"); * * foreach (string f in SameFileDateLogFile) * { * Response.Write(" SameFileDateLogFile=" + f + "<br/>"); * } * * HandleFile(SameFileDateLogFile, CheckFileID); * * DBUtil.DBOp("ConnDB", "UPDATE [dbo].[L_LogCheckFileCount] set [TransferMsg] = {0} where id={1} ", new string[] { TransMsg, CheckFileID.ToString() }, NSDBUtil.CmdOpType.ExecuteNonQuery); * } * } * * * **/ #endregion } else { DBUtil.DBOp("ConnDB", "INSERT INTO [dbo].[L_LogCheckFileCount] ([FileDate] ,[MustCount] ,[ActuallyCount] ,CheckStatus,TransferMsg) VALUES (null,{1},0,0,{0}) ", new string[] { TransMsg, TotalNeedLogItem.ToString() }, NSDBUtil.CmdOpType.ExecuteNonQuery); } }