示例#1
0
        /// <summary>
        /// Invokes the UpdateData and TrackChanges events
        /// </summary>
        /// <param name="sender">The sending object</param>
        /// <param name="e">The event arguments</param>
        private void OnInvokeUpdate(object sender, EventArgs e)
        {
            // Invoke the UpdateData event
            UpdateData?.Invoke(sender, EventArgs.Empty);

            // Invoke the TrackChanges event
            TrackChanges?.Invoke(sender, EventArgs.Empty);
        }
示例#2
0
        public ActionResult Edit(int?id, CreateTicketsViewModel form)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction(nameof(TicketController.Index)));
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }


            var model = Db.Tickets.FirstOrDefault(p => p.Id == id);

            var currentUserId = User.Identity.GetUserId();

            var log = new TrackChanges(Db, model, form);

            var mailHelper = new MailSender(userManager, model);

            //check if there is any change in our ticket
            //also check there has any developer assigned to this ticket
            //also check that if developer edit the ticket they will not get any notification.
            if (log.IsTicketEdited())
            {
                var allValues = log.ModifiedValues();

                foreach (var item in allValues)
                {
                    item.UserId = User.Identity.GetUserId();
                    Db.Histories.Add(item);
                }

                mailHelper.Send(currentUserId);

                Db.SaveChanges();
            }



            model.Title            = form.Title;
            model.Description      = form.Description;
            model.TicketPriorityId = form.TicketPriorityId;
            model.TicketTypeId     = form.TicketTypeId;
            model.TicketStatusId   = form.TicketStatusId;
            model.DateUpdated      = DateTime.Now;
            Db.SaveChanges();


            return(RedirectToAction(nameof(TicketController.Details), new { id = model.Id }));
        }
示例#3
0
        /// <summary>
        /// Invokes the UpdateData and TrackChanges events
        /// </summary>
        /// <param name="sender">The sending object</param>
        /// <param name="e">The event arguments</param>
        private void OnInvokeUpdate(object sender, EventArgs e)
        {
            // Invoke the UpdateData event
            UpdateData?.Invoke(sender, EventArgs.Empty);

            // Invoke the TrackChanges event
            if (sender.GetType() == typeof(ViewBox))
            {
                TrackChangesArgs args = new TrackChangesArgs((ViewBox)sender);

                TrackChanges?.Invoke(sender, args);
            }
        }
        public override void Dispose()
        {
            base.Dispose();

            DisposeTextBlock(TextBlock1);
            TextBlock1 = null;
            DisposeTextBlock(TextBlock2);
            TextBlock2 = null;
            DisposeTextBlock(TextBlock3);
            TextBlock3 = null;
            DisposeTextBlock(TextBlock4);
            TextBlock4 = null;
            DisposeTextBlock(TextBlock5);
            TextBlock5 = null;
            DisposeTextBlock(TextBlock6);
            TextBlock6 = null;
            DisposeTextBlock(TextBlock7);
            TextBlock7 = null;

            Button1.Click -= Button_Click_1;
            DisposeButton(Button1);
            Button1        = null;
            Button2.Click -= Button_Click_2;
            DisposeButton(Button2);
            Button2 = null;

            DisposeRadioButton(rdAcceptAll);
            rdAcceptAll = null;
            DisposeRadioButton(rdRejectAll);
            rdRejectAll = null;

            TrackChangesOptions.ClearValue(StackPanel.OrientationProperty);
            TrackChangesOptions.ClearValue(StackPanel.VerticalAlignmentProperty);
            TrackChangesOptions = null;

            TrackChanges.ClearValue(Grid.BackgroundProperty);
            TrackChanges.ClearValue(Grid.PaddingProperty);
            TrackChanges.Children.Clear();
            TrackChanges.ColumnDefinitions.Clear();
            TrackChanges.RowDefinitions.Clear();
            TrackChanges = null;
        }
示例#5
0
        public String SaveNewDiscussionByEntity(string text, int recordId, string projectionName, string hierarchyId)
        {
            var dbObjectId          = Settings.GetInstance.GetVwProjectionList(userInfo.ProfileId).Find(x => x.Projection_Name == projectionName).DbObject_Id;
            var discussionMessageId = 0;

            using (SqlConnection conn = new SqlConnection(DbConnectionString))
            {
                conn.Open();

                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 1. Save new discussion message
                        var saveNewDiscussionByEntityCommand = this.GetSaveNewDiscussionByEntityCommand(text, recordId, projectionName, hierarchyId);
                        saveNewDiscussionByEntityCommand.Connection  = conn;
                        saveNewDiscussionByEntityCommand.Transaction = trans;
                        object a = saveNewDiscussionByEntityCommand.ExecuteScalar();
                        discussionMessageId = (int)a;

                        #endregion

                        #region 2. Add information to TrackChanges
                        var trackChanges = new TrackChanges();
                        trackChanges.Created = DateTime.Now;

                        using (VistosDbContext ctx = new VistosDbContext())
                        {
                            trackChanges.RecordId    = recordId;
                            trackChanges.ReferenceId = (int)discussionMessageId;
                            trackChanges.DbObject_FK = dbObjectId;
                            //**trackChanges.Type_FK = (int)BAL.Services.TrackChanges.TrackChangesType.AddDiscusionMessage;
                            trackChanges.NewValue = text;
                            trackChanges.User_FK  = userInfo.UserId;
                            ctx.TrackChanges.Add(trackChanges);
                            ctx.SaveChanges();
                        }
                        #endregion
                        trans.Commit();

                        //**var nws = new GenerateNotificationWorkerSettings(this.userInfo, new List<TrackChanges>() { trackChanges }, DbConnectionString);
                        //**Worker.ExecuteGenerateNotification(nws);
                    }
                    catch (Exception ex)
                    {
                        // TODO: log exception
                        Logger.SaveLogError(LogLevel.Error, ex.Message, ex, null, userInfo);
                        trans.Rollback();
                    }
                    finally
                    {
                        if (conn.State == ConnectionState.Open)
                        {
                            conn.Close();
                        }
                    }
                }
            }



            return("{}");
        }