private void FindEBSVersion() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "FindEBSVersion"); try { DLSettingDto entity = DataInterfaceFactory.GetInterface().GetSettings(); if (entity != null) { IS_EBS_13_0 = entity.EBSVersion.IgnoreCaseCompare("13.0"); } } catch (Exception ex) { Log.Exception(PROC, ex); } }
public DLSettingDto GetSettings() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "GetSettings"); DLSettingDto result = new DLSettingDto(); try { using (Database db = DbFactory.OpenDB(_connectionString)) { DataRow dr = db.ExecuteDataset(CommandType.StoredProcedure, "dbo.rsp_EBS_GetInitialSettings").GetDataRow(0, 0); result.IsEnabled = TypeSystem.GetValueBool(dr["IsEBSEnabled"].ToString()); result.SendDataToEBS = TypeSystem.GetValueBool(dr["SendDataToEBS"].ToString()); result.EBSEndPointURL = dr["EBSEndPointURL"].ToString(); result.EBSVersion = dr["EBSVersion"].ToString(); } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
private void OnListen_SendDataToEBS() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Method"); try { LogManager.WriteLog("SendDataToEBS - Started.", LogManager.enumLogLevel.Info); int Interval = BMC.CoreLib.Extensions.GetAppSettingValueInt("TimerIntervalinSecs", 60) * 1000; LogManager.WriteLog("SendDataToEBS - Interval: " + Interval.ToString(), LogManager.enumLogLevel.Info); DLSettingDto setting = _di.GetSettings(); _ebsEndpointUrl = setting.EBSEndPointURL; _ebsEndpointAddress = new EndpointAddress(_ebsEndpointUrl); _sentToEBSBinding = EBSCommClientFactory.CreateBinding(IS_EBS_13_0); LogManager.WriteLog("SendDataToEBS - EndPOintURL: " + _ebsEndpointUrl, LogManager.enumLogLevel.Info); IExecutorService exec = this.Executor; do { try { setting = _di.GetSettings(); if (setting.IsEnabled && setting.SendDataToEBS) { int recordStatus = SEND_FAILED; int id = -1; XElement newValue = null; DataTable dt = _di.GetUnprocessedRecords(); LogManager.WriteLog("[BMC->EBS] SendDataToEBS - Unprocessed Record Count: " + dt.Rows.Count.ToString(), LogManager.enumLogLevel.Info); foreach (DataRow dr in dt.Rows) { recordStatus = -1; id = -1; try { id = dr.GetFieldValue <int>("EH_ID"); string siteCode = dr.GetFieldValue <string>("EH_SiteCode"); Log.InfoV(PROC, "[BMC->EBS] SendDataToEBS - Start Processing Record Id : {0}, Site Code : {1}", id, siteCode); string type = dr.GetFieldValue <string>("EH_TYPE"); string value = dr.GetFieldValue <string>("EH_VALUE"); bool isDeleted = dr.GetFieldValue <bool>("EH_IsDeleted"); bool proceed = true; if (!value.IsEmpty()) { try { newValue = XElement.Parse(value); } catch { proceed = false; recordStatus = SEND_SKIPPED; } } else { proceed = false; recordStatus = SEND_SKIPPED; } if (proceed && this.SendDataToEBS_AllOrSingleSite(siteCode, id, type, newValue, isDeleted)) { recordStatus = SEND_SUCCEEDED; LogManager.WriteLog("[BMC->EBS] Successfully sent data to EBS. ID: " + id.ToString(), LogManager.enumLogLevel.Info); } else { LogManager.WriteLog("[BMC->EBS] Failed to send data to EBS. ID: " + id.ToString(), LogManager.enumLogLevel.Info); } } catch (Exception ex) { LogManager.WriteLog("[BMC->EBS] Failed to send data to EBS. ID: " + id.ToString(), LogManager.enumLogLevel.Info); ExceptionManager.Publish(ex); } finally { _di.UpdateRecordStatus(id, recordStatus); } if (recordStatus == SEND_FAILED) { break; } if (exec.WaitForShutdown(10)) { break; } } } } catch (Exception ex) { Log.Exception(ex); } } while (!exec.WaitForShutdown(Interval)); } catch (Exception ex) { Log.Exception(PROC, ex); } }