Пример #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the EventUpdates EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEventUpdates(EventUpdate eventUpdate)
 {
     base.AddObject("EventUpdates", eventUpdate);
 }
Пример #2
0
        private void ShowInvoiceReportCommandExecuted()
        {
            var appPath = (string)ApplicationSettings.Read("DocumentsPath");
            var fileName = string.Format("{0}_{1}_{2}", _event.Name, "Invoice", DateTime.Now.ToString("g").Replace(":", "").Replace(@"/", ""));
            var reportPath = string.Concat(fileName, ".pdf");
            var exportPath = string.Concat(appPath, reportPath);

            // create a pdf file
            ReportingService.CreateInvoiceReport(Invoice, exportPath);

            // store report in the database
            var report = new Report()
            {
                ID = Guid.NewGuid(),
                EventID = _event.Event.ID,
                Date = DateTime.Now,
                Name = string.Format("Invoice"),
                Path = reportPath
            };

            _eventDataUnit.InvoicesRepository.Add(_invoice.InnerInvoice);

            _eventDataUnit.ReportsRepository.Add(report);
            _event.Reports.Add(new ReportModel(report));
            _event.RefreshReports();

            // update Updates table
            var update = new EventUpdate()
            {
                ID = Guid.NewGuid(),
                EventID = _event.Event.ID,
                Date = DateTime.Now,
                UserID = AccessService.Current.User.ID,
                Message = "Event invoice was created",
                OldValue = null,
                NewValue = _invoice.InvoiceNumber.ToString(),
                ItemId = _invoice.InnerInvoice.ID,
                ItemType = "EventInvoice",
                Field = "Invoice",
                Action = UpdateAction.Added
            };

            // add document
            var document = new Document()
            {
                ID = report.ID,
                Path = reportPath,
                Name = string.Format("Invoice for {0}", _event.Name),
                IsEnabled = true,
                IsCommon = false
            };

            _eventDataUnit.DocumentsRepository.Add(document);
            _event.Documents.Add(document);

            _eventDataUnit.EventUpdatesRepository.Add(update);

        }
Пример #3
0
        private void DeleteEventCommandExecuted(EventModel eventModel)
        {
            if (eventModel == null) return;

            bool? dialogResult = null;
            string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM;

            RaisePropertyChanged("DisableParentWindow");

            RadWindow.Confirm(new DialogParameters()
            {
                Owner = Application.Current.MainWindow,
                Content = confirmText,
                Closed = (sender, args) => { dialogResult = args.DialogResult; }
            });

            RaisePropertyChanged("EnableParentWindow");

            if (dialogResult != true) return;

            eventModel.Event.IsDeleted = true;

            var update = new EventUpdate()
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                Event = eventModel.Event,
                UserID = AccessService.Current.User.ID,
                Message = string.Format("Event {0} was deleted", eventModel.Name),
                OldValue = eventModel.Name,
                NewValue = null,
                ItemId = eventModel.Event.ID,
                ItemType = "Event",
                Field = "Event",
                Action = UpdateAction.Removed
            };

            _eventsDataUnit.EventUpdatesRepository.Add(update);

            _eventsDataUnit.SaveChanges();

            _allEvents.Remove(eventModel);
            Events.Remove(eventModel);
            SelectedEvent = null;

            RefreshAppointments();
        }
Пример #4
0
 /// <summary>
 /// Create a new EventUpdate object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="eventID">Initial value of the EventID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 /// <param name="message">Initial value of the Message property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static EventUpdate CreateEventUpdate(global::System.Guid id, global::System.Guid eventID, global::System.Guid userID, global::System.String message, global::System.DateTime date)
 {
     EventUpdate eventUpdate = new EventUpdate();
     eventUpdate.ID = id;
     eventUpdate.EventID = eventID;
     eventUpdate.UserID = userID;
     eventUpdate.Message = message;
     eventUpdate.Date = date;
     return eventUpdate;
 }
Пример #5
0
 public EventUpdateModel(EventUpdate eventUpdate)
 {
     EventUpdate = eventUpdate;
     UpdatesHistory=new List<UpdatesHistoryModel>();
 }
Пример #6
0
        private async void SubmitEventCommandExecuted()
        {
            IsBusy = true;
            BusyText = "Processing";

            //Set the Items Count on change of Number of Places 
            SetItemsCountOnPlacesChange();

            //Check whether the Sum of Invoived and Uninvoiced Items is equal or not
            if (!IsInvoicedandUnInvoicedPriceEquals())
            {
                IsBusy = false;
                return;
            }

            //Check whether the resources are available
            await ValidateResourcesAvailability();

            if (AlreadyBookedEventItems.Count > 0)
            {
                var alreadyBookedWindow = new EventItemsAlreadyBooked(Event, AlreadyBookedCaterings, AlreadyBookedRooms, AlreadyBookedGolfs, AlreadyBookedEventItems);
                RaisePropertyChanged("DisableParentWindow");
                alreadyBookedWindow.ShowDialog();
                RaisePropertyChanged("EnableParentWindow");
                if (alreadyBookedWindow.DialogResult == null || !alreadyBookedWindow.DialogResult.Value)
                {
                    IsBusy = false;
                    return;
                }
            }
            if (_isEditMode)
            {
                var eventUpdates = LoggingService.FindDifference(_originalEvent, _event);
                ProcessUpdates(_event, eventUpdates);
                _event.Event.LastEditDate = DateTime.Now;
                // Release lock
                _event.Event.LockedUserID = null;
            }
            else
            {
                _eventsDataUnit.EventsRepository.Add(_event.Event);

                var update = new EventUpdate()
                {
                    ID = Guid.NewGuid(),
                    EventID = _event.Event.ID,
                    Date = DateTime.Now,
                    UserID = AccessService.Current.User.ID,
                    Message = string.Format("Event {0} was created", _event.Name),
                    OldValue = null,
                    NewValue = _event.Name,
                    ItemId = _event.Event.ID,
                    ItemType = "Event",
                    Field = "Event",
                    Action = UpdateAction.Added
                };
                _event.EventUpdates.Add(update);
                _eventsDataUnit.EventUpdatesRepository.Add(update);

                var eventUpdates = LoggingService.FindDifference(_originalEvent, _event, true);
                ProcessUpdates(_event, eventUpdates);
            }
            await _eventsDataUnit.SaveChanges();

            IsBusy = false;
            RaisePropertyChanged("CloseDialog");
            PopupService.ShowMessage(
                _isEditMode
                    ? Properties.Resources.MESSAGE_NEW_EVENT_UPDATED
                    : Properties.Resources.MESSAGE_NEW_EVENT_ADDED, MessageType.Successful);
        }
Пример #7
0
        private void ShowFunctionSheetCommandExecuted()
        {
            var appPath = (string)ApplicationSettings.Read("DocumentsPath");

            var eventWasChanged = _event.Event.LastFunctionSheetPrint <= _event.Event.LastEditDate;
            var lastReport = _event.Reports.Where(x => x.Name == "Function Sheet").OrderByDescending(x => x.Report.Date).FirstOrDefault();

            if (!eventWasChanged && lastReport != null)
            {
                var oldExportPath = string.Concat(appPath, lastReport.Report.Path);

                if (File.Exists(oldExportPath))
                {
                    Process.Start(oldExportPath);
                    return;
                }
            }

            var fileName = string.Format("{0}_{1}_{2}", _event.Name, "Function Sheet", DateTime.Now.ToString("g").Replace(":", "").Replace(@"/", ""));
            var reportPath = string.Concat(fileName, ".pdf");
            var exportPath = string.Concat(appPath, reportPath);

            // create a pdf file
            ReportingService.CreateFunctionSheetReport(_event, exportPath);

            // store report in the database
            var report = new Report()
            {
                ID = Guid.NewGuid(),
                EventID = _event.Event.ID,
                Date = DateTime.Now,
                Name = string.Format("Function Sheet"),
                Path = reportPath
            };

            _event.Event.LastFunctionSheetPrint = DateTime.Now;

            _event.Reports.Insert(0, new ReportModel(report));
            _eventDataUnit.ReportsRepository.Add(report);
            _event.RefreshReports();

            // update Updates table
            var update = new EventUpdate()
            {
                ID = Guid.NewGuid(),
                EventID = _event.Event.ID,
                Date = DateTime.Now,
                UserID = AccessService.Current.User.ID,
                Message = Resources.MESSAGE_FUNCTION_SHEET_WAS_CREATED,
                OldValue = null,
                NewValue = report.Name,
                ItemId = report.ID,
                ItemType = "EventReport",
                Field = "FunctionSheetReport",
                Action = UpdateAction.Added
            };

            _event.EventUpdates.Insert(0, update);
            _eventDataUnit.EventUpdatesRepository.Add(update);

            var document = new Document()
            {
                ID = report.ID,
                EventID = _event.Event.ID,
                Path = reportPath,
                Name = Path.GetFileNameWithoutExtension(reportPath),
                IsEnabled = true,
                IsCommon = false
            };

            _event.Documents.Add(document);
            _eventDataUnit.DocumentsRepository.Add(document);
        }
Пример #8
0
        private void AddFileFromHdd(string path)
        {
            var appPath = (string)ApplicationSettings.Read("DocumentsPath");
            var filePath = Path.GetFileName(path);
            var fullPath = string.Concat(appPath, filePath);

            try
            {
                if (File.Exists(fullPath))
                    File.Delete(fullPath);

                File.Copy(path, fullPath);

                var report = new ReportModel(new Report()
                {
                    ID = Guid.NewGuid(),
                    EventID = _event.Event.ID,
                    Date = DateTime.Now,
                    Name = Path.GetFileNameWithoutExtension(path),
                    Path = filePath
                });

                _event.Reports.Insert(0, report);
                _eventDataUnit.ReportsRepository.Add(report.Report);
                _event.RefreshReports();

                // update Updates table
                var update = new EventUpdate()
                {
                    ID = Guid.NewGuid(),
                    EventID = _event.Event.ID,
                    Date = DateTime.Now,
                    UserID = AccessService.Current.User.ID,
                    Message = Resources.MESSAGE_FUNCTION_SHEET_WAS_CREATED,
                    OldValue = null,
                    NewValue = report.Name,
                    ItemId = report.Report.ID,
                    ItemType = "EventReport",
                    Field = "DocumentUpload",
                    Action = UpdateAction.Added
                };

                _eventDataUnit.EventUpdatesRepository.Add(update);

                var document = new Document()
                {
                    ID = report.Report.ID,
                    EventID = _event.Event.ID,
                    Path = filePath,
                    Name = Path.GetFileNameWithoutExtension(path),
                    IsEnabled = true,
                    IsCommon = false
                };

                _event.Documents.Add(document);
                _eventDataUnit.DocumentsRepository.Add(document);

            }
            catch (Exception ex)
            {
                PopupService.ShowMessage(ex.Message, MessageType.Failed);
            }
        }
Пример #9
0
        private async void BookCommandExecute()
        {
            bool? dialogResult = null;
            string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_BOOKING_ENQUIRY;

            RadWindow.Confirm(new DialogParameters()
            {
                Owner = Application.Current.MainWindow,
                Content = confirmText,
                Closed = (sender, args) => { dialogResult = args.DialogResult; }
            });

            if (dialogResult != true) return;

            Enquiry.EnquiryStatus = EnquiryStatuses.FirstOrDefault(x => x.Status == "Booked");
            EnquiryStatus = Enquiry.EnquiryStatus;

            var newEvent = new Event()
            {
                ID = Guid.NewGuid(),
                Name = Enquiry.Name,
                Date = (DateTime)Enquiry.Date,
                Places = (int)Enquiry.Places,
                CreationDate = DateTime.Now,
                ShowOnCalendar = true,
                IsDeleted = false,
                LastEditDate = DateTime.Now,
                EventTypeID = Enquiry.EventType.ID,
                EnquiryID = Enquiry.Enquiry.ID,
                EventStatusID = _eventStatuses.FirstOrDefault(x => x.Name == "Provisional").ID
            };

            if (_enquiry.PrimaryContact != null)
                newEvent.ContactID = _enquiry.PrimaryContact.Contact.ID;

            _crmDataUnit.EventsRepository.Add(newEvent);

            var update = new EventUpdate()
            {
                ID = Guid.NewGuid(),
                EventID = newEvent.ID,
                Date = DateTime.Now,
                UserID = AccessService.Current.User.ID,
                Message = string.Format("Event {0} was created", newEvent.Name),
                OldValue = null,
                NewValue = newEvent.Name,
                ItemId = newEvent.ID,
                ItemType = "Event",
                Field = "Event",
                Action = UpdateAction.Added
            };

            _crmDataUnit.EventUpdatesRepository.Add(update);
            _crmDataUnit.SaveChanges();

            // Warning: Here we use EventDataUnit!

            var events = await _eventDataUnit.EventsRepository.GetLightEventsAsync(x => x.ID == newEvent.ID);
            var @event = events.FirstOrDefault();

            var item = new EventModel(@event);

            // Open Add Event window in UI thread
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                var bookingView = new BookingView(BookingViews.Event, item);
                bookingView.ShowDialog();

                if (bookingView.DialogResult != null && bookingView.DialogResult == true)
                {
                    string campaingText = Enquiry.Campaign == null ? "" : ", via Campaign " + Enquiry.Campaign.Name;

                    var note = new EventNoteModel(new EventNote()
                    {
                        ID = Guid.NewGuid(),
                        EventID = newEvent.ID,
                        Date = DateTime.Now,
                        EventNoteType = _eventNoteTypes.FirstOrDefault(x => x.Type == "Internal"),
                        UserID = AccessService.Current.User.ID,
                        Note = String.Format("From Enquiry, made on {0}, Taken by {1} Assigned to {2} enquiry via {3} {4}. {5} Notes, {6} Updates, {7} Activities & {8} Follow-Ups.",
                        DateTime.Now,
                        Enquiry.LoggedUser.FirstName,
                        Enquiry.AssignedToUser.FirstName,
                        Enquiry.ReceivedMethod.ReceiveMethod,
                        campaingText,
                        Enquiry.EnquiryNotes.Count,
                        Enquiry.EnquiryUpdates.Count,
                        Enquiry.Activities.Count,
                        Enquiry.FollowUps.Count)
                    });

                    _crmDataUnit.EventNotesRepository.Add(note.EventNote);
                    _crmDataUnit.SaveChanges();
                }
            }));

            BookCommand.RaiseCanExecuteChanged();
        }
Пример #10
0
        private async void SubmitCommandExecuted()
        {
            IsBusy = true;

            if (!_isResend)
            {
                var type = _corresponcenceTypes.FirstOrDefault(x => x.Type == "Event");
                Correspondence.CorresponcenceType = type;
            }

            var onCompleteAction = new Action(() =>
            {
                if (Correspondence.SendMailToCcAddress)
                    AddCCContacts();

                foreach (var document in Correspondence.Documents)
                {
                    var correspondenceDocument = new CorrespondenceDocument()
                    {
                        ID = Guid.NewGuid(),
                        CorrespondenceID = Correspondence.Correspondence.ID,
                        DocumentID = document.ID
                    };

                    _eventDataUnit.CorrespondenceDocumentsRepository.Add(correspondenceDocument);
                }

                // add entry into update log
                var update = new EventUpdate()
                {
                    ID = Guid.NewGuid(),
                    EventID = _event.Event.ID,
                    Date = DateTime.Now,
                    Message = string.Format("Email was sent to {0}", _correspondence.ToAddress),
                    UserID = AccessService.Current.User.ID,
                    OldValue = null,
                    NewValue = _correspondence.ToAddress,
                    ItemId = _correspondence.Correspondence.ID,
                    ItemType = "Correspondence",
                    Field = "Email",
                    Action = UpdateAction.Added
                };

                _event.EventUpdates.Insert(0, update);
                _eventDataUnit.EventUpdatesRepository.Add(update);

                _event.Correspondences.Insert(0, Correspondence);
                _eventDataUnit.CorresponcencesRepository.Add(Correspondence.Correspondence);
            });

            bool success = await EmailService.SendEmail(Correspondence, onCompleteAction, MainEmailTemplate.MailTemplate.Template);

            IsBusy = false;

            if (success)
                RaisePropertyChanged("CloseDialog");
        }
Пример #11
0
 private static EventUpdate ProcessUpdate(EventModel eventModel, string message, string oldValue, string newValue, Guid itemID, string itemType, string field, UpdateAction action)
 {
     var update = new EventUpdate()
     {
         ID = Guid.NewGuid(),
         Date = DateTime.Now,
         Event = eventModel.Event,
         UserID = AccessService.Current.User.ID,
         Message = message,
         OldValue = oldValue,
         NewValue = newValue,
         ItemId = itemID,
         ItemType = itemType,
         Field = field,
         Action = action
     };
     return update;
 }