public ReturnInfo(ReturnCode code = ReturnCode.Unknown, string msg = null, object data = null) { if (data is ReturnCode) { Code = (ReturnCode)data; Message = Code.ToString(); Data = null; } else if (data is Exception) { Exception x = (Exception)data; Code = ReturnCode.Exception; Message = x.Message; Data = x.InnerException; } else if (data != null && code == ReturnCode.Unknown && string.IsNullOrEmpty(msg)) { Code = ReturnCode.Success; Message = Code.ToString(); Data = data; } else { Code = code; Message = msg ?? code.ToString(); Data = data; } }
public bool IsReturn() { switch (ReturnCode) { case ReturnCodes.Error: { return(true); } case ReturnCodes.Ok: { return(false); } case ReturnCodes.Exit: { return(true); } case ReturnCodes.Done: { return(true); } default: { throw new UnknownReturnCode(ReturnCode.ToString()); } } }
// Update is called once per frame - call Framework's BeckonManager update method void Update() { if (m_isInitilzed) { HandleInput(); if (!m_sequenceEnded) { ReturnCode rc = BeckonManager.BeckonInstance.UpdateStates(out m_hasNewImage); if (rc.IsError()) { if (rc.SDKReturnCode == Omek.OMKStatus.OMK_ERROR_SEQUENCE_EOF_REACHED || rc.SDKReturnCode == Omek.OMKStatus.OMK_ERROR_ASSERTION_FAILURE) { m_sequenceEnded = true; m_hasNewImage = false; Debug.LogWarning(new ReturnCode(Omek.OMKStatus.OMK_ERROR_SEQUENCE_EOF_REACHED).ToString()); } else { Debug.LogError(rc.ToString()); if (rc.FrameworkReturnCode == ReturnCode.FrameworkReturnCodes.Sensor_Not_Initialized) { m_isInitilzed = false; } return; } } } } }
private void GameOver() { facade.GameOver(); gameOverTimer += Time.deltaTime; gameOverText.transform.parent.GetComponent <Image>().raycastTarget = true; if (gameOverTimer < 2) { gameOverText.text = "GameOver"; gameOverText.color = gameOver; } else if (gameOverTimer < 4) { switch (returnCode) { case ReturnCode.Win: facade.PlaySound("Win"); gameOverText.color = win; break; case ReturnCode.Lose: facade.PlaySound("Lose"); gameOverText.color = lose; break; } gameOverText.text = returnCode.ToString(); } else { closeButton.gameObject.SetActive(true); } }
internal static OperationResponse CreateNegativeResponse(OperationRequest operationRequest, ReturnCode returnCode) { return(new OperationResponse(operationRequest.OperationCode) { ReturnCode = (short)returnCode, DebugMessage = returnCode.ToString() + ": " + operationRequest.OperationCode.ToString() }); }
public static Response <TResponse> BuildResponse(TResponse data, bool success = true, ReturnCode returnCode = ReturnCode.Success, string returnMessage = "Success") { return(new Response <TResponse>() { Data = data, Success = success, ReturnCode = returnCode, ReturnMessage = returnMessage, ReturnCodeString = returnCode.ToString() }); }
public bool ReinitSensor() { if (m_isInitilzed == false) { ReturnCode rc = BeckonManager.BeckonInstance.DestroySensor(); if (rc.IsError()) { Debug.LogError(rc.ToString()); } m_isInitilzed = CreateSensor(); } return(m_isInitilzed); }
public SharedQueue(string name, UInt32 averageItemSize) { if (averageItemSize > UInt32.MaxValue) { throw new ArgumentOutOfRangeException("averageItemSize", "Maximum value is" + int.MaxValue.ToString()); } if (averageItemSize > (int.MaxValue - headerSize)) { buffer = new byte[int.MaxValue]; } else { buffer = new byte[averageItemSize + headerSize]; } bufferLength = (UInt32)buffer.Length; ReturnCode rc = NativeMethods.JoinMemoryMgr(name, ref commBuffer); if (rc != ReturnCode.Success) { if (rc == ReturnCode.InvalidArgument) { throw new ArgumentException("Invalid argument value", "name"); } else { if (rc == ReturnCode.QueueNameDoesNotExist) { throw new SharedQueueDoesNotExistException("Queue name does not exist"); } else { throw new SharedQueueInitializationException("(HRESULT:" + rc.ToString() + ") SharedQueue failed to initialize"); } } } if (averageItemSize > QueueSize) { try { NativeMethods.ReleaseMemoryMgr(ref commBuffer); } finally { throw new ArgumentOutOfRangeException("averageItemSize", "Value must not exceed the queue size"); } } }
private void WriteXml(XmlTextWriter xmlWriter) { WriteStart(xmlWriter, RootName, "1.0"); if (WriteReturnCode) { xmlWriter.WriteElementString("ReturnCode", ReturnCode.ToString()); } if (ReturnCode != XmlReturnCode.Failure && _xml != null) { xmlWriter.WriteRaw(_xml); } WriteErrors(xmlWriter); WriteEnd(xmlWriter); }
public SharedQueue(string name, UInt32 size, UInt32 averageItemSize) { if (size < 1000) { throw new ArgumentOutOfRangeException("size", "Minimum value is 1000"); } if (averageItemSize > (Int32.MaxValue - headerSize)) { throw new ArgumentOutOfRangeException("averageItemSize", "Maximum value is " + (Int32.MaxValue - headerSize).ToString()); } if (averageItemSize > (size - headerSize)) { throw new ArgumentOutOfRangeException("averageItemSize", "Value must not exceed the queue size"); } if (averageItemSize > (UInt32)(int.MaxValue - headerSize)) { buffer = new byte[int.MaxValue]; } else { buffer = new byte[averageItemSize + headerSize]; } bufferLength = (UInt32)buffer.Length; ReturnCode rc = NativeMethods.InitMemoryMgr(name, size, ref commBuffer); if (rc != ReturnCode.Success) { if (rc == ReturnCode.InvalidArgument) { throw new ArgumentException("Invalid argument value", "name"); } else { if (rc == ReturnCode.InsufficientMemory) { throw new SharedQueueInsufficientMemoryException("(HRESULT:" + rc.ToString() + ") Insufficient memory to allocate the event queue"); } else { throw new SharedQueueInitializationException("(HRESULT:" + rc.ToString() + ") SharedQueue failed to initialize"); } } } }
public override string ToString() { return ("ReturnCode:\t " + ReturnCode.ToString() + "\r" + "Message:\t" + Message + "\r" + "FoundTag:\t" + FoundTag.ToString() + "\r" + "SelfClosing:\t" + SelfClosing.ToString() + "\r" + "HtmlEnd:\t" + HtmlEnd.ToString() + "\r" + "TagName:\t" + TagName + "\r" + "HtmlInner:\t" + HtmlInner + "\r" + "HtmlOuter:\t" + HtmlOuter + "\r" + "Html:\t" + Html + "\r" + "SelfClosing:\t" + SelfClosing.ToString() ); }
/// <summary> /// Gets the resx key defined in the <see cref="ResxKeyAttribute"/> on the provided <see cref="ReturnCode"/> /// </summary> /// <param name="code">The <see cref="ReturnCode"/></param> /// <returns>The resx key associated with this <see cref="ReturnCode"/></returns> public static string GetResxKey(this ReturnCode code) { string key = null; Type t = code.GetType(); MemberInfo[] members = t.GetMember(code.ToString()); if (members.Length == 1) { object[] attrs = members[0].GetCustomAttributes(typeof(ResxKeyAttribute), false); if (attrs.Length == 1) { key = ((ResxKeyAttribute)attrs[0]).Key; } } return(key); }
private static void TestOnInconsistentTopic() { DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory(); DomainParticipant participant = dpf.CreateParticipant(RTPS_DOMAIN); if (participant == null) { throw new ApplicationException("Failed to create the participant."); } BindRtpsUdpTransportConfig(participant); Subscriber subscriber = participant.CreateSubscriber(); if (subscriber == null) { throw new ApplicationException("Failed to create the subscriber."); } AthleteTypeSupport support = new AthleteTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(participant, typeName); if (result != ReturnCode.Ok) { throw new ApplicationException("Failed to register the type." + result.ToString()); } Topic topic = participant.CreateTopic(nameof(TestOnInconsistentTopic), typeName); if (topic == null) { throw new ApplicationException("Failed to create the topic."); } DataReader reader = subscriber.CreateDataReader(topic); if (reader == null) { throw new ApplicationException("Failed to create the reader."); } while (true) { System.Threading.Thread.Sleep(100); } }
private static void TestOnSubscriptionLostDisconnected() { DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory(); DomainParticipant participant = dpf.CreateParticipant(INFOREPO_DOMAIN); if (participant == null) { throw new ApplicationException("Failed to create the participant."); } BindTcpTransportConfig(participant); Publisher publisher = participant.CreatePublisher(); if (publisher == null) { throw new ApplicationException("Failed to create the publisher."); } TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(participant, typeName); if (result != ReturnCode.Ok) { throw new ApplicationException("Failed to register the type." + result.ToString()); } Topic topic = participant.CreateTopic("TestOnSubscriptionLostDisconnected", typeName); if (topic == null) { throw new ApplicationException("Failed to create the topic."); } DataWriter writer = publisher.CreateDataWriter(topic); if (writer == null) { throw new ApplicationException("Failed to create the writer."); } while (true) { System.Threading.Thread.Sleep(100); } }
private void ApplicationAck(long id) { if (Flow == null) { return; } if (Flow.Properties.AckMode != MessageAckMode.AutoAck) { ReturnCode rc = Flow.Ack(id); if (rc != ReturnCode.SOLCLIENT_IN_PROGRESS && rc != ReturnCode.SOLCLIENT_OK) { throw new MessagingException("Ack failure: " + rc.ToString()); } } else { logger.LogDebug("Application tried to ack a message but the flow has AutoAck enabled."); } }
public byte[] Dequeue(UInt32 timeout) { ReturnCode rc = ReturnCode.Timeout; UInt32 bytesRead = 0; byte[] returnBuffer; try { rc = NativeMethods.GetBuffer(buffer, bufferLength, timeout, ref bytesRead, ref commBuffer); if (rc == ReturnCode.Timeout || bytesRead == 0) { return(null); } if (rc == ReturnCode.Overflow) { buffer = new byte[bytesRead + headerSize]; bufferLength = (UInt32)buffer.Length; rc = NativeMethods.GetBuffer(buffer, bufferLength, timeout, ref bytesRead, ref commBuffer); } if (rc != ReturnCode.Success) { throw new SharedQueueException("(HRESULT:" + rc.ToString() + ") Dequeue failed"); } returnBuffer = new byte[bytesRead]; Buffer.BlockCopy(buffer, 0, returnBuffer, 0, (int)bytesRead); return(returnBuffer); } catch (Exception) { throw; } }
private bool CreateSensor() { //Debug.Log("m_currentConf " + m_currentConf.SequencePath); ReturnCode rc = BeckonManager.BeckonInstance.CreateSensor(m_currentConf); if (rc.IsError()) { Debug.LogError("CreateSensor failed: " + rc); return(false); } if (m_currentConf.UseRunSensor) { rc = new ReturnCode(BeckonManager.BeckonInstance.Analyzer.runTrackingThread()); if (rc.IsError()) { Debug.LogError(rc.ToString()); return(false); } } return(true); }
/////////////////////////////////////////////////////////////////////// #region Internal Methods internal string ToTraceString() { IStringList list = new StringPairList(); list.Add("debug", debug.ToString()); list.Add("args", FormatOps.WrapArgumentsOrNull(true, true, args)); list.Add("code", code.ToString()); list.Add("breakpointType", breakpointType.ToString()); list.Add("breakpointName", FormatOps.WrapOrNull(breakpointName)); list.Add("token", (token != null).ToString()); list.Add("traceInfo", (traceInfo != null).ToString()); list.Add("engineFlags", FormatOps.WrapOrNull(engineFlags)); list.Add("substitutionFlags", FormatOps.WrapOrNull(substitutionFlags)); list.Add("eventFlags", FormatOps.WrapOrNull(eventFlags)); list.Add("expressionFlags", FormatOps.WrapOrNull(expressionFlags)); list.Add("headerFlags", FormatOps.WrapOrNull(headerFlags)); list.Add("clientData", FormatOps.WrapOrNull(clientData)); list.Add("arguments", FormatOps.WrapOrNull(true, true, arguments)); list.Add("exit", exit.ToString()); return(list.ToString()); }
public static void Build() { Clear(); var Mods = ModsEditor.GetMods(); int length = Mods.Length; for (int i = 0; i < length; i++) { var ModInfo = ModsEditor.GetModInfo(Mods[i]); var ModOutPutFolder = OutPutFolder + "/" + ModInfo.PackageName; Directory.CreateDirectory(ModOutPutFolder); //生成ModInfo文件 using (StreamWriter sw = File.CreateText(ModOutPutFolder + "/" + ModInfo.PackageName + ".json")) { sw.Write(JsonConvert.SerializeObject(ModInfo)); } //Windows64版本构建 //构建参数 var param = new BundleBuildParameters(BuildTarget.StandaloneWindows64, BuildTargetGroup.Standalone, ModOutPutFolder); param.BundleCompression = BuildCompression.LZ4; //填入资源 var content = new BundleBuildContent(new AssetBundleBuild[] { GetAllAssets(ModInfo, "winmod") }); IBundleBuildResults results; //构建包 ReturnCode code = ContentPipeline.BuildAssetBundles(param, content, out results); if (code != ReturnCode.Success) { if (code == ReturnCode.Canceled) { return;//如果取消,直接返回 } Debug.LogError("构建失败!错误原因:" + code.ToString()); } } }
public void ReadInitDataSynch(int clientSubscriptionIndex) { //turn dynamic list into array used to subscribe to items itemIdentifiers = _itemIdentifiers.ToArray(); //create return code for subscription result Kepware.ClientAce.OpcDaClient.ReturnCode returnCode; returnCode = new ReturnCode(); // Transaction Handle Is the PLC's Index 1 Based So Must Decrement By 1 int idx = clientSubscriptionIndex - 1; int index = 0; if (_itemIdentifiers.Count != 0) { try { //temporarily use Synchronous Read. Calls the normal Callback Handler ItemValue[] itemValues; returnCode = clientAce.DAServer.Read(0, ref itemIdentifiers, out itemValues); //set initial value read to true for each plc and record if (IDCService.IDCConfig.model.plcs[idx].initDataReceived != true) { IDCService.IDCConfig.model.plcs[idx].initDataReceived = true; logger.Debug("Initial data received for PLC: {0}", IDCService.IDCConfig.model.plcs[idx].name); } if (returnCode.ToString() != "SUCCEEDED") { logger.Error("DAServer.Read error: ReturnCode: {0} for PLC: {1}", returnCode, IDCService.IDCConfig.model.plcs[idx].name); } if (itemValues != null) { foreach (ItemValue itemValue in itemValues) { //write values to items within plc. //clientSubscriptionIndex - PLC index //index - item index within PLC if (itemValue.Value != null & itemValue.Quality != null & itemValue.TimeStamp != null) { IDCService.IDCConfig.model.plcs[idx].opcliitems[index].value = itemValue.Value; IDCService.IDCConfig.model.plcs[idx].opcliitems[index].quality = itemValue.Quality.Quality; IDCService.IDCConfig.model.plcs[idx].opcliitems[index].timestamp = itemValue.TimeStamp; } else { logger.Error("ItemVlaue Read returned null values for opccliitem: {0}", IDCService.IDCConfig.model.plcs[idx].opcliitems[index].name); } index++; } } } catch (Exception ex) { logger.Error("ReadInitDataSynch exception. Reason: {0}, PLC: {1}", ex.Message, IDCService.IDCConfig.model.plcs[idx].name); } } else { logger.Info("There were no items to be initially read."); } }
/// <summary> /// Connects to Solace. Ignores call if already connected. /// </summary> /// <param name="config">The configuration to establish a Solace connection</param> public void Connect() { if (_state == CommunicationState.Opened || _state == CommunicationState.Opening) { log.Debug("Ignoring call - the Solace transport channel is in state: " + _state.ToString()); return; } // Indicate we are opening this._state = CommunicationState.Opening; log.Debug("Connecting to Solace"); try { // Context & Session Properties var contextProps = new ContextProperties(); SessionProperties sessionProps = new SessionProperties(); sessionProps.Host = this._config.SessionHost; sessionProps.VPNName = this._config.SessionVpnName; sessionProps.UserName = this._config.SessionUsername; sessionProps.Password = this._config.SessionPassword; sessionProps.ClientName = this._config.SessionClientName; sessionProps.ClientDescription = this._config.SessionClientDescription; sessionProps.ConnectRetries = this._config.SessionConnectRetries; sessionProps.ConnectTimeoutInMsecs = this._config.SessionConnectTimeoutInMsecs; sessionProps.ReconnectRetries = this._config.SessionReconnectRetries; sessionProps.ReconnectRetriesWaitInMsecs = this._config.SessionReconnectRetriesWaitInterval; sessionProps.ReapplySubscriptions = true; // Context _context = ContextFactory.Instance.CreateContext(contextProps, null); // Session _session = _context.CreateSession(sessionProps, HandleMessageEvent, HandleSessionEvent); // Connect ReturnCode rc = _session.Connect(); if (rc != ReturnCode.SOLCLIENT_OK) { // throw exception to caller throw new Exception("Unable to connect Solace session. Solace ReturnCode: " + rc.ToString()); } // Update state this._state = CommunicationState.Opened; log.InfoFormat("Service is connected to Solace on: {0}", this._config.SessionHost); } catch (OperationErrorException ex) { throw new Exception("Unable to connect Solace session. See inner exception for details.", ex); } }
private static Topic CreateTestTopic(DomainParticipant participant) { TestStructTypeSupport typeSupport = new TestStructTypeSupport(); string typeName = typeSupport.GetTypeName(); ReturnCode ret = typeSupport.RegisterType(participant, typeName); if (ret != ReturnCode.Ok) { throw new ApplicationException("TestStructTypeSupport could not be registered: " + ret.ToString()); } Topic topic = participant.CreateTopic("TestTopic", typeName); if (topic == null) { throw new ApplicationException("Topic could not be created."); } return(topic); }
public static void BuildAll() { Clear(); var Mods = ModsEditor.GetMods(); int length = Mods.Length; for (int i = 0; i < length; i++) { var ModInfo = ModsEditor.GetModInfo(Mods[i]); var ModOutPutFolder = OutPutFolder + "/" + ModInfo.PackageName; //Windows64版本构建 //构建参数 var param = new BundleBuildParameters(BuildTarget.StandaloneWindows64, BuildTargetGroup.Standalone, ModOutPutFolder); param.BundleCompression = BuildCompression.LZ4; //填入资源 var content = new BundleBuildContent(new AssetBundleBuild[] { GetAllAssets(ModInfo, "winmod") }); IBundleBuildResults results; //构建包 ReturnCode code = ContentPipeline.BuildAssetBundles(param, content, out results); if (code != ReturnCode.Success) { if (code == ReturnCode.Canceled) { return;//如果取消,直接返回 } Debug.LogError("构建失败!错误原因:" + code.ToString()); } //OSX版本构建 //构建参数 param.Target = BuildTarget.StandaloneOSX; //填入资源 content = new BundleBuildContent(new AssetBundleBuild[] { GetAllAssets(ModInfo, "osxmod") }); results = null; //构建包 code = ContentPipeline.BuildAssetBundles(param, content, out results); if (code != ReturnCode.Success) { if (code == ReturnCode.Canceled) { return;//如果取消,直接返回 } Debug.LogError("构建失败!错误原因:" + code.ToString()); } //Linux版本构建 //构建参数 param.Target = BuildTarget.StandaloneLinux64; //填入资源 content = new BundleBuildContent(new AssetBundleBuild[] { GetAllAssets(ModInfo, "linuxmod") }); results = null; //构建包 code = ContentPipeline.BuildAssetBundles(param, content, out results); if (code != ReturnCode.Success) { if (code == ReturnCode.Canceled) { return;//如果取消,直接返回 } Debug.LogError("构建失败!错误原因:" + code.ToString()); } //Android版本构建 //构建参数 param.Target = BuildTarget.Android; param.Group = BuildTargetGroup.Android; //填入资源 content = new BundleBuildContent(new AssetBundleBuild[] { GetAllAssets(ModInfo, "androidmod") }); results = null; //构建包 code = ContentPipeline.BuildAssetBundles(param, content, out results); if (code != ReturnCode.Success) { if (code == ReturnCode.Canceled) { return;//如果取消,直接返回 } Debug.LogError("构建失败!错误原因:" + code.ToString()); } //ios版本构建 //构建参数 param.Target = BuildTarget.iOS; param.Group = BuildTargetGroup.iOS; //填入资源 content = new BundleBuildContent(new AssetBundleBuild[] { GetAllAssets(ModInfo, "iosmod") }); results = null; //构建包 code = ContentPipeline.BuildAssetBundles(param, content, out results); if (code != ReturnCode.Success) { if (code == ReturnCode.Canceled) { return;//如果取消,直接返回 } Debug.LogError("构建失败!错误原因:" + code.ToString()); } //生成ModInfo文件 ModInfo = ModsEditor.GetModInfo(Mods[i]);//由于构建后资源会被释放,这里需要重载 using (FileStream fs = File.Create(ModOutPutFolder + "/" + ModInfo.PackageName + ".json")) { StreamWriter sw = new StreamWriter(fs); sw.Write(JsonConvert.SerializeObject(ModInfo)); sw.Dispose(); } } }
static int exit(ReturnCode code, string message) { string errmsg = PROGNAME + ": " + message + "\n"; errmsg += "Try " + PROGNAME + " --help for usage information."; Console.WriteLine(errmsg); AnalyticsWrapper.Telemetry.TrackEvent(string.Format("[ReturnCode] {0} : {1}", code.ToString(), message)); AnalyticsWrapper.Telemetry.EndSession(); //End Telemetry session and force data sending return((int)code); }
internal OpenCLException(ReturnCode code) : base("OpenCL error: " + code.ToString()) { ReturnCode = code; }
public void GetResponse(out string response) { ReturnCode responseCode = ReturnCode.VmsValidationSuccessful; response = string.Empty; long financialTransactionId = 0; try { InitParameters(_data); } catch (Exception ex) { HandleError(string.Format("System Error occured while initializing 'PP_01_ConsumeVoucher' command.\r\n" + "The error encountered was: '{0}'", ex.Message), ex); responseCode = ReturnCode.IbsCiSystemError; response = responseCode.ToString(); return; } TraceInformation(string.Format("'PP_01_ConsumeVoucher' command for voucher ticket number '{0}' has been successfully initialized.", _voucherTicketNumber)); string vmsResponseString = string.Empty; try { // Call the VMS WebService vmsResponseString = VmsConsumeVoucher(); } catch (Exception ex) { HandleError(string.Format("Error Communicating with VMS web service occured while processing 'PP_01_ConsumeVoucher' message for voucher ticket number '{0}'.\r\n" + "The error encountered was: '{1}'", _voucherTicketNumber, ex.Message), ex); responseCode = ReturnCode.IbsCiVmsCommunicationFailure; response = responseCode.ToString(); return; } VmsReturnCode vmsResponse = VmsReturnCode.Y; try { vmsResponse = (VmsReturnCode)Enum.Parse(typeof(VmsReturnCode), vmsResponseString, true); } catch (Exception ex) { HandleError(string.Format("VMS web service returned unexpected returncode '{0}' while processing 'PP_01_ConsumeVoucher' message for voucher ticket number '{1}'.\r\n" + "The error encountered was: '{2}'", vmsResponseString, _voucherTicketNumber, ex.Message), ex); responseCode = ReturnCode.IbsCiUnknownVMSResponse; response = responseCode.ToString(); return; } responseCode = (ReturnCode)vmsResponse; if (responseCode != ReturnCode.VmsValidationSuccessful) { string message = string.Format("VMS web service returned error code '{0} ({1})' while processing 'PP_01_ConsumeVoucher' message for voucher ticket number '{2}'.\r\n", vmsResponseString, responseCode.ToString(), _voucherTicketNumber); // 2010.12.01 IBSO 19840 - JCopus - Per this issue BBCL requests that we handle the returned // error code 'C (VmsVoucherAlreadyConsumed)' as a Warning instead of an error. if (vmsResponseString == "C") { HandleWarning(message, null); } else { HandleError(message, null); } response = responseCode.ToString(); } else if (_voucherAmount == 0m) { HandleError(string.Format("VMS web service returned unexpected returncode '{0}' while processing 'PP_01_ConsumeVoucher' message for voucher ticket number '{1}'.\r\n" + "The error encountered was: '{2}'", vmsResponseString, _voucherTicketNumber, "Voucher Amount can not be 0."), null); responseCode = ReturnCode.IbsCiUnknownVMSResponse; response = responseCode.ToString(); } else // VMS Communication Successfull so Proceed { TraceInformation(string.Format("'PP_01_ConsumeVoucher' worker for voucher ticket number '{0}' has successfully received '{1}' return code from VMS web service.", _voucherTicketNumber, vmsResponseString)); TraceInformation(string.Format("'PP_01_ConsumeVoucher' worker for voucher ticket number '{0}' information:\r\n" + "Prepaid voucher number '{0}' successfuly consumed by VMS System.", _voucherTicketNumber)); // Create manual (prepay) financial transaction in IBS try { FinancialTransaction financialTransaction = CreatePrepayFinancialTransaction(); if (financialTransaction == null) { throw new IntegrationException("Unable to determine Financial Transaction ID from IBS CreatePaymentTransactions() call."); } financialTransactionId = financialTransaction.Id.Value; TraceInformation(string.Format("'PP_01_ConsumeVoucher' worker for voucher ticket number '{0}' information:\r\n" + "Manual financial transaction for prepaid voucher number '{0}' has been created and successfully uploaded to IBS.", _voucherTicketNumber)); responseCode = ReturnCode.VmsValidationSuccessful; } catch (Exception ex) { HandleError(string.Format("Error occured while creating or uploading a manual financial transaction for prepaid voucher number '{0}' while processing 'PP_01_ConsumeVoucher' message for voucher ticket number '{0}'.\r\n" + "The error encountered was: '{1}'", _voucherTicketNumber, ex.Message), ex); responseCode = ReturnCode.IbsCiIBSCommunicationFailure; } response = string.Format("{0}|{1}", financialTransactionId, responseCode); } }
private void btn_auth_Click(object sender, EventArgs e) { byte AuthSource = 0xFF; byte BlockNo; byte ReturnCode; byte[] Key = new byte[6]; BlockNo = byte.Parse(cmb_AuthBlockNo.Text); //The following Key will be used only if Provided Key option is selected. Key[0] = byte.Parse(t_K1.Text, System.Globalization.NumberStyles.HexNumber); Key[1] = byte.Parse(t_K2.Text, System.Globalization.NumberStyles.HexNumber); Key[2] = byte.Parse(t_K3.Text, System.Globalization.NumberStyles.HexNumber); Key[3] = byte.Parse(t_K4.Text, System.Globalization.NumberStyles.HexNumber); Key[4] = byte.Parse(t_K5.Text, System.Globalization.NumberStyles.HexNumber); Key[5] = byte.Parse(t_K6.Text, System.Globalization.NumberStyles.HexNumber); //Mifare Default Key? if (rdb_MDefault.Checked == true) { AuthSource = (byte)sm_mifare_lib.ASource.KeyMifareDefault; } //Provided Key? if (rdb_PKey.Checked == true) { if (rdb_KeyA.Checked == true) { AuthSource = (byte)sm_mifare_lib.ASource.KeyTypeA; } if (rdb_KeyB.Checked == true) { AuthSource = (byte)sm_mifare_lib.ASource.KeyTypeB; } //Keys were previosly loaded above. } //E2Prom Key (Internal SOurce) ? if (rdb_E2prom.Checked == true) { if (rdb_KeyA.Checked == true) { AuthSource = sm_mifare_lib.mifare.E2promKeyA[cmb_E2promBlockNo.SelectedIndex]; } else if (rdb_KeyB.Checked == true) { AuthSource = sm_mifare_lib.mifare.E2promKeyB[cmb_E2promBlockNo.SelectedIndex]; } } //Authenticate if (sm132.CMD_Authenticate(AuthSource, Key, BlockNo, out ReturnCode)) { textBox1.Text = " Authentication Success "; textBox_S.Text = textBox1.Text; } else { if (ReturnCode == 0x4E) //'N' { textBox1.Text = "No Tag or Login failed. Error Code:" + ReturnCode.ToString("X2"); } else if (ReturnCode == 0x55) { textBox1.Text = "Login failed. Error Code:" + ReturnCode.ToString("X2"); } else if (ReturnCode == 0x45) { textBox1.Text = "Invalid Key Format. Error Code:" + ReturnCode.ToString("X2"); } else if (ReturnCode == 0) { textBox1.Text = "Communication Error. Error Code:" + ReturnCode.ToString("X2"); } else { textBox1.Text = "Unknown Error. Error Code:" + ReturnCode.ToString("X2"); } textBox_S.Text = textBox1.Text; } }
private static void TestPublisher(DomainParticipant participant) { Console.WriteLine("Starting applicattion as Publisher..."); Publisher publisher = participant.CreatePublisher(); if (publisher == null) { throw new ApplicationException("Publisher could not be created."); } Topic topic = CreateTestTopic(participant); DataWriterQos qos = new DataWriterQos(); qos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; DataWriter dw = publisher.CreateDataWriter(topic, qos); if (dw == null) { throw new ApplicationException("DataWriter could not be created."); } TestStructDataWriter dataWriter = new TestStructDataWriter(dw); Console.WriteLine("Waiting for the subscriber..."); bool wait = WaitForSubscriptions(dw, 1, 60000); if (wait) { Console.WriteLine("Subscription found. Sending test data with default values..."); TestStruct data = new TestStruct(); dataWriter.Write(data); ReturnCode ret = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 60, NanoSeconds = 0, }); if (ret == ReturnCode.Ok) { Console.WriteLine("Data sent and acknowledged."); } else { Console.WriteLine("No acknowledge received: " + ret.ToString()); return; } Console.WriteLine("Subscription found. Sending test data with custom values..."); data = new TestStruct { ShortField = -1, LongField = -2, LongLongField = -3, UnsignedShortField = 1, UnsignedLongField = 2, UnsignedLongLongField = 3, BooleanField = true, CharField = 'C', WCharField = 'W', FloatField = 42.42f, DoubleField = 0.42, //LongDoubleField = 0.4242m, OctetField = 0x42, UnboundedStringField = "Unbounded string field.", UnboundedWStringField = "Unbounded WString field.", BoundedStringField = "Bounded string field.", BoundedWStringField = "Bounded WString field.", BoundedBooleanSequenceField = { true, true, false }, UnboundedBooleanSequenceField = { true, true, false, true, true, false }, BoundedCharSequenceField = { '1', '2', '3', '4', '5' }, UnboundedCharSequenceField = { '1', '2', '3', '4', '5', '6' }, BoundedWCharSequenceField = { '1', '2', '3', '4', '5' }, UnboundedWCharSequenceField = { '1', '2', '3', '4', '5', '6' }, BoundedOctetSequenceField = { 0x42, 0x69 }, UnboundedOctetSequenceField = { 0x42, 0x69, 0x42, 0x69, 0x42, 0x69 }, BoundedShortSequenceField = { 1, 2, 3, 4, 5 }, UnboundedShortSequenceField = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }, BoundedUShortSequenceField = { 1, 2, 3, 4, 5 }, UnboundedUShortSequenceField = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }, BoundedLongSequenceField = { 1, 2, 3, 4, 5 }, UnboundedLongSequenceField = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }, BoundedULongSequenceField = { 1, 2, 3, 4, 5 }, UnboundedULongSequenceField = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }, BoundedLongLongSequenceField = { 1, 2, 3, 4, 5 }, UnboundedLongLongSequenceField = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }, BoundedULongLongSequenceField = { 1, 2, 3, 4, 5 }, UnboundedULongLongSequenceField = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }, BoundedFloatSequenceField = { 0.42f, 42.42f, 1f, 2f, 3f }, UnboundedFloatSequenceField = { 0.42f, 42.42f, 1f, 2f, 3f, 0.42f, 42.42f, 1f, 2f, 3f }, BoundedDoubleSequenceField = { 0.42, 42.42, 1, 2, 3 }, UnboundedDoubleSequenceField = { 0.42, 42.42, 1, 2, 3, 0.42, 42.42, 1, 2, 3 }, BoundedStringSequenceField = { "This", "is", "the", "end." }, BoundedWStringSequenceField = { "This", "is", "the", "end." }, UnboundedStringSequenceField = { "This", "is", "the", "end.", "This", "is", "the", "end." }, UnboundedWStringSequenceField = { "This", "is", "the", "end.", "This", "is", "the", "end." }, NestedStructField = { Id = 1, Message = "This is the end." }, BoundedStructSequenceField = { new NestedStruct { Id = 1, Message = "This is the end." }, new NestedStruct { Id = 2, Message = "my only friend, the end." } }, UnboundedStructSequenceField = { new NestedStruct { Id = 1, Message = "This is the end." }, new NestedStruct{ Id = 2, Message = "my only friend, the end." } }, TestEnumField = TestEnum.ENUM12, BoundedEnumSequenceField = { TestEnum.ENUM1, TestEnum.ENUM2, TestEnum.ENUM3, TestEnum.ENUM4, TestEnum.ENUM5 }, UnboundedEnumSequenceField = { TestEnum.ENUM1, TestEnum.ENUM2, TestEnum.ENUM3, TestEnum.ENUM4, TestEnum.ENUM5, TestEnum.ENUM6, TestEnum.ENUM7, TestEnum.ENUM8, TestEnum.ENUM9, TestEnum.ENUM10, TestEnum.ENUM11, TestEnum.ENUM12 }, ShortArrayField = new short[] { 1, -2, 3, -4, 5 }, UnsignedShortArrayField = new ushort[] { 1, 2, 3, 4, 5 }, LongArrayField = new int[] { 1, -2, 3, -4, 5 }, UnsignedLongArrayField = new uint[] { 1, 2, 3, 4, 5 }, LongLongArrayField = new long[] { 1, -2, 3, -4, 5 }, UnsignedLongLongArrayField = new ulong[] { 1, 2, 3, 4, 5 }, CharArrayField = new char[] { 'A', 'B', 'C', 'D', 'E' }, WCharArrayField = new char[] { 'A', 'B', 'C', 'D', 'E' }, BooleanArrayField = new bool[] { true, true, false, true, true }, OctetArrayField = new byte[] { 0x42, 0x42, 0x69, 0x42, 0x42 }, FloatArrayField = new float[] { 0.42f, 0.4242f, 1f, 2f, 3f }, DoubleArrayField = new double[] { 0.42, 0.4242, 1, 2, 3 }, StringArrayField = new string[] { "This", "is", "the", "end", "my only friend, the end." }, WStringArrayField = new string[] { "This", "is", "the", "end", "my only friend, the end." }, EnumArrayField = new TestEnum[] { TestEnum.ENUM1, TestEnum.ENUM2, TestEnum.ENUM3, TestEnum.ENUM4, TestEnum.ENUM5 }, StructArrayField = new NestedStruct[] { new NestedStruct { Id = 1, Message = "This is the end." }, new NestedStruct { Id = 2, Message = "This is the end." }, new NestedStruct { Id = 3, Message = "This is the end." }, new NestedStruct { Id = 4, Message = "This is the end." }, new NestedStruct { Id = 5, Message = "This is the end." }, }, ShortMultiArrayField = new short[, , ] { { { -01, -02 }, { -03, -04 }, { -05, -06 }, { -07, -08 }, }, { { -09, -10 }, { -11, -12 }, { -13, -14 }, { -15, -16 }, }, { { -17, -18 }, { -19, -20 }, { -21, -22 }, { -23, -24 }, } }, UnsignedShortMultiArrayField = new ushort[, , ] { { { 01, 02 }, { 03, 04 }, { 05, 06 }, { 07, 08 }, }, { { 09, 10 }, { 11, 12 }, { 13, 14 }, { 15, 16 }, }, { { 17, 18 }, { 19, 20 }, { 21, 22 }, { 23, 24 }, } }, LongMultiArrayField = new[, , ] { { { -01, 02 }, { -03, 04 }, { -05, 06 }, { -07, 08 }, }, { { -09, 10 }, { -11, 12 }, { -13, 14 }, { -15, 16 }, }, { { -17, 18 }, { -19, 20 }, { -21, 22 }, { -23, 24 }, } }, UnsignedLongMultiArrayField = new[, , ] { { { 25U, 26U }, { 27U, 28U }, { 29U, 30U }, { 31U, 32U }, }, { { 33U, 34U }, { 35U, 36U }, { 37U, 38U }, { 39U, 40U }, }, { { 41U, 42U }, { 43U, 44U }, { 45U, 46U }, { 47U, 48U }, } }, LongLongMultiArrayField = new[, , ] { { { -25L, -26L }, { -27L, -28L }, { -29L, -30L }, { -31L, -32L }, }, { { -33L, -34L }, { -35L, -36L }, { -37L, -38L }, { -39L, -40L }, }, { { -41L, -42L }, { -43L, -44L }, { -45L, -46L }, { -47L, -48L }, } }, UnsignedLongLongMultiArrayField = new[, , ] { { { 49UL, 50UL }, { 51UL, 52UL }, { 53UL, 54UL }, { 55UL, 56UL }, }, { { 57UL, 58UL }, { 59UL, 60UL }, { 61UL, 62UL }, { 63UL, 64UL }, }, { { 65UL, 66UL }, { 67UL, 68UL }, { 69UL, 70UL }, { 71UL, 72UL }, } }, FloatMultiArrayField = new[, , ] { { { 01.01f, 02.02f }, { 03.03f, 04.04f }, { 05.05f, 06.06f }, { 07.07f, 08.08f } }, { { 09.09f, 10.10f }, { 11.11f, 12.12f }, { 13.13f, 14.14f }, { 15.15f, 16.16f }, }, { { 17.17f, 18.18f }, { 19.19f, 20.20f }, { 21.21f, 22.22f }, { 23.23f, 24.24f }, } }, DoubleMultiArrayField = new[, , ] { { { 01.01, 02.02 }, { 03.03, 04.04 }, { 05.05, 06.06 }, { 07.07, 08.08 }, }, { { 09.09, 10.10 }, { 11.11, 12.12 }, { 13.13, 14.14 }, { 15.15, 16.16 }, }, { { 17.17, 18.18 }, { 19.19, 20.20 }, { 21.21, 22.22 }, { 23.23, 24.24 }, } }, BooleanMultiArrayField = new[, , ] { { { true, false }, { true, false }, { true, false }, { true, false }, }, { { true, false }, { true, false }, { true, false }, { true, false }, }, { { true, false }, { true, false }, { true, false }, { true, false }, } }, OctetMultiArrayField = new byte[, , ] { { { 01, 02 }, { 03, 04 }, { 05, 06 }, { 07, 08 }, }, { { 09, 10 }, { 11, 12 }, { 13, 14 }, { 15, 16 }, }, { { 17, 18 }, { 19, 20 }, { 21, 22 }, { 23, 24 }, } }, EnumMultiArrayField = new TestEnum[, , ] { { { TestEnum.ENUM1, TestEnum.ENUM2 }, { TestEnum.ENUM3, TestEnum.ENUM4 }, { TestEnum.ENUM5, TestEnum.ENUM6 }, { TestEnum.ENUM7, TestEnum.ENUM8 }, }, { { TestEnum.ENUM9, TestEnum.ENUM10 }, { TestEnum.ENUM11, TestEnum.ENUM12 }, { TestEnum.ENUM1, TestEnum.ENUM2 }, { TestEnum.ENUM3, TestEnum.ENUM4 }, }, { { TestEnum.ENUM5, TestEnum.ENUM6 }, { TestEnum.ENUM7, TestEnum.ENUM8 }, { TestEnum.ENUM9, TestEnum.ENUM10 }, { TestEnum.ENUM11, TestEnum.ENUM12 }, }, }, StructMultiArrayField = new NestedStruct[, , ] { { { new NestedStruct { Id = 1, Message = "01" }, new NestedStruct { Id = 2, Message = "02" } }, { new NestedStruct { Id = 3, Message = "03" }, new NestedStruct { Id = 4, Message = "04" } }, { new NestedStruct { Id = 5, Message = "05" }, new NestedStruct { Id = 6, Message = "06" } }, { new NestedStruct { Id = 7, Message = "07" }, new NestedStruct { Id = 8, Message = "08" } }, }, { { new NestedStruct { Id = 9, Message = "09" }, new NestedStruct { Id = 10, Message = "10" } }, { new NestedStruct { Id = 11, Message = "11" }, new NestedStruct { Id = 12, Message = "12" } }, { new NestedStruct { Id = 13, Message = "13" }, new NestedStruct { Id = 14, Message = "14" } }, { new NestedStruct { Id = 15, Message = "15" }, new NestedStruct { Id = 16, Message = "16" } }, }, { { new NestedStruct { Id = 17, Message = "17" }, new NestedStruct { Id = 18, Message = "18" } }, { new NestedStruct { Id = 19, Message = "19" }, new NestedStruct { Id = 20, Message = "20" } }, { new NestedStruct { Id = 21, Message = "21" }, new NestedStruct { Id = 22, Message = "22" } }, { new NestedStruct { Id = 23, Message = "23" }, new NestedStruct { Id = 24, Message = "24" } }, }, }, StringMultiArrayField = new[, , ] { { { "01", "02" }, { "03", "04" }, { "05", "06" }, { "07", "08" }, }, { { "09", "10" }, { "11", "12" }, { "13", "14" }, { "15", "16" }, }, { { "17", "18" }, { "19", "20" }, { "21", "22" }, { "23", "24" }, }, }, WStringMultiArrayField = new[, , ] { { { "01", "02" }, { "03", "04" }, { "05", "06" }, { "07", "08" }, }, { { "09", "10" }, { "11", "12" }, { "13", "14" }, { "15", "16" }, }, { { "17", "18" }, { "19", "20" }, { "21", "22" }, { "23", "24" }, }, }, CharMultiArrayField = new[, , ] { { { '1', '2' }, { '3', '4' }, { '5', '6' }, { '7', '8' }, }, { { '9', '0' }, { '1', '2' }, { '3', '4' }, { '5', '6' }, }, { { '7', '8' }, { '9', '0' }, { '1', '2' }, { '3', '4' }, } }, WCharMultiArrayField = new[, , ] { { { '1', '2' }, { '3', '4' }, { '5', '6' }, { '7', '8' } }, { { '9', '0' }, { '1', '2' }, { '3', '4' }, { '5', '6' }, }, { { '7', '8' }, { '9', '0' }, { '1', '2' }, { '3', '4' }, } }, }; dataWriter.Write(data); ret = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 60, NanoSeconds = 0, }); if (ret == ReturnCode.Ok) { Console.WriteLine("Data sent and acknowledged."); } else { Console.WriteLine("No acknowledge received: " + ret.ToString()); } } else { Console.WriteLine("Subscription not found."); } }
protected void WriteReturnCode(XmlTextWriter xmlWriter) { xmlWriter.WriteElementString("ReturnCode", ReturnCode.ToString()); }
/// <summary> /// 获取友好提示 /// </summary> /// <returns></returns> public virtual string GetFriendlyMessage() { return(ReturnCode.ToString()); }
static int exit(ReturnCode code, string message) { string errmsg = "Code: " + (int)code + " " + PROGNAME + ": " + message + Environment.NewLine; errmsg += "Try " + PROGNAME + " --help for usage information."; Console.WriteLine(errmsg); AnalyticsWrapper.Telemetry.TrackEvent(EventType.ReturnCode, string.Format("{0} : {1}", code.ToString(), message), LogType.Genration); return((int)code); }