public ServiceStatus GetServiceStatus(DocumentURI uri, string serviceIdentifier) { if (uri != null) { var doc = this.docRepository.GetDocByRegUriIncludeElectronicServiceStages(uri.RegisterIndex, int.Parse(uri.SequenceNumber), uri.ReceiptOrSigningDate.Value); if (doc != null) { ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.InitiatingDocumentURI = new InitiatingDocumentURI(); serviceStatus.InitiatingDocumentURI.RegisterIndex = uri.RegisterIndex; serviceStatus.InitiatingDocumentURI.SequenceNumber = uri.SequenceNumber; serviceStatus.InitiatingDocumentURI.ReceiptOrSigningDate = uri.ReceiptOrSigningDate; //if (!String.IsNullOrWhiteSpace(doc.DocType.ElectronicServiceFileTypeUri)) //{ // serviceStatus.ServiceURI = new AdministrativeNomenclatureServiceURI(); // serviceStatus.ServiceURI.SUNAUServiceURI = doc.DocType.ElectronicServiceFileTypeUri; //} serviceStatus.ServiceURI = new AdministrativeNomenclatureServiceURI(); serviceStatus.ServiceURI.SUNAUServiceURI = !String.IsNullOrWhiteSpace(doc.DocType.ApplicationName) ? doc.DocType.ApplicationName : doc.DocType.Name; var allStages = this.unitOfWork.DbContext.Set<ElectronicServiceStage>() .Where(e => e.DocTypeId == doc.DocTypeId.Value) .OrderBy(e => e.ElectronicServiceStageId) .ToList(); if (doc.DocElectronicServiceStages.Where(s => s.EndingDate.HasValue).Any()) { serviceStatus.ExecutedTasks = new ExecutedTasks(); serviceStatus.ExecutedTasks.TaskCollection = new TaskCollection(); foreach (var executedStage in doc.DocElectronicServiceStages.Where(s => s.EndingDate.HasValue)) { var stage = allStages.Where(s => s.ElectronicServiceStageId == executedStage.ElectronicServiceStageId).FirstOrDefault(); if (stage != null) { var task = new Task(); task.TaskData = new AISTask(); task.TaskData.NameAndShortDescription = stage.Name; task.TaskData.ExpandedDescription = stage.Description; ; task.TaskData.ScheduledStartDate = executedStage.StartingDate; task.TaskData.ScheduledCompletionDate = executedStage.ExpectedEndingDate; task.TaskData.ActualStartDate = executedStage.StartingDate; task.TaskData.ActualCompletionDate = executedStage.EndingDate; task.TaskData.ExecutedBy = new AISTaskExecutor(); task.TaskData.ExecutedBy.Names = new AISUserNames(); task.TaskData.ExecutedBy.Names.PersonNames = new PersonNames(); task.TaskData.ExecutedBy.Names.PersonNames.First = doc.DocSourceType.Alias == "Internet" && stage.Alias == "AcceptApplication" ? "Системен потребител" : "Служител МОСВ"; serviceStatus.ExecutedTasks.TaskCollection.Add(task); } } } var unexecutedStages = allStages.Where(s => !doc.DocElectronicServiceStages.Where(ds => ds.EndingDate.HasValue).Select(ds => ds.ElectronicServiceStageId).ToList() .Contains(s.ElectronicServiceStageId)); if (unexecutedStages.Any()) { serviceStatus.UnexecutedTasks = new UnexecutedTasks(); serviceStatus.UnexecutedTasks.TaskOrServiceStageCollection = new TaskOrServiceStageCollection(); foreach (var unexecutedStage in unexecutedStages) { if (unexecutedStage.Alias != "DecreeRefusal") { var task = new TaskOrServiceStage(); task.Task = new TaskOrServiceStageTask(); task.Task.TaskData = new AISTask(); task.Task.TaskData.NameAndShortDescription = unexecutedStage.Name; task.Task.TaskData.ExpandedDescription = unexecutedStage.Description; task.Task.TaskData.ScheduledStartDate = null; task.Task.TaskData.ScheduledCompletionDate = null; task.Task.TaskData.ExecutedBy = new AISTaskExecutor(); task.Task.TaskData.ExecutedBy.Names = new AISUserNames(); task.Task.TaskData.ExecutedBy.Names.PersonNames = new PersonNames(); task.Task.TaskData.ExecutedBy.Names.PersonNames.First = "Служител МОСВ"; serviceStatus.UnexecutedTasks.TaskOrServiceStageCollection.Add(task); } } } return serviceStatus; } else { throw new Exception("Document not found."); } } else { throw new ArgumentException(); } }
public ServiceStatus GetServiceStatus(DocumentURI uri, string serviceIdentifier) { var doc = this.docRepository.GetDocByRegUri(uri.RegisterIndex, int.Parse(uri.SequenceNumber), uri.ReceiptOrSigningDate.Value); if (doc != null) { ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.InitiatingDocumentURI = new InitiatingDocumentURI(); serviceStatus.InitiatingDocumentURI.RegisterIndex = uri.RegisterIndex; serviceStatus.InitiatingDocumentURI.SequenceNumber = uri.SequenceNumber; serviceStatus.InitiatingDocumentURI.ReceiptOrSigningDate = uri.ReceiptOrSigningDate; DocElectronicServiceStage currentDocStage = this.docRepository.GetCurrentServiceStageByDocId(doc.DocId); if (currentDocStage != null) { serviceStatus.UnexecutedTasks = new UnexecutedTasks(); serviceStatus.UnexecutedTasks.TaskOrServiceStageCollection = new TaskOrServiceStageCollection(); var task = new TaskOrServiceStage(); task.Task = new TaskOrServiceStageTask(); task.Task.TaskData = new AISTask(); task.Task.TaskData.NameAndShortDescription = currentDocStage.ElectronicServiceStage.Name; task.Task.TaskData.ExpandedDescription = currentDocStage.ElectronicServiceStage.Description; task.Task.TaskData.ActualStartDate = currentDocStage.StartingDate; task.Task.TaskData.ActualCompletionDate = currentDocStage.EndingDate; serviceStatus.UnexecutedTasks.TaskOrServiceStageCollection.Add(task); } return serviceStatus; } else { throw new Exception("Document not found."); } }