Пример #1
0
        public static string GetExportNameFromNamingRule(PDFExportOptions opts, ExportSheet vs)
        {
            var    segs         = opts.GetNamingRule();
            string filenameTest = string.Empty;

            foreach (var seg in segs)
            {
                filenameTest += seg.Prefix;
                var pid       = seg.ParamId;
                var cid       = seg.CategoryId;
                var cidString = cid.ToString();
                if (cid.IntegerValue == (int)BuiltInCategory.OST_ProjectInformation)
                {
                    var param = vs.Sheet.Document.ProjectInformation.Parameters.Cast <Parameter>().Where(p => p.Id == pid);
                    if (param.Count() > 0)
                    {
                        var paramValue = param.First().AsValueString();
                        filenameTest += paramValue;
                    }
                }
                else
                {
                    var param = vs.Sheet.Parameters.Cast <Parameter>().Where(p => p.Id == pid);
                    if (param.Count() > 0)
                    {
                        // if (param.First().Definition.Name == "Current Revision" && vs.ForceDate)
                        // {
                        //     filenameTest += "Current Revision";
                        // }
                        // else
                        // {
                        var paramValue = param.First().AsValueString();
                        if (paramValue.Length < 1)
                        {
                            filenameTest += "Current Revision";
                        }
                        else
                        {
                            filenameTest += paramValue;
                        }
                        //// }
                    }
                }
                filenameTest += seg.Suffix;
                filenameTest += seg.Separator;
            }
            return(filenameTest);
        }