private void ConsumptionForm_FormClosed(object sender, FormClosedEventArgs e) { NHibernateHelper.CloseSession(); }
public BackwardReply Dispatch(IMessage msg) { try { if (msg == null) { STrace.Debug(GetType().FullName, "Message: null"); return(BackwardReply.None); } var msgType = msg.GetType(); if (msgType.FullName == null) { STrace.Debug(GetType().FullName, "Message: null type"); return(BackwardReply.None); } var pcInstanceName = STrace.Module + "_" + msg.GetType().Name; //Update Performance Counters // PerformanceCounterHelper.Increment(BackendCategory.Instance.CategoryName, BackendCategory.Instance.DispatcherProcess, pcInstanceName); PerformanceCounterHelper.Increment(BackendCategory.Instance.CategoryName, BackendCategory.Instance.DispatcherProcess); var sw = Stopwatch.StartNew(); var handlers = GetHandlers(msgType); //STrace.Debug(GetType().FullName, 0, String.Format("Dispatch {0} T={1} Id={2} HCount={3}", msg.Tiempo, msg.GetType().Name, msg.DeviceId, (Handlers == null) ? -1 : Handlers.Count())); if ((handlers != null) && (handlers.Count() != 0)) { using (var session = NHibernateHelper.GetCurrentSession()) { foreach (var handler in handlers) { //lock (handler) { object ret = null; try { ret = handler(msg); } catch (Exception e) { STrace.Exception(GetType().FullName, e, msg.DeviceId, String.Format("mType:{0} hType:{1} failure on delivering", msgType.Name, handler.GetType().Name)); } if (ret == null || (!(ret is HandleResults))) { return(BackwardReply.Release); } var result = (HandleResults)ret; if (result == HandleResults.UnspecifiedFailure) { Thread.Sleep(100); return(BackwardReply.Release); } if (result == HandleResults.BreakSuccess) { break; } } } NHibernateHelper.CloseSession(); } // PerformanceCounterHelper.IncrementBy(BackendCategory.Instance.CategoryName, // BackendCategory.Instance.DispatcherProcess, pcInstanceName, sw.ElapsedTicks); PerformanceCounterHelper.IncrementBy(BackendCategory.Instance.CategoryName, BackendCategory.Instance.DispatcherProcess, STrace.Module, sw.ElapsedTicks); } } catch (Exception e) { STrace.Exception(typeof(ReflectionIMessageDispatcher).FullName, e); } return(BackwardReply.None); }
/// <summary> /// 新增插件记录 /// </summary> /// <param name="currentNode">参考节点</param> /// <param name="domainPlugin">插件对象</param> public void Insert(int currentNode, ZhuJi.Portal.Domain.Plugin domainPlugin) { ITransaction tx = null; try { tx = session.BeginTransaction(); ZhuJi.Portal.Domain.Plugin parentDomainPlugin = (ZhuJi.Portal.Domain.Plugin)session.Get(typeof(ZhuJi.Portal.Domain.Plugin), domainPlugin.Parent); if (parentDomainPlugin != null) { ZhuJi.Portal.Domain.Plugin tmpDomainPlugin = null; switch (currentNode) { case 0: //更新父节点 tmpDomainPlugin = (ZhuJi.Portal.Domain.Plugin)session.Get(typeof(ZhuJi.Portal.Domain.Plugin), parentDomainPlugin.Parent); if (tmpDomainPlugin != null) { tmpDomainPlugin.Child++; session.Update(tmpDomainPlugin); } domainPlugin.Parent = parentDomainPlugin.Parent; domainPlugin.OrderBy = parentDomainPlugin.OrderBy - 1; domainPlugin.Depth = parentDomainPlugin.Depth; domainPlugin.Path = parentDomainPlugin.Path; break; case 1: //更新父节点 tmpDomainPlugin = (ZhuJi.Portal.Domain.Plugin)session.Get(typeof(ZhuJi.Portal.Domain.Plugin), parentDomainPlugin.Parent); if (tmpDomainPlugin != null) { tmpDomainPlugin.Child++; session.Update(tmpDomainPlugin); } domainPlugin.Parent = parentDomainPlugin.Parent; domainPlugin.OrderBy = parentDomainPlugin.OrderBy + 1; domainPlugin.Depth = parentDomainPlugin.Depth; domainPlugin.Path = parentDomainPlugin.Path; break; case 2: //更新父节点 parentDomainPlugin.Child++; session.Update(parentDomainPlugin); domainPlugin.Depth = parentDomainPlugin.Depth + 1; domainPlugin.Path = string.Concat(parentDomainPlugin.Path, domainPlugin.Parent, "."); break; } } session.Save(domainPlugin); tx.Commit(); } catch (HibernateException ex) { if (tx != null) { tx.Rollback(); } throw ex; } finally { NHibernateHelper.CloseSession(); } }
/// <summary> /// 更新插件记录 /// </summary> /// <param name="currentNode">参考节点</param> /// <param name="domainPlugin">插件对象</param> public void Update(int currentNode, ZhuJi.Portal.Domain.Plugin domainPlugin) { ITransaction tx = null; try { tx = session.BeginTransaction(); //原插件记录 ZhuJi.Portal.Domain.Plugin oldDomainPlugin = (ZhuJi.Portal.Domain.Plugin)session.Get(typeof(ZhuJi.Portal.Domain.Plugin), domainPlugin.Id); if (oldDomainPlugin == null) { throw new ArgumentException("记录不存在!"); } else { string path = "0."; int len = session.CreateQuery(string.Format("select t from Plugin t where t.Path Like '{0}%' And t.Id = {1}", string.Concat(oldDomainPlugin.Path, oldDomainPlugin.Id, "."), domainPlugin.Parent)).List <ZhuJi.Portal.Domain.Plugin>().Count; if (len > 0) { throw new ArgumentException("类别不可以转移到子类别下面!"); } else { UpdateOldParent(oldDomainPlugin); } switch (currentNode) { case 0: domainPlugin = UpdateCurrent(domainPlugin, -1); break; case 1: domainPlugin = UpdateCurrent(domainPlugin, 1); break; case 2: //父插件记录 ZhuJi.Portal.Domain.Plugin parentDomainPlugin = UpdateParent(domainPlugin); if (parentDomainPlugin != null) { path = string.Concat(parentDomainPlugin.Path, domainPlugin.Parent, "."); } UpdateChild(oldDomainPlugin, path); domainPlugin.Path = path; domainPlugin.Depth = path.Split('.').Length - 1; break; } } tx.Commit(); } catch (HibernateException ex) { if (tx != null) { tx.Rollback(); } throw ex; } finally { NHibernateHelper.CloseSession(); } base.Update(domainPlugin); }
private void MorbidityForm_FormClosed(object sender, FormClosedEventArgs e) { NHibernateHelper.CloseSession(); }
private void FrmConsumables_FormClosed(object sender, FormClosedEventArgs e) { NHibernateHelper.CloseSession(); }
protected void CloseSession() { NHibernateHelper.CloseSession(); }
private void TestFrom_FormClosed(object sender, FormClosedEventArgs e) { NHibernateHelper.CloseSession(); }
protected void Application_EndRequest(object sender, EventArgs e) { NHibernateHelper.CloseSession(); }