예제 #1
0
        private void OnMenuClick3(object sender, EventArgs e)
        {
            var dte = ServiceProvider.GetService(typeof(DTE)) as DTE;

            if (dte != null && dte.SelectedItems.Count == 1 && dte.SelectedItems.Item(1).Name.EndsWith(Constants.ExtName))
            {
                var selectedItem    = dte.SelectedItems.Item(1).ProjectItem;
                var selectedProject = selectedItem.ContainingProject;

                var provider = ErrorTracking.Provider;

                ErrorTracking.Provider = this;

                ErrorTracking.ClearError();

                var builder = new FBSProject(selectedProject.Name, GetAllFBSFiles(selectedProject), ErrorHandler);
                var file    = builder.Build(selectedItem.FileNames[0]);
                if (errorCount <= 0)
                {
                    if (file.RootTable != null)
                    {
                        var xls  = file.RootTable.Attributes.GetAttribute <XLS>();
                        var json = file.RootTable.Attributes.GetAttribute <JsonFile>();
                        var csv  = file.RootTable.Attributes.GetAttribute <CSV>();
                        if (json != null)
                        {
                            List <string> errors = new List <string>();
                            var           obj    = JsonUtil.ParseJson(json.filePath, file.RootTable, file.RootTable.Attributes, ErrorHandler);
                            foreach (var error in errors)
                            {
                                package.AddError(json.filePath, json.filePath, error, 0, 0);
                            }
                        }
                        else if (csv != null)
                        {
                            CsvUtil.ParseCSV(csv.filePath, csv, file.RootTable, file.RootTable.Attributes);
                        }
                        //new DataReaderFactory(selectedProject.Name, ErrorHandler).ReadData(file.RootTable);
                    }
                }

                ErrorTracking.Provider = provider;
            }
        }