コード例 #1
0
        public bool UpdateResponseLog(MainLogDTO log, MyLogDBEntities logContext)
        {
            MainLog dbLog = logContext.MainLog.FirstOrDefault(x => x.ID == log.ID);

            if (dbLog != null)
            {
                dbLog.Succeed   = log.Succeed;
                dbLog.Exception = log.Exception;
                if (dbLog.Exception == true)
                {
                    dbLog.ExceptionDetail             = new MyLogManager.ExceptionDetail();
                    dbLog.ExceptionDetail.Description = log.ExceptionDesc;
                }
                dbLog.Duration = (int)(DateTime.Now.TimeOfDay - dbLog.Time).TotalSeconds;
                foreach (var parameter in log.ResultParameters)
                {
                    var dbparameter = new ResultParameters()
                    {
                        Name = parameter.Name, Value = parameter.Value
                    };
                    dbLog.ResultParameters.Add(dbparameter);
                }
                logContext.SaveChanges();
                return(true);
            }



            return(false);
        }
コード例 #2
0
        public bool InsertRequestLog(MainLogDTO log, MyLogDBEntities logContext)
        {
            MainLog dbLog = new MainLog();

            dbLog.UserID = log.UserID;
            if (log.PackageGuid != null && log.PackageGuid != Guid.Empty)
            {
                dbLog.PackageGuid = log.PackageGuid;
            }
            dbLog.Date         = DateTime.Now.ToShortDateString();
            dbLog.Time         = DateTime.Now.TimeOfDay;
            dbLog.Type         = (Int16)log.Type;
            dbLog.LocationInfo = log.LocationInfo;
            if (log.EnityID != 0)
            {
                dbLog.EntityID = log.EnityID;
            }
            else
            {
                dbLog.EntityID = null;
            }

            foreach (var keyColumn in log.KeyColumns)
            {
                var dbKeycolumn = new MyLogManager.EntityKeyColumns()
                {
                    ColumnID = keyColumn.ColumnID, Value = keyColumn.Value
                };
                dbLog.EntityKeyColumns.Add(dbKeycolumn);
            }
            foreach (var dataColumn in log.DataEntryColumns)
            {
                var dbdataColumn = new DataEntryColumns()
                {
                    ColumnID = dataColumn.ColumnID, Value = dataColumn.Value
                };
                dbLog.DataEntryColumns.Add(dbdataColumn);
            }
            foreach (var parameter in log.RecievedParameters)
            {
                var dbparameter = new RecievedParameters()
                {
                    Name = parameter.Name, Value = parameter.Value
                };
                dbLog.RecievedParameters.Add(dbparameter);
            }

            logContext.MainLog.Add(dbLog);
            //logContext.SaveChanges();
            log.ID = dbLog.ID;
            return(true);
        }