//this is a recursion-based serialization scheme //apparently this has problems dealing with nested collections //so I need to instead make a flat ActorRecord collection that // encompasses the entire workspace actor tree. public bool Populate(IWorkspace workspace) { //workspace type name _properties = new WorkspaceProperties() { _workspaceTypeName = workspace.GetWorkspaceTypeName(), _authorLockName = workspace.GetAuthorLockName() }; if (string.IsNullOrEmpty(_properties._workspaceTypeName)) { return(false); } //all them actors var actorCollection = workspace.GetActorCollection(); _actorRecordCollection = GetActorRecordCollectionFromActorCollection(actorCollection); if (_actorRecordCollection == null || _actorRecordCollection.Count == 0) { return(false); } PopulateDependencyManifest(); return(true); }
private void OnPublish(object obj) { if (!model.IsLoggedIn) { model.Authenticate(); } if (!model.IsLoggedIn) { return; } var workspaceProperties = new WorkspaceProperties { Name = Name, Description = Description, Cameras = Cameras }; var workspace = CurrentWorkspaceModel as HomeWorkspaceModel; if (workspace == null) { throw new InvalidOperationException("The CurrentWorkspaceModel must be of type " + typeof(HomeWorkspaceModel).Name); } model.SendAsync(workspace, workspaceProperties); }
internal void SendAsynchronously(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { State = UploadState.Uploading; Task.Factory.StartNew(() => { var result = this.Send(workspace, workspaceProperties); var serverResponce = serverResponceRegex.Match(result); if (serverResponce.Success) { State = UploadState.Succeeded; Error = UploadErrorType.None; CustomizerURL = String.Concat(serverUrl, serverResponce.Value); } else if (InvalidNodeNames != null) { Error = UploadErrorType.InvalidNodes; } else { // If there wasn't any error during uploading, // that means it's some error on the server side. Error = UploadErrorType.UnknownServerError; } }); }
private void Initialize(IDictionary <string, string> workspaceProperties) { // Always Build in this Configuration, regardless. workspaceProperties[nameof(Configuration)] = Configuration; foreach (var wp in workspaceProperties) { WorkspaceProperties.Add(wp); } }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> internal string Send(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (String.IsNullOrWhiteSpace(serverUrl)) { Error = UploadErrorType.ServerNotFound; return(Resources.FailedMessage); } if (String.IsNullOrWhiteSpace(authenticationProvider.Username)) { Error = UploadErrorType.AuthenticationFailed; return(Resources.FailedMessage); } if (authenticationProvider == null) { Error = UploadErrorType.AuthProviderNotFound; return(Resources.FailedMessage); } if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } var dependencies = WorkspaceDependencies.Collect(workspace, customNodeManager); string result; try { result = reachClient.Send( workspace, dependencies.CustomNodeWorkspaces, workspaceProperties); InvalidNodeNames = null; } catch (InvalidNodesException ex) { InvalidNodeNames = ex.InvalidNodeNames; result = Resources.FailedMessage; } catch { result = Resources.FailedMessage; } return(result); }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> private IReachHttpResponse Send(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } var dependencies = WorkspaceDependencies.Collect(workspace, customNodeManager); InvalidNodeNames = null; return(reachClient.Send( workspace, dependencies.CustomNodeWorkspaces, workspaceProperties)); }
private void OnPublish(object obj) { if (!model.IsLoggedIn) { model.Authenticate(); } if (!model.IsLoggedIn) { return; } var homeWorkspace = Workspaces.OfType <HomeWorkspaceModel>().First(); var workspaceProperties = new WorkspaceProperties(); workspaceProperties.Name = Name; workspaceProperties.Description = Description; model.SendAsynchronously(Workspaces, workspaceProperties); }
public virtual Workspace CreateOrUpdateWorkspace( string resourceGroupName, string workspaceName, string location, string sku, Guid?customerId, IDictionary <string, string> tags) { WorkspaceProperties properties = new WorkspaceProperties(); if (!string.IsNullOrWhiteSpace(sku)) { properties.Sku = new Sku(sku); } if (customerId.HasValue) { properties.CustomerId = customerId; } var response = OperationalInsightsManagementClient.Workspaces.CreateOrUpdate( resourceGroupName, new WorkspaceCreateOrUpdateParameters() { Workspace = new Workspace() { Name = workspaceName, Location = location, Tags = tags, Properties = properties } }); return(response.Workspace); }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> private IReachHttpResponse Send(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } var dependencies = WorkspaceDependencies.Collect(workspace, customNodeManager); InvalidNodeNames = null; return reachClient.Send( workspace, dependencies.CustomNodeWorkspaces, workspaceProperties); }
internal async void SendAsync(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (String.IsNullOrWhiteSpace(serverUrl)) { Error = UploadErrorType.ServerNotFound; return; } if (String.IsNullOrWhiteSpace(authenticationProvider.Username)) { Error = UploadErrorType.AuthenticationFailed; return; } if (workspace.Nodes.Count() == 0) { Error = UploadErrorType.EmptyWorkspace; return; } if (authenticationProvider == null) { Error = UploadErrorType.AuthProviderNotFound; return; } State = UploadState.Uploading; IReachHttpResponse result; try { result = await Task.Run(() => this.Send(workspace, workspaceProperties)); } catch (InvalidNodesException ex) { InvalidNodeNames = ex.InvalidNodeNames; Error = UploadErrorType.InvalidNodes; return; } if (result.StatusCode == HttpStatusCode.Unauthorized) { Error = UploadErrorType.Unauthorized; return; } var serverResponce = serverResponceRegex.Match(result.Content); if (serverResponce.Success) { State = UploadState.Succeeded; Error = UploadErrorType.None; CustomizerURL = String.Concat(serverUrl, serverResponce.Value); } else { // If there wasn't any error during uploading, // that means it's some error on the server side. Error = UploadErrorType.UnknownServerError; } }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> internal string Send(IEnumerable<IWorkspaceModel> workspaces, WorkspaceProperties workspaceProperties = null) { if (String.IsNullOrWhiteSpace(serverUrl)) { Error = UploadErrorType.ServerNotFound; return Resources.FailedMessage; } if (String.IsNullOrWhiteSpace(authenticationProvider.Username)) { Error = UploadErrorType.AuthenticationFailed; return Resources.FailedMessage; } if (authenticationProvider == null) { Error = UploadErrorType.AuthProviderNotFound; return Resources.FailedMessage; } if (reachClient == null) reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); HomeWorkspace = workspaces.OfType<HomeWorkspaceModel>().First(); var functionNodes = HomeWorkspace.Nodes.OfType<Function>(); List<CustomNodeDefinition> dependencies = new List<CustomNodeDefinition>(); foreach (var node in functionNodes) { dependencies.AddRange(node.Definition.Dependencies); } CustomNodeWorkspaces = new List<ICustomNodeWorkspaceModel>(); foreach (var dependency in dependencies) { ICustomNodeWorkspaceModel customNodeWs; var isWorkspaceCreated = customNodeManager.TryGetFunctionWorkspace(dependency.FunctionId, false, out customNodeWs); if (isWorkspaceCreated && !CustomNodeWorkspaces.Contains(customNodeWs)) CustomNodeWorkspaces.Add(customNodeWs); } string result; try { result = reachClient.Send( HomeWorkspace, CustomNodeWorkspaces.OfType<CustomNodeWorkspaceModel>(), workspaceProperties); InvalidNodeNames = null; } catch (InvalidNodesException ex) { InvalidNodeNames = ex.InvalidNodeNames; result = Resources.FailedMessage; } catch { result = Resources.FailedMessage; } return result; }
internal void SendAsynchronously(IEnumerable<IWorkspaceModel> workspaces, WorkspaceProperties workspaceProperties = null) { State = UploadState.Uploading; Task.Factory.StartNew(() => { var result = this.Send(workspaces, workspaceProperties); var serverResponce = serverResponceRegex.Match(result); if (serverResponce.Success) { State = UploadState.Succeeded; Error = UploadErrorType.None; CustomizerURL = String.Concat(serverUrl, serverResponce.Value); } else if (InvalidNodeNames != null) { Error = UploadErrorType.InvalidNodes; } else { // If there wasn't any error during uploading, // that means it's some error on the server side. Error = UploadErrorType.UnknownServerError; } }); }
private void OnPublish(object obj) { if (!model.IsLoggedIn) { model.Authenticate(); } if (!model.IsLoggedIn) { return; } var workspaceProperties = new WorkspaceProperties { Name = Name, Description = Description }; var workspace = CurrentWorkspaceModel as HomeWorkspaceModel; if (workspace == null) { throw new InvalidOperationException("The CurrentWorkspaceModel must be of type " + typeof(HomeWorkspaceModel).Name); } model.SendAsynchronously(workspace, workspaceProperties); }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> internal string Send(HomeWorkspaceModel workspace, WorkspaceProperties workspaceProperties = null) { if (String.IsNullOrWhiteSpace(serverUrl)) { Error = UploadErrorType.ServerNotFound; return Resources.FailedMessage; } if (String.IsNullOrWhiteSpace(authenticationProvider.Username)) { Error = UploadErrorType.AuthenticationFailed; return Resources.FailedMessage; } if (authenticationProvider == null) { Error = UploadErrorType.AuthProviderNotFound; return Resources.FailedMessage; } if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } var dependencies = WorkspaceDependencies.Collect(workspace, customNodeManager); string result; try { result = reachClient.Send( workspace, dependencies.CustomNodeWorkspaces, workspaceProperties); InvalidNodeNames = null; } catch (InvalidNodesException ex) { InvalidNodeNames = ex.InvalidNodeNames; result = Resources.FailedMessage; } catch { result = Resources.FailedMessage; } return result; }
/// <summary> /// Sends workspace and its' dependencies to Flood. /// </summary> /// <returns>String which is response from server.</returns> internal string Send(IEnumerable <IWorkspaceModel> workspaces, WorkspaceProperties workspaceProperties = null) { if (String.IsNullOrWhiteSpace(serverUrl)) { Error = UploadErrorType.ServerNotFound; return(Resources.FailedMessage); } if (String.IsNullOrWhiteSpace(authenticationProvider.Username)) { Error = UploadErrorType.AuthenticationFailed; return(Resources.FailedMessage); } if (authenticationProvider == null) { Error = UploadErrorType.AuthProviderNotFound; return(Resources.FailedMessage); } if (reachClient == null) { reachClient = new WorkspaceStorageClient(authenticationProvider, serverUrl); } HomeWorkspace = workspaces.OfType <HomeWorkspaceModel>().First(); var functionNodes = HomeWorkspace.Nodes.OfType <Function>(); List <CustomNodeDefinition> dependencies = new List <CustomNodeDefinition>(); foreach (var node in functionNodes) { dependencies.AddRange(node.Definition.Dependencies); } CustomNodeWorkspaces = new List <ICustomNodeWorkspaceModel>(); foreach (var dependency in dependencies) { ICustomNodeWorkspaceModel customNodeWs; var isWorkspaceCreated = customNodeManager.TryGetFunctionWorkspace(dependency.FunctionId, false, out customNodeWs); if (isWorkspaceCreated && !CustomNodeWorkspaces.Contains(customNodeWs)) { CustomNodeWorkspaces.Add(customNodeWs); } } string result; try { result = reachClient.Send( HomeWorkspace, CustomNodeWorkspaces.OfType <CustomNodeWorkspaceModel>(), workspaceProperties); InvalidNodeNames = null; } catch (InvalidNodesException ex) { InvalidNodeNames = ex.InvalidNodeNames; result = Resources.FailedMessage; } catch { result = Resources.FailedMessage; } return(result); }
private void OnPublish(object obj) { if (!model.IsLoggedIn) model.Authenticate(); if (!model.IsLoggedIn) return; var homeWorkspace = Workspaces.OfType<HomeWorkspaceModel>().First(); var workspaceProperties = new WorkspaceProperties(); workspaceProperties.Name = Name; workspaceProperties.Description = Description; model.SendAsynchronously(Workspaces, workspaceProperties); }