Beispiel #1
0
        public static LogPO LogDOtoPO(LogDO from)
        {
            LogPO to = new LogPO();

            to.LogID     = from.LogID;
            to.Timestamp = from.Timestamp;
            to.Message   = from.Message;
            return(to);
        }
 public static void WriteLogAsyn(LogDO log)
 {
     new Task(() =>
     {
         log.LogTime = DateTime.Now;
         log.Ip      = SecurityHelper.GetWebClientIp();
         LFFK.DataManager.Insert <LogDO>(log);
     });
 }
Beispiel #3
0
        public static LogDO LogTableRowToDO(DataRow row)
        {
            LogDO logDO = new LogDO();

            logDO.LogID     = int.Parse(row["LogID"].ToString());
            logDO.Timestamp = row["Timestamp"].ToString().Trim();
            logDO.Message   = row["Message"].ToString().Trim();
            return(logDO);
        }
Beispiel #4
0
 public LogDO Constructor(
     uint? table,
     uint? cpr,
     ActivityEnum? activity
 )
 {
     LogDO target = new LogDO(table, cpr, activity);
     return target;
     // TODO: add assertions to method LogDOTest.Constructor(Nullable`1<UInt32>, Nullable`1<UInt32>, Nullable`1<ActivityEnum>)
 }
Beispiel #5
0
        public LogDO Constructor(
            uint?table,
            uint?cpr,
            ActivityEnum?activity
            )
        {
            LogDO target = new LogDO(table, cpr, activity);

            return(target);
            // TODO: add assertions to method LogDOTest.Constructor(Nullable`1<UInt32>, Nullable`1<UInt32>, Nullable`1<ActivityEnum>)
        }
Beispiel #6
0
 /// <summary>
 /// Updates the log with activity registered for the current voter
 /// </summary>
 /// <param name="ae">The activity to be logged</param>
 private void UpdateLog(ActivityEnum ae)
 {
     try
     {
         //Create the log DAO with setup information, activity and current voter.
         var ldo  = new LogDO(setupInfo.TableNo, currentVoter.PrimaryKey, ae);
         var ldao = new LogDAO(DigitalVoterList.GetInstanceFromServer(setupInfo.Ip));
         ldao.Create(ldo);
     }
     catch (Exception)
     {
         ConnectionError();
     }
 }
 public static void WriteInfoLogAsyn(string msg, string title = "日志记录")
 {
     new Task(() =>
     {
         var log = new LogDO()
         {
             Message = msg,
             LogTime = DateTime.Now,
             Level   = "INFO",
             Title   = title,
             Ip      = SecurityHelper.GetWebClientIp(),
         };
         LFFK.DataManager.Insert <LogDO>(log);
     });
 }
 public static void WriteInfoLogAsyn(Exception ex, string title = "日志记录")
 {
     new Task(() =>
     {
         var log = new LogDO()
         {
             Message   = ex.Message,
             Exception = ex.Message + ex.Source + ex.StackTrace,
             LogTime   = DateTime.Now,
             Level     = "INFO",
             Ip        = SecurityHelper.GetWebClientIp(),
             Title     = title,
         };
         LFFK.DataManager.Insert <LogDO>(log);
     });
 }
        public List <LogDO> ObtainRecentLogs()
        {
            List <LogDO>   logs            = new List <LogDO>();
            SqlConnection  connectionToSql = null;
            SqlCommand     obtainLogs      = null;
            SqlDataAdapter adapter         = null;
            DataTable      logTable        = new DataTable();

            try
            {
                connectionToSql        = new SqlConnection(_connectionString);
                obtainLogs             = new SqlCommand("OBTAIN_RECENT_LOGS", connectionToSql);
                obtainLogs.CommandType = CommandType.StoredProcedure;
                connectionToSql.Open();
                adapter = new SqlDataAdapter(obtainLogs);
                adapter.Fill(logTable);
                foreach (DataRow row in logTable.Rows)
                {
                    LogDO logDO = Mapping.Mapper.LogTableRowToDO(row);
                    logs.Add(logDO);
                }
            }
            catch (Exception ex)
            {
                _logger.LogMessage(ex, "Fatal");
                throw ex;
            }
            finally
            {
                if (connectionToSql != null)
                {
                    connectionToSql.Close();
                    connectionToSql.Dispose();
                }
                if (adapter != null)
                {
                    adapter.Dispose();
                }
            }
            return(logs);
        }
Beispiel #10
0
        }   //  end LogError6

        public static StringBuilder GetIdentifier(string tableName, long CNtoFind)
        {
            StringBuilder ident = new StringBuilder();

            switch (tableName)
            {
            case "Sale":
                SaleDO sale = Global.BL.getSale().FirstOrDefault(sd => sd.Sale_CN == CNtoFind);
                if (sale != null)
                {
                    ident.Append("Sale number = ");
                    ident.Append(sale.SaleNumber);
                }
                else
                {
                    ident.Append("Sale number not found");
                }
                break;

            case "Stratum":
                StratumDO strat = Global.BL.getStratum().FirstOrDefault(sdo => sdo.Stratum_CN == CNtoFind);
                if (strat != null)
                {
                    ident.Append(strat.Code);
                }
                else
                {
                    ident.Append("Stratum code not found");
                }
                break;

            case "Cutting Unit":
                CuttingUnitDO cudo = Global.BL.getCuttingUnits().FirstOrDefault(cu => cu.CuttingUnit_CN == CNtoFind);
                if (cudo != null)
                {
                    ident.Append("   ");
                    ident.Append(cudo.Code.PadLeft(3, ' '));
                }
                else
                {
                    ident.Append("Cutting unit not found");
                }
                break;

            case "Tree":
                TreeDO tdo = Global.BL.getTrees().FirstOrDefault(td => td.Tree_CN == CNtoFind);
                if (tdo != null)
                {
                    ident.Append(tdo.Stratum.Code.PadRight(3, ' '));
                    ident.Append(tdo.CuttingUnit.Code.PadLeft(3, ' '));
                    if (tdo.Plot == null)
                    {
                        ident.Append("     ");
                    }
                    else if (tdo.Plot_CN == 0)
                    {
                        ident.Append("     ");
                    }
                    else
                    {
                        ident.Append(tdo.Plot.PlotNumber.ToString().PadLeft(5, ' '));
                    }
                    ident.Append(tdo.TreeNumber.ToString().PadLeft(5, ' '));
                    ident.Append(" --- ");
                    if (tdo.Species == null)
                    {
                        ident.Append("       ");
                    }
                    else
                    {
                        ident.Append(tdo.Species.PadRight(7, ' '));
                    }
                    if (tdo.SampleGroup == null)
                    {
                        ident.Append("   ");
                    }
                    else
                    {
                        if (tdo.SampleGroup.Code == "" || tdo.SampleGroup.Code == " " ||
                            tdo.SampleGroup.Code == "<Blank>" || tdo.SampleGroup.Code == null)
                        {
                            ident.Append("   ");
                        }
                        else
                        {
                            ident.Append(tdo.SampleGroup.Code.PadRight(3, ' '));
                        }
                        ident.Append(tdo.SampleGroup.PrimaryProduct.PadRight(3, ' '));
                    }       //  endif
                }
                else
                {
                    ident.Append("Tree not found");
                }
                break;

            case "Log":
                LogDO log = Global.BL.getLogs().FirstOrDefault(ld => ld.Log_CN == CNtoFind);
                if (log != null)
                {
                    ident.Append(log.Tree.Stratum.Code.PadRight(3, ' '));
                    ident.Append(log.Tree.CuttingUnit.Code.PadLeft(3, ' '));
                    if (log.Tree.Plot == null)
                    {
                        ident.Append("     ");
                    }
                    else
                    {
                        ident.Append(log.Tree.Plot.PlotNumber.ToString().PadLeft(5, ' '));
                    }
                    ident.Append(log.Tree.TreeNumber.ToString().PadLeft(5, ' '));
                    ident.Append(log.LogNumber.PadLeft(3, ' '));
                }
                else
                {
                    ident.Append("Log not found");
                }
                break;

            case "Volume Equation":
                if (CNtoFind == 0)
                {
                    CNtoFind = 1;
                }
                //List<VolumeEquationDO> vList = Global.BL.getVolumeEquations();
                VolumeEquationDO ve = Global.BL.getVolumeEquations().ElementAt((int)CNtoFind - 1);
                ident.Append("-- --- ---- ---- --- ");
                ident.Append(ve.Species.PadRight(7, ' '));
                ident.Append("-- ");
                ident.Append(ve.PrimaryProduct.PadRight(3, ' '));
                ident.Append(ve.VolumeEquationNumber.PadRight(10, ' '));

                //ident.Append("-- --- ---- ---- --- ");
                //ident.Append(vList[(int)CNtoFind-1].Species.PadRight(7, ' '));
                //ident.Append("-- ");
                //ident.Append(vList[(int)CNtoFind-1].PrimaryProduct.PadRight(3, ' '));
                //ident.Append(vList[(int)CNtoFind-1].VolumeEquationNumber.PadRight(10,' '));
                break;

            case "Value Equation":
                if (CNtoFind == 0)
                {
                    CNtoFind = 1;
                }
                ValueEquationDO veq = Global.BL.getValueEquations().ElementAt((int)CNtoFind - 1);
                ident.Append("-- --- ---- ---- --- ");
                ident.Append(veq.Species.PadRight(7, ' '));
                ident.Append("-- ");
                ident.Append(veq.PrimaryProduct.PadRight(3, ' '));
                ident.Append(veq.ValueEquationNumber.PadRight(10, ' '));
                //List<ValueEquationDO> veList = Global.BL.getValueEquations();
                //ident.Append("-- --- ---- ---- --- ");
                //ident.Append(veList[(int)CNtoFind-1].Species.PadRight(7, ' '));
                //ident.Append("-- ");
                //ident.Append(veList[(int)CNtoFind-1].PrimaryProduct.PadRight(3,' '));
                //ident.Append(veList[(int)CNtoFind-1].ValueEquationNumber.PadRight(10,' '));
                break;

            case "Quality Adjustment":
                if (CNtoFind == 0)
                {
                    CNtoFind = 1;
                }
                QualityAdjEquationDO qe = Global.BL.getQualAdjEquations().ElementAt((int)CNtoFind - 1);
                ident.Append("-- --- ---- ---- --- ");
                ident.Append(qe.Species.PadRight(7, ' '));
                ident.Append("-- -- ");
                ident.Append(qe.QualityAdjEq.PadRight(10, ' '));
                //List<QualityAdjEquationDO> qList = Global.BL.getQualAdjEquations();
                //ident.Append("-- --- ---- ---- --- ");
                //ident.Append(qList[(int)CNtoFind-1].Species.PadRight(7, ' '));
                //ident.Append("-- -- ");
                //ident.Append(qList[(int)CNtoFind-1].QualityAdjEq.PadRight(10,' '));
                break;

            case "SampleGroup":
                SampleGroupDO sg = Global.BL.getSampleGroups().FirstOrDefault(sgd => sgd.SampleGroup_CN == CNtoFind);
                if (sg != null)
                {
                    ident.Append(sg.Stratum.Code.PadRight(3, ' '));
                    ident.Append("--- ---- ---- --- ------ ");
                    ident.Append(sg.Code.PadRight(3, ' '));
                    ident.Append(sg.PrimaryProduct.PadRight(3, ' '));
                }
                else
                {
                    ident.Append("Sample Group not found");
                }
                break;
            } //  end switch
            return(ident);
        }     //  end GetIdentifier
