/*****************************************************************************************/ public static List <string> GetActiveSchemes(WS.DocumentService documentService) { List <string> numberingSchemes = new List <string>(); WS.NumSchm[] schemes = documentService.GetNumberingSchemesByType(WS.NumSchmType.Activated); if (schemes != null) { foreach (WS.NumSchm scheme in schemes) { numberingSchemes.Add(scheme.Name); } } return(numberingSchemes); }
/*****************************************************************************************/ public static Option <string> GetNumber(WS.DocumentService documentService, string numberingSchemeName, string[] fields = null) { fields = fields ?? new string[] { "" }; WS.NumSchm[] schemes = documentService.GetNumberingSchemesByType(WS.NumSchmType.Activated); if (schemes == null) { return(Option.None); } foreach (WS.NumSchm scheme in schemes) { if (scheme.Name.Equals(numberingSchemeName, StringComparison.InvariantCultureIgnoreCase)) { return(documentService.GenerateFileNumber(scheme.SchmID, fields).AsOption()); } } return(Option.None); }
public static AWS.Folder GetOrCreateFolder(AWS.DocumentService docSvc, string path, bool libraryFolder) { AWS.Folder result = null; if (String.IsNullOrEmpty(path)) { return(result); } if (path.EndsWith("/")) { path = path.TrimEnd('/'); } try { result = docSvc.GetFolderByPath(path); } catch { } if (result != null) { return(result); } // doesn't exist, create new one AWS.Folder parent = null; string[] subPaths = path.Split('/'); string path2 = string.Empty; foreach (string subPath in subPaths) { AWS.Folder folder = null; if (path2.Length > 0) { path2 += "/"; } path2 += subPath; if (path2.Equals("$")) { folder = docSvc.GetFolderRoot(); } else { AWS.Folder[] subFolders = docSvc.GetFoldersByParentId(parent.Id, false); if (subFolders != null) { folder = subFolders.FirstOrDefault(f => f.FullName.Equals(path2, StringComparison.OrdinalIgnoreCase)); } } if (folder == null) { if (parent.ParId != -1) { libraryFolder = parent.IsLib; } folder = docSvc.AddFolder(subPath, parent.Id, libraryFolder); } parent = folder; } return(parent); }
public void RunCommand(string server, string vault, string username, string password, string lifecycledef, string state, Boolean force, string comment) { SecurityService secSrv = new SecurityService(); secSrv.SecurityHeaderValue = new Autodesk.Connectivity.WebServices.SecuritySvc.SecurityHeader(); secSrv.Url = "http://" + server + "/AutodeskDM/Services/SecurityService.asmx"; try { secSrv.SignIn(username, password, vault); Autodesk.Connectivity.WebServices.DocumentService docSrv = new Autodesk.Connectivity.WebServices.DocumentService(); docSrv.SecurityHeaderValue = new Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader(); docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId; docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket; docSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentService.asmx"; DocumentServiceExtensions docExSrv = new DocumentServiceExtensions(); docExSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentServiceExtensions.asmx"; docExSrv.SecurityHeaderValue = new Autodesk.Connectivity.WebServices.DocumentExSvc.SecurityHeader(); docExSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket; docExSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId; LfCycDef[] lcDefs = docExSrv.GetAllLifeCycleDefinitions(); long lcfound = -1; long lcstate = -1; if (lcDefs != null) { Console.WriteLine("Defined LifeCycles"); Console.WriteLine("------------------"); foreach (LfCycDef lcDef in lcDefs) { Console.WriteLine(" LifeCycle: " + lcDef.DispName); if (lcDef.DispName == lifecycledef) { lcfound = lcDef.Id; foreach (LfCycState lcState in lcDef.StateArray) { Console.WriteLine(" LifeCycle State: " + lcState.DispName); if (lcState.DispName == state) { Console.WriteLine(" Overriding LifeCycle State: " + lcState.DispName); lcstate = lcState.Id; } if ((lcState.IsDflt) && (lcstate == -1)) { Console.WriteLine(" Using Default LifeCycle State: " + lcState.DispName); lcstate = lcState.Id; } } } } } if (lcfound != -1) { Folder root = docSrv.GetFolderRoot(); //root = docSrv.GetFolderByPath("$/Designs/Designs/C690 T3"); //root = docSrv.GetFolderByPath("$/Code Numbers"); ProcessFilesInFolder(root, docSrv, docExSrv, lifecycledef, state, lcfound, lcstate, force, comment); } else { Console.WriteLine(""); Console.WriteLine("ERROR: Requested LifeCycle not defined [" + lifecycledef + "]"); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.ToString()); return; } }