public void EndFileTransfer(long submittedJobInfoId, FileTransferMethodExt usedTransferMethod, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser        = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IFileTransferLogic fileTransferLogic = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork);
             fileTransferLogic.EndFileTransfer(submittedJobInfoId, FileTransferConverts.ConvertFileTransferMethodExtToIn(usedTransferMethod), loggedUser);
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
     }
 }
示例#2
0
 public DataTransferMethodExt GetDataTransferMethod(string nodeIPAddress, int nodePort, long submittedTaskInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser         = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IDataTransferLogic dataTransferLogic  = LogicFactory.GetLogicFactory().CreateDataTransferLogic(unitOfWork);
             DataTransferMethod dataTransferMethod = dataTransferLogic.GetDataTransferMethod(nodeIPAddress, nodePort, submittedTaskInfoId, loggedUser);
             return(dataTransferMethod.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(default);
示例#3
0
 public void DeleteJob(long submittedJobInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser         loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IJobManagementLogic jobLogic   = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork);
             jobLogic.DeleteJob(submittedJobInfoId, loggedUser);
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
     }
 }
 public byte[] DownloadFileFromCluster(long submittedJobInfoId, string relativeFilePath, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser        = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IFileTransferLogic fileTransferLogic = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork);
             return(fileTransferLogic.DownloadFileFromCluster(submittedJobInfoId, relativeFilePath, loggedUser));
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public IEnumerable <AdaptorUserGroupExt> ListAdaptorUserGroups(string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser        = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Maintainer);
             IJobReportingLogic jobReportingLogic = LogicFactory.GetLogicFactory().CreateJobReportingLogic(unitOfWork);
             return(jobReportingLogic.ListAdaptorUserGroups().Select(s => s.ConvertIntToExt()));
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public SubmittedJobInfoUsageReportExt GetResourceUsageReportForJob(long jobId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser        = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Reporter);
             IJobReportingLogic jobReportingLogic = LogicFactory.GetLogicFactory().CreateJobReportingLogic(unitOfWork);
             return(jobReportingLogic.GetResourceUsageReportForJob(jobId).ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public string RemoveCommandTemplate(long commandTemplateId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser      loggedUser      = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Administrator);
             IManagementLogic managementLogic = LogicFactory.GetLogicFactory().CreateManagementLogic(unitOfWork);
             managementLogic.RemoveCommandTemplate(commandTemplateId);
             return($"CommandTemplate with id {commandTemplateId} has been removed.");
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
示例#8
0
 public SubmittedJobInfoExt SubmitJob(long createdJobInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser         loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IJobManagementLogic jobLogic   = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork);
             SubmittedJobInfo    jobInfo    = jobLogic.SubmitJob(createdJobInfoId, loggedUser);
             return(jobInfo.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
示例#9
0
 public IEnumerable <string> GetAllocatedNodesIPs(long submittedTaskInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser         loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IJobManagementLogic jobLogic   = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork);
             var nodesIPs = jobLogic.GetAllocatedNodesIPs(submittedTaskInfoId, loggedUser);
             return(nodesIPs.ToArray());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
示例#10
0
 public SubmittedJobInfoExt[] ListJobsForCurrentUser(string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser         loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IJobManagementLogic jobLogic   = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork);
             var jobInfos = jobLogic.GetJobsForUser(loggedUser);
             return(jobInfos.Select(s => s.ConvertIntToExt()).ToArray());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public ClusterNodeUsageExt GetCurrentClusterNodeUsage(long clusterNodeId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Reporter);
             IClusterInformationLogic clusterLogic = LogicFactory.GetLogicFactory().CreateClusterInformationLogic(unitOfWork);
             ClusterNodeUsage         nodeUsage    = clusterLogic.GetCurrentClusterNodeUsage(clusterNodeId, loggedUser);
             return(nodeUsage.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public FileInformationExt[] ListChangedFilesForJob(long submittedJobInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser                   loggedUser        = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IFileTransferLogic            fileTransferLogic = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork);
             ICollection <FileInformation> result            = fileTransferLogic.ListChangedFilesForJob(submittedJobInfoId, loggedUser);
             return(result?.Select(s => s.ConvertIntToExt()).ToArray());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public FileTransferMethodExt GetFileTransferMethod(long submittedJobInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser         = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IFileTransferLogic fileTransferLogic  = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork);
             FileTransferMethod fileTransferMethod = fileTransferLogic.GetFileTransferMethod(submittedJobInfoId, loggedUser);
             return(fileTransferMethod.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
示例#14
0
 public SubmittedJobInfoExt CreateJob(JobSpecificationExt specification, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser         loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IJobManagementLogic jobLogic   = LogicFactory.GetLogicFactory().CreateJobManagementLogic(unitOfWork);
             JobSpecification    js         = specification.ConvertExtToInt();
             SubmittedJobInfo    jobInfo    = jobLogic.CreateJob(js, loggedUser, specification.IsExtraLong.Value);
             return(jobInfo.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
 public JobFileContentExt[] DownloadPartsOfJobFilesFromCluster(long submittedJobInfoId, TaskFileOffsetExt[] taskFileOffsets, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser            loggedUser          = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IFileTransferLogic     fileTransferLogic   = LogicFactory.GetLogicFactory().CreateFileTransferLogic(unitOfWork);
             IList <JobFileContent> downloadedFileParts = fileTransferLogic.DownloadPartsOfJobFilesFromCluster(
                 submittedJobInfoId,
                 (from taskFileOffset in (new List <TaskFileOffsetExt>(taskFileOffsets).ToList()) select FileTransferConverts.ConvertTaskFileOffsetExtToIn(taskFileOffset)).ToArray(),
                 loggedUser);
             return((from fileContent in downloadedFileParts select FileTransferConverts.ConvertJobFileContentToExt(fileContent)).ToArray());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(null);
     }
 }
        public UserResourceUsageReportExt GetUserResourceUsageReport(long userId, DateTime startTime, DateTime endTime, string sessionCode)
        {
            try
            {
                using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
                {
                    AdaptorUser loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
                    if (loggedUser.Id != userId)
                    {
                        throw new NotAllowedException("Logged user is not allowed to request this report.");
                    }

                    IJobReportingLogic jobReportingLogic = LogicFactory.GetLogicFactory().CreateJobReportingLogic(unitOfWork);
                    return(jobReportingLogic.GetUserResourceUsageReport(userId, startTime, endTime).ConvertIntToExt());
                }
            }
            catch (Exception exc)
            {
                ExceptionHandler.ThrowProperExternalException(exc);
                return(null);
            }
        }
示例#17
0
        public CommandTemplateExt ModifyCommandTemplate(long commandTemplateId, string name, string description, string code, string executableFile, string preparationScript, string sessionCode)
        {
            try
            {
                using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
                {
                    AdaptorUser      loggedUser      = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Administrator);
                    IManagementLogic managementLogic = LogicFactory.GetLogicFactory().CreateManagementLogic(unitOfWork);
                    CommandTemplate  commandTemplate = managementLogic.ModifyCommandTemplate(commandTemplateId, name, description, code, executableFile, preparationScript);
                    return(commandTemplate.ConvertIntToExt());
                }
            }
            catch (Exception exc)
            {
                if (exc.Message.Contains("No such file or directory"))
                {
                    ExceptionHandler.ThrowProperExternalException(new InputValidationException(exc.Message));
                }

                ExceptionHandler.ThrowProperExternalException(exc);
                return(null);
            }
        }
        public IEnumerable <string> GetCommandTemplateParametersName(long commandTemplateId, string userScriptPath, string sessionCode)
        {
            try
            {
                using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
                {
                    AdaptorUser loggedUser = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
                    IClusterInformationLogic clusterLogic = LogicFactory.GetLogicFactory().CreateClusterInformationLogic(unitOfWork);
                    return(clusterLogic.GetCommandTemplateParametersName(commandTemplateId, userScriptPath, loggedUser));
                }
            }

            catch (Exception exc)
            {
                //TODO Should be rewrite!
                if (exc.Message.Contains("No such file or directory") || exc.Message.Contains("Is a directory"))
                {
                    ExceptionHandler.ThrowProperExternalException(new InputValidationException(exc.Message));
                }

                ExceptionHandler.ThrowProperExternalException(exc);
                return(null);
            }
        }