private static void ProcessSceneTypeChanges(MessageItem msg) { if (null == msg) { return; } var usernoteItem = new UserMessageQueueItem(); List <Services.SyncStateDto> syncInfo; if (OperationEnum.Deleted == msg.Operation) { syncInfo = msg.Data.Exists(o => o.Key == "EnterpriseID") ? Service.GetExistSyncStateDtosByEnterpriseID(msg.Data.Find(o => o.Key == "EnterpriseID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "EnterpriseID"); var del = new[] { new DeletedEntity() }; if (msg.Data.Exists(o => o.Key == "SceneTypeID")) { del[0] = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "SceneTypeID").Value, EntityName = msg.EntityName } } ; GeneralSetUserMessageQueueItem(usernoteItem, del, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } else { syncInfo = msg.Data.Exists(o => o.Key == "EnterpriseID") ? Service.GetExistSyncStateDtosByEnterpriseID(msg.Data.Find(o => o.Key == "EnterpriseID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "EnterpriseID"); GeneralSetUserMessageQueueItem(usernoteItem, AppSyncActionEnum.SyncProjectAndScene, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } UserMsgItem2Mongo(Service, syncInfo, usernoteItem); }
private static void ProcessProjectChanges(MessageItem msg) { try { if (null == msg) { return; } var usernoteItem = new UserMessageQueueItem(); List <Services.SyncStateDto> syncInfo; if (OperationEnum.Deleted == msg.Operation) { // 删除操作 string departmentIDs = "-1"; var data = msg.Data.Find(o => o.Key == "DepartMentIDs"); if (null != data) { departmentIDs = msg.Data.Find(o => o.Key == "DepartMentIDs").Value; } var idList = departmentIDs.Split('|').ToList(); var ids = idList.Select(id => Convert.ToInt32(id)).ToList(); syncInfo = Service.GetExistSyncStateDtoByDepartMentIDs(ids); var del = new[] { new DeletedEntity() }; if (msg.Data.Exists(o => o.Key == "ProjectID")) { del[0] = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "ProjectID").Value, EntityName = msg.EntityName } } ; GeneralSetUserMessageQueueItem(usernoteItem, del, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } else { // 其他操作 syncInfo = msg.Data.Exists(o => o.Key == "ProjectID") ? Service.GetExistSyncStateDtoByProjectID(msg.Data.Find(o => o.Key == "ProjectID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "ProjectID"); GeneralSetUserMessageQueueItem(usernoteItem, AppSyncActionEnum.SyncProjectAndScene, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } UserMsgItem2Mongo(Service, syncInfo, usernoteItem); } catch (Exception ex) { var logger = log4net.LogManager.GetLogger(typeof(MsmqProvider)); logger.Error(ex.Message); } }
private static OrganizationUserMsgItem2Mongo ProcessFrontUserChanges(MessageItem msg) { try { if (null == msg) { return(null); } var usernoteItem = new UserMessageQueueItem(); List <Services.SyncStateDto> syncInfo; if (OperationEnum.Deleted == msg.Operation) { // 删除操作 syncInfo = msg.Data.Exists(o => o.Key == "EnterpriseID") ? Service.GetExistSyncStateDtosByEnterpriseID(msg.Data.Find(o => o.Key == "EnterpriseID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "EnterpriseID"); var del = new[] { new DeletedEntity() }; if (msg.Data.Exists(o => o.Key == "UserID")) { del[0] = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "UserID").Value, EntityName = msg.EntityName } } ; GeneralSetUserMessageQueueItem(usernoteItem, del, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } else { // 其他操作 syncInfo = msg.Data.Exists(o => o.Key == "UserID") ? Service.GetExistSyncStateDtosRelateFrontUserIDAtEnterprise(msg.Data.Find(o => o.Key == "UserID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "UserID"); GeneralSetUserMessageQueueItem(usernoteItem, AppSyncActionEnum.SyncOrganization, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } return(new OrganizationUserMsgItem2Mongo { SyncInfo = syncInfo, UsernoteItem = usernoteItem }); //UserMsgItem2Mongo(Service, syncInfo, usernoteItem); } catch (Exception ex) { var logger = log4net.LogManager.GetLogger(typeof(MsmqProvider)); logger.Error(ex.Message); } return(null); }
private static void ProcessSceneDataChanges(List <ML.BC.Infrastructure.MsmqHelper.MessageItem> messageItems) { try { if (null == messageItems || messageItems.Count == 0) { return; } foreach (var msg in messageItems) { var usernoteItem = new UserMessageQueueItem(); List <Services.SyncStateDto> syncInfos; if (OperationEnum.Deleted == msg.Operation) { // 删除操作 syncInfos = msg.Data.Exists(o => o.Key == "SceneID") ? Service.GetExistSyncStateDtosBySceneID(msg.Data.Find(o => o.Key == "SceneID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "SceneID"); var del = new[] { new DeletedEntity() }; if (msg.Data.Exists(o => o.Key == "Id")) { del[0] = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "Id").Value, EntityName = msg.EntityName } } ; GeneralSetUserMessageQueueItem(usernoteItem, del, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } else { // 其他操作 syncInfos = msg.Data.Exists(o => o.Key == "Id") ? Service.GetExistSyncStateDtosBySceneItemID(msg.Data.Find(o => o.Key == "Id").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "Id"); GeneralSetUserMessageQueueItem(usernoteItem, AppSyncActionEnum.SyncSceneData, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } UserMsgItem2Mongo(Service, syncInfos, usernoteItem); } } catch (Exception ex) { var logger = log4net.LogManager.GetLogger(typeof(MsmqSync)); logger.Error(ex.Message); } }
private static void ProcessSceneChanges(MessageItem msg) { try { if (null == msg) { return; } var usernoteItem = new UserMessageQueueItem(); List <Services.SyncStateDto> syncInfo; if (OperationEnum.Deleted == msg.Operation) { // 删除操作 syncInfo = msg.Data.Exists(o => o.Key == "ProjectID") ? Service.GetExistSyncStateDtoByProjectID(msg.Data.Find(o => o.Key == "ProjectID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "ProjectID"); var del = new[] { new DeletedEntity() }; if (msg.Data.Exists(o => o.Key == "SceneID")) { del[0] = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "SceneID").Value, EntityName = msg.EntityName } } ; GeneralSetUserMessageQueueItem(usernoteItem, del, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } else { // 其他操作 syncInfo = msg.Data.Exists(o => o.Key == "ProjectID") ? Service.GetExistSyncStateDtoByProjectID(msg.Data.Find(o => o.Key == "ProjectID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "ProjectID"); GeneralSetUserMessageQueueItem(usernoteItem, AppSyncActionEnum.SyncProjectAndScene, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } UserMsgItem2Mongo(Service, syncInfo, usernoteItem); } catch (Exception ex) { var logger = log4net.LogManager.GetLogger(typeof(MsmqProvider)); logger.Error(ex.Message); } }
private static OrganizationUserMsgItem2Mongo ProcessUserRoleChanges(MessageItem msg) { try { if (null == msg) { return(null); } var usernoteItem = new UserMessageQueueItem(); List <Services.SyncStateDto> syncInfo; if (OperationEnum.Deleted == msg.Operation) { // 删除操作 var delList = new List <DeletedEntity>(); if ("UserRole" == msg.EntityName) { syncInfo = msg.Data.Exists(o => o.Key == "UserID") ? Service.GetExistSyncStateDtosRelateFrontUserIDAtEnterprise(msg.Data.Find(o => o.Key == "UserID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "UserID"); var delete = new DeletedEntity(); if (msg.Data.Exists(o => o.Key == "User_RoleID")) { delete = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "User_RoleID").Value, EntityName = msg.EntityName } } ; delList.Add(delete); } else { syncInfo = msg.Data.Exists(o => o.Key == "EnterpriseID") ? Service.GetExistSyncStateDtosByEnterpriseID(msg.Data.Find(o => o.Key == "EnterpriseID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "EnterpriseID"); var delete = new DeletedEntity(); if (msg.Data.Exists(o => o.Key == "RoleID")) { delete = new DeletedEntity { EntityID = msg.Data.Find(o => o.Key == "RoleID").Value, EntityName = msg.EntityName } } ; delList.Add(delete); } DeletedEntity[] del = delList.ToArray(); GeneralSetUserMessageQueueItem(usernoteItem, del, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } else { // 其他操作 if ("UserRole" == msg.EntityName) { syncInfo = msg.Data.Exists(o => o.Key == "UserID") ? Service.GetExistSyncStateDtosRelateFrontUserIDAtEnterprise(msg.Data.Find(o => o.Key == "UserID").Value) : GetError2Log4Net(msg.EntityName, msg.Operation, "UserID"); } else { var item = msg.Data.Find(o => o.Key == "RoleID"); int roleId = 0; if (item != null) { int.TryParse(msg.Data.Find(o => o.Key == "RoleID").Value, out roleId); } syncInfo = Service.GetExistSyncStateDtoByRoleID(roleId); } GeneralSetUserMessageQueueItem(usernoteItem, AppSyncActionEnum.SyncOrganization, AppSyncDataTypeEnum.Entity, msg.ChangeTime); } return(new OrganizationUserMsgItem2Mongo { SyncInfo = syncInfo, UsernoteItem = usernoteItem }); //UserMsgItem2Mongo(Service, syncInfo, usernoteItem); } catch (Exception ex) { var logger = log4net.LogManager.GetLogger(typeof(MsmqProvider)); logger.Error(ex.Message); } return(null); }