public virtual void HandleDragFinish(object sender, MouseEventArgs e) { using (Handle.Host.Figure.DirtManager.BeginDirty()) { var moveDelta = (Size)e.Location - (Size)_startPoint; if (KeyUtil.IsControlPressed()) { _targets.HideFeedback(_moveRequest); if (_targets.Editors.Any()) { var target = _targets.Editors.First().Parent; var cloneRequest = new CloneRequest(_targets.Editors); cloneRequest.MoveDelta = moveDelta; var cmd = target.PerformRequest(cloneRequest) as CloneCommand; if (cmd != null && cmd.ClonedEditors != null) { var select = new SelectMultiCommand(cmd.ClonedEditors, SelectKind.True, true); select.Execute(); } } } else { _moveRequest.MoveDelta = moveDelta; _targets.HideFeedback(_moveRequest); _targets.PerformCompositeRequest(_moveRequest, Handle.Host.Site.CommandExecutor); } Handle.Host.ShowFeedback(new HighlightRequest()); } }
public async Task <ActionResult <BoolResult> > Clone([FromBody] CloneRequest request) { if (!await _authManager.HasAppPermissionsAsync(LoginManager.PermissionsTemplates)) { return(Unauthorized()); } var templateInfoList = _loginManager.GetTemplateInfoList(request.Type); var originalTemplateInfo = templateInfoList.First(x => StringUtils.EqualsIgnoreCase(request.OriginalName, x.Name)); if (templateInfoList.Any(x => StringUtils.EqualsIgnoreCase(request.Name, x.Name))) { return(this.Error($"标识为 {request.Name} 的模板已存在,请更换模板标识!")); } var templateInfo = new TemplateInfo { Type = request.Type, Name = request.Name, Main = originalTemplateInfo.Main, Publisher = string.Empty, Description = request.Description, Icon = originalTemplateInfo.Icon }; templateInfoList.Add(templateInfo); _loginManager.Clone(request.OriginalName, templateInfo, request.TemplateHtml); return(new BoolResult { Value = true }); }
public static ICommand RequestClone(this IEditor editor, IEnumerable <IEditor> cloningEditors, Size moveDelta) { var req = new CloneRequest(cloningEditors); req.MoveDelta = moveDelta; return(editor.PerformRequest(req)); }
public IHttpActionResult CloneUser(CloneRequest req) { string token = "0"; if (!ModelState.IsValid) { return(Ok(token)); } ObjectParameter CloneToken = new ObjectParameter("impersonate", typeof(string)); CloneToken.Value = "0"; int rc = db.cloneUser(req.Hash, req.CloneUserID, CloneToken); try { token = (string)CloneToken.Value; } catch (System.Exception e) { token = "0"; } return(Ok(token)); }
private void CloneVolume(string deviceName, string volumeName, string volumeId, IList <string> accessControlRecordIds) { string cloneVolumeName = "Cloned" + volumeName; //get device var device = this.Client.Devices.Get(deviceName.GetDoubleEncoded(), this.ResourceGroupName, this.ManagerName); Assert.NotNull(device); // Get the latest backups for the volume var volume = this.Client.Volumes.ListByDevice(deviceName.GetDoubleEncoded(), this.ResourceGroupName, this.ManagerName); var backups = GetBackupsByVolume(deviceName, volumeId); Assert.NotNull(backups); var backup = backups.First(); Assert.NotNull(backup); Assert.NotNull(backup.Elements); //get the backup-element corresponding to the volume var backupElement = backup.Elements.FirstOrDefault(e => e.VolumeName.Equals(volumeName, StringComparison.CurrentCultureIgnoreCase)); Assert.NotNull(backupElement); // Prepare clone request and trigger clone var cloneRequest = new CloneRequest { BackupElement = backupElement, TargetDeviceId = device.Id, TargetVolumeName = cloneVolumeName, TargetAccessControlRecordIds = accessControlRecordIds }; this.Client.Backups.Clone( deviceName.GetDoubleEncoded(), backup.Name, backupElement.ElementName, cloneRequest, this.ResourceGroupName, this.ManagerName); // Verify that the clone volume is created var refreshedVolumes = this.Client.Volumes.ListByDevice( deviceName, this.ResourceGroupName, this.ManagerName); var clonedVolume = refreshedVolumes.FirstOrDefault( v => v.Name.Equals( cloneVolumeName, StringComparison.CurrentCultureIgnoreCase)); Assert.NotNull(clonedVolume); }
public override Task <CloneResponse> Clone(CloneRequest request, ServerCallContext context) { RemoteValue value = valueStore.GetObject(request.Value.Id); RemoteValue cloneResult = value.Clone(); var response = new CloneResponse(); if (cloneResult != null) { response.CloneResult = GrpcFactoryUtils.CreateValue(cloneResult, valueStore.AddObject(cloneResult)); } return(Task.FromResult(response)); }
/// <summary> /// Triggers clone operation on a fileserver using a given backup /// </summary> /// <param name="backupSet"></param> /// <param name="deviceName"></param> /// <param name="fileServer"></param> /// <param name="backupElementName"></param> /// <param name="restoredShareName"></param> public static void Clone( this Backup backupSet, string deviceName, FileServer fileServer, string backupElementName, string restoredShareName) { var device = backupSet.Client.Devices.Get( deviceName, backupSet.ResourceGroupName, backupSet.ManagerName); Assert.True( device != null, "no matching device found with name:" + deviceName); Assert.True( fileServer != null, "FileServer param is null"); var restoreFileShare = new FileShare( backupSet.Client, backupSet.ResourceGroupName, backupSet.ManagerName, TestConstants.DefaultTieredFileShareName); restoreFileShare.Initialize(DataPolicy.Tiered); restoreFileShare.Description = "Restore file Share"; restoreFileShare.AdminUser = deviceName + "\\StorSimpleAdmin"; CloneRequest cloneRequest = new CloneRequest() { NewEndpointName = restoredShareName, TargetAccessPointId = fileServer.Id, TargetDeviceId = device.Id, Share = restoreFileShare }; backupSet.Client.Backups.Clone( device.Name.GetDoubleEncoded(), backupSet.Name.GetDoubleEncoded(), backupElementName, cloneRequest, backupSet.ResourceGroupName, backupSet.ManagerName); }
/// <summary> /// Triggers clone operation on a iscsiserver for given backupset /// </summary> /// <param name="backupSet"></param> /// <param name="deviceName"></param> /// <param name="isciServer"></param> /// <param name="backupElementName"></param> /// <param name="endPointName"></param> public static void Clone( this Backup backupSet, string deviceName, ISCSIServer isciServer, string backupElementName, string endPointName) { var device = backupSet.Client.Devices.Get( deviceName, backupSet.ResourceGroupName, backupSet.ManagerName); Assert.True( device != null, "no matching device found with name:" + deviceName); Assert.True( isciServer != null, "iscsiServer param is null"); var restoreIscsiDisk = new ISCSIDisk( backupSet.Client, backupSet.ResourceGroupName, backupSet.ManagerName, endPointName); restoreIscsiDisk.Initialize(DataPolicy.Tiered); restoreIscsiDisk.Description = "Restore Disk "; var cloneRequest = new CloneRequest() { NewEndpointName = endPointName, TargetAccessPointId = isciServer.Id, TargetDeviceId = device.Id, Disk = restoreIscsiDisk }; backupSet.Client.Backups.Clone( device.Name.GetDoubleEncoded(), backupSet.Name.GetDoubleEncoded(), backupElementName, cloneRequest, backupSet.ResourceGroupName, backupSet.ManagerName); }
public async Task <RepositorySource> Clone(CloneRequest cloneRequest, CancellationToken cancellationToken = default) { var existingRepository = _fileRepository.GetServiceRepositories(Domains.BitBucket, cloneRequest.GetRepositoriesRequest.User) ?? new RepositorySource { Name = cloneRequest.GetRepositoriesRequest.User, Domain = Domains.BitBucket, Source = Sources.BitBucket }; var existingSlugs = existingRepository.Repositories.Select(s => s.Slug).ToList(); var repositories = await _bitBucketClient.GetRepositoriesAsync(cloneRequest.GetRepositoriesRequest, cancellationToken); var repositoriesToAdd = repositories .ToRepositories(cloneRequest.CloneDirectory) .Where(rep => !existingSlugs.Contains(rep.Slug)) .ToList(); foreach (var cloneProcess in repositoriesToAdd .Select(repo => new { RunnableProcess = RepositoryManager .Clone(Git.Models.Clone.Create(repo.Local.Location, repo.Origin.Location, repo.Local.Name)) .ToRunnableProcess(), Repo = repo })) { Console.WriteLine($"Cloning: {cloneProcess.Repo.Slug} into: {cloneProcess.Repo.Local.Location}"); cloneProcess.RunnableProcess.Start(); Console.WriteLine($"Cloned: {cloneProcess.Repo.Slug} into: {cloneProcess.Repo.Local.Location}"); } existingRepository.Repositories.AddRange(repositoriesToAdd); _repositoryRegisterManager.UpdateRegister(existingRepository.GetFileName()); return(_fileRepository.WriteServiceRepositories(existingRepository)); }
async Task <CodeContainer> RunAcquisition(IProgress <ServiceProgressData> downloadProgress, CancellationToken cancellationToken, IRepositoryModel repository) { CloneRequest request = null; try { var uiProvider = await Task.Run(() => Package.GetGlobalService(typeof(IGitHubServiceProvider)) as IGitHubServiceProvider); var cm = uiProvider.TryGetService <IConnectionManager>(); var gitRepositories = await GetGitRepositoriesExt(uiProvider); request = ShowCloneDialog(uiProvider, gitRepositories, repository); } catch { // TODO: log } if (request == null) { return(null); } var path = Path.Combine(request.BasePath, request.Repository.Name); var uri = request.Repository.CloneUrl.ToRepositoryUrl(); return(new CodeContainer( localProperties: new CodeContainerLocalProperties(path, CodeContainerType.Folder, new CodeContainerSourceControlProperties(request.Repository.Name, path, new Guid(Guids.GitSccProviderId))), remote: new RemoteCodeContainer(request.Repository.Name, new Guid(Guids.CodeContainerProviderId), uri, new Uri(uri.ToString().TrimSuffix(".git")), DateTimeOffset.UtcNow), isFavorite: false, lastAccessed: DateTimeOffset.UtcNow)); }
/// <summary> /// Clones the given backup element to a new disk or share with given details. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='backupName'> /// The backup name. /// </param> /// <param name='elementName'> /// The backup element name. /// </param> /// <param name='cloneRequest'> /// The clone request. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task BeginCloneAsync(this IBackupsOperations operations, string deviceName, string backupName, string elementName, CloneRequest cloneRequest, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.BeginCloneWithHttpMessagesAsync(deviceName, backupName, elementName, cloneRequest, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Clones the given backup element to a new disk or share with given details. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name. /// </param> /// <param name='backupName'> /// The backup name. /// </param> /// <param name='elementName'> /// The backup element name. /// </param> /// <param name='cloneRequest'> /// The clone request. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static void BeginClone(this IBackupsOperations operations, string deviceName, string backupName, string elementName, CloneRequest cloneRequest, string resourceGroupName, string managerName) { operations.BeginCloneAsync(deviceName, backupName, elementName, cloneRequest, resourceGroupName, managerName).GetAwaiter().GetResult(); }
private void InitItems() { _remove = new ToolStripMenuItem(); _remove.Text = "削除(&R)"; _remove.Click += (sender, e) => { using (_owner.CommandExecutor.BeginChain()) { var req = new RemoveRequest(); var cmds = new CompositeCommand(); var parent = default(IEditor); foreach (var editor in _owner.SelectionManager.SelectedEditors) { if (parent == null) { parent = editor.Parent; } if (editor.CanUnderstand(req)) { cmds.Children.Add(editor.GetCommand(req)); } } _owner.CommandExecutor.Execute(cmds); if (parent != null) { parent.RequestSelect(SelectKind.True, true); } } }; _clone = new ToolStripMenuItem(); _clone.Text = "複製(&C)"; _clone.Click += (sender, e) => { var cloning = new List <IEditor>(_owner.SelectionManager.SelectedEditors); var req = new CloneRequest(cloning); req.MoveDelta = CloneMoveDelta; if (cloning.Any()) { var target = cloning.First().Parent; var cmd = target.PerformRequest(req) as CloneCommand; if (cmd != null && cmd.ClonedEditors != null) { _owner.SelectionManager.DeselectAll(); foreach (var cloned in cmd.ClonedEditors) { cloned.RequestSelect(SelectKind.True, false); } } } }; _cut = new ToolStripMenuItem(); _cut.Text = "切り取り(&X)"; _cut.Click += (sender, e) => { var cmd = GetCutCommand(); _owner.CommandExecutor.Execute(cmd); }; _copy = new ToolStripMenuItem(); _copy.Text = "コピー(&C)"; _copy.Click += (sender, e) => { var targets = _owner.SelectionManager.SelectedEditors; var req = new CopyRequest(targets); var list = new EditorBundle(targets); list.PerformGroupRequest(req, _owner.CommandExecutor); }; _copyAsImage = new ToolStripMenuItem(); _copyAsImage.Text = "画像としてコピー(&I)"; _copyAsImage.Click += (sender, e) => { _owner.CopySelectedAsImage(); }; _paste = new ToolStripMenuItem(); _paste.Text = "貼り付け(&P)"; _paste.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { var cmd = found.RequestPaste(_currentEvent.Location, null) as PasteCommand; if (cmd != null && cmd.PastedEditors != null) { _owner.SelectionManager.DeselectAll(); foreach (var editor in cmd.PastedEditors) { editor.RequestSelect(SelectKind.True, false); } } } }; _pasteInBlock = new ToolStripMenuItem(); _pasteInBlock.Text = "段落内に貼り付け(&P)"; _pasteInBlock.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { var cmd = found.RequestPaste( _currentEvent.Location, EditorConsts.InBlockPasteDescription ) as PasteCommand; if (cmd != null && cmd.PastedEditors != null) { _owner.SelectionManager.DeselectAll(); foreach (var editor in cmd.PastedEditors) { editor.RequestSelect(SelectKind.True, false); } } } }; _front = new ToolStripMenuItem(); _front.Text = "前面に移動(&F)"; _front.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.Front); } }; _frontMost = new ToolStripMenuItem(); _frontMost.Text = "最前面に移動(&F)"; _frontMost.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.FrontMost); } }; _back = new ToolStripMenuItem(); _back.Text = "背面に移動(&B)"; _back.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.Back); } }; _backMost = new ToolStripMenuItem(); _backMost.Text = "最背面に移動(&B)"; _backMost.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.BackMost); } }; _arrangeHLeft = new ToolStripMenuItem("左揃え(&L)"); _arrangeHLeft.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var left = rect.Left; edi.RequestMove(new Size(left - edi.Figure.Left, 0)); } } }; _arrangeHCenter = new ToolStripMenuItem("左右中央揃え(&C)"); _arrangeHCenter.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); var center = RectUtil.GetCenter(rect); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var left = center.X - edi.Figure.Width / 2; edi.RequestMove(new Size(left - edi.Figure.Left, 0)); } } }; _arrangeHRight = new ToolStripMenuItem("右揃え(&R)"); _arrangeHRight.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var left = rect.Right - edi.Figure.Width; edi.RequestMove(new Size(left - edi.Figure.Left, 0)); } } }; _arrangeVTop = new ToolStripMenuItem("上揃え(&T)"); _arrangeVTop.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var top = rect.Top; edi.RequestMove(new Size(0, top - edi.Figure.Top)); } } }; _arrangeVMiddle = new ToolStripMenuItem("上下中央揃え(&M)"); _arrangeVMiddle.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); var center = RectUtil.GetCenter(rect); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var top = center.Y - edi.Figure.Height / 2; edi.RequestMove(new Size(0, top - edi.Figure.Top)); } } }; _arrangeVBottom = new ToolStripMenuItem("下揃え(&B)"); _arrangeVBottom.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var top = rect.Bottom - edi.Figure.Height; edi.RequestMove(new Size(0, top - edi.Figure.Top)); } } }; _detailForm = new ToolStripMenuItem(); _detailForm.Text = "設定(&S)"; _detailForm.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { if (found.Controller != null && found.Controller.UIProvider != null) { var ui = found.Controller.UIProvider; var form = new DetailSettingsForm(); try { form.Size = _detailFormSize; form.Theme = _owner.Theme; ui.ConfigureDetailForm(form); if (form.ShowDialog() == DialogResult.OK) { var cmd = form.GetUpdateCommand(); if (cmd != null) { _owner.CommandExecutor.Execute(cmd); } } } finally { form.Dispose(); } } } }; }
/// <summary> /// Clones the backup element as a new volume. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name /// </param> /// <param name='backupName'> /// The backup name. /// </param> /// <param name='backupElementName'> /// The backup element name. /// </param> /// <param name='parameters'> /// The clone request object. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task CloneAsync(this IBackupsOperations operations, string deviceName, string backupName, string backupElementName, CloneRequest parameters, string resourceGroupName, string managerName, CancellationToken cancellationToken = default(CancellationToken)) { await operations.CloneWithHttpMessagesAsync(deviceName, backupName, backupElementName, parameters, resourceGroupName, managerName, null, cancellationToken).ConfigureAwait(false); }
/// <summary> /// Clones the backup element as a new volume. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='deviceName'> /// The device name /// </param> /// <param name='backupName'> /// The backup name. /// </param> /// <param name='backupElementName'> /// The backup element name. /// </param> /// <param name='parameters'> /// The clone request object. /// </param> /// <param name='resourceGroupName'> /// The resource group name /// </param> /// <param name='managerName'> /// The manager name /// </param> public static void Clone(this IBackupsOperations operations, string deviceName, string backupName, string backupElementName, CloneRequest parameters, string resourceGroupName, string managerName) { operations.CloneAsync(deviceName, backupName, backupElementName, parameters, resourceGroupName, managerName).GetAwaiter().GetResult(); }