예제 #1
0
        public static List <MsgFile> ReadMsgFiles(bool addFullFiles,
                                                  [NotNull][ItemNotNull] List <FileInfo> filteredFiles,
                                                  [NotNull] DirectoryInfo baseDir, [NotNull] DistLogger logger, [NotNull] ThreadId threadId)
        {
            var  lpgFiles  = new List <MsgFile>();
            long totalSize = 0;

            foreach (var fi in filteredFiles)
            {
                var relativeDirectory = "";
                if (fi.DirectoryName?.Length > baseDir.FullName.Length)
                {
                    relativeDirectory = fi.DirectoryName.Substring(baseDir.FullName.Length).Trim().Trim('\\');
                }

                MsgFile jf = new MsgFile(fi, relativeDirectory);
                if (addFullFiles)
                {
                    jf.FileContent = File.ReadAllBytes(fi.FullName);
                }

                totalSize += fi.Length;
                lpgFiles.Add(jf);
            }

            string prettySize = AutomationUtili.MakePrettySize(totalSize);

            logger.Info("Collected files with " + prettySize, threadId);
            return(lpgFiles);
        }
 public ClientThread([NotNull] DistLogger logger, [NotNull] Settings mySettings, [NotNull] ThreadId threadId)
 {
     _logger     = logger;
     _mySettings = mySettings;
     _threadId   = threadId;
     logger.Info("initalizing logger", threadId);
 }
 public ServerThread([NotNull] Settings settings, [NotNull] ThreadId threadId, [NotNull] DistLogger logger, [NotNull] DistLogger errorLogger)
 {
     _settings    = settings;
     _threadId    = threadId;
     _logger      = logger;
     _errorLogger = errorLogger;
     logger.Info("Initializing Server", _threadId);
 }
        public ApplicationPresenter()
        {
            var settings = LoadSettings();

#pragma warning disable CA2000 // Dispose objects before losing scope
            DistLogger logger = new DistLogger(@"c:\work\DistCalc.Server.Log.sqlite", "Log", null);
#pragma warning restore CA2000 // Dispose objects before losing scope
#pragma warning disable CA2000 // Dispose objects before losing scope
            DistLogger errorlogger = new DistLogger(@"c:\work\DistCalc.Server.CalcErrors.sqlite", "Log", null);
#pragma warning restore CA2000 // Dispose objects before losing scope
            ServerThread = new ServerThread(settings, new ThreadId("Server", 1), logger, errorlogger);
            //AutoClosingMessageBox.Show("Starting the server", "ServerStart", 5000);
            var t = new Thread(() => ServerThread.Run(ShowMessageBox));
            t.Start();
        }
예제 #5
0
        public void WriteBytesFromJson([NotNull] string dstPath, [NotNull] DistLogger logger)
        {
            if (FileContent == null)
            {
                throw new DistSimException("Tried to save an empty jsonfile");
            }

            if (FileContent.Length != FileLength)
            {
                throw new DistSimException("File length is wrong");
            }

            try {
                File.WriteAllBytes(dstPath, FileContent);
                File.SetLastWriteTime(dstPath, FileModifiedDate);
            }
            catch (Exception ex) {
                logger.Exception(ex, "failed to write results to " + dstPath);
                throw;
            }
        }
        public MainWindowClient()
        {
            BindingErrorListener.Listen(m => {
                if (!m.Contains("FindAncestor"))
                {
                    var s = m;
                    var t = new Thread(() => MessageBox.Show(s));
                    Console.WriteLine(m);
                    t.Start();
                }
            });
            InitializeComponent();
            _applicationPresenter = new ApplicationPresenter();
            SaveExecuteHelper.Get().Dispatcher = Dispatcher;
            for (int i = 1; i <= _applicationPresenter.Settings.ClientSettings.NumberOfThreads; i++)
            {
                string workingDir = _applicationPresenter.Settings.ClientSettings.WorkingDirectory;
#pragma warning disable CA2000 // Dispose objects before losing scope
                string     logfilename = Path.Combine(workingDir, "DistCalc.Client." + i + ".Log.sqlite");
                DistLogger logger      = new DistLogger(logfilename, "Log", null);
#pragma warning restore CA2000 // Dispose objects before losing scope
                Settings cs = new Settings(_applicationPresenter.Settings);
                cs.ClientSettings.WorkingDirectory = Path.Combine(cs.ClientSettings.WorkingDirectory, "c" + i);
                ClientThread ct = new ClientThread(logger, cs, new ThreadId(Environment.MachineName, i));
                _clientThreads.Add(ct);
                var t = new Thread(() => ct.Run(ShowMessageBox));
                _threads.Add(t);
                t.Start();
                TabItem ti = new TabItem();
                ti.Header = "Client " + i;
                ClientView      cv = new ClientView();
                ClientPresenter cp = new ClientPresenter(ct, this);
                cv.DataContext = cp;
                ti.Content     = cv;
                MyTabControl.Items.Add(ti);
            }
        }
예제 #7
0
 public CalcDirectoryPreparer([NotNull] Settings settings, [NotNull] DistLogger logger, [NotNull] ThreadId threadId)
 {
     _settings = settings;
     _logger   = logger;
     _threadId = threadId;
 }
 public CalcExecutor([NotNull] ThreadId threadId, [NotNull] DistLogger logger, [NotNull] Settings mySettings)
 {
     _threadId   = threadId;
     _mySettings = mySettings;
     _logger     = logger;
 }