示例#1
0
        public WorkPackage Start(OSEnum pOS, String pAssignedClient)
        {
            StartDate = DateTime.UtcNow;
            ClientID  = pAssignedClient;

            _timeoutTimer          = new System.Timers.Timer();
            _timeoutTimer.Interval = TimeoutValue;
            _timeoutTimer.Elapsed += (sender, args) =>
            {
                _timeoutTimer.Stop();
                OnTimeoutHappenedEvent?.Invoke(this);
                StartDate     = DateTime.MinValue;
                ClientID      = String.Empty;
                WorkPackage   = null;
                _timeoutTimer = null;
            };
            _timeoutTimer.Start();

            return(new WorkPackage()
            {
                GUID = this.WorkItemID,
                WorkType = this.WorkType,
                Version = this.Version,
                InFiles = this.Files
            });
        }
示例#2
0
        public void DefaultParameterValueIsReturnedForNonExistingKey()
        {
            var section = new ConfigurationSection(SectionName);

            const OptionsEnum optionsEnumDefault = OptionsEnum.None;
            OptionsEnum       optionsEnum        = section.Get(Key, optionsEnumDefault);

            Assert.Equal(optionsEnumDefault, optionsEnum);

            const OSEnum osEnumDefault = OSEnum.WinXp;
            OSEnum       osEnum        = section.Get(Key, osEnumDefault);

            Assert.Equal(osEnumDefault, osEnum);

            const string stringDefault = Value;
            string       stringValue   = section.Get(Key, stringDefault);

            Assert.Equal(stringDefault, stringValue);

            bool boolValue = section.Get(Key, true);

            Assert.Equal(true, boolValue);

            boolValue = section.Get(Key, false);
            Assert.Equal(false, boolValue);

            var defaultSection = new ConfigurationSection("MyDefault");
            ConfigurationSection dummySection = section.Get(Key, defaultSection);

            Assert.Equal(defaultSection, dummySection);
        }
示例#3
0
        public void CanGetAndSetEnumInt32Values()
        {
            const OSEnum value   = OSEnum.Win2k;
            var          section = new ConfigurationSection(SectionName);

            section.Set(Key, (int)value);
            var fromSection = section.Get <OSEnum>(Key);

            Assert.Equal(value, fromSection);
        }
示例#4
0
        public WorkPackage FetchWork(OSEnum pOS, String pAssignedClient)
        {
            if (!QueuedWorkItems.Any())
            {
                return(null);
            }

            //get first item in list and create package for it
            var item    = QueuedWorkItems.First();
            var package = item.Start(pOS, pAssignedClient);

            //move from queued to active
            QueuedWorkItems.Remove(item);
            ActiveWorkItems.Add(item);

            return(package);
        }
示例#5
0
        public WorkPackage Start(OSEnum pOS, String pAssignedClient)
        {
            StartDate = DateTime.UtcNow;
            ClientID  = pAssignedClient;

            _timeoutTimer          = new System.Timers.Timer();
            _timeoutTimer.Interval = TimeoutValue;
            _timeoutTimer.Elapsed += (sender, args) =>
            {
                _timeoutTimer.Stop();
                OnTimeoutHappenedEvent?.Invoke(this);
                StartDate     = DateTime.MinValue;
                ClientID      = String.Empty;
                WorkPackage   = null;
                _timeoutTimer = null;
            };
            _timeoutTimer.Start();

            WorkPackage = CreateWorkPackage(pOS, Parameters);
            return(WorkPackage);
        }
示例#6
0
        private WorkPackage CreateWorkPackage(OSEnum pOS, String pParameter)
        {
            //clean
            if (pOS == OSEnum.Ubuntu)
            {
                return new WorkPackage()
                       {
                           //example ubuntu commands
                           Commands = new List <WorkPackage.Command>()
                           {
                               new WorkPackage.Command()
                               {
                                   FileName   = "/bin/bash",
                                   Arguments  = "-c \"git clone http://git.chemsorly.com/Chemsorly/MA-C2K-LSTM.git\"",
                                   WorkDir    = "/root/app",
                                   Parameters = pParameter
                               },
                               new WorkPackage.Command()
                               {
                                   FileName   = "/bin/bash",
                                   Arguments  = "-c \"git fetch --all\"",
                                   WorkDir    = "/root/app/MA-C2K-LSTM",
                                   Parameters = pParameter
                               },
                               new WorkPackage.Command()
                               {
                                   FileName   = "/bin/bash",
                                   Arguments  = "-c \"git pull --all\"",
                                   WorkDir    = "/root/app/MA-C2K-LSTM",
                                   Parameters = pParameter
                               },
                               new WorkPackage.Command()
                               {
                                   FileName   = "/bin/bash",
                                   Arguments  = $"-c \"source /cntk/activate-cntk && /root/anaconda3/envs/cntk-py27/bin/python -u {pParameter}\"",
                                   WorkDir    = "/root/app/MA-C2K-LSTM/code",
                                   Parameters = pParameter
                               }
                           },
                           TargetFiles = new List <List <string> >()
                           {
                               new List <string>()
                               {
                                   "MA-C2K-LSTM", "code", "output_files", "models", "model-latest.h5"
                               },
                               new List <string>()
                               {
                                   "MA-C2K-LSTM", "code", "output_files", "results", "results.csv"
                               }
                           }
                       }
            }
            ;
            if (pOS == OSEnum.Windows)
            {
                return new WorkPackage()
                       {
                           //example windows commands
                           Commands = new List <WorkPackage.Command>()
                           {
                               new WorkPackage.Command()
                               {
                                   FileName   = "cmd",
                                   Arguments  = "/C \"git clone http://git.chemsorly.com/Chemsorly/MA-C2K-LSTM.git\"",
                                   WorkDir    = "C:\\app\\",
                                   Parameters = pParameter
                               },
                               new WorkPackage.Command()
                               {
                                   FileName   = "/bin/bash",
                                   Arguments  = "-c \"git fetch --all\"",
                                   WorkDir    = "/root/app/MA-C2K-LSTM",
                                   Parameters = pParameter
                               },
                               new WorkPackage.Command()
                               {
                                   FileName   = "/bin/bash",
                                   Arguments  = "-c \"git pull --all\"",
                                   WorkDir    = "/root/app/MA-C2K-LSTM",
                                   Parameters = pParameter
                               },
                               new WorkPackage.Command()
                               {
                                   FileName   = "python",
                                   Arguments  = $"-u {pParameter}",
                                   WorkDir    = "C:\\app\\MA-C2K-LSTM\\code",
                                   Parameters = pParameter
                               }
                           },
                           TargetFiles = new List <List <string> >()
                           {
                               new List <string>()
                               {
                                   "MA-C2K-LSTM", "code", "output_files", "models", "model-latest.h5"
                               },
                               new List <string>()
                               {
                                   "MA-C2K-LSTM", "code", "output_files", "results", "results.csv"
                               }
                           }
                       }
            }
            ;
            return(null);
        }
    }
}
示例#7
0
 private WorkPackage SignalrmanagerOnWorkRequestedEvent(OSEnum pos, string pclientid)
 {
     return(_commandManager.FetchWork(pos, pclientid));
 }
示例#8
0
 internal EnumOS(OSEnum type)
 {
     this.Enum = type;
 }