Esempio n. 1
0
        /// <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();

            }
        }
Esempio n. 2
0
 public void Log(LogActivity activity, string subject)
 {
     // do nothing
 }
Esempio n. 3
0
 /// <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();
     }
 }
Esempio n. 4
0
 public void Log(LogActivity logActivity, string subject)
 {
     var message = BuildMessage(logActivity, subject);
     Debug.Print(message);
     _log.Add(message);
 }
Esempio n. 5
0
 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);
 }
Esempio n. 7
0
 public bool IsLogged(LogActivity logActivity, JobTaskBase jobTaskBase)
 {
     return IsLogged(logActivity, jobTaskBase.JobTaskNameWithOrder());
 }
Esempio n. 8
0
        /// <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));
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 10
0
        /// <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));
        }
Esempio n. 11
0
        /// <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));
        }
Esempio n. 12
0
        /// <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));
        }
Esempio n. 13
0
        /// <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());
        }
Esempio n. 14
0
        /// <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));
        }
Esempio n. 15
0
 public void Log(LogActivity activity, string subject)
 {
     PrepareLogger(subject).Info(activity.ToString());
 }
Esempio n. 16
0
 public bool IsLogged(LogActivity logActivity, string subject)
 {
     var message = BuildMessage(logActivity, subject);
     return _log.Contains(message);
 }
Esempio n. 17
0
 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);
 }
Esempio n. 18
0
        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);
        }