コード例 #1
0
 private void Process(VaultedDocs unPostedVaultedDoc)
 {
     Log.Info(String.Format("############ Processing the Vaulted Doc {0} #############", unPostedVaultedDoc.ToString()));
     //Validate record if required
     try
     {
         if (unPostedVaultedDoc != null)
         {
             //Get BLOB
             Log.Info("Capturing the file stream from blob");
             DbContext.Instance().VaultedDocsRepository.CaptureVaultedDocsBlob(unPostedVaultedDoc);
             Log.Info("Captured the file stream from blob");
             //Upload              
             string responseURL= Upload(unPostedVaultedDoc);
             //Update the status
             Log.Info("Updating the vaulted_doc's processed status to Y");
             Log.Info("Updating the vaulted_doc's VAULT_GUID to " + responseURL);
             DbContext.Instance().VaultedDocsRepository.Update(unPostedVaultedDoc, responseURL);
             Log.Info("Updated the vaulted_doc's processed status to Y");
             Log.Info("Updated the vaulted_doc's VAULT_GUID to " + responseURL);
         }
     }
     catch (Exception ex)
     {
         //TODO:may be we need to stop here for fixed iterations and then send mail... other wise it will be in loop .               
         Log.Error("Failed to process the Vaulted doc uplaoding ." + ex.Message);
     }    
 }
コード例 #2
0
 private string Upload(VaultedDocs unPostedVaultedDoc)
 {
     Log.Info("Uploading the document to vault doc service");
     string response= ServiceContext.Instance().VaultSvcAccessor.UploadDocument(String.Empty, unPostedVaultedDoc.RqmtDocTypeDocTypeCode,unPostedVaultedDoc.TRDSYSTICKET,
                                      unPostedVaultedDoc.TRDSYSCODE, unPostedVaultedDoc.VaultedDocsBlobImageFileExt,unPostedVaultedDoc.VaultedDocsBlobDocBlob);
     string respURL = "";
     if (!String.IsNullOrEmpty(response))
     {
         Log.Info("Document uploaded successfully at -- " + response);
         string[] respArr = response.Split(':');
         if (respArr != null && respArr.Count() > 0)
             respURL = respArr[respArr.Count() - 1];
         if (respURL.Length > 50)
             respURL = respURL.Substring(0, 50);
     }
     else
     {
         Log.Info("Document uploaded failed");
     }
     return respURL;
 }
コード例 #3
0
       public void CaptureVaultedDocsBlob(VaultedDocs vaultedDoc)
       {
          string sql = String.Format("SELECT ID,DOC_BLOB.PathName(),GET_FILESTREAM_TRANSACTION_CONTEXT() FROM {0}VAULTED_DOCS_BLOB{1} WHERE ID={2}"
              , DbContext.SCHEMA_NAME, DbContext.NO_LOCK,vaultedDoc.VaultedDocsBlobId);         
            using (TransactionScope ts = new TransactionScope())
            {
                using (SqlConnection conn = new SqlConnection(_connectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {                    
                        using (SqlDataReader dataReader = cmd.ExecuteReader())
                        {

                            if (dataReader.HasRows)
                            {
                                while (dataReader.Read())
                                {
                                    using (SqlFileStream sqlFileStr = new SqlFileStream(dataReader.GetSqlString(1).Value, dataReader.GetSqlBinary(2).Value, FileAccess.Read))
                                    {
                                        using (MemoryStream memStream = new MemoryStream())
                                        {
                                            sqlFileStr.CopyTo(memStream);
                                            vaultedDoc.VaultedDocsBlobDocBlob = memStream.ToArray();
                                        }
                                        sqlFileStr.Close();
                                    }                                    
                                }
                            }
                        }
                    }
                }
                ts.Complete();
            }                  
       }
コード例 #4
0
       public int Update(VaultedDocs vaultedDocs, string URL)
       {
           Int32 rowsUpdated = 0;
           string sql = "UPDATE " + DbContext.SCHEMA_NAME + "VAULTED_DOCS " +
               " SET PROCESSED_FLAG = @PROCESSED_FLAG ,PROCESSED_TIMESTAMP= @PROCESSED_TIMESTAMP ,VAULT_GUID = @VAULT_GUID" +
               " WHERE ID = @ID";

           using (SqlConnection conn = new SqlConnection(_connectionString))
           {
               using (SqlCommand cmd = new SqlCommand(sql, conn))
               {
                   cmd.CommandType = System.Data.CommandType.Text;
                   cmd.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = vaultedDocs.VaultedDocsId;
                   cmd.Parameters.Add("@PROCESSED_FLAG", System.Data.SqlDbType.VarChar).Value = "Y";
                   cmd.Parameters.Add("@PROCESSED_TIMESTAMP", System.Data.SqlDbType.DateTime2).Value = DateTime.Now;//the service runs on GMT ..
                   cmd.Parameters.Add("@VAULT_GUID", System.Data.SqlDbType.VarChar).Value = URL;

                   conn.Open();
                   rowsUpdated = cmd.ExecuteNonQuery();
               }
           }
           return rowsUpdated;
       }