コード例 #1
0
        //Import attachment file
        private void ImportContractAttachment(List <string> fileList, string resurceType, Guid contractGuid, Guid resourceGuid, bool isDelete)
        {
            var destinationPath = string.Empty;

            foreach (var item in fileList)
            {
                var folder = _documentManagementService.GetFolderByKey("Contract", contractGuid, resurceType);
                var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(resurceType, contractGuid);
                if (contractResourceFile != null)
                {
                    destinationPath = rootPath + contractResourceFile.FilePath + "/";
                    var fileSize   = new System.IO.FileInfo(item).Length.ToString();
                    var outPutPath = _importFileService.MoveAttachment(item, destinationPath, isDelete);
                    if (!string.IsNullOrWhiteSpace(outPutPath))
                    {
                        var isCSV = Path.GetExtension(item) == ".csv" ? true : false;
                        ContractResourceFile contractFile = new ContractResourceFile();
                        contractFile.ContractResourceFileGuid = Guid.NewGuid();
                        contractFile.ResourceGuid             = contractGuid;
                        contractFile.CreatedBy           = loggedUser;
                        contractFile.CreatedOn           = DateTime.UtcNow;
                        contractFile.Keys                = resurceType;
                        contractFile.IsActive            = true;
                        contractFile.IsCsv               = isCSV;
                        contractFile.IsDeleted           = false;
                        contractFile.UpdatedBy           = loggedUser;
                        contractFile.UpdatedOn           = DateTime.Now;
                        contractFile.ContentResourceGuid = resourceGuid;
                        contractFile.IsFile              = true;
                        contractFile.ResourceType        = "Contract";
                        contractFile.UploadFileName      = Path.GetFileName(item);
                        contractFile.FilePath            = outPutPath.Replace(rootPath, "");
                        contractFile.FileSize            = fileSize;
                        if (folder != null)
                        {
                            contractFile.ParentId = contractResourceFile.ContractResourceFileGuid;
                        }
                        _contractsService.InsertContractFile(contractFile);
                    }
                }
            }
        }
コード例 #2
0
        public bool UpdateContractFile(ContractResourceFile file)
        {
            var insertSql = @"UPDATTE [dbo].[ContractResourceFile]
                        SET
                        ResourceGuid = @ResourceGuid,
                        UploadFileName = @UploadFileName,
                        Keys = @Keys,
                        MimeType = @MimeType,
                        IsActive = @IsActive,
                        IsDeleted = @IsDeleted,
                        CreatedBy = @CreatedBy,
                        UpdatedBy = @UpdatedBy,
                        CreatedOn = @CreatedOn,
                        IsCsv =@IsCsv
                        WHERE ContractResourceFileGuid = @ContractResourceFileGuid
                        )";

            _context.Connection.Execute(insertSql, file);
            return(true);
        }
コード例 #3
0
        public bool InsertContractFile(ContractResourceFile file)
        {
            var insertSql = @"INSERT INTO [dbo].[ContractResourceFile]
                        VALUES
                        (
                            @ResourceGuid,
                            @Keys,
                            @UploadFileName,
                            @MimeType,
                            @IsActive,
                            @IsDeleted,
                            @CreatedBy,
                            @UpdatedBy,
                            @CreatedOn,
                            @IsCsv,
                        )";

            _context.Connection.Execute(insertSql, file);
            return(true);
        }
コード例 #4
0
        private void AuditLogForUploadDownload(ContractResourceFile file, string type)
        {
            var    keys = file.Keys;
            string additionalInformation    = string.Empty;
            string additionalInformationURl = string.Empty;
            string resource = string.Empty;

            if (keys.Equals(ResourceType.Contract.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, ResourceType.Contract.ToString().ToLower() + " File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractEntity.ContractGuid);
                resource = string.Format("{0} </br>  Contract No:{1} </br> Project No:{2} </br> Contract Title:{3} </br> File Name:{4}", ResourceType.Contract.ToString(), contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.TaskOrder.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, ResourceType.TaskOrder.ToString().ToLower() + " File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", ResourceType.Contract.ToString(), contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.ContractModification.ToString()))
            {
                var contractModificationEntity = _contractModificationService.GetDetailById(file.ContentResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Contract Mod File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractModificationEntity.ContractGuid);
                resource = string.Format("{0} </br> Mod No: {1} </br> Mod Title:{2}</br> File Name:{3}", "Contract Mod", contractModificationEntity.ModificationNumber, contractModificationEntity.ModificationTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.TaskOrderModification.ToString()))
            {
                var contractModificationEntity = _contractModificationService.GetDetailById(file.ContentResourceGuid);
                additionalInformation    = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "TaskOrder Mod File");
                additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractModificationEntity.ContractGuid);
                resource = string.Format("{0} </br>  Mod No: {1} </br> Mod Title:{2}</br> File Name:{3}", "Contract Mod", contractModificationEntity.ModificationNumber, contractModificationEntity.ModificationTitle, file.UploadFileName);
            }
            else if (keys.Equals(ResourceType.EmployeeBillingRates.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Employee Billing Rates File");

                if (contractEntity.ParentContractGuid == Guid.Empty || contractEntity.ParentContractGuid == null)
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  Contract No:{1} </br> Project No:{2} </br> Contract Title:{3} </br> File Name:{4}", "Employee Billing Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
                else
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", "Employee Billing Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
            }
            else if (keys.Equals(ResourceType.WorkBreakDownStructure.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Work BreakDown Structure File");

                if (contractEntity.ParentContractGuid == Guid.Empty || contractEntity.ParentContractGuid == null)
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  Contract No:{1} </br> Project No:{2} </br> Contract Title:{3} </br> File Name:{4}", "Work BreakDown Structure", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
                else
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", "Work BreakDown Structure", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
            }
            else if (keys.Equals(ResourceType.LaborCategoryRates.ToString()))
            {
                var contractEntity = _contractsService.GetContractEntityByContractId(file.ResourceGuid);
                additionalInformation = string.Format("{0} {1} the {2}", User.FindFirst("fullName").Value, type, "Labor Category Rates File");

                if (contractEntity.ParentContractGuid == Guid.Empty || contractEntity.ParentContractGuid == null)
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Contract/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  Contract No:{1} </br> Project No:{2} </br> Contract Title:{3} </br> File Name:{4}", "Labor Category Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
                else
                {
                    additionalInformationURl = _configuration.GetSection("SiteUrl").Value + ("/Project/Details/" + contractEntity.ContractGuid);
                    resource = string.Format("{0} </br>  TaskOrder No:{1} </br> Project No:{2} </br> TaskOrder Title:{3} </br> File Name:{4}", "Labor Category Rates", contractEntity.ContractNumber, contractEntity.ProjectNumber, contractEntity.ContractTitle, file.UploadFileName);
                }
            }

            AuditLogHandler.InfoLog(_logger, User.FindFirst("fullName").Value, UserHelper.CurrentUserGuid(HttpContext), file, resource, file.ContractResourceFileGuid, UserHelper.GetHostedIp(HttpContext), "File " + type, Guid.Empty, "Successful", "", additionalInformation, additionalInformationURl);
        }