public void Deal(EventContract msg) { var bus = MqBusMgr.GetInstance(); OptEnum operation; Enum.TryParse(msg.Operation.ToString(), out operation); var unitContract = new UnitContract { Operation = operation, UnitId = msg.Id }; if (msg.Operation != Zmind.EventBus.Contract.OptEnum.Delete) { var unitFacade = new t_unitFacade(); var result = unitFacade.GetUnitById(msg.Id); if (result == null) { return; } unitContract.UnitCode = result.unit_code; unitContract.UnitName = result.unit_name; unitContract.TypeCode = result.type_code; unitContract.ParentUnitId = result.src_unit_id; unitContract.UnitNameEn = result.unit_name_en; unitContract.UnitNameShort = result.unit_name_short; unitContract.City1Name = result.city1_name; unitContract.City2Name = result.city2_name; unitContract.City3Name = result.city3_name; unitContract.UnitAddress = result.unit_address; unitContract.UnitContact = result.unit_contract; unitContract.UnitTel = result.unit_tel; unitContract.UnitFax = result.unit_fax; unitContract.UnitEmail = result.unit_email; unitContract.UnitPostcode = result.unit_postcode; unitContract.UnitRemark = result.unit_remark; unitContract.CreateTime = string.IsNullOrEmpty(result.create_time) ? null : DateTime.Parse(result.create_time); unitContract.ModifyTime = string.IsNullOrEmpty(result.modify_time) ? null : DateTime.Parse(result.modify_time); unitContract.StoreType = result.StoreType; } bus.Publish <IZmindToXgx>(unitContract); }
public void Deal(UnitContract contract) { if (contract.UnitId == ConfigMgr.XgxHeadUnitId) { return; } if (contract.ParentUnitId == ConfigMgr.XgxHeadUnitId) { contract.ParentUnitId = ConfigMgr.HeadUnitId; } var dbEntity = ConvertTot_unit(contract); var dbApEntity = ConvertTot_customer_shopEntity(contract); var unitFacade = new t_unitFacade(); var unitRelationFacade = new T_Unit_RelationFacade(); var unitApFacade = new t_customer_shopFacade(); switch (contract.Operation) { case OptEnum.Create: unitFacade.Create(dbEntity); unitApFacade.Create(dbApEntity); unitRelationFacade.Create(ConvertToT_Unit_Relation(contract)); break; case OptEnum.Update: unitFacade.Update(dbEntity); unitApFacade.Update(dbApEntity); unitRelationFacade.Update(ConvertToT_Unit_Relation(contract)); break; case OptEnum.Delete: unitFacade.Delete(dbEntity); unitApFacade.Delete(dbApEntity); unitRelationFacade.Delete(ConvertToT_Unit_Relation(contract)); break; } }