/// <summary>
        ///     Initializes a new instance of the <see cref="TaosConnection" /> class.
        /// </summary>
        public TaosConnection()
        {
            if (_dll_isloaded == false)
            {
#if NET45
                configDir = "C:/TDengine/cfg";
#else
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    configDir = "/etc/taos";
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    configDir = "C:/TDengine/cfg";
                }
#endif
                TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir);
                TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
                TDengine.Init();
                Process.GetCurrentProcess().Disposed += (object sender, EventArgs e) =>
                {
                    TDengine.Cleanup();
                };
                _dll_isloaded = true;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TaosConnection" /> class.
 /// </summary>
 public TaosConnection()
 {
     if (_dll_isloaded == false)
     {
         var libManager = new LibraryManager(
             new LibraryItem(Platform.Windows, Bitness.x64,
                             new LibraryFile("taos.dll", Binary(typeof(TaosConnection).Assembly, $"{typeof(TaosConnection).Namespace}.libs.taos_x64.dll"))),
             new LibraryItem(Platform.Windows, Bitness.x32,
                             new LibraryFile("taos.dll", Binary(typeof(TaosConnection).Assembly, $"{typeof(TaosConnection).Namespace}.libs.taos_x32.dll"))),
             new LibraryItem(Platform.Linux, Bitness.x64,
                             new LibraryFile("libtaos.so", Binary(typeof(TaosConnection).Assembly, $"{typeof(TaosConnection).Namespace}.libs.libtaos_x64.so"))));
         libManager.LoadLibraryExplicit = true;
         if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
         {
             configDir = "/etc/taos";
         }
         else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
         {
             configDir = "C:/TDengine/cfg";
         }
         if (!System.IO.Directory.Exists(configDir))
         {
             configDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "taos.studio");
         }
         var cfg = new System.IO.FileInfo(System.IO.Path.Combine(configDir, "taos.cfg"));
         if (!cfg.Directory.Exists)
         {
             cfg.Directory.Create();
         }
         if (!cfg.Exists)
         {
             System.IO.File.WriteAllBytes(cfg.FullName, Binary(typeof(TaosConnection).Assembly, $"{typeof(TaosConnection).Namespace}.cfg.taos.cfg"));
         }
         if ((RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && RuntimeInformation.OSArchitecture == Architecture.X64) ||
             (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X64) ||
             (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X86))
         {
             TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir);
             TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
             TDengine.Init();
             Process.GetCurrentProcess().Disposed += (object sender, EventArgs e) =>
             {
                 TDengine.Cleanup();
             };
             _dll_isloaded = true;
         }
         else
         {
             throw new PlatformNotSupportedException("Only Support Linux X64 And Windows X64/X86");
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TaosConnection" /> class.
 /// </summary>
 public TaosConnection()
 {
     if (_dll_isloaded == false)
     {
         var accessor   = new ResourceAccessor(Assembly.GetExecutingAssembly());
         var libManager = new LibraryManager(
             Assembly.GetExecutingAssembly(),
             new LibraryItem(Platform.Windows, Bitness.x64,
                             new LibraryFile("taos.dll", accessor.Binary("libs.taos_x64.dll"))),
             new LibraryItem(Platform.Windows, Bitness.x32,
                             new LibraryFile("taos.dll", accessor.Binary("libs.taos_x32.dll"))),
             new LibraryItem(Platform.Linux, Bitness.x64,
                             new LibraryFile("libtaos.so", accessor.Binary("libs.libtaos_x64.so"))));
         libManager.LoadNativeLibrary(false);
         if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
         {
             configDir = "/etc/taos";
         }
         else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
         {
             configDir = "C:/TDengine/cfg";
         }
         var cfg = new System.IO.FileInfo(System.IO.Path.Combine(configDir, "taos.cfg"));
         if (!cfg.Directory.Exists)
         {
             cfg.Directory.Create();
         }
         if (!cfg.Exists)
         {
             System.IO.File.WriteAllBytes(cfg.FullName, accessor.Binary("cfg.taos.cfg"));
         }
         if ((RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && RuntimeInformation.OSArchitecture == Architecture.X64) ||
             (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X64) ||
             (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.OSArchitecture == Architecture.X86))
         {
             TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir);
             TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
             TDengine.Init();
             _dll_isloaded = true;
         }
         else
         {
             throw new PlatformNotSupportedException("Only Support Linux X64 And Windows X64/X86");
         }
     }
 }