Пример #1
0
        public static bool ShouldNotifyConsistencyService(RecordStatusChangeReason recordStatusChangeReason)
        {
            var shouldNotify = false;
            NotifyConsistencyServiceAttribute notifyConsistencyServiceAttribute = NotifyConsistencyServiceAttribute.False;

            notifyConsistencyServiceAttribute = FindNotifyConsistencyServiceAttribute(recordStatusChangeReason);
            shouldNotify = notifyConsistencyServiceAttribute.ShouldNotify;

            return(shouldNotify);
        }
 public void UpdateRecordStatus(IResponseContext responceContext, int statusId, RecordStatusChangeReason reasonForStatusChange)
 {
     _surveyResponseDao.UpdateRecordStatus(responceContext, statusId, reasonForStatusChange);
 }
        public List <SurveyResponseBO> UpdateSurveyResponse(List <SurveyResponseBO> surveyResponseBOs, int status, RecordStatusChangeReason reasonForStatusChange)
        {
            List <SurveyResponseBO> result = surveyResponseBOs;

            //Check if this respose has parent
            foreach (var surveyResponseBO in surveyResponseBOs)
            {
                ((IResponseContext)surveyResponseBO).ResolveMetadataDependencies();
                surveyResponseBO.RecStatus             = status;
                surveyResponseBO.ReasonForStatusChange = reasonForStatusChange;
                _surveyResponseDao.UpdateSurveyResponse(surveyResponseBO);
            }
            return(result);
        }
Пример #4
0
        public bool UpdateResponseStatus(IResponseContext responseContext, int responseStatus, RecordStatusChangeReason reasonForStatusChange)
        {
            var formId     = responseContext.FormId;
            var responseId = responseContext.ResponseId;

            Attachment attachment = null;

            try
            {
                switch (responseStatus)
                {
                case RecordStatus.Saved:
                    var UpdateAttachmentresult = _formResponseCRUD.UpdateAttachment(responseContext, responseStatus);
                    break;

                case RecordStatus.Deleted:
                    var UpdateSurveyResponseStatusToDeleteResult = _formResponseCRUD.DeleteResponse(responseContext, RecordStatus.Deleted);
                    //NotifyConsistencyService(responseId, RecordStatus.Deleted, RecordStatusChangeReason.DeleteResponse);
                    break;

                case RecordStatus.RecoverLastRecordVersion:
                    attachment = RecoverLastRecordVersion(responseContext);
                    if (attachment == null)
                    {
                        //Add new record Don't Save
                        var NewRecordDontSaveResult = _formResponseCRUD.DeleteResponse(responseContext, RecordStatus.PhysicalDelete);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(true);
        }
Пример #5
0
        public void NotifyConsistencyService(IResponseContext responseContext, int responseStatus, RecordStatusChangeReason reasonForStatusChange)
        {
            if (responseStatus == RecordStatus.Deleted || responseStatus == RecordStatus.Saved)
            {
                try
                {
                    var serviceBusCRUD       = new ServiceBusCRUD();
                    var hierarchicalResponse = GetHierarchicalResponsesByResponseId(responseContext, includeDeletedRecords: true);
                    var messageHeader        = string.Format("{0},{1},{2}", responseContext.RootFormName, responseContext.RootFormId, responseContext.RootResponseId);

                    var shouldNotify = ConsistencyServiceAttributeHelper.ShouldNotifyConsistencyService(reasonForStatusChange);
                    if (shouldNotify)
                    {
                        //send notification to ServiceBus
                        NotifyConsistencyService(hierarchicalResponse);
                        //ConsistencyHack(hierarchicalResponse);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
Пример #6
0
        private static NotifyConsistencyServiceAttribute FindNotifyConsistencyServiceAttribute(RecordStatusChangeReason key)
        {
            NotifyConsistencyServiceAttribute notifyConsistencyServiceAttribute = null;
            var field = _fields.Where(f => f.Name == key.ToString()).SingleOrDefault();

            if (field != null)
            {
                notifyConsistencyServiceAttribute = field.GetCustomAttributes(false).Where(a => a.GetType() == typeof(NotifyConsistencyServiceAttribute)).FirstOrDefault() as NotifyConsistencyServiceAttribute;
            }
            notifyConsistencyServiceAttribute = notifyConsistencyServiceAttribute ?? NotifyConsistencyServiceAttribute.False;
            return(notifyConsistencyServiceAttribute);
        }