public void Init() { CommonDelegates.Initialize(Dispatcher.CurrentDispatcher); dll_init(); dll_main(); }
public int playTone(ETones toneId) { lock (_lockObj) { if (_isPlaying) { //Task.Factory.StartNew(() => stopTone(), TaskCreationOptions.PreferFairness); _isPlaying = false; CommonDelegates.SafeInvoke(() => dll_releaseWav(_playerId)); } if (_sessionId >= 0) { _playerId = CommonDelegates.SafeInvoke(() => dll_playWav(GetToneFile(toneId), true, _sessionId)); if (_playerId >= 0) { _isPlaying = true; } } return(_playerId); } }
/// <summary> /// Fills the list of entities /// </summary> private void FillEntities() { // Displays entities if (entityCache == null) { MessageBox.Show(this, "You are not connected to an organization, so it is not possible to display a list of entities\n\nPlease use menu \"More actions\" to load entities and web resources", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Close(); } foreach (var emd in entityCache) { if (emd.DisplayName.UserLocalizedLabel != null) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd }; ListViewDelegates.AddItem(lvSelectedEntities, item); } } // Enables controls ListViewDelegates.Sort(lvSelectedEntities); ListViewDelegates.SetEnableState(lvSelectedEntities, true); CommonDelegates.SetEnableState(btnCancel, true); CommonDelegates.SetEnableState(btnValidate, true); }
private void SyncThread() { CommonDelegates.Initialize(Dispatcher.CurrentDispatcher); _syncThreadFlag.Set(); Dispatcher.Run(); }
/// <summary> /// Unregister all accounts /// </summary> /// <returns></returns> public override int unregisterAccounts() { CommonDelegates.SafeInvoke(() => dll_removeAccounts()); Instance.BaseAccountStateChanged(-1); return(1); }
private void FillImageList() { ListViewDelegates.ClearItems(lstWebResources); if (webResourcesImageCache == null || webResourcesImageCache.Count == 0) { webResourcesImageCache = new List <Entity>(); QueryExpression qe = new QueryExpression("webresource"); ConditionExpression ce = new ConditionExpression(); ce.AttributeName = "webresourcetype"; if (requestedType == (int)WebResourceType.Image) { ce.Operator = ConditionOperator.In; ce.Values.AddRange(5, 6, 7); } else { ce.Operator = ConditionOperator.Equal; ce.Values.Add(requestedType); } qe.Criteria.AddCondition(ce); qe.ColumnSet.AllColumns = true; EntityCollection ec = service.RetrieveMultiple(qe); foreach (Entity webresource in ec.Entities) { webResourcesImageCache.Add(webresource); } } foreach (Entity webresource in webResourcesImageCache) { if (requestedType == 11 && webresource.GetAttributeValue <OptionSetValue>("webresourcetype").Value == 11 || requestedType != 11 && webresource.GetAttributeValue <OptionSetValue>("webresourcetype").Value != 11) { ListViewItem item = new ListViewItem(webresource.Contains("displayname") ? webresource["displayname"].ToString() : "N/A"); item.SubItems.Add(webresource["name"].ToString()); item.Tag = webresource; ListViewDelegates.AddItem(lstWebResources, item); } } ListViewDelegates.Sort(lstWebResources); ListViewDelegates.SetEnableState(lstWebResources, true); CommonDelegates.SetEnableState(btnWebResourcePickerCancel, true); CommonDelegates.SetEnableState(btnWebResourcePickerValidate, true); CommonDelegates.SetEnableState(btnNewResource, true); CommonDelegates.SetEnableState(btnRefresh, true); }
/// <summary> /// Set codec priority /// </summary> /// <param name="codecname"></param> /// <param name="priority"></param> public override void setCodecPriority(string codecname, int priority) { if (!IsInitialized) { return; } CommonDelegates.SafeInvoke(() => dll_setCodecPriority(codecname, priority)); }
/// <summary> /// Shutdown pjsip stack /// </summary> /// <returns></returns> public override int shutdown() { if (!IsInitialized) { return(-1); } return(CommonDelegates.SafeInvoke(() => dll_shutdown())); }
/// <summary> /// Get number of all codecs /// </summary> /// <returns></returns> public override int getNoOfCodecs() { if (!IsInitialized) { return(0); } return(CommonDelegates.SafeInvoke(() => dll_getNumOfCodecs())); }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Register all configured accounts /// </summary> /// <returns></returns> public override int registerAccounts() { if (!pjsipStackProxy.Instance.IsInitialized) { return(-1); } unregisterAccounts(); // iterate all accounts IAccount acc = Config.Account; // check if accounts available if (null == acc) { return(-1); } // reset account Index field Config.Account.Index = -1; // reset account state Config.Account.RegState = -1; if (acc.Enabled && acc.HostName.Length > 0) { string displayName = acc.DisplayName; // warning:::Publish do not work if display name in uri !!! string uri = "sip:" + acc.UserName; if (acc.UserName.IndexOf("@") < 0) { uri += "@" + acc.HostName; } string reguri = "sip:" + acc.HostName; // check transport - if TCP add transport=TCP reguri = pjsipStackProxy.Instance.SetTransport(reguri); string domain = acc.DomainName; string username = acc.UserName; string password = acc.Password; string proxy = ""; if (acc.ProxyAddress.Length > 0) { proxy = "sip:" + acc.ProxyAddress; } // Indicate connecting state BaseAccountStateChanged(0); // store account Id to Index field Config.Account.Index = CommonDelegates.SafeInvoke(() => dll_registerAccount(uri, reguri, domain, username, password, proxy, true)); } return(1); }
/// <summary> /// Get codec by index /// </summary> /// <param name="index"></param> /// <returns></returns> public override string getCodec(int index) { if (!IsInitialized) { return(""); } StringBuilder codec = new StringBuilder(256); CommonDelegates.SafeInvoke(() => dll_getCodec(index, codec)); return(codec.ToString()); }
private void LoadEntities() { txtSearchEntity.Text = string.Empty; lvEntities.Items.Clear(); gbEntities.Enabled = false; tsbPublishEntity.Enabled = false; tsbPublishAll.Enabled = false; tsbSaveViews.Enabled = false; lvSourceViews.Items.Clear(); lvTargetViews.Items.Clear(); lvSourceViewLayoutPreview.Columns.Clear(); WorkAsync(new WorkAsyncInfo { Message = "Loading entities...", Work = (bw, e) => { e.Result = MetadataHelper.RetrieveEntities(Service); }, PostWorkCallBack = e => { if (e.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, true); CommonDelegates.DisplayMessageBox(ParentForm, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { entitiesCache = (List <EntityMetadata>)e.Result; lvEntities.Items.Clear(); var list = new List <ListViewItem>(); foreach (EntityMetadata emd in (List <EntityMetadata>)e.Result) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd.LogicalName }; item.SubItems.Add(emd.LogicalName); list.Add(item); } this.listViewItemsCache = list.ToArray(); lvEntities.Items.AddRange(listViewItemsCache); gbEntities.Enabled = true; tsbPublishEntity.Enabled = true; tsbPublishAll.Enabled = true; tsbSaveViews.Enabled = true; } } }); }
internal void HandleDevicesRemoved(IEnumerable <AudioDevicesWatcher.AudioDeviceDescriptor> deviceDescriptors) { var devices = ConvertDeviceDescriptors(deviceDescriptors); // Call sync CommonDelegates.SafeInvoke <int>(() => { ReloadAudioDevices(); return(0); }); if (devices != null && AudioDevicesRemoved != null) { AudioDevicesRemoved(devices); } }
private void LoadEntities() { fetchXml = string.Empty; lvEntities.Items.Clear(); gbEntities.Enabled = false; tsbLoadEntities.Enabled = false; tsbRefresh.Enabled = false; tsbExportExcel.Enabled = false; tsbEditInFxb.Enabled = false; lvViews.Items.Clear(); txtFetchXml.Text = ""; WorkAsync(new WorkAsyncInfo("Loading entities...", e => { e.Result = MetadataHelper.RetrieveEntities(Service); }) { PostWorkCallBack = completedargs => { if (completedargs.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(completedargs.Error, true); CommonDelegates.DisplayMessageBox(ParentForm, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { entitiesCache = (List <EntityMetadata>)completedargs.Result; lvEntities.Items.Clear(); var list = new List <ListViewItem>(); foreach (EntityMetadata emd in (List <EntityMetadata>)completedargs.Result) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd.LogicalName }; item.SubItems.Add(emd.LogicalName); list.Add(item); } lvEntities.Items.AddRange(list.ToArray()); lvEntities.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); gbEntities.Enabled = true; gbEntities.Enabled = true; tsbLoadEntities.Enabled = true; tsbRefresh.Enabled = true; } } }); }
void _guiTimer_Tick(object sender, EventArgs e) { _guiTimer.Stop(); //_elapsed(sender, e); // Synchronize thread with GUI because SIP stack works with GUI thread only // TODO: check! May occur disposing problems //if (/*(_form.Form.IsDisposed) || (_form.Form.Disposing) ||*/ (!_core.IsInitialized)) // return; CommonDelegates.SafeBeginInvoke(() => { if (_elapsed != null) { _elapsed.Invoke(sender, e); } }); }
public int stopTone() { lock (_lockObj) { if (!_isPlaying) { return(0); } _isPlaying = false; CommonDelegates.SafeInvoke(() => dll_releaseWav(_playerId)); } return(0); }
private void BwFillEntitiesRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, true); CommonDelegates.DisplayMessageBox(ParentForm, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { gbEntities.Enabled = true; tsbPublishEntity.Enabled = true; tsbPublishAll.Enabled = true; } Controls.Remove(informationPanel); CommonDelegates.SetCursor(this, Cursors.Default); }
/// <summary> /// Set presence status /// </summary> /// <param name="status"></param> /// <returns></returns> public override int setStatus(EUserStatus status) { if (!pjsipStackProxy.Instance.IsInitialized) { return(-1); } if (Config.Account.RegState != 200) { return(-1); } if (!Config.PublishEnabled) { return(-1); } return(CommonDelegates.SafeInvoke(() => dll_setStatus(Config.Account.Index, (int)status))); }
private void BwPublishRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { CommonDelegates.SetCursor(this, Cursors.Default); //Cursor = Cursors.Default; if (e.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, false); MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Controls.Remove(informationPanel); tsbPublishEntity.Enabled = true; tsbPublishAll.Enabled = true; tsbLoadEntities.Enabled = true; }
private void tsbPublishEntity_Click(object sender, EventArgs e) { if (lvEntities.SelectedItems.Count > 0) { tsbPublishEntity.Enabled = false; tsbPublishAll.Enabled = false; tsbLoadEntities.Enabled = false; CommonDelegates.SetCursor(this, Cursors.WaitCursor); informationPanel = InformationPanel.GetInformationPanel(this, "Publishing entity...", 340, 120); var bwPublish = new BackgroundWorker(); bwPublish.DoWork += BwPublishDoWork; bwPublish.RunWorkerCompleted += BwPublishRunWorkerCompleted; bwPublish.RunWorkerAsync(lvEntities.SelectedItems[0].Text); } }
private void BwTransferViewsDoWork(object sender, DoWorkEventArgs e) { try { List <Entity> checkedViews = new List <Entity>(); foreach (ListViewItem item in ListViewDelegates.GetSelectedItems(lvSourceViews)) { checkedViews.Add((Entity)item.Tag); } e.Result = ViewHelper.TransferViews(checkedViews, service, targetService, _savedQueryMetadata); } catch (Exception error) { CommonDelegates.DisplayMessageBox(ParentForm, error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadEntities() { lvEntities.Items.Clear(); gbEntities.Enabled = false; tsbPublishEntity.Enabled = false; tsbPublishAll.Enabled = false; lvSourceViews.Items.Clear(); lvSourceViewLayoutPreview.Columns.Clear(); CommonDelegates.SetCursor(this, Cursors.WaitCursor); informationPanel = InformationPanel.GetInformationPanel(this, "Loading entities...", 340, 120); var bwFillEntities = new BackgroundWorker(); bwFillEntities.DoWork += BwFillEntitiesDoWork; bwFillEntities.RunWorkerCompleted += BwFillEntitiesRunWorkerCompleted; bwFillEntities.RunWorkerAsync(); }
/// <summary> /// Fills the list of entities /// </summary> private void FillEntities() { // Checks the application cache and load it if needed //if (entityCache == null || entityCache.Count == 0) //{ // entityCache = new List<EntityMetadata>(); // var request = new RetrieveAllEntitiesRequest // { // EntityFilters = EntityFilters.Entity // }; // var response = (RetrieveAllEntitiesResponse)SiteMapEditor.service.Execute(request); // foreach (var emd in response.EntityMetadata) // { // SiteMapEditor.entityCache.Add(emd); // } //} // Displays entities foreach (var emd in entityCache) { if ((emd.IsCustomizable.Value || emd.IsManaged.Value == false) && emd.DisplayName.UserLocalizedLabel != null) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd }; ListViewDelegates.AddItem(lvSelectedEntities, item); } } // Enables controls ListViewDelegates.Sort(lvSelectedEntities); ListViewDelegates.SetEnableState(lvSelectedEntities, true); CommonDelegates.SetEnableState(btnCancel, true); CommonDelegates.SetEnableState(btnValidate, true); }
private void tsbTransferViews_Click(object sender, EventArgs e) { if (service == null || targetService == null) { MessageBox.Show("You must select both a source and a target environment.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (lvSourceViews.SelectedItems.Count == 0) { MessageBox.Show("You must select at least one view to be transfered in the right list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } CommonDelegates.SetCursor(this, Cursors.WaitCursor); var bwTransferViews = new BackgroundWorker(); bwTransferViews.DoWork += BwTransferViewsDoWork; bwTransferViews.RunWorkerCompleted += BwTransferViewsWorkerCompleted; bwTransferViews.RunWorkerAsync(); }
private void BwTransferViewsWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { CommonDelegates.SetCursor(this, Cursors.Default); Controls.Remove(informationPanel); if (e.Result == null) { return; } if (((List <Tuple <string, string> >)e.Result).Count > 0) { var errorDialog = new ErrorList((List <Tuple <string, string> >)e.Result); errorDialog.ShowDialog(); } else { MessageBox.Show("Selected views have been successfully transfered!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fills the entities listview /// </summary> public void FillEntitiesList() { try { ListViewDelegates.ClearItems(lvEntities); foreach (EntityMetadata emd in entitiesCache) { var item = new ListViewItem { Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd.LogicalName }; item.SubItems.Add(emd.LogicalName); ListViewDelegates.AddItem(lvEntities, item); } } catch (Exception error) { string errorMessage = CrmExceptionHelper.GetErrorMessage(error, true); CommonDelegates.DisplayMessageBox(ParentForm, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <returns></returns> private int start() { // prepare configuration struct // read data from Config interface. If null read all values directly from SipConfigMore if (!Config.IsNull) { ConfigMore.listenPort = Config.SIPPort; ConfigMore.rtpPort = Config.RTPPort; } CommonDelegates.SafeInvoke(() => dll_setSipConfig(ConfigMore)); int status = CommonDelegates.SafeInvoke(() => { return(dll_init()); }); if (status != 0) { return(status); } status = CommonDelegates.SafeInvoke(() => dll_main()); return(status); }
/// <summary> /// Initializes a new instance of class WebResourcePicker /// </summary> /// <param name="type">Type of web resource to select</param> public WebResourcePicker(WebResourceType type, List <Entity> webResourcesImageCache, List <Entity> webResourcesHtmlCache, IOrganizationService service) { InitializeComponent(); this.webResourcesImageCache = webResourcesImageCache; this.webResourcesHtmlCache = webResourcesHtmlCache; this.service = service; requestedType = (int)type; // Disables controls ListViewDelegates.SetEnableState(lstWebResources, false); CommonDelegates.SetEnableState(btnWebResourcePickerCancel, false); CommonDelegates.SetEnableState(btnWebResourcePickerValidate, false); CommonDelegates.SetEnableState(btnNewResource, false); // Run work var worker = new BackgroundWorker(); worker.DoWork += worker_DoWork; worker.RunWorkerCompleted += worker_RunWorkerCompleted; worker.RunWorkerAsync(); }
private void FillList() { try { ListViewDelegates.ClearItems(lstSolutions); EntityCollection ec = RetrieveSolutions(); foreach (Entity solution in ec.Entities) { ListViewItem item = new ListViewItem(solution["friendlyname"].ToString()); item.SubItems.Add(solution["version"].ToString()); item.SubItems.Add(((EntityReference)solution["publisherid"]).Name); item.Tag = solution; ListViewDelegates.AddItem(lstSolutions, item); } } catch (Exception error) { CommonDelegates.DisplayMessageBox(this, error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void WorkerDoWork(object sender, DoWorkEventArgs e) { var worker = (BackgroundWorker)sender; foreach (var role in settings.SelectedRoles) { try { worker.ReportProgress(1, string.Format("Retrieving privileges set for role \"{0}\"...", role["name"])); var rolePrivileges = rManager.GetPrivilegesForRole(role.Id); foreach (var pAction in settings.Actions) { if (pAction.Level == PrivilegeLevel.None) { worker.ReportProgress(1, string.Format("Removing privilege \"{0}\" from role \"{1}\"...", pAction.PrivilegeName, role["name"])); rManager.RemovePrivilegeFromRole(rolePrivileges, pAction.PrivilegeId); } else { worker.ReportProgress(1, string.Format("Adding/Updating privilege \"{0}\" in role \"{1}\"...", pAction.PrivilegeName, role["name"])); rManager.AddPrivilegeToRole(rolePrivileges, pAction); } } worker.ReportProgress(1, string.Format("Replacing privileges set for role \"{0}\"...", role["name"])); rManager.ApplyChanges(rolePrivileges, role.Id); } catch (Exception error) { CommonDelegates.DisplayMessageBox(ParentForm, "Error while updating role " + role["name"] + ": " + error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }