/// <summary> /// Converts a server-side entity path to a client-side entity path. /// </summary> /// <param name="path"> /// The server-side entity path. /// </param> /// <returns> /// The client-side entity path. /// </returns> /// <remarks> /// The client-side entity path expects an extra root ID of "-1", /// which this method includes. /// </remarks> public static string[] GetClientPath(Guid[] path) { var rootId = CoreConstants.System.Root.ToInvariantString(); var clientPath = new[] { rootId } .Concat(path.Select(x => GuidHelper.GetString(x))) .ToArray(); return clientPath; }
public static IEnumerable<TaskActivityDC> GetLastVersionTaskActivityDC(Guid[] taskGuids) { var result = WorkflowsQueryServiceUtility.UsingClientReturn(client => client.TaskActivityGetList(new TaskActivityGetListRequest() { List = taskGuids.Select(t => new TaskActivityDC() { Guid = t }).ToList(), }.SetIncaller())); result.StatusReply.CheckErrors(); return result.List; }
/// <summary> /// Creates a filter from the given properties. /// </summary> /// <param name="subscriptionIds">The subscriptions to query.</param> /// <param name="resourceGroup">The name of the resource group/</param> /// <param name="resourceType">The resource type.</param> /// <param name="resourceName">The resource name.</param> /// <param name="tagName">The tag name.</param> /// <param name="tagValue">The tag value.</param> /// <param name="filter">The filter.</param> public static string CreateFilter( Guid[] subscriptionIds, string resourceGroup, string resourceType, string resourceName, string tagName, string tagValue, string filter, string nameContains = null, string resourceGroupNameContains = null) { var filterStringBuilder = new StringBuilder(); if (subscriptionIds.CoalesceEnumerable().Any()) { if (subscriptionIds.Length > 1) { filterStringBuilder.Append("("); } filterStringBuilder.Append(subscriptionIds .Select(subscriptionId => string.Format("subscriptionId EQ '{0}'", subscriptionId)) .ConcatStrings(" OR ")); if (subscriptionIds.Length > 1) { filterStringBuilder.Append(")"); } } if (!string.IsNullOrWhiteSpace(resourceGroup)) { if (filterStringBuilder.Length > 0) { filterStringBuilder.Append(" AND "); } filterStringBuilder.AppendFormat("resourceGroup EQ '{0}'", resourceGroup); } var remainderFilter = QueryFilterBuilder.CreateFilter(resourceType, resourceName, tagName, tagValue, filter, nameContains, resourceGroupNameContains); if (filterStringBuilder.Length > 0 && !string.IsNullOrWhiteSpace(remainderFilter)) { return filterStringBuilder.ToString() + " AND " + remainderFilter; } return filterStringBuilder.Length > 0 ? filterStringBuilder.ToString() : remainderFilter; }
/// <summary> /// Deletes multiples articles /// </summary> /// <param name="articlesIds">Array of articles' ids</param> public void DeleteArticles(Guid[] articlesIds) { // Converti le tableau de Guid en tableau de string. string[] strIds = articlesIds.Select(id => id.ToString()).ToArray(); using (var conn = OpenConnection()) using (var cmd = conn.CreateCommand()) { cmd.CommandText = "dbo.pDeleteArticlesFromIds"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.AddParameterWithValue("articlesids_in", //NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Varchar, strIds); cmd.ExecuteNonQuery(); } }
public void Add(ReservedIdsSource id, Guid[] ids) { _db.HandleTransientErrors(db => { try { db.Insert(new ReservedIdRow() { Id = ReservedIdRow.GetId(id), Data = ids.Select(d => d.ToString()).StringJoin() }); } catch (DbException ex) when (db.IsUniqueViolation(ex)) { //ignore duplicates } }); }
public static void Delete(Guid[] ids) { using (var session = Workflow.WorkflowInit.Provider.Store.OpenSession()) { var objs = session.Load<Document>(ids.Select(c=>c as ValueType).ToList()); foreach (Document item in objs) { session.Delete(item); } session.SaveChanges(); } WorkflowInbox[] wis = null; do { foreach (var id in ids) { using (var session = Workflow.WorkflowInit.Provider.Store.OpenSession()) { wis = session.Query<WorkflowInbox>().Where(c => c.ProcessId == id).ToArray(); foreach (var wi in wis) session.Delete<WorkflowInbox>(wi); session.SaveChanges(); } } } while (wis.Length > 0); }
public IObservable<PerfTestResult> Run(Guid[] tests, int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return TestSuiteManager.Run(tests.Select(x => this.Tests[x]).ToArray(), start, step, end, configuration, parallel); }
public Status<string[]> ReorderPhotos(string username, Guid[] photoIds) { if (photoIds.Length == 0) return Status.ValidationError<string[]>(null, "photoIds", "photoIds cannot be empty"); string[] existingPhotoIds = null; Guid primaryPhotoId = photoIds[0]; using (RentlerContext context = new RentlerContext()) { try { var building = (from p in context.Photos .Include("Building.Photos") where p.PhotoId == primaryPhotoId && p.Building.User.Username == username select p.Building).SingleOrDefault(); if (building == null) return Status.NotFound<string[]>(); // save order prior to changing in case we have to restore them var photos = from p in building.Photos orderby p.SortOrder select p; existingPhotoIds = photos.Select(p => p.PhotoId.ToString()).ToArray(); for (int i = 0; i < photoIds.Length; ++i) { var photo = photos.SingleOrDefault(p => p.PhotoId == photoIds[i]); photo.SortOrder = i; // primary photo if (i == 0) { building.PrimaryPhotoId = photo.PhotoId; building.PrimaryPhotoExtension = photo.Extension; } } context.SaveChanges(); string[] resultIds = photoIds.Select(i => i.ToString()).ToArray(); InvalidateCache(building.BuildingId); return Status.OK<string[]>(resultIds); } catch (Exception ex) { return Status.Error<string[]>(ex.Message, existingPhotoIds); } } }
private Guid[] BeginPublish(Guid[] webresourceIds) { UpdateStatus("Publishing..."); OrganizationRequest request = new OrganizationRequest { RequestName = "PublishXml" }; request.Parameters = new ParameterCollection(); request.Parameters.Add( new KeyValuePair<string, object>("ParameterXml", string.Format("<importexportxml><webresources>{0}</webresources></importexportxml>", string.Join("", webresourceIds.Select(a => string.Format("<webresource>{0}</webresource>", a))) ))); this.Sdk.Execute(request); return webresourceIds; }
public async void StartScanningForDevices(Guid[] serviceUuids) { if (_isScanning) { Mvx.Trace("Adapter: Already scanning!"); return; } _isScanning = true; // in ScanTimeout seconds, stop the scan _cancellationTokenSource = new CancellationTokenSource(); try { // Wait for the PoweredOn state await WaitForState(CBCentralManagerState.PoweredOn, _cancellationTokenSource.Token).ConfigureAwait(false); Mvx.Trace("Adapter: Starting a scan for devices."); CBUUID[] serviceCbuuids = null; if (serviceUuids != null && serviceUuids.Any()) { serviceCbuuids = serviceUuids.Select(u => CBUUID.FromString(u.ToString())).ToArray(); Mvx.Trace("Adapter: Scanning for " + serviceCbuuids.First()); } // clear out the list _discoveredDevices = new List<IDevice>(); // start scanning _central.ScanForPeripherals(serviceCbuuids); await Task.Delay(ScanTimeout, _cancellationTokenSource.Token); Mvx.Trace("Adapter: Scan timeout has elapsed."); StopScan(); TryDisposeToken(); _isScanning = false; //important for this to be caled after _isScanning = false so don't move to finally block ScanTimeoutElapsed(this, new EventArgs()); } catch (TaskCanceledException) { Mvx.Trace("Adapter: Scan was cancelled."); StopScan(); TryDisposeToken(); _isScanning = false; } }
private async void StartLeScan(Guid[] serviceUuids) { if (_isScanning) { Mvx.Trace("Adapter: Already scanning."); return; } _isScanning = true; // clear out the list _discoveredDevices = new List<IDevice>(); if (serviceUuids == null || !serviceUuids.Any()) { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { Mvx.Trace("Adapter < 21: Starting a scan for devices."); //without filter _adapter.StartLeScan(this); } else { Mvx.Trace("Adapter >= 21: Starting a scan for devices."); if (_adapter.BluetoothLeScanner != null) { _adapter.BluetoothLeScanner.StartScan(_api21ScanCallback); } else { Mvx.Trace("Adapter >= 21: Scan failed. Bluetooth is probably off"); } } } else { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { var uuids = serviceUuids.Select(u => UUID.FromString(u.ToString())).ToArray(); Mvx.Trace("Adapter < 21: Starting a scan for devices."); _adapter.StartLeScan(uuids, this); } else { Mvx.Trace("Adapter >=21: Starting a scan for devices with service ID {0}.", serviceUuids.First()); var scanFilters = new List<ScanFilter>(); foreach (var serviceUuid in serviceUuids) { var sfb = new ScanFilter.Builder(); sfb.SetServiceUuid(ParcelUuid.FromString(serviceUuid.ToString())); scanFilters.Add(sfb.Build()); } var ssb = new ScanSettings.Builder(); //ssb.SetCallbackType(ScanCallbackType.AllMatches); if (_adapter.BluetoothLeScanner != null) { _adapter.BluetoothLeScanner.StartScan(scanFilters, ssb.Build(), _api21ScanCallback); } else { Mvx.Trace("Adapter >= 21: Scan failed. Bluetooth is probably off"); } } } // in ScanTimeout seconds, stop the scan _cancellationTokenSource = new CancellationTokenSource(); try { await Task.Delay(ScanTimeout, _cancellationTokenSource.Token); Mvx.Trace("Adapter: Scan timeout has elapsed."); StopScan(); TryDisposeToken(); _isScanning = false; //important for this to be caled after _isScanning = false; ScanTimeoutElapsed(this, new EventArgs()); } catch (TaskCanceledException) { Mvx.Trace("Adapter: Scan was cancelled."); StopScan(); TryDisposeToken(); _isScanning = false; } }
public override List<IDevice> GetSystemConnectedOrPairedDevices(Guid[] services = null) { CBUUID[] serviceUuids = null; if (services != null) { serviceUuids = services.Select(guid => CBUUID.FromString(guid.ToString())).ToArray(); } var nativeDevices = _centralManager.RetrieveConnectedPeripherals(serviceUuids); return nativeDevices.Select(d => new Device(this, d)).Cast<IDevice>().ToList(); }
public void AddWorkspaceCheckoutId(Guid[] workspaceCheckoutId) { if (workspaceCheckoutId == null || workspaceCheckoutId.Length == 0) { return; } var strings = workspaceCheckoutId.Select(g => g.ToString()).ToArray(); Contract.Assume(strings.Length > 0); AddFilterPart("workspacecheckoutid", strings); }
public virtual MailAddress[] GetMailAddress(Guid[] userIds) { return userIds.Select(x => GetMailAddress(x)).ToArray(); }
/// <summary> /// Fetches a list of raw data information for the characteristic identified by <paramref name="charateristicUuids"/>. /// </summary> /// <param name="charateristicUuids">The list of characteristic uuids the raw data information should be fetched for.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task<RawDataInformation[]> ListRawDataForCharacteristics( Guid[] charateristicUuids, CancellationToken cancellationToken = default( CancellationToken ) ) { return ListRawData( RawDataEntity.Characteristic, charateristicUuids.Select( u => u.ToString() ).ToArray(), cancellationToken ); }
/// <summary> /// Fetches a list of raw data information for the parts identified by <paramref name="partUuids"/>. /// </summary> /// <param name="partUuids">The list of part uuids the raw data information should be fetched for.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task<RawDataInformation[]> ListRawDataForParts( Guid[] partUuids, CancellationToken cancellationToken = default( CancellationToken ) ) { return ListRawData( RawDataEntity.Part, partUuids.Select( u => u.ToString() ).ToArray(), cancellationToken ); }
/// <summary> /// Fetches a list of raw data information for the measurements identified by <paramref name="measurementUuids"/>. /// </summary> /// <param name="measurementUuids">The list of measurement uuids the raw data information should be fetched for.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task<RawDataInformation[]> ListRawDataForMeasurements( Guid[] measurementUuids, CancellationToken cancellationToken = default( CancellationToken ) ) { return ListRawData( RawDataEntity.Measurement, measurementUuids.Select( u => u.ToString() ).ToArray(), cancellationToken ); }
public bool AttachToProcess(ProcessOutput processOutput, EnvDTE.Process process, Guid[] engines = null) { // Retry the attach itself 3 times before displaying a Retry/Cancel // dialog to the user. var dte = GetDTE(); dte.SuppressUI = true; try { try { if (engines == null) { process.Attach(); } else { var process3 = process as EnvDTE90.Process3; if (process3 == null) { return false; } process3.Attach2(engines.Select(engine => engine.ToString("B")).ToArray()); } return true; } catch (COMException) { if (processOutput.Wait(TimeSpan.FromMilliseconds(500))) { // Process exited while we were trying return false; } } } finally { dte.SuppressUI = false; } // Another attempt, but display UI. process.Attach(); return true; }
protected override async Task StartScanningForDevicesNativeAsync(Guid[] serviceUuids, bool allowDuplicatesKey, CancellationToken scanCancellationToken) { // Wait for the PoweredOn state await WaitForState(CBCentralManagerState.PoweredOn, scanCancellationToken).ConfigureAwait(false); if (scanCancellationToken.IsCancellationRequested) throw new TaskCanceledException("StartScanningForDevicesNativeAsync cancelled"); Trace.Message("Adapter: Starting a scan for devices."); CBUUID[] serviceCbuuids = null; if (serviceUuids != null && serviceUuids.Any()) { serviceCbuuids = serviceUuids.Select(u => CBUUID.FromString(u.ToString())).ToArray(); Trace.Message("Adapter: Scanning for " + serviceCbuuids.First()); } DiscoveredDevices.Clear(); _centralManager.ScanForPeripherals(serviceCbuuids, new PeripheralScanningOptions { AllowDuplicatesKey = allowDuplicatesKey }); }