private void btnInstanceDelete_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Manually export collection 00000001 first through the controller, before proceeding");

            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Gets the collection "00000001"

            ITisCollectionData collData = b.Get("00000001");

            // Deletes the collection
            // even if it is locked
            b.Delete(collData);

            MessageBox.Show("collection 00000001 is gone");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceFromDynamic_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Imports the collections present within the dynamic: "c:\temp\test.dynamic".

            ITisCollectionData[] collDatas = b.FromDynamic(@"c:\temp\test.dynamic");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceFree_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Gets the collection "00000001"

            ITisCollectionData collData = b.Get("00000001");

            // Put the collection (writes it back)
            // to the CSM and keeps it in the same
            // queue
            b.Free(collData);

            MessageBox.Show("Collection: " + collData.Name + " is still in the same queue");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceToDynamic_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Exports the collections "000002349_0001" and "000002349_0002"
            // to the dynamic: "c:\temp\test.dynamic" file.

            b.ToDynamic(@"c:\temp\Dync2and3.dynamic", new string[] { "00000002",
                "00000002" });

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceRelease_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Release the collection "00000002"
            b.Hold("00000002");

            MessageBox.Show("Collection 00000002 on Hold - refresh the Controller");

            // Release the collection "00000002"
            b.Release("00000002");

            MessageBox.Show("Collection 00000002 released - refresh the Controller");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceReleaseMany_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Holds the collections "00000002" and "00000003"

            b.HoldMany(new string[] { "00000002", "00000003" });
            MessageBox.Show("Collections 00000002 and 00000003 on Hold - refresh the Controller");

            // Releases the collections "00000002" and "00000003"

            b.ReleaseMany(new string[] { "00000002", "00000003" });
            MessageBox.Show("Collections 00000002 and 00000003 released - refresh the Controller");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceReject_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Gets the collection "00000001"

            ITisCollectionData collData = b.Get("00000001");

            // Reject the collection
            b.Reject(collData);

            MessageBox.Show("collection 00000001 is in Reject, please refresh the controller and drag it back");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstancePut_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Gets the collection "00000001"

            ITisCollectionData collData = b.Get("00000001");

            // Put the collection (writes it back)
            // to the CSM and moves it to the next
            // queue
            b.Put(collData);

            MessageBox.Show("Collection: " + collData.Name + " is now in the next queue (ManualId), please refresh the controller and drag it back");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstancePrioritize_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Sets the collection "00000002" to AboveNormal priority.

            b.Prioritize("00000002", Batch.Priority.AboveNormal);
            MessageBox.Show("Collection 00000002 AboveNormal priority - refresh the Controller");

            b.Prioritize("00000002", Batch.Priority.Normal);
            MessageBox.Show("Collection 00000002 Normal priority - refresh the Controller");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstancePrioritizeMany_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Prioritizes collections "00000002" and "00000003" with High priority

            b.PrioritizeMany(new string[] { "00000002", "00000003" }, Batch.Priority.High);
            MessageBox.Show("Collections 00000002 and 00000003 High priority - refresh the Controller");

            b.PrioritizeMany(new string[] { "00000002", "00000003" }, Batch.Priority.Normal);
            MessageBox.Show("Collections 00000002 and 00000003 Normal priority - refresh the Controller");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceMove_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Moves the collection "00000001" to
            // the "Export" station

            b.Move("00000001", "Export");
            MessageBox.Show("Collection 00000001 moved to Export  - refresh the Controller. Please, manually drag it back to FormId");

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }
        private void btnInstanceLogout_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Do something here...
            MessageBox.Show("AppName is: " + b.ApplicationName);

            // Logs out fromn the CSM
            b.Logout();

            // Dispose the batch instance
            // and disconnect from the CSM
            // The Dispose() will not
            // log out from the CSM if the
            // Logout() has been called

            // If Logout() has not been called
            // then Dispose() will perform
            // the log out.

            // In any case Dispose() should always
            // be called.

            b.Dispose();
        }
        private void btnInstanceHistory_Click(object sender, EventArgs e)
        {
            // Create a new Batch instance
            // Logs onto the CSM with "AdvancedDemo" application
            // and "FormId" station

            Batch b = new Batch("AdvancedDemo", "FormId");

            // Gets the collection "00000001"

            ITisCollectionData collData = b.Get("00000001");

            // Gets the history for collData

            string[] h = b.History(collData);

            MessageBox.Show("History for " + collData.Name + " is: " + String.Join("->", h));

            // Dispose the batch instance
            // and disconnect from the CSM

            b.Dispose();
        }