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. ioctl用法详解 (网络)

    本函数影响由fd参数引用的一个打开的文件. #include#include int ioctl( int fd, int request, .../* void *arg */ );返回0:成功   ...

  2. 【转】linux线程模型

    一.定义 关于进程.轻量级进程.线程.用户线程.内核线程的定义,这个很容易找到,但是看完之后你可以说你懂了,但实际上你真的明白了么? 在现代操作系统中,进程支持多线程.进程是资源管理的最小单元:而线程 ...

  3. Js原型模式

    function Person(){ } Person.prototype.name = "xd"; Person.prototype.age = 26; Person.proto ...

  4. [转] 使用C#开发ActiveX控件

    双魂人生 原文 使用C#开发ActiveX控件 ActiveX 是一个开放的集成平台,为开发人员.用户和 Web生产商提供了一个快速而简便的在 Internet 和 Intranet 创建程序集成和内 ...

  5. Tombstone crash

    首先,android平台应用程序可能产生以下四种crash:App层:Force close crashANR crashNative层:Tombstone crashKernel层:Kernel p ...

  6. Web自动化框架搭建之二基于数据驱动应用简单实例~~

    整体框架,先划分成细小功能模块~~,从最简单的开始,介绍 实现循环百度搜索实例: #coding=utf-8 '''Created on 2014��6��9�� @author: 小鱼'''impo ...

  7. Selenium2Library系列 keywords 之 _SelectElementKeywords 之 page_should_not_contain_list(self, locator, message='', loglevel='INFO')

    def page_should_not_contain_list(self, locator, message='', loglevel='INFO'): """Veri ...

  8. STM32F407 外扩SRAM

    字节控制功能.支持高/低字节控制. 看看实现 IS62WV51216 的访问,需要对 FSMC进行哪些配置. 这里就做一个概括性的讲解.步骤如下: 1)使能 FSMC 时钟,并配置 FSMC 相关的  ...

  9. 在/proc文件系统中增加一个目录hello,并在这个目录中增加一个文件world,文件的内容为hello world

    一.题目 编写一个内核模块,在/proc文件系统中增加一个目录hello,并在这个目录中增加一个文件world,文件的内容为hello world.内核版本要求2.6.18 二.实验环境 物理主机:w ...

  10. Unity中Instantiate一个prefab时需要注意的问题

    在调用Instantiate()方法使用prefab创建对象时,接收Instantiate()方法返回值的变量类型必须和声明prefab变量的类型一致,否则接收变量的值会为null.   比如说,我在 ...