Zetetic.Ldap.LdifCsvPivot.AddColumn C# (CSharp) Method

AddColumn() public method

public AddColumn ( string ldapName, string title, int index ) : void
ldapName string
title string
index int
return void
        public void AddColumn(string ldapName, string title, int index)
        {
            Columns.Add(new PivotColumn(ldapName, title, index));
        }

Same methods

LdifCsvPivot::AddColumn ( string ldapName, string title, string join ) : void

Usage Example

コード例 #1
0
ファイル: Program.cs プロジェクト: skradel/Zetetic.Ldap
        private static void Run(List<string> ldifs, string colConfig, string fileOut)
        {
            System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(
                typeof(List<PivotColumn>));

            LdifCsvPivot pivot = new LdifCsvPivot();

            if (string.IsNullOrEmpty(colConfig))
            {
                pivot.AddColumn("dn", "dn", null);
                pivot.AddColumn("rdn", "rdn", null);
                pivot.AddColumn("parent", "parent", null);
                pivot.AddColumn("samaccountname", "uid", null);
                pivot.AddColumn("objectclass", "objectclass", PivotColumn.LAST_INDEX);
                pivot.AddColumn("sn", "sn", null);
                pivot.AddColumn("givenName", "givenName", null);
                pivot.AddColumn("mail", "mail", null);

                EmitSampleXml(pivot, ser);
            }
            else
            {
                using (System.IO.FileStream fs = new System.IO.FileStream(colConfig, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                {
                    pivot.Columns = (List<PivotColumn>)ser.Deserialize(fs);
                }
            }

            if (!string.IsNullOrEmpty(fileOut))
                pivot.Output = new System.IO.StreamWriter(fileOut, false, new System.Text.UTF8Encoding(false, true));

            try
            {
                int i = 0;
                foreach (string s in ldifs)
                {
                    try
                    {
                        pivot.Process(s, i++ == 0);
                    }
                    catch (Exception)
                    {
                        Console.Error.WriteLine("Failed on file {0}", s);
                        throw;
                    }
                }
            }
            finally
            {
                if (!string.IsNullOrEmpty(fileOut))
                    pivot.Output.Dispose();
            }
        }