public void Dispose() { lock (s_ServiceLocker) { lock (s_ServiceLocker) { m_callback = null; GC.Collect(); GC.WaitForPendingFinalizers(); } } m_callback = null; }
public void Verify(string userName, string verificationCode) { lock (s_ServiceLocker) { try { //获得回调接口实例 ITraceServiceCallback callback = OperationContext.Current.GetCallbackChannel <ITraceServiceCallback>(); if (!Verify(verificationCode)) { callback.CloseSession(); } else { m_callback = callback; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public bool Excute(SuperControl.ServiceModel.ExcuteAction[] actions) { bool issuccessed = false; List <ExcuteAction> retList = new List <ExcuteAction>(); lock (s_ServiceLocker) { foreach (ExcuteAction action in actions) { ModelBase model = action.ExcuteObject as ModelBase; if (model == null) { continue; } Exception ex = null; string logstring = string.Empty; int maxrid = 0; switch (action.ExcuteType) { case ExcuteType.Delete: ModelMapping mp = new ModelMapping(model.GetType()); ModelFactoryCollection.DeleteModel(model, mp, out ex); logstring = "delete"; if (ex == null) { ModelAccessManager.CacheManager.Remove(model); retList.Add(action); } break; case ExcuteType.Append: case ExcuteType.Insert: mp = new ModelMapping(model.GetType()); //model.Rid = ModelFactoryCollection.GetMaxRid(mp); ModelFactoryCollection.InsertModel(model, mp, out ex); logstring = "insert"; maxrid = ModelFactoryCollection.GetMaxRid(mp); if (ex == null) { ModelAccessManager.CacheManager.Save(model); retList.Add(action); } break; case ExcuteType.Update: mp = new ModelMapping(model.GetType()); logstring = "update"; ModelFactoryCollection.UpdateModel(model, mp, out ex); if (ex == null) { ModelAccessManager.CacheManager.Save(model); retList.Add(action); } break; default: break; } try { if (ex != null) { issuccessed = false; m_callback.ErrorNotify("Registration", ex.Message, action.ExcuteType); } else { issuccessed = true; } } catch (Exception e) { m_callback = null; Console.WriteLine(e.Message); } } if (retList.Count > 0) { SendAll(retList.ToArray()); } } return(issuccessed); }