public static void Synchronize(IDatabaseSource src, IDatabaseSource dst, IProgressInfo progress, DataSynDef datasyn, DataSynReportEnv repenv, string outFile, DataSynGuiEnv guienv) { Synchronizer syn = new Synchronizer(src, dst, progress, datasyn, repenv, outFile, guienv); syn.Progress = progress; syn.Run(); }
public OutputProgressWindow( string baseName, bool showClipping, IProgressInfo progressInfo, IBufferLoading bufferLoading, Synthesizer.IStopTask stopCallback, IFinished finished, IWaitFinished waitFinished, ShowCompletionMethod showError) { this.stopCallback = stopCallback; this.bufferLoading = bufferLoading; this.progressInfo = progressInfo; this.finished = finished; this.waitFinished = waitFinished; this.showCompletion = showError; InitializeComponent(); this.Icon = OutOfPhase.Properties.Resources.Icon2; DpiChangeHelper.ScaleFont(this, Program.Config.AdditionalUIZoom); if (!showClipping) { labelTotalClippedPoints.Visible = false; textTotalClippedPoints.Visible = false; } UpdateValues(); this.Text = String.Format("{0} - {1}", baseName, "Synthesis"); }
// GenerateSql can return NULL, if SQL cannot be generated for given dialect public string GenerateSql(ISqlDialect dialect, DbTypeBase targetType, IProgressInfo progress) { try { return(dialect.GenerateScript(dmp => { dmp.ProgressInfo = progress; GenerateSql(dmp, targetType); })); } catch (SyntaxNotSupportedError) { return(null); } }
public override void DoLoad(IProgressInfo progressInfo) { if (m_parent != null) { if (m_parent.CurrentState != null) { m_project = m_parent.CurrentState.Project; m_verseRef = m_parent.CurrentState.VerseRef; Invoke((Action)(() => ShowProjectInfo())); } } }
public override string ToString() { IProgressInfo me = (IProgressInfo)this; TimeSpan rem = me.Remaining; TimeSpan ela = me.Elapsed; return("{0:0.00}% | {1}/{2} | Elap: {3} + Rem: {4} = Total: {5} -> Finish: {6:u}".FormatWith( me.Percentage, current, count, ela.NiceToString(DateTimePrecision.Seconds), rem.NiceToString(DateTimePrecision.Seconds), (ela + rem).NiceToString(DateTimePrecision.Seconds), (DateTime.UtcNow + rem).ToLocalTime())); }
public void Rerun(IProgressInfo progressInfo) { progressInfo.Initialize("Building list", 100, 0); for (int i = 0; i < 100; i++) { progressInfo.Value = i; Thread.Sleep(5 * 1000 / 100); if (progressInfo.CancelRequested) { MessageBox.Show("List generation canceled"); return; } } IReferenceListWindow refList = m_Host.ReferenceList; IReadOnlyList <IReferenceListItem> mylist = refList.AllListItems; }
public static void RemoveNonPk1AutoIncrements(TableStructure table, IProgressInfo progress) { IPrimaryKey pk = table.FindConstraint <IPrimaryKey>(); foreach (ColumnStructure col in table.Columns) { var type = col.DataType; if (type is DbTypeInt && ((DbTypeInt)type).Autoincrement) { if (pk == null || pk.Columns.Count != 1 || pk.Columns[0].ColumnName != col.ColumnName) { type.SetAutoincrement(false); progress.LogMessage("migrate", LogLevel.Warning, "Removed autoincrement flag, column {0}.{1} is not primary key", table.FullName, col.ColumnName); } } } }
public static void RaiseErrorEx(this IProgressInfo progress, Exception err, string message, string category) { string longmsg = String.Format("{0} ({1})", message, err.Message); if (category != null) { progress.LogMessage(category, LogLevel.Error, longmsg); } Logging.Error("Error: {0}; {1}", message, err); if (progress != null) { progress.RaiseError(longmsg); } else { throw new Exception(message, err); } }
public Synchronizer(IDatabaseSource src, IDatabaseSource dst, IProgressInfo progress, DataSynDef datasyn, DataSynReportEnv repenv, string outFile, DataSynGuiEnv guienv) { m_source = src; m_target = dst; m_progress = progress; m_datasyn = datasyn; m_outFile = outFile; m_srcSada = m_source.Dialect.CreateDataSynAdapter(); m_dstSada = m_target.Dialect.CreateDataSynAdapter(); m_dstDDA = m_target.GetAnyDDA(); m_reportEnvObj = repenv; m_reportEnv = repenv; m_guienv = guienv; if (m_reportEnv == null) { m_reportEnv = new DummyDataSynReportEnv(); } }
/// <summary> /// ライブラリを更新します。 /// </summary> /// <param name="progressInfo"></param> public void Update(IProgressInfo progressInfo) { if (SearchDirectoryPaths.Count == 0) { // 一番使用されているパスを検索対象とする。 var mostUseDirectoryPath = _movselexLibrary.SelectMostUseDirectoryPath(); if (!string.IsNullOrEmpty(mostUseDirectoryPath)) _searchDirectoryPaths.Add(mostUseDirectoryPath); } _searchDirectoryPaths.DebugWriteJson("SearchDirectoryPaths"); foreach (var searchDirectoryPath in SearchDirectoryPaths) { // 検索対象ディレクトリからサポートしている拡張子のファイルだけ抜く。 var registFiles = GetSupportFiles(searchDirectoryPath); _movselexLibrary.Regist(registFiles, progressInfo); } _movselexLibrary.ReScan(_movselexLibrary.GetInCompleteIds()); }
public DatabaseStructure Run(ISqlDialect dialect, IPhysicalConnection conn, string dbname, DatabaseStructureMembers members, IProgressInfo progress) { AnalyserCache = conn.Cache.GetAnalyserCache(dbname); m_conn = conn; //m_serverVersion = m_dbConn.ServerVersion; //ParseVersion(); m_dialect = dialect; m_members = members; m_dbname = dbname; m_progress = progress; m_db.Dialect = m_dialect; m_definedSpecs = m_dialect.GetSpecificTypes(); PrepareMembers(); SetCurWork(Texts.Get("s_loading_tables")); LoadDomains(); LoadTableList(); LoadTableColumns(); LoadConstraints(); LoadIndexes(); AfterLoadIndexesOrConstraints(); InternalAfterLoadConstraints(); MarkFilledTableMembers(); LoadSchemata(); LoadCharacterSets(); LoadCollations(); SetCurWork(Texts.Get("s_loading_objects")); LoadSpecificObjects(); LoadDatabaseOptions(); LoadViewsAsTables(); LoadDependencies(); return(m_db); }
public override void DoLoad(IProgressInfo progressInfo) { // Actually do the load: // Since DoLoad is done on a different thread than what was used // to create the control, we need to use the Invoke method. Invoke((Action)(() => LoadSavedText())); // Illustrate use of progressInfo const int MAX_TIME = 100; progressInfo.Initialize("Loading Reference F", MAX_TIME); for (int i = 0; i < MAX_TIME; i++) { if (progressInfo.CancelRequested) { m_writeLock.Dispose(); m_writeLock = null; textBox.Text = ""; textBox.ReadOnly = true; } Thread.Sleep(20); progressInfo.Value = i; } }
public virtual DbTypeBase MigrateDataType(IColumnStructure owningColumn, DbTypeBase type, IMigrationProfile profile, IProgressInfo progress) { ISpecificType spectype = GenericTypeToSpecific(type, profile, progress); //if (!DialectCaps.Arrays && type.ArraySpec.IsArray) //{ // return new DbTypeText(); // migrate arrays as text blob //} return(spectype.ToGenericType()); }
protected virtual Constraint MigrateConstraintOrIndex(Constraint cnt, IMigrationProfile profile, IProgressInfo progress) { if (cnt is IPrimaryKey) { if (DialectCaps.AnonymousPrimaryKey) { PrimaryKey pk = (PrimaryKey)cnt; pk.Name = DbObjectNameTool.PkName(pk.Table.FullName); } } return(cnt); }
public virtual void MigrateDatabase(DatabaseStructure db, IMigrationProfile profile, IProgressInfo progress) { if (db.Dialect.SameDialect(this)) { return; } foreach (TableStructure table in db.Tables) { MigrateTable(table, profile, progress); } db.Dialect = this; }
public static IEnumerable <T> ToProgressEnumerator <T>(this IEnumerable <T> source, out IProgressInfo pi) { pi = new ProgressEnumerator <T>(source, source.Count()); return((IEnumerable <T>)pi); }
public override ISpecificType GenericTypeToSpecific(DbTypeBase type, IMigrationProfile profile, IProgressInfo progress) { switch (type.Code) { case DbTypeCode.Int: return(GetEfzTypeInt((DbTypeInt)type)); case DbTypeCode.String: return(GetEfzTypeString((DbTypeString)type)); case DbTypeCode.Logical: return(new EfzTypeBoolean()); case DbTypeCode.Datetime: { string attr = type.GetSpecificAttribute("effiproz", "subtype"); var dtype = type as DbTypeDatetime; if (attr == "timestamp") { var res = new EfzTypeTimestamp(); res.Precision = Int32.Parse(type.GetSpecificAttribute("effiproz", "precision")); return(res); } if (attr == "yeartomonth") { var res = new EfzTypeIntervalYearToMonth(); //res.Precision = Int32.Parse(type.GetSpecificAttribute("effiproz", "precision")); return(res); } if (attr == "daytosecond") { var res = new EfzTypeIntervalDayToSecond(); //res.Precision = Int32.Parse(type.GetSpecificAttribute("effiproz", "precision")); return(res); } if (attr == "date") { var res = new EfzTypeDate(); return(res); } switch (dtype.SubType) { case DbDatetimeSubType.Date: return(new EfzTypeDate()); case DbDatetimeSubType.Datetime: if (dtype.HasTimeZone) { return(new EfzTypeTimestampTz()); } else { return(new EfzTypeTimestamp()); } case DbDatetimeSubType.Interval: return(new EfzTypeIntervalDayToSecond()); case DbDatetimeSubType.Time: return(new EfzTypeTimestamp()); case DbDatetimeSubType.Year: return(new EfzTypeDate()); } return(new EfzTypeTimestamp()); } case DbTypeCode.Numeric: { var res = new EfzTypeNumber(); res.Precision = ((DbTypeNumeric)type).Precision; res.Scale = ((DbTypeNumeric)type).Scale; res.IsIdentity = ((DbTypeNumeric)type).Autoincrement; int increment; if (Int32.TryParse(type.GetSpecificAttribute("effiproz", "identity_increment"), out increment)) { res.IdentityIncrement = increment; res.IdentitySeed = Int32.Parse(type.GetSpecificAttribute("effiproz", "identity_seed")); } return(res); } case DbTypeCode.Blob: { var res = new EfzTypeBlob(); string size = type.GetSpecificAttribute("effiproz", "maxbytes"); if (size != null) { res.MaxBytes = Int32.Parse(size); } return(res); } case DbTypeCode.Text: { var res = new EfzTypeClob(); string size = type.GetSpecificAttribute("effiproz", "maxbytes"); if (size != null) { res.MaxBytes = Int32.Parse(size); } return(res); } case DbTypeCode.Array: return(new EfzTypeClob()); case DbTypeCode.Float: return(new EfzTypeDouble()); case DbTypeCode.Xml: return(new EfzTypeClob()); case DbTypeCode.Generic: return(new EfzTypeGeneric { Sql = ((DbTypeGeneric)type).Sql }); } throw new Exception("DAE-00323 unknown type"); }
public static void InvokeScript(this IDatabaseSource db, Action <ISqlDumper> script, IProgressInfo progress) { db.InvokeScript(script, progress, false); }
public static IDatabaseStructure InvokeLoadStructure(this IDatabaseSource db, DatabaseStructureMembers members, IProgressInfo progress) { if (db.Connection == null) { return(db.LoadDatabaseStructure(members, progress)); } IAsyncResult async = db.Connection.BeginInvoke( (Func <IDatabaseStructure>) delegate() { return(db.LoadDatabaseStructure(members, progress)); }, null); Async.WaitFor(async); return((IDatabaseStructure)db.Connection.EndInvoke(async)); }
public void RegistFiles(string[] files, IProgressInfo progressInfo) { var registFiles = files.SelectMany(x => Directory.Exists(x) ? GetSupportFiles(x) : new[] {x}); _movselexLibrary.Regist(registFiles, progressInfo); }
void OnUpdatedOperationProgress(IProgressInfo progressInfo) { OperationProgressChange?.Invoke(progressInfo); }
//public static List<NameWithSchema> InvokeLoadFullTableNames(this IPhysicalConnection conn, string dbname) //{ // DatabaseStructureMembers dbmem = new DatabaseStructureMembers { TableList = true }; // IDatabaseStructure dbs = conn.InvokeLoadStructure(dbname, dbmem); // return dbs.GetTableNames(); //} public static IDatabaseStructure InvokeLoadStructure(this IPhysicalConnection conn, string dbname, DatabaseStructureMembers members, IProgressInfo progress) { IAsyncResult async = conn.BeginInvoke( (Func <IDatabaseStructure>) delegate() { return(conn.Dialect.AnalyseDatabase(conn, dbname, members, progress)); }, null); Async.WaitFor(async); return((IDatabaseStructure)conn.EndInvoke(async)); }
public static void RunScript(this IPhysicalConnection conn, Action <ISqlDumper> script, DbTransaction trans, IProgressInfo progress) { ConnectionSqlOutputStream sqlo = new ConnectionSqlOutputStream(conn.SystemConnection, trans, conn.Dialect); ISqlDumper fmt = conn.Dialect.CreateDumper(sqlo, SqlFormatProperties.Default); fmt.ProgressInfo = progress; script(fmt); }
//public override bool IsSystemTable(string schema, string table) //{ // return table.Contains("$") || table == "HELP"; //} public override ISpecificType GenericTypeToSpecific(DbTypeBase type, IMigrationProfile profile, IProgressInfo progress) { switch (type.Code) { case DbTypeCode.Array: return(new OracleTypeClob()); case DbTypeCode.Blob: if (type.GetSpecificAttribute("oracle", "subtype") == "longraw") { return(new OracleTypeLongRaw()); } return(new OracleTypeBlob()); case DbTypeCode.Datetime: { var dtype = (DbTypeDatetime)type; string subtype = type.GetSpecificAttribute("oracle", "subtype"); if (subtype == "timestamp") { var res = new OracleTypeTimestamp(); try { res.TimeZone = (TimeZoneType)Enum.Parse(typeof(TimeZoneType), type.GetSpecificAttribute("oracle", "timezone"), true); } catch { res.TimeZone = TimeZoneType.None; } string fprec = type.GetSpecificAttribute("oracle", "fractionalprecision"); if (fprec != null) { res.FractionalPrecision = Int32.Parse(fprec); } return(res); } if (subtype == "yeartomonth") { var res = new OracleTypeIntervalYearToMonth(); string yprec = type.GetSpecificAttribute("oracle", "yearprecision"); if (yprec != null) { res.YearPrecision = Int32.Parse(yprec); } return(res); } if (subtype == "daytosecond") { var res = new OracleTypeIntervalDayToSecond(); string dprec = type.GetSpecificAttribute("oracle", "dayprecision"); string fprec = type.GetSpecificAttribute("oracle", "fractionalprecision"); if (dprec != null) { res.DayPrecision = Int32.Parse(dprec); } if (fprec != null) { res.FractionalPrecision = Int32.Parse(fprec); } return(res); } if (dtype.SubType == DbDatetimeSubType.Interval) { return(new OracleTypeIntervalDayToSecond()); } return(new OracleTypeDate()); } case DbTypeCode.Float: if (type.GetSpecificAttribute("oracle", "subtype") == "number") { return(new OracleTypeNumber()); } if (((DbTypeFloat)type).Bytes == 4) { return(new OracleTypeBinaryFloat()); } return(new OracleTypeBinaryDouble()); case DbTypeCode.Generic: return(new OracleTypeGeneric { Sql = ((DbTypeGeneric)type).Sql }); case DbTypeCode.Int: { string ilen = type.GetSpecificAttribute("oracle", "length"); if (ilen != null) { return new OracleTypeNumber { Precision = Int32.Parse(ilen) } } ; } return(new OracleTypeInteger()); case DbTypeCode.Logical: return(new OracleTypeInteger()); case DbTypeCode.Numeric: { var ntype = (DbTypeNumeric)type; if (type.GetSpecificAttribute("oracle", "noprec") == "1") { return new OracleTypeNumber { Scale = ntype.Scale } } ; return(new OracleTypeNumber { Precision = ntype.Precision, Scale = ntype.Scale }); } case DbTypeCode.String: { string subtype = type.GetSpecificAttribute("oracle", "subtype"); if (subtype != null) { switch (subtype) { case "rowid": return(new OracleTypeRowId()); case "urowid": return(new OracleTypeURowId()); case "mlslabel": return(new OracleTypeMlsLabel()); case "bfile": return(new OracleTypeBFile()); } } var stype = (DbTypeString)type; if (stype.IsBinary) { return new OracleTypeRaw { Length = stype.Length } } ; if (stype.IsVarLength) { if (stype.IsUnicode) { return new OracleTypeNVarChar2 { Length = stype.Length } } ; else { return new OracleTypeVarChar2 { Length = stype.Length } }; } else { if (stype.IsUnicode) { return new OracleTypeNChar { Length = stype.Length } } ; else { return new OracleTypeChar { Length = stype.Length } }; } } case DbTypeCode.Text: if (type.GetSpecificAttribute("oracle", "subtype") == "long") { return(new OracleTypeLong()); } if (((DbTypeText)type).IsUnicode) { return(new OracleTypeNClob()); } else { return(new OracleTypeClob()); } case DbTypeCode.Xml: return(new OracleTypeXml()); } throw new Exception("DAE-00342 unknown type"); }
public IDatabaseStructure AnalyseDatabase(IPhysicalConnection conn, string dbname, DatabaseStructureMembers members, IProgressInfo progress) { DatabaseAnalyser analyser = CreateAnalyser(); try { return(analyser.Run(this, conn, dbname, members, progress)); } catch (Exception err) { conn.FillInfo(err.Data); err.Data["analyse_dbname"] = dbname; throw; } }
public static void InvokeScript(this IDatabaseSource db, Action <ISqlDumper> script, IProgressInfo progress, bool denyTransaction) { db.Connection.Invoke( (Action) delegate() { db.Connection.SystemConnection.SafeChangeDatabase(db.DatabaseName); DbTransaction tran = null; if (db.Dialect.DialectCaps.NestedTransactions && !denyTransaction) { tran = db.Connection.SystemConnection.BeginTransaction(); } try { db.Connection.RunScript(script, tran, progress); } catch { if (tran != null) { tran.Rollback(); } throw; } if (tran != null) { tran.Commit(); } }); }
public virtual ISpecificType GenericTypeToSpecific(DbTypeBase generic, IMigrationProfile profile, IProgressInfo progress) { return(generic); }
public override void DoLoad(IProgressInfo progressInfo) { // Since DoLoad is done on a different thread than what was used // to create the control, we need to use the Invoke method. Invoke((Action)(() => ShowScripture())); }
//public virtual string Symbols { get { return "()=+-<>*/"; } } public virtual string GetSpecificExpression(SqlSpecialConstant specConst, DbTypeBase type, IProgressInfo progress) { return(null); }
public IDatabaseStructure LoadDatabaseStructure(DatabaseStructureMembers members, IProgressInfo progress) { return(Conn.GetStructure()); }
public virtual void MigrateTable(TableStructure table, IMigrationProfile profile, IProgressInfo progress) { foreach (ColumnStructure col in table.Columns) { // character and collation is not portable col.Collation = ""; col.CharacterSet = ""; col.DataType = MigrateDataType(col, col.DataType, profile, progress); List <string> todel = new List <string>(); foreach (string attr in col.SpecificData.Keys) { if (!attr.StartsWith(DialectName + ".")) { todel.Add(attr); } } foreach (string d in todel) { col.SpecificData.Remove(d); } } var newConstraints = new List <Constraint>(); foreach (Constraint cnt in table.Constraints) { var newcnt = MigrateConstraintOrIndex(cnt, profile, progress); if (newcnt != null) { newConstraints.Add(newcnt); } } table._Constraints.Clear(); foreach (var cnt in newConstraints) { table._Constraints.Add(cnt); } }
public override void DoLoad(IProgressInfo progressInfo) { }
/// <summary> /// ライブラリにファイルを登録します。 /// </summary> /// <param name="registFiles"></param> /// <param name="progressInfo"></param> public void Regist(IEnumerable<string> registFiles, IProgressInfo progressInfo) { using (var tran = _databaseAccessor.BeginTransaction()) { var existsFiles = _databaseAccessor.SelectAllLibraryFilePaths().ToList(); var i = 1; var regfiles = registFiles.ToArray(); foreach (var registFile in regfiles) { progressInfo.UpdateProgressMessage("Regist Files", Path.GetFileName(registFile), i++, regfiles.Length); if (!existsFiles.Contains(registFile)) { // 未登録の場合のみ登録する var mediaFile = new MediaFile(registFile); if (mediaFile.Duration == TimeSpan.Zero) continue; // 不完全ファイルは追加しない。 _movselexGroup.SetMovGroup(mediaFile); var isSuccess = _databaseAccessor.InsertMediaFile(mediaFile); if (isSuccess) { _log.Info("Registed Media File. Id:{0} Title:{1} Group:{2}", mediaFile.Id, mediaFile.MovieTitle, mediaFile.GroupName); mediaFile.DebugWriteJson("RegistMedia"); existsFiles.Add(registFile); } else { _log.Error("Fail Regist Media File. Id:{0} Title:{1} Group:{2} Detail:{3}", mediaFile.Id, mediaFile.MovieTitle, mediaFile.GroupName, mediaFile.ToJson()); } } else { // TODO: 同じものがあればファイルパス更新 } } tran.Commit(); } }