private void Save() { try { List <ClientResponseDetail> lstClientResponseDetails = new List <ClientResponseDetail>(); objTinNhanDen = new TIN_NHAN_DEN(); List <RECEIVER> lstReceivers = new List <RECEIVER>(); foreach (RECEIVER objTinNhan in grdTinNhanDenDS.SelectedItems) { lstReceivers.Add(objTinNhan); } objTinNhanDen.DSaReceivers = lstReceivers.ToArray(); int iret = new SMSProcess().TinNhanDen(DatabaseConstant.Action.THEM, ref objTinNhanDen, ref lstClientResponseDetails); CommonFunction.ThongBaoKetQua(lstClientResponseDetails); } catch (Exception ex) { LMessage.ShowMessage("M.DungChung.LoiKhongXacDinh", LMessage.MessageBoxType.Error); LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); } }
public int LayTinNhanDen(DatabaseConstant.Action action, ref List <MODEM> lstModems, ref TIN_NHAN_DEN objTinNhanDen, ref List <ClientResponseDetail> listClientResponseDetail) { SMSServiceClient client = null; SMSRequest request = null; SMSResponse response = null; int iret = 1; try { // Kiểm tra kết nối, server, service trước khi request Common.Utilities.IsRequestAllow(ApplicationConstant.SystemService.SMSService.layGiaTri()); client = SMSServiceClient(ApplicationConstant.SystemService.SMSService); request = Common.Utilities.PrepareRequest(new SMSRequest()); response = new SMSResponse(); //Khởi tạo request request.Function = DatabaseConstant.Function.SMS_DSACH_TNHAN_DEN; request.Action = action; request.lstModems = lstModems.ToArray(); request.objTinNhanDen = objTinNhanDen; // make a call to service client here response = client.SMS(request); //Kiểm tra kết quả trả về Common.Utilities.ValidResponse(request, response); if (response == null) { iret = 0; } else { listClientResponseDetail = Common.Utilities.convertToClientResponseDetail(response); lstModems = response.lstModems.ToList(); objTinNhanDen = response.objTinNhanDen; if (response.ResponseStatus.Equals(ApplicationConstant.ResponseStatus.THANH_CONG)) { iret = 1; } else { iret = 0; } } } catch (Exception ex) { iret = 0; LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); throw ex; } finally { if (client.State == CommunicationState.Faulted) { client.Abort(); } else { client.Close(); } client = null; request = null; response = null; } return(iret); }