upgrading the synology DS 107 firmware to 4.2

synology DS107 latest official firmware is (and should officially remain) 3.1 ( DSM_DS107_1613.pat )

But..
you can upgrade it to 4.2 firmware!

how to ?
1) connect to your diskstation web interface: (typically : http://diskstation:5000/webman/index.cgi)

2) activate TELNET/SSH in Control Panel/Network Services/Terminal

3) if you don’t have Putty (free Telnet Client), download it to access diskstation with telnet : http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

4) run putty.exe , and for host, write : diskstation, select telnet and click “Open”

puttytelnetsyno

then a console window should open:

type ‘root’ and then your diskstation usual password (the same as to connect on the web interface) then press ‘enter’ key

puttyconsole

note: the password will not show when you type

5) type

cd ..
cd etc.defaults

(press ‘enter’ key at the end of each line)

6)Edit the file synoinfo.conf. This can be done using the built in editor vi. Simply type:
vi synoinfo.conf

to start the editor.
Now… vi is not exactly the most typical editor so you might end up with some troubles here. A quick guide is:

  • The vi editor has a command mode, and and input mode.
  • You switch to input mode by pressing the i key.
  • When you are in input mode everything you type is inserted as normal into the document.
  • You go back into the command mode by pressing escape.
  • The cursor keys navigate the document.
  • The x key will delete characters under the cursor when you are in command mode.

You need to change the first line from:

unique="synology_powerpc_107"

into

unique="synology_powerpc_109j"

Now, to save the file, make sure you are in command mode (Press escape if in doubt.) and type:

:wq

This tells vi to write and quit. If you messed something up just type:

:q!
and the editor will quit without saving. Then start over by typing vi synoinfo.conf again. (Usually you can just press the cursor up key, and then enter, to reissue the command.)If you need more help with vi it might be helpful to read the Mastering the vi editor guide.

7) Now you can exit the telnet session again if you want. Just type exit and the connection will close.

8) DON’T REBOOT YOUR SYNOLOGY NOW! (or you will have to reinstall the old DS-107 firmware with this assistant)
Now your Synology device will think its a DS109J model. This enables you to download the firmware for the DS-109j and apply it using the web interface just as usual. The firmware can be downloaded from Synology download site

You will first have to install firwmare 3.2 ; the updgrade file is called DSM_DS109j_1955.pat (link : http://ukdl.synology.com/download/DiskStation/DSM3.2/1955/DSM_DS109j_1955.pat)
then you will have to install firmware 4.0 ; the updgrade file is called DSM_DS109j_2228.pat (link : http://ukdl.synology.com/download/DiskStation/DSM4.0/2228/DSM_DS109j_2228.pat)
then you can install 4.2 : link : http://ukdl.synology.com/download/DiskStation/DSM4.2/3211/DSM_DS109j_3211.pat

To install these firmwares, don’t use synology assistant, but use synology web interface (in Control Panel /DSM update) with Manual update

If you install latest DSM version (4.2 beta) : don’t forget to update audio,download station, itunes server and other packages packages in web interface (beta channel update) after installation:

synoupdatepkg

———— DONE :)
synoupgrade
note : you synology is now like a DS109j

this trick may work with few modification on other x-07 – and maybe other – synology diskstation but you’ll have to check which processor you have inside your syno:

http://xpenology.com/forum/viewtopic.php?f=2&t=538

other useful link:

http://www.timo.dk/wp/2011/08/07/upgrading-the-synology-106e-firmware-to-to-3-1/

http://www.robvanhamersveld.nl/2013/01/21/install-and-test-synology-dsm-in-a-virtual-machine/

Master Data Services Excel Add-in Query updater

Hi

This small tool allows you to Load, Edit, and save MDS queries with operators that are not available in current mds add-in
232951
you can download the source code (.Net C# 4.0 Client Profile, VS2010) of my tool here (FREE) HERE
OR
binary only: HERE

very easy to use:

Load your already generated query

then choose a new Operator and edit the criteria

and then save the updated query

you can use all these operators:
[Description("")] NotSpecified,
[Description("=")] IsEqual,
[Description("<>")] IsNotEqual,
[Description("LIKE")] Like,
[Description("NOT LIKE")] NotLike,
[Description(">")] GreaterThan,
[Description("< ")] LessThan, [Description(">=")] GreaterThanOrEqual,
[Description("< =")] LessThanOrEqual,
[Description("MATCH")] Matches,
[Description("NOT MATCH")] NotMatches,
[Description("REGEX")] ContainsPattern,
[Description("NOT REGEX")] NotContainsPattern,
[Description("IS NULL")] IsNull,
[Description("IS NOT NULL")] IsNotNull,
[Description("IN")] In,
[Description("NOT IN")] NotIn,
[Description("DIRECT DECENDANTS")] DirectDecendants,
[Description("ALL DECENDANTS")] AllDecendants,

More info on sql mds 2012 MSDN blog

NWZ-E463/E463HK/E463K/E464/E464K/E465 sony walkman sound unlocking

Hello

here is a new post about these models:

How to use the destination setting tool
Note 1: Please use this tool after closing other application software.

Model : NWZ-E463/E464/E465

Destination setting (DEST)
The destination setting, language information, and sound pressure
regulation information are written in the NAND fl ash memory.

Note: Not used for the servicing.

Nevertheless, you can try the testmode with the service manual here:

(I will NOT be liable to you for any damages, including without limitation, direct, indirect, special, incidental, punitive, or consequential damages that may occurs to your product)

Master Data Services : Display entity members with good sort order when code is numeric

a MDS user recently asked me this question:

When looking at entity contents via web UI in the column code, 10 and each code that starts with 1 (10,11..19) always goes before 2 and so on. Is there any way to fix it? I don’t believe that’s the right order.

example:

 

so I’ve started to investigate..

first (easy solution)

the easiest way is to add at least one zero before code “1″ and code  ”2″ and so on

but if your code size is huge, you will have to add a lot of “0″ behind your code

so I’ve tried to find a custom hack in MDS stored procedure: and finally I’ve found it :)

second (hard way) solution:

after a few search on google, I’ve found this post :

http://stackoverflow.com/questions/119730/how-do-i-sort-a-varchar-column-in-sql-server-that-contains-numbers

but I had to find where to place this code hack

after a few search on mds (by sorting entity members in Web UI and looking at SQL profiler)

i’ve found that a call was made to this stored procedure:

 

declare @p16 int
set @p16=NULL
declare @p17 mdm.MemberGetCriteria
exec mdm.udpEntityMembersGet @User_ID=1,@Version_ID=5,@Hierarchy_ID=NULL,@HierarchyType_ID=NULL,@ParentEntity_ID=NULL,@Entity_ID=336,@MemberType_ID=1,@ParentCode=default,@ColumnString=N'',@AttributeGroup_ID=NULL,@PageNumber=1,@PageSize=50,@SortColumn=N'Code',@SortDirection=N'ASC',@CountOnly=0,@MemberCount=@p16 output,@SearchTable=@p17
select  @p16declare @p16 int
set @p16=NULL
declare @p17 mdm.MemberGetCriteria

exec mdm.udpEntityMembersGet @User_ID=1,@Version_ID=5,@Hierarchy_ID=NULL,@HierarchyType_ID=NULL,@ParentEntity_ID=NULL,@Entity_ID=336,@MemberType_ID=1,@ParentCode=default,@ColumnString=N'',@AttributeGroup_ID=NULL,@PageNumber=1,@PageSize=50,@SortColumn=N'Code',@SortDirection=N'ASC',@CountOnly=0,@MemberCount=@p16 output,@SearchTable=@p17
select  @p16

after looking into udpEntityMembersGet, I’ve found that another stored procedure was called : mdm.udpMembersGet, a huge one!

so I’ve tried to update this SP code and finally it works!

be carefull, this hack could slow down the entitymembers get request, and it is only for testing purpose, and if you update MDS with cumulative update, it could be erased!

you just have to replace every instance of (there should be 3 of them) :

 

IF (@SortOrderColumnQuoted IS NOT NULL) BEGIN
SET @SQL += @SortOrderColumnQuoted + N' ' + @SortDirection + N', ';
  				END

by:

 

 IF (@SortOrderColumnQuoted IS NOT NULL) BEGIN  
                SET @SQL += N' CASE 
    WHEN ISNUMERIC('+@SortOrderColumnQuoted+') = 1 THEN CONVERT(INT, '+@SortOrderColumnQuoted+') 
    ELSE 9999999 -- or something huge
  END ' + N' ' + @SortDirection + N', ';  
            END

 result:

 

 right click here and ‘save as’ to download the customized stored procedure

 

Complete programmatic WCF service client wrapper in C#

Hi,the goal of this class was to avoid to use a app config file for the WCF object model

so as to not have to restart my application (MDSManager) when updating endpoint url

it is now done and you can update the endpoint on the fly!

 note: this post is based on Steve Wilkes’ article (see here)

 download the latest version of this class file (right click and ‘save as’ )

usage:

 using (ServiceClient c = new ServiceClientWrapper().CreateServiceClient())
                    {
}
Service Wrapper Code :
using System;
using System.Net;
using System.Net.Security;
using System.ServiceModel;
using Common.ServiceReference1;
using System.ServiceModel.Description;

namespace Common
{
    public class ServiceClientWrapper :
    ServiceClientWrapper<ServiceClient, ServiceReference1.IService>
    {
        public ServiceClientWrapper()
            : base()
        {
        }
    }

    public class ServiceClientWrapper<TClient, IService> : IDisposable
        where TClient : ClientBase
        where IService : class
    {
        public const int maxStringContentLength = 2147483647;
        private readonly string _domain;
        private readonly string _userName;
        private readonly string _password;
        private readonly Uri _uri;

        private TClient _serviceClient;

        public ServiceClientWrapper()
        {
            this._domain = Globals.Domain;
            this._userName = Globals.UserName;
            this._password = Globals.Password;
            this._uri = Globals.EndPointAddress;

        }

        public ServiceClientWrapper(string domain, string userName, string password, Uri uri)
        {
            this._domain = domain;
            this._userName = userName;
            this._password = password;
            this._uri = uri;
        }
      public TClient CreateServiceClient()
        {
            this.DisposeExistingServiceClientIfRequired();
            if (Globals.EndPointAddress != null)
            {
                //if (this._config.IgnoreSslErrors)
                //{
                ServicePointManager.ServerCertificateValidationCallback =
                    (obj, certificate, chain, errors) => true;
                //}
                //else
                //{
                //    ServicePointManager.ServerCertificateValidationCallback =
                //        (obj, certificate, chain, errors) => errors == SslPolicyErrors.None;
                //}

                //here we can specify the end point identity, so as to avoid security negocation errors
                EndpointIdentity epid = EndpointIdentity.CreateUpnIdentity("host\\localhost");

// update : programmatic binding
EndpointAddress epaddr = new EndpointAddress(new Uri(Globals.EndpointAddress), epid);
            this._serviceClient = (TClient)Activator.CreateInstance(
                typeof(TClient), new WSHttpBinding()
                {
                    MaxBufferPoolSize = maxStringContentLength,
                    MaxReceivedMessageSize = maxStringContentLength,
                    OpenTimeout = new TimeSpan(1, 0, 0),
                    ReceiveTimeout = new TimeSpan(1, 0, 0),
                    SendTimeout = new TimeSpan(1, 0, 0)
                },
                epaddr);
                //we specify here the windows client credentials
                if (!string.IsNullOrEmpty(Globals.EndPointName))
                    this._serviceClient.Endpoint.Name = Globals.EndPointName;

                if (!string.IsNullOrEmpty(Globals.Domain))
                    this._serviceClient.ClientCredentials.Windows.ClientCredential.Domain = Globals.Domain;
 //update to specify UserName and Password for other credentials than ClientCredentials.Windows
 if (!string.IsNullOrEmpty(Globals.UserName))
            {
                this._serviceClient.ClientCredentials.Windows.ClientCredential.UserName = Globals.UserName;
                this._serviceClient.ClientCredentials.UserName.UserName = (!string.IsNullOrWhiteSpace(Globals.Domain) ? Globals.Domain + "\\" + Globals.UserName : Globals.UserName);
            }
            if (!string.IsNullOrEmpty(Globals.Password))
            {
                this._serviceClient.ClientCredentials.Windows.ClientCredential.Password = Globals.Password;
                this._serviceClient.ClientCredentials.UserName.Password = Globals.Password;
            }
                //here we override the "MaxItemsInObjectGraph" property with max value :2147483647, so as to avoid buffer limit error
                var operations = _serviceClient.Endpoint.Contract.Operations;
                foreach (var operation in operations)
                {

                    operation.Behaviors.Find().MaxItemsInObjectGraph = maxStringContentLength;
                }
                _serviceClient.InnerChannel.OperationTimeout = new TimeSpan(1, 0, 0);

                return this._serviceClient;
            }
            return null;
        }
     public void Dispose()
        {
            this.DisposeExistingServiceClientIfRequired();
        }

private void DisposeExistingServiceClientIfRequired() { if (this._serviceClient != null) { try { if (this._serviceClient.State == CommunicationState.Faulted) { this._serviceClient.Abort(); } else { this._serviceClient.Close(); } } catch { this._serviceClient.Abort(); } this._serviceClient = null; } }

update october 29 : added 2 catch blocks so as to catch the REAL error message, please see this post:
http://fczaja.blogspot.com/2009/05/communication-object.html

   
 private void DisposeExistingServiceClientIfRequired()
    {
            if (this._serviceClient != null)
            {
                try
                {
                    if (this._serviceClient.State == CommunicationState.Faulted)
                    {
                        this._serviceClient.Abort();
                    }
                    else
                    {
                        this._serviceClient.Close();
                    }
                }
                catch (CommunicationException)
                {
                    this._serviceClient.Abort();
                }
                catch (TimeoutException)
                {
                    this._serviceClient.Abort();
                }
                catch (Exception ex)
                {
                    this._serviceClient.Abort();
                    throw ex;
                }

                this._serviceClient = null;
            }
        }
    }
}

and your app.config “serviceModel” section will be reduced to: (and could be reduced even more..)

update details (@Oct 16,2011):

programatic bindind in C#

 EndpointAddress epaddr = new EndpointAddress(Globals.EndPointAddress, epid); this._serviceClient = (TClient)Activator.CreateInstance( typeof(TClient), Globals.EndPointName, epaddr);
becomes
            this._serviceClient = (TClient)Activator.CreateInstance(
                typeof(TClient), new WSHttpBinding()
                {
                    MaxBufferPoolSize = maxStringContentLength,
                    MaxReceivedMessageSize = maxStringContentLength,
                    OpenTimeout = new TimeSpan(1, 0, 0),
                    ReceiveTimeout = new TimeSpan(1, 0, 0),
                    SendTimeout = new TimeSpan(1, 0, 0)
                },
                epaddr);

update 2011/10/19: added a binding type switch

  EndpointIdentity epid = EndpointIdentity.CreateUpnIdentity("host\\localhost");
                // update : programmatic binding
                EndpointAddress epaddr = new EndpointAddress(Globals.EndPointAddress, epid);
                if (Globals.myBindingType == Globals.BindingType.BasicHttpBinding)
                {
                    this._serviceClient = (TClient)Activator.CreateInstance(
                        typeof(TClient), new BasicHttpBinding()
                        {
                            MaxBufferPoolSize = maxStringContentLength,
                            MaxReceivedMessageSize = maxStringContentLength,
                            ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
                            {
                                MaxArrayLength = maxStringContentLength,
                                MaxBytesPerRead = maxStringContentLength,
                                MaxDepth = 32,
                                MaxNameTableCharCount = maxStringContentLength,
                                MaxStringContentLength = maxStringContentLength
                            },
                            MaxBufferSize = maxStringContentLength,
                            UseDefaultWebProxy = true,
                            OpenTimeout = new TimeSpan(1, 0, 0),
                            ReceiveTimeout = new TimeSpan(1, 0, 0),
                            SendTimeout = new TimeSpan(1, 0, 0)
                        },
                        epaddr);
                }
                if (Globals.myBindingType == Globals.BindingType.WSHttpBinding)
                {
                    this._serviceClient = (TClient)Activator.CreateInstance(
                        typeof(TClient), new WSHttpBinding()
                        {
                            MaxBufferPoolSize = maxStringContentLength,
                            MaxReceivedMessageSize = maxStringContentLength,
                            OpenTimeout = new TimeSpan(1, 0, 0),
                            ReceiveTimeout = new TimeSpan(1, 0, 0),
                            SendTimeout = new TimeSpan(1, 0, 0),
                            ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
                            {
                                MaxArrayLength = maxStringContentLength,
                                MaxBytesPerRead = maxStringContentLength,
                                MaxDepth = 32,
                                MaxNameTableCharCount = maxStringContentLength,
                                MaxStringContentLength = maxStringContentLength
                            }
},
                        epaddr);
                }

Master Data Services : Business Rules Copy / Import / Export (Cross Model)

updated article (Oct 2011)

(code refactored)

Hi All,

One other missing feature of MDS is Import / Export / Copy Business rules from a model to another (or copy business rules to the same model)

my code is still in beta, but it is already (partially) working.

you can find it on my “MDS Manager” tool on codeplex:

http://mdsmanager.codeplex.com


Get business rules from modelId, quite easy with service client method “business rules get”, returns a business rule set

 public BusinessRules GetBusinessRules(string fileName)
        {
            BusinessRules brs = null;
            Stream str = null;
            try
            {

                if (File.Exists(fileName))
                {
                    str = new FileStream(@fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

                    if (str == null)
                    {
                        throw new BusinessRulesException("error while opening file!");
                    }

                    XmlSerializer xs = new XmlSerializer(typeof(BusinessRules));
                    // Load the object saved above by using the Deserialize function
                     brs = (BusinessRules)xs.Deserialize(str);

                }
                else
                {
                    throw new BusinessRulesException("Cannot find specified file!");
                }

                return brs;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                // Cleanup                 if (str != null)
                    str.Close();

            }

        }
then we export business rules to a XML file
note:
//this is needed to avoid a serialization error (more info on http://www.johnsoer.com/blog/?p=125 ) :
 //XmlSerializer xs = new XmlSerializer(typeof(BusinessRules), new Type[] { typeof(BRAttributeValueArgument),typeof(BRBlankArgument)
   //                                                                                     ,typeof(BRDomainBasedAttributeArgument)});
here is the export method :
 public void ExportBusinessRules(string exportFileName, BusinessRules brs)
        {
            TextWriter WriteFileStream = null;
            try
            {

                //new type needed to avoir error because serialization of an inherited class                 XmlSerializer xs = new XmlSerializer(typeof(BusinessRules), new Type[] { typeof(Common.ServiceReference1.BRAttributeValueArgument) });
//update oct 2011!
//new type needed to avoir error because serialization of an inherited class

               XmlSerializer xs = new XmlSerializer(typeof(BusinessRules), new Type[] { typeof(BRAttributeValueArgument),typeof(BRBlankArgument)
                                                                                        ,typeof(BRDomainBasedAttributeArgument)});
              // Create a new file stream to write the serialized object to a file                 WriteFileStream = new StreamWriter(@exportFileName);
                xs.Serialize(WriteFileStream, brs);

               //custom exception class , but not required              throw new BusinessRulesException("Business Rules successfully exported to file " + exportFileName);

            }
            catch (Exception exc)
            {
                throw exc;
            }
            finally
            {
               // Cleanup                 if (WriteFileStream != null)
                    WriteFileStream.Close();
            }
        }

then we would like to import this XML file to another model:
here is the method to get business rules set from a previously exported XML file :
  public BusinessRules GetBusinessRules(string fileName)
        {
            BusinessRules brs = null;
            Stream str = null;
            try
            {

                if (File.Exists(fileName))
                {
                    str = new FileStream(@fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

                    if (str == null)
                    {
                        throw new BusinessRulesException("error while opening file!");
                    }

                    XmlSerializer xs = new XmlSerializer(typeof(BusinessRules));
                   // Load the object saved above by using the Deserialize function                    brs = (BusinessRules)xs.Deserialize(str);

                }
                else
                {
                    throw new BusinessRulesException("Cannot find specified file!");
                }

                return brs;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

              // Cleanup 
          if (str != null)
                    str.Close();

            }

        }

//then we can get the source modelID
 sourceModelId =brs.BusinessRulesMember.First().Identifier.ModelId as Identifier;
// and then clone business rule set with updated modelId:
//brs is the business rule set
//sourceModelId is the source Model Identifier (taken above from the Rules set from the XML file)
//target ModelId is the model Identifier for the model we want to import back the B. rules to
CloneBusinessRules(brs,sourceModelId, targetModelId));
Here is the CloneBusinessRules Method:
public string CloneBusinessRules(BusinessRules brs, Identifier SourceModelId, Identifier targetModelId)
        {

            OperationResult or = null;
            //instanciate new BR members
            try
            {
                int cptMissingEntity = 0;
                StringBuilder sb = new StringBuilder("these business rule related entities does not exists in target model:");
                sb.AppendLine();
                BusinessRules newBRS = new BusinessRules();
                foreach (BusinessRule br in brs.BusinessRulesMember)
                {
                    Identifier EntityId = null;
                    //this is used to get the target entity Id with matching its name 
                    using (ServiceClient c = new ServiceClientWrapper().CreateServiceClient())
                    {
                        EntityId = GetEntityIdFromName(c, c.Endpoint.Address.Uri.OriginalString, targetModelId, br.Identifier.EntityId.Name);

                    }
                    if (EntityId != null)
                    {
                        newBRS.BusinessRulesMember = new Collection<BusinessRule>();

                        //create a new business rule based on the source one, and applying on it the target identifiers and names 
                        BusinessRule newBR = BusinessRuleInstanciate(Guid.NewGuid(), br.Identifier.Name, targetModelId.Name, br.Identifier.EntityId.Name,
                            br.Identifier.MemberType, br.Priority, br.BRActions, br.Identifier.InternalId, br.RuleActionText, br.RuleConditionText);
                        //some required parameters to instanciate below:

                        //instanciate BRActions
                        newBRS.BRActions = BRActionsInstanciate(brs.BRActions, newBR.Identifier);
                        //instanciate BRConditions
                        newBRS.BRConditions = BRConditionsInstanciate(brs.BRConditions, newBR.Identifier);
                        //instanciate BRConditionTreeNodes
                        newBRS.BRConditionTreeNodes = BRConditionTreeNodesInstanciate(brs.BRConditionTreeNodes, newBR.Identifier);
                        newBRS.BusinessRulesMember.Add(newBR);
                    }
                    else
                    {
                        sb.AppendLine(br.Identifier.EntityId.Name);
                        cptMissingEntity++;
                        //these business rule related entities do not exist in target model
                    }
                    //then we clone modified BRSet
                    using (ServiceClient c = new ServiceClientWrapper().CreateServiceClient())
                    {

                        or = c.BusinessRulesClone(new International(), newBRS);
                        string err = Tools.HandleErrors(or);
                        if (!string.IsNullOrEmpty(err))
                        {
                            throw new Exception(err);
                        }
                    }
                    if (cptMissingEntity == 0)
                    {
                        sb = new StringBuilder();
                    }
                }

                return sb.ToString();
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }

update oct 2011 code for BRActionsInstanciate, BRConditionsInstanciate,BRConditionTreeNodesInstanciate

 private Collection<BRConditionTreeNode> BRConditionTreeNodesInstanciate(Collection<BRConditionTreeNode> BRConditionTreeNodes, MemberTypeContextIdentifier BRId)
        {

            try
            {
                //Add BRConditionTreeNode to BRConditionTreeNode Collection

                Collection<BRConditionTreeNode> newBRConditionTreeNodes = new Collection<BRConditionTreeNode>();

                foreach (BRConditionTreeNode brctn in BRConditionTreeNodes)
                {
                    BRConditionTreeNode BRConditionTreeNodeItem = new BRConditionTreeNode();
                    //Add Attribute and Action type to the collection
                    BRConditionTreeNodeItem.BRConditions = BRConditionsInstanciate(brctn.BRConditions, BRId);
                    BRConditionTreeNodeItem.BusinessRuleId = BRId;
                    BRConditionTreeNodeItem.ConditionTreeChildNodes = brctn.ConditionTreeChildNodes;
                    BRConditionTreeNodeItem.ConditionTreeParentNode = brctn.ConditionTreeParentNode;
                    BRConditionTreeNodeItem.LogicalOperator = brctn.LogicalOperator;
                    BRConditionTreeNodeItem.Identifier = new Identifier() { Name = brctn.Identifier.Name, Id = Guid.NewGuid() };

                    //All Action and Condition Items must have a sequence greater that zero
                    BRConditionTreeNodeItem.Sequence = brctn.Sequence;
                    newBRConditionTreeNodes.Add(BRConditionTreeNodeItem);
                }
                return newBRConditionTreeNodes;
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }

        private Collection<BRAction> BRActionsInstanciate(Collection<BRAction> BRActions, MemberTypeContextIdentifier BRId)
        {

            try
            {
                //Add Action to Action Collection

                Collection<BRAction> newBRActions = new Collection<BRAction>();

                foreach (BRAction bra in BRActions)
                {
                    BRAction BRActionItem = new BRAction() { Identifier = new Identifier() { Id = Guid.NewGuid(), Name = bra.Identifier.Name }, BusinessRuleId = BRId };
                    //Add Attribute and Action type to the collection
                    BRActionItem.PrefixArgument = new BRAttributeArgument();
                    BRActionItem.PrefixArgument.PropertyName = bra.PrefixArgument.PropertyName;
                    BRActionItem.PrefixArgument.AttributeId = new Identifier();
                    BRActionItem.PrefixArgument.AttributeId.Id = Guid.NewGuid();
                    BRActionItem.PrefixArgument.AttributeId.Name = bra.PrefixArgument.AttributeId.Name;
                    BRActionItem.Operator = bra.Operator;
                    var colBRffa = new Collection<object>();
                    foreach (var brffa in bra.PostfixArguments)
                    {
                        BRBlankArgument BRba = brffa as BRBlankArgument;
                        BRFreeformArgument BRffa = brffa as BRFreeformArgument;
                        if (BRba != null)
                        {
                            colBRffa.Add(new BRBlankArgument() { Identifier = new Identifier() { Id = Guid.NewGuid(), Name = BRba.Identifier.Name }, PropertyName = BRba.PropertyName });

                        }
                        else
                        {
                            if (BRffa != null)
                            {
                                colBRffa.Add(new BRFreeformArgument() { Identifier = new Identifier() { Id = Guid.NewGuid(), Name = BRffa.Identifier.Name }, Value = BRffa.Value, PropertyName = BRffa.PropertyName });

                            }
                        }
                    }
                    BRActionItem.PostfixArguments = colBRffa;
                    BRActionItem.Text = bra.Text;

                    //All Action and Condition Items must have a sequence greater that zero
                    BRActionItem.Sequence = bra.Sequence;
                    newBRActions.Add(BRActionItem);
                }
                return newBRActions;
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
        public Collection<BRCondition> BRConditionsInstanciate(Collection<BRCondition> BRconditions, MemberTypeContextIdentifier BRId)
        {

            try
            {
                //Add Action to Action Collection

                Collection<BRCondition> newBRconditions = new Collection<BRCondition>();
                BRCondition BRConditionItem = new BRCondition();

                foreach (BRCondition brc in BRconditions)
                {
                    //Add Attribute and Action type to the collection
                    BRConditionItem.BusinessRuleId = BRId;

                    BRConditionItem.ConditionTreeNodeId = new Identifier() { Name = brc.ConditionTreeNodeId.Name };
                    BRConditionItem.Identifier = new Identifier() { Id = Guid.NewGuid(), Name = brc.Identifier.Name };
                    BRConditionItem.Operator = brc.Operator;
                    BRConditionItem.PrefixArgument = brc.PrefixArgument;
                    BRConditionItem.PostfixArguments = brc.PostfixArguments;
                    //All Action and Condition Items must have a sequence greater that zero
                    BRConditionItem.Sequence = brc.Sequence;
                    BRConditionItem.Text = brc.Text;
                    newBRconditions.Add(BRConditionItem);
                }
                return newBRconditions;
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }