Esempio n. 1
0
        private void OnTaskDetails(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            try
            {
                IEdmTaskInstance TaskInstance = (IEdmTaskInstance)poCmd.mpoExtra;
                if ((TaskInstance != null))
                {
                    // SetupPageObj;//= new SetupPage((IEdmVault7)poCmd.mpoVault, TaskInstance);
                    return;

                    //Force immediate creation of the control
                    //and its handle
                    //SetupPageObj.CreateControl();
                    // SetupPageObj.LoadData(poCmd);
                    // SetupPageObj.DisableControls();
                    poCmd.mbsComment = "State Age Details";
                    //  poCmd.mlParentWnd = SetupPageObj.Handle.ToInt32();
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public AutoCADTaskAddin(EdmCmd poCmd, EdmCmdData[] ppoData, AutoCADTaskSettings taskSettings)
        {
            //Get the task instance interface
            inst     = poCmd.mpoExtra as IEdmTaskInstance;
            data     = ppoData;
            settings = taskSettings;
            if (inst == null)
            {
                throw new Exception("Task values incorrect");
            }

            vault = (IEdmVault20)poCmd.mpoVault;

            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTcwMjQwQDMxMzcyZTMzMmUzMGhycFlDaldXNDVZeWxhdnFwckswQnRhMHVwclp2OWNrUEltNHczb21ENDQ9;MTcwMjQxQDMxMzcyZTMzMmUzMG4xOFQ1dnBDR1oxalUvazM5UmlTRkdUelJRcHkweURnVERXRXRabnpaZVE9");
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the status of a task to EdmTaskStat_DoneFailed and sends correct message based on argument Exception.
        /// </summary>
        /// <param name="poCmd"></param>
        /// <param name="ex"></param>
        protected void SetTaskError(EdmCmd poCmd, Exception ex)
        {
            string msg;

            IEdmTaskInstance taskInst = poCmd.mpoExtra as IEdmTaskInstance;

            if (taskInst != null)
            {
                int hres = 0;
                if (ex is COMException)
                {
                    hres = (ex as COMException).ErrorCode;
                }
                var dt = DateTime.Now.ToString();
                msg = string.Format("{0} --- {1}", dt, ex.ToString());
                taskInst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, hres, msg);
            }
        }
Esempio n. 4
0
        private void OnTaskRun(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            IEdmTaskInstance inst = default(IEdmTaskInstance);

            inst = (IEdmTaskInstance)poCmd.mpoExtra;

            IEdmVault5 vault = new EdmVault5();

            try
            {
                for (int i = 0; i < ppoData.Length; i++)
                {
                    if (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1 != 0)
                    {
                        vault = (IEdmVault5)poCmd.mpoVault;
                        IEdmObject5 folderObject = vault.GetObject(EdmObjectType.EdmObject_Folder, ((EdmCmdData)ppoData.GetValue(i)).mlObjectID2);
                        IEdmFolder5 ef           = (IEdmFolder5)folderObject;
                        IEdmObject5 fileObject   = vault.GetObject(EdmObjectType.EdmObject_File,
                                                                   ((EdmCmdData)ppoData.GetValue(i)).mlObjectID1);
                        string fullpath = ef.LocalPath + "\\" + fileObject.Name;

                        DxfLoad dxfl = new DxfLoad();
                        var     sp   = dxfl.GetSpecification(fullpath, "");
                        dxfl.UpLoadDxf(sp);
                        XmlFile xf = new XmlFile();
                        xf.DownloadXml(fullpath);
                    }

                    SolidWorksPdmAdapter.Instance.KillProcsses("SLDWORKS");
                    MessageObserver.Instance.SetMessage("End upload.\n");
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, ex.ErrorCode, "The test task failed!");
            }
            catch (Exception ex)
            {
                MessageObserver.Instance.SetMessage(ex.Message);
            }
        }
Esempio n. 5
0
        private void OnTaskRun(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            //Get the task instance interface
            IEdmTaskInstance inst = poCmd.mpoExtra as IEdmTaskInstance;

            if (inst == null)
            {
                return;
            }
            try
            {
                AutoCADTaskSettings taskSettings;
                string settings = inst.GetValEx(AutoCADTaskSettings.Acadtask_Settings) as string;
                if (!string.IsNullOrEmpty(settings))
                {
                    taskSettings = JsonConvert.DeserializeObject <AutoCADTaskSettings>(settings);
                }
                else
                {
                    taskSettings = new AutoCADTaskSettings();
                }

                var tas = new AutoCADTaskAddin(poCmd, ppoData, taskSettings);
                tas.runTask();
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                log.Error(ex);
                inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, ex.ErrorCode, "The test task failed!");
            }
            catch (Exception ex)
            {
                log.Error(ex);
                inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, 0, "", "The test task failed!");
            }
        }
Esempio n. 6
0
        void OnTaskRun(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            var statusTask = true;

            edmTaskInstance = (IEdmTaskInstance)poCmd.mpoExtra;
            edmTaskInstance.SetStatus(EdmTaskStatus.EdmTaskStat_Running);
            List <Files.Info> filesToConvert = null;

            try
            {
                var vault = poCmd.mpoVault as IEdmVault7;

                InitializeErrorList();

                filesToProceed = 1;

                filesPdm  = Files.GetFilesToConvert(vault, ref poCmd, ref ppoData);
                FilesList = Batch.UpdateFileInfo(vault, filesPdm);

                filesToConvert = FilesList.Where(x => !x.ExistCutList | !x.ExistDXF /*| !x.ExistEdrawing*/).ToList();

                Logger.Add($@"\n\n{new string('-', 500)}\nTime {DateTime.Now}\nЗадача '{edmTaskInstance.TaskName}'
                            ID: {edmTaskInstance.ID}, для {filesToConvert.Count} элемента(ов), OnTaskRun ver.{currentVer}");

                edmTaskInstance.SetProgressRange(filesToConvert.Count, 0, $"Запуск задачи в {DateTime.Now}");

                GetAndDeleteUnnecesseryFromPdm(vault, filesToConvert);

                // Run SldWorks

                if (filesToConvert.Count != 0)
                {
                    KillSwAndStartNewProccess();

                    // Разбиваем лист на группы
                    var nChunks     = 1;
                    var totalLength = filesToConvert.Count();
                    var chunkLength = (int)Math.Ceiling(totalLength / (double)nChunks);
                    var partsToList = Enumerable.Range(0, chunkLength).Select(i => filesToConvert.Skip(i * nChunks).Take(nChunks).ToList()).ToList();

                    for (var i = 0; i < partsToList.Count; i++)
                    {
                        if (!ConvertChunk(vault, partsToList[i]))
                        {
                            statusTask = false;
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                statusTask = false;
                this.ex    = ex;
                Logger.Add("OnTaskRun HRESULT = 0x" + ex.ErrorCode.ToString("X") + "; " + ex.StackTrace + "; \n" + ex.Message);
            }
            catch (Exception ex)
            {
                statusTask = false;
                this.ex    = ex;
                Logger.Add(ex.Message + ";\n" + ex.StackTrace);
            }
            finally
            {
                if (ListWithConvertErrors?.Count > 0)
                {
                    statusTask = false;
                    try
                    {
                        var message = "";
                        foreach (var item in ListWithConvertErrors)
                        {
                            message = message + "\n" + $"FileName - {item.FileName} FolderID - {item.FolderID} IdPDM - {item.IdPDM} Revision {item.Revision}";
                        }
                        Logger.Add(message);
                    }
                    catch (Exception)
                    {
                        Logger.Add("Ошибки при выгрузке данных об ошибке");
                    }
                }

                edmTaskInstance.SetProgressPos(filesToConvert.Count, "Выполнено, ID = " + edmTaskInstance.ID);
                edmTaskInstance.SetStatus(statusTask ? EdmTaskStatus.EdmTaskStat_DoneOK : EdmTaskStatus.EdmTaskStat_DoneFailed, GetHashCode());
            }
        }