CustomerSOList
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的更多相关文章
随机推荐
- python - pip 从已有的安装列表 安装
已经安装好的机器:sudo pip freeze > install_list.list 需要安装的机器:sudo pip install -r install_list.list
- js把div固定在页面的右下角
在公司做材料系统中,需要做一个总是居于右下角的div,但是因为右边这部分本就是用iframe做的,所以是不好弄的. 一开始,以为用position:fixed,一句css就可以完成,结果在iframe ...
- solr4.5 schema.xml配置文件
schema.xml配置文件是用于定义index索引库的结构,有点类似于数据表表的定义. 当我们打开schema.xml配置文件时,也许会被里面密密麻麻的代码所吓倒,其实不必惊慌,里面其实就两个东西f ...
- win7和centos双系统安装
几年之前为了安装xp和linux的双系统曾折腾了好多天,今天为了安装这个win7和centos双系统,也折腾了两天多,哦,我的天,安装个双系统,怎么这么麻烦呢? 没有来得及整理,先铺上草稿,供同志们参 ...
- UTF-8编码规则
UTF-8是Unicode的一种实现方式,也就是它的字节结构有特殊要求,所以我们说一个汉字的范围是0X4E00到0x9FA5,是指unicode值,至于放在utf-8的编码里去就是由三个字节来组织,所 ...
- hdu 1026 Ignatius and the Princess I(优先队列+bfs+记录路径)
以前写的题了,现在想整理一下,就挂出来了. 题意比较明确,给一张n*m的地图,从左上角(0, 0)走到右下角(n-1, m-1). 'X'为墙,'.'为路,数字为怪物.墙不能走,路花1s经过,怪物需要 ...
- [Everyday Mathematics]20150112
设 $f\in C[0,1]$ 适合 $$\bex \int_x^1 f(t)\rd t\geq \frac{1-x^2}{2},\quad \forall\ x\in [0,1]. \eex$$ 试 ...
- golang学习遭遇错误原因分析续
7. error: reference to field ‘Printf’ in object which has no fields or methods f.Printf("%v&quo ...
- 关于在Eclipse里面启动了服务,但是localhost:8080无法访问的问题:
今天eclipse重新换了一个然后写项目,结果发生了一些bug,当在Tomca服务开启之后,浏览器端输入localhost:8080无法访问,以为是服务器没有搞定,检查了没问题,百度了一下有很多乱七八 ...
- Android - LayoutInflater
在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById().不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例 ...