public override IDocumentType GetDocumentType(string fileName) { return(this.GetDocumentType(fileName, (IList <IDocumentType>) new List <IDocumentType>(1) { DocumentServiceExtensions.DocumentTypes(this.Services)[DocumentTypeNamesHelper.Xaml] })); }
protected override IDocumentType GetDocumentTypeForBuildItem(string fileName, string buildItemType) { if (buildItemType == "ApplicationDefinition" && PathHelper.FileExists(fileName)) { return(DocumentServiceExtensions.DocumentTypes(this.Services)[DocumentTypeNamesHelper.ApplicationDefinition]); } return(base.GetDocumentTypeForBuildItem(fileName, buildItemType)); }
protected override AddProjectItemCommand.FileTypeDescription[] GetFileTypeFilter() { return(new AddProjectItemCommand.FileTypeDescription[1] { new AddProjectItemCommand.FileTypeDescription(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.AddProjectItemCommandFileFilterTextFormat, new object[2] { (object)DocumentServiceExtensions.DocumentTypes(this.Services)[DocumentTypeNamesHelper.Assembly].Description, (object)"*.dll, *.exe" }), "*.dll; *.exe") }); }
private void ProcessFilesInFolder(Folder parentFolder, DocumentService docSvc, DocumentServiceExtensions docExSvc, string lifecycledef, string state, long lcid, long lcstate, Boolean force, string comment) { Autodesk.Connectivity.WebServices.File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false); if (files != null && files.Length > 0) { foreach (Autodesk.Connectivity.WebServices.File file in files) { Console.WriteLine(""); Console.WriteLine(" " + parentFolder.FullName + "/" + file.Name); Console.WriteLine(" Master ID : " + String.Format("{0:0}", file.MasterId)); Console.WriteLine(" LifeCycle ID: " + file.FileLfCyc.LfCycDefId.ToString()); Console.WriteLine(" State : " + file.FileLfCyc.LfCycStateName); if (file.FileLfCyc.LfCycDefId != -1) { if (force) Console.WriteLine(" LifeCycle is already set: Forcing change"); else Console.WriteLine(" LifeCycle is already set: Use -force to change"); } if ((file.FileLfCyc.LfCycDefId == -1) || (force)) { try { docExSvc.UpdateFileLifeCycleDefinitions(new long[] { file.MasterId }, new long[] { lcid }, new long[] { lcstate }, comment); } catch (Exception ex) { Console.WriteLine("ERROR: Changing LifeCycle " + parentFolder.FullName + "/" + file.Name + " (New LifeCycle - " + lifecycledef + ")"); Console.WriteLine(ex.Message.ToString()); } finally { } } #if DEBUG Console.WriteLine("Press enter ..."); Console.ReadLine(); #endif } } Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false); if (folders != null && folders.Length > 0) { foreach (Folder folder in folders) { ProcessFilesInFolder(folder, docSvc, docExSvc, lifecycledef, state, lcid, lcstate, force, comment); } } }
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; } }
private void ProcessFilesInFolder(Folder parentFolder, DocumentService docSvc, DocumentServiceExtensions docextSrv, string statename, string state, long propid, long prophistid, string checkstates, long newstateid, long newlcdid, string newstate, long revertstateid, string revertstate, string lifecycledefinition) { string[] states = checkstates.Split('|'); Autodesk.Connectivity.WebServices.File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false); if (files != null && files.Length > 0) { foreach (Autodesk.Connectivity.WebServices.File file in files) { Boolean matchesprop = false; Console.WriteLine(""); Console.WriteLine("Checking: " + parentFolder.FullName + "/" + file.Name); Autodesk.Connectivity.WebServices.PropInst[] fileProperties = docSvc.GetProperties(new long[] { file.Id }, new long[] { propid }); if (fileProperties[0].Val != null) { //Console.WriteLine(" Property: " + statename + " - " + fileProperties[0].Val.ToString()); if (fileProperties[0].Val.ToString() == state) { matchesprop = true; } } //string outputfile = parentFolder.FullName.Substring(1) + "/" + file.Name; //outputfile = outputfile.Replace("/", "\\"); if (matchesprop && (file.VerNum > states.Length)) { Hashtable users = new Hashtable(); for (int vernum = file.VerNum; vernum > file.VerNum - states.Length; vernum--) { //Console.WriteLine(" Property Check: " + vernum.ToString()); //Console.WriteLine(" State Check: " + (file.VerNum - vernum).ToString()); Console.Write(" Checking State: " + states[file.VerNum - vernum]); Autodesk.Connectivity.WebServices.File verFile = docSvc.GetFileByVersion(file.MasterId, vernum); Autodesk.Connectivity.WebServices.PropInst[] verFileProperties = docSvc.GetProperties(new long[] { verFile.Id }, new long[] { propid }); if (verFileProperties[0].Val != null) { //Console.WriteLine(" Property: " + statename + " - " + verFileProperties[0].Val.ToString()); //Console.WriteLine(" Property: " + statename + " - " + verFile.CreateUserName); if (fileProperties[0].Val.ToString() == state) { users.Add(verFileProperties[0].Val.ToString(), verFile.CreateUserName); Console.Write(" : " + verFile.CreateUserName); } } else { verFileProperties = docSvc.GetProperties(new long[] { verFile.Id }, new long[] { prophistid }); if (verFileProperties[0].Val != null) { //Console.WriteLine(" Property: " + statename + " - " + verFileProperties[0].Val.ToString()); //Console.WriteLine(" Property: " + statename + " - " + verFile.CreateUserName); if (fileProperties[0].Val.ToString() == state) { users.Add(verFileProperties[0].Val.ToString(), verFile.CreateUserName); Console.Write(" : " + verFile.CreateUserName); } } } Console.WriteLine(""); } Boolean statesmatch = true; List<string> userlist = new List<string>(); foreach (string thisstate in states) { //Console.WriteLine("|" + thisstate + "|"); //Console.WriteLine("|" + users[thisstate].ToString() + "|"); if (!userlist.Contains(users[thisstate].ToString())) { userlist.Add(users[thisstate].ToString()); } if (users[thisstate].ToString() == "") { statesmatch = false; } } //Console.WriteLine(users.Count.ToString()); //Console.WriteLine(userlist.Count.ToString()); if (users.Count != userlist.Count) { statesmatch = false; } //Console.WriteLine(statesmatch.ToString()); if (statesmatch) { Console.WriteLine(""); Console.WriteLine(" " + parentFolder.FullName + "/" + file.Name); //Console.WriteLine(" Master ID : " + String.Format("{0:0}", file.MasterId)); Console.WriteLine(" LifeCycle : " + lifecycledefinition); Console.WriteLine(" State : " + file.FileLfCyc.LfCycStateName); Console.WriteLine(" New State : " + newstate); try { docextSrv.UpdateFileLifeCycleStates(new long[] { file.MasterId }, new long[] { newstateid }, "Automatic State Change"); } catch (Exception ex) { Console.WriteLine("ERROR: Changing state (New State - " + newstate + ")"); Console.WriteLine(ex.Message.ToString()); } finally { } } else { if (revertstateid == -1) { Console.WriteLine("ERROR: Cannot change state, previous changes not performed by unique users"); Console.WriteLine(" : No revert state specified"); } else { Console.WriteLine(""); Console.WriteLine(" " + parentFolder.FullName + "/" + file.Name); //Console.WriteLine(" Master ID : " + String.Format("{0:0}", file.MasterId)); Console.WriteLine(" LifeCycle : " + lifecycledefinition); Console.WriteLine(" State : " + file.FileLfCyc.LfCycStateName); Console.WriteLine(" Reverting to : " + revertstate); try { docextSrv.UpdateFileLifeCycleStates(new long[] { file.MasterId }, new long[] { revertstateid }, "Automatic State Revert"); } catch (Exception ex) { Console.WriteLine("ERROR: Changing state (New State - " + revertstate + ")"); Console.WriteLine(ex.Message.ToString()); } finally { } } } } else { Console.WriteLine(""); } } } Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false); if (folders != null && folders.Length > 0) { foreach (Folder folder in folders) { ProcessFilesInFolder(folder, docSvc, docextSrv, statename, state, propid, prophistid, checkstates, newstateid, newlcdid, newstate, revertstateid, revertstate, lifecycledefinition); } } }
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; } }