Beispiel #11
0
        public DAL CreateDataStore(int treesToCreate, int numLogToCreate)
        {
            var ds = new DAL();

            try
            {
                var stratum = new StratumDO()
                {
                    DAL    = ds,
                    Code   = "01",
                    Method = "something"
                };

                stratum.Save();


                //set up the log fields
                int counter        = 1;
                var logFieldSetups = CruiseDAL.Schema.LOG._ALL
                                     .Select(x => new LogFieldSetupDO()
                {
                    DAL = ds, Field = x, FieldOrder = counter++, Heading = x, Stratum = stratum
                })
                                     .ToList();

                foreach (var lfs in logFieldSetups)
                {
                    lfs.Save();
                }

                var cuttingUnit = new CuttingUnitDO()
                {
                    DAL  = ds,
                    Code = "01"
                };

                cuttingUnit.Save();

                for (int j = 0; j < treesToCreate; j++)
                {
                    var tree = new TreeDO()
                    {
                        DAL         = ds,
                        CuttingUnit = cuttingUnit,
                        Stratum     = stratum,
                        TreeNumber  = j + 1
                    };

                    tree.Save();

                    for (int i = 0; i < numLogToCreate; i++)
                    {
                        var log = new LogDO()
                        {
                            DAL       = ds,
                            LogNumber = (i + 1).ToString(),
                            Tree      = tree,
                        };

                        log.Save();
                    }
                }

                return(ds);
            }
            catch
            {
                ds.Dispose();
                throw;
            }
        }
Beispiel #12
0
        private void dgvResultados2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string statedid = dgvResultados2.Rows[e.RowIndex].Cells[7].Value.ToString();
            string ticketid = dgvResultados2.Rows[e.RowIndex].Cells[3].Value.ToString();
            Form   f1       = new frmEditarEstado();

            frmEditarEstado.f1.Text = "Expediente: " + ticketid;
            frmEditarEstado.f1.lblExpediente.Text = ticketid;
            frmEditarEstado.f1.cmbEstado.Text     = statedid.ToString();
            // frmEditarEstado.f1.cmbEstado.DataSource = EstadoDO.ListarEstados(statedid);
            frmEditarEstado.f1.cmbEstado.DataSource    = EstadoDO.ListarEstados(statedid);
            frmEditarEstado.f1.cmbEstado.ValueMember   = "stateid";
            frmEditarEstado.f1.cmbEstado.DisplayMember = "name";

            frmEditarEstado.f1.dgvValues.DataSource            = ValuesDO.ListarValues(ticketid);
            frmEditarEstado.f1.dgvValues.Columns[0].HeaderText = "Id";
            frmEditarEstado.f1.dgvValues.Columns[0].Width      = 60;
            frmEditarEstado.f1.dgvValues.Columns[1].HeaderText = "Ticket";
            frmEditarEstado.f1.dgvValues.Columns[1].Width      = 70;
            frmEditarEstado.f1.dgvValues.Columns[2].HeaderText = "Field";
            frmEditarEstado.f1.dgvValues.Columns[2].Width      = 200;
            frmEditarEstado.f1.dgvValues.Columns[3].HeaderText = "Value";
            frmEditarEstado.f1.dgvValues.Columns[3].Width      = 550;
            frmEditarEstado.f1.dgvValues.Columns[4].HeaderText = "Order";
            frmEditarEstado.f1.dgvValues.Columns[4].Width      = 50;

            frmEditarEstado.f1.dgvLog.DataSource            = LogDO.ListarLog(ticketid);
            frmEditarEstado.f1.dgvLog.Columns[0].HeaderText = "Id";
            frmEditarEstado.f1.dgvLog.Columns[0].Width      = 60;
            frmEditarEstado.f1.dgvLog.Columns[1].HeaderText = "GUID";
            frmEditarEstado.f1.dgvLog.Columns[1].Width      = 100;
            frmEditarEstado.f1.dgvLog.Columns[2].HeaderText = "Robot";
            frmEditarEstado.f1.dgvLog.Columns[2].Width      = 100;
            frmEditarEstado.f1.dgvLog.Columns[3].HeaderText = "StateId";
            frmEditarEstado.f1.dgvLog.Columns[3].Width      = 60;
            frmEditarEstado.f1.dgvLog.Columns[4].HeaderText = "State";
            frmEditarEstado.f1.dgvLog.Columns[4].Width      = 100;
            frmEditarEstado.f1.dgvLog.Columns[5].HeaderText = "TicketId";
            frmEditarEstado.f1.dgvLog.Columns[5].Width      = 60;
            frmEditarEstado.f1.dgvLog.Columns[6].HeaderText = "Descripción";
            frmEditarEstado.f1.dgvLog.Columns[6].Width      = 150;
            frmEditarEstado.f1.dgvLog.Columns[7].HeaderText = "Excepción";
            frmEditarEstado.f1.dgvLog.Columns[7].Width      = 100;
            frmEditarEstado.f1.dgvLog.Columns[8].HeaderText = "Método";
            frmEditarEstado.f1.dgvLog.Columns[8].Width      = 100;
            frmEditarEstado.f1.dgvLog.Columns[8].HeaderText = "Creación";
            frmEditarEstado.f1.dgvLog.Columns[8].Width      = 100;

            frmEditarEstado.f1.dgvHist.DataSource            = HistoriesDO.ListarHistories(ticketid);
            frmEditarEstado.f1.dgvHist.Columns[0].HeaderText = "Id";
            frmEditarEstado.f1.dgvHist.Columns[0].Width      = 60;
            frmEditarEstado.f1.dgvHist.Columns[1].HeaderText = "TicketId";
            frmEditarEstado.f1.dgvHist.Columns[1].Width      = 80;
            frmEditarEstado.f1.dgvHist.Columns[2].HeaderText = "Estado";
            frmEditarEstado.f1.dgvHist.Columns[2].Width      = 200;
            frmEditarEstado.f1.dgvHist.Columns[3].HeaderText = "Usuario";
            frmEditarEstado.f1.dgvHist.Columns[3].Width      = 150;
            frmEditarEstado.f1.dgvHist.Columns[4].HeaderText = "RobotGuid";
            frmEditarEstado.f1.dgvHist.Columns[4].Width      = 200;
            frmEditarEstado.f1.dgvHist.Columns[5].HeaderText = "Robot";
            frmEditarEstado.f1.dgvHist.Columns[5].Width      = 200;
            frmEditarEstado.f1.dgvHist.Columns[6].HeaderText = "Acción";
            frmEditarEstado.f1.dgvHist.Columns[6].Width      = 150;
            f1.ShowDialog();
        }