none
Extended Flat File Disassembler - IPersistPropertyBag.Load problem. RRS feed

  • Question

  • I have successfully extended the Flat File Disassembler which takes a large file and breaks it down into batches.

    I want to be able to configure the number of entries in a batch. What I assumed is that it could be done via the IPersistPropertyBag.Load which would result in a new "Property" after I had dropped it into "Dissassemble" area of the Pipeline Component.

    This is my original code.

           void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog)
            {
                object valBatchSize = String.Empty;
                base.Load(propertyBag, errorLog);
               
                try
                {
                    propertyBag.Read("BatchSize", out valBatchSize, 0);
                }
                catch (ArgumentException argEx)
                {
                    throw new ApplicationException("Error ArgumentException: " + argEx.Message);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Error reading propertybag: " + ex.Message);
                }

                if (valBatchSize != null)
                    batchSize = (int)valBatchSize;
                else
                    batchSize = 1000;
            }
            void IPersistPropertyBag.Save
             (IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
            {
                object valBatchSize = (object)batchSize;
                propertyBag.Write("BatchSize", ref valBatchSize);
                base.Save(propertyBag, clearDirty, saveAllProperties);
            }

    This generated an error When I did the drag and drop I had an error

    "pipeline component load() method failed on IPersisPropertyBag implementation".

    This I have tracked down to ArgumentException being raised, I assume because "BatchSize" does not exist in the property bag. So I have commented out the "throw new" and I no longer get the error on the drag and drop.

            void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog)
            {
                object valBatchSize = String.Empty;
                base.Load(propertyBag, errorLog);
               
                try
                {
                    propertyBag.Read("BatchSize", out valBatchSize, 0);
                }
                catch (ArgumentException argEx)
                {
    //                throw new ApplicationException("Error ArgumentException: " + argEx.Message);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Error reading propertybag: " + ex.Message);
                }

                if (valBatchSize != null)
                    batchSize = (int)valBatchSize;
                else
                    batchSize = 1000;
            }

    However - "BatchSize" still is not appearing as a property. How can I get "BatchSize" implemented as a property that I can configure?

    Thanks

    Wednesday, July 22, 2015 11:41 AM

Answers

  • Hi,

    Please ensure you have implemented members of IPersistpropertyBag as below:

    private int _BatchSize;
            public int BatchSize
            {
                get { return _BatchSize; }
                set { _BatchSize = value; }
            }
     
            public void GetClassID(out Guid classID)
            {
              
    classID = new Guid("ACC3F15A-C389-4a5d-8F8E-2A951CDC4C19");
            }
           
            public void InitNew()
            {
     
            }
           
     
       public void Load(IPropertyBag propertyBag, int errorLog)
            {
                object val = null;
                try
                {
                    propertyBag.Read("BatchSize", out val, 0);
                }
                catch (Exception ex)
                {
    throw new ApplicationException("Error reading propertybag: " + ex.Message);
                }
     
                if (val != null)
                    _BatchSize = (int)val;
                else
                    _BatchSize = 1;
     
            }
     
          public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
            {
                object val = (object)BatchSize;
                propertyBag.Write("BatchSize", ref val);
            }    

    You will find that you can set value of "BatchSize" property at pipeline design time.

    Refer: http://blogs.msdn.com/b/brajens/archive/2006/12/03/how-to-develop-biztalk-custom-pipeline-components-part2.aspx


    Please mark as answer or vote as helpful if my reply does

    • Marked as answer by TreforE Wednesday, July 22, 2015 2:56 PM
    Wednesday, July 22, 2015 12:06 PM
    Moderator
  • This like this are usually pretty easy to debug.

    1. Attach Visual Studio to either another instance of Visual Studio or BizTalk Administrator.
    2. Open the Pipeline Component, either in the Pipeline Designer or Port.
    3. It should break in the error.  You can then debug just like any other .Net implementation.
    • Marked as answer by TreforE Wednesday, July 22, 2015 2:57 PM
    Wednesday, July 22, 2015 2:09 PM
    Moderator

All replies

  • Hi,

    Please ensure you have implemented members of IPersistpropertyBag as below:

    private int _BatchSize;
            public int BatchSize
            {
                get { return _BatchSize; }
                set { _BatchSize = value; }
            }
     
            public void GetClassID(out Guid classID)
            {
              
    classID = new Guid("ACC3F15A-C389-4a5d-8F8E-2A951CDC4C19");
            }
           
            public void InitNew()
            {
     
            }
           
     
       public void Load(IPropertyBag propertyBag, int errorLog)
            {
                object val = null;
                try
                {
                    propertyBag.Read("BatchSize", out val, 0);
                }
                catch (Exception ex)
                {
    throw new ApplicationException("Error reading propertybag: " + ex.Message);
                }
     
                if (val != null)
                    _BatchSize = (int)val;
                else
                    _BatchSize = 1;
     
            }
     
          public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
            {
                object val = (object)BatchSize;
                propertyBag.Write("BatchSize", ref val);
            }    

    You will find that you can set value of "BatchSize" property at pipeline design time.

    Refer: http://blogs.msdn.com/b/brajens/archive/2006/12/03/how-to-develop-biztalk-custom-pipeline-components-part2.aspx


    Please mark as answer or vote as helpful if my reply does

    • Marked as answer by TreforE Wednesday, July 22, 2015 2:56 PM
    Wednesday, July 22, 2015 12:06 PM
    Moderator
  • This like this are usually pretty easy to debug.

    1. Attach Visual Studio to either another instance of Visual Studio or BizTalk Administrator.
    2. Open the Pipeline Component, either in the Pipeline Designer or Port.
    3. It should break in the error.  You can then debug just like any other .Net implementation.
    • Marked as answer by TreforE Wednesday, July 22, 2015 2:57 PM
    Wednesday, July 22, 2015 2:09 PM
    Moderator
  • Yes - Brilliant - That fixed it .  Thank you.....
    Wednesday, July 22, 2015 2:56 PM