Ejemplo n.º 1
0
 public void Save(IConfigurable instance)
 {
     using (HostRpcClient hostRpcClient = new HostRpcClient(this.serverFqdn))
     {
         hostRpcClient.SetDarTask((TaskStoreObject)instance);
     }
 }
Ejemplo n.º 2
0
        protected override void InternalProcessRecord()
        {
            base.WriteObject("Sending no op task");
            OrganizationId organizationId = (this.TenantId != null) ? GetDarTask.ResolveOrganizationId(this.TenantId) : OrganizationId.ForestWideOrgId;
            string         fqdn           = GetDarTask.ResolveServerId(base.CurrentOrganizationId).Fqdn;

            using (HostRpcClient hostRpcClient = new HostRpcClient(fqdn))
            {
                string          text    = Guid.NewGuid().ToString();
                TaskStoreObject darTask = new TaskStoreObject
                {
                    Id       = text,
                    TaskType = "Common.NoOp",
                    TenantId = organizationId.GetBytes(Encoding.UTF8)
                };
                hostRpcClient.SetDarTask(darTask);
                base.WriteObject("Task enqueued, waiting for completed status. ID:" + text);
                for (int i = 0; i < this.Retries; i++)
                {
                    TaskStoreObject[] darTask2 = hostRpcClient.GetDarTask(new DarTaskParams
                    {
                        TaskId = text
                    });
                    if (darTask2.Length > 1)
                    {
                        base.WriteError(new Exception("Unexected number of tasks returned by GetDarTask"), ErrorCategory.InvalidResult, darTask2.Length);
                        return;
                    }
                    if (darTask2.Length == 1)
                    {
                        base.WriteObject("Task state: " + darTask2[0].TaskState);
                        if (darTask2[0].TaskState == DarTaskState.Completed)
                        {
                            return;
                        }
                    }
                    else
                    {
                        base.WriteObject("No tasks found");
                    }
                    Thread.Sleep(1000);
                }
            }
            base.WriteError(new Exception("Operation timeout"), ErrorCategory.OperationTimeout, null);
        }