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; } }
public void RunCommand(string server, string vault, string username, string password, string statename, string statehistname, string state, string checkstates, string newstate, string revertstate, string lifecycledefinition) { long stateid = 0; long statehistid = 0; 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); DocumentService docSrv = new 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 docextSrv = new DocumentServiceExtensions(); docextSrv.SecurityHeaderValue = new Autodesk.Connectivity.WebServices.DocumentExSvc.SecurityHeader(); docextSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId; docextSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket; docextSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentServiceExtensions.asmx"; Folder root = docSrv.GetFolderRoot(); Autodesk.Connectivity.WebServices.PropDef[] defs = docSrv.GetAllPropertyDefinitions(); foreach (Autodesk.Connectivity.WebServices.PropDef pd in defs) { if (pd.DispName.ToString().ToLower() == statename.ToLower()) { stateid = pd.Id; } if (pd.DispName.ToString().ToLower() == statehistname.ToLower()) { statehistid = pd.Id; } } long revertstateid = -1; long newstateid = -1; long newlcdid = -1; LfCycDef[] lifecycledefs = docextSrv.GetAllLifeCycleDefinitions(); foreach (LfCycDef lcd in lifecycledefs) { if (lcd.DispName.ToString().ToLower() == lifecycledefinition.ToLower()) { newlcdid = lcd.Id; } } long[] transitionids = docextSrv.GetAllowedFileLifeCycleStateTransitionIds(); LfCycTrans[] transitions = docextSrv.GetLifeCycleStateTransitionsByIds(transitionids); List<long> tostateidlist = new List<long>(); foreach (LfCycTrans thistransition in transitions) { if (!tostateidlist.Contains(thistransition.ToId)) { tostateidlist.Add(thistransition.ToId); } } long[] tostateids = tostateidlist.ToArray(); LfCycState[] lifecyclestates = docextSrv.GetLifeCycleStatesByIds(tostateids); foreach (LfCycState lcs in lifecyclestates) { if ((lcs.DispName.ToString().ToLower() == newstate.ToLower()) && (newlcdid == lcs.LfCycDefId)) { newstateid = lcs.Id; } if ((lcs.DispName.ToString().ToLower() == revertstate.ToLower()) && (newlcdid == lcs.LfCycDefId)) { revertstateid = lcs.Id; } } if ((statehistid == 0) && (stateid == 0) && (newstateid == -1)) { if (statehistid == 0) Console.WriteLine("Error: \"State (Historical)\" property undefined"); if (stateid == 0) Console.WriteLine("Error: \"State\" property undefined"); if (newstateid == -1) Console.WriteLine("Error: State \"" + newstate + "\" not defined for lifecycle \"" + lifecycledefinition + "\""); } else { ProcessFilesInFolder(root, docSrv, docextSrv, statename, state, stateid, statehistid, checkstates, newstateid, newlcdid, newstate, revertstateid, revertstate, lifecycledefinition); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.ToString()); return; } }