private i9Message AgencySave(i9Message requestMessage) { i9Message ResponseMessage = new i9Message(); try { if (requestMessage.MsgBodyDataSet != null) { if (requestMessage.MsgBodyDataSet.Tables.Count > 0) { SQLAccess da = new SQLAccess(); da.SaveDataTable(requestMessage.MsgBodyDataSet.Tables["i9Agency"]); ResponseMessage.ErrorStatus.IsError = false; } } } catch (Exception ex) { ServiceLogManager.LogThis("Error saving dataset", LogEventType.Error, ex, "", ""); ResponseMessage.ErrorStatus.IsError = true; ResponseMessage.ErrorStatus.ErrorMsg = ex.Message; } return(ResponseMessage); }
private i9Message Security_SaveGroupItems(i9Message requestMessage) { i9Message ResponseMessage = new i9Message(); try { if (requestMessage.MsgBodyDataSet != null) { if (requestMessage.MsgBodyDataSet.Tables.Count > 0) { StringBuilder sbSQL = new StringBuilder(); SQLGenerator SqlGen = new SQLGenerator(); DataSet ds = requestMessage.MsgBodyDataSet; sbSQL.Append(SqlGen.DataTableSQL(ds.Tables["i9SecurityGroup"])); sbSQL.Append(SqlGen.DataTableSQL(ds.Tables["i9SecurityGroupModule"])); sbSQL.Append(SqlGen.DataTableSQL(ds.Tables["i9SecurityGroupTask"])); SQLAccess sqla = new SQLAccess(); string SQL = SQLUtility.WrapInTransaction(sbSQL.ToString()); sqla.ExecuteSQL(SQL); ResponseMessage.ErrorStatus.IsError = false; } } } catch (Exception ex) { ServiceLogManager.LogThis("Error saving dataset", LogEventType.Error, ex, "", ""); ResponseMessage.ErrorStatus.IsError = true; ResponseMessage.ErrorStatus.ErrorMsg = ex.Message; } return(ResponseMessage); }
/// <summary> /// Process Mobile Message /// </summary> /// <param name="requestMessage"></param> /// <returns></returns> public i9Message ProcessMobileMessage(i9Message requestMessage) { i9Message responseMessage = new i9Message(); switch (requestMessage.ToBizLayerMsgType) { case SecurityType.Security_PersonnelGroupsGet: responseMessage = Security_GetPersonnelGroups(requestMessage); break; case SecurityType.Security_PersonnelGroupsSave: responseMessage = Security_SavePersonnelGroups(requestMessage); break; case SecurityType.Security_SecurityGroupsGet: responseMessage = Security_GetSecurityGroups(requestMessage); break; case SecurityType.Security_SecurityGroupSave: responseMessage = Security_SaveGroupItems(requestMessage); break; case SecurityType.Security_PersonnelGroupTaskGet: responseMessage = Security_PersonnelGroupTaskGet(requestMessage); break; default: responseMessage.ErrorStatus.IsError = true; responseMessage.ErrorStatus.ErrorMsg = "Unknown Message Type(" + DateTime.Now.ToString() + "): " + requestMessage.ToBizLayerMsgType; ServiceLogManager.LogThis("Unkown message type in the Security business layer : " + requestMessage.ToBizLayerMsgType, LogEventType.Info, "", ""); break; } return(responseMessage); }
/// <summary> /// Process Mobile Message /// </summary> /// <param name="requestMessage"></param> /// <returns></returns> public i9Message ProcessMobileMessage(i9Message requestMessage) { i9Message responseMessage = new i9Message(); switch (requestMessage.ToBizLayerMsgType) { case AgencyType.Agency_GetList: responseMessage = GetList(requestMessage); break; case AgencyType.Agency_Delete: responseMessage = DeleteAgency(requestMessage); break; case AgencyType.Agency_GetDetail: responseMessage = GetDetail(requestMessage); break; case AgencyType.Agency_Save: responseMessage = AgencySave(requestMessage); break; default: responseMessage.ErrorStatus.IsError = true; responseMessage.ErrorStatus.ErrorMsg = "Unknown Message Type(" + DateTime.Now.ToString() + "): " + requestMessage.ToBizLayerMsgType; ServiceLogManager.LogThis("Unkown message type in the Agency business layer : " + requestMessage.ToBizLayerMsgType, LogEventType.Info, "", ""); break; } return(responseMessage); }
private i9Message PersonnelSave(i9Message requestMessage) { i9Message ResponseMessage = new i9Message(); try { if (requestMessage.MsgBodyDataSet != null) { if (requestMessage.MsgBodyDataSet.Tables.Count > 0) { SQLAccess da = new SQLAccess(); //TODO: Need to wrap this in a transaction da.SaveDataTable(requestMessage.MsgBodyDataSet.Tables["i9SysPersonnel"]); da.SaveDataTable(requestMessage.MsgBodyDataSet.Tables["i9SysPersonnelAddress"]); da.SaveDataTable(requestMessage.MsgBodyDataSet.Tables["i9SysPersonnelAssignment"]); da.SaveDataTable(requestMessage.MsgBodyDataSet.Tables["i9SysPersonnelPhone"]); ResponseMessage.ErrorStatus.IsError = false; } } } catch (Exception ex) { ServiceLogManager.LogThis("Error saving dataset", LogEventType.Error, ex, "", ""); ResponseMessage.ErrorStatus.IsError = true; ResponseMessage.ErrorStatus.ErrorMsg = ex.Message; } return(ResponseMessage); }
private static i9Message SendMessageAsync(i9Message MobileMsg) { i9Message ReturnMessage = new i9Message(); try { //Security Information to the Message. MobileMsg.MessageSecurity.MachineName = Environment.MachineName; MobileMsg.MessageSecurity.MachineUserName = Environment.UserName; MobileMsg.MessageSecurity.IPAddress = "???"; MobileMsg.MessageSecurity.LoginPersonnelID = ""; // SettingManager.Instance.LoginPersonnelID; MobileMsg.MessageSecurity.AgencyID = ""; // SettingManager.Instance.AgencyID; string TextMsg = MobileMsg.XMLSerializeMessage(); string ReturnXMLMessage = ""; Ii9MessageManager oIi9MessageManager = new InvertService.BusinessLib.i9MessageManagerBLL(); ReturnXMLMessage = oIi9MessageManager.ProcessMobileMessage(TextMsg); ReturnMessage = (i9Message)i9Message.XMLDeserializeMessage(typeof(i9Message), ReturnXMLMessage); } catch (Exception ex) { ReturnMessage.ErrorStatus.IsError = true; ReturnMessage.ErrorStatus.ErrorMsg = "Error: " + ex.GetBaseException().Message + Environment.NewLine + " StackTrace: " + ex.GetBaseException().StackTrace; //LogManager.Instance.LogMessage("Error in the MessageManager.SendMessage", ex); ServiceLogManager.LogThis("", LogEventType.Error, ex, "", ""); } return(ReturnMessage); }
static Bootstrap() { ServiceLogManager.SetProvider(() => new Log4NetServiceLog("Dagent")); ServiceLocatorManager.SetProvider(() => new UnityServiceLocator()) // new MicroServiceLocator()) .Register(r => { ConfigurationManagerEx.GetSection <HostingSection>("hosting").Configure(r); var appSection = ConfigurationManagerEx.GetSection <AppSection>("appSection").Configure(r); if (appSection.Log4Net) { XmlConfigurator.Configure(); } HostingEnvironment.Initialize(); }); var o = ServiceLocatorManager.Current; }
public static i9Message SendMessage(i9Message MobileMsg) { i9Message ReturnMessage = new i9Message(); try { //RespomseMsg = SendMessage_V1(MobileMsg); ReturnMessage = SendMessageAsync(MobileMsg); } catch (Exception ex) { ServiceLogManager.LogThis("", LogEventType.Error, ex, "", ""); ReturnMessage.ErrorStatus.IsError = true; ReturnMessage.ErrorStatus.ErrorMsg = "Error: " + ex.GetBaseException().Message + Environment.NewLine + " StackTrace: " + ex.GetBaseException().StackTrace; } return(ReturnMessage); }
/// <summary> /// Logs an exception and its context to the error log. /// </summary> /// <param name="e">The e.</param> /// <param name="httpContext">The HTTP context.</param> protected virtual void LogException(Exception e, HttpContext httpContext) { var serviceLog = ServiceLogManager.Get <HttpErrorTrapModule>(); if (e == null) { throw new ArgumentNullException("e"); } try { var b = new StringBuilder(); using (var w = XmlWriter.Create(b)) { w.WriteStartElement("error"); new HttpError(e, httpContext).ToXml(w); w.WriteEndElement(); } string errorText = b.ToString(); // log based on status code var httpException = (e as HttpException); if (httpException != null) { int statusId = httpException.GetHttpCode(); switch ((int)Math.Floor((double)(statusId / 100M))) { case 4: serviceLog.Information(errorText); break; default: serviceLog.Fatal(errorText); break; } } else { serviceLog.Fatal(errorText); } } catch (Exception localException) { Trace.WriteLine(localException); } }
static ConsoleServiceLog() { ServiceLogManager.EnsureRegistration(); }
public static void AddServiceLogger(IServiceLogger <TClient, TUser> serviceLogger) { ServiceLogManager <TClient, TUser> .AddLogService(serviceLogger); }
static ServiceManagerDebuggerBase() { ServiceLogManager.EnsureRegistration(); }
static StreamServiceLog() { ServiceLogManager.EnsureRegistration(); }
static TraceSourceServiceLog() { ServiceLogManager.EnsureRegistration(); }
protected override object Invoke(MethodInfo targetMethod, object[] args) { object result = null; var sourceTargetMethod = GetSourceTargetMethod(targetMethod); try { if (targetMethod == null || sourceTargetMethod == null) { throw new ArgumentException($"Middleware Framework could not get {nameof(targetMethod)}"); } var cacheKey = string.Empty; var isGetFromCache = false; var cachingProfile = sourceTargetMethod.GetCustomAttribute <CachingAttribute>(); var isCaching = sourceTargetMethod.IsCaching(); if (isCaching) { cacheKey = sourceTargetMethod.GenerateCacheKey(args, Client.GetCachePrefix(ServiceVersion)); var cachedData = CacheManager.Get(cacheKey); if (cachedData != null) { isGetFromCache = true; if (!sourceTargetMethod.HasServiceResponse()) { result = cachedData; } else { result = Activator.CreateInstance(sourceTargetMethod.ReturnType); var propertyInfo = sourceTargetMethod.ReturnType.GetProperty("Data"); propertyInfo?.SetValue(result, cachedData); } } } ServiceLogManager <TClient, TUser> .OnBeforeMethodCall(Client, User, sourceTargetMethod, args, isGetFromCache); if (!isGetFromCache) { try { result = sourceTargetMethod.Invoke(_decorated, args); } catch (Exception ex) { ServiceLogManager <TClient, TUser> .OnException(Client, User, ex, sourceTargetMethod); if (sourceTargetMethod.HasServiceResponse()) { result = ex.ToMessageResponse(sourceTargetMethod); } else { throw; } } sourceTargetMethod.CheckDropCache(); if (isCaching && result != null) { var cacheData = result; if (sourceTargetMethod.HasGenericServiceResponse()) { var propertyInfo = sourceTargetMethod.ReturnType.GetProperty("Data"); cacheData = propertyInfo?.GetValue(result); } CacheManager.Set(cacheKey, cacheData, cachingProfile.CacheDuration); } } if (sourceTargetMethod.HasGenericServiceResponse()) { var propertyInfo = sourceTargetMethod.ReturnType.GetProperty(nameof(ServiceResponse.HasAuth)); var hasAuth = (bool)(propertyInfo?.GetValue(result) ?? false); if (!hasAuth) { propertyInfo?.SetValue(result, User != null); } } ServiceLogManager <TClient, TUser> .OnAfterMethodCall(Client, User, sourceTargetMethod, args, result, isGetFromCache); return(result); } catch (Exception ex) { var targetException = ex.InnerException ?? ex; ServiceLogManager <TClient, TUser> .OnException(Client, User, targetException, sourceTargetMethod); throw targetException; } }
static SPDeveloperServiceLog() { ServiceLogManager.EnsureRegistration(); }
public string ProcessMobileMessage(string Message) { ServiceLogManager.LogThis(Message, LogEventType.InMessages, "", ""); i9Message Response = new i9Message(); try { i9Message RequestMessage = (i9Message)i9Message.XMLDeserializeMessage(typeof(i9Message), Message); if (RequestMessage.MessageFormatVersion != i9Message.MESSAGE_FORMAT_VERSION) { throw new Exception("Your Invert911 Cloud app is out of sync with the Clould server. Please upgrade to the latest i9Invert911 Clound App"); } //Need to Log Inbound Message //ServiceLogManager.LogThis(Message, LogEventType.Info, RequestMessage.MessageSecurity.LoginPersonnelID, RequestMessage.MessageSecurity.AgencyID); //Security Check: if (HasSecurityRight(RequestMessage, ref Response) == false) { return(Response.XMLSerializeMessage()); } //Module Message Switch. Routes Messages switch (RequestMessage.ToBizLayer) { case MobileMessageType.Admin: Response = new AdminBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.Agency: Response = new AgencyBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.Citation: Response = new CitationBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.Common: Response = new CommonBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.FieldContact: Response = new FieldContactBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.Incident: Response = new LawIncidentBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.SyncCache: Response = new SyncBLL().ProcessMobileMessage(RequestMessage); break; case MobileMessageType.Security: Response = new SecurityBLL().ProcessMobileMessage(RequestMessage); break; default: ServiceLogManager.LogThis("Unkown message type in the Message Manager BLL: " + RequestMessage.ToBizLayerMsgType, LogEventType.Info, "", ""); Response.ErrorStatus.SetError(true, "Message Type is unknown", new Exception()); break; } } catch (Exception ex) { ServiceLogManager.LogThis("Error", LogEventType.Error, ex, "", ""); Response.ErrorStatus.IsError = true; Response.ErrorStatus.ErrorMsg = "Error processing server message: "; Response.ErrorStatus.ErrorTrace = ex.StackTrace; Response.ErrorStatus.ErrorException = ex.Message; } //Response Message In string format string ResponseMessageText = Response.XMLSerializeMessage(); //Log Outbound Message ServiceLogManager.LogThis(ResponseMessageText, LogEventType.OutMessages, "", ""); // return(ResponseMessageText); }
static SPEventLogServiceLog() { ServiceLogManager.EnsureRegistration(); }
static Log4NetServiceLog() { ServiceLogManager.EnsureRegistration(); }