public List <Table> Preview(SourceOption option) { using (var dialog = new OpenFileDialog()) { dialog.Filter = "Power Designer|*.pdm"; if (dialog.ShowDialog() != DialogResult.OK) { return(null); } pdmFileName = dialog.FileName; } var pdm = PdmParser.Parse(pdmFileName); using (var frm = new frmTableSelector(pdm)) { if (frm.ShowDialog() == DialogResult.OK) { return(frm.Selected); } } return(null); }
public override bool Delete(string sourceID, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "DELETE FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_CHANGE_IN + " " + opt + " @id"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@id", System.Data.DbType.Int32) { Value = sourceID }); db.ExecuteNonQuery(cmdText, paramList); } return(true); }
public override FolderMetadata LoadFolderMetadata(string currId, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; var folderMetadata = new FolderMetadata(currId, this.RootPath); var db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "SELECT * FROM " + Configuration.TLB_FOLDERMETADATA + " WHERE " + Configuration.COL_SOURCE_ID + opt + " @sourceId"; var paramList = new SqliteParameterCollection { new SqliteParameter("@sourceId", DbType.String) { Value = currId } }; db.ExecuteReader(cmdText, paramList, reader => folderMetadata.FolderMetadataItems.Add( new FolderMetadataItem( (string)reader[Configuration.COL_SOURCE_ID], (string)reader[Configuration.COL_FOLDER_RELATIVE_PATH], (int)reader[Configuration.COL_IS_FOLDER_EMPTY]))); } return(folderMetadata); }
public override FileMetaData LoadFileMetadata(string currId, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; var mData = new FileMetaData(currId, RootPath); var db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = string.Format("SELECT * FROM {0} WHERE {1}{2} @sourceId", Configuration.TBL_METADATA, Configuration.COL_SOURCE_ID, opt); var paramList = new SqliteParameterCollection { new SqliteParameter("@sourceId", DbType.String) { Value = currId } }; db.ExecuteReader(cmdText, paramList, reader => mData.MetaDataItems.Add(new FileMetaDataItem( (string)reader[Configuration.COL_SOURCE_ID], (string)reader[Configuration.COL_RELATIVE_PATH], (string)reader[Configuration.COL_HASH_CODE], (DateTime)reader[Configuration.COL_LAST_MODIFIED_TIME], Convert.ToUInt32(reader[Configuration.COL_NTFS_ID1]), Convert.ToUInt32(reader[Configuration.COL_NTFS_ID2])))); } return(mData); }
public List <Table> Preview(SourceOption option) { IEnumerable <Table> tables = null; using (var frm = new frmSourceMgr()) { if (frm.ShowDialog() == DialogResult.OK) { con = frm.DbConStr; tables = OpenDb(option); } } if (tables == null) { return(null); } using (var frm = new frmTableSelector(tables)) { if (frm.ShowDialog() == DialogResult.OK) { return(frm.Selected.Count == 0 ? null : frm.Selected); } } return(null); }
public async Task <MinerData> GetMinerData(int executionID, SourceOption source) { MinerData minerData = await TheMinerDataContr.GetMinerData(executionID, source); // Return only the needed fields as an instance of the base class return(new MinerData(minerData)); }
public async Task UpdateSearchRequestStatus(Status newStatus, SourceOption finishedSourceID) { Status currentStatus = (await GetTheSearchRequest()).TheStatus; // Avoid going backwards if (newStatus <= currentStatus) { return; } // In the case that the Miners are being awaited, progress when all of them have finished if (newStatus == Status.Mining_Done) // If a miner finished { MiningSource minersLeft = await DecreaseTheSourcesLeft(NewStateNames.TheMinersToFinish, finishedSourceID); if (minersLeft.IsEmpty() != true) // If there are miners that haven't finished yet { return; } } // In the case that the Analysers are being awaited, progress when all of them have finished if (newStatus == Status.Analysing_Done) // If an analysers finished { MiningSource analysersLeft = await DecreaseTheSourcesLeft(NewStateNames.TheAnalysersToFinish, finishedSourceID); if (analysersLeft.IsEmpty() != true) // If there are analysers that haven't finished yet { return; } } await SetTheSearchRequestStatus(newStatus); await RegisterReminderAsync(ReminderNames.FulfillSReqReminder); }
public void SetFromList(List <SourceOption> theList) { TheSelection = 0; foreach (var option in theList) { TheSelection |= option; } }
public override IList <SyncAction> Load(string sourceID, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; IList <SyncAction> actions = new List <SyncAction>(); SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME), false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) { throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); } string cmdText = "SELECT * FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_CHANGE_IN + opt + " @sourceId"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@sourceId", System.Data.DbType.String) { Value = sourceID }); db.ExecuteReader(cmdText, paramList, reader => { ChangeType actionType = (ChangeType)reader[Configuration.COL_ACTION_TYPE]; if (actionType == ChangeType.DELETED) { DeleteAction delAction = new DeleteAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_OLD_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_HASH]); actions.Add(delAction); } else if (actionType == ChangeType.NEWLY_CREATED) { CreateAction createAction = new CreateAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_NEW_RELATIVE_PATH], (string)reader[Configuration.COL_NEW_HASH]); actions.Add(createAction); } else if (actionType == ChangeType.RENAMED) { RenameAction renameAction = new RenameAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_NEW_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_HASH]); actions.Add(renameAction); } } ); } return(actions); }
public MinerData(int theBEExecID, SourceOption theSource) { TheExecutionID = theBEExecID; TheSource = theSource; TheTextsNum = 0; ThePositivesNum = 0; TheNegativesNum = 0; TheBEExecution = null; }
public async Task <MinerData> GetMinerData(int executionID, SourceOption source) { MinerData minerData = null; using (var db = new BEMainDBContext()) { minerData = db.MinerData .Where(md => (md.TheExecutionID == executionID) && (md.TheSource == source)) .ToList() .FirstOrDefault(); } return(minerData); }
public async Task <int> GetBEMinedTextsCount(int executionID, SourceOption source, TextStatus status) { int textsCount = 0; using (var db = new BEMainDBContext()) { textsCount = db.BEMinedTexts .Where(mt => (mt.ExecutionID == executionID) && (mt.TheSource == source) && (mt.TheStatus == status)) .Count(); } return(textsCount); }
private void LoadSourceStruct(ISourceProvider provider) { var option = new SourceOption { View = Config.Instance.Source_View }; var tables = provider.Preview(option); if (tables == null) { return; } GetSchemaAsync(provider, tables); }
private IEnumerable <Table> OpenDb(SourceOption option) { try { var provider = ProviderHelper.GetDefinedProviderInstance(con.Type); using (var db = new Fireasy.Data.Database(con.ConnectionString, provider)) { var schema = db.Provider.GetService <Schema.ISchemaProvider>(); var tables = schema.GetSchemas <Schema.Table>(db).ToList(); var views = option.View ? schema.GetSchemas <Schema.View>(db).ToList() : new List <Schema.View>(); return(ConvertSchemaTables(tables, views)); } } catch (Exception exp) { ErrorMessageBox.Show("获取数据架构时出错。", exp); return(null); } }
public SourceOptionViewModel(SourceOption sourceOption, string sourcePath = null) { this.sourceOption = sourceOption; this.SourcePath = sourcePath; // Text this.WhenAnyValue(x => x.VolumeLabel) .Select(volumeLabel => { switch (this.sourceOption.Type) { case SourceType.File: if (this.SourcePath == null) { return(MainRes.SourceOption_VideoFile); } return(this.SourcePath); case SourceType.DiscVideoFolder: if (this.SourcePath == null) { return(MainRes.SourceOption_DiscFolder); } return(this.SourcePath); case SourceType.Disc: return(this.sourceOption.DriveInfo.RootDirectory + " - " + volumeLabel); default: break; } return(string.Empty); }).ToProperty(this, x => x.Text, out this.text); this.ChooseSource = ReactiveCommand.Create(); this.ChooseSource.Subscribe(_ => this.ChooseSourceImpl()); }
public MiningSource(SourceOption theSelection = 0) { TheSelection = theSelection; }
public MiningSource() { TheSelection = 0; }
public abstract FolderMetadata LoadFolderMetadata(string currId, SourceOption option);
/// <summary> /// Loads either the MetaData with specified id or with different id. /// </summary> /// <param name="currId">Id of MetaData.</param> /// <param name="loadOther">false to load metadata with currId. true to load other metadata with id different from currId.</param> /// <returns></returns> public abstract Metadata Load(string currId, SourceOption option);
public static PointArray <bool> ScanToArray(Point source, Func <Point, bool> condition, SourceOption sourceOption = SourceOption.AlwaysIncludeSource) { PointArray <bool> result = new PointArray <bool>(GameUniverse.MapWidth, GameUniverse.MapHeight); foreach (Point p in Scan(source, condition, sourceOption)) { result[p] = true; } return(result); }
/// <summary> /// /// </summary> /// <param name="currId"></param> /// <param name="option"></param> /// <returns></returns> public abstract FileMetaData LoadFileMetadata(string currId, SourceOption option);
public override IList<SyncAction> Load(string sourceID, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; IList<SyncAction> actions = new List<SyncAction>(); SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME),false); using (SqliteConnection con = db.NewSQLiteConnection ()) { if (con == null) throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); string cmdText = "SELECT * FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_CHANGE_IN + opt + " @sourceId"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@sourceId", System.Data.DbType.String) { Value = sourceID }); db.ExecuteReader(cmdText, paramList, reader => { ChangeType actionType = (ChangeType)reader[Configuration.COL_ACTION_TYPE]; if (actionType == ChangeType.DELETED) { DeleteAction delAction = new DeleteAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_OLD_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_HASH]); actions.Add(delAction); } else if (actionType == ChangeType.NEWLY_CREATED) { CreateAction createAction = new CreateAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_NEW_RELATIVE_PATH], (string)reader[Configuration.COL_NEW_HASH]); actions.Add(createAction); } else if (actionType == ChangeType.RENAMED) { RenameAction renameAction = new RenameAction( (int)reader[Configuration.COL_ACTION_ID], (string)reader[Configuration.COL_CHANGE_IN], (string)reader[Configuration.COL_NEW_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_RELATIVE_PATH], (string)reader[Configuration.COL_OLD_HASH]); actions.Add(renameAction); } } ); } return actions; }
public override bool Delete(string sourceID, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS ) ? " <> " : " = "; SQLiteAccess db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME),false); using (SqliteConnection con = db.NewSQLiteConnection ()) { if (con == null) throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); string cmdText = "DELETE FROM " + Configuration.TBL_ACTION + " WHERE " + Configuration.COL_CHANGE_IN + " " + opt + " @id"; SqliteParameterCollection paramList = new SqliteParameterCollection(); paramList.Add(new SqliteParameter("@id", System.Data.DbType.Int32) { Value = sourceID }); db.ExecuteNonQuery(cmdText, paramList); } return true; }
/// <summary> /// 为指定的主题添加下载地址 /// </summary> /// <param name="themeId"></param> /// <param name="url"></param> /// <param name="isDefault"></param> /// <param name="source"></param> /// <returns></returns> public bool AddThemeDownloadUrl(int themeId, string url, bool isDefault, SourceOption source) { string cmdText = @" insert into ThemeFiles (ThemeId,IsDefault,Url,Source,AddTime) values (@ThemeId,@IsDefault,@Url,@Source,@AddTime) "; SqlParameter[] parameters = new SqlParameter[] { SqlParameterHelper.BuildInputParameter("@ThemeId",SqlDbType.Int, 4, themeId), SqlParameterHelper.BuildInputParameter("@IsDefault",SqlDbType.SmallInt, 2, isDefault ? 1 : 0), SqlParameterHelper.BuildInputParameter("@Url",SqlDbType.NVarChar, 500, url), SqlParameterHelper.BuildInputParameter("@Source",SqlDbType.SmallInt, 2, source), SqlParameterHelper.BuildInputParameter("@AddTime",SqlDbType.DateTime, 8, DateTime.Now) }; return SqlHelper.ExecuteNonQuery(_connectionProvider.GetWriteConnectionString(), CommandType.Text, cmdText, parameters) > 0; }
public MiningSource(MiningSource miningSource) { TheSelection = miningSource.TheSelection; }
public void CopyFrom(MiningSource source) { TheSelection = source.TheSelection; }
public static Uri GetAnalyserUri(SourceOption analyserSourceID) { return(new Uri(ApplicationName + GetAnalyserName(analyserSourceID))); }
public void RemoveSource(SourceOption option) { TheSelection &= ~option; }
public static IEnumerable <Point> Scan(Point source, Func <Point, bool> condition, SourceOption sourceOption = SourceOption.AlwaysIncludeSource) { List <Point> frontier = new List <Point>(); HashSet <Point> visited = new HashSet <Point> { source }; switch (sourceOption) { case SourceOption.AlwaysIncludeSource: yield return(source); break; case SourceOption.ConditionallyIncludeSource: case SourceOption.StopScanOnSourceFailure: if (condition.Invoke(source)) { yield return(source); } else if (sourceOption == SourceOption.StopScanOnSourceFailure) { yield break; } break; } frontier.Add(source); while (frontier.Count > 0) { Point current = frontier[frontier.Count - 1]; frontier.RemoveAt(frontier.Count - 1); foreach (Dir8 dir in EightDirections.Enumerate(true, false, false)) { Point neighbor = current.PointInDir(dir); if (!neighbor.ExistsBetweenMapEdges()) { continue; } if (visited.Contains(neighbor)) { continue; } if (condition.Invoke(neighbor)) { yield return(neighbor); frontier.Add(neighbor); visited.Add(neighbor); } } } }
public override FileMetaData LoadFileMetadata(string currId, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; var mData = new FileMetaData(currId, RootPath); var db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME),false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); string cmdText = string.Format("SELECT * FROM {0} WHERE {1}{2} @sourceId", Configuration.TBL_METADATA, Configuration.COL_SOURCE_ID, opt); var paramList = new SqliteParameterCollection { new SqliteParameter("@sourceId", DbType.String) {Value = currId} }; db.ExecuteReader(cmdText, paramList, reader => mData.MetaDataItems.Add(new FileMetaDataItem( (string) reader[Configuration.COL_SOURCE_ID], (string) reader[Configuration.COL_RELATIVE_PATH], (string) reader[Configuration.COL_HASH_CODE], (DateTime) reader[Configuration.COL_LAST_MODIFIED_TIME], Convert.ToUInt32(reader[Configuration.COL_NTFS_ID1]), Convert.ToUInt32(reader[Configuration.COL_NTFS_ID2])))); } return mData; }
public static string GetAnalyserName(SourceOption analyserSourceID) { return(analyserNames[analyserSourceID]); }
public static Uri GetMinerUri(SourceOption minerSourceID) { return(new Uri(ApplicationName + GetMinerName(minerSourceID))); }
/// <summary> /// Deletes actions based on specified SourceID. /// </summary> /// <param name="srcID">SourceID to be based on.</param> /// <param name="deleteOther"> /// true to delete actions with different SourceID as argument. /// false to delete actions with srcActionID as argument. /// </param> /// <returns></returns> public abstract bool Delete(string sourceID, SourceOption option);
public override FolderMetadata LoadFolderMetadata(string currId, SourceOption option) { string opt = (option == SourceOption.SOURCE_ID_NOT_EQUALS) ? " <> " : " = "; var folderMetadata = new FolderMetadata(currId, this.RootPath); var db = new SQLiteAccess(Path.Combine(this.StoragePath, Configuration.DATABASE_NAME),false); using (SqliteConnection con = db.NewSQLiteConnection()) { if (con == null) throw new DatabaseException(String.Format(m_ResourceManager.GetString("err_somethingNotFound"), Path.Combine(this.StoragePath, Configuration.DATABASE_NAME))); string cmdText = "SELECT * FROM " + Configuration.TLB_FOLDERMETADATA + " WHERE " + Configuration.COL_SOURCE_ID + opt + " @sourceId"; var paramList = new SqliteParameterCollection {new SqliteParameter("@sourceId", DbType.String) {Value = currId}}; db.ExecuteReader(cmdText, paramList, reader => folderMetadata.FolderMetadataItems.Add( new FolderMetadataItem( (string)reader[Configuration.COL_SOURCE_ID], (string)reader[Configuration.COL_FOLDER_RELATIVE_PATH], (int)reader[Configuration.COL_IS_FOLDER_EMPTY] ))); } return folderMetadata; }
/// <summary> /// Load all actions based specified SourceID. /// </summary> /// <param name="srcActionID">SourceID to be based on.</param> /// <param name="loadOther"> /// true to load Actions with different SourceID as argument. /// false to load all Actions with same SourceID as argument.</param> /// <returns></returns> public abstract IList <SyncAction> Load(string sourceID, SourceOption option);
/// <summary> /// Load all actions based specified SourceID. /// </summary> /// <param name="srcActionID">SourceID to be based on.</param> /// <param name="loadOther"> /// true to load Actions with different SourceID as argument. /// false to load all Actions with same SourceID as argument.</param> /// <returns></returns> public abstract IList<SyncAction> Load(string sourceID, SourceOption option);
/// <summary> /// Load Metadata from database /// </summary> /// <param name="currId"></param> /// <param name="option"></param> /// <returns></returns> public override Metadata Load(string currId, SourceOption option) { return new Metadata(LoadFileMetadata(currId, option), LoadFolderMetadata(currId, option)); }