コード例 #1
0
        /// <summary>
        /// Parse out the Building / Phase, separator, Sheet ID, sheet name
        /// </summary>
        /// <param name="sheetPdf"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public bool Parse2(FileNameSheetPdf sheetPdf, string filename)
        {
            sheetPdf.isPhaseBldg = null;
            sheetPdf.shtCompType = ShtCompTypes.UNASSIGNED;

            Match match = patternShtNumAndName.Match(filename);

            if (!match.Success)
            {
                sheetPdf.fileType = FileTypeSheetPdf.INVALID;
                return(false);
            }

            GroupCollection g = match.Groups;

            string test;

            // phase-bldg
            test = g[ShtIds.CompGrpName2(ShtCompTypes.PHBLDG, PHBLDG_COMP_IDX)].Value;

            if (!test.IsVoid())
            {
                sheetPdf.SheetComps[PHBLDG_VALUE_IDX] = test;
                sheetPdf.SheetComps[PBSEP_VALUE_IDX]  =
                    g[ShtIds.CompGrpName2(ShtCompTypes.PHBLDG, PBSEP_COMP_IDX)].Value;
                sheetPdf.sheetID = g[ShtIds.CompGrpName2(ShtCompTypes.PHBLDG, SHTID_COMP_IDX)].Value;

                sheetPdf.isPhaseBldg = true;
            }
            else
            {
                sheetPdf.sheetID     = g[ShtIds.CompGrpName2(ShtCompTypes.PHBLDG, SHTID_COMP_IDX)].Value;
                sheetPdf.isPhaseBldg = false;
            }

            sheetPdf.originalSheetTitle = g[ShtIds.CompGrpName2(ShtCompTypes.PHBLDG, SHTNAME_COMP_IDX)].Value;

            sheetPdf.sheetTitle = sheetPdf.originalSheetTitle;

            return(true);
        }
コード例 #2
0
        internal bool ParseType(ShtCompTypes type, GroupCollection g, FileNameSheetPdf shtIdComps)
        {
            string test;

            bool?use      = null;         // false is optional & true is required
            bool hasPrior = false;
            bool inOptSeq = false;

            foreach (SheetCompInfo2 ci in ShtIds.ShtCompList2[(int)type].ShtCompInfo)
            {
                if (!ci.IsUseOK)
                {
                    return(false);
                }

                if (ci.SeqCtrlUse == SeqCtrlUse2.SKIP ||
                    ci.SeqCtrlUse == SeqCtrlUse2.NOT_USED)
                {
                    continue;
                }

                if (ci.SeqCtrlUse == SeqCtrlUse2.OPTIONAL)
                {
                    use = false;
                }
                else if (ci.SeqCtrlUse == SeqCtrlUse2.REQUIRED)
                {
                    use = true;
                }

                if (inOptSeq)
                {
                    if (ci.GetNextOpt() == SeqCtrlNextOpt.SEQ_END)
                    {
                        inOptSeq = false;
                    }

                    continue;
                }

                test = g[ci.GrpName].Value;

                if (use == true)
                {
                    // required
                    if (!ci.IsReqdProceedOK || !ci.IsReqdNextOK)
                    {
                        return(false);
                    }

                    if (test.IsVoid())
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!ci.IsOptProceedOK || !ci.IsOptNextOK)
                    {
                        return(false);
                    }

                    // optional
                    if (test.IsVoid())
                    {
                        // no test value
                        if (ci.GetNextOpt() == SeqCtrlNextOpt.SEQ_END_SEQ_REQ)
                        {
                            return(false);
                        }
                        if (hasPrior && ci.GetNextOpt() == SeqCtrlNextOpt.REQ_IF_PRIOR)
                        {
                            return(false);
                        }

                        if (ci.GetNextOpt() == SeqCtrlNextOpt.SEQ_START)
                        {
                            inOptSeq = true;
                        }

                        hasPrior = false;
                        continue;
                    }

                    // not void - has a test value

                    if (ci.GetNextOpt() == SeqCtrlNextOpt.SEQ_END_SEQ_REQ)
                    {
                        inOptSeq = false;
                    }
                }

                shtIdComps.SheetComps[ci.ValueIndex] = test;

                hasPrior = true;

                if (ci.GetProceedOpt() == SeqCtrlProceedOpt.END ||
                    ci.GetProceedReqd() == SeqCtrlProceedReqd.END)
                {
                    break;
                }
            }

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// parse out the components of a sheet id
        /// </summary>
        /// <returns></returns>
        public bool ParseSheetId2(FileNameSheetPdf shtIdComps, string shtId)
        {
            bool status = true;

            if (shtId.IsVoid() ||
                shtIdComps.fileType != FileTypeSheetPdf.SHEET_PDF)
            {
                status = false;
            }
            else
            {
                Match match = shtIdPattern.Match(shtId);

                if (match.Success)
                {
                    GroupCollection g = match.Groups;

                    shtIdComps.shtCompType = GetShtCompTypeFromGrpCollection(g);

                    try
                    {
                        if (!ParseType(shtIdComps.shtCompType, g, shtIdComps))
                        {
                            status = false;
                        }
                    }
                    catch
                    {
                        status = false;
                    }

                    if (status)
                    {
                        shtIdComps.hasIdentifier = false;

                        // if (!ParseIdent(g, shtIdComps)) status = false;
                        if (!ParseType(ShtCompTypes.IDENT, g, shtIdComps))
                        {
                            status = false;
                        }
                        else
                        {
                            if (!shtIdComps.SheetComps[SEP4_VALUE_IDX].IsVoid())
                            {
                                shtIdComps.hasIdentifier = true;
                            }
                        }
                    }
                }
                else
                {
                    status = false;
                }
            }

            if (!status)
            {
                shtIdComps.fileType = FileTypeSheetPdf.INVALID;
                return(false);
            }

            return(true);
        }