コード例 #1
0
        public void test_add_new_connection_log(ISession session)
        {
            var connection_log = new Domain.Cloud.Logs.ConnectionLogs {
                application = session.Get <TUFStatus.Domain.Cloud.App.Applications>(3), installation = session.Get <TUFStatus.Domain.Cloud.App.Installations>(1), connection_time = DateTime.Now
            };
            //if connection_log.disconnection_time.HasValue

            //IConnectionLogRepository repository = new ConnectionLogRepository();
            var repository = new TUFStatus.DAL.Repositories.Repository <ISession, Domain.Cloud.Logs.ConnectionLogs>(session);

            using (var xa = session.BeginTransaction())
            {
                repository.Add(connection_log);
                //frepo.Add(fad);
                xa.Commit();
                //frepo.Reload(fad);
                //Assert.NotNull(fad);
                //Assert.AreNotEqual(0, fad.Id);
            }
        }
コード例 #2
0
ファイル: CloudStatusDB.cs プロジェクト: spc-ofp/TUFStatus
        public int WriteConnectionLog()
        {
            try
            {
                //using (ISession session = NHibernateHelper.OpenLocalSession())
                Domain.Cloud.Logs.ConnectionLogs connection_log = new Domain.Cloud.Logs.ConnectionLogs
                {
                    application     = session.Get <TUFStatus.Domain.Cloud.App.Applications>(3),
                    installation    = session.Get <TUFStatus.Domain.Cloud.App.Installations>(Program.TufmanInstallationID),
                    connection_time = DateTime.Now
                };

                var repository = new TUFStatus.DAL.Repositories.Repository <ISession, Domain.Cloud.Logs.ConnectionLogs>(session);


                using (var xa = session.BeginTransaction())
                {
                    repository.Add(connection_log);
                    xa.Commit();
                    //Assert.NotNull(fad);
                    //Assert.AreNotEqual(0, fad.Id);
                }


                if (Program.RunMode == 0)
                {
                    int x = connection_log.connection_id;
                    System.Windows.Forms.MessageBox.Show(x.ToString() + ":" + connection_log.installation.installation_id.ToString());    //.description.ToString());
                }

                connectionID = connection_log.connection_id;
            }
            catch (Exception ex)
            {
                ErrorHandler.Instance.HandleError(ActionLog.ActionTypes.Application, "", "There was an error writing the connection log:", ex.Message);
                return(0);
            }

            return(connectionID);
        }
コード例 #3
0
ファイル: CloudStatusDB.cs プロジェクト: spc-ofp/TUFStatus
        public bool WriteDisconnectionTime()
        {
            try
            {
                var repository = new TUFStatus.DAL.Repositories.Repository <ISession, Domain.Cloud.Logs.ConnectionLogs>(session);
                //Domain.Cloud.Logs.Connection_Logs connection_log = session.Get<Domain.Cloud.Logs.Connection_Logs>(connectionID);

                using (var xa = session.BeginTransaction())
                {
                    Domain.Cloud.Logs.ConnectionLogs connection_log = repository.FindById(connectionID);
                    connection_log.disconnection_time = DateTime.Now;
                    repository.Update(connection_log);
                    xa.Commit();
                    //Assert.NotNull(fad);
                    //Assert.AreNotEqual(0, fad.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Instance.HandleError(ActionLog.ActionTypes.Application, "", "There was an error writing the disconnection time:", ex.Message);
                return(false);
            }
            return(true);
        }