public bool Delete(long rowId) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Delete"); bool result = default(bool); try { using (Database db = this.DataManager.Connect()) { DbParameter[] parameters = db.CreateParameters(1); parameters[0] = db.CreateParameter("@ROWID", rowId); result = (db.ExecuteNonQuery(CommandType.Text, QUERY_DELETE_RECORD, parameters) > 0); } } catch (Exception ex) { Log.Exception(PROC, ex); } finally { Log.InfoV(PROC, "Data with row id {0:D} was deleted ({1}).", rowId, (result ? "Success" : "Failure")); } return(result); }
protected bool Open() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Close"); bool result = default(bool); try { if (!_isFixedChannel) { this.Close(); if (_factory == null) { _factory = _createChannelFactory(); if (_knownTypes != null) { this.EnsureKnownTypesAdded(); } _factory.Open(); } _innerChannel = _factory.CreateChannel(this.Address); _commChannel = _innerChannel as ICommunicationObject; } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
public string this[string columnName] { get { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "this"); string result = default(string); try { if (this.State == ObjectNotifyStates.Updated) { if (_requiredMessages.ContainsKey(columnName)) { object propertyValue = this.GetType().GetProperty(columnName).GetValue(this, null); if (propertyValue != null && propertyValue.GetType() == typeof(string) && propertyValue.ToString().IsEmpty()) { return(_requiredMessages[columnName]); } } result = this.GetErrorInfoMessage(columnName); } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); } }
public bool CreateTicketCompleteMC300(int installation_No, string barcode, int value, DateTime date, int seqNumber, int ticket_Type, DateTime printedDate) { try { using (ExCommsSQLDataAccess DataContext = this.GetDataContext()) { ModuleProc PROC = new ModuleProc("CreateTicketCompleteMC300"); int? retResult = -1; DataContext.esp_CreateTicketCompleteMC300(installation_No, barcode, value, date, seqNumber, ticket_Type, printedDate, ref retResult); if (retResult != 0) { Log.Info(PROC, "Unable to create ticket complete MC300 - Installation No " + installation_No.ToString()); return(false); } Log.Info(PROC, "Created ticket complete MC300- Installation No " + installation_No.ToString()); return(true); } } catch (Exception ex) { Log.Exception(ex); return(false); } }
public bool CreateTreasury_Handpay(int installation_No, int ticket_Value, string hP_Type) { try { using (ExCommsSQLDataAccess DataContext = this.GetDataContext()) { ModuleProc PROC = new ModuleProc("CreateTreasury_Handpay"); int? retResult = -1; DataContext.usp_createTreasury_Handpay(installation_No, ticket_Value, hP_Type, ref retResult); if (retResult != 0) { Log.Info(PROC, "Unable to create handpay for 21/243 event - Installation No " + installation_No.ToString()); return(false); } Log.Info(PROC, "Handpay created for 21/243 event - Installation No " + installation_No.ToString()); return(true); } } catch (Exception ex) { Log.Exception(ex); return(false); } }
public void OnDequeue() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnDequeue"); try { IExecutorService exec = this.ExecutorService; while (!exec.WaitForShutdown(_queueTimeout)) { try { T item = _queue.Dequeue(); if (exec.IsShutdown) { break; } if (this.Dequeue != null) { this.Dequeue(item); } } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
/// <summary> /// Starts the customizaed Wcf Service Host. /// </summary> /// <returns>True if succeeded; otherwise false.</returns> public virtual bool Start() { ModuleProc PROC = new ModuleProc("WindowsWcfServiceHostFactory", "Start"); bool result = false; try { Log.Info(PROC, "Inside Start..."); this.Open(); result = (this.State == CommunicationState.Opening || this.State == CommunicationState.Opened); } catch (Exception ex) { Log.Exception(PROC, ex); } finally { if (result) { Log.Info(PROC, "Service host was started successfully."); } else { Log.Info(PROC, "Unable to start the service host."); } } return(result); }
public override void RemoveSheetsExcept(string sheetName) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "RemoveSheetsExcept"); try { foreach (var ws in _worksheets.OfType <Worksheet>()) { bool exists = false; try { if (!ws.Name.IgnoreCaseCompare(sheetName)) { ws.Delete(); } else { exists = true; } } finally { if (!exists) { Extensions.DisposeComObject(ws); } } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void InvokeWorkInternal_FromEBS(s2sMessage target, Is2sMessage_Items source) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "InvokeWork_Items"); try { Type sourceType = source.GetType(); if (_worksFromEBS.ContainsKey(sourceType)) { TypeFromEBSWorkDictionary workDict = _worksFromEBS[sourceType]; foreach (var item in source.Items) { Type childType = item.GetType(); if (workDict.ContainsKey(childType)) { workDict[childType](target, item); } } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { ModuleProc PROC = new ModuleProc("", "Method"); Assembly result = null; try { if (lvwProcesses.SelectedItems.Count > 0) { AssemblyName name = new AssemblyName(args.Name); ComboItem item = lvwProcesses.SelectedItems[0].Tag as ComboItem; if (args.Name.IgnoreCaseCompare(item.AsmName.FullName)) { string asmPath = item.Process2.ExecutablePath; result = Assembly.LoadFile(asmPath); } else { string asmPath = Path.Combine(Path.GetDirectoryName(item.Process2.ExecutablePath), name.Name + ".dll"); result = Assembly.LoadFile(asmPath); } } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
private void cboImplementations_SelectedIndexChanged(object sender, EventArgs e) { ModuleProc PROC = new ModuleProc("", "Method"); try { if (cboImplementations.SelectedIndex != -1) { if (lvwProcesses.SelectedItems.Count > 0) { ComboItem item = lvwProcesses.SelectedItems[0].Tag as ComboItem; ComboItem2 configStoreImpl = cboImplementations.SelectedItem as ComboItem2; //_store = _domain.CreateInstanceAndUnwrap(item.AsmName.FullName, configStoreImpl) as ConfigStore; _store = Activator.CreateInstance(configStoreImpl.Value, true) as ConfigStore; ConfigStoreManager.PullValues(_store); propData.SelectedObject = _store; btnSave.Enabled = true; } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void OnListen() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnListen"); try { while (!_executorService.WaitForShutdown(100)) { try { IAsyncResult acceptAsync = _socket.BeginAccept(null, null); int waitIndex = _executorService.WaitAny(acceptAsync.AsyncWaitHandle, -1); if (waitIndex == 0) { break; } Socket clientSocket = _socket.EndAccept(acceptAsync); INetSocketHandler client = new TcpSocketServerClient(clientSocket); int hashcode = client.GetHashCode(); if (_hasThreads) { if (_totalThreads != -1) { int threadIndex = (hashcode % _totalThreads); ClientsInfo ci = null; if (_clients.ContainsKey(threadIndex)) { ci = _clients[threadIndex]; } else { ci = new ClientsInfo(threadIndex); _clients.Add(threadIndex, ci); _pool.QueueWorkerItem(ci); } Log.InfoV(PROC, "Client [{0}] was connected at Thread {1:D}", client.ToString(), threadIndex); ci.AddClient(client); } else { } } this.OnClientConnected(client); } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private ThreadExecutor <T> AddThreadExecutor(string itemKey) { ModuleProc PROC = new ModuleProc(DYN_MODULE_NAME, "Initialize"); ThreadExecutor <T> executor = null; try { IThreadSafeQueue <ThreadExecutorItem <T> > threadQueue = null; if (_kernelModeQueue) { threadQueue = new BlockingBoundQueueKernel <ThreadExecutorItem <T> >(this.ThreadExecutorService, this.QueueCapacity); } else { threadQueue = new BlockingBoundQueueUser <ThreadExecutorItem <T> >(this.ThreadExecutorService, this.QueueCapacity); } executor = new ThreadExecutor <T>(this.ThreadExecutorService, threadQueue, false, itemKey); executor.ProcessItem += new ExecutorProcessItemHandler <T>(OnExecutor_ProcessItem); executor.ProcessItemCompleted += new ExecutorProcessItemCompletedHandler <T>(OnExecutor_ProcessItemCompleted); _activeWorkersCount.Add(itemKey, new ThreadHashValue() { Executor = executor, ItemCount = 0 }); } catch (Exception ex) { Log.Exception(PROC, ex); } return(executor); }
public bool Add(string settingName, string settingValue) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "AddIfNotExists"); bool result = false; try { using (Database db = this.DataManager.Connect()) { DbParameter[] parameters = db.CreateParametersV( db.CreateParameter("@SettingName", settingName), db.CreateParameter("@SettingValue", settingValue) ); result = (db.ExecuteNonQuery(CommandType.Text, QUERY_INSERT_RECORD, parameters) > 0); } } catch (Exception ex) { Log.Exception(PROC, ex); } finally { if (result) { Log.InfoV(PROC, "Data with Hash code {0} was inserted into GIM Information ({1}).", settingName, (result ? "Success" : "Failure")); } } return(result); }
/// <summary> /// Waits for all the threads to finish. /// </summary> /// <param name="timeToWait">The time to wait.</param> /// <returns> /// True if the signal was given; otherwise false. /// </returns> private bool WaitAll(TimeSpan timeToWait, EventWaitHandle[] waitHandles, bool exitContext) { ModuleProc PROC = new ModuleProc("ExecutorService", "IsShutdown"); bool result = false; try { if (timeToWait == TimeSpan.Zero) { #if !SILVERLIGHT result = EventWaitHandle.WaitAll(waitHandles, -1, exitContext); #else result = EventWaitHandle.WaitAll(waitHandles, -1); #endif } else { #if !SILVERLIGHT result = EventWaitHandle.WaitAll(waitHandles, timeToWait, exitContext); #else result = EventWaitHandle.WaitAll(waitHandles, timeToWait); #endif } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
private void InvokeWorkInternal_FromEBS(s2sMessage target, object source, object[] sourceChild) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "InvokeWork_Items"); try { Type sourceType = source.GetType(); if (_worksFromEBS.ContainsKey(sourceType)) { TypeFromEBSWorkDictionary workDict = _worksFromEBS[sourceType]; if (sourceChild != null && sourceChild.Length > 0) { object item = sourceChild[0]; Type childType = item.GetType(); if (workDict.ContainsKey(childType)) { workDict[childType](target, item); } } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void AddImportedSchemas(XmlSchema schema, XmlSchemaSet schemaSet, List <XmlSchema> importsList) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "AddImportedSchemas"); try { foreach (XmlSchemaImport import in schema.Includes) { ICollection realSchemas = schemaSet.Schemas(import.Namespace); foreach (XmlSchema ixsd in realSchemas) { if (!importsList.Contains(ixsd)) { importsList.Add(ixsd); AddImportedSchemas(ixsd, schemaSet, importsList); } } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void InvokeWork_FromEBS(s2sMessage target, object source) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "InvokeWork"); try { if (source == null) { return; } if (source is Is2sMessage_Items) { this.InvokeWorkInternal_FromEBS(target, source as Is2sMessage_Items); } else if (source is Is2sMessage_Item) { this.InvokeWorkInternal_FromEBS(target, source as Is2sMessage_Item); } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void AddDefaultBehaviors() { ModuleProc PROC = new ModuleProc("WcfWebServiceHostBase", "AddDefaultBehaviors"); try { foreach (ServiceEndpoint sep in this.Description.Endpoints) { try { if (sep.Binding.GetType() == typeof(WebHttpBinding)) { WebHttpBehavior httpBehavior = sep.Behaviors.Find <WebHttpBehavior>(); if (httpBehavior == null) { httpBehavior = new WebHttpBehavior(); sep.Behaviors.Add(httpBehavior); } httpBehavior.DefaultOutgoingResponseFormat = WebMessageFormat.Json; } } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
public void UpdateFloorStatus(int installation_No, DateTime?systemLastUpdate, DateTime?meterLastUpdate, System.Nullable <int> doorStatus, System.Nullable <int> powerStatus, System.Nullable <int> ePIStatus, string ePIDetails, System.Nullable <int> datapak_Variant, System.Nullable <int> datapak_LastEventNo, System.Nullable <int> datapak_PollingStatus, string empCardNo, string empCardInTime, System.Nullable <int> gMU_Machine_Status) { using (ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "UpdateFloorStatus")) { try { using (ExCommsSQLDataAccess DataContext = this.GetDataContext()) { DataContext.usp_UpdateFloorStatus(installation_No, systemLastUpdate, meterLastUpdate, doorStatus, powerStatus, ePIStatus, ePIDetails, datapak_Variant, datapak_LastEventNo, datapak_PollingStatus, empCardNo, empCardInTime, gMU_Machine_Status); } } catch (Exception ex) { Log.Exception(ex); } } }
/// <summary> /// Stops the customizaed Wcf Service Host. /// </summary> /// <returns>True if succeeded; otherwise false.</returns> public virtual bool Stop() { ModuleProc PROC = new ModuleProc("HostingServiceWrapper", "Stop"); bool result = false; try { Log.Info(PROC, "Inside Stop..."); this.Close(); result = (this.State == CommunicationState.Closing || this.State == CommunicationState.Closed); } catch (Exception ex) { Log.Exception(PROC, ex); } finally { if (result) { Log.Info(PROC, "Service host was stopped successfully."); } else { Log.Info(PROC, "Unable to stop the service host."); } } return(result); }
public T Dequeue() { ModuleProc PROC = new ModuleProc(DYN_MODULE_NAME, "Enqueue"); T result = default(T); // some thing should be there in the queue if (!_semConsumer.WaitOne(this.QueueTimeout)) { return(result); } try { _mtxLock.WaitOne(); // always remove the first node if (_queue.First != null) { result = _queue.First.Value; _queue.RemoveFirst(); } } catch (Exception ex) { Log.Exception(PROC, ex); } finally { _mtxLock.ReleaseMutex(); _semProducer.Release(); // signal the producer to add items to queue } return(result); }
public bool InsertTicket(int installation_ID, int?machine_Serial, int?datapak_Serial, int?ticket_Value, int?ticket_Number, DateTime?print_Time) { try { using (ExCommsSQLDataAccess DataContext = this.GetDataContext()) { ModuleProc PROC = new ModuleProc("InsertTicket"); int retResult = DataContext.usp_InsertTicket(installation_ID, machine_Serial, datapak_Serial, ticket_Value, ticket_Number, print_Time); if (retResult != 0) { Log.Info(PROC, "Unable to create NOVO ticket complete MC300 - Installation No " + installation_ID.ToString()); return(false); } Log.Info(PROC, "Created ticket complete NOVO - Installation No " + installation_ID.ToString()); return(true); } } catch (Exception ex) { Log.Exception(ex); return(false); } }
private void OnReceiveMessages() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnReceiveMessages"); try { while (!this.ExecutorService.WaitForShutdown()) { try { AppNotifyData data = _queue.Dequeue(); if (data != null && _callback != null) { _callback.NotifyData(data); } } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } finally { this.Shutdown(); } }
private void EnsureKnownTypesAdded() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "EnsureKnownTypesAdded"); try { if (_factory.Endpoint == null) { return; } ContractDescription cd = _factory.Endpoint.Contract; if (cd.ContractType != typeof(IMetadataExchange)) { foreach (OperationDescription od in cd.Operations) { foreach (Type knownType in _knownTypes) { if (od.KnownTypes.IndexOf(knownType) == -1) { od.KnownTypes.Add(knownType); } } } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void DoWorkItem(ThreadExecutor <T> executor, T item) { ModuleProc PROC = new ModuleProc(DYN_MODULE_NAME, "DoWorkItem"); try { if (!item.Equals(default(T))) { try { if (executor != null) { ThreadExecutorItem <T> executorItem = new ThreadExecutorItem <T>(item); executor.QueueWorkerItem(executorItem); Interlocked.Increment(ref _activeWorkers); this.ActiveWorkerThreadIncrement(executor.UniqueKey, item.UniqueKey); } } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
protected bool Close() { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Close"); bool result = default(bool); try { if (!_isFixedChannel) { if (_commChannel != null) { CommunicationState state = _commChannel.State; if (state != CommunicationState.Faulted) { _commChannel.Close(); _commChannel = null; } } } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
void OnExecutor_ProcessItemCompleted(ThreadExecutor <T> source, ThreadExecutorItem <T> item) { ModuleProc PROC = new ModuleProc(DYN_MODULE_NAME, "OnExecutor_ProcessItemCompleted"); try { lock (_lockList) { try { Interlocked.Decrement(ref _activeWorkers); this.ActiveWorkerThreadDecrement(source.UniqueKey, item.UniqueKey); } catch (Exception ex) { Log.Exception(PROC, ex); } } // wake the producers who are waiting to produce if (_fullWaiters > 0) { lock (_lockFullEvent) { Monitor.Pulse(_lockFullEvent); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private SearchResult Search(T key) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "DoLookup"); RbtreeNode currentNode = _rootNode; SearchResult result = new Rbtree <T> .SearchResult(); try { while (currentNode != null) { result.Position = _comparer.Compare(currentNode.Value, key); if (result.Position == 0) { result.Node = currentNode; return(result); } result.ParentNode = currentNode; if (result.Position > 0) { currentNode = currentNode.Left; } else { currentNode = currentNode.Right; } } } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
public bool UpdateValue(long rowId, string settingValue) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "UpdateIPAddress"); bool result = default(bool); try { using (Database db = this.DataManager.Connect()) { DbParameter[] parameters = db.CreateParametersV( db.CreateParameter("@SettingValue", settingValue), db.CreateParameter("@ROWID", rowId) ); result = (db.ExecuteNonQuery(CommandType.Text, QUERY_UPDATE_VALUE, parameters) > 0); } } catch (Exception ex) { Log.Exception(PROC, ex); } finally { Log.InfoV(PROC, "Data with row id {0:D} was updated for setting value ({1}).", rowId, (result ? "Success" : "Failure")); } return(result); }