public bool Update(UserViewModel model) { string msgError = ""; try { var vv = MessageConvert.SerializeObject(model.objectjson_person); var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_user_update", "@user_id", model.user_id, "@username", model.username, "@language_code", model.language_code, "@domain_name", model.domain_name, "@description_l", model.description_l, "@description_e", model.description_e, "@lu_user_id", model.lu_user_id, "@objectjson_person", MessageConvert.SerializeObject(model.objectjson_person)); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public bool Create(UserViewModel model, bool create_emp) { string msgError = ""; try { var xxx = MessageConvert.SerializeObject(model.objectjson_person); var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_user_create", "@create_employee", create_emp, "@user_id", model.user_id, "@username", model.username, "@password", model.password, "@language_code", model.language_code, "@domain_name", model.domain_name, "@description_l", model.description_l, "@description_e", model.description_e, "@access_token", model.access_token, "@created_by_user_id", model.created_by_user_id, "@objectjson_employee", MessageConvert.SerializeObject(model.objectjson_employee), "@objectjson_person", MessageConvert.SerializeObject(model.objectjson_person)); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Peek Event Handler /// </summary> private async Task MyPeekCompleted(object source, PeekCompletedEventArgs asyncResult, string ChannelToReturnTo, string channelPeeked) { ResultModel resultModel = new ResultModel(); try { // Connect to the queue. System.Messaging.MessageQueue mq = (System.Messaging.MessageQueue)source; // End the asynchronous peek operation. System.Messaging.Message myMessage = mq.EndPeek(asyncResult.AsyncResult); resultModel.message = MessageConvert.ConvertFromSystemMessage(myMessage); resultModel.Result = (int)ResultsEnum.Done; // Restart the asynchronous peek operation. Response response = await initiator.SendRequestAsync(new KubeMQ.SDK.csharp.CommandQuery.LowLevel.Request() { Metadata = "PeekOK", Body = Converter.ToByteArray(resultModel), CacheKey = "", CacheTTL = 0, Channel = ChannelToReturnTo, ClientID = clientID, RequestType = RequestType.Query }); } catch (Exception ex) { _logger.LogCritical(string.Format("Failed to peek path {0} on ex {1}", channelPeeked, ex.Message)); } }
/// <summary> /// Send message to existing queue from json format. /// </summary> /// <param name="meta">contain the queue general data for exemple:queue path , queue name.</param> /// <param name="body">the body as string to insert to the queue</param> /// <returns>ResultModel:show the status of the request.</returns> internal ResultModel SendJsonRequestToQueue(MSMQMeta meta, string body) { ResultModel resultModel = new ResultModel(); try { System.Messaging.MessageQueue myQueue = new System.Messaging.MessageQueue(meta.Path); myQueue.Formatter = new ActiveXMessageFormatter(); System.Messaging.Message MyMessage = MessageConvert.ConvertStringToSystemMessage(body, meta.FormmaterName, meta.Label); myQueue.Send(MyMessage); _logger.LogDebug(string.Format("Added json message to Queue:{0}", meta.Path)); resultModel.Result = (int)ResultsEnum.AddedToQueue; } catch (System.Messaging.MessageQueueException ex) { KubeMQ.MSMQSDK.Results.MessageQueueException messageEx = new KubeMQ.MSMQSDK.Results.MessageQueueException(ex); _logger.LogCritical("Failed Sending json Message to queue {0} on exception {1}", meta.Path, ex.Message); resultModel.Result = (int)ResultsEnum.Error; resultModel.exception = messageEx; } catch (Exception ex) { resultModel.Result = (int)ResultsEnum.Error; _logger.LogCritical("Failed Sending json Message to queue {0} on exception {1}", meta.Path, ex.Message); resultModel.exception = ex; } return(resultModel); }
/// <summary> /// Peek and return the first message in the queue. /// </summary> /// <param name="path">the queue name.</param> /// <returns>ResultModel:show the status of the request.</returns> internal ResultModel PeekQueue(string path) { ResultModel resultModel = new ResultModel(); try { System.Messaging.MessageQueue myQueue = new System.Messaging.MessageQueue(path); System.Messaging.Message myMessage = myQueue.Peek(); resultModel.message = MessageConvert.ConvertFromSystemMessage(myMessage); _logger.LogDebug(string.Format("Peek done on path :{0}", path)); resultModel.Result = (int)ResultsEnum.Done; } catch (Exception ex) { resultModel.Result = (int)ResultsEnum.Error; _logger.LogCritical(string.Format("Failed to peek path {0} on ex {1}", path, ex.Message)); resultModel.exception = ex; } return(resultModel); }
public bool Create(HoaDonModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_hoa_don_create", "@ma_hoa_don", model.ma_hoa_don, "@ho_ten", model.ho_ten, "@dia_chi", model.dia_chi, "@listjson_chitiet", model.listjson_chitiet != null ? MessageConvert.SerializeObject(model.listjson_chitiet) : null); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }