locked
updating member name and code RRS feed

  • Question

  • Hello all,

    I'd like to update the code of a member via file upload. Inserting new members is no biggine via SISS package and feeding the file through web interface. How can I do the updating? Because when I try to update then I get  "The member code already exists." error.

    I am a bit new in here so a sample code in VB.NET would be appericiated. Once the wheel starts to roll then I can take over the driving seat :-)

    Do I need to declare some reference like Microsoft.SqlServer.Dts.Runtime (which I declared to run the package) ?

    Friday, February 18, 2011 12:34 PM

Answers

  • Thanks...I'll convert this code in vb.net and will write my thoughts :-)

    by the way, there is an online C# to VB conversion tool, very usefull!

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Regards,



    Xavier Averbouch
    Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful".
    Friday, February 18, 2011 5:08 PM
  • Hi Professor

    please take a look here : http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/69372/

    at the end of the web page, there is this SSIS package : 

    MDS_StagingLoadBarclayProject.dtsx



    Xavier Averbouch
    Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful".
    Monday, February 21, 2011 9:52 AM
  • Hi Professor

    please check this sample for api members  update :

    http://social.msdn.microsoft.com/Forums/en/sqlmds/thread/66e2b792-193c-4bdc-9b0f-b3b48b54acf3

    for SSIS import script , here is a C# code sample : (XML file import with external XSLT file it's a custom dev , you should adapt it for your requirements)

    /* Microsoft SQL Server Integration Services Script Component
    * Write scripts using Microsoft Visual C# 2008.
    * ScriptMain is the entry point class of the script.*/
    
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    using System.Xml;
    using System.Text;
    using System.IO;
    using System.Collections.ObjectModel;
    using System.Xml.XPath;
    using System.Xml.Xsl;
    using System.Net;
    using System.Text.RegularExpressions;
    using System.Diagnostics;
    
    
    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
    public class ScriptMain : UserComponent
    {
      public Member m;
      public MemberAttribute ma;
      public Collection<Member> colMembers;
      public Collection<MemberAttribute> colAttributes;
      private const string strEntityName = "EntityName";
      private const string strMemberCode = "MemberCode";
      private const string strMemberName = "MemberName";
      private const string strAttributeName = "AttributeName";
      private const string strAttributeValue = "AttributeValue";
      
      public override void PreExecute()
      {
        base.PreExecute();
        /*
         Add your code here for preprocessing or remove if not needed
        */
    
      }
    
      public override void PostExecute()
      {
        base.PostExecute();
        /*
         Add your code here for postprocessing or remove if not needed
         You can set read/write variables here, for example:
         Variables.MyIntVar = 100
        */
      }
    
      public override void CreateNewOutputRows()
      {
        /*
         Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
         For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
        */
        //instanciate collections of members and attributes
        colMembers = new Collection<Member>();
        colAttributes = new Collection<MemberAttribute>();
    
    
        //xslt tranform
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(@Variables.xsltTransformFileName);
        StringWriter sw = new StringWriter();
        XmlWriter xmlWriter = new XmlTextWriter(sw);
        xslt.Transform(@Variables.xmlimportfilename, xmlWriter);
        string xml = sw.ToString();
        //File.WriteAllText(@"c:\temp\testImportXSLT.xml", xml); //keep commented , only for testing purposes
        //xml recursive parsing
        XmlDocument xd = new XmlDocument();
    
        xd.LoadXml(xml);
    
        XmlNode xnodDE = xd.DocumentElement;
    
        ParseChild(xnodDE, 0);
    
    
        foreach (Member currentMember in colMembers)
        {
          InsertMember(currentMember);
    
        }
        MembersOutputBuffer.SetEndOfRowset();
    
    
        foreach (MemberAttribute currentAttribute in colAttributes)
        {
    
          InsertMemberAttribute(currentAttribute);
    
        }
        AttributesOutputBuffer.SetEndOfRowset();
    
      }
    
      private static bool IsDuplicateMember(Collection<Member> col, Member member)
      {
        foreach (Member m in col)
        {
          if ((m.MemberCode == member.MemberCode) && (m.EntityName == member.EntityName) && (m.MemberName == member.MemberName))
            return true;
        }
        return false;
      }
    
      private static bool IsDuplicateAttribute(Collection<MemberAttribute> col, MemberAttribute attribute)
      {
        foreach (MemberAttribute a in col)
        {
          if ((a.MemberCode == attribute.MemberCode) && (a.AttributeName == attribute.AttributeName) && (a.EntityName == attribute.EntityName) && (a.AttributeValue == attribute.AttributeValue))
            return true;
        }
        return false;
      }
    
      private static bool IsValidDomainBasedAttribute(Collection<MemberAttribute> col, MemberAttribute attribute)
      {
        foreach (MemberAttribute a in col)
        {
    
          if ((a.MemberCode == attribute.MemberCode) && (a.EntityName == attribute.EntityName) && (a.AttributeValue == attribute.AttributeValue))
            return true;
        }
        return false;
      }
    
    
      private string SelectNodeValue(XmlNode n, string nodeName)
      {
        if (n != null && n.HasChildNodes && n.SelectSingleNode(nodeName).HasChildNodes && !string.IsNullOrEmpty(n.SelectSingleNode(nodeName).FirstChild.Value)
          && !n.SelectSingleNode(nodeName).FirstChild.Value.Contains("__") && !n.SelectSingleNode(nodeName).FirstChild.Value.EndsWith("_"))
        {
    
          return n.SelectSingleNode(nodeName).FirstChild.Value;
        }
        return string.Empty;
      }
      private void ParseChild(XmlNode xnod, int level)
      {
        XmlNode xnodWorking;
        
        if (m == null)
        {
          m = new Member();
        }
        if (ma == null)
        {
          ma = new MemberAttribute();
        }
    
       
    
        if (xnod.Name == "#text")
        {
          XmlNode MyNode = xnod.ParentNode.ParentNode;
          if (MyNode != null)
          {
            
    
            string strMDSMemberType = "";
            if (MyNode != null && MyNode.HasChildNodes && !string.IsNullOrEmpty(MyNode.FirstChild.InnerXml))
            {
              strMDSMemberType = MyNode.FirstChild.InnerXml;
            }
            if (strMDSMemberType.ToLower() == MDSMemberType.member.ToString())
            {
              m.EntityName = SelectNodeValue(MyNode, strEntityName);
              if (!string.IsNullOrEmpty(m.EntityName))
              {
                m.EntityName = m.EntityName.Trim();
              }
              m.MemberCode = SelectNodeValue(MyNode, strMemberCode);
              m.MemberCode = Regex.Replace(m.MemberCode, @"\s", string.Empty);
    
              m.MemberName = SelectNodeValue(MyNode, strMemberName);
              m.MemberType_ID = "1";
              m.ModelName = Variables.ModelName;
              if (!IsDuplicateMember(colMembers, m) && !string.IsNullOrEmpty(m.MemberCode))
              {
                colMembers.Add(m);
                m = new Member();
              }
            }
            else if (strMDSMemberType.ToLower() == MDSMemberType.attribute.ToString() || strMDSMemberType.ToLower() == MDSMemberType.dba.ToString())
            {
              ma.EntityName = SelectNodeValue(MyNode, strEntityName);
              ma.MemberCode = SelectNodeValue(MyNode, strMemberCode);
              ma.MemberCode = Regex.Replace(ma.MemberCode, @"\s", string.Empty);
              ma.AttributeName = SelectNodeValue(MyNode, strAttributeName);
    
              ma.AttributeValue = SelectNodeValue(MyNode, strAttributeValue);
              if (strMDSMemberType.ToLower() == MDSMemberType.dba.ToString())
              {
                ma.AttributeValue = Regex.Replace(ma.AttributeValue, @"\s", string.Empty);
              }
              ma.MemberType_ID = "1";
              ma.ModelName = Variables.ModelName;
              if (!IsDuplicateAttribute(colAttributes, ma) && !string.IsNullOrEmpty(ma.MemberCode) && !string.IsNullOrEmpty(ma.AttributeValue))
              {
                colAttributes.Add(ma);
                ma = ma.NewMemberAttribute();
              }
            }
    
            
    
          }
        }
        
    
        if (xnod.HasChildNodes)
        {
          xnodWorking = xnod.FirstChild;
          while (xnodWorking != null)
          {
            ParseChild(xnodWorking, level + 1);
            xnodWorking = xnodWorking.NextSibling;
          }
        }
      }
      /// <summary>
      /// inserts a mds member into members RowSet
      /// </summary>
      /// <param name="m"></param>
      public void InsertMember(Member m)
      {
    
        MembersOutputBuffer.AddRow();
        MembersOutputBuffer.ModelName = this.Variables.ModelName.Trim();
        MembersOutputBuffer.EntityName = (m.EntityName != null && !string.IsNullOrEmpty(m.EntityName)) ? m.EntityName.Trim() : string.Empty;
        MembersOutputBuffer.MemberTypeID = 1;
        MembersOutputBuffer.MemberCode = (m.MemberCode != null && !string.IsNullOrEmpty(m.MemberCode)) ? m.MemberCode.Trim() : string.Empty;
        MembersOutputBuffer.MemberName = (m.MemberName != null && !string.IsNullOrEmpty(m.MemberName)) ? m.MemberName.Trim() : string.Empty;
    
    
    
      }
    
      /// <summary>
      /// inserts a mds attribute into attributes RowSet
      /// </summary>
      /// <param name="ma"></param>
      public void InsertMemberAttribute(MemberAttribute ma)
      {
    
        AttributesOutputBuffer.AddRow();
        AttributesOutputBuffer.ModelName = this.Variables.ModelName.Trim();
        AttributesOutputBuffer.EntityName = (ma.EntityName != null && !string.IsNullOrEmpty(ma.EntityName)) ? ma.EntityName.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : string.Empty;
        AttributesOutputBuffer.MemberTypeID = 1;
        AttributesOutputBuffer.MemberCode = (ma.MemberCode != null && !string.IsNullOrEmpty(ma.MemberCode)) ? ma.MemberCode.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : string.Empty; ;
        AttributesOutputBuffer.AttributeName = (ma.AttributeName != null && !string.IsNullOrEmpty(ma.AttributeName)) ? ma.AttributeName.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : "_";
        AttributesOutputBuffer.AttributeValue = (ma.AttributeValue != null && !string.IsNullOrEmpty(ma.AttributeValue)) ? ma.AttributeValue.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : string.Empty;
    
    
      }
    
    }
    
    public enum MDSMemberType
    {
      dba,
      member,
      attribute
    }
    
    /// <summary>
    /// Master data services class for staging tables members/attributes
    /// </summary>
    public class Member
    {
      public Member()
      {
      }
    
      //public Member(string memberType_ID, string modelName, string entityName, string memberCode, string memberName)
      //{
      //  MemberType_ID = memberType_ID;
      //  ModelName = modelName;
      //  EntityName = entityName.Trim();
      //  MemberCode = memberCode.Trim();
      //  MemberName = memberName.Trim();
      //}
    
    
      public string MemberType_ID { get; set; }
      public string ModelName { get; set; }
      public string EntityName { get; set; }
      public string MemberCode { get; set; }
      public string MemberName { get; set; }
    
      public static bool isFull(Member m)
      {
        return (!string.IsNullOrEmpty(m.EntityName) && !string.IsNullOrEmpty(m.EntityName.Trim()) && !string.IsNullOrEmpty(m.MemberCode) && !string.IsNullOrEmpty(m.MemberCode.Trim()));
      }
    
      public static string ToString(Member m)
      {
    
        if (m != null)
        {
          
    
          return string.Format("MBR->Entity:{0}, Member:{1}, Name:{2}", m.EntityName, Regex.Replace(m.MemberCode, @"\s", string.Empty), m.MemberName);
        }
        return string.Empty;
      }
    
    
      public Member NewMember()
      {
        return new Member();
      }
    
    }
    public class MemberAttribute
    {
      public MemberAttribute()
      {
      }
      public static string ToString(MemberAttribute m)
      {
    
        if (m != null)
        {
          return string.Format("ATT->Entity:{0}, Member:{1}, AttributeName:{2}, AttributeValue:{3}", m.EntityName, Regex.Replace(m.MemberCode, @"\s", string.Empty), m.AttributeName, m.AttributeValue);
        }
        return string.Empty;
      }
      public MemberAttribute(string memberType_ID, string modelName, string entityName, string memberCode, string attributeName, string attributeValue)
      {
        MemberType_ID = memberType_ID;
        ModelName = modelName;
        EntityName = entityName.Trim();
        MemberCode = memberCode.Trim();
        AttributeName = attributeName.Trim();
        AttributeValue = attributeValue.Trim();
      }
      public string MemberType_ID { get; set; }
      public string ModelName { get; set; }
      public string EntityName { get; set; }
      public string MemberCode { get; set; }
      public string AttributeName { get; set; }
      public string AttributeValue { get; set; }
    
      public static bool isFull(MemberAttribute ma)
      {
        return (!string.IsNullOrEmpty(ma.EntityName) && !string.IsNullOrEmpty(ma.MemberCode)
          && !string.IsNullOrEmpty(ma.AttributeValue));
      }
    
      public MemberAttribute NewMemberAttribute()
      {
        return new MemberAttribute();
      }
    }
    
    
    Regards,
    


    Xavier Averbouch
    Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful".
    Friday, February 18, 2011 1:54 PM

All replies

  • Hi Professor

    please check this sample for api members  update :

    http://social.msdn.microsoft.com/Forums/en/sqlmds/thread/66e2b792-193c-4bdc-9b0f-b3b48b54acf3

    for SSIS import script , here is a C# code sample : (XML file import with external XSLT file it's a custom dev , you should adapt it for your requirements)

    /* Microsoft SQL Server Integration Services Script Component
    * Write scripts using Microsoft Visual C# 2008.
    * ScriptMain is the entry point class of the script.*/
    
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    using System.Xml;
    using System.Text;
    using System.IO;
    using System.Collections.ObjectModel;
    using System.Xml.XPath;
    using System.Xml.Xsl;
    using System.Net;
    using System.Text.RegularExpressions;
    using System.Diagnostics;
    
    
    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
    public class ScriptMain : UserComponent
    {
      public Member m;
      public MemberAttribute ma;
      public Collection<Member> colMembers;
      public Collection<MemberAttribute> colAttributes;
      private const string strEntityName = "EntityName";
      private const string strMemberCode = "MemberCode";
      private const string strMemberName = "MemberName";
      private const string strAttributeName = "AttributeName";
      private const string strAttributeValue = "AttributeValue";
      
      public override void PreExecute()
      {
        base.PreExecute();
        /*
         Add your code here for preprocessing or remove if not needed
        */
    
      }
    
      public override void PostExecute()
      {
        base.PostExecute();
        /*
         Add your code here for postprocessing or remove if not needed
         You can set read/write variables here, for example:
         Variables.MyIntVar = 100
        */
      }
    
      public override void CreateNewOutputRows()
      {
        /*
         Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
         For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
        */
        //instanciate collections of members and attributes
        colMembers = new Collection<Member>();
        colAttributes = new Collection<MemberAttribute>();
    
    
        //xslt tranform
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(@Variables.xsltTransformFileName);
        StringWriter sw = new StringWriter();
        XmlWriter xmlWriter = new XmlTextWriter(sw);
        xslt.Transform(@Variables.xmlimportfilename, xmlWriter);
        string xml = sw.ToString();
        //File.WriteAllText(@"c:\temp\testImportXSLT.xml", xml); //keep commented , only for testing purposes
        //xml recursive parsing
        XmlDocument xd = new XmlDocument();
    
        xd.LoadXml(xml);
    
        XmlNode xnodDE = xd.DocumentElement;
    
        ParseChild(xnodDE, 0);
    
    
        foreach (Member currentMember in colMembers)
        {
          InsertMember(currentMember);
    
        }
        MembersOutputBuffer.SetEndOfRowset();
    
    
        foreach (MemberAttribute currentAttribute in colAttributes)
        {
    
          InsertMemberAttribute(currentAttribute);
    
        }
        AttributesOutputBuffer.SetEndOfRowset();
    
      }
    
      private static bool IsDuplicateMember(Collection<Member> col, Member member)
      {
        foreach (Member m in col)
        {
          if ((m.MemberCode == member.MemberCode) && (m.EntityName == member.EntityName) && (m.MemberName == member.MemberName))
            return true;
        }
        return false;
      }
    
      private static bool IsDuplicateAttribute(Collection<MemberAttribute> col, MemberAttribute attribute)
      {
        foreach (MemberAttribute a in col)
        {
          if ((a.MemberCode == attribute.MemberCode) && (a.AttributeName == attribute.AttributeName) && (a.EntityName == attribute.EntityName) && (a.AttributeValue == attribute.AttributeValue))
            return true;
        }
        return false;
      }
    
      private static bool IsValidDomainBasedAttribute(Collection<MemberAttribute> col, MemberAttribute attribute)
      {
        foreach (MemberAttribute a in col)
        {
    
          if ((a.MemberCode == attribute.MemberCode) && (a.EntityName == attribute.EntityName) && (a.AttributeValue == attribute.AttributeValue))
            return true;
        }
        return false;
      }
    
    
      private string SelectNodeValue(XmlNode n, string nodeName)
      {
        if (n != null && n.HasChildNodes && n.SelectSingleNode(nodeName).HasChildNodes && !string.IsNullOrEmpty(n.SelectSingleNode(nodeName).FirstChild.Value)
          && !n.SelectSingleNode(nodeName).FirstChild.Value.Contains("__") && !n.SelectSingleNode(nodeName).FirstChild.Value.EndsWith("_"))
        {
    
          return n.SelectSingleNode(nodeName).FirstChild.Value;
        }
        return string.Empty;
      }
      private void ParseChild(XmlNode xnod, int level)
      {
        XmlNode xnodWorking;
        
        if (m == null)
        {
          m = new Member();
        }
        if (ma == null)
        {
          ma = new MemberAttribute();
        }
    
       
    
        if (xnod.Name == "#text")
        {
          XmlNode MyNode = xnod.ParentNode.ParentNode;
          if (MyNode != null)
          {
            
    
            string strMDSMemberType = "";
            if (MyNode != null && MyNode.HasChildNodes && !string.IsNullOrEmpty(MyNode.FirstChild.InnerXml))
            {
              strMDSMemberType = MyNode.FirstChild.InnerXml;
            }
            if (strMDSMemberType.ToLower() == MDSMemberType.member.ToString())
            {
              m.EntityName = SelectNodeValue(MyNode, strEntityName);
              if (!string.IsNullOrEmpty(m.EntityName))
              {
                m.EntityName = m.EntityName.Trim();
              }
              m.MemberCode = SelectNodeValue(MyNode, strMemberCode);
              m.MemberCode = Regex.Replace(m.MemberCode, @"\s", string.Empty);
    
              m.MemberName = SelectNodeValue(MyNode, strMemberName);
              m.MemberType_ID = "1";
              m.ModelName = Variables.ModelName;
              if (!IsDuplicateMember(colMembers, m) && !string.IsNullOrEmpty(m.MemberCode))
              {
                colMembers.Add(m);
                m = new Member();
              }
            }
            else if (strMDSMemberType.ToLower() == MDSMemberType.attribute.ToString() || strMDSMemberType.ToLower() == MDSMemberType.dba.ToString())
            {
              ma.EntityName = SelectNodeValue(MyNode, strEntityName);
              ma.MemberCode = SelectNodeValue(MyNode, strMemberCode);
              ma.MemberCode = Regex.Replace(ma.MemberCode, @"\s", string.Empty);
              ma.AttributeName = SelectNodeValue(MyNode, strAttributeName);
    
              ma.AttributeValue = SelectNodeValue(MyNode, strAttributeValue);
              if (strMDSMemberType.ToLower() == MDSMemberType.dba.ToString())
              {
                ma.AttributeValue = Regex.Replace(ma.AttributeValue, @"\s", string.Empty);
              }
              ma.MemberType_ID = "1";
              ma.ModelName = Variables.ModelName;
              if (!IsDuplicateAttribute(colAttributes, ma) && !string.IsNullOrEmpty(ma.MemberCode) && !string.IsNullOrEmpty(ma.AttributeValue))
              {
                colAttributes.Add(ma);
                ma = ma.NewMemberAttribute();
              }
            }
    
            
    
          }
        }
        
    
        if (xnod.HasChildNodes)
        {
          xnodWorking = xnod.FirstChild;
          while (xnodWorking != null)
          {
            ParseChild(xnodWorking, level + 1);
            xnodWorking = xnodWorking.NextSibling;
          }
        }
      }
      /// <summary>
      /// inserts a mds member into members RowSet
      /// </summary>
      /// <param name="m"></param>
      public void InsertMember(Member m)
      {
    
        MembersOutputBuffer.AddRow();
        MembersOutputBuffer.ModelName = this.Variables.ModelName.Trim();
        MembersOutputBuffer.EntityName = (m.EntityName != null && !string.IsNullOrEmpty(m.EntityName)) ? m.EntityName.Trim() : string.Empty;
        MembersOutputBuffer.MemberTypeID = 1;
        MembersOutputBuffer.MemberCode = (m.MemberCode != null && !string.IsNullOrEmpty(m.MemberCode)) ? m.MemberCode.Trim() : string.Empty;
        MembersOutputBuffer.MemberName = (m.MemberName != null && !string.IsNullOrEmpty(m.MemberName)) ? m.MemberName.Trim() : string.Empty;
    
    
    
      }
    
      /// <summary>
      /// inserts a mds attribute into attributes RowSet
      /// </summary>
      /// <param name="ma"></param>
      public void InsertMemberAttribute(MemberAttribute ma)
      {
    
        AttributesOutputBuffer.AddRow();
        AttributesOutputBuffer.ModelName = this.Variables.ModelName.Trim();
        AttributesOutputBuffer.EntityName = (ma.EntityName != null && !string.IsNullOrEmpty(ma.EntityName)) ? ma.EntityName.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : string.Empty;
        AttributesOutputBuffer.MemberTypeID = 1;
        AttributesOutputBuffer.MemberCode = (ma.MemberCode != null && !string.IsNullOrEmpty(ma.MemberCode)) ? ma.MemberCode.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : string.Empty; ;
        AttributesOutputBuffer.AttributeName = (ma.AttributeName != null && !string.IsNullOrEmpty(ma.AttributeName)) ? ma.AttributeName.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : "_";
        AttributesOutputBuffer.AttributeValue = (ma.AttributeValue != null && !string.IsNullOrEmpty(ma.AttributeValue)) ? ma.AttributeValue.Trim().Replace(@"\r", string.Empty).Replace(@"\n", string.Empty).Replace(@"\t", string.Empty) : string.Empty;
    
    
      }
    
    }
    
    public enum MDSMemberType
    {
      dba,
      member,
      attribute
    }
    
    /// <summary>
    /// Master data services class for staging tables members/attributes
    /// </summary>
    public class Member
    {
      public Member()
      {
      }
    
      //public Member(string memberType_ID, string modelName, string entityName, string memberCode, string memberName)
      //{
      //  MemberType_ID = memberType_ID;
      //  ModelName = modelName;
      //  EntityName = entityName.Trim();
      //  MemberCode = memberCode.Trim();
      //  MemberName = memberName.Trim();
      //}
    
    
      public string MemberType_ID { get; set; }
      public string ModelName { get; set; }
      public string EntityName { get; set; }
      public string MemberCode { get; set; }
      public string MemberName { get; set; }
    
      public static bool isFull(Member m)
      {
        return (!string.IsNullOrEmpty(m.EntityName) && !string.IsNullOrEmpty(m.EntityName.Trim()) && !string.IsNullOrEmpty(m.MemberCode) && !string.IsNullOrEmpty(m.MemberCode.Trim()));
      }
    
      public static string ToString(Member m)
      {
    
        if (m != null)
        {
          
    
          return string.Format("MBR->Entity:{0}, Member:{1}, Name:{2}", m.EntityName, Regex.Replace(m.MemberCode, @"\s", string.Empty), m.MemberName);
        }
        return string.Empty;
      }
    
    
      public Member NewMember()
      {
        return new Member();
      }
    
    }
    public class MemberAttribute
    {
      public MemberAttribute()
      {
      }
      public static string ToString(MemberAttribute m)
      {
    
        if (m != null)
        {
          return string.Format("ATT->Entity:{0}, Member:{1}, AttributeName:{2}, AttributeValue:{3}", m.EntityName, Regex.Replace(m.MemberCode, @"\s", string.Empty), m.AttributeName, m.AttributeValue);
        }
        return string.Empty;
      }
      public MemberAttribute(string memberType_ID, string modelName, string entityName, string memberCode, string attributeName, string attributeValue)
      {
        MemberType_ID = memberType_ID;
        ModelName = modelName;
        EntityName = entityName.Trim();
        MemberCode = memberCode.Trim();
        AttributeName = attributeName.Trim();
        AttributeValue = attributeValue.Trim();
      }
      public string MemberType_ID { get; set; }
      public string ModelName { get; set; }
      public string EntityName { get; set; }
      public string MemberCode { get; set; }
      public string AttributeName { get; set; }
      public string AttributeValue { get; set; }
    
      public static bool isFull(MemberAttribute ma)
      {
        return (!string.IsNullOrEmpty(ma.EntityName) && !string.IsNullOrEmpty(ma.MemberCode)
          && !string.IsNullOrEmpty(ma.AttributeValue));
      }
    
      public MemberAttribute NewMemberAttribute()
      {
        return new MemberAttribute();
      }
    }
    
    
    Regards,
    


    Xavier Averbouch
    Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful".
    Friday, February 18, 2011 1:54 PM
  • Thanks...I'll convert this code in vb.net and will write my thoughts :-)
    Friday, February 18, 2011 2:12 PM
  • Thanks...I'll convert this code in vb.net and will write my thoughts :-)

    by the way, there is an online C# to VB conversion tool, very usefull!

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Regards,



    Xavier Averbouch
    Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful".
    Friday, February 18, 2011 5:08 PM
  • Thanks :-)

     

    Ok, this code seems over my programming skills :-) Is it possible to use something like "if record exists then update it, or add that record" trick in staging tables and then update MDS records from integration screen in website? is it a good approach?

    Monday, February 21, 2011 9:04 AM
  • Hi Professor

    please take a look here : http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/69372/

    at the end of the web page, there is this SSIS package : 

    MDS_StagingLoadBarclayProject.dtsx



    Xavier Averbouch
    Avanade , FRANCE
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful".
    Monday, February 21, 2011 9:52 AM