예제 #1
0
        public Oppm TestOppmLogin(WebServiceCredentials webServiceCredentials)
        {
            try
            {
                NLogger.Info("Testing Oppm WebServiceCredentials");
                //
                // Test our login to OPPM via web services
                //
                var oppm = new Oppm(webServiceCredentials);
                oppm.Login();
                NLogger.Trace("OPPM token {0}", oppm.SeSecurity.SecurityToken);

                //
                // Logout
                //
                var token = oppm.SeSecurity.SecurityToken;
                oppm.Logout(token);
                NLogger.Info("Successful Oppm WebServiceCredentials");
                return(oppm);
            }
            catch (Exception ex)
            {
                NLogger.Error(ex.Message);
                return(null);
            }
        }
        void PostLifeCycleEvent(object sender, UpdateFileLifeCycleStateCommandEventArgs EventArgs)
        {
            IWebService           VaultSesession      = (IWebService)sender;
            String                VaultName           = VaultSesession.WebServiceManager.WebServiceCredentials.VaultName;
            WebServiceCredentials VaultCrednetials    = new WebServiceCredentials(VaultSesession);
            WebServiceManager     VaultServiceManager = new WebServiceManager(VaultCrednetials);

            List <File> AllFiles = new List <File>();
            List <long> FileIds  = new List <long>();
            List <long> LifeCycleDefninitions = new List <long>();
            List <long> FromLifecycleStates   = new List <long>();

            File FileObject = new File();

            foreach (long EachMasterId in EventArgs.FileMasterIds)
            {
                FileObject = new File();
                FileObject = VaultServiceManager.DocumentService.GetLatestFileByMasterId(EachMasterId);
                FileLfCyc FromLifeCycle = FileObject.FileLfCyc;

                AllFiles.Add(FileObject);
                FileIds.Add(FileObject.Id);
                LifeCycleDefninitions.Add(FromLifeCycle.LfCycDefId);
                FromLifecycleStates.Add(FromLifeCycle.LfCycStateId);
            }

            IEnumerable <long> UniqueLifeCycleDefinitionIds = LifeCycleDefninitions.Distinct();
            IEnumerable <long> UniqueFromLifecycleStateIds  = FromLifecycleStates.Distinct();
            IEnumerable <long> UniqueToLifecycleStateIds    = EventArgs.ToStateIds.Distinct();

            LfCycDef[] AllFileLifeCycleDefs = VaultServiceManager.LifeCycleService.GetLifeCycleDefinitionsByIds(UniqueLifeCycleDefinitionIds.ToArray());

            List <PropDefCond> ConditionArray = new List <PropDefCond>();

            // Get the Condition Arrays for the Selected Files by matching the from and to lifercycle state Ids
            foreach (LfCycDef EachDef in AllFileLifeCycleDefs)
            {
                LfCycTrans[] LifeCycleTransitions = EachDef.TransArray;

                foreach (LfCycTrans EachTran in LifeCycleTransitions)
                {
                    if (!(EachTran.RuleSet is null))
                    {
                        foreach (long FromLifeCycleStateId in UniqueFromLifecycleStateIds)
                        {
                            foreach (long UniqueToLifecycleStateId in UniqueToLifecycleStateIds)
                            {
                                foreach (long UniqueFromLifecycleStateId in UniqueFromLifecycleStateIds)
                                {
                                    if ((EachTran.FromId == UniqueFromLifecycleStateId) && (EachTran.ToId == UniqueToLifecycleStateId))
                                    {
                                        foreach (PropDefCond EachCond in EachTran.RuleSet.CondArray)
                                        {
                                            ConditionArray.Add(EachCond);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Get the Porerpty Def Ids from the Condition Array
            List <long> NonCompliantPropDefIds = new List <long>();

            foreach (PropDefCond EachCond in ConditionArray)
            {
                NonCompliantPropDefIds.Add(EachCond.PropDefId);
            }

            //Shortlist the Compliance Falgged Proerpty Ids
            IEnumerable <long> UniqueNonCompliantPropDefIds = NonCompliantPropDefIds.Distinct();

            // Getting the Prorepty VALUES for Compliance Marked Properties from the Selected Files
            PropInst[]  AllProeprtyInfo = VaultServiceManager.PropertyService.GetProperties("FILE", FileIds.ToArray(), UniqueNonCompliantPropDefIds.ToArray());
            List <long> ActualNonCompliantProperties = new List <long>();

            foreach (PropInst EachPropInfo in AllProeprtyInfo)
            {
                if (EachPropInfo.Val is null)
                {
                    ActualNonCompliantProperties.Add(EachPropInfo.PropDefId);
                }
            }

            // Shotlist the Array with Unqiue Property Ids
            IEnumerable <long> UniqueActualNonCompliantProperties = ActualNonCompliantProperties.Distinct();

            // Get the Proerpty Definition for these Ids
            PropDefInfo[] NonCompliantProperties = VaultServiceManager.PropertyService.GetPropertyDefinitionInfosByEntityClassId("FILE", UniqueActualNonCompliantProperties.ToArray());

            // Generate the Warning Message
            String PropertyNames = "";
            int    i             = 0;

            foreach (PropDefInfo EachInfo in NonCompliantProperties)
            {
                PropertyNames += EachInfo.PropDef.DispName + "\n";
                i++;
            }
            MessageBox.Show("Warning! The following Property(s) are Non-Compliant: \n\n" + PropertyNames, "Property Compliance Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
예제 #3
0
        void UpdateFileLifecycleStateEvents_Post(object sender, UpdateFileLifeCycleStateCommandEventArgs e)
        {
            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;

                FileArray[] mAllFileCollections = mgr.DocumentService.GetFilesByMasterIds(e.FileMasterIds);
                List <long> mTempMasterIds      = new List <long>();
                List <long> mTempReleaseStates  = new List <long>();

                int mNumberOfFullyApproved = 0;
                int N = 0;
                foreach (FileArray mFileCollection in mAllFileCollections)
                {
                    int numFileCol = mFileCollection.Files.Length;

                    //check that lifecycle type is of parallelApproval ? Yes -> continue
                    File mLatestFile   = mFileCollection.Files[mFileCollection.Files.Length - 1];
                    long mCurrentLfcID = mLatestFile.FileLfCyc.LfCycDefId;

                    if (!(mPWLfcycles.ContainsValue(mCurrentLfcID)))
                    {
                        return;
                    }
                    if (!(mApprovalLfcycle.Contains(mFileCollection.Files[numFileCol - 1].FileLfCyc.LfCycDefId)))
                    {
                        return;
                    }
                    //check that current latestversion is not released state ?
                    //No -> continue | Yes ->  add file to the list of released files
                    long mCurrentFinalStateID = (long)mPWFinalStates[mCurrentLfcID];
                    if (mLatestFile.FileLfCyc.LfCycStateId == mCurrentFinalStateID &&
                        mFileCollection.Files[numFileCol - 1].FileRev.MaxConsumeFileId == mFileCollection.Files[numFileCol - 1].FileRev.MaxFileId)
                    {
                        String mFileName = mFileCollection.Files[0].Name;
                        mReleasedFiles.Add(mFileName);
                        mPostRecursiv = true;
                    }

                    //check that the file(s) custom state is fully approved ? yes -> continue

                    long[] mReturnFiles = new long[mFileCollection.Files.Length];
                    Int32  i            = 0;

                    foreach (File mFile in mFileCollection.Files)
                    {
                        mReturnFiles[i] = mFile.Id;
                        i += 1;
                    }

                    FileArray[] mFileHistory = null;
                    mFileHistory   = mgr.DocumentService.GetFilesByHistoryType(mReturnFiles, FileHistoryTypeOptions.All);
                    mFullyApproved = mCheckParallelFlow(sender, e, mFileHistory, (string[])mPWStatesByName[mCurrentLfcID]);

                    if (mFullyApproved && mPostRecursiv == false)
                    {
                        mTempMasterIds.Add((long)mFileCollection.Files[0].MasterId);
                        mTempReleaseStates.Add((long)mPWFinalStates[mCurrentLfcID]);
                        mNumberOfFullyApproved += 1;
                    }
                    N += 1;
                } //for each file collection

                if (mTempMasterIds.Count > 0) // && mNumberOfFullyApproved == mFileMasterIds.Length)
                {
                    long[] mFileMasterIds = new long[mTempMasterIds.Count];
                    mReleaseStates = new long[mTempReleaseStates.Count];

                    mFileMasterIds = mTempMasterIds.ToArray();
                    mReleaseStates = mTempReleaseStates.ToArray();

                    mgr.DocumentServiceExtensions.UpdateFileLifeCycleStates(mFileMasterIds, mReleaseStates, "Engineering, Manufacturing and Project Manager approved; set to fully released.");
                    mPostRecursiv = false;
                }

                if (mReleasedFiles.Count > 0 && N == mAllFileCollections.Length && mPostRecursiv == false)
                {
                    Form mResultForm = new mResultForm();
                    Application.EnableVisualStyles();
                    mResultForm.Show();
                    DataGridView mGrid = new DataGridView();
                    mResultForm.Controls.Add(mGrid);
                    mGrid.AutoGenerateColumns = true;
                    mGrid.ColumnCount         = 1;
                    mGrid.Columns[0].Name     = "Name";
                    mGrid.Columns[0].Width    = 430;

                    foreach (var item in mReleasedFiles)
                    {
                        DataGridViewCell cellFileName = new DataGridViewTextBoxCell();
                        DataGridViewRow  tempRow      = new DataGridViewRow();
                        cellFileName.Value = item;
                        tempRow.Cells.Add(cellFileName);
                        mGrid.Rows.Add(tempRow);
                    }
                    mGrid.Width  = 404;
                    mGrid.Height = 215;
                    mGrid.Dock   = DockStyle.Bottom;
                    mGrid.ColumnHeadersVisible = true;
                    mGrid.EditMode             = DataGridViewEditMode.EditProgrammatically;
                    mGrid.AutoSizeColumnsMode  = DataGridViewAutoSizeColumnsMode.Fill;
                    mGrid.RowHeadersWidth      = 4;
                    mGrid.RowHeadersVisible    = false;
                    System.Drawing.Point mPoint = new System.Drawing.Point();
                    mPoint.X       = 0;
                    mPoint.Y       = 55;
                    mGrid.Location = mPoint;
                }
            } // using
        }
예제 #4
0
        void UpdateFileLifecycleStateEvents_GetRestrictions(object sender, UpdateFileLifeCycleStateCommandEventArgs e)
        {
            //PWLifecycleSettings mPWSettings = PWLifecycleSettings.Load();
            if ((mPWLfcycles.Count == 0))
            {
                mReadPWLfcs(sender);
            }

            mFullyApproved = false;
            mReleasedFiles = new List <string>();
            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;

                //FileArray mFileCollection; // = mgr.DocumentService.GetFilesByMasterIds(e.FileMasterIds);
                FileArray[] mAllFileCollections = mgr.DocumentService.GetFilesByMasterIds(e.FileMasterIds);

                int N = 0;
                foreach (FileArray mFileCollection in mAllFileCollections)
                {
                    //toDo: loop for all file collections, not only for [0]
                    int numFileCol = mFileCollection.Files.Length;

                    //check that lifecycle type is of parallelApproval ? Yes -> continue
                    File mLatestFile   = mFileCollection.Files[mFileCollection.Files.Length - 1];
                    long mCurrentLfcID = mLatestFile.FileLfCyc.LfCycDefId;

                    if (!(mPWLfcycles.ContainsValue(mCurrentLfcID)))
                    {
                        return;
                    }
                    if (!(mApprovalLfcycle.Contains(mFileCollection.Files[numFileCol - 1].FileLfCyc.LfCycDefId))) //(!(mLatestFile.FileLfCyc.LfCycDefId == mLfCycle.Id))
                    {
                        return;
                    }

                    //check that current latestversion is not released state ? No -> continue
                    long mCurrentFinalStateID = (long)mPWFinalStates[mCurrentLfcID];
                    if (mLatestFile.FileLfCyc.LfCycStateId == mCurrentFinalStateID)
                    {
                        return;
                    }
                    if (mReleaseStates.Contains(mLatestFile.FileLfCyc.LfCycStateId))
                    {
                        return;
                    }

                    //check that the file(s) toStateId is a released state or member of parallel approvals states?
                    //Yes -> continue | NOT -> raise restriction
                    //if (!(mApprovalStateIDs.Contains(e.ToStateIds[N])) || !(mReleaseStates.Contains(e.ToStateIds[N])))
                    //{
                    //    return;
                    //}

                    //check that the file(s) custom state is fully approved ? yes -> continue
                    long[] mReturnFiles = new long[mFileCollection.Files.Length];
                    Int32  i            = 0;

                    foreach (File mFile in mFileCollection.Files)
                    {
                        mReturnFiles[i] = mFile.Id;
                        i += 1;
                    }
                    FileArray[] mFileHistory = null;
                    mFileHistory   = mgr.DocumentService.GetFilesByHistoryType(mReturnFiles, FileHistoryTypeOptions.All);
                    mFullyApproved = mCheckParallelFlow(sender, e, mFileHistory, (string[])mPWStatesByName[mCurrentLfcID]);
                    //if (!(mFullyApproved) && mReleaseStates.Contains(e.ToStateIds[N]) &&
                    //    mParallelStates.Contains(mFileCollection.Files[numFileCol-2].FileLfCyc.LfCycStateName))
                    if (!(mFullyApproved) && (long)mPWFinalStates[mCurrentLfcID] == e.ToStateIds[N])
                    {
                        String mFileName = mFileCollection.Files[N].Name;
                        RestrictRelease(e, "Freigabe Bedingungen", mFileName, (string[])mPWStatesByName[mCurrentLfcID]);
                    }

                    N           += 1;
                    mReturnFiles = null;
                    mFileHistory = null;
                    mLatestFile  = null;
                } //foreach file collection
            }     //using
        }
예제 #5
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
        }
예제 #6
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 { }
        }