/// <summary> /// Method to get register according to register number /// </summary> /// <param name="register">Register</param> /// <param name="registerNumber">Register</param> public void SetRegister(ref Register register, short registerNumber) { var existingRegister = CacheManager.GetRegister(PosId); if (existingRegister != null) { register = existingRegister; return; } var device = new Device(); LoadDevice(ref device); register = _utilityService.SetRegisterInfo(registerNumber, device); if (register == null) { return; } register.WritePosLog = _utilityService.CanWritePosLog(PosId); CacheManager.AddRegister(register, PosId); }
/// <summary> /// Method to write to log file /// </summary> /// <param name="msgStr"></param> protected void WriteToLogFile(string msgStr) { try { var register = CacheManager.GetRegister(PosId); if (register.WritePosLog) { var logPath = @"C:\APILog\"; var fileName = logPath + "PosLog_" + PosId + ".txt"; WriteToLogFileFl++; if (WriteToLogFileFl > 100) { WriteToLogFileFl = (short)0; if (FileSystem.Dir(fileName) != "") { if (FileSystem.FileLen(fileName) > 1000000) { var newFName = logPath + "PosLog_" + PosId + DateAndTime.Day(DateAndTime.Today).ToString("00") + DateAndTime.Hour(DateAndTime.TimeOfDay).ToString("00") + ".txt"; Variables.CopyFile(fileName, newFName, 0); Variables.DeleteFile(fileName); } } } using (StreamWriter fileWriter = new StreamWriter(fileName, true)) { fileWriter.WriteLine(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + Strings.Space(3) + msgStr); } } } catch (Exception ex) { } }