public JobInformation BuildJob(string accountName, JobInformation jobToBuild)
 {
     return
         _jobClient.Job.Build(accountName, jobToBuild);
 }
        public override void ExecuteCmdlet()
        {
            // error handling for not passing or passing both script and script path
            if ((string.IsNullOrEmpty(Script) && string.IsNullOrEmpty(ScriptPath)) ||
                (!string.IsNullOrEmpty(Script) && !string.IsNullOrEmpty(ScriptPath)))
            {
                throw new CloudException(Resources.AmbiguousScriptParameter);
            }

            // get the script
            if (string.IsNullOrEmpty(Script))
            {
                var powerShellDestinationPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(ScriptPath);
                if (!File.Exists(powerShellDestinationPath))
                {
                    throw new CloudException(string.Format(Resources.ScriptFilePathDoesNotExist,
                        powerShellDestinationPath));
                }

                Script = File.ReadAllText(powerShellDestinationPath);
            }

            JobType jobType;
            JobProperties properties;
            if (USql)
            {
                jobType = JobType.USql;
                var sqlIpProperties = new USqlJobProperties
                {
                    Script = Script
                };

                if (!string.IsNullOrEmpty(CompileMode))
                {
                    CompileMode toUse;
                    if (Enum.TryParse(CompileMode, out toUse))
                    {
                        sqlIpProperties.CompileMode = toUse;
                    }
                }

                if (!string.IsNullOrEmpty(Runtime))
                {
                    sqlIpProperties.RuntimeVersion = Runtime;
                }

                properties = sqlIpProperties;
            }
            else if (Hive)
            {
                jobType = JobType.Hive;
                properties = new HiveJobProperties
                {
                    Script = Script
                };
            }
            else
            {
                throw new CloudException(Resources.InvalidJobType);
            }

            var jobInfo = new JobInformation
            {
                JobId = DataLakeAnalyticsClient.JobIdQueue.Count == 0 ? Guid.NewGuid() : DataLakeAnalyticsClient.JobIdQueue.Dequeue(),
                Name = Name,
                Properties = properties,
                Type = jobType,
                DegreeOfParallelism = DegreeOfParallelism,
                Priority = Priority
            };

            WriteObject(CompileOnly
                ? DataLakeAnalyticsClient.BuildJob(Account, jobInfo)
                : DataLakeAnalyticsClient.SubmitJob(Account, jobInfo));
        }
 public JobInformation SubmitJob(string accountName, JobInformation jobToSubmit)
 {
     return
         _jobClient.Job.Create(accountName, jobToSubmit.JobId.GetValueOrDefault(),
             jobToSubmit);
 }
 public JobInformation SubmitJob(string accountName, JobInformation jobToSubmit)
 {
     return
         _jobClient.Job.Create(jobToSubmit.JobId,
             jobToSubmit, accountName);
 }