コード例 #1
0
        /// <summary>
        /// Uploads a unique (GUID appended) copy of the file to JetAdvantage
        /// Will throw an exception if the file is not confirmed at destination
        /// </summary>
        private void UploadUniqueFile(FileInfo fileInfo, PluginExecutionData data)
        {
            JetAdvantageUploadLog log = new JetAdvantageUploadLog(data);

            TitanAPI  titanApi = new TitanAPI(_jetAdvantageProxy, _jetAdvantageURL);
            TitanUser user     = new TitanUser(_activityData.LoginId, _activityData.LoginPassword);

            UniqueFile uniqueFile = UniqueFile.Create(fileInfo);

            UpdateStatus(string.Format("Created file {0}", uniqueFile.FullName));

            FileInfo fi = uniqueFile.FileInfo;

            DateTime jobStart = DateTime.Now;

            log.CompletionStatus  = "Starting";
            log.DestinationUrl    = _jetAdvantageProxy;
            log.FileName          = uniqueFile.FullName;
            log.FileSentDateTime  = jobStart;
            log.FileSizeSentBytes = fi.Length;
            log.FileType          = fi.Extension;
            log.LoginId           = user.EmailAddress;

            ExecutionServices.DataLogger.Submit(log);
            //bool success = titanApi.CheckJetAdvantageAvailability(_jetAdvantageURL, _jetAdvantageProxy);
            // test that the server is available by trying to access the destination
            var existingDocs = titanApi.GetPrintQueue(user);

            UpdateStatus(string.Format("Verified that we can access JetAdvantage servers {0}, {1}", _jetAdvantageProxy, _jetAdvantageURL));

            try
            {
                var      receivedDoc = titanApi.UploadDocument(user, uniqueFile);
                DateTime jobEnd      = DateTime.Now;

                UpdateStatus(string.Format("Uploaded file {0}", uniqueFile.FullName));

                log.CompletionStatus      = "Success";
                log.FileSizeReceivedBytes = receivedDoc.size;
                log.FileReceivedDateTime  = jobEnd;
                log.CompletionDateTime    = DateTime.Now;
                UpdateStatus("Submitting log info.");
                ExecutionServices.DataLogger.Update(log);
                UpdateStatus("After submitting log info.");
            }
            catch (Exception ex)
            {
                log.CompletionStatus   = "Failed";
                log.CompletionDateTime = System.DateTime.Now;

                ExecutionServices.DataLogger.Update(log);
                throw ex;
            }
        }
コード例 #2
0
ファイル: TitanApi.cs プロジェクト: ProjectAgri20/newrepo
 public List <TitanDocument> GetPrintQueue(TitanUser requestor)
 {
     try
     {
         return(GetPrintQueue(Login(requestor)));
     }
     catch (Exception)
     {
         throw CreateException("Unable to retrieve queued docs for " + requestor);
     }
 }
コード例 #3
0
ファイル: TitanApi.cs プロジェクト: ProjectAgri20/newrepo
        public string Login(TitanUser requestor)
        {
            string         result  = null;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(LoginUrl("X-Auth-Token"));

            //http://blog.kowalczyk.info/article/at3/Forcing-basic-http-authentication-for-HttpWebReq.html
            string authInfo = requestor.EmailAddress + ":" + requestor.Password;

            authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
            request.Headers.Add("Authorization", "Basic " + authInfo);
            request.Accept = "x-auth-token/header";
            request.Method = "GET";
            request.Headers.Add("Version", "1");
            request.Headers.Add("X-Client-Id", "482a16dc-a6a6-4e28-8ff5-cb050731d933");

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                result = response.Headers["X-Auth-Token"];
                if (String.IsNullOrEmpty(result))
                {
                    //This is only tested because
                    String cookie = response.Headers["Set-Cookie"];
                    if (cookie.StartsWith("X-Auth-Token="))
                    {
                        result = cookie.Substring(13);
                    }
                }
            }

            if (result == null)
            {
                throw CreateException("Failed to login the user " + requestor);
            }

            return(result);
        }
コード例 #4
0
ファイル: TitanApi.cs プロジェクト: ProjectAgri20/newrepo
 public string DeleteDocument(TitanUser requestor, TitanDocument document)
 {
     return(DeleteDocument(Login(requestor), document));
 }
コード例 #5
0
ファイル: TitanApi.cs プロジェクト: ProjectAgri20/newrepo
 public void DeleteDocuments(TitanUser requestor)
 {
     DeleteDocuments(Login(requestor));
 }
コード例 #6
0
ファイル: TitanApi.cs プロジェクト: ProjectAgri20/newrepo
 public TitanDocument UploadDocument(TitanUser requestor, FileInfo file)
 {
     return(UploadDocument(Login(requestor), file));
 }