Esempio n. 1
0
        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})");
                }
            }
        }
Esempio n. 2
0
 private Channel GetChannelOrThrow(VariableRef v)
 {
     if (mapChannels.ContainsKey(v))
     {
         return(mapChannels[v]);
     }
     else
     {
         Channel res = db.GetChannel(v.Object.LocalObjectID, v.Name);
         mapChannels[v] = res;
         return(res);
     }
 }