public override void Init()
        {
            LITETask.Register($"{Connection.name}.DownloadViaHttp", Connection.maxDownloadViaHttpTasks);
            LITETask.Register($"{Connection.name}.Store", Connection.maxStoreTasks);
            List <string> fileEntries;

            var profile = _profileStorage.Current;

            lock (InitLock)
            {
                base.Init();

                //read the persisted RoutedItems bound for EGS

                string dir = profile.tempPath + Path.DirectorySeparatorChar + Connection.name + Path.DirectorySeparatorChar + "toEGS" + Path.DirectorySeparatorChar + Constants.Dirs.Meta;
                Directory.CreateDirectory(dir);
                fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

                foreach (string file in fileEntries)
                {
                    RoutedItem st = _routedItemLoader.LoadFromFile(file);
                    if (st == null)
                    {
                        continue;
                    }

                    st.fromConnection = Connection.name;

                    if (!Connection.toEGS.Contains(st))
                    {
                        Connection.toEGS.Add(st);
                    }
                }

                //read the persisted RoutedItems bound for Rules

                dir = profile.tempPath + Path.DirectorySeparatorChar + Connection.name + Path.DirectorySeparatorChar + Constants.Dirs.ToRules + Path.DirectorySeparatorChar + Constants.Dirs.Meta;
                Directory.CreateDirectory(dir);
                fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

                foreach (string file in fileEntries)
                {
                    RoutedItem ri = _routedItemLoader.LoadFromFile(file);
                    if (ri == null)
                    {
                        continue;
                    }
                    ri.fromConnection = Connection.name;

                    if (!toRules.Contains(ri))
                    {
                        toRules.Add(ri);
                    }
                }

                //read the persisted RoutedItems inbound from EGS
                dir = profile.tempPath + Path.DirectorySeparatorChar + Connection.name + Path.DirectorySeparatorChar + "fromEGS" + Path.DirectorySeparatorChar + Constants.Dirs.Meta;
                Directory.CreateDirectory(dir);
                fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

                foreach (string file in fileEntries)
                {
                    RoutedItem ri = _routedItemLoader.LoadFromFile(file);
                    if (ri == null)
                    {
                        continue;
                    }

                    ri.fromConnection = Connection.name;

                    if (!Connection.fromEGS.Contains(ri))
                    {
                        Connection.fromEGS.Add(ri);
                    }
                }
            }

            Connection.started = true;
        }
Пример #2
0
        public override void Init()
        {
            if (Connection.Boxes.Count == 0)
            {
                //add sample box
                ShareDestinations shareDestinations = new ShareDestinations
                {
                    boxUuid = "19db62ba-128d-412c-8c4f-df28351e8ae0",
                    boxName = "LITESample"
                };
                Connection.Boxes.Add(shareDestinations);
            }

            List <string> fileEntries;

            string dir;

            lock (InitLock)
            {
                LITETask.Register($"{Connection.name}.Wado", Connection.maxWadoTasks);
                LITETask.Register($"{Connection.name}.Stow", Connection.maxStowTasks);
                LITETask.Register($"{Connection.name}.downloadStudy", Connection.maxStudyDownloadTasks);
                LITETask.Register($"{Connection.name}.putHL7", Connection.maxHL7UploadTasks);
                LITETask.Register($"{Connection.name}.PostResponse", Connection.maxPostResponseTasks);

                if (loginNeeded)
                {
                    base.Init();
                    int newTaskID = LITETask.NewTaskID();


                    // Register is a one-time operation.  Once you have your tenantID, don't call this again, but populate the tenantID upon class instantiation.
                    if (Connection.tenantID == null)
                    {
                        register(newTaskID).Wait();
                    }

                    // if you tried to register and you still don't have a tenantID, we're done.
                    if (Connection.tenantID == null)
                    {
                        _logger.Log(LogLevel.Warning, $"Account is not registered.");
                        return;
                    }

                    // //login
                    // newTaskID = LITETask.newTaskID();
                    // var result = login(newTaskID).Result;
                    // if (result != "OK")
                    // {
                    //     return;  //this is to prevent reading in work below if we don't login.
                    // }
                }

                //read the persisted RoutedItems bound for Cloud

                dir = _profileStorage.Current.tempPath +
                      Path.DirectorySeparatorChar +
                      Connection.name +
                      Path.DirectorySeparatorChar +
                      Constants.Dirs.ToCloud +
                      Path.DirectorySeparatorChar +
                      Constants.Dirs.Meta;

                Directory.CreateDirectory(dir);
                fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

                foreach (string file in fileEntries)
                {
                    var st = _routedItemLoader.LoadFromFile(file);
                    if (st == null)
                    {
                        continue;
                    }

                    st.fromConnection = Connection.name;

                    if (!Connection.toCloud.Contains(st))
                    {
                        Connection.toCloud.Add(st);
                    }
                }
            }

            //read the persisted RoutedItems bound for Rules

            dir = _profileStorage.Current.tempPath +
                  Path.DirectorySeparatorChar +
                  Connection.name +
                  Path.DirectorySeparatorChar +
                  Constants.Dirs.ToRules +
                  Path.DirectorySeparatorChar +
                  Constants.Dirs.Meta;

            Directory.CreateDirectory(dir);
            fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

            foreach (string file in fileEntries)
            {
                RoutedItem ri = _routedItemLoader.LoadFromFile(file);
                if (ri == null)
                {
                    continue;
                }

                ri.fromConnection = Connection.name;

                if (!toRules.Contains(ri))
                {
                    toRules.Add(ri);
                }
            }

            Connection.started = true;
        }
        public override void Init()
        {
            _logger.Log(LogLevel.Debug, $"{Connection.name} entering init.");

            base.Init();

            //register semaphore limits
            LITETask.Register($"{Connection.name}.read", Connection.maxInboundConnections);

            //2019-04-05 shb BOUR-934 old code was for conn.accept semaphore (without ip:port) which caused more than one accept per ip:port
            //in situations where multiple addresses were returned but say ipv6 was disabled.  Now we don't need to specify
            //so that when we create the task the type is specific to the ip and port which will register a semaphore of 1

            // var addressList = Dns.GetHostEntry(localHostname).AddressList;
            // foreach( var address in addressList){
            //     LITETask.Register($"{name}.accept: {address}:{localPort}", 1);
            // }

            //read the persisted RoutedItems bound for Rules

            string dir = _profileStorage.Current.tempPath + Path.DirectorySeparatorChar + Connection.name + Path.DirectorySeparatorChar + Constants.Dirs.ToRules + Path.DirectorySeparatorChar + Constants.Dirs.Meta;

            Directory.CreateDirectory(dir);
            var fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

            foreach (string file in fileEntries)
            {
                RoutedItem ri = _routedItemLoader.LoadFromFile(file);
                if (ri == null)
                {
                    continue;
                }

                ri.fromConnection = Connection.name;

                if (!toRules.Contains(ri))
                {
                    toRules.Add(ri);
                }
            }

            //read the persisted RoutedItems bound for HL7

            dir = _profileStorage.Current.tempPath + Path.DirectorySeparatorChar + Connection.name + Path.DirectorySeparatorChar + "toHL7" + Path.DirectorySeparatorChar + Constants.Dirs.Meta;
            Directory.CreateDirectory(dir);
            fileEntries = _util.DirSearch(dir, Constants.Extensions.MetaExt.ToSearchPattern());

            foreach (string file in fileEntries)
            {
                RoutedItem ri = _routedItemLoader.LoadFromFile(file);
                if (ri == null)
                {
                    continue;
                }

                ri.fromConnection = Connection.name;

                if (!Connection.ToHL7.Contains(ri))
                {
                    Connection.ToHL7.Add(ri);
                }
            }

            Connection.started = true;
        }