示例#1
0
        public static Dictionary <string, LfCycState> getFileLifeCycleStates(VDF.Vault.Currency.Connections.Connection connection, string filePath)
        {
            Dictionary <string, LfCycState> lifeCycleDict = new Dictionary <string, LfCycState>();

            try
            {
                File selectedFile = FileHelper.gefilebyfilePath(connection, filePath);
                if (selectedFile != null)
                {
                    if (selectedFile.FileLfCyc != null)
                    {
                        LfCycDef lifeCycleDef = connection.WebServiceManager.LifeCycleService.GetLifeCycleDefinitionsByIds(
                            selectedFile.FileLfCyc.LfCycDefId.ToSingleArray()).First();

                        lifeCycleDict = lifeCycleDef.StateArray.ToDictionary(n => n.DispName);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (SystemException ex)
            {
                Debug.Write(ex.ToString());
                //MessageBox.Show(ex.ToString());
            }
            return(lifeCycleDict);
        }
        public ChangeLifeCycleForm(long currentLifeCycleDefId, long currentLifeCycleStateId, VDF.Vault.Currency.Connections.Connection connection)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            LifeCycleService lifecycleSvc = connection.WebServiceManager.LifeCycleService;

            // get all of the life cycle definitions
            LfCycDef[] definitions = lifecycleSvc.GetAllLifeCycleDefinitions();
            Dictionary <long, LfCycDef> lifeCycleMap = new Dictionary <long, LfCycDef>();

            // put the life cycle definitions into a hashtable for easy lookup
            foreach (LfCycDef definition in definitions)
            {
                lifeCycleMap[definition.Id] = definition;
            }

            LfCycDef currentLifeCycleDef = lifeCycleMap[currentLifeCycleDefId];

            // list each life cycle that the current Item can move to
            foreach (LfCycTrans lifeCycleTrans in currentLifeCycleDef.TransArray)
            {
                LfCycState state = currentLifeCycleDef.StateArray.FirstOrDefault(lfState => lfState.Id == lifeCycleTrans.ToId);
                if (state != null)
                {
                    m_lifeCycleListBox.Items.Add(new ListLifeCycle(state));
                }
            }
        }
示例#3
0
        private void RefreshItemList()
        {
            m_tableMap.Clear();
            m_dataTable.Clear();
            m_selectedItem   = null;
            m_gridLabel.Text = "Refreshing Grid";
            m_itemsGrid.Refresh();

            ItemService itemSvc = m_connection.WebServiceManager.ItemService;

            string      bookmark = null;
            List <Item> items    = new List <Item>();
            SrchStatus  status   = null;

            while (status == null || status.TotalHits > items.Count)
            {
                items.AddRange(itemSvc.FindItemRevisionsBySearchConditions(null, null, true, ref bookmark, out status));
            }


            if (items != null && items.Count > 0)
            {
                foreach (Item item in items)
                {
                    LfCycDef   lifeCycleDef = m_lifeCycleMap[item.LfCyc.LfCycDefId];
                    LfCycState state        = lifeCycleDef.StateArray.FirstOrDefault(lifecycleState => lifecycleState.Id == item.LfCycStateId);

                    DataRow newRow = m_dataTable.NewRow();
                    newRow["Item Number"]      = item.ItemNum;
                    newRow["Revision Number"]  = item.RevNum;
                    newRow["Title"]            = item.Title;
                    newRow["Life Cycle State"] = state.Name;

                    ItemFileAssoc [] associations = itemSvc.GetItemFileAssociationsByItemIds(new long [] { item.Id }, ItemFileLnkTypOpt.Primary);
                    if (associations != null)
                    {
                        foreach (ItemFileAssoc assoc in associations)
                        {
                            newRow["Primary File Link"] = assoc.FileName;
                            break;
                        }
                    }

                    m_tableMap[item.ItemNum] = item;
                    m_dataTable.Rows.Add(newRow);
                }
            }



            m_itemsGrid.Refresh();
            m_gridLabel.Text = "Item List";
        }
示例#4
0
        public static EntLfCyc getEntityLifeCycleStates(VDF.Vault.Currency.Connections.Connection connection, string folderPath)
        {
            try
            {
                Autodesk.Connectivity.WebServices.Folder fld = FolderHelper.gefolderbyfolderPath(connection, folderPath);
                LfCycDef lifeCycleDef = connection.WebServiceManager.LifeCycleService.GetLifeCycleDefinitionsByIds(
                    fld.LfCyc.LfCycDefId.ToSingleArray()).First();

                lifeCycleDict = lifeCycleDef.StateArray.ToDictionary(n => n.DispName);
            }
            catch (SystemException ex)
            {
                Debug.Write(ex.ToString());
                //MessageBox.Show(ex.ToString());
            }
            return(resultELC);
        }
示例#5
0
 internal void SettingsValuesExistInVault(
     string lifeCycleDefName, out bool LifeCycleDefName_found,
     string wipStateName, out bool WipStateName_found,
     long wipStateID, out bool WipStateID_found,
     string releasedStateName, out bool ReleasedStateName_found,
     long releasedStateID, out bool ReleasedStateID_found)
 {
     LifeCycleDefName_found = WipStateName_found = WipStateID_found = ReleasedStateName_found = ReleasedStateID_found = false;
     try
     {
         LfCycDef[] lfCycDefs = _webServiceManager.DocumentServiceExtensions.GetAllLifeCycleDefinitions();
         LfCycDef   lfCycDef  = (from row in lfCycDefs where row.DispName == lifeCycleDefName select row).FirstOrDefault();
         if (lfCycDef != null)
         {
             LifeCycleDefName_found = true;
             LfCycState[] lfCycStates             = lfCycDef.StateArray;
             LfCycState   lfCycState_WipStateName = (from row in lfCycStates where row.DispName == wipStateName select row).FirstOrDefault();
             if (lfCycState_WipStateName != null)
             {
                 WipStateName_found = true;
                 LfCycState lfCycState_WipStateID = (from row in lfCycStates where row.DispName == wipStateName && row.Id == wipStateID select row).FirstOrDefault();
                 if (lfCycState_WipStateID != null)
                 {
                     WipStateID_found = true;
                 }
             }
             LfCycState lfCycState_ReleasedStateName = (from row in lfCycStates where row.DispName == releasedStateName select row).FirstOrDefault();
             if (lfCycState_ReleasedStateName != null)
             {
                 ReleasedStateName_found = true;
                 LfCycState lfCycState_ReleasedStateID = (from row in lfCycStates where row.DispName == releasedStateName && row.Id == releasedStateID select row).FirstOrDefault();
                 if (lfCycState_ReleasedStateID != null)
                 {
                     ReleasedStateID_found = true;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
示例#6
0
        /// <summary>
        /// Check the lifecycles to be handled as parallel workflow
        /// </summary>
        /// <param name="mPWxml"></param>
        private void mReadPWLfcs(object sender)
        {
            XElement            mXDoc         = XElement.Load(RestrictOperations.RestrictSettings.GetSettingsPath("PWLifecycles.xml"));
            IEnumerable <XNode> mPWLifecycles = mXDoc.Nodes(); //all registered lifecycles with parallel workflow(s) states

            //List<string> mPWLfcNames = new List<string>(); //list the names, to get the IDs by name later
            //List<string[]> mStates = new List<string[]>(); //list the states arrays, to get their IDs later as well
            string[] mPWStateNames; //minimum 2 states for parallel workflow expected
            // List<string> mFinalStates = new List<string>(); //just one state per lifecycle; this is the state, that the final approval automatically will activate

            IWebService service = sender as IWebService;

            if (service == null)
            {
                return;
            }
            WebServiceCredentials cred = new WebServiceCredentials(service);

            using (WebServiceManager mgr = new WebServiceManager(cred))
            {
                long currentUserId = mgr.SecurityService.SecurityHeader.UserId;

                //int i = 0;
                foreach (XElement item in mPWLifecycles)
                {
                    //mPWLfcNames.Add(item.Attribute("Name").Value); //get all registered lifecycle names
                    LfCycDef[] defs = mgr.LifeCycleService.GetAllLifeCycleDefinitions();
                    //get the lifecycle object for parallel approval by name
                    LfCycDef mLfCycle = defs.FirstOrDefault(n => n.DispName == item.Attribute("Name").Value);
                    //add the Name/ID pair to the hashtable
                    if (!(mLfCycle == null))
                    {
                        mPWLfcycles.Add(item.Attribute("Name").Value, mLfCycle.Id);

                        List <XElement> mPWLfcStates = new List <XElement>();
                        Autodesk.Connectivity.WebServices.LfCycState[] mDefStates = mLfCycle.StateArray;
                        mPWLfcStates.AddRange(item.Elements("PWState"));
                        mPWStateIDs   = new long[mPWLfcStates.Count];
                        mPWStateNames = new string[mPWLfcStates.Count];
                        int nStates = 0;
                        foreach (XElement mState in mPWLfcStates)
                        {
                            mPWStateNames[nStates] = mState.Attribute("Name").Value;
                            LfCycState mLfcycState = mDefStates.FirstOrDefault(x => x.DispName == mState.Attribute("Name").Value);
                            mPWStateIDs[nStates] = mLfcycState.Id;

                            nStates += 1;
                        }
                        mPWStates.Add(mLfCycle.Id, mPWStateIDs);
                        mPWStatesByName.Add(mLfCycle.Id, mPWStateNames); //the history evaluation requires names instead of the IDs

                        //mFinalStates.Add(item.Element("PWFinalState").Attribute("Name").Value);
                        LfCycState mLfcycFinalState = mDefStates.FirstOrDefault(y => y.DispName == item.Element("PWFinalState").Attribute("Name").Value);
                        long[]     mPWFinalStateIDs = new long[1];
                        mPWFinalStateIDs[0] = mLfcycFinalState.Id;
                        //mPWFinalStates.Add(mLfCycle.Id, mPWFinalStateIDs); //update lifecycle expects array of toIds
                        mPWFinalStates.Add(mLfCycle.Id, mLfcycFinalState.Id);

                        //  i += 1;
                    }
                }
            }//using mgr
        }
示例#7
0
        void UpdateFileLifecycleStateEvents_GetRestrictions(
            object sender, UpdateFileLifeCycleStateCommandEventArgs e)
        {
            try
            {
                IWebService service = sender as IWebService;
                if (service == null)
                {
                    return;
                }
                WebServiceCredentials cred = new WebServiceCredentials(service);
                //WebServiceCredentials_bugfix cred = new WebServiceCredentials_bugfix(service);
                using (WebServiceManager mgr = new WebServiceManager(cred))
                {
                    long        currentUserId  = mgr.SecurityService.SecurityHeader.UserId;
                    FileArray[] fileCollection = mgr.DocumentService.GetFilesByMasterIds(e.FileMasterIds);
                    //checks the lifecycle of the first file we are changing the state of.
                    CheckFile(fileCollection[0].Files);

                    LfCycDef[] defs = mgr.DocumentServiceExtensions.GetAllLifeCycleDefinitions();
                    //LfCycDef releaseProcess = defs.FirstOrDefault(
                    //    n => n.SysName == "Flexible Release Process");

                    LfCycDef releaseProcess = defs.FirstOrDefault(n => n.Id == relProcess);
                    //LfCycDef releaseProcess = defs.FirstOrDefault(n => n.SysName == "Basic Release Process");

                    LfCycState reviewState  = null;
                    LfCycState releaseState = null;

                    switch (releaseProcess.DispName)
                    {
                    case "Basic Release Process":
                        reviewState  = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "For Review");
                        releaseState = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "Released");
                        break;

                    case "Legacy Release Process":
                        reviewState  = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "For Review");
                        releaseState = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "Released");
                        break;

                    case "Project Release Process":
                        reviewState  = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "Internal Review");
                        releaseState = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "Customer Approval");
                        break;

                    case "Matrix Release Process":
                        reviewState  = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "For Review");
                        releaseState = releaseProcess.StateArray.FirstOrDefault(n => n.DispName == "Sign & Release");
                        break;

                    default:
                        break;
                    }

                    for (int i = 0; i < fileCollection.Length; i++)
                    {
                        CheckFile(fileCollection[i].Files, e.ToStateIds[i], currentUserId, reviewState, releaseState, e);
                    }
                }
            }
            catch { }
        }