using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page
{
private CustomerSOList bgCustomerSOListEntity { get; set; }
private CustomerSOList dbCustomerSOListEntity { get; set; }
private bool enableStyle { get; set; } protected void Page_Load(object sender, EventArgs e)
{
GenerateDemoData();
SortCustomerSOListEntityProperty(dbCustomerSOListEntity);
SortCustomerSOListEntityProperty(bgCustomerSOListEntity); var dbNode = new TreeNode("CustomerSOListEntity");
var bgNode = new TreeNode("CustomerSOListEntity");
this.TreeView1.Nodes.Add(dbNode);
this.TreeView2.Nodes.Add(bgNode); enableStyle = true;
CompareCustomerSOList(dbNode, dbCustomerSOListEntity, bgCustomerSOListEntity);
enableStyle = false;
CompareCustomerSOList(bgNode, bgCustomerSOListEntity, dbCustomerSOListEntity);
} public void GenerateDemoData()
{
var soTran1 = new SOTransactionBasic()
{
ItemNumber = "s-001",
Description = "sd-001"
}; var soTran2 = new SOTransactionBasic()
{
ItemNumber = "s-002",
Description = "sd-002"
}; var soTran3 = new SOTransactionBasic()
{
ItemNumber = "s-003",
Description = "sd-003"
}; var soBasic1 = new SOBasic()
{
SONumber = ,
SODate = DateTime.Now,
SOTransactionBasicList = new List<SOTransactionBasic>() { soTran1 }
}; var soBasic2 = new SOBasic()
{
SONumber = ,
SODate = DateTime.Now,
SOTransactionBasicList = new List<SOTransactionBasic>() { soTran1, soTran2 }
}; var soBasic3 = new SOBasic()
{
SONumber = ,
SODate = DateTime.Now,
SOTransactionBasicList = new List<SOTransactionBasic>() { soTran1, soTran3 }
}; var soBasic4 = new SOBasic()
{
SONumber = ,
SODate = DateTime.Now,
SOTransactionBasicList = new List<SOTransactionBasic>() { soTran1, soTran3 }
}; bgCustomerSOListEntity = new CustomerSOList()
{
RowKey = "10|60000",
SOBasicList = new List<SOBasic>() { soBasic1, soBasic2 }
}; dbCustomerSOListEntity = new CustomerSOList()
{
RowKey = "10|60000",
SOBasicList = new List<SOBasic>() { soBasic3, soBasic4 }
}; bgCustomerSOListEntity = null;
} public void SortCustomerSOListEntityProperty(CustomerSOList customerSOListEntity)
{
if (customerSOListEntity == null) return; if (customerSOListEntity.SOBasicList != null && customerSOListEntity.SOBasicList.Any())
{
customerSOListEntity.SOBasicList = customerSOListEntity.SOBasicList.OrderBy(p => p.SONumber).ToList();
customerSOListEntity.SOBasicList.ForEach(p =>
{
if (p.SOTransactionBasicList != null && p.SOTransactionBasicList.Any())
{
p.SOTransactionBasicList = p.SOTransactionBasicList.OrderBy(m => m.ItemNumber).ToList();
}
});
}
} public void CompareCustomerSOList2(TreeNode dbPNode, TreeNode bgPNode, object obj1, object obj2)
{
CustomerSOList dbCustomerSOs = null;
CustomerSOList bgCustomerSOs = null;
if (obj1.GetType() == typeof(CustomerSOList))
{
dbCustomerSOs = obj1 as CustomerSOList;
bgCustomerSOs = obj2 as CustomerSOList;
} SOBasic dbSOBasic = null;
SOBasic bgSOBasic = null;
if (obj1.GetType() == typeof(SOBasic))
{
dbSOBasic = obj1 as SOBasic;
bgSOBasic = obj2 as SOBasic;
} var dbProperties = obj1.GetType().GetProperties();
var bgProperties = obj2 == null ? null : obj2.GetType().GetProperties(); foreach (var pi in dbProperties)
{
if (pi.PropertyType == typeof(List<SOBasic>))
{
var dbNodeList = new TreeNode("SOBasicList");
var bgNodeList = new TreeNode("SOBasicList");
dbPNode.ChildNodes.Add(dbNodeList);
bgPNode.ChildNodes.Add(bgNodeList); dbCustomerSOs.SOBasicList.ForEach(p1 =>
{
var dbNode = new TreeNode(string.Format("SOBasic-{0}", dbCustomerSOs.SOBasicList.IndexOf(p1)));
var bgNode = new TreeNode(string.Format("SOBasic-{0}", dbCustomerSOs.SOBasicList.IndexOf(p1)));
dbNodeList.ChildNodes.Add(dbNode);
bgNodeList.ChildNodes.Add(bgNode); var p2 = bgCustomerSOs.SOBasicList.Find(m => m.SONumber == p1.SONumber); if (p2 == null)
{
SetPerentNodeStyle(dbNode);
SetChildNodeStyle(dbNode);
} CompareCustomerSOList2(dbNode, bgNode, p1, p2);
});
}
else if (pi.PropertyType == typeof(List<SOTransactionBasic>))
{
var dbNodeList = new TreeNode("SOTransactionBasicList");
var bgNodeList = new TreeNode("SOTransactionBasicList");
dbPNode.ChildNodes.Add(dbNodeList);
bgPNode.ChildNodes.Add(bgNodeList); dbSOBasic.SOTransactionBasicList.ForEach(p1 =>
{
var dbNode = new TreeNode(string.Format("SOTransactionBasic-{0}", dbSOBasic.SOTransactionBasicList.IndexOf(p1)));
var bgNode = new TreeNode(string.Format("SOTransactionBasic-{0}", dbSOBasic.SOTransactionBasicList.IndexOf(p1)));
dbNodeList.ChildNodes.Add(dbNode);
bgNodeList.ChildNodes.Add(bgNode); var p2 = bgSOBasic == null || bgSOBasic.SOTransactionBasicList == null ? null : bgSOBasic.SOTransactionBasicList.Find(m => m.ItemNumber == p1.ItemNumber); if (p2 == null)
{
SetPerentNodeStyle(dbNode);
SetChildNodeStyle(dbNode);
} CompareCustomerSOList2(dbNode, bgNode, p1, p2);
});
}
else
{
var dbPropertyValue = pi.GetValue(obj1).ToString();
var dbNode = new TreeNode(string.Format("{0}:{1}", pi.Name, dbPropertyValue));
dbPNode.ChildNodes.Add(dbNode); string bgPropertyValue = null; if (bgProperties != null)
{
bgPropertyValue = bgProperties.ToList().Find(p => p.Name == pi.Name).GetValue(obj2).ToString();
var bgNode = new TreeNode(string.Format("{0}:{1}", pi.Name, bgPropertyValue));
bgPNode.ChildNodes.Add(bgNode);
} if (dbPropertyValue == bgPropertyValue) continue; SetPerentNodeStyle(dbNode); } }
} public void CompareCustomerSOList(TreeNode dbPNode, object obj1, object obj2)
{
if (obj1 == null) return; CustomerSOList dbCustomerSOs = null;
CustomerSOList bgCustomerSOs = null;
if (obj1.GetType() == typeof(CustomerSOList))
{
dbCustomerSOs = obj1 as CustomerSOList;
bgCustomerSOs = obj2 as CustomerSOList;
} SOBasic dbSOBasic = null;
SOBasic bgSOBasic = null;
if (obj1.GetType() == typeof(SOBasic))
{
dbSOBasic = obj1 as SOBasic;
bgSOBasic = obj2 as SOBasic;
} var dbProperties = obj1.GetType().GetProperties();
var bgProperties = obj2 == null ? null : obj2.GetType().GetProperties(); foreach (var pi in dbProperties)
{
if (pi.PropertyType == typeof(List<SOBasic>))
{
var dbNodeList = new TreeNode("SOBasicList");
dbPNode.ChildNodes.Add(dbNodeList); dbCustomerSOs.SOBasicList.ForEach(p1 =>
{
var dbNode = new TreeNode(string.Format("SOBasic-{0}", dbCustomerSOs.SOBasicList.IndexOf(p1)));
dbNodeList.ChildNodes.Add(dbNode); var p2 = bgCustomerSOs == null ? null : bgCustomerSOs.SOBasicList.Find(m => m.SONumber == p1.SONumber); if (enableStyle && p2 == null)
{
SetPerentNodeStyle(dbNode);
SetChildNodeStyle(dbNode);
} CompareCustomerSOList(dbNode, p1, p2);
});
}
else if (pi.PropertyType == typeof(List<SOTransactionBasic>))
{
var dbNodeList = new TreeNode("SOTransactionBasicList");
dbPNode.ChildNodes.Add(dbNodeList); dbSOBasic.SOTransactionBasicList.ForEach(p1 =>
{
var dbNode = new TreeNode(string.Format("SOTransactionBasic-{0}", dbSOBasic.SOTransactionBasicList.IndexOf(p1)));
dbNodeList.ChildNodes.Add(dbNode); var p2 = bgSOBasic == null || bgSOBasic.SOTransactionBasicList == null ? null : bgSOBasic.SOTransactionBasicList.Find(m => m.ItemNumber == p1.ItemNumber); if (enableStyle && p2 == null)
{
SetPerentNodeStyle(dbNode);
SetChildNodeStyle(dbNode);
} CompareCustomerSOList(dbNode, p1, p2);
});
}
else
{
var dbPropertyValue = pi.GetValue(obj1).ToString();
var dbNode = new TreeNode(string.Format("{0}:{1}", pi.Name, dbPropertyValue));
dbPNode.ChildNodes.Add(dbNode); string bgPropertyValue = null; if (bgProperties != null)
{
bgPropertyValue = bgProperties.ToList().Find(p => p.Name == pi.Name).GetValue(obj2).ToString();
} if (dbPropertyValue == bgPropertyValue) continue; if (enableStyle)
{
SetPerentNodeStyle(dbNode);
} } }
} public void SetPerentNodeStyle(TreeNode node)
{
if (node == null) return; node.Text = node.Text.IndexOf("yellowBack") > ? node.Text : string.Format("<span class='yellowBack'>{0}</span>", node.Text); SetPerentNodeStyle(node.Parent);
} public void SetChildNodeStyle(TreeNode node)
{
if (node == null) return; node.Text = node.Text.IndexOf("yellowBack") > ? node.Text : string.Format("<span class='yellowBack'>{0}</span>", node.Text); if (node.ChildNodes != null && node.ChildNodes.Count > )
{
foreach (var item in node.ChildNodes)
{
SetChildNodeStyle(node);
}
} }
}

CustomerSOList的更多相关文章

随机推荐

  1. HDU 5305 Friends (DFS,穷举+剪枝)

    题意: 给定n个人,m对朋友关系,如果对于每个人,只能刚好选择其所有朋友中的一半的人进行聊天(只是我和我的朋友,不是我的朋友和我的朋友),那么有多少种情况?只要一个选择不同,视为不同情况. 思路: 比 ...

  2. Android开发中常见的设计模式

    对于开发人员来说,设计模式有时候就是一道坎,但是设计模式又非常有用,过了这道坎,它可以让你水平提高一个档次.而在android开发中,必要的了解一些设计模式又是非常有必要的.对于想系统的学习设计模式的 ...

  3. js一些平时会用到的

    如何屏蔽页面js错误    <script language="javascript">    function killErrors()    {        re ...

  4. ASP.NET MVC 教程汇总

    自学MVC看这里——全网最全ASP.NET MVC 教程汇总   MVC架构已深得人心,微软也不甘落后,推出了Asp.net MVC.小编特意整理博客园乃至整个网络最具价值的MVC技术原创文章,为想要 ...

  5. 嵌入式 hi3518c下ramdisk文件系统与文件系统烧写以及uboot中change-the-env

    NULL RAM : mkdir ramdisk_test  临时挂在点 dd if=/dev/zero of=123 bs=1k count=10000 建立空硬盘 losetup /dev/loo ...

  6. [Everyday Mathematics]20150108

    设 $f$ 在 $(a,b)$ 上 $n+1$ 次可导, 且 $$\bex \ln\frac{f(b)+f'(b)+\cdots+f^{(n)}(b)}{f(a)+f'(a)+\cdots+f^{(n ...

  7. Objective-C异步编程

    1. 不要阻塞主线程 不管在进行iOS还是OS X开发中,主线程都只应该处理用户交互和界面布局,好的程序通常能够随时快速响应用户的操作,所以CPU密集型或者会阻塞线程的代码应该在其他位置去执行,我指的 ...

  8. MongoDB@入门一

    安装MongoDB自行搜索, 我这里提供GUI版本类似navicat. 1. 数据库层面 show dbs #查看服务器上的数据库  [local  0.000GB] use test  #切换到指定 ...

  9. [Hive - LanguageManual] Create/Drop/Grant/Revoke Roles and Privileges / Show Use

    Create/Drop/Grant/Revoke Roles and Privileges Hive Default Authorization - Legacy Mode has informati ...

  10. sf空间配置

    1.创建VHost     记住Homepage,打开VHost DNS标签页,创建Virtual Host,如下图: 2.Wcp上传文件     用户名是"sf用户名,sf项目名" ...