public void TestLogEntry() { if (log == null) { Assert.Inconclusive($"{loggerName} Logger disabled"); } else { LogInformation info = new LogInformation(); info.Type = LogType.Information; info.Origin = "UnitTests"; info.Category = "Unit Test"; info.Message = "Test Message"; info.Data = new { url = "http://www.com" }; info.ActivityID = Guid.NewGuid(); log.Log(info); System.Threading.Thread.Sleep(1000); using (var db = new VoatDataContext()) { var entry = db.EventLog.FirstOrDefault(x => x.ActivityID.ToUpper() == info.ActivityID.ToString().ToUpper()); Assert.IsNotNull(entry, "Crickie! Where is the log data at!?"); Assert.AreEqual(info.Type.ToString(), entry.Type); Assert.AreEqual(info.Origin, entry.Origin); Assert.AreEqual(info.Category, entry.Category); Assert.AreEqual(info.Message, entry.Message); Assert.AreEqual(JsonConvert.SerializeObject(info.Data), entry.Data); Assert.AreEqual(info.ActivityID.ToString().ToUpper(), entry.ActivityID.ToUpper()); } } }
private void WriteLog(LogEventType eventType, string message) { if (IsLogRequired(eventType)) { var logInformation = new LogInformation() { Message = "Thread Id: {0}, Message: {1}".FormatInvariant(Thread.CurrentThread.ManagedThreadId, message), ClassName = RetrieveClassName(), Category = eventType.ToString(), SourceID = 100, // TODO: Source ID should passed here SourceType = SourceType, ActivityId = Activity.ActivityId, CreatedDateTime = DefaultDateGetter() }; // Any error occurred in the logger, should be suppressed. try { _logWriter.WriteLog(logInformation); } catch { } } }
private static async Task OnLogInformation(LogInformation message) { using (MonitorDbContext context = new MonitorContextFactory().CreateDbContext(new string[] {})) { IUnitOfWork unitOfWork = new UnitOfWork(context); Monitor.Domain.Entities.LogInformation log = new Domain.Entities.LogInformation( message.Timestamp, message.HttpStatus, message.Duration, message.HttpMethod, message.Path, message.ServiceId); unitOfWork.Repository.Add(log); await unitOfWork.SaveChanges(); } System.Console.WriteLine("--"); System.Console.WriteLine($"Timestamp: {message.Timestamp}"); System.Console.WriteLine($"Duration: {message.Duration} millisec"); System.Console.WriteLine($"HttpStatus: {message.HttpStatus}"); System.Console.WriteLine($"Path: {message.Path}"); System.Console.WriteLine($"Httpmethod: {message.HttpMethod}"); System.Console.WriteLine($"SeriveId: {message.ServiceId}"); System.Console.WriteLine("--"); }
/// <summary> /// Deletes the user, UserAccountInfo, and PasswordHistory. /// </summary> /// <param name="user">The user.</param> /// <param name="providersNames">The providers names.</param> /// <returns><c>true</c> if the user was succesffully deleted; <c>false</c> otherwise.</returns> private bool DeleteUser(MembershipUser user, ProviderNames providersNames) { try { var userId = new Guid(user.ProviderUserKey.ToString()); // delete userAccountInfo and passwordHistory data this.userAccountInfoRepository.DeleteUserAccountInfoByUserId(userId); this.passwordHistoryRepository.DeleteByUserId(userId); // delete user Membership.Providers[providersNames.Membership].DeleteUser(user.UserName, true); return(true); } catch (Exception e) { var logInfo = new LogInformation { ClassName = "AccountManager", MethodName = "DeleteUser", ArgumentsPassedIn = new string[] { JsonConvert.SerializeObject(user), JsonConvert.SerializeObject(providersNames) }, ErrorMessage = e.Message }; this.logger.Error(JsonConvert.SerializeObject(logInfo)); return(false); } }
/// <summary> /// Deletes the user roles. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="roleProviderName">Name of the role provider.</param> /// <returns><c>true</c> if the roles are deleted successfully; <c>false</c> otherwise.</returns> private bool DeleteUserRoles(string userName, string roleProviderName) { try { var userRoles = Roles.Providers[roleProviderName].GetRolesForUser(userName); if (userRoles.Count() == 0) { return(true); } var usersArray = new string[] { userName }; Roles.Providers[roleProviderName].RemoveUsersFromRoles(usersArray, userRoles); return(true); } catch (Exception e) { var logInfo = new LogInformation { ClassName = "AccountManager", MethodName = "DeleteUserRoles", ArgumentsPassedIn = new string[] { userName, roleProviderName }, ErrorMessage = e.Message }; this.logger.Error(JsonConvert.SerializeObject(logInfo)); return(false); } }
/// <summary> /// Gets the user account. /// </summary> /// <param name="userName">Name of the user.</param> /// <returns>An account container.</returns> public AccountContainer GetUserAccountContainer(string userName) { var account = new AccountContainer { IsEmpty = true, Profile = null, Roles = null, User = null }; var container = this.FindUser(userName); if (container.IsEmpty) { return(account); } account.User = container.User; try { account.Profile = UserProfile.GetUserProfile(userName); account.Roles = Roles.Providers[container.Providers.Role].GetRolesForUser(userName); account.StateAssignments = this.stateAssignmentRepository.SearchFor(x => x.UserName.Equals(userName)).ToList(); account.IsEmpty = false; } catch (Exception e) { account.IsEmpty = true; var logInfo = new LogInformation { ClassName = "AccountManager", MethodName = "GetUserAccountContainer", ArgumentsPassedIn = new string[] { userName }, ErrorMessage = e.Message }; this.logger.Error(JsonConvert.SerializeObject(logInfo)); } return(account); }
/// <summary> /// Creates the user. /// It also populates the userAccountInfo table. /// </summary> /// <param name="model">The model.</param> /// <param name="membershipProviderName">Name of the membership provider.</param> /// <param name="isApproved">if set to <c>true</c> [is approved].</param> /// <returns> /// The username that the application assigns to the user. /// </returns> private string CreateUser(UserAddModel model, string membershipProviderName, bool isApproved = true) { var userId = Guid.NewGuid(); model.UserName = userId.ToString(); try { var password = Membership.GeneratePassword(12, 5); MembershipCreateStatus createStatus; Membership.Providers[membershipProviderName].CreateUser(model.UserName, password, model.Email, null, null, isApproved, userId, out createStatus); this.userAccountInfoRepository.CreateUserAccountInfo(userId); if (createStatus == MembershipCreateStatus.Success) { return(model.UserName); } } catch (Exception e) { var logInfo = new LogInformation { ClassName = "AccountManager", MethodName = "CreateUser", ArgumentsPassedIn = new string[] { JsonConvert.SerializeObject(model), membershipProviderName }, ErrorMessage = e.Message }; this.logger.Error(JsonConvert.SerializeObject(logInfo)); } return(null); }
private void BindData() { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(Configs.Global.BaseURL); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync(Configs.Global.GetLogInformation + "/" + logId).Result; if (response.IsSuccessStatusCode) { LogInformation objProperty = JsonConvert.DeserializeObject <LogInformation>(response.Content.ReadAsStringAsync().Result); lblCategory.Text = objProperty.TenantComplaint.CategoryName; lblLocation.Text = objProperty.TenantComplaint.Location; lblDescription.Text = objProperty.TenantComplaint.Description; lblRequestedDate.Text = objProperty.TenantComplaint.RequestedDate.ToString(); lblCompletedDate.Text = objProperty.TenantComplaint.ResolveDate.ToString(); ddlStatus.SelectedValue = objProperty.TenantComplaint.Status; ddlUsers.DataSource = objProperty.Users; ddlUsers.DataBind(); if (objProperty.TenantComplaint.AssignedTo != null) { ddlUsers.SelectedValue = Convert.ToString(objProperty.TenantComplaint.AssignedTo); } } else { StatusInfo objStatus = JsonConvert.DeserializeObject <StatusInfo>(response.Content.ReadAsStringAsync().Result); } }
/// <summary> /// Updates the user account. /// </summary> /// <param name="model">The model.</param> /// <param name="isApproved">if set to <c>true</c> [is approved].</param> /// <returns> /// An AccountTransactionStatus struct. /// </returns> public AccountTransactionStatus UpdateUserAccount(UserAddModel model, bool isApproved = true) { // Try to find user. AccountTransactionStatus status = new AccountTransactionStatus { HasUpdatedMembership = false, HasUpdatedStateAssignments = false, HasUpdatedRoles = false, HasUpdatedProfile = false }; var container = this.FindUser(model.UserName); if (container.IsEmpty) { var logInfo = new LogInformation { ClassName = "AccountManager", MethodName = "UpdateUserAccount", ArgumentsPassedIn = new string[] { JsonConvert.SerializeObject(model), isApproved.ToString() }, ErrorMessage = "User was not found or does not exist." }; this.logger.Error(JsonConvert.SerializeObject(logInfo)); } else { // perform updates status.HasUpdatedMembership = this.UpdateUser(container.User, model, container.Providers.Membership, isApproved); status.HasUpdatedProfile = this.UpdateUserProfile(model.UserName, model); status.HasUpdatedRoles = this.UpdateUserRoles(model.UserName, model.RoleSelections, container.Providers.Role); status.HasUpdatedStateAssignments = this.UpdateUserStateAssignments(model.UserName, model.CheckboxStateSelections, model.RadioSelectedState, container.Providers.Role); } return(status); }
private void btnGetData_Click(object sender, RoutedEventArgs e) { //txtPayload.Text = "{\n \"ISO_DATE\": \"2016-12-30 16:27:54,435\", \n \"MESSAGE\": \"FxRestfulController: USDUSD not found: ccy1 and ccy2 should not be the same FxRestfulController.java 208 \", \n \"STATUS\": \"OK\"\n}\n"; if (!string.IsNullOrWhiteSpace(txtPayload.Text)) { try { Mouse.OverrideCursor = Cursors.Wait; LogInformation information = RestClient.RestClient.GetData(txtPayload.Text, System.Configuration.ConfigurationManager.AppSettings["RestServiceURL"]); lblStatus.Text = information.Status; lblLogClass.Text = information.LogClass; lblDate.Text = information.ISO_DATE; lblMessage.Text = information.ORGMSG; dataGrid.ItemsSource = information.relatedIncident; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.OverrideCursor = null; } } else { MessageBox.Show("Please provide input payload", "Message", MessageBoxButton.OK, MessageBoxImage.Information); } }
public async Task Invoke(HttpContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); await this.next(context); stopwatch.Stop(); long duration = stopwatch.ElapsedMilliseconds; Console.WriteLine(this.config["ServiceId"]); LogInformation logMessage = new LogInformation( DateTime.Now, context.Response.StatusCode, duration, context.Request.Method, context.Request.Path, this.config["ServiceId"]); bus.Publish(logMessage); }
private void Client_ApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs e) { LogDebug?.Invoke($"ApplicationMessageReceived Topic {e.ApplicationMessage.Topic} QualityOfServiceLevel:{e.ApplicationMessage.QualityOfServiceLevel} Retain:{e.ApplicationMessage.Retain} "); try { if (e.ApplicationMessage.Topic.StartsWith($"/devices/") && e.ApplicationMessage.Topic.Contains("/response/")) { ReceiveAttributes(e); } else if (e.ApplicationMessage.Topic.StartsWith($"/devices/") && e.ApplicationMessage.Topic.Contains("/rpc/request/")) { var tps = e.ApplicationMessage.Topic.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var rpcmethodname = tps[4]; var rpcdevicename = tps[1]; var rpcrequestid = tps[5]; LogInformation?.Invoke($"rpcmethodname={rpcmethodname} "); LogInformation?.Invoke($"rpcdevicename={rpcdevicename } "); LogInformation?.Invoke($"rpcrequestid={rpcrequestid} "); if (!string.IsNullOrEmpty(rpcmethodname) && !string.IsNullOrEmpty(rpcdevicename) && !string.IsNullOrEmpty(rpcrequestid)) { OnExcRpc?.Invoke(Client, new RpcRequest() { Method = rpcmethodname, DeviceId = rpcdevicename, RequestId = rpcrequestid, Params = e.ApplicationMessage.ConvertPayloadToString() }); } } } catch (Exception ex) { LogError?.Invoke($"ClientId:{e.ClientId} Topic:{e.ApplicationMessage.Topic},Payload:{e.ApplicationMessage.ConvertPayloadToString()}", ex); } }
private void ReceiveAttributes(MqttApplicationMessageReceivedEventArgs e) { var tps = e.ApplicationMessage.Topic.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var rpcmethodname = tps[2]; var rpcdevicename = tps[1]; var rpcrequestid = tps[4]; LogInformation?.Invoke($"rpcmethodname={rpcmethodname} "); LogInformation?.Invoke($"rpcdevicename={rpcdevicename } "); LogInformation?.Invoke($"rpcrequestid={rpcrequestid} "); if (!string.IsNullOrEmpty(rpcmethodname) && !string.IsNullOrEmpty(rpcdevicename) && !string.IsNullOrEmpty(rpcrequestid)) { if (e.ApplicationMessage.Topic.Contains("/attributes/")) { OnReceiveAttributes?.Invoke(Client, new AttributeResponse() { KeyName = rpcmethodname, DeviceName = rpcdevicename, Id = rpcrequestid, Data = e.ApplicationMessage.ConvertPayloadToString() }); } } }
public void TestLogEntryLevel() { if (log == null) { Assert.Inconclusive($"{loggerName} Logger disabled"); } else { var level = log.LogLevel; try { log.LogLevel = LogType.Critical; LogInformation info = new LogInformation(); info.Type = LogType.Information; info.Origin = "UnitTests"; info.Category = "Unit Test"; info.Message = "Test Message"; info.Data = new { url = "http://www.com" }; info.ActivityID = Guid.NewGuid(); log.Log(info); using (var db = new VoatDataContext()) { var entry = db.EventLog.FirstOrDefault(x => x.ActivityID == info.ActivityID.ToString()); Assert.IsNull(entry, "Crickie! Data magically appeared when it shouldn't have!?"); } } finally { log.LogLevel = level; } } }
public void Log(LogInformation log) { lock (this) { if (!String.IsNullOrEmpty(log.Channel) && !Channels.Contains(log.Channel)) { Channels.Add(log.Channel); } LogInformationList.Add(log); } if (log.LogLevel == LogLevel.Error) { Errors++; } else if (log.LogLevel == LogLevel.Warning) { Warnings++; } else { Messages++; } foreach (var window in Windows) { window.LogWindow(log); } if (log.LogLevel == LogLevel.Error && ErrorPause) { Debug.Break(); } }
private void RefreshLog(LogInformation log) { GUILayout.BeginHorizontal(); { EditorGUILayout.HelpBox(log.message, log.MessageType); } GUILayout.EndHorizontal(); }
public async Task <bool> ConnectAsync(Uri uri, string username, string password) { if (BrokerUri == null && uri != null) { BrokerUri = uri; } if (BrokerUri != null && uri == null) { uri = BrokerUri; } bool initok = false; try { var factory = new MqttFactory(); Client = factory.CreateMqttClient( ); var clientOptions = new MqttClientOptionsBuilder() .WithClientId(uri.ToString() + Guid.NewGuid().ToString()) .WithTcpServer(uri.Host, uri.Port) .WithCredentials(username, password) .Build(); Client.ApplicationMessageReceivedAsync += Client_ApplicationMessageReceived; Client.ConnectedAsync += e => { Client.SubscribeAsync($"/devices/{DeviceId}/rpc/request/+/+"); Client.SubscribeAsync($"/devices/{DeviceId}/attributes/update/", MqttQualityOfServiceLevel.ExactlyOnce); LogInformation?.Invoke($"CONNECTED WITH SERVER "); return(Task.CompletedTask); }; Client.DisconnectedAsync += async e => { try { await Client.ConnectAsync(clientOptions); } catch (Exception exception) { LogError?.Invoke("CONNECTING FAILED", exception); } }; try { var result = await Client.ConnectAsync(clientOptions); initok = result.ResultCode == MqttClientConnectResultCode.Success; } catch (Exception exception) { LogError?.Invoke("CONNECTING FAILED", exception); } LogInformation?.Invoke("WAITING FOR APPLICATION MESSAGES"); } catch (Exception exception) { LogError?.Invoke("CONNECTING FAILED", exception); } return(initok); }
/// <summary> /// 保存数据 /// </summary> private void DataSave() { #region 得到 post 提交的数据 int dataLength = Request.Form.Count + 3; string[] filedName = new string[dataLength]; object[] filedValue = new object[dataLength]; for (int i = 0; i < Request.Form.Count; i++) { string controlName = Request.Form.Keys[i]; filedName[i] = controlName; filedValue[i] = Request.Form[controlName].Trim();//添加去除空格 } if (Request.Files.Count > 0 && Request.Files[0].FileName != "") { //保存二进制数据 filedName[dataLength - 3] = Request.Files.Keys[0]; HttpPostedFile postedFile = Request.Files[0]; byte[] buffer = new byte[postedFile.ContentLength]; postedFile.InputStream.Read(buffer, 0, postedFile.ContentLength); postedFile.InputStream.Close(); filedValue[dataLength - 3] = buffer; //保存文件格式 filedName[dataLength - 2] = "imgFormat"; filedValue[dataLength - 2] = postedFile.FileName.Remove(0, postedFile.FileName.LastIndexOf('.')); } #endregion string config_id = "1005"; GetFormInfo getfrom = new GetFormInfo(); string message = ""; //得到操作类型 Detail、Update、Add string operate_Type = "Update"; string desc = ""; string pk_Field = "ID"; string pk_Value = GetID(); string sqlWhere = " where " + pk_Field + " = '" + pk_Value + "'"; message = getfrom.DataSave(config_id, filedName, filedValue, sqlWhere); desc = " ID 为 " + pk_Value; #region 操作记录 string IP = GetSystemProperties.GetIP(); string Mac = GetSystemProperties.GetMacBySendARP(IP); string userID = getSession("userID"); string userName = getSession("userName"); LogInformation.OperationLog(userID, userName, operate_Type, config_id, desc, IP, Mac); #endregion Response.Write(message); Response.End(); }
/// <summary> /// Updates the user state assignment for the <c>current year</c>. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="stateSelections">The state selections.</param> /// <param name="roleProviderName">The role provider name.</param> /// <returns><c>true</c> if the state assignments update was successful; <c>false</c> otherwise.</returns> private bool UpdateUserStateAssignments(string userName, List <StateSelection> checkboxStateSelections, int radioSelectedState, string roleProviderName) { try { var assignements = this.stateAssignmentRepository.SearchFor(x => x.UserName.Equals(userName)); this.stateAssignmentRepository.DeleteAll(assignements.AsEnumerable()); // assign state specific roles var stateRoles = new string[] { Constants.ProjectAdminRole, Constants.ProjectUserRole, Constants.MultipleStateUserRole, Constants.SiteAdministratorRole }; foreach (var state in checkboxStateSelections.Where(x => x.IsChecked)) { foreach (var role in stateRoles) { if (Roles.Providers[roleProviderName].IsUserInRole(userName, role)) { this.stateAssignmentRepository.Update( new StateAssignment { UserName = userName, StateId = state.StateId, Role = role }); } } } var stateUserRoles = new string[] { Constants.StateAdminRole, Constants.StateUserRole }; foreach (var role in stateUserRoles) { if (Roles.Providers[roleProviderName].IsUserInRole(userName, role)) { this.stateAssignmentRepository.Update( new StateAssignment { UserName = userName, StateId = radioSelectedState, Role = role }); } } return(true); } catch (Exception e) { var logInfo = new LogInformation { ClassName = "AccountManager", MethodName = "UpdateUserStateAssignments", ArgumentsPassedIn = new string[] { userName, JsonConvert.SerializeObject(checkboxStateSelections), JsonConvert.SerializeObject(radioSelectedState), roleProviderName }, ErrorMessage = e.Message }; this.logger.Error(JsonConvert.SerializeObject(logInfo)); return(false); } }
public async Task <bool> ConnectAsync(Uri uri, string username, string password) { if (BrokerUri == null && uri != null) { BrokerUri = uri; } if (BrokerUri != null && uri == null) { uri = BrokerUri; } bool initok = false; try { var factory = new MqttFactory(); MqttNetLogger mqttNetLogger = new MqttNetLogger(); mqttNetLogger.LogMessagePublished += MqttNetLogger_LogMessagePublished;; Client = factory.CreateMqttClient(mqttNetLogger); var clientOptions = new MqttClientOptionsBuilder() .WithClientId(uri.ToString() + Guid.NewGuid().ToString()) .WithTcpServer(uri.Host, uri.Port) .WithCredentials(username, password) .Build(); Client.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(args => Client_ApplicationMessageReceived(Client, args)); Client.ConnectedHandler = new MqttClientConnectedHandlerDelegate(args => Client_ConnectedAsync(Client, args)); Client.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(async e => { try { await Client.ConnectAsync(clientOptions); } catch (Exception exception) { LogError?.Invoke("CONNECTING FAILED", exception); } }); try { var result = await Client.ConnectAsync(clientOptions); initok = result.ResultCode == MqttClientConnectResultCode.Success; } catch (Exception exception) { LogError?.Invoke("CONNECTING FAILED", exception); } LogInformation?.Invoke("WAITING FOR APPLICATION MESSAGES"); } catch (Exception exception) { LogError?.Invoke("CONNECTING FAILED", exception); } return(initok); }
static public void Log(UnityEngine.Object origin, LogLevel logLevel, string channel, object message, params object[] paramsObject) { lock (LoggerList) { if (!Logged) { try { Logged = true; foreach (IFilter filter in FilterList) { if (!filter.ApplyFilter(origin, logLevel, channel, message, paramsObject)) { return; } } LogStackFrame orginStackFrame; List <LogStackFrame> stackFrames = new List <LogStackFrame>(); bool OnlyUnityLog = GetStackFramListFromUnity(ref stackFrames, out orginStackFrame); if (OnlyUnityLog) { return; } var logInformation = new LogInformation(origin, channel, logLevel, stackFrames, orginStackFrame, message); RecentMessages.AddLast(logInformation); while (RecentMessages.Count > MaxMessage) { RecentMessages.RemoveFirst(); } foreach (ILogger logs in LoggerList) { if (logs == null) { LoggerList.Remove(logs); } else { logs.Log(logInformation); } } if (XLogGUIConstans.XLOG_ADD_UNITY_LOG_SYSTEM) { PushBackToUnity(origin, logLevel, message, paramsObject); } } finally { Logged = false; } } } }
public void AddBranchLog(Branch branch, LogInformation logInfo) { var branchLog = new BranchLog { BranchLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = branch, LogData = logInfo }; _logRepository.AddBranchLog(branchLog); }
public void AddGivenDegreeLog(GivenDegree givenDegree, LogInformation logInfo) { var givenDegreeLog = new GivenDegreeLog { GivenDegreeLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = givenDegree, LogData = logInfo }; _logRepository.AddGivenDegreeLog(givenDegreeLog); }
public void AddMeetingLog(Meeting meeting, LogInformation logInfo) { var meetingLog = new MeetingLog { MeetingLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = meeting, LogData = logInfo }; _logRepository.AddMeetingLog(meetingLog); }
public void AddExamTermLog(ExamTerm examTerm, LogInformation logInfo) { var examTermLog = new ExamTermLog { ExamTermLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = examTerm, LogData = logInfo }; _logRepository.AddExamTermLog(examTermLog); }
public void AddDegreeLog(Degree degree, LogInformation logInfo) { var degreeLog = new DegreeLog { DegreeLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = degree, LogData = logInfo }; _logRepository.AddDegreeLog(degreeLog); }
public void AddCourseQueueLog(CourseQueue courseQueue, LogInformation logInfo) { var courseQueueLog = new CourseQueueLog { CourseQueueLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = courseQueue, LogData = logInfo }; _logRepository.AddCourseQueueLog(courseQueueLog); }
public void AddUserLog(CertificationPlatformUser user, LogInformation logInfo) { var userLog = new CertificationPlatformUserLog { CertificationPlatformUserLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = user, LogData = logInfo }; _logRepository.AddUserLog(userLog); }
public void AddCertificateLog(Certificate certificate, LogInformation logInfo) { var certificateLog = new CertificateLog { CertificateLogIdentificator = _keyGenerator.GenerateNewId(), AlteredEntity = certificate, LogData = logInfo }; _logRepository.AddCertificateLog(certificateLog); }
/// <summary> /// This method is used to add new user data in the system /// </summary> /// <param name="uData"></param> /// <returns></returns> private bool AddUserData(UserProfileData uData) { bool status = false; if (_isDebugEnabled) { LogInformation.LogInfor(string.Format("Request came in for AddUserData at {0}", DateTime.Now.ToString("MM/dd/yyy H:mm:ss zzz"))); } //return as no Sql tables & procs are defined. return(false); if (uData == null) { if (_isDebugEnabled) { LogInformation.LogInfor("User data come as null obj"); } return(false); } try { using (SqlConnection sqlConnection = new SqlConnection(_connectionString)) { string procName = "Add_User_Profile";//Assuming proc is already in db using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.CommandText = procName; sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; sqlCommand.Parameters.Clear(); //only working on FirstName, Lastname, Email... sqlCommand.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = uData.FirstName; sqlCommand.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = uData.LastName; sqlCommand.Parameters.Add("@EmailAddress", SqlDbType.NVarChar).Value = uData.EmailAddress; sqlConnection.Open(); var reader = sqlCommand.ExecuteNonQuery(); if (reader > 0 && _isDebugEnabled) { LogInformation.LogInfor("User data added succefully in the system"); status = true; } } } } catch (Exception ex) { LogInformation.LogError(string.Format("{0}:{1}", ex.Message, ex.StackTrace)); status = false; } return(status); }
public ServerPadInt(int id) { log = new LogInformation(); this.id = id; }