예제 #1
0
    public static void GenerateDemoData(
      IIssueRepository issueRepository, 
      IProjectRepository projectRepository, 
      IAttachmentRepository attachmentRepository)
    {
      Project p = new Project("SHOP", "Webshop", "All issues related to the webshop.");
      projectRepository.Add(p);

      Issue i = new Issue(p, "Crash after payment", @"I have justed paid for two pairs of shoes - or rather I tried to. When I clicked 'Pay' all I got was a yellow error screen.", 3);

      issueRepository.Add(i);

      string errorReport = "This is an error report ...";
      Attachment att = new Attachment(i, "Error report", "Error report from end user", Encoding.UTF8.GetBytes(errorReport), "text/plain");
      attachmentRepository.Add(att);

      string logFile = "DEBUG 2014-01-22 15:45:07,610 166033ms  [9] Log4NetTraceListener   WriteLine          - Executing OperationResult OperationResult: type=OK, statusCode=200.";
      att = new Attachment(i, "Logfile", "Logfile with server stack trace", Encoding.UTF8.GetBytes(logFile), "text/plain");
      attachmentRepository.Add(att);

      i = new Issue(p, "Not calculating VAT correctly", @"When I add both shoes and socks it fails to calculate the VAT correctly.", 3);

      issueRepository.Add(i);

      i = new Issue(p, "General Failure?", @"When I press ctrl-P it says 'General failure reading harddisk'! Who is that General and why is he reading my hard disk?", 5);

      issueRepository.Add(i);
    }
예제 #2
0
        public static void GenerateDemoData(
            IIssueRepository issueRepository,
            IProjectRepository projectRepository,
            IAttachmentRepository attachmentRepository)
        {
            Project p = new Project("SHOP", "Webshop", "All issues related to the webshop.");

            projectRepository.Add(p);

            Issue i = new Issue(p, "Crash after payment", @"I have justed paid for two pairs of shoes - or rather I tried to. When I clicked 'Pay' all I got was a yellow error screen.", 3);

            issueRepository.Add(i);

            string     errorReport = "This is an error report ...";
            Attachment att         = new Attachment(i, "Error report", "Error report from end user", Encoding.UTF8.GetBytes(errorReport), "text/plain");

            attachmentRepository.Add(att);

            string logFile = "DEBUG 2014-01-22 15:45:07,610 166033ms  [9] Log4NetTraceListener   WriteLine          - Executing OperationResult OperationResult: type=OK, statusCode=200.";

            att = new Attachment(i, "Logfile", "Logfile with server stack trace", Encoding.UTF8.GetBytes(logFile), "text/plain");
            attachmentRepository.Add(att);

            i = new Issue(p, "Not calculating VAT correctly", @"When I add both shoes and socks it fails to calculate the VAT correctly.", 3);

            issueRepository.Add(i);

            i = new Issue(p, "General Failure?", @"When I press ctrl-P it says 'General failure reading harddisk'! Who is that General and why is he reading my hard disk?", 5);

            issueRepository.Add(i);
        }
예제 #3
0
        /// <summary>
        /// Adds an attachment
        /// </summary>
        /// <param name="attachment"></param>
        /// <returns></returns>
        public int AddAttachment(AttachmentDomain attachment)
        {
            ValidationHelper.NotNull(attachment, NotificationMessages.AttachmentNotProvided);
            ValidationHelper.NotNull(attachment.File, NotificationMessages.AttachmentFileNotProvided);

            return(_attachmentRepository.Add(attachment));
        }
예제 #4
0
        public Attachment UploadAttachment(string applicationId, byte[] bytes, string fileName, string fileType)
        {
            string FileEncryptKey = GenerateEncryptionKey();

            var fileUpload = new Attachment()
            {
                FileSize         = bytes.Length,
                MimeType         = fileType,
                OriginalFileName = fileName,
                Deleted          = false,
                ApplicationId    = applicationId,
                EncryptionKey    = FileEncryptKey
            };

            fileUpload.RepositoryFilePath = $@"{applicationId}\{fileUpload.Id}";

            // Encrypt file
            byte[] keyInBytes = Encoding.UTF8.GetBytes(FileEncryptKey + fileName);
            // Hash the password with SHA256
            keyInBytes = SHA256.Create().ComputeHash(keyInBytes);
            byte[] bytesEncrypted = AES_Encrypt(bytes, keyInBytes);
            _fileRepository.Upload(bytesEncrypted, fileUpload.RepositoryFilePath);

            _attachmentRepository.Add(fileUpload);
            _attachmentRepository.SaveChanges();

            return(fileUpload);
        }
예제 #5
0
 protected void AddAttachments(IAttachmentRepository attachmentRepository, Diary diary, List <string> fileNames)
 {
     foreach (string fileName in fileNames)
     {
         attachmentRepository.Add(new Attachment {
             Path = fileName, DiaryId = diary.Id
         });
     }
 }
예제 #6
0
 protected void AddAttachments(IAttachmentRepository attachmentRepository, Todo todo, List <string> fileNames)
 {
     foreach (string fileName in fileNames)
     {
         attachmentRepository.Add(new Attachment {
             Path = fileName, TodoId = todo.Id
         });
     }
 }
 public Tuple <bool, string> Add(AttachmentModel attachmentModel)
 {
     try
     {
         _attachmentRepository.Add(new Attachment {
             File = attachmentModel.File, Extention = attachmentModel.Extention, RequestId = attachmentModel.RequestId, Size = attachmentModel.Size, Title = attachmentModel.Title
         });
         _unitOfWork.SaveChanges();
         return(new Tuple <bool, string>(true, "عملیات ثبت شد"));
     }
     catch (Exception ex)
     {
         return(new Tuple <bool, string>(false, "خطا در انجام عملیات"));
     }
 }
예제 #8
0
        public Attachment UploadAttachment(string EIN, MemoryStream memoryStream, string fileName, string fileType)
        {
            var fileUpload = new Attachment()
            {
                FileSize         = memoryStream.Length,
                MimeType         = fileType,
                OriginalFileName = fileName,
                Deleted          = false,
                EIN = EIN
            };

            fileUpload.RepositoryFilePath = $@"{EIN}\{fileUpload.Id}";

            _fileRepository.Upload(memoryStream, fileUpload.RepositoryFilePath);

            _attachmentRepository.Add(fileUpload);
            _attachmentRepository.SaveChanges();

            return(fileUpload);
        }
예제 #9
0
 public int SaveAttachment(AttachmentRequest _request)
 {
     var entity = Mapper.Map<AttachmentRequest, Attachment>(_request);
     entity.IsDeleted = false;
     entity.CreatedBy = 1;
     entity.CreatedDate = System.DateTime.Now;
     entity.Remark = "None";
     entity.ReportId = 1;
     entity.ModifiedBy = 1;
     entity.ModifiedDate = System.DateTime.Now;
     _attachmentRepository.Add(entity);
     if (_attachmentRepository.Commit())
     {
         return entity.Id;
     }
     else
     {
         return 0;
     }
 }
예제 #10
0
        public void OnElectrocardiogramUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            if (e.IsValid)
            {
                var attachment =
                    new Attachment {
                    FileName        = e.UploadedFile.FileName,
                    MimeType        = e.UploadedFile.ContentType,
                    StorageFileName = Path.ChangeExtension(
                        Guid.NewGuid().ToString(),
                        Path.GetExtension(e.UploadedFile.FileName)),
                    FileSize = (int)e.UploadedFile.ContentLength
                };
                attachmentRepository.Add(attachment);
                SaveFile(e, attachment);
                attachmentRepository.Save();

                e.CallbackData = string.Format(
                    "{{ \"id\": {0}, \"name\": \"{1}\", \"link\": \"{2}\" }}",
                    attachment.Id.ToString(),
                    attachment.FileName,
                    Url.Action("GetAttachment", "Attachment", new { id = attachment.Id }));
            }
        }
        public void PopulateDay1Visit(Visit day1Visit, Visit baselineVisit)
        {
            //happiness form
            int dice;

            dice = randomGenerator.Next(100);
            if (dice < FormIsFilledChance)
            {
                var happinessForm = day1Visit.Forms.First(f => f.FormType == FormType.Happiness);
                happinessForm.FormState = FormState.Completed;
                var happinessFormData = happinessFormDataRepository.GetFormDataByFormId(happinessForm.Id);
                int happinessLevel;
                dice = randomGenerator.Next(100);
                if (dice < 5)
                {
                    happinessLevel = 0;
                }
                else if (dice < 25)
                {
                    happinessLevel = 25;
                }
                else if (dice < 90)
                {
                    happinessLevel = 50;
                }
                else if (dice < 98)
                {
                    happinessLevel = 75;
                }
                else
                {
                    happinessLevel = 100;
                }
                happinessFormData.HappinessLevel.Value = happinessLevel.ToString();
            }
            //electrocardiogram form
            dice = randomGenerator.Next(100);
            if (dice < FormIsFilledChance)
            {
                var electrocardiogramForm = day1Visit.Forms.First(f => f.FormType == FormType.Electrocardiogram);
                electrocardiogramForm.FormState = FormState.Completed;
                var electrocardiogramFormData = electrocardiogramFormDataRepository.GetFormDataByFormId(electrocardiogramForm.Id);
                electrocardiogramFormData.ElectrocardiogramAttachment.File = new Attachment {
                    FileName        = string.Format("{0}_cardiogramm.png", day1Visit.Patient.Caption),
                    FileSize        = 0,
                    Id              = electrocardiogramForm.Id,
                    MimeType        = "image/png",
                    StorageFileName = "ecg1.png"
                };
                attachmentRepository.Add(electrocardiogramFormData.ElectrocardiogramAttachment.File);
            }
            //vitals form

            dice = randomGenerator.Next(100);
            if (dice < FormIsFilledChance)
            {
                var vitalsOriginalForm = baselineVisit.Forms.First(f => f.FormType == FormType.Vitals);
                if (vitalsOriginalForm.FormState == FormState.Completed)
                {
                    var vitalsOriginalFormData = vitalsFormDataRepository.GetFormDataByFormId(vitalsOriginalForm.Id);

                    var vitalsForm = day1Visit.Forms.First(f => f.FormType == FormType.Vitals);
                    vitalsForm.FormState = FormState.Completed;
                    var vitalsFormData = vitalsFormDataRepository.GetFormDataByFormId(vitalsForm.Id);


                    vitalsFormData.ActualTime.Value = day1Visit.VisitTime.Value.AddMinutes(randomGenerator.Next(18) * 10).ToString();


                    FillVitalsBasedOnPreviousVisit(vitalsOriginalFormData, vitalsFormData, vitalsForm);
                }
            }
        }
예제 #12
0
        public async Task <SendMessageResponse> UpdateProcessTaskAssign(TaskItemAssignDto dto)
        {
            SendMessageResponse sendMessage = new SendMessageResponse();

            try
            {
                using (var scope = _dbContextScopeFactory.Create())
                {
                    List <AttachmentDto> attachmentDtos = dto.Attachments.ToList();
                    dto.Attachments = null;
                    TaskItemAssign entity = _objectRepository.GetAll().Where(e => e.Id == dto.Id).FirstOrDefault();
                    if (entity != null)
                    {
                        TaskItem taskEntity = _taskItemRepository.GetAll().Where(e => e.Id == entity.TaskItemId).FirstOrDefault();
                        if (!dto.IsFullControl && taskEntity.AssignBy != dto.ModifiedBy && entity.AssignTo != dto.ModifiedBy)
                        {
                            sendMessage = SendMessageResponse.CreateFailedResponse("AccessDenied");
                            return(sendMessage);
                        }
                        if (DateTime.TryParseExact(dto.ExtendDateText, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime extendDate))
                        {
                            dto.ExtendDate = extendDate;
                        }
                        else
                        {
                            dto.ExtendDate = null;
                        }
                        entity.AppraiseProcess = dto.AppraiseProcess;
                        entity.AppraiseStatus  = dto.AppraiseStatus;
                        entity.FinishedDate    = dto.FinishedDate;
                        entity.FromDate        = dto.FromDate;
                        entity.IsDeleted       = dto.IsDeleted;
                        entity.ModifiedDate    = dto.ModifiedDate;
                        entity.Problem         = dto.Problem;
                        entity.Solution        = dto.Solution;
                        entity.ToDate          = dto.ToDate;
                        if (entity.AssignTo == dto.ModifiedBy && !dto.IsAssignBy)
                        {
                            switch (dto.ActionText)
                            {
                            case "Process":
                                dto.TaskItemStatusId = TaskItemStatusId.InProcess;
                                dto.ActionId         = ActionId.Process;
                                entity.PercentFinish = dto.PercentFinish;
                                break;

                            case "Report":
                                if (taskEntity.IsReport == false)
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.Finished;
                                    dto.ActionId         = ActionId.Finish;
                                }
                                else
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.Report;
                                    dto.ActionId         = ActionId.Report;
                                }
                                entity.PercentFinish = dto.PercentFinish;
                                break;

                            case "Extend":
                                entity.IsExtend      = true;
                                entity.ExtendDate    = dto.ExtendDate;
                                dto.ActionId         = ActionId.Extend;
                                entity.PercentFinish = dto.PercentFinish;

                                break;

                            case "ReturnReport":
                                dto.TaskItemStatusId = TaskItemStatusId.ReportReturn;
                                dto.ActionId         = ActionId.Return;
                                break;

                            default:
                                break;
                            }
                            if (entity.TaskType != TaskType.Primary)
                            {
                                dto.TaskItemStatusId = TaskItemStatusId.Read;
                            }
                            entity.LastResult = dto.Description;
                            //entity.IsExtend = dto.IsExtend;
                            //entity.ExtendDate = dto.ExtendDate;
                        }
                        if (taskEntity.AssignBy == dto.ModifiedBy && dto.IsAssignBy)
                        {
                            switch (dto.ActionText)
                            {
                            case "Appraise":
                                dto.ActionId = ActionId.Appraise;

                                if (entity.TaskItemStatusId == TaskItemStatusId.Extend)
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.InProcess;
                                }
                                else if (entity.TaskItemStatusId == TaskItemStatusId.Report)
                                {
                                    dto.TaskItemStatusId         = TaskItemStatusId.Finished;
                                    entity.AppraisePercentFinish = dto.AppraisePercentFinish;
                                    entity.PercentFinish         = dto.AppraisePercentFinish;
                                    dto.ActionId = ActionId.Finish;
                                }
                                else if (entity.TaskItemStatusId == TaskItemStatusId.ReportReturn)
                                {
                                    dto.TaskItemStatusId = TaskItemStatusId.Cancel;
                                }
                                break;

                            case "Return":
                                dto.TaskItemStatusId         = TaskItemStatusId.InProcess;
                                entity.AppraisePercentFinish = dto.AppraisePercentFinish;
                                entity.PercentFinish         = dto.AppraisePercentFinish;
                                dto.ActionId = ActionId.Return;
                                break;

                            case "AppraiseExtend":
                                entity.ExtendDate = dto.ExtendDate;
                                taskEntity.ToDate = dto.ExtendDate;
                                entity.IsExtend   = false;
                                dto.ActionId      = ActionId.Appraise;
                                break;

                            case "ReturnExtend":
                                entity.ExtendDate = null;
                                entity.IsExtend   = false;
                                dto.ActionId      = ActionId.Return;
                                break;

                            default:
                                break;
                            }
                            entity.AppraiseResult = dto.Description;
                        }

                        entity.TaskItemStatusId = dto.TaskItemStatusId;
                        TaskItemProcessHistory taskAssignHistory = new TaskItemProcessHistory
                        {
                            Id               = Guid.NewGuid(),
                            ProjectId        = entity.ProjectId,
                            ActionId         = dto.ActionId,
                            CreatedBy        = dto.ModifiedBy,
                            PercentFinish    = entity.PercentFinish,
                            CreatedDate      = dto.ModifiedDate,
                            TaskItemId       = entity.TaskItemId,
                            TaskItemAssignId = entity.Id,
                            TaskItemStatusId = entity.TaskItemStatusId,
                            ProcessResult    = dto.Description
                        };
                        if (entity.TaskType == TaskType.Primary || dto.IsAssignBy)
                        {
                            //TaskItemProcessHistory taskHistory = new TaskItemProcessHistory
                            //{
                            //    Id = Guid.NewGuid(),
                            //    ProjectId = entity.ProjectId,
                            //    ActionId = dto.ActionId,
                            //    CreatedBy = dto.ModifiedBy,
                            //    PercentFinish = dto.PercentFinish,
                            //    CreatedDate = dto.ModifiedDate,
                            //    TaskItemId = entity.TaskItemId,
                            //    TaskItemStatusId = entity.TaskItemStatusId,
                            //    ProcessResult = dto.Description
                            //};
                            taskEntity.TaskItemStatusId = entity.TaskItemStatusId;
                            taskEntity.PercentFinish    = entity.PercentFinish;
                            //_taskItemProcessHistoryRepository.Add(taskHistory);
                        }

                        _objectRepository.Modify(entity);
                        //_taskItemRepository.Modify(taskEntity);
                        _taskItemProcessHistoryRepository.Add(taskAssignHistory);
                        foreach (AttachmentDto attachDto in attachmentDtos)
                        {
                            attachDto.ProjectId = entity.ProjectId;
                            attachDto.ItemId    = entity.Id;
                            Attachment attach = _mapper.Map <Attachment>(attachDto);
                            _attachmentRepository.Add(attach);
                        }
                        if (dto.AttachDelIds != null)
                        {
                            if (dto.AttachDelIds.Any())
                            {
                                List <Attachment> attachDels = _attachmentRepository.GetAll().Where(e => dto.AttachDelIds.Contains(e.Id)).ToList();
                                _attachmentRepository.DeleteRange(attachDels);
                            }
                        }
                        await scope.SaveChangesAsync();

                        var param = new List <SqlParameter>();
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.UniqueIdentifier,
                            ParameterName = "@ProjectId",
                            IsNullable    = false,
                            Value         = dto.ProjectId
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.UniqueIdentifier,
                            ParameterName = "@TaskId",
                            IsNullable    = false,
                            Value         = taskEntity.Id
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.DateTime,
                            ParameterName = "@FromDate",
                            IsNullable    = false,
                            Value         = taskEntity.FromDate
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.DateTime,
                            ParameterName = "@ToDate",
                            IsNullable    = false,
                            Value         = taskEntity.ToDate
                        });
                        param.Add(new SqlParameter()
                        {
                            SqlDbType     = SqlDbType.Bit,
                            ParameterName = "@IsUpdateStatus",
                            IsNullable    = true,
                            Value         = 1
                        });
                        await _objectRepository.SqlQueryAsync(typeof(ProjectDto), "[dbo].[SP_UPDATE_TASK_RANGE_DATE] @ProjectId, @TaskId, @FromDate, @ToDate, @IsUpdateStatus", param.ToArray());
                    }
                }
                sendMessage = SendMessageResponse.CreateSuccessResponse(string.Empty);
                return(sendMessage);
            }
            catch (Exception ex)
            {
                _loggerServices.WriteError(ex.ToString());
                sendMessage = SendMessageResponse.CreateFailedResponse(string.Empty);
                return(sendMessage);
            }
        }
예제 #13
0
        private int AddAttachmentFiles(string appId, int customerId, long creditCheckingId,
                                       ICollection <AttachmentUploadResource> attachmentUploadResourceFiles,
                                       string createdByUserId)
        {
            // Upsert Attachment rows for this App. and Customer
            IEnumerable <Attachment> attachmentsFromRepo = _attachmentRepo.Query(a => a.AppId == appId && a.CustomerId == customerId);

            int seq = 1;

            if (attachmentsFromRepo != null)
            {
                // Loop by New Upload files from User
                foreach (var newAttachment in attachmentUploadResourceFiles)
                {
                    var existingAttachment = _attachmentRepo.FindByKey(seq, newAttachment.AppId,
                                                                       newAttachment.CustomerId);

                    // Add new if not found
                    if (existingAttachment == null)
                    {
                        _attachmentRepo.Add(new Attachment
                        {
                            Id             = seq,
                            AppId          = newAttachment.AppId,
                            CustomerId     = newAttachment.CustomerId,
                            CCCreditChkId  = creditCheckingId,
                            AttachmentType = newAttachment.AttachmentType,
                            Name           = newAttachment.Name,
                            FileName       = string.Empty,
                            Remark         = string.Empty,
                            Status         = BusinessConstant.StatusActive,
                            CreateBy       = createdByUserId,
                            CreateDate     = DateTime.Now,
                            UpdateBy       = createdByUserId,
                            UpdateDate     = DateTime.Now
                        });
                    }
                    else
                    {
                        existingAttachment.Id             = seq;
                        existingAttachment.AppId          = newAttachment.AppId;
                        existingAttachment.CustomerId     = newAttachment.CustomerId;
                        existingAttachment.CCCreditChkId  = creditCheckingId;
                        existingAttachment.AttachmentType = newAttachment.AttachmentType;
                        existingAttachment.Name           = newAttachment.Name;
                        existingAttachment.FileName       = string.Empty;
                        existingAttachment.Remark         = string.Empty;
                        existingAttachment.Status         = BusinessConstant.StatusActive;
                        existingAttachment.CreateBy       = createdByUserId;
                        existingAttachment.CreateDate     = DateTime.Now;
                        existingAttachment.UpdateBy       = createdByUserId;
                        existingAttachment.UpdateDate     = DateTime.Now;
                    }


                    //    //drSubAttachment.Attachment_CCCreditChkID = this.CCCreditChk_ID;

                    seq++;
                }

                //_attachmentRepo.Commit();
            }

            return(seq);
        }