private KCMSMQueueReader CreateQueue(SyncType syncType) { var pnName = KCMSMQQueueHelper.GetSyncName(syncType); string pnAddress = Environment.MachineName + @"\private$\" + KCMSMQQueueHelper.GetSyncQueueName(syncType); KCMSMQueueReader queue = new KCMSMQueueReader(pnAddress); bool queueExists = queue.IsQueueExists; if (queueExists) { queue.DeleteQueue(); } queue.CreateQueue(); string activity = KCMSMQConstants.createQueue(pnName); string comments = KCMSMQConstants.createQueueSuccess(pnName); InsertInitializationActivity(activity, comments); return(queue); }
private bool MessagesExist() { var nameInventoryPrice = KCMSMQQueueHelper.GetSyncName(SyncType.InventoryPrice); var nameInventoryQuantity = KCMSMQQueueHelper.GetSyncName(SyncType.InventoryQuantity); var nameVendorQuantity = KCMSMQQueueHelper.GetSyncName(SyncType.VendorQuantity); string pnAddressInventoryPrice = Environment.MachineName + @"\private$\" + KCMSMQQueueHelper.GetSyncQueueName(SyncType.InventoryPrice); string pnAddressInventoryQuantity = Environment.MachineName + @"\private$\" + KCMSMQQueueHelper.GetSyncQueueName(SyncType.InventoryQuantity); string pnAddressVendorQuantity = Environment.MachineName + @"\private$\" + KCMSMQQueueHelper.GetSyncQueueName(SyncType.VendorQuantity); KCMSMQueueReader queueInventoryPrice = new KCMSMQueueReader(pnAddressInventoryPrice); KCMSMQueueReader queueInventoryQuantity = new KCMSMQueueReader(pnAddressInventoryQuantity); KCMSMQueueReader queueVendorQuantity = new KCMSMQueueReader(pnAddressVendorQuantity); bool queueInventoryPriceExists = queueInventoryPrice.IsQueueExists; bool queueInventoryQuantityExists = queueInventoryQuantity.IsQueueExists; bool queueVendorQuantityExists = queueVendorQuantity.IsQueueExists; if (queueInventoryPriceExists && queueInventoryPrice.GetMessagesCount() > 0) { return(true); } else if (queueInventoryQuantityExists && queueInventoryQuantity.GetMessagesCount() > 0) { return(true); } else if (queueVendorQuantityExists && queueVendorQuantity.GetMessagesCount() > 0) { return(true); } return(false); }
private void CreatePN(SyncType syncType) { var pnName = KCMSMQQueueHelper.GetSyncName(syncType); PushNotificationsHook notification = PushNotifications.SelectSingle(pnName); if (notification != null) { PushNotifications.Delete(notification); PushNotifications.Cache.PersistDeleted(notification); foreach (var item in PushNotifocationSource.Select(notification.HookId)) { var obj = item.GetItem <PushNotificationsSource>(); PushNotifocationSource.Delete(obj); PushNotifocationSource.Cache.PersistDeleted(obj); } foreach (var item in PushNotifocationErrors.Select(notification.HookId)) { var obj = item.GetItem <PushNotificationsErrors>(); PushNotifocationErrors.Delete(obj); PushNotifocationErrors.Cache.PersistDeleted(obj); } foreach (var item in PushNotifocationFailed.Select(notification.HookId)) { var obj = item.GetItem <PushNotificationsFailedToSend>(); PushNotifocationFailed.Delete(obj); PushNotifocationFailed.Cache.PersistDeleted(obj); } Persist(); } notification = new PushNotificationsHook { Name = pnName, Type = "KCMQ", Active = true, Address = Environment.MachineName + @"\private$\" + KCMSMQQueueHelper.GetSyncQueueName(syncType), HookId = Guid.NewGuid() }; PushNotifications.Insert(notification); GIDesign design = Design.SelectSingle(pnName); PushNotificationsSource source = new PushNotificationsSource { HookId = notification.HookId, DesignID = design.DesignID, SourceType = "GI" }; PushNotifocationSource.Insert(source); InsertInitializationActivity(KCMSMQConstants.createPN(pnName), KCMSMQConstants.createPNSuccess(pnName)); Persist(); }