/// <summary> /// Sets the status of a work order accordingly /// </summary> /// <param name="ID">Work order ID</param> /// <param name="newStatus">New status ID</param> /// <param name="notes">Program coordinator notes</param> private static void UpdateStatus(int ID, int newStatus, string notes) { using (WOLinqClassesDataContext db = new WOLinqClassesDataContext()) { Workorder wo = db.Workorders.Single(w => w.ID == ID); wo.status = newStatus; // only modify the status if it's "approved with changes" if (newStatus == 3) wo.coordinatorNotes = notes; // we want to add this to the activity log as well LogActivity log = new LogActivity(); log.action = "Marked '" + wo.Status1.status + "'"; log.DateTime = DateTime.Now; log.username = Function.GetUserName(); log.wID = wo.ID; db.LogActivities.InsertOnSubmit(log); db.SubmitChanges(); } }
public void Log(LogActivity activity, string subject) { // do nothing }
/// <summary> /// Adds an action to the activity log /// </summary> /// <param name="wID">Work order ID</param> /// <param name="action">Text that will be added to the activity log</param> public static void LogAction(int wID, string action) { using (WOLinqClassesDataContext db = new WOLinqClassesDataContext()) { LogActivity l = new LogActivity(); l.DateTime = DateTime.Now; l.wID = wID; l.username = Function.GetUserName(); l.action = action; db.LogActivities.InsertOnSubmit(l); db.SubmitChanges(); } }
public void Log(LogActivity logActivity, string subject) { var message = BuildMessage(logActivity, subject); Debug.Print(message); _log.Add(message); }
private static string BuildMessage(LogActivity logActivity, string subject) { string message = logActivity.ToString() + " " + subject; return message; }
public EditWordsController(IWordsService wordsService, IUserLogService usersLogService) { WordsService = wordsService; LogActivities = new LogActivity(usersLogService); }
public bool IsLogged(LogActivity logActivity, JobTaskBase jobTaskBase) { return IsLogged(logActivity, jobTaskBase.JobTaskNameWithOrder()); }
/// <summary> /// Send a DELETE request including an activity ID to the specified Uri with a cancellation token /// as an asynchronous operation. /// </summary> /// <param name="client">The client.</param> /// <param name="requestUri">The request URI.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="activity">The <see cref="LogActivity"/> whose ID is to be included in the request.</param> /// <returns>The response.</returns> /// <exception cref="ArgumentNullException">Thrown when a required argument is <c>null</c>.</exception> /// <exception cref="InvalidOperationException">Thrown when the request has already been sent by the <see cref="HttpClient"/> class.</exception> public static async Task <HttpResponseMessage> DeleteAsync(this HttpClient client, string requestUri, CancellationToken cancellationToken, LogActivity activity) { var request = new HttpRequestMessage(HttpMethod.Delete, requestUri); if (!string.IsNullOrEmpty(activity.Id)) { request.Headers.Add(LogActivity.HttpHeader, activity.Id); } return(await client.SendAsync(request, cancellationToken)); }
void btnDelete_Click(object sender, EventArgs e) { try { if (!ProductPermission.CanDelete) { SiteUtils.RedirectToEditAccessDeniedPage(); return; } bool isDeleted = false; foreach (GridDataItem data in grid.SelectedItems) { int productId = Convert.ToInt32(data.GetDataKeyValue("ProductId")); Product product = new Product(siteSettings.SiteId, productId); if (product != null && product.ProductId != -1 && !product.IsDeleted) { if (product.ZoneId.ToString() != ddZones.SelectedValue && ddZones.SelectedValue != "-1") { ZoneSettings objZone = new ZoneSettings(siteSettings.SiteId, Convert.ToInt32(ddZones.SelectedValue)); if (objZone != null && objZone.ZoneId > 0) { ZoneItem zoneNews = new ZoneItem(objZone.ZoneGuid, product.ProductGuid); ZoneItem.Delete(zoneNews.ZoneGuid, zoneNews.ItemGuid); } } else { ContentDeleted.Create(siteSettings.SiteId, product.Title, "Product", typeof(ProductDeleted).AssemblyQualifiedName, product.ProductId.ToString(), Page.User.Identity.Name); product.IsDeleted = true; product.ContentChanged += new ContentChangedEventHandler(product_ContentChanged); product.SaveDeleted(); LogActivity.Write("Delete product", product.Title); } //ContentDeleted.Create(siteSettings.SiteId, product.Title, "Product", typeof(ProductDeleted).AssemblyQualifiedName, product.ProductId.ToString(), Page.User.Identity.Name); //product.IsDeleted = true; //product.ContentChanged += new ContentChangedEventHandler(product_ContentChanged); //product.SaveDeleted(); //LogActivity.Write("Delete product", product.Title); isDeleted = true; } } if (isDeleted) { SiteUtils.QueueIndexing(); grid.Rebind(); message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage"); } } catch (Exception ex) { log.Error(ex); } }
/// <summary> /// Send an HTTP request including an activity ID as an asynchronous operation. /// </summary> /// <param name="client">The client.</param> /// <param name="request">The HTTP request message to send.</param> /// <param name="activity">The <see cref="LogActivity"/> whose ID is to be included in the request.</param> /// <returns>The response.</returns> /// <exception cref="ArgumentNullException">Thrown when a required argument is <c>null</c>.</exception> /// <exception cref="InvalidOperationException">Thrown when the request has already been sent by the <see cref="HttpClient"/> class.</exception> public static async Task <HttpResponseMessage> SendAsync(this HttpClient client, HttpRequestMessage request, LogActivity activity) { if (!string.IsNullOrEmpty(activity.Id)) { request.Headers.Add(LogActivity.HttpHeader, activity.Id); } return(await client.SendAsync(request)); }
/// <summary> /// Send an HTTP request including an activity ID as an asynchronous operation with using a completion option and cancellation token /// and including a <see cref="LogActivity"/> ID. /// </summary> /// <param name="client">The client.</param> /// <param name="request">The request.</param> /// <param name="completionOption"> /// When the operation should complete (as soon as a response is available or after /// reading the whole response content). /// </param> /// <param name="cancellationToken">The cancellation token to cancel operation.</param> /// <param name="activity">The <see cref="LogActivity"/> whose ID is to be included in the request.</param> /// <returns>The response.</returns> /// <exception cref="ArgumentNullException">Thrown when a required argument is <c>null</c>.</exception> /// <exception cref="InvalidOperationException">Thrown when the request has already been sent by the <see cref="HttpClient"/> class.</exception> public static async Task <HttpResponseMessage> SendAsync(this HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken, LogActivity activity) { if (!string.IsNullOrEmpty(activity.Id)) { request.Headers.Add(LogActivity.HttpHeader, activity.Id); } return(await client.SendAsync(request, completionOption, cancellationToken)); }
/// <summary> /// Send a PUT request including an activity ID to the specified Uri as an asynchronous operation. /// </summary> /// <param name="client">The client.</param> /// <param name="requestUri">The request URI.</param> /// <param name="content">The content to be sent to the server.</param> /// <param name="activity">The <see cref="LogActivity"/> whose ID is to be included in the request.</param> /// <returns>The response.</returns> /// <exception cref="ArgumentNullException">Thrown when a required argument is <c>null</c>.</exception> public static async Task <HttpResponseMessage> PutAsync(this HttpClient client, Uri requestUri, HttpContent content, LogActivity activity) { var request = new HttpRequestMessage(HttpMethod.Put, requestUri); request.Content = content; if (!string.IsNullOrEmpty(activity.Id)) { request.Headers.Add(LogActivity.HttpHeader, activity.Id); } return(await client.SendAsync(request)); }
/// <summary> /// Send a GET request including an activity ID to the specified Uri and return the response body as a string /// in an asynchronous operation. /// </summary> /// <param name="client">The client.</param> /// <param name="requestUri">The request URI.</param> /// <param name="activity">The <see cref="LogActivity"/> whose ID is to be included in the request.</param> /// <returns>The response string.</returns> /// <exception cref="ArgumentNullException">Thrown when a required argument is <c>null</c>.</exception> public static async Task <string> GetStringAsync(this HttpClient client, Uri requestUri, LogActivity activity) { var request = new HttpRequestMessage(HttpMethod.Get, requestUri); if (!string.IsNullOrEmpty(activity.Id)) { request.Headers.Add(LogActivity.HttpHeader, activity.Id); } var response = await client.SendAsync(request); return(await response.Content.ReadAsStringAsync()); }
/// <summary> /// Send a GET request including an activity ID to the specified Uri with an HTTP completion option as an /// asynchronous operation. /// </summary> /// <param name="client">The client.</param> /// <param name="requestUri">The request URI.</param> /// <param name="completionOption"> /// When the operation should complete (as soon as a response is available or after /// reading the whole response content). /// </param> /// <param name="activity">The <see cref="LogActivity"/> whose ID is to be included in the request.</param> /// <returns>The response.</returns> /// <exception cref="ArgumentNullException">Thrown when a required argument is <c>null</c>.</exception> public static async Task <HttpResponseMessage> GetAsync(this HttpClient client, Uri requestUri, HttpCompletionOption completionOption, LogActivity activity) { var request = new HttpRequestMessage(HttpMethod.Get, requestUri); if (!string.IsNullOrEmpty(activity.Id)) { request.Headers.Add(LogActivity.HttpHeader, activity.Id); } return(await client.SendAsync(request, completionOption)); }
public void Log(LogActivity activity, string subject) { PrepareLogger(subject).Info(activity.ToString()); }
public bool IsLogged(LogActivity logActivity, string subject) { var message = BuildMessage(logActivity, subject); return _log.Contains(message); }
public virtual void LogActivity_created_with_LogEntry_having_null_calling_type_does_not_throw() { var entry = new LogEntry("a message"); Assert.IsNull(entry.CallingType); var activity = new LogActivity(entry); }
private bool UpdateNewsPosition(bool moveRight) { if (ddlPosition.SelectedValue.Length == 0) { return(false); } bool isUpdated = false; if (moveRight) { foreach (GridDataItem data in grid1.SelectedItems) { int newsId = Convert.ToInt32(data.GetDataKeyValue("NewsID")); int position = Convert.ToInt32(data.GetDataKeyValue("Position")); int positionNew = position; int.TryParse(ddlPosition.SelectedValue, out positionNew); if ((position & positionNew) == 0) { News news = new News(SiteId, newsId); if (news != null && news.NewsID > 0) { news.Position = (news.Position | positionNew); if (news.Position < 0) { news.Position = 0; } if (news.Save()) { LogActivity.Write("Change news position", news.Title); isUpdated = true; } } } } } else { foreach (GridDataItem data in grid2.SelectedItems) { int newsId = Convert.ToInt32(data.GetDataKeyValue("NewsID")); int position = Convert.ToInt32(data.GetDataKeyValue("Position")); int positionNew = position; int.TryParse(ddlPosition.SelectedValue, out positionNew); if ((position & positionNew) > 0) { News news = new News(SiteId, newsId); if (news != null && news.NewsID > 0) { news.Position = (news.Position - positionNew); if (news.Position < 0) { news.Position = 0; } if (news.Save()) { LogActivity.Write("Change news position", news.Title); isUpdated = true; } } } } } if (isUpdated) { grid2.Rebind(); message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage"); return(true); } return(false); }