/// <summary>
        /// Process an exhibit with a custom workflow
        /// </summary>
        /// <param name="exhibitId"></param>
        /// <param name="mediaId"></param>
        /// <param name="workflow"></param>
        public void ProcessExhibit(int exhibitId, int mediaId, List <EVE.Workflow.WorkflowStep> workflow)
        {
            const bool isDistributable = false;
            int?       parentWorkId    = null;

            // Create the work item which will trigger processing.
            var workParams = Serializer.SerializeToBinary(new EVE.GroupController.Contract.Work.WorkBase.WorkParameters
            {
                RuntimeData = new Dictionary <string, string>
                {
                    { "ExhibitId", exhibitId.ToString(CultureInfo.InvariantCulture) },
                    { "MediaId", mediaId.ToString(CultureInfo.InvariantCulture) }
                }
            });

            Media.UpdateMedia_Workflow(exhibitId, mediaId, Serializer.SerializeToXml <List <EVE.Workflow.WorkflowStep> >(workflow));
            Work.InsertWork(typeof(EVE.GroupController.Contract.Work.ProcessMedia).FullName, workParams, isDistributable, parentWorkId);
            Media.UpdateMedia_Status(exhibitId, mediaId, MediaStatus.Queued);
        }
        public bool IsExhibitProcessed(ExhibitHelperModel model)
        {
            var media = Media.GetMedia(model.ExhibitId, model.MediaId);

            switch (media.MediaStatusCode)
            {
            case "DEFINED":
            case "QUEUED":
            case "PROC":
            case "REPROC":
                return(false);

            case "VALIDATIONERR":
                throw new Exception("Exhibit Processing validation error");

            case "PROCESSED":
                return(true);

            case "PROCERR":
                throw new Exception("Exhibit Processing Error");
            }
            return(false);
        }
        public ExhibitHelperModel PrepareDbData(string evidencePath, AcquisitionFormatType type)
        {
            var exhibitDataModel = new ExhibitDataModel().GetDefault();
            var caseDataModel    = new CaseDataModel().GetDefault();
            var mediaDataModel   = new MediaDataModel().GetDefault();

            caseDataModel.SiteId = new SiteTable(Config.GetConnectionString(DataStore.Central)).GetSiteId();

            var caseId = Case.InsertCase(caseDataModel.PoliceFileNumber,
                                         caseDataModel.EclCaseNumber,
                                         caseDataModel.Description,
                                         caseDataModel.OfficerInChargeId,
                                         caseDataModel.DistrictId,
                                         caseDataModel.SiteId,
                                         caseDataModel.OffenceTypeId,
                                         caseDataModel.CreatedById);

            var exhibitId = EVE.BLL.Exhibit.CreateExhibit(caseId,
                                                          caseDataModel.CreatedById,
                                                          exhibitDataModel.EclExhibitNumber,
                                                          exhibitDataModel.Description,
                                                          exhibitDataModel.PoliceExhibitNumber);

            mediaDataModel.EvidencePath = Path.GetFullPath(evidencePath);

            var mediaId = Media.InsertMedia(exhibitId,
                                            mediaDataModel.MediaNumber,
                                            mediaDataModel.Description,
                                            mediaDataModel.EvidencePath,
                                            MediaStatus.Defined,
                                            type,
                                            string.Empty);

            return(new ExhibitHelperModel {
                ExhibitId = exhibitId, MediaId = mediaId, CaseId = caseId, CasePoliceNumber = caseDataModel.PoliceFileNumber, EclExhibitNumber = exhibitDataModel.EclExhibitNumber, MediaNumber = mediaDataModel.MediaNumber
            });
        }