コード例 #1
0
        void mrsClient_CreateSalesEstimateLogCompleted(object sender, CreateSalesEstimateLogCompletedEventArgs e)
        {
            _mrsClient.CreateSalesEstimateLogCompleted -= new EventHandler <CreateSalesEstimateLogCompletedEventArgs>(mrsClient_CreateSalesEstimateLogCompleted);

            if (e.Error == null)
            {
                string subject = string.Empty;
                string desc    = "";
                if (_logAction == MRSLogAction.Reject && _nextRevisionTypeId == 1 && EstimateList.SelectedContractid != "0") //Rejects to Sales Consultant
                {
                    subject = @"Estimate " + _estimatenumber + " V" + _revisionnumner + " has been rejected!";
                    desc    = (App.Current as App).CurrentUserFullName + @" has rejected estimate " + _estimatenumber + " (Revision " + _revisionnumner + @") and have requested you rectify as per comments below.<br>
                         <b>Details:</b><br>
                         Customer Name: " + estimate.CustomerName + @"<br>
                         Contract No: " + estimate.ContractNumber + @"<br>
                         Estimate No: " + _estimatenumber + @"<br>
                         Revision No: " + _revisionnumner + @"<br>
                         Rejected By: " + (App.Current as App).CurrentUserFullName + @"<br>
                         Comments: " + txtComments.Text + @"<br><br>
                         <b>Action:</b><br>
                         Please communicate above comments to customer.<br><br>
                         <b>Note:</b><br>
                         You can always view completed estimate in system by visiting http://metriconretail<br><br>
                         Kind Regards,<br><br>
                         Metricon Homes";

                    _mrsClient.CreateTaskForContractCompleted += new EventHandler <CreateTaskForContractCompletedEventArgs>(mrsClient_CreateTaskForContractCompleted);
                    _mrsClient.CreateTaskForContractAsync(EstimateList.SelectedContractid, EstimateList.SelectedEstimateRevisionId, subject, DateTime.Now.AddDays(2), "Rejected", desc);

                    // send email to SC to notify rejection
                    //_mrsClient.SendNotificationEmailCompleted += delegate(object o,  SendNotificationEmailCompletedEventArgs es)
                    //{

                    //    if (es.Error == null)
                    //    {

                    //    }
                    //    else
                    //        ExceptionHandler.PopUpErrorMessage(es.Error, "SendNotificationEmail");

                    //};

                    //_mrsClient.SendNotificationEmailAsync(EstimateList.SelectedContractid,estimate.SalesAcceptor, estimate.SalesConsultantName, estimate.ContractNumber.ToString(), "new_contract", "REJECTED", _estimatenumber, _revisionnumner, txtComments.Text);
                }
                else if (_logAction == MRSLogAction.Accept && chkCustomerNotification.IsChecked == true && _nextRevisionTypeId == 1 && EstimateList.SelectedContractid != "0")
                {
                    subject = @"Customer Notification is required for Estimate " + _estimatenumber + " V" + _revisionnumner;
                    desc    = (App.Current as App).CurrentUserFullName + @"  has completed estimate " + _estimatenumber + " (Revision " + _revisionnumner + @") and have requested you  to notify customer of following. Completed estimate is also attached for your reference.<br>
                         <b>Details:</b><br>
                         Customer Name: " + estimate.CustomerName + @"<br>
                         Contract No: " + estimate.ContractNumber + @"<br>
                         Estimate No: " + _estimatenumber + @"<br>
                         Revision No: " + _revisionnumner + @"<br>
                         Completed By: " + (App.Current as App).CurrentUserFullName + @"<br>
                         Comments: " + txtComments.Text + @"<br><br>
                         <b>Action:</b><br>
                         Please communicate above comments to customer.<br><br>
                         <b>Note:</b><br>
                         You can always view completed estimate in system by visiting http://metriconretail<br><br>
                         Kind Regards,<br><br>
                         Metricon Homes";

                    _mrsClient.CreateTaskForContractCompleted += new EventHandler <CreateTaskForContractCompletedEventArgs>(mrsClient_CreateTaskForContractCompleted);
                    _mrsClient.CreateTaskForContractAsync(EstimateList.SelectedContractid, EstimateList.SelectedEstimateRevisionId, subject, DateTime.Now.AddDays(1), "Completed", desc);

                    // send email to SC to notify rejection
                    //_mrsClient.SendNotificationEmailCompleted += delegate(object o, SendNotificationEmailCompletedEventArgs es)
                    //{

                    //    if (es.Error == null)
                    //    {

                    //    }
                    //    else
                    //        ExceptionHandler.PopUpErrorMessage(es.Error, "SendNotificationEmail");

                    //};

                    //_mrsClient.SendNotificationEmailAsync(EstimateList.SelectedContractid, estimate.SalesAcceptor, estimate.SalesConsultantName, estimate.ContractNumber.ToString(), "new_contract", "COMPLETED", _estimatenumber, _revisionnumner, txtComments.Text);
                }
                else if (_logAction == MRSLogAction.Reject && _nextRevisionTypeId == 5 && _ownerId > 0 && EstimateList.SelectedContractid != "0") //Rejects to CSC
                {
                    subject = @"Estimate " + _estimatenumber + " V" + _revisionnumner + " has been rejected!";
                    desc    = (App.Current as App).CurrentUserFullName + @" has rejected estimate " + _estimatenumber + " (Revision " + _revisionnumner + @") and have requested you rectify as per comments below.<br>
                         <b>Details:</b><br>
                         Customer Name: " + estimate.CustomerName + @"<br>
                         Contract No: " + estimate.ContractNumber + @"<br>
                         Estimate No: " + _estimatenumber + @"<br>
                         Revision No: " + _revisionnumner + @"<br>
                         Rejected By: " + (App.Current as App).CurrentUserFullName + @"<br>
                         Comments: " + txtComments.Text + @"<br><br>
                         <b>Action:</b><br>
                         Please communicate above comments to customer.<br><br>
                         <b>Note:</b><br>
                         You can always view completed estimate in system by visiting http://metriconretail<br><br>
                         Kind Regards,<br><br>
                         Metricon Homes";

                    _mrsClient.SendCrmEmailCompleted += new EventHandler <SendCrmEmailCompletedEventArgs>(_mrsClient_SendCrmEmailCompleted);
                    _mrsClient.SendCrmEmailAsync(new Guid(EstimateList.SelectedContractid), _ownerId, subject, desc);
                }
                else if (_logAction == MRSLogAction.Accept && _ownerId > 0 && EstimateList.SelectedContractid != "0") //Assign automatically to existing user
                {
                    subject = @"Estimate " + _estimatenumber + " V" + _revisionnumner + " has been assigned to you.";
                    desc    = (App.Current as App).CurrentUserFullName + @" has completed estimate " + _estimatenumber + " (Revision " + _revisionnumner + @") and the MRS automatically assigned it to you.<br>
                         <b>Details:</b><br>
                         Customer Name: " + estimate.CustomerName + @"<br>
                         Contract No: " + estimate.ContractNumber + @"<br>
                         Estimate No: " + _estimatenumber + @"<br>
                         Revision No: " + _revisionnumner + @"<br>
                         Completed By: " + (App.Current as App).CurrentUserFullName + @"<br>
                         Comments: " + txtComments.Text + @"<br><br>
                         <b>Action:</b><br>
                         Please work on the assigned estimate.<br><br>
                         <b>Note:</b><br>
                         You can always view completed estimate in system by visiting http://metriconretail<br><br>
                         Kind Regards,<br><br>
                         Metricon Homes";

                    _mrsClient.SendCrmEmailCompleted += new EventHandler <SendCrmEmailCompletedEventArgs>(_mrsClient_SendCrmEmailCompleted);
                    _mrsClient.SendCrmEmailAsync(new Guid(EstimateList.SelectedContractid), _ownerId, subject, desc);
                }
                else
                {
                    CompleteEstimate();
                }
            }
            else
            {
                BusyIndicator1.IsBusy = false;
                ExceptionHandler.PopUpErrorMessage(e.Error, "CreateSalesEstimateLogCompleted");
            }
        }