private void GroupSignal(Group group, ContactEventTypes eventType) { ContactEventArgs eargs = new ContactEventArgs(eventType); eargs.AddExtra(ContactEventArgs.EXTRA_GROUP, group); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); }
public bool DeleteGroup(Group parent, Group group) { bool result; if (parent == null || null == group) { result = false; } else { foreach (ContactItem contact in parent.Children) { if (contact == group) { parent.Children.Remove(contact); ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.GROUP_REMOVED); eargs.AddExtra("group", group); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); result = true; return(result); } if (contact is Group && contact.Children.Count > 0) { if (this.DeleteGroup(contact as Group, group)) { result = true; return(result); } } } result = false; } return(result); }
public int CancelTask() { int ret = -1; try { CleanTask(); if (this.OnServiceTaskEndHandler != null) { EventHandlerTrigger.TriggerEvent <ServiceTaskEndEventArgs>(this.OnServiceTaskEndHandler, this, new ServiceTaskEndEventArgs(this)); } ret = 0; } catch (System.Exception ex) { // Logger.LogError(className, ":" + ex.Message); QueueInstance.Instance.AddMyLogList(System.DateTime.Now.ToString() + "结束任务捕获未知异常" + ex.Message); ret = 9; } finally { this.isRunning = false; this.isCanceled = true; } return(ret); }
private void ContactSignal(Contact contact, ContactEventTypes eventType) { ContactEventArgs eargs = new ContactEventArgs(eventType); eargs.AddExtra(ContactEventArgs.EXTRA_CONTACT, contact); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); }
public bool AddPerson2Group(Group group, System.Collections.Generic.List <Person> persons) { bool result; if (group == null || null == persons) { result = false; } else { string strDPSUser = UriUtils.GetUserName(this.serviceManager.ConfigurationService.IdentityCfg.Impi); foreach (Person person in persons) { string strPersonName = UriUtils.GetUserName(person.Uri); if (!strDPSUser.Equals(person.UDN, System.StringComparison.InvariantCultureIgnoreCase) && !strDPSUser.Equals(strPersonName, System.StringComparison.InvariantCultureIgnoreCase)) { group.Children.Add(person); person.Parent = group; } } ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_ADDED); eargs.AddExtra("parent", group); eargs.AddExtra("contact", persons); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); result = true; } return(result); }
public bool AddGroup(Group group, ContactItem parent) { bool result; if (group == null || parent == null) { result = false; } else if (this.FindItem(group.GDN, ContactType.Group) != null) { result = false; } else { lock (parent) { parent.Children.Add(group); group.Parent = parent; } ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.GROUP_ADDED); eargs.AddExtra("group", group); eargs.AddExtra("parent", parent); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); result = true; } return(result); }
public void onRegistrationEvent(object sender, RegistrationEventArgs e) { switch (e.Type) { case RegistrationEventTypes.REGISTRATION_OK: this.anStatus = ANStatus.INSERVICE; this.isRegistered = true; break; case RegistrationEventTypes.REGISTRATION_NOK: this.anStatus = ANStatus.STACK_STARTED; break; case RegistrationEventTypes.REGISTRATION_INPROGRESS: this.anStatus = ANStatus.REGISTERING; break; case RegistrationEventTypes.UNREGISTRATION_OK: this.anStatus = ANStatus.UNREGISTERED; this.isRegistered = false; this.StopHeartbeatDetector(); break; case RegistrationEventTypes.UNREGISTRATION_NOK: this.anStatus = ANStatus.INSERVICE; break; case RegistrationEventTypes.UNREGISTRATION_INPROGRESS: this.anStatus = ANStatus.UNREGISTERING; break; } EventHandlerTrigger.TriggerEvent <AccessNetworkEventArgs>(this.onAccessNetworkEvent, this, new AccessNetworkEventArgs(AccessNetworkEventTypes.ANET_LOGIN, this.anStatus, e.Phrase)); }
private void ProcessResponse(MsrpMessage message) { short code = message.getCode(); if (code >= 200 && code <= 299) { // File Transfer => ProgressBar if (this.session.MediaType == MediaType.FileTransfer) { long start = -1, end = -1, total = -1; message.getByteRange(out start, out end, out total); MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.SUCCESS_2XX); eargs.AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_START, start) .AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_END, end) .AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_TOTAL, total) .AddExtra(MsrpEventArgs.EXTRA_RESPONSE_CODE, code) .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session); EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs); } } else if (code >= 300) { MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.ERROR); eargs.AddExtra(MsrpEventArgs.EXTRA_RESPONSE_CODE, code) .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session); EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs); } }
private void LoadHistory() { this.loading = true; HistoryService.LOG.Debug(string.Format("Loading history from {0}", this.fileFullPath)); try { if (!System.IO.File.Exists(this.fileFullPath)) { HistoryService.LOG.Debug(string.Format("{0} doesn't exist, trying to create new one", this.fileFullPath)); System.IO.File.Create(this.fileFullPath).Close(); this.events = new MyObservableCollection <HistoryItem>(); this.ImmediateSave(); } using (System.IO.StreamReader reader = new System.IO.StreamReader(this.fileFullPath)) { try { this.events = (this.xmlSerializer.Deserialize(reader) as MyObservableCollection <HistoryItem>); } catch (System.InvalidOperationException ie) { HistoryService.LOG.Error("Failed to load history", ie); reader.Close(); System.IO.File.Delete(this.fileFullPath); } } } catch (System.Exception e) { HistoryService.LOG.Error("Failed to load history", e); } this.loading = false; EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET)); }
public bool AvatarPublish(String base64Content, String mimeType) { if (!this.prepared) { LOG.Error("XCAP sevice not prepared"); return(false); } if (!this.hasOMAPresenceContent) { LOG.Error("OMAPresenceContent not supported"); return(false); } new System.Threading.Thread(delegate() { if (this.CreatePresenceContentDocument(base64Content, mimeType)) { this.Avatar = base64Content; XcapEventArgs eargs = new XcapEventArgs(XcapEventTypes.PRESCONTENT_DONE, 200, "OK"); eargs.AddExtra(XcapEventArgs.EXTRA_CONTENT, this.Avatar); EventHandlerTrigger.TriggerEvent <XcapEventArgs>(this.onXcapEvent, this, eargs); } }) .Start(); return(true); }
public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value) { if (value == null) { return(false); } try { using (RegistryKey regkey = this.basekey.CreateSubKey(folder.ToString())) { regkey.SetValue(entry.ToString(), value); regkey.Close(); } } catch (Exception e) { LOG.Error("Failed to set value into registry", e); return(false); } // Trigger EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value)); return(true); }
public void UpdateEvent(HistoryItem @event) { HistoryEventArgs eargs = new HistoryEventArgs(HistoryEventTypes.UPDATED); eargs.AddExtra("event", @event); EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, eargs); this.DeferredSave(); }
public void UpdateGroupsAndContacts(List <Group> freshGroups, List <Contact> freshContacts) { this.groups.ReplaceRange(freshGroups); this.contacts.ReplaceRange(freshContacts); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, new ContactEventArgs(ContactEventTypes.RESET)); }
public bool UpdatePersonInfo(Person person) { ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_UPDATED); eargs.AddExtra("contact", person); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); return(true); }
public void ClearStates() { lock (this.states) { this.states.Clear(); EventHandlerTrigger.TriggerEvent <StateMonitorEventArgs>(this.onStateChangedEvent, this, new StateMonitorEventArgs(StateMonitorEventTypes.CLEARED, null, null)); } }
public void OnContentReceived() { lock (this) { this.is_remote_active = false; EventHandlerTrigger.TriggerEvent(this.remoteStateChangedEvent, this); } }
public bool DelPersonInGroup(Group group, System.Collections.Generic.List <Person> persons) { ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_REMOVED); eargs.AddExtra("parent", group); eargs.AddExtra("contact", persons); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); return(true); }
public void AddEvent(HistoryItem @event) { this.events.Insert(0, @event); HistoryEventArgs eargs = new HistoryEventArgs(HistoryEventTypes.ADDED); eargs.AddExtra("event", @event); EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, eargs); this.DeferredSave(); }
public void DeleteEvent(HistoryItem @event) { this.events.Remove(@event); HistoryEventArgs eargs = new HistoryEventArgs(HistoryEventTypes.REMOVED); eargs.AddExtra("event", @event); EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, eargs); this.DeferredSave(); }
public bool DelPersonInGroup(Group group, Person person) { ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_REMOVED); eargs.AddExtra("parent", group); eargs.AddExtra("contact", person); EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs); return(true); }
public override int OnElt(CommonElt elt) { if (OnEvent != null) { // Because the event is delivered asynchronously we must copy the elt HERE before the native memory (C++) is destroyed. Elt element = Elt.New(elt); EventHandlerTrigger.TriggerEvent <EltEventArgs>(OnEvent, this, new EltEventArgs(element)); } return(0); }
private void systimer_local_active_Elapsed(object sender, ElapsedEventArgs e) { lock (this) { if (this.is_local_active) { EventHandlerTrigger.TriggerEvent(this.sendMessageEvent, this); } } }
public bool RaiseEvent(EventArgs eargs) { if (eargs is MessagingEventArgs) { EventHandlerTrigger.TriggerEvent <MessagingEventArgs>(this.onMessagingEvent, this, (eargs as MessagingEventArgs)); return(true); } LOG.Error("Cannot raise event with type = " + eargs); return(false); }
private void LoadHistory() { this.loading = true; LOG.Debug(String.Format("Loading history from {0}", this.fileFullPath)); try { #if WINRT if (!IsolatedStorageFile.GetUserStoreForApplication().FileExists(this.fileFullPath)) #else if (!File.Exists(this.fileFullPath)) #endif { LOG.Debug(String.Format("{0} doesn't exist, trying to create new one", this.fileFullPath)); #if WINRT IsolatedStorageFile.GetUserStoreForApplication().CreateFile(this.fileFullPath).Close(); #else File.Create(this.fileFullPath).Close(); #endif // create xml declaration this.events = new MyObservableCollection <HistoryEvent>(); this.ImmediateSave(); } #if WINRT using (StreamReader reader = new StreamReader(new IsolatedStorageFileStream(this.fileFullPath, FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication()))) #else using (StreamReader reader = new StreamReader(this.fileFullPath)) #endif { try { this.events = this.xmlSerializer.Deserialize(reader) as MyObservableCollection <HistoryEvent>; } catch (InvalidOperationException ie) { LOG.Error("Failed to load history", ie); reader.Close(); File.Delete(this.fileFullPath); } } } catch (Exception e) { LOG.Error("Failed to load history", e); } this.loading = false; EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET)); }
public override Int32 OnErrorHdr(h264HdrType_t eType) { lock (mParser) { if (mParser.onEvent != null) { EventHandlerTrigger.TriggerEvent <HdrEventParseArgs>(mParser.onEvent, mParser, new HdrEventParseArgsH264(HdrEventParseType.ErrorHdr, eType)); } } return(0); }
private void systimer_remote_active_Elapsed(object sender, ElapsedEventArgs e) { lock (this) { if (this.is_remote_active) { this.is_remote_active = false; } EventHandlerTrigger.TriggerEvent(this.remoteStateChangedEvent, this); } }
public bool InternalSet(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value) { lock (this) { IsolatedStorageSettings.ApplicationSettings[BuildKey(folder, entry)] = value; EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value)); this.DeferredSave(); return(true); } }
public override Int32 OnFrameDraw(IntPtr pLum, IntPtr pCb, IntPtr pCr, uint uiWidth, uint uiHeight, uint uiStride) { lock (mParser) { if (mParser.onEventData != null) { FrameEventDrawArgs args = new FrameEventDrawArgs(0 /*FIXME*/, pLum, pCb, pCr, uiWidth, uiHeight, uiStride); EventHandlerTrigger.TriggerEvent <FrameEventDrawArgs>(mParser.onEventData, mParser, args); } } return(0); }
public void RemoveState(String stateKey) { lock (this.states) { if (this.states.ContainsKey(stateKey)) { String stateDescription = this.states[stateKey]; this.states.Remove(stateKey); EventHandlerTrigger.TriggerEvent <StateMonitorEventArgs>(this.onStateChangedEvent, this, new StateMonitorEventArgs(StateMonitorEventTypes.REMOVED, stateKey, stateDescription)); } } }
private void systimer_local_active_Elapsed(object sender, ElapsedEventArgs e) { // You are sender lock (this) { if (this.is_local_active) { // We were active, and we are still active --> do not switch state but raise event EventHandlerTrigger.TriggerEvent(this.sendMessageEvent, this); } } }