zoukankan      html  css  js  c++  java
  • 截稿1

    /* Copyright (c) 2015 Xiamen Weixin Software Co., Ltd. All rights reserved
    *
    * Create by huanglc@holworth.com at 2015-10-19 11:25:45
    *
    */

    using System;
    using System.ComponentModel;
    using System.Linq;
    using System.Reflection;
    using System.Text;
    using System.Collections.Generic;
    using Contract.IService;
    using Framework;
    using System.Collections;
    using Contract.Domain;
    using BaseService;
    using Contract.IService;
    using Framework.Domain;
    namespace Bll
    {
    public class TranSumaryInfomationService : BaseService.EntityService<Contract.Domain.TranSumaryInfomation>, ITranSumaryInfomationService
    {
    public PropertyInfo GetProperyInfo(string Name, PropertyInfo[] ps)
    {
    PropertyInfo p1 = null;
    ps.ToList().ForEach(p =>
    {
    if (p.Name == Name)
    {
    p1 = p;
    }
    });
    return p1;
    }
    public TranSumaryInfomation FindTransactionInfo(int TransactionId)
    {
    QueryInfo info = new QueryInfo();
    info.AddParam("TransactionId", TransactionId);
    TranSumaryInfomation t = Dao.FindOne(info) as TranSumaryInfomation;
    return t;
    }
    /// <summary>
    /// 保存汇总交易信息
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public override TranSumaryInfomation SaveOrUpdate(TranSumaryInfomation obj)
    {


    List<PropertyInfo> ps = typeof(TranSumaryInfomation).GetProperties().ToList();
    TranSumaryInfomation ori = null;
    #region 根据id标记实体状态
    if (!string.IsNullOrEmpty(obj.Id))
    {
    ori = Dao.FindById(obj.GetType(), obj.Id, null, null) as TranSumaryInfomation;
    if (obj.State.Dirty)
    ori.State.MarkDirty();
    else
    {
    ori.State.MarkDeleted();
    }
    }
    else
    {
    ori = new TranSumaryInfomation();
    ori.State.MarkNew();
    }
    #endregion

    #region 保证交易类型下对应的交易号是不重复的
    if (obj.State.Dirty || obj.State.New)
    {
    var tranSumaryInfomations =
    Holworth.Utility.Utility.ListToT<TranSumaryInfomation>(Dao.FindList(new QueryInfo("TranSumaryInfomation"))).ToList();
    var tranSumaryInfomationDic =
    tranSumaryInfomations.ToList().ToDictionary(x => new { x.TransactionId, x.TranTypeName });
    if (tranSumaryInfomationDic.ContainsKey(new { obj.TransactionId, obj.TranTypeName }) && tranSumaryInfomationDic[new { obj.TransactionId, obj.TranTypeName }].Id != ori.Id)
    {
    //提示
    throw new Exception("交易出现异常,交易号和交易类型名称不能重复!!");

    }

    ps.ForEach(p =>
    {
    if (p.Name != "Id")
    {
    var value = p.GetValue(obj, null);
    p.SetValue(ori, value, null);
    }

    });

    }
    #endregion

    #region 此段语句应当是不会触发的但是如果触发了则进行相应的删除操作
    if (obj.State.Deleted)
    {

    Delete(Convert.ToInt32(obj.TransactionId));

    }
    #endregion

    ori = base.SaveOrUpdate(ori);
    return ori;

    }

    public void Delete(int TransactionId)
    {
    //查询 entity,transactionId 并删除TranSumaryInfomation对应的交易号信息
    #region 删除汇总表 Transaction交易号对应的信息
    QueryInfo delInfo = new QueryInfo();
    delInfo.QueryObject = "TranSumaryInfomation";
    delInfo.AddParam("TransactionId", TransactionId);
    TranSumaryInfomation tinfo = Dao.FindOne(delInfo) as TranSumaryInfomation; if (tinfo == null)
    {
    return;
    }
    string entity = tinfo.TranEntity;
    tinfo.State.MarkDeleted();
    Dao.SaveOrUpdate(tinfo);
    #endregion

    #region 根据 entity,transactionId 查询主表信息 删除从表信息 删除主表信息

    #region 查出主交易消息 根据主记录查出从表信息Details并进行删除
    delInfo = new QueryInfo();
    delInfo.QueryObject = entity;
    delInfo.AddParam("Id", TransactionId);
    object obj1 = Dao.FindOne(delInfo);
    ArrayList childrens = null;
    PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(obj1);
    foreach (PropertyDescriptor p in pdc)
    {
    var value = p.GetValue(obj1);
    bool b = false;
    if (value != null)
    {
    b = value.GetType().GetInterface("IList") != null;
    }
    if (b)
    {
    childrens = new ArrayList();
    var childList = value as IList;
    if (childList != null && childList.Count > 0)
    {
    foreach (Entity child in childList)
    {
    child.State.MarkDeleted();
    childrens.Add(child);
    }
    }
    Dao.Evict(obj1);
    Dao.Evict(childList);
    Dao.Flush();
    Dao.SaveOrUpdateAll(childrens);
    }

    }


    #endregion

    #region HQL删除主表信息
    delInfo = new QueryInfo();
    delInfo.CustomSQL = string.Format("delete from {0} where Id={1}", entity, TransactionId);
    Dao.ExecuteUpdate(delInfo);
    #endregion

    #endregion

    #region 删除TransactionId对应的TranStructure
    QueryInfo deleteTranStructureInfo = new QueryInfo();
    deleteTranStructureInfo.CustomSQL = "delete from TranStructure";
    deleteTranStructureInfo.AddParam("TransactionId", TransactionId);
    Dao.ExecuteUpdate(deleteTranStructureInfo);
    #endregion

    #region 根据TransactionId删除对应的现金流信息
    QueryInfo deleteTranCashFlowInfo = new QueryInfo();
    deleteTranCashFlowInfo.CustomSQL = "delete from TranCashFlow";
    deleteTranCashFlowInfo.AddParam("TransactionId", TransactionId);
    Dao.ExecuteUpdate(deleteTranCashFlowInfo);
    #endregion

    #region 删除对应TransactionId的TranPayoff信息
    Framework.QueryInfo deletePayOffInfo = new QueryInfo();
    deletePayOffInfo.CustomSQL = "delete from TranPayoff";
    deletePayOffInfo.AddParam("TransactionId", TransactionId);
    Dao.ExecuteUpdate(deletePayOffInfo);
    #endregion

    #region 删除对应的TranProfitloss信息
    Framework.QueryInfo deleteTranProfitlossInfo = new QueryInfo();
    deleteTranProfitlossInfo.CustomSQL = "delete from TranProfitloss"; //new TranProfitloss().TransactionId
    deleteTranProfitlossInfo.AddParam("TransactionId", TransactionId);
    Dao.ExecuteUpdate(deleteTranProfitlossInfo);
    #endregion
    }


    }
    }

  • 相关阅读:
    论文参考文献
    Spatial Transformer Networks
    python实现两个升序链表合并
    ImportError: cannot import name 'PILLOW_VERSION'
    交叉熵与KL散度
    windows环境下面安装neo4j出错记录
    在vue项目中引入JQuery
    Vue在windows的环境配置
    js动态修改Easyui元素不生效,EasyUI动态渲染解析解决方案
    java.lang.NoClassDefFoundError:org/apache/commons/lang/exception/NestableRuntimeException报错的原因
  • 原文地址:https://www.cnblogs.com/kexb/p/4905448.html
Copyright © 2011-2022 走看看