internal void UpdateHconn(NmqiMQ mqInstance, Phconn phconn) { uint method = 0x2f9; this.TrEntry(method, new object[] { mqInstance, phconn }); try { this.MQI = mqInstance; Hconn hconn = null; switch (this.value_) { case -1: hconn = new HconnAdapter(-1); break; case 0: hconn = new HconnAdapter(0); break; default: hconn = this; if (this.qMgrInfo == null) { this.qMgrInfo = NmqiTools.GetQueueManagerInfo(base.env, mqInstance, this); } break; } phconn.HConn = hconn; } finally { base.TrExit(method); } }
public static byte[] StringToQmgrBytes(NmqiEnvironment env, Hconn hconn, string str, byte[] charAttrs, int offset, int length) { Encoding dotnetEncoding = MQCcsidTable.GetDotnetEncoding(hconn.Ccsid); byte[] bytes = dotnetEncoding.GetBytes(str); if (bytes.Length > length) { NmqiException exception = new NmqiException(env, -1, null, 2, 0x7d5, null); env.LastException = exception; throw exception; } if ((offset + length) > charAttrs.Length) { NmqiException exception2 = new NmqiException(env, -1, null, 2, 0x7d5, null); env.LastException = exception2; throw exception2; } for (int i = 0; i < bytes.Length; i++) { charAttrs[offset + i] = bytes[i]; } byte[] buffer2 = dotnetEncoding.GetBytes(" "); for (int j = bytes.Length; j < length; j++) { charAttrs[offset + j] = buffer2[0]; } return(bytes); }
public static UnmanagedHconn GetUnmanagedHconn(NmqiEnvironment env, object userWorkerThread, Hconn hconn) { if (hconn is UnmanagedHconn) { return((UnmanagedHconn)hconn); } if (hconn is HconnAdapter) { return(new UnmanagedHconn(env, userWorkerThread, 0)); } return(new UnmanagedHconn(env, userWorkerThread)); }
public static string QmgrBytesToString(Hconn hconn, byte[] charAttrs, int offset, int length) { return(MQCcsidTable.GetDotnetEncoding(hconn.Ccsid).GetString(charAttrs, offset, length).Trim()); }
public static QueueManagerInfo GetQueueManagerInfo(NmqiEnvironment env, NmqiMQ mq, Hconn hconn) { QueueManagerInfo info = env.NewQueueManagerInfo(); MQObjectDescriptor pObjDesc = env.NewMQOD(); pObjDesc.ObjectType = 5; int options = 0x20; Phobj pHobj = env.NewPhobj(); int pCompCode = 0; int pReason = 0; mq.MQOPEN(hconn, ref pObjDesc, options, pHobj, out pCompCode, out pReason); if (pReason == 0) { Hobj hOBJ = pHobj.HOBJ; int[] pSelectors = new int[] { 0x1f, 0x20, 2, 0x7df, 0x7f0 }; int[] pIntAttrs = new int[3]; byte[] pCharAttrs = new byte[0x60]; mq.MQINQ(hconn, hOBJ, pSelectors.Length, pSelectors, pIntAttrs.Length, pIntAttrs, pCharAttrs.Length, pCharAttrs, out pCompCode, out pReason); if (pReason == 0) { info.CommandLevel = pIntAttrs[0]; info.Platform = pIntAttrs[1]; info.Ccsid = pIntAttrs[2]; Encoding dotnetEncoding = MQCcsidTable.GetDotnetEncoding(info.Ccsid); info.Name = dotnetEncoding.GetString(pCharAttrs, 0, 0x30); info.Uid = dotnetEncoding.GetString(pCharAttrs, 0x30, 0x30); } else { NmqiException exception = new NmqiException(env, 0x253a, null, pCompCode, pReason, null); env.LastException = exception; throw exception; } mq.MQCLOSE(hconn, pHobj, 0, out pCompCode, out pReason); return(info); } NmqiException exception2 = new NmqiException(env, 0x2525, null, pCompCode, pReason, null); env.LastException = exception2; throw exception2; }
public static byte[] GetMessage(NmqiEnvironment env, NmqiSP sp, Hconn hconn, Hobj hobj, MQMessageDescriptor md, MQGetMessageOptions gmo, int expectedMsgLength, int maxMsgLength, byte[] buffer, int msgTooSmallForBufferCount, out int dataLength, out int compCode, out int reason) { int num = 0x1000; int num2 = 10; int num3 = (expectedMsgLength < 0) ? num : expectedMsgLength; num3 = Math.Min(num3, maxMsgLength); if ((buffer == null) || (buffer.Length < num3)) { buffer = new byte[num3]; } int encoding = md.Encoding; int ccsid = md.Ccsid; byte[] msgId = md.MsgId; byte[] correlId = md.CorrelId; int options = gmo.Options; bool callExitOnLenErr = false; int returnedLength = 0; int bufferLength = 0; byte[] buffer4 = null; dataLength = 0; compCode = 0; reason = 0; int num10 = 1; while (num10 != 0) { int num12; switch (num10) { case 1: bufferLength = Math.Min(buffer.Length, maxMsgLength); sp.NmqiGetMessage(hconn, hobj, md, gmo, bufferLength, buffer, out dataLength, out compCode, out reason); num12 = reason; if (num12 > 0x7da) { break; } switch (num12) { case 0: goto Label_0100; case 0x7da: goto Label_0108; } goto Label_01CC; case 2: { byte[] source = buffer; byte[] structure = new byte[bufferLength]; IntPtr zero = IntPtr.Zero; Marshal.StructureToPtr(structure, zero, false); Marshal.Copy(source, 0, zero, dataLength); buffer = structure; int availableLength = dataLength; if (!sp.NmqiConvertMessage(hconn, hobj, encoding, ccsid, options, callExitOnLenErr, md, buffer, out dataLength, availableLength, bufferLength, out compCode, out reason, out returnedLength)) { goto Label_0232; } num10 = 0; continue; } default: { continue; } } switch (num12) { case 0x820: { msgTooSmallForBufferCount = 0; if (dataLength >= maxMsgLength) { goto Label_019C; } if (bufferLength < dataLength) { bufferLength = Math.Min(dataLength, maxMsgLength); } else { bufferLength = Math.Min(bufferLength * 2, maxMsgLength); } buffer4 = new byte[bufferLength]; buffer = buffer4; md.Encoding = encoding; md.Ccsid = ccsid; md.MsgId = msgId; md.CorrelId = correlId; num10 = 1; continue; } case 0x848: case 0x88e: { msgTooSmallForBufferCount = 0; if (dataLength < maxMsgLength) { bufferLength = Math.Min(dataLength * 2, maxMsgLength); num10 = 2; } else { num10 = 0; } continue; } default: goto Label_01CC; } Label_0100: num10 = 0; continue; Label_0108: maxMsgLength = dataLength; md.Encoding = encoding; md.Ccsid = ccsid; md.MsgId = msgId; md.CorrelId = correlId; num10 = 1; continue; Label_019C: num10 = 0; continue; Label_01CC: num10 = 0; continue; Label_0232: switch (reason) { case 0: { num10 = 0; continue; } case 0x848: case 0x88e: { if (dataLength < maxMsgLength) { bufferLength = Math.Min(bufferLength * 2, maxMsgLength); num10 = 2; } else { num10 = 0; } continue; } } num10 = 0; } byte[] buffer7 = buffer; if ((compCode == 0) || (compCode == 1)) { if ((bufferLength > (dataLength * 2)) && (bufferLength > num)) { msgTooSmallForBufferCount++; } else { msgTooSmallForBufferCount = 0; } if (msgTooSmallForBufferCount > num2) { buffer = null; msgTooSmallForBufferCount = 0; } } return(buffer7); }
public static BindingsHconn GetBindingsHconn(NmqiEnvironment env, object userWorkerThread, Hconn hconn) { if (hconn is BindingsHconn) { return((BindingsHconn)hconn); } if (hconn is HconnAdapter) { return(new BindingsHconn(env, userWorkerThread, 0)); } return(new BindingsHconn(env, userWorkerThread)); }
public Phconn(NmqiEnvironment env) { base.TrConstructor("%Z% %W% %I% %E% %U%", new object[] { env }); this.hconn = null; }