コード例 #1
0
ファイル: Migrate.cs プロジェクト: ifakFAST/Mediator.Net
        public static void CopyDatabase(TimeSeriesDB source, TimeSeriesDB dest)
        {
            ChannelInfo[] sourceChannels = source.GetAllChannels();

            Console.WriteLine($"CopyDatabase source db channel count: {sourceChannels.Length}.");

            double Total   = sourceChannels.Length;
            double counter = 0;

            foreach (ChannelInfo ch in sourceChannels)
            {
                counter += 1;

                if (dest.ExistsChannel(ch.Object, ch.Variable))
                {
                    Channel srcChannel = source.GetChannel(ch.Object, ch.Variable);
                    Channel dstChannel = dest.GetChannel(ch.Object, ch.Variable);

                    var  sw    = Stopwatch.StartNew();
                    long count = CopyChannel(srcChannel, dstChannel);
                    sw.Stop();
                    string progress = string.Format("{0:0.0}%", 100.0 * counter / Total);
                    Console.WriteLine($"Copied {count} entries of channel {ch.Object} in {sw.ElapsedMilliseconds} ms ({progress})");
                }
            }
        }
コード例 #2
0
ファイル: Migrate.cs プロジェクト: ifakFAST/Mediator.Net
 public static void CopyData(string srcType, string srcConnectionString, string dstType, string dstConnectionString)
 {
     try {
         TimeSeriesDB src = OpenDatabase(srcType, srcConnectionString);
         TimeSeriesDB dst = OpenDatabase(dstType, dstConnectionString);
         CopyDatabase(source: src, dest: dst);
     }
     catch (Exception exp) {
         Console.Error.WriteLine(exp.Message);
         Console.Error.WriteLine(exp.StackTrace);
     }
 }
コード例 #3
0
        private async Task Runner()
        {
            while (true)
            {
                WorkItem it = await ReceiveNext();

                if (it is WI_BatchAppend)
                {
                    try {
                        Append(it as WI_BatchAppend);
                    }
                    catch (Exception exp) {
                        logger.Error(exp, "Batch Append failed");
                    }
                }
                else if (it is WI_ReadRaw)
                {
                    ReadRaw(it as WI_ReadRaw);
                }
                else if (it is WI_Count)
                {
                    DoCount(it as WI_Count);
                }
                else if (it is WI_DeleteInterval)
                {
                    DoDeleteInterval(it as WI_DeleteInterval);
                }
                else if (it is WI_Modify)
                {
                    DoModify(it as WI_Modify);
                }
                else if (it is WI_Delete)
                {
                    DoDelete(it as WI_Delete);
                }
                else if (it is WI_GetLatestTimestampDb)
                {
                    DoGetLatestTimestampDb(it as WI_GetLatestTimestampDb);
                }
                else if (it is WI_Start)
                {
                    WI_Start start = it as WI_Start;
                    try {
                        db = dbCreator();
                        db.Open(dbName, dbConnectionString, dbSettings);
                        start.Promise.SetResult(true);
                        started = true;
                    }
                    catch (Exception e) {
                        start.Promise.SetException(e);
                        return;
                    }
                }
                else if (it is WI_Terminate)
                {
                    WI_Terminate terminate = it as WI_Terminate;
                    db.Close();
                    terminate.Promise.SetResult(true);
                    return;
                }
            }
        }