コード例 #1
0
        private void InitializeFromTemplate(TemplateData template)
        {
            var staffRecips = new List <StaffSummary>();
            var groupRecips = new List <StaffGroupSummary>();

            if (template != null)
            {
                var staffRecipIds = template.GetStaffRecipients();
                var groupRecipIds = template.GetGroupRecipients();
                if (staffRecipIds.Count > 0 || groupRecipIds.Count > 0)
                {
                    // load the recipient staff/groups defined in the template
                    Platform.GetService <IOrderNoteService>(
                        service =>
                    {
                        var formDataRequest  = new GetConversationEditorFormDataRequest(staffRecipIds, groupRecipIds);
                        var formDataResponse = service.GetConversationEditorFormData(formDataRequest);
                        staffRecips          = formDataResponse.RecipientStaffs;
                        groupRecips          = formDataResponse.RecipientStaffGroups;
                    });
                }
            }

            InitializeFromTemplate(template, staffRecips, groupRecips);
        }
コード例 #2
0
        /// <summary>
        /// Called by the host to initialize the application component.
        /// </summary>
        public override void Start()
        {
            // init lookup handlers
            _cannedTextLookupHandler = new CannedTextLookupHandler(this.Host.DesktopWindow);

            // init recip table here, and not in constructor, because it relies on Host being set
            _recipients = new RecipientTable(this);

            // if exactly 1 template choice, then it is selected
            _selectedTemplate = _templateChoices.Count == 1 ? _templateChoices[0] : null;

            // create soft keys
            UpdateSoftKeys();

            // load the existing conversation, plus editor form data
            GetConversationEditorFormDataResponse formDataResponse = null;

            Platform.GetService <IOrderNoteService>(
                service =>
            {
                var formDataRequest = new GetConversationEditorFormDataRequest(
                    _selectedTemplate != null ? _selectedTemplate.GetStaffRecipients() : new List <string>(),
                    _selectedTemplate != null ? _selectedTemplate.GetGroupRecipients() : new List <string>());
                formDataResponse = service.GetConversationEditorFormData(formDataRequest);

                var request  = new GetConversationRequest(_orderRef, new List <string>(_orderNoteCategories), false);
                var response = service.GetConversation(request);

                _orderRef   = response.OrderRef;
                _orderNotes = response.OrderNotes;
            });


            // init on-behalf of choices
            _onBehalfOfChoices = formDataResponse.OnBehalfOfGroupChoices;
            _onBehalfOfChoices.Insert(0, _emptyStaffGroup);

            // initialize from template (which may be null)
            InitializeFromTemplate(_selectedTemplate, formDataResponse.RecipientStaffs, formDataResponse.RecipientStaffGroups);

            // build the action model
            _recipientsActionModel = new CrudActionModel(true, false, true, new ResourceResolver(this.GetType(), true));
            _recipientsActionModel.Add.SetClickHandler(AddRecipient);
            _recipientsActionModel.Delete.SetClickHandler(DeleteRecipient);

            // init conversation view component
            _orderNoteViewComponent = new OrderNoteViewComponent(_orderNotes);
            _orderNoteViewComponent.CheckedItemsChanged += delegate { NotifyPropertyChanged("CompleteButtonLabel"); };
            _orderNotesComponentHost = new ChildComponentHost(this.Host, _orderNoteViewComponent);
            _orderNotesComponentHost.StartComponent();

            base.Start();
        }