Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.54 KB | None | 0 0
  1.     public partial class FrmMain : Form
  2.     {
  3.         private BatchProcessor batchProcessor;
  4.         private BatchManager batchManager;
  5.  
  6.         public FrmMain()
  7.         {
  8.             InitializeComponent();
  9.         }
  10.  
  11.         private void BatchPolling()
  12.         {
  13.             // ...
  14.         }
  15.  
  16.         private void UpdateUI()
  17.         {
  18.             // ... Do custom stuff here ...
  19.         }
  20.  
  21.         private void FrmMain_Load(object sender, EventArgs e)
  22.         {
  23.             try
  24.             {
  25.                 batchProcessor = new BatchProcessor();
  26.                 batchManager = new BatchManager(batchProcessor.CustomModuleId);
  27.  
  28.                 batchManager.LoginToRuntimeSession();
  29.  
  30.                 timerBatchPolling.Enabled = true;
  31.             }
  32.             catch (Exception exception)
  33.             {
  34.                 throw exception;
  35.             }
  36.         }
  37.  
  38.         private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
  39.         {
  40.             timerBatchPolling.Enabled = false;
  41.  
  42.             try
  43.             {
  44.                 // ...
  45.             }
  46.             catch (Exception exception)
  47.             {
  48.                 throw exception;
  49.             }
  50.         }
  51.  
  52.         private void timerBatchPolling_Tick(object sender, EventArgs e)
  53.         {
  54.             BatchPolling();
  55.             UpdateUI();
  56.         }
  57.     }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.     internal class BatchProcessor
  70.     {
  71.         private const string CUSTOM_MODULE_ID = "StampOnScanProcess";
  72.         private const string BATCH = "Batch";
  73.         private const string DOCUMENTS = "Documents";
  74.         private const string DOCUMENT = "Document";
  75.         private const string PDF_GENERATION_FILE_NAME = "PDFGenerationFileName";
  76.  
  77.         public string CustomModuleId { get { return CUSTOM_MODULE_ID; } }
  78.  
  79.         public void Process(IBatch batch)
  80.         {
  81.             IACDataElement rootElement = batch.ExtractRuntimeACDataElement(0);
  82.             IACDataElement batchElement = rootElement.FindChildElementByName(BATCH);
  83.  
  84.             IACDataElementCollection currentDocuments = batchElement.FindChildElementByName(DOCUMENTS).FindChildElementsByName(DOCUMENT);
  85.  
  86.             for (int i = 0; i < currentDocuments.Count; i++)
  87.             {
  88.                 int currentPageIndex = i + 1;
  89.                 IACDataElement currentDocument = currentDocuments[currentPageIndex];
  90.                 string documentFilePath = currentDocument[PDF_GENERATION_FILE_NAME];
  91.  
  92.                 // !!! Manipulate the PDF file here !!!
  93.             }
  94.         }
  95.     }
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.     internal class BatchManager
  110.     {
  111.         private Login currentSession;
  112.  
  113.         public BatchManager(string customModuleId)
  114.         {
  115.             // ...
  116.         }
  117.  
  118.         public void LoginToRuntimeSession()
  119.         {
  120.             if (currentSession == null)
  121.             {
  122.                 currentSession = new Login();
  123.                 string applicationName = Application.ExecutablePath;
  124.                 // strPathName = Right(strPathName, 12);
  125.                 // strPathName = Left(strPathName, 8);
  126.  
  127.                 currentSession.Login();
  128.                 currentSession.ApplicationName = applicationName;
  129.             }
  130.  
  131.             // currentSession.ValidateUser(/* UniqueID */);
  132.  
  133.             IRuntimeSession runtimeSession = null; // DirectCast(currentSession.RuntimeSession, RuntimeSession);
  134.  
  135.             runtimeSession.BatchAvailable += RuntimeSession_BatchAvailable;
  136.         }
  137.  
  138.         private void RuntimeSession_BatchAvailable()
  139.         {
  140.             // ...
  141.         }
  142.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement