示例#1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Inits report table.
        /// </summary>
        private void _InitReportTable()
        {
            ReportsGenerator generator = App.Current.ReportGenerator;

            if (null != generator)
            {
                Debug.Assert(null != _viewSourceReports);

                List <ReportDataWrapper> reportsWrap = new List <ReportDataWrapper>();
                foreach (string name in generator.GetPresentedNames(false))
                {
                    reportsWrap.Add(new ReportDataWrapper(name));
                }

                _viewSourceReports.Source = reportsWrap;
            }
        }
示例#2
0
        private int _GetSubReportsCount(SelectReportWrapper reportWrapper)
        {
            ReportsGenerator generator = App.Current.ReportGenerator;

            Debug.Assert(null != App.Current.ReportGenerator);
            Debug.Assert(generator.GetPresentedNames(false).Contains(reportWrapper.Name.Name));

            ReportInfo report = generator.GetReportInfo(reportWrapper.Name.Name);

            int result = 0;

            if ((null != report) && (null != report.SubReports))
            {
                result = report.SubReports.Count;
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// Gets template dublicate unique name.
        /// </summary>
        /// <param name="oldName">Source template name.</param>
        /// <returns>Dublicate unique name.</returns>
        private string _GetNameForDublicate(string sourceName)
        {
            ReportsGenerator     generator  = App.Current.ReportGenerator;
            ICollection <string> collection = generator.GetPresentedNames(true);

            int k = 2;

            string newName = string.Format((string)App.Current.FindResource("ItemCopyShortName"), sourceName);

            if (collection.Contains(newName))
            {
                newName = string.Format((string)App.Current.FindResource("ItemCopyLongName"), k, sourceName);
                while (collection.Contains(newName))
                {
                    ++k;
                    newName = string.Format((string)App.Current.FindResource("ItemCopyLongName"), k, sourceName);
                }
            }

            return(newName);
        }
示例#4
0
        public override ValidationResult Validate(object value, CultureInfo culture, CellValidationContext context)
        {
            // not empty check
            bool isObjectEmpty = true;

            if (null != value)
            {
                isObjectEmpty = string.IsNullOrEmpty(value.ToString().Trim());
            }
            if (isObjectEmpty)
            {
                return(new ValidationResult(false, (string)Application.Current.FindResource("ReportTemplateEmptyName")));
            }

            // unique name check
            string name = value.ToString();

            if (!string.IsNullOrEmpty(ReportDataWrapper.StartTemplateName))
            {
                if (0 == string.Compare(ReportDataWrapper.StartTemplateName, name, true))
                {
                    return(ValidationResult.ValidResult);
                }
            }

            ReportsGenerator     generator      = App.Current.ReportGenerator;
            ICollection <string> presentedNames = generator.GetPresentedNames(true);

            foreach (string nameTemplate in presentedNames)
            {
                if (0 == string.Compare(nameTemplate, name, true))
                {
                    return(new ValidationResult(false, (string)Application.Current.FindResource("ReportTemplateNotUniqueName")));
                }
            }

            // normal length check
            bool   isLong       = false;
            string templatePath = ReportsGenerator.GetNewTemplatePath(name, ReportDataWrapper.StartTemplatePath);
            string fileName     = null;

            try
            {
                fileName = ReportsGenerator.GetTemplateAbsolutelyPath(templatePath);
                new FileInfo(fileName);
            }
            catch (PathTooLongException)
            {
                isLong = true;
            }
            catch (Exception)
            {
            }

            if (isLong)
            {
                return(new ValidationResult(false, (string)Application.Current.FindResource("ReportTemplateLongName")));
            }

            // valid name check
            if (!FileHelpers.ValidateFilepath(fileName))
            {
                return(new ValidationResult(false, (string)Application.Current.FindResource("ReportTemplateInvalidName")));
            }

            return(ValidationResult.ValidResult);
        }