マイナーでもいいよね??

殆どVB系、でも .NET じゃない VB は知らないよん

目次

Blog 利用状況

書庫

日記カテゴリ

組織単位リスト画面のWebアプリのコード(C#)

組織単位リスト画面の Web アプリの C# のコードです。

 

//直下のオブジェクト格納用(OU自身のパス, 直下のオブジェクトの名前と種類と説明を格納したデータソース用のテーブル)

private Dictionary<string, DataTable> domainObjectsInfos;

private List<OrganizationalUnit> ouCol;   //OUのコレクション

 

protected void Page_Load(object sender, EventArgs e)

{

  if (base.Page.IsPostBack)   //ポストバックの時

  {

    domainObjectsInfos = (Dictionary<string, DataTable>)ViewState["domainObjectsInfos"];

    return;

  }

 

  var ous = DirectoryAccess.GetOrganizationalUnits();   //OUを取得

  ouCol = ous.OrderBy(ou => ou.DisplayPath).ThenBy(ou => ou.Name).ToList();

  this.CountLabel.Text = String.Format("{0} 個のオブジェクト", ous.Count);

  domainObjectsInfos = new Dictionary<string, DataTable>();

  ViewState["domainObjectsInfos"] = domainObjectsInfos;

  this.AddChildNode(null);  //子ノードを追加

}

 

protected void DetailDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)

{

  if (this.OUTreeView.SelectedNode == null)

  {

    e.Cancel = true;

  }

}

 

protected void DetailDataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)

{

  this.DataPanel.Visible = true;

  this.ShowStoredData((OrganizationalUnit)e.ReturnValue);   //格納されているデータを表示

}

 

protected void Button1_Click(object sender, EventArgs e)

{

  Response.Redirect("Main.aspx?idx=3");

}

 

//子ノードを追加

private void AddChildNode(TreeNode node)

{

  var path = (node == null) ? String.Empty : node.ValuePath;

  var childOUs = ouCol.Where(ou => ou.DisplayPath.Equals(path)).ToList();   //直下のOU

  foreach (var ou in childOUs)

  {

    var childNode = CreateNode(ou);   //ノードを作成

    if (node == null)

    {

      this.OUTreeView.Nodes.Add(childNode);

    }

    else

    {

      node.ChildNodes.Add(childNode);

    }

    this.AddChildNode(childNode);   //子ノードを追加

  }

}

 

//指定した OU のノードを作成

private TreeNode CreateNode(OrganizationalUnit ou)

{

  var path = (ou.DisplayPath.Length == 0) ? String.Empty : ou.DisplayPath + "/";

  return new TreeNode(ou.Name, path + ou.Name);

}

 

//指定した OU に格納されているデータを表示

private void ShowStoredData(OrganizationalUnit ou)

{

  DataTable table;

  if (domainObjectsInfos.TryGetValue(this.OUTreeView.SelectedValue, out table) == false//直下のオブジェクトを格納していない時

  {

    table = CreateDataSourceTable();  //データソース用のテーブルを作成

    foreach (var domainObject in ou.StoredDomainObjects)  //直下のオブジェクト数分

    {

      var row = table.NewRow();

      var objectType = (CategoryType)Enum.Parse(typeof(CategoryType), domainObject.Entry.SchemaClassName, true);

      row[0] = domainObject.Name;   //名前をセット

      row[1] = DirectoryAccess.CategoryNames[(int)objectType];  //種類をセット

      row[2] = domainObject.Description;  //説明をセット

      table.Rows.Add(row);

    }

    domainObjectsInfos.Add(this.OUTreeView.SelectedValue, table);

  }

  this.DataCountLabel.Text = String.Format("{0} 個のオブジェクト", table.Rows.Count);

  this.DataCountLabel.Visible = table.Rows.Count > 0;

  this.DataGridView.DataSource = table;

  this.DataGridView.DataBind();

}

 

//データソース用のテーブルを作成

private DataTable CreateDataSourceTable()

{

  var table = new DataTable();

  table.Columns.Add(new DataColumn("Name", typeof(string)));

  table.Columns.Add(new DataColumn("Type", typeof(string)));

  table.Columns.Add(new DataColumn("Description", typeof(string)));

  return table;

}

 

説明は少しですが VB のコードの方に書いてます。

投稿日時 : 2014年4月24日 23:25

コメントを追加

# online essay helper e83uov 2022/09/08 23:37 Charlosmox


Point effectively used.. https://definitionessays.com/ custom papers online

# how to write phd dissertation n53xiw 2023/02/09 12:53 Albertosed


Lovely forum posts, Regards!

https://service-essay.com/ write a essay for me

# pay someone to write paper e98rst 2023/02/26 10:18 CharlesSnoff


Very good content. Appreciate it!
pay someone to write an essay for you https://quality-essays.com/ essay writer pay

# paper writing service superiorpapers o94nnh 2023/02/28 23:09 StevenGrelo


Wonderful tips. Appreciate it.
best service for paper writing https://service-essay.com/ student paper writing service

# create a thesis statement t20nkg 2023/03/02 23:24 Josephbried

You said this adequately.
thesis formatting service in singapore https://writingthesistops.com/ buy a thesis online

# help with writing a thesis o19slh 2023/03/06 3:37 EugeneSib


Kudos. A lot of facts!
high school essay writing https://writinganessaycollegeservice.com write essays for me https://helptowriteanessay.com

# essay writers c10kzx 2023/03/06 3:43 Gregorysaipt

You actually suggested this perfectly!
college essay writer for pay https://essaywritingservicehelp.com dissertation experts https://helptowriteanessay.com

# dissertation methodology a331fh 2023/03/08 0:48 Gregorysaipt

You actually suggested it very well!
web content writer https://quality-essays.com harvard college essay https://buycheapessaysonline.com

# writing a good essay m970yh 2023/03/08 1:33 EugeneSib


You said it perfectly..
affordable essay writing service https://helpwithdissertationwriting.com persuasive essay writing help https://customthesiswritingservice.com

# how to write a college essay paper v38bfd 2023/03/08 16:55 EugeneSib


Beneficial info. Thanks.
funny college essay https://essaywritingserviceahrefs.com college essay writing help https://researchproposalforphd.com

# length of dissertation a21qds 2023/03/08 23:04 Gregorysaipt


Thanks, I enjoy this!
letter writing services https://bestmasterthesiswritingservice.com how to write a good scholarship essay https://hireawriterforanessay.com

# executive resume writing services chicago r221bg 2023/03/10 0:11 EugeneSib

You actually stated this exceptionally well.
help in assignment writing https://buyanessayscheaponline.com writing expository essay https://researchpaperwriterservices.com

# what should a college essay be about g91evx 2023/03/10 14:34 EugeneSib


Incredible plenty of excellent facts.
dissertation university https://domyhomeworkformecheap.com top online resume writing services https://researchproposalforphd.com

# how to write a creative essay r74eyf 2023/03/10 18:06 Gregorysaipt


Great write ups. Regards.
how to write a self evaluation essay https://ouressays.com mba dissertations https://essaywritingservicehelp.com

# best cv writing service in dubai w63jqv 2023/03/11 5:43 EugeneSib

You actually expressed it terrifically!
postgraduate thesis https://argumentativethesis.com writing essays online https://englishessayhelp.com

# write custom essays q94kmq 2023/03/12 13:36 Gregorysaipt


Amazing tons of amazing material.
resume writing services https://custompaperwritingservices.com writer service https://englishessayhelp.com

# proquest umi dissertation publishing k67mym 2023/03/13 1:50 EugeneSib


Very good content. Thanks a lot!
how to write a lit essay https://custompaperwritersservices.com what is the best essay writing service https://essaywriting4you.com

# importance of college education essay x138tj 2023/03/13 11:23 Gregorysaipt


Regards, I value it!
how to write an intro paragraph for an essay https://phdthesisdissertation.com essays about college https://helpmedomyxyzhomework.com

# graphic organizers for writing essays r65ycb 2023/04/01 23:04 EugeneSib

You suggested this exceptionally well!
critical essay help https://argumentativethesis.com how to write a collage essay https://buyanessayscheaponline.com

タイトル
名前
URL
コメント