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. LeetCode: divideInteger

    Title: Divide two integers without using multiplication, division and mod operator. If it is overflo ...

  2. Delphi DecodeDate和EncodeDate 拆分和聚合时间函数的用法

    SysUtilsprocedure DecodeData(Date: TDateTime; var Year, Month, Day: Word);DecodeDate打断TdateTime成为年月日 ...

  3. 正在连接...ORA-12541: TNS: 无监听程序

    明明已经在Net Configuration Assistant中配置过监听程序并启动过.但在测试本地网络服务名配置中扔提示以上错误"正在连接...ORA-12541: TNS: 无监听程序 ...

  4. 修改Oracle 表空间名称 tablespace name

    修改表空间名称步骤如下: 1. 使用oracle用户登录执行 $sqlplus / as sysdba 2. 执行修改表空间命令如下 SQL> alter tablespace  TEST re ...

  5. logback.xml配置

    一:根节点<configuration>包含的属性: scan: 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true. scanPeriod: 设置监测配置文 ...

  6. [转]Oracle 阳历转农历

    CREATE TABLE SolarData ( YearID INTEGER NOT NULL, -- 农历年 DATA ) NOT NULL, -- 农历年对应的16进制数 DataInt INT ...

  7. [Tommas] 一种有效的测试策略(转)

    在最近的一个大型项目中,我们在早期就定下了一个目标:不会在软件中使用大量QA人员专注于手工测试.通过手工测试发现bug极其耗时且成本高昂,这促使团队尝试尽可能的将质量内嵌到产品内部.但这并不意味着手工 ...

  8. c#基类 常用数据验证的封装,数字,字符,邮箱的验证

    #region 常用数据验证的封装,数字字符的验证       /// <summary>       /// 常用数据验证的封装,数字字符的验证       /// </summa ...

  9. 2015NOIP简单说说

    在机房度过最后两节课然后滚回去赶文化课,准备期中考试,高考.AFO的称号毫无悬念的归来了.DAY1T2的失误不能拿下230,只能190滚粗,DAY2一上午都在混沌.旁边的哥们求我给看第一题,于是他就对 ...

  10. vim 操作

    vim -b test.bin vim 的 -b 选项是告诉 vim 打开的是一个二进制文件,不指定的话,会在后面加上 0x0a ,即一个换行符,这样若是二进制文件,则文件被改变了,后面多了一个0x0 ...