Пример #1
0
        private void AddECRItem(DrawingRev r)
        {
            ModelDoc2 md           = (ModelDoc2)r.SwApp.ActiveDoc;
            string    partpath     = md.GetPathName();
            string    partfilename = System.IO.Path.GetFileNameWithoutExtension(partpath);

            if (md.GetPathName() == string.Empty)
            {
                md.Extension.RunCommand((int)swCommands_e.swCommands_SaveAs, md.GetTitle());
                if (md.GetPathName() == string.Empty)
                {
                    throw new Exception("Unsaved drawings cannot be added to an ECR.");
                }
                partpath     = md.GetPathName();
                partfilename = System.IO.Path.GetFileNameWithoutExtension(partpath);
            }
            string[] partarr = partfilename.Split(new string[] { "REV" }, StringSplitOptions.RemoveEmptyEntries);
            string   partno  = partarr[0].Trim();
            string   rv      = revision.Value;

            if (partarr.Length > 1)
            {
                rv = partarr[1].Trim();
            }
            string question = string.Format(Properties.Resources.InsertIntoEcrItems,
                                            System.IO.Path.GetFileName(partno),
                                            r.Eco.Value);

            swMessageBoxResult_e mbr = swMessageBoxResult_e.swMbHitNo;

            int en = 0;

            if (int.TryParse(r.Eco.Value, out en) &&
                !cutlist_data.ECRIsBogus(r.Eco.Value) &&
                !cutlist_data.ECRItemExists(en, partno, revision.Value))
            {
                mbr = (swMessageBoxResult_e)r.SwApp.SendMsgToUser2(question,
                                                                   (int)swMessageBoxIcon_e.swMbQuestion,
                                                                   (int)swMessageBoxBtn_e.swMbYesNo);
            }

            if (mbr == swMessageBoxResult_e.swMbHitYes)
            {
                OnAdded(EventArgs.Empty);
                ArchivePDF.csproj.ArchivePDFWrapper apw = new ArchivePDF.csproj.ArchivePDFWrapper(r.SwApp);
                apw.Archive();
                int parttype = 7;
                // M2M
                M2MData m = new M2MData();
                if (m.GetPartCount(partno, revision.Value) > 0)
                {
                    parttype = m.GetPartType(partno, revision.Value);
                }
                else
                {
                    // Cutlist
                    int prtid = 0;
                    if (int.TryParse(
                            cutlist_data.GetCutlistData(partno, revision.Value).Tables[0].Columns["CLID"].ToString(), out prtid))
                    {
                        if (prtid > 0)
                        {
                            parttype = 5;
                        }
                    }
                    else
                    {
                        if (cutlist_data.PartUsed(partno))
                        {
                            parttype = 6;
                        }
                    }
                }
                cutlist_data.InsertECRItem(en,
                                           partno,
                                           rv,
                                           parttype,
                                           r.Revision.Value,
                                           partpath,
                                           r.Eco.Value);
            }

            OnAddedLvl(new EventArgs());
        }
Пример #2
0
        private void AddECRItem(DrawingRev r)
        {
            ModelDoc2 md = (ModelDoc2)r.SwApp.ActiveDoc;
              string partpath = md.GetPathName();
              string partfilename = System.IO.Path.GetFileNameWithoutExtension(partpath);
              if (md.GetPathName() == string.Empty) {
            md.Extension.RunCommand((int)swCommands_e.swCommands_SaveAs, md.GetTitle());
            if (md.GetPathName() == string.Empty) {
              throw new Exception("Unsaved drawings cannot be added to an ECR.");
            }
            partpath = md.GetPathName();
            partfilename = System.IO.Path.GetFileNameWithoutExtension(partpath);
              }
              string[] partarr = partfilename.Split(new string[] { "REV" }, StringSplitOptions.RemoveEmptyEntries);
              string partno = partarr[0].Trim();
              string rv = revision.Value;
              if (partarr.Length > 1) {
            rv = partarr[1].Trim();
              }
              string question = string.Format(Properties.Resources.InsertIntoEcrItems,
            System.IO.Path.GetFileName(partno),
            r.Eco.Value);

              swMessageBoxResult_e mbr = swMessageBoxResult_e.swMbHitNo;

              int en = 0;
              if (int.TryParse(r.Eco.Value, out en) &&
            !cutlist_data.ECRIsBogus(r.Eco.Value) &&
            !cutlist_data.ECRItemExists(en, partno, revision.Value)) {

            mbr = (swMessageBoxResult_e)r.SwApp.SendMsgToUser2(question,
            (int)swMessageBoxIcon_e.swMbQuestion,
            (int)swMessageBoxBtn_e.swMbYesNo);
              }

              if (mbr == swMessageBoxResult_e.swMbHitYes) {
            OnAdded(EventArgs.Empty);
            ArchivePDF.csproj.ArchivePDFWrapper apw = new ArchivePDF.csproj.ArchivePDFWrapper(r.SwApp);
            apw.Archive();
            int parttype = 7;
            // M2M
            M2MData m = new M2MData();
            if (m.GetPartCount(partno, revision.Value) > 0) {
              parttype = m.GetPartType(partno, revision.Value);
            } else {
              // Cutlist
              int prtid = 0;
              if (int.TryParse(
            cutlist_data.GetCutlistData(partno, revision.Value).Tables[0].Columns["CLID"].ToString(), out prtid)) {
            if (prtid > 0) {
              parttype = 5;
            }
              } else {
            if (cutlist_data.PartUsed(partno)) {
              parttype = 6;
            }
              }
            }
            cutlist_data.InsertECRItem(en,
              partno,
              rv,
              parttype,
              r.Revision.Value,
              partpath,
              r.Eco.Value);
            }

              OnAddedLvl(new EventArgs());
        }