/// <include file='summary.xml' path='Summary/Members[@name="SaveLogXml"]/*' /> ///<param name="folderCreationMode">Specifies the folder creation type</param> /// <param name="mode">Specifies Product Mode</param> /// <param name="providerType">Specifies Provider type</param> /// <param name="searchId">SearchId for identifier.</param> ///<param name="suffix">Specifies for distinguish of xml</param> ///<param name="contents">Xml String</param> ///<returns> true if log was written successfully; false otherwise</returns> public static void SaveLogXml(FolderCreationMode folderCreationMode, ProductMode mode, ProviderType providerType, string searchId, string suffix, string contents) { try { if (string.IsNullOrEmpty(searchId)) { searchId = DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "").Replace(" ", "").Replace(":", "").Replace("AM", "").Replace("PM", ""); } var path = GetXmlLogFilePath(folderCreationMode, providerType.ToString(), searchId, suffix); if (contents != null) { File.WriteAllText(path, contents); } } catch (Exception ex) { } }
/// <include file='summary.xml' path='Summary/Members[@name="SaveLogXml"]/*' /> ///<param name="folderCreationMode">Specifies the folder creation type</param> /// <param name="mode">Specifies Product Mode</param> /// <param name="providerType">Specifies Provider type</param> /// <param name="searchId">SearchId for identifier.</param> ///<param name="suffix">Specifies for distinguish of xml</param> ///<param name="objType">The object that holds the serialized object data</param> ///<returns> true if log was written successfully; false otherwise</returns> public static void SaveLogXml(FolderCreationMode folderCreationMode, ProductMode mode, ProviderType providerType, string searchId, string suffix, object objType) { if (objType == null) { throw new ArgumentNullException("objType"); } try { if (string.IsNullOrEmpty(searchId)) { searchId = DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "").Replace(" ", "").Replace(":", "").Replace("AM", "").Replace("PM", ""); } var path = GetXmlLogFilePath(folderCreationMode, providerType.ToString(), searchId, suffix); File.WriteAllText(path, SerializeAnObject(objType)); } catch (Exception ex) { } }
/// <summary> /// Read log xml string /// </summary> ///<param name="folderCreationMode">Specifies the folder creation type</param> /// <param name="mode">Specifies Product Mode</param> /// <param name="providerType">Specifies Provider type</param> /// <param name="searchId">SearchId for identifier.</param> ///<param name="suffix">Specifies for distinguish of xml</param> ///<returns>Log xml string</returns> public static string ReadLogXml(FolderCreationMode folderCreationMode, ProductMode mode, ProviderType providerType, string searchId, string suffix) { var strReadContents = string.Empty; try { if (string.IsNullOrEmpty(searchId)) { searchId = DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "").Replace(" ", "").Replace(":", "").Replace("AM", "").Replace("PM", ""); } var path = GetReadXmlLogFilePath(folderCreationMode, providerType.ToString(), searchId, suffix); if (File.Exists(path) == true) { strReadContents = File.ReadAllText(path); } else { strReadContents = "File not found"; } } catch (Exception ex) { } return(strReadContents); }
public MyProductKernel <T> KernelProduct <T>(MyNode owner, int nGPU, ProductMode mode, int bufferSize = MyParallelKernel <T> .BUFFER_SIZE, bool forceNewInstance = false) where T : struct { return(new MyProductKernel <T>(owner, nGPU, mode, bufferSize)); }
public MyProductKernel(MyNode owner, int nGPU, ProductMode mode, int bufferSize = BUFFER_SIZE) : base(owner, nGPU, ParallelKernelDescriptor.GetDescriptor(typeof(ProductMode), mode.ToString()), bufferSize) { ResetParameters(); }
/// <summary> /// specified error message and a reference to the inner exception that is /// the cause of this exception. /// </summary> ///<param name="objException">The exception that is the cause of the current /// exception. If the innerException parameter is not a <see langword="null"/> reference, /// the current exception is raised in a catch block that handles the inner /// exception. /// </param> /// <param name="folderCreationMode">Specifies the folder creation type</param> /// <param name="mode">Specifies Product Mode</param> /// <param name="errorMode">Specifies Error Mode</param> /// <param name="searchId">SearchId for identifier.</param> /// <param name="portal">Specifies Portal</param> /// <param name="module">Specifies module</param> /// <returns> true if log was written successfully; false otherwise</returns> public static bool WriteErrorLog(Exception objException, FolderCreationMode folderCreationMode, ProductMode mode, ErrorMode errorMode, string searchId, string portal, string module) { bool bReturn = false; string strException = string.Empty; try {//Inactive conversation if (objException.Message.ToUpper().Contains("INACTIVE CONVERSATION")) { ClearSessionPool(); } if (string.IsNullOrEmpty(searchId)) { searchId = DateTime.Now.ToString(CultureInfo.InvariantCulture).Replace("/", "").Replace(" ", "").Replace(":", "").Replace("AM", "").Replace("PM", ""); } var sw = new StringBuilder(); sw.Append("Source : "+ objException.Source.ToString().Trim()); sw.Append("Method : "+ objException.TargetSite.Name.ToString()); sw.Append("Date : "+ DateTime.Now.ToLongTimeString()); sw.Append("Time : "+ DateTime.Now.ToShortDateString()); sw.Append("Error : "+ objException.Message.ToString().Trim()); sw.Append("Stack Trace : "+ objException.StackTrace.ToString().Trim()); string path = GetErrorLogFilePath(folderCreationMode, searchId); WriteException(path, sw.ToString()); //LogException.clsLogException objLog = new LogException.clsLogException(); //objLog.WriteException(Mode.ToString(), "Flights", objException.Message);//Module, Product, Error Msg //sw = new StreamWriter(GetErrorLogFilePath(folderCreationMode), true); //sw.WriteLine("Source : " + objException.Source.ToString().Trim()); //sw.WriteLine("Method : " + objException.TargetSite.Name.ToString()); //sw.WriteLine("Date : " + DateTime.Now.ToLongTimeString()); //sw.WriteLine("Time : " + DateTime.Now.ToShortDateString()); //sw.WriteLine("Computer : " + Dns.GetHostName().ToString()); //sw.WriteLine("Error : " + objException.Message.ToString().Trim()); //sw.WriteLine("Stack Trace : " + objException.StackTrace.ToString().Trim()); //sw.WriteLine("^^-------------------------------------------------------------------^^"); //sw.Flush(); //sw.Close(); using (var objLoggerData = new LoggerData()) { var intMsg = objLoggerData.SaveLogError(searchId, errorMode.ToString(), objException.StackTrace.ToString(), portal, !string.IsNullOrEmpty(module) ? module : mode.ToString()); } #region Send Log / Error Email to admininistrators PreEmail.SendLogMail(objException.StackTrace.ToString(), searchId); #endregion #region Send Log / Error SMS to admininistrators if (errorMode.ToString().ToLower() == "critical") { using (SendSMS objSendSMS = new SendSMS()) { objSendSMS.MobileNo = ConfigurationSettings.AppSettings["ErrorPhoneNoTo"].ToString(); objSendSMS.Message = "New exception occurred on BMT(SearchId : " + searchId + ")"; objSendSMS.CallSMS(); } } #endregion bReturn = true; } catch (Exception ex) { bReturn = false; } return(bReturn); }
/// <summary> /// Read object from log xml string in case if not found from MemCache or Memcahche failed /// </summary> ///<param name="folderCreationMode">Specifies the folder creation type</param> /// <param name="mode">Specifies Product Mode</param> /// <param name="providerType">Specifies Provider type</param> /// <param name="searchId">SearchId for identifier.</param> ///<param name="suffix">Specifies for distinguish of xml</param> ///<param name="type">Specified for the tgype of object to be retured</param> ///<returns>Object of the Type or null</returns> public static object GetLogXmlToObject(FolderCreationMode folderCreationMode, ProductMode mode, ProviderType providerType, string searchId, string suffix, Type type) { try { var strXml = ReadLogXml(folderCreationMode, mode, providerType, searchId, suffix); if (!string.IsNullOrEmpty(strXml) && strXml != "File not found") { StringReader reader; XmlSerializer serz = new XmlSerializer(type); reader = new StringReader((string)strXml); return(serz.Deserialize(reader)); } } catch (Exception ex) { WriteErrorLog(ex, folderCreationMode, mode, ErrorMode.Normal, searchId, "BMT", "Utilities"); } return(null); }