public string GetPrinterTypeFromOutputManager(string WarehouseID, string TerminalID, string DocumentType, string DocumentSubType, out string Error) { string printerType = string.Empty; lock (_warehouseOMConfiguration) { if (_warehouseOMConfiguration.ContainsKey(WarehouseID)) { OutputManagerConfig omConf = _warehouseOMConfiguration[WarehouseID]; printerType = omConf.GetPrinterType(TerminalID, DocumentType, DocumentSubType, out Error); } else { Error = "No OutputManager configuration exists for Warehouse: [" + WarehouseID + "]"; } } return(printerType); }
private void UpdateOutputManagerInformation() { Dictionary <string, Warehouse_OutputManager_Config> WarehouseOMConfig = GetWarehouseOMConfig(); Dictionary <string, OutputManagerConfig> outputManagerConfigurationDic = new Dictionary <string, OutputManagerConfig>(); Dictionary <string, OutputManagerConfig> warehouseOMConfiguration = new Dictionary <string, OutputManagerConfig>(); foreach (Warehouse_OutputManager_Config WHOMconf in WarehouseOMConfig.Values) { if (!outputManagerConfigurationDic.ContainsKey(WHOMconf.OutputManagerId)) { OutputManagerConfig OMconf = GetOutputManagerPrinterConfig(WHOMconf); if (OMconf != null) { outputManagerConfigurationDic.Add(OMconf.WarehouseOMID, OMconf); } else { _tracing.TraceEvent(TraceEventType.Error, 0, "Could not contact OutputManager service(s) for OMID: [" + WHOMconf.OutputManagerId + "]"); } } if (outputManagerConfigurationDic.ContainsKey(WHOMconf.OutputManagerId)) { if (!warehouseOMConfiguration.ContainsKey(WHOMconf.WarehouseId)) { warehouseOMConfiguration.Add(WHOMconf.WarehouseId, outputManagerConfigurationDic[WHOMconf.OutputManagerId]); } } } lock (_warehouseOMConfiguration) { _warehouseOMConfiguration = warehouseOMConfiguration; } }
private OutputManagerConfig GetOutputManagerPrinterConfig(Warehouse_OutputManager_Config omToCall) { OutputManagerService.OutputHandlerServiceClient client = new OutputManagerService.OutputHandlerServiceClient(_endpointName); foreach (string urlToCall in omToCall.orderdURLs) { bool iOK = true; try { EndpointAddress currentEndpoint = client.Endpoint.Address; EndpointAddress address = new EndpointAddress(new Uri(urlToCall), currentEndpoint.Identity, currentEndpoint.Headers); client.Endpoint.Address = address; OutputManagerService.FindPrinterInfoResult omResult = client.FindPrinterInfo(null); client.Close(); OutputManagerConfig newOMConfig = new OutputManagerConfig(); newOMConfig.WarehouseOMID = omToCall.WarehouseId; foreach (OutputManagerService.TerminalGroup terGrp in omResult.TerminalGroups) { foreach (string terminal in terGrp.Terminals) { if (!newOMConfig.TerminalsWithGroup.ContainsKey(terminal)) { newOMConfig.TerminalsWithGroup.Add(terminal, terGrp.TerminalGroupID); } } } foreach (OutputManagerService.ReportGroup rptGrp in omResult.ReportGroups) { foreach (string docTypeAndSub in rptGrp.DocumentTypesWithSubDocType) { if (!newOMConfig.DocumentTypesWithReportGroup.ContainsKey(docTypeAndSub)) { newOMConfig.DocumentTypesWithReportGroup.Add(docTypeAndSub, rptGrp.ReportGroupID); } } } foreach (OutputManagerService.Printer prt in omResult.Printers) { if (!newOMConfig.Printers.ContainsKey(prt.PrinterID)) { newOMConfig.Printers.Add(prt.PrinterID, new OutputManagerConfig.PrinterInfo() { PrinterID = prt.PrinterID, PrinterDeviceName = prt.PrinterDeviceName, PrinterType = prt.PrinterType }); } } foreach (OutputManagerService.PrinterAssociation prtAssoc in omResult.PrinterAssociations) { if (newOMConfig.Printers.ContainsKey(prtAssoc.PrinterID)) { OutputManagerConfig.PrinterInfo printerInfo = newOMConfig.Printers[prtAssoc.PrinterID]; if (!newOMConfig.TerGrp_RptGrp_PrtInfo.ContainsKey(prtAssoc.TerminalGroupID)) { newOMConfig.TerGrp_RptGrp_PrtInfo.Add(prtAssoc.TerminalGroupID, new Dictionary <string, OutputManagerConfig.PrinterInfo>()); } if (!newOMConfig.TerGrp_RptGrp_PrtInfo[prtAssoc.TerminalGroupID].ContainsKey(prtAssoc.ReportGroupID)) { newOMConfig.TerGrp_RptGrp_PrtInfo[prtAssoc.TerminalGroupID].Add(prtAssoc.ReportGroupID, printerInfo); } } } return(newOMConfig); } catch { iOK = false; } if (iOK) { break; } } return(null); }