Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Relativity.Services.ServiceProxy.ServiceFactorySettings settings = new Relativity.Services.ServiceProxy.ServiceFactorySettings(
                new Uri(_rsapiUrl + "/relativity.services/"),
                new Uri(_rsapiUrl + "/relativity.rest/api"),
                new Relativity.Services.ServiceProxy.UsernamePasswordCredentials(_rsapiUsername, _rsapiPassword));

            DuplicateFolders(settings);


            // exit
            Console.WriteLine("\r\nDone.");
            Console.Read();
        }
Ejemplo n.º 2
0
        static void DuplicateFolders(Relativity.Services.ServiceProxy.ServiceFactorySettings settings)
        {
            try
            {
                using (IRSAPIClient rsapiProxy = new Relativity.Services.ServiceProxy.ServiceFactory(settings).CreateProxy <IRSAPIClient>())
                {
                    // query for template workspace
                    DTOs.Workspace template = FindWorkspace(_templateCase, rsapiProxy);

                    if (template != null)
                    {
                        _templateArtifactId        = template.ArtifactID;
                        Folder._templateRootFolder = template.RootFolderID;
                    }
                    else
                    {
                        return;
                    }

                    // query for target workspace
                    DTOs.Workspace target = FindWorkspace(_targetCase, rsapiProxy);

                    if (target != null)
                    {
                        _targetArtifactId        = target.ArtifactID;
                        Folder._targetRootFolder = target.RootFolderID;
                    }
                    else
                    {
                        return;
                    }

                    rsapiProxy.APIOptions.WorkspaceID = _templateArtifactId;

                    // get folders from template workspace
                    List <DTOs.Result <DTOs.Folder> > source = GetSourceFolders(rsapiProxy);

                    if (source == null)
                    {
                        return;
                    }
                    else if (source.Count == 1)
                    {
                        Console.WriteLine("Template workspace has no folders; exiting.");
                        return;
                    }

                    rsapiProxy.APIOptions.WorkspaceID = _targetArtifactId;

                    // confirm target workspace has no folders
                    bool?targetIsEmpty = VerifyEmptyTarget(rsapiProxy);

                    if (targetIsEmpty == false)
                    {
                        Console.WriteLine("Target workspace already contains folders; exiting.");
                        return;
                    }
                    else if (targetIsEmpty == null)
                    {
                        return;
                    }

                    // create folders
                    Folder.CreateFolders(source, rsapiProxy);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Exception encountered:\r\n{0}\r\n{1}", ex.Message, ex.InnerException));
            }
        }