예제 #1
0
        public void AddErrorLog(IFreeDocument item, Exception ex, IColumnProcess process)
        {
            if (string.IsNullOrEmpty(errorLogName))
            {
                return;
            }
            var param = item.Clone() as FreeDocument;

            param["__SysObjectID"] = process.ObjectID;
            param["__SysETL"]      = (process as ToolBase)?.Father.Name;
            param["__SysERROR"]    = ex.Message;
            param["__SysTime"]     = DateTime.Now.ToString();
            ControlExtended.UIInvoke(() =>
            {
                if (ConfigFile.GetConfig <DataMiningConfig>().IsAddErrorCollection)
                {
                    if (errorCollection == null)
                    {
                        errorCollection = new DataCollection()
                        {
                            Name = errorLogName
                        };
                        DataManager.AddDataCollection(errorCollection);
                    }
                    errorCollection?.ComputeData.Add(param);
                    errorCollection?.OnPropertyChanged("Count");
                }
                else
                {
                    XLogSys.Print.Error(string.Format(GlobalHelper.Get("key_208"), process.Column, process.TypeName, ex));
                }
            });
        }
예제 #2
0
        private Project LoadProject(Project project, bool keepLast = false)
        {
            if (project != null)
            {
                var config = ConfigFile.GetConfig <DataMiningConfig>();
                config.Projects.RemoveElementsNoReturn(d => string.IsNullOrWhiteSpace(d.SavePath));
                var first = config.Projects.FirstOrDefault(d => d.SavePath == project.SavePath);
                if (first != null)
                {
                    config.Projects.Remove(first);
                }
                else
                {
                    first = new ProjectItem();
                    project.DictCopyTo(first);
                }
                if (!keepLast)
                {
                    CleanAllItems();
                }
                dataManager.LoadDataConnections(project.DBConnections);
                if (project.DataCollections?.Count > 0)
                {
                    //TODO: 添加名称重名?

                    project.DataCollections.Execute(d => dataManager.AddDataCollection(d));
                }
                config.Projects.Insert(0, first);
                CurrentProject = project;
                var name = Path.GetFileNameWithoutExtension(project.SavePath);
                if (string.IsNullOrEmpty(CurrentProject.Name))
                {
                    CurrentProject.Name = name;
                }

                foreach (var task in project.Tasks)
                {
                    task.Load(false);
                }
                if (string.IsNullOrEmpty(project.ConfigSelector.SelectItem) == false)
                {
                    this.CurrentProject.ConfigSelector.SelectItem = project.ConfigSelector.SelectItem;
                }
                else
                {
                    this.CurrentProject.ConfigSelector.SetDefault();
                }
                NotifyCurrentProjectChanged();
                config.SaveConfig();
                project.LoadRunningTasks();
            }
            return(project);
        }
예제 #3
0
파일: TableEX.cs 프로젝트: zzzz123321/Hawk
        public override bool Init(IEnumerable <IFreeDocument> datas)
        {
            collection = dataManager.DataCollections.FirstOrDefault(d => d.Name == Table);
            if (collection == null && string.IsNullOrEmpty(Table) == false)

            {
                collection = new DataCollection(new List <IFreeDocument>())
                {
                    Name = Table
                };
                dataManager.AddDataCollection(collection);
            }

            return(base.Init(datas));
        }
예제 #4
0
        public override IEnumerable <IFreeDocument> Execute(IEnumerable <IFreeDocument> documents)
        {
            foreach (var document in documents)
            {
                var name = AppHelper.Query(Table, document);
                Monitor.Enter(this);
                collection = dataManager.DataCollections.FirstOrDefault(d => d.Name == name);
                if (collection == null)
                {
                    if (string.IsNullOrEmpty(name) == false)
                    {
                        collection = new DataCollection(new List <IFreeDocument>())
                        {
                            Name = name
                        };
                        dataManager.AddDataCollection(collection);
                    }
                }
                Monitor.Exit(this);
                if (collection == null)
                {
                    XLogSys.Print.Error(GlobalHelper.Get("create_collection_error"));
                    yield return(document);

                    continue;
                }



                ControlExtended.UIInvoke(() =>
                {
                    var data = document.Clone();
                    Monitor.Enter(collection);
                    collection.ComputeData.Add(data);
                    collection.OnPropertyChanged("Count");
                    Monitor.Exit(collection);
                });



                yield return(document);
            }
        }