Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(File.Exists(sourceBonySemFile) && File.Exists(sourceBonyFile) && !File.Exists(destinationBonyFile) && !File.Exists(destinationBonySemFile))
- {
- FileStream lockSemFile = null;
- FileStream lockLabFile = null;
- DateTime now = DateTime.Now;
- try
- {
- lockSemFile = new FileStream(sourceBonySemFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Delete);
- }
- catch(Exception locksem)
- {
- string lockerrormsg = now.Hour + ":" + now.Minute + " - Sem fájl lockolása sikertelen - Hiba: " + locksem.ToString() + Environment.NewLine;
- logger.AppendText(lockerrormsg);
- }
- finally
- {
- try
- {
- lockLabFile = new FileStream(sourceBonySemFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Delete);
- }
- catch(Exception locklab)
- {
- string lockerrormsg = now.Hour + ":" + now.Minute + " - Lab fájl lockolása sikertelen - Hiba: " + locklab.ToString() + Environment.NewLine;
- logger.AppendText(lockerrormsg);
- }
- finally
- {
- try
- {
- File.Move(sourceBonyFile, destinationBonyFile);
- }
- catch(Exception labmoveex)
- {
- string lockerrormsg = now.Hour + ":" + now.Minute.ToString().PadLeft(2, '0') + " - Lab fájl mozgatása sikertelen - Hiba: " + labmoveex.ToString() + Environment.NewLine;
- logger.AppendText(lockerrormsg);
- }
- finally
- {
- string successmsg = now.Hour + ":" + now.Minute + " - A labor kérő fájl mozgatása sikeres." + Environment.NewLine;
- logger.AppendText(successmsg);
- }
- try
- {
- File.Move(sourceBonySemFile, destinationBonySemFile);
- }
- catch (Exception labsemmoveex)
- {
- string movesemerrormsg = now.Hour + ":" + now.Minute.ToString().PadLeft(2, '0') + " - Lab fájl mozgatása sikertelen - Hiba: " + labsemmoveex.ToString() + Environment.NewLine;
- logger.AppendText(movesemerrormsg);
- }
- finally
- {
- string successsemmsg = now.Hour + ":" + now.Minute + " - A labor kérő semafor fájl mozgatása sikeres." + Environment.NewLine;
- logger.AppendText(successsemmsg);
- }
- }
- }
- if(lockSemFile!=null)
- {
- lockSemFile.Dispose();
- }
- if(lockLabFile!=null)
- {
- lockLabFile.Dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement