Exemple #1
0
        public MakinoBackend(IConfiguration config, FMSSettings st)
        {
            try
            {
                var cfg = config.GetSection("Makino");

                string adePath = cfg.GetValue <string>("ADE Path");
                if (string.IsNullOrEmpty(adePath))
                {
                    adePath = @"c:\Makino\ADE";
                }

                string dbConnStr = cfg.GetValue <string>("SQL Server Connection String");
                if (string.IsNullOrEmpty(dbConnStr))
                {
                    dbConnStr = DetectSqlConnectionStr();
                }

                bool downloadOnlyOrders = cfg.GetValue <bool>("Download Only Orders");

                Log.Information(
                    "Starting makino backend. Connection Str: {connStr}, ADE Path: {path}, DownloadOnlyOrders: {downOnlyOrders}",
                    dbConnStr, adePath, downloadOnlyOrders);

                _dataDirectory = st.DataDirectory;

                _log = new JobLogDB(st);
                _log.Open(
                    System.IO.Path.Combine(_dataDirectory, "log.db"),
                    System.IO.Path.Combine(_dataDirectory, "inspections.db"),
                    startingSerial: st.StartingSerial
                    );

                _jobDB = new BlackMaple.MachineFramework.JobDB();
                _jobDB.Open(System.IO.Path.Combine(_dataDirectory, "jobs.db"));

                _status = new StatusDB(System.IO.Path.Combine(_dataDirectory, "makino.db"));

#if DEBUG
                _makinoDB = new MakinoDB(MakinoDB.DBTypeEnum.SqlLocal, "", _status, _log);
#else
                _makinoDB = new MakinoDB(MakinoDB.DBTypeEnum.SqlConnStr, dbConnStr, _status, _log);
#endif

                _logTimer = new LogTimer(_log, _jobDB, _makinoDB, _status, st);

                _jobs = new Jobs(_makinoDB, _jobDB, adePath, downloadOnlyOrders);

                _logTimer.LogsProcessed += OnLogsProcessed;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error when initializing makino backend");
            }
        }
Exemple #2
0
 public LogTimer(
     JobLogDB log, JobDB jobDB, MakinoDB makinoDB, StatusDB status, FMSSettings settings)
 {
     _lock     = new object();
     _log      = log;
     _jobDB    = jobDB;
     Settings  = settings;
     _makinoDB = makinoDB;
     _status   = status;
     TimerSignaled(null, null);
     _timer          = new System.Timers.Timer(TimeSpan.FromMinutes(1).TotalMilliseconds);
     _timer.Elapsed += TimerSignaled;
     _timer.Start();
 }
Exemple #3
0
        public MakinoDB(DBTypeEnum dbType, string dbConnStr, StatusDB status,
                        BlackMaple.MachineFramework.JobLogDB log)
        {
            _status = status;
            _logDb  = log;
            switch (dbType)
            {
            case DBTypeEnum.SqlLocal:
                _db = new System.Data.SqlClient.SqlConnection("Data Source = (localdb)\\MSSQLLocalDB; Initial Catalog = Makino;");
                _db.Open();
                dbo = "dbo.";
                break;

            case DBTypeEnum.SqlConnStr:
                _db = new System.Data.SqlClient.SqlConnection(dbConnStr);
                _db.Open();
                dbo = "dbo.";
                break;
            }
        }