Пример #1
0
        public static void SaveTemplate(ChartTemplateInfo template)
        {
            try
            {
                if (template.ID <= 0)
                {
                    string tempType = template.TEMPLATE_TYPE;
                    string name     = template.NAME;

                    FrmSaveTemplate frm = new FrmSaveTemplate(tempType, name);
                    frm.ShowDialog();

                    if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        template.NAME          = frm.TemplateName;
                        template.TEMPLATE_TYPE = frm.TemplateType;
                    }
                    else
                    {
                        return;
                    }
                }

                string path = AppDomain.CurrentDomain.BaseDirectory + "\\ChartTemplate\\" + template.TEMPLATE_TYPE + "_" + template.NAME + ".xml";

                if (Instance.CurrentModuleBase == null)
                {
                    return;
                }
                ChartModuleBase chartDemoBase = Instance.CurrentModuleBase.TModule as ChartModuleBase;
                if (chartDemoBase == null)
                {
                    return;
                }
                chartDemoBase.ChartControl.SaveToFile(path);

                byte[] file = File.ReadAllBytes(path);

                template.TEMPLATE_FILE = file;
                File.Delete(path);

                MB.WinDxChart.Chart.DxChartControlHelper.Instance.SaveChartTemplate(template);
            }
            catch (Exception ex)
            {
                MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex);
            }
        }
Пример #2
0
        public virtual void SaveChartControl(ChartTemplateInfo template)
        {
            try
            {
                if (template.ID <= 0 || string.IsNullOrEmpty(template.NAME))
                {
                    string tempType = template.TEMPLATE_TYPE;
                    string name     = template.NAME;

                    FrmSaveTemplate frm = new FrmSaveTemplate(tempType, name);
                    frm.ShowDialog();

                    if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        template.NAME          = frm.TemplateName;
                        template.TEMPLATE_TYPE = frm.TemplateType;
                    }
                    else
                    {
                        return;
                    }
                }

                string basePath = AppDomain.CurrentDomain.BaseDirectory + "\\ChartTemplate\\";
                if (!Directory.Exists(basePath))
                {
                    Directory.CreateDirectory(basePath);
                }

                string path = basePath + template.TEMPLATE_TYPE + "_" + template.NAME + ".xml";
                ChartControl.SaveToFile(path);

                byte[] file = File.ReadAllBytes(path);

                template.TEMPLATE_FILE = file;
                File.Delete(path);

                MB.WinDxChart.Chart.DxChartControlHelper.Instance.SaveChartTemplate(template);
            }
            catch (Exception ex)
            {
                MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex);
            }
        }