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的更多相关文章
随机推荐
- LeetCode Binary Tree Level Order Traversal II (二叉树颠倒层序)
题意:从左到右统计将同一层的值放在同一个容器vector中,要求上下颠倒,左右不颠倒. 思路:广搜逐层添加进来,最后再反转. /** * Definition for a binary tree no ...
- 转载RabbitMQ入门(5)--主题
主题(topic) (使用Java客户端) 在先前的指南中我们改进了我们的日志系统.取代使用fanout类型的交易所,那个仅仅有能力实现哑的广播,我们使用一个direct类型的交易所,获得一个可以有选 ...
- 【转】linux中waitpid及wait的用法
原文网址:http://www.2cto.com/os/201203/124851.html wait(等待子进程中断或结束) 表头文件 #include<sys/types.h> ...
- function 中定义函数的默认返回值,
result有默认值的int类型的为0,string类型的为‘’,tobject类型的为nil等等
- InnoDB一定会在索引中加上主键吗
InnoDB一定会在索引中加上主键吗 http://www.penglixun.com/tech/database/will_innodb_store_pk_in_index.html
- [转] c#中 多线程访问winform控件
原文 c#中多线程访问winform控件的若干问题小结 我们在做winform应用的时候,大部分情况下都会碰到使用多线程控制界面上控件信息的问题.然而我们并不能用传统方法来解决这个问题,下面我将详细的 ...
- JTA事务管理--配置剖析(二)
Spring引用Tomcat的 JTA事务 Tomcat是Servlet容器,但它提供了JNDI的实现,因此用户可以象在Java EE应用程序服务器中一样,在Tomcat中使用JNDI查找JD ...
- 使用calabash测试开源中国Android客户端
Calabash-android是支持android的UI自动化测试框架,前面已经介绍过<中文Win7下成功安装calabash-android步骤>,这篇博文尝试测试一个真实应用:开源中 ...
- Android的AutoCompleteTextView在API17高版本添加的setText函数在低版本系统居然能正常调用?官方文档是不是不靠谱了?
官方文档:https://developer.android.com/reference/android/widget/AutoCompleteTextView.html#setText(java.l ...
- 【和我一起学python吧】Python 启航
话说万张高楼平地起,不会走之前先学会爬吧.尤其对于我等的小菜同学来说更是这样,不管怎么先code first吧,等我等小菜们翅膀硬了才test first吧. 1, 怎么运行python? 先到pyt ...