Пример #1
0
        /// <summary>
        /// Occurs when user press "Enter" on edited grid row.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridCollectionViewSource_CommittingEdit(object sender, DataGridItemCancelEventArgs e)
        {
            try
            {
                if (_isEditeStart && !string.IsNullOrEmpty(_selectedProfileName))
                {
                    ReportInfo editedInfo = App.Current.ReportGenerator.GetReportInfo(_selectedProfileName);
                    if (null != editedInfo)
                    {
                        Debug.Assert(!editedInfo.IsPredefined);

                        ReportDataWrapper selectedItem = xceedGridReports.CurrentItem as ReportDataWrapper;

                        string templatePath = ReportsGenerator.GetNewTemplatePath(selectedItem.Name, editedInfo.TemplatePath);

                        string fileSrcName  = ReportsGenerator.GetTemplateAbsolutelyPath(editedInfo.TemplatePath);
                        string fileDestName = ReportsGenerator.GetTemplateAbsolutelyPath(templatePath);
                        File.Move(fileSrcName, fileDestName);

                        _selectedProfileName = editedInfo.Name = selectedItem.Name;
                        ReportDataWrapper.StartTemplatePath = templatePath;
                        ReportDataWrapper.StartTemplateName = _selectedProfileName;
                        editedInfo.TemplatePath             = templatePath;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                App.Current.Messenger.AddError(ex.Message);
            }

            _isEditeStart = false;
            e.Handled     = true;
        }
Пример #2
0
        /// <summary>
        /// Duplicates report template file.
        /// </summary>
        /// <param name="srcTemplatePath">Source template file path.</param>
        /// <param name="dubTemplatePath">Doublecate template file path.</param>
        private void _DuplicateReportFile(string srcTemplatePath, string dubTemplatePath)
        {
            Debug.Assert(!string.IsNullOrEmpty(srcTemplatePath));
            Debug.Assert(!string.IsNullOrEmpty(dubTemplatePath));

            string fileSrcName  = ReportsGenerator.GetTemplateAbsolutelyPath(srcTemplatePath);
            string fileDestName = ReportsGenerator.GetTemplateAbsolutelyPath(dubTemplatePath);

            File.Copy(fileSrcName, fileDestName, true);
        }
Пример #3
0
        /// <summary>
        /// Edit button click handler.
        /// </summary>
        private void _EditTemplate_Click(object sender, RoutedEventArgs e)
        {
            ReportInfo info = _GetSelectedInfo();

            if (null != info)
            {
                string reportTemplatePath = ReportsGenerator.GetTemplateAbsolutelyPath(info.TemplatePath);

                EndUserDesignerForm form = new EndUserDesignerForm(info.Name, reportTemplatePath);
                form.Show();
            }
        }
Пример #4
0
        /// <summary>
        /// Delete button click handler.
        /// </summary>
        private void _DeleteTemplate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ReportInfo selectedInfo = _GetSelectedInfo();
                if (null != selectedInfo)
                {
                    bool doProcess = true;
                    if (Settings.Default.IsAllwaysAskBeforeDeletingEnabled)
                    {
                        // show warning dialog
                        doProcess = DeletingWarningHelper.Execute(selectedInfo.Name, "ReportTemplate", "ReportTemplate");
                    }

                    if (doProcess)
                    {
                        App.Current.ReportGenerator.DeleteReportInfo(selectedInfo.Name);
                        _itemIndexToSelection = xceedGridReports.SelectedIndex;

                        // remove template file
                        string reportTemplatePath = ReportsGenerator.GetTemplateAbsolutelyPath(selectedInfo.TemplatePath);
                        _DeleteFileSafe(reportTemplatePath);

                        // remove sub report templates
                        foreach (SubReportInfo subReport in selectedInfo.SubReports)
                        {
                            reportTemplatePath = ReportsGenerator.GetTemplateAbsolutelyPath(subReport.TemplatePath);
                            _DeleteFileSafe(reportTemplatePath);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            _InitReportTable();
        }
Пример #5
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);
        }