Ejemplo n.º 1
0
        /// <summary>
        /// Detalle de inspeccion del panel general
        /// </summary>
        /// <returns></returns>
        private List <Detail> GetInspectionDetail()
        {
            string query = SqlServerQuery.ListFaultInfo(this);

            DataTable dt = _sqlserver.Query(query);

            List <Detail> detalles = new List <Detail>();

            if (dt.Rows.Count > 0)
            {
                #region FILL_ERROR_DETAIL
                foreach (DataRow r in dt.Rows)
                {
                    int    bid = int.Parse(r["bloque"].ToString());
                    Detail det = new Detail();
                    det.faultcode  = r["faultcode"].ToString();
                    det.estado     = r["estado"].ToString();
                    det.referencia = r["uname"].ToString();
                    det.bloqueId   = bid;
                    //det.total_faultcode = int.Parse(r["total"].ToString());
                    det.descripcionFaultcode = r["descripcion"].ToString();

                    if (!DuplicatedInspectionDetail(det, detalles))
                    {
                        detalles.Add(det);
                    }
                }
                #endregion
            }
            return(detalles);
        }
Ejemplo n.º 2
0
        public void Seila()
        {
            var exp = "select * from Person.Person where FirstName = 'David' AND JobTitle = 'Developer'";
            var q = new SqlServerQuery()
                .Select("*")
                .From("Person.Person")
                .Where("{0} = {1} AND {2} = {3}", "FirstName", "'David'", "JobTitle", "'Developer'");

            Assert.AreEqual(exp, q.ToString(), true);
        }
Ejemplo n.º 3
0
        public void Simple_Select_Using_Order_By()
        {
            var exp = "select * from Person.Person order by PersonID";

            var q = new SqlServerQuery()
                .Select("*")
                .From("Person.Person")
                .OrderBy("PersonID");

            Assert.AreEqual(exp, q.ToString(), ignoreCase: true);
        }
Ejemplo n.º 4
0
        public void TestAnd_ValidateNull()
        {
            SqlServerQuery query = new SqlServerQuery();

            query.Select("");
            var sqlbuilder = query.GetSqlBuilder();

            query.NewSqlBuilder();
            // query.Less();

            Expression <Func <Customer, bool> > _expression = null;

            _query.And(_expression);
            Assert.AreEqual(null, _query.GetPredicate());
        }
Ejemplo n.º 5
0
        public void Simple_Select_Should_Work_As_Expected()
        {
            var expected = "select * from HumanResources.Employee";
            var expected2 = "select JobTitle, BirthDate FROM HumanResources.Employee";
            var expected3 = "select * from Person.Person";

            Query query = new SqlServerQuery();
            query.Select("*").From("HumanResources.Employee");

            Query query2 = new SqlServerQuery()
                .Select("JOBTITLE", "BIRTHDATE")
                .From("HumanResources.Employee");

            Query query3 = new SqlServerQuery()
                .Select("* FROM Person.Person");

            Assert.AreEqual(expected, query.ToString(), true);
            Assert.AreEqual(expected2, query2.ToString(), true);
            Assert.AreEqual(expected3, query3.ToString(), true);
        }
        public BulkTask CreateTask(string taskName)
        {
            Check.NotEmpty(taskName, nameof(taskName));

            var connectionString      = _taskConfigurationObject.GetConfigurationValue <string>("connectionString");
            var query                 = _taskConfigurationObject.GetConfigurationValue <string>("query");
            var host                  = _taskConfigurationObject.GetConfigurationValue <string>("host");
            var port                  = _taskConfigurationObject.GetConfigurationValue <int>("port");
            var source                = new SqlServerQuery(connectionString, query);
            var bulkTaskConfiguration = new BulkTaskConfiguration(taskName, host, port)
            {
                IndexName = IndexTemplate, TypeName = Type
            };
            var chunkConfiguration = new ChunkConfiguration()
            {
                ChunkSize = ChunkSize
            };

            return(new BulkTask(bulkTaskConfiguration, chunkConfiguration, source, _logger));
        }
Ejemplo n.º 7
0
        public void HandleInspection(Machine inspMachine)
        {
            DateTime new_last_inspection = new DateTime(1, 1, 1);

            inspMachine.LogBroadcast("info",
                                     string.Format("{0} | Maquina {1} | Ultima inspeccion {2}",
                                                   inspMachine.smd,
                                                   inspMachine.line_barcode,
                                                   inspMachine.ultima_inspeccion
                                                   )
                                     );

            string    query     = SqlServerQuery.ListLastInspections(inspMachine.maquina, inspMachine.ultima_inspeccion);
            DataTable dt        = sqlserver.Query(query);
            int       totalRows = dt.Rows.Count;

            aoiWorker.SetProgressTotal(totalRows);

            if (totalRows > 0)
            {
                inspMachine.LogBroadcast("notify",
                                         string.Format("Se encontraron ({0}) inspecciones.", totalRows)
                                         );

                int count = 0;

                #region CREATE_INSPECTION_OBJECT
                foreach (DataRow r in dt.Rows)
                {
                    count++;
                    ZenithPanel panel = new ZenithPanel(sqlserver, r, inspMachine);

                    inspMachine.LogBroadcast("info",
                                             string.Format("Programa: [{0}] | PanelBarcode: {1} | Bloques: {2} | Pendiente: {3}", panel.programa, panel.barcode, panel.pcbInfo.bloques, panel.pendiente)
                                             );

                    if (!Config.debugMode)
                    {
                        // TENGO QUE DESCOMENTAR ESTO PARA GUARDAR EN TRAZA
                        panel.TrazaSave(aoiConfig.xmlExportPath);
                        aoiWorker.SetProgressWorking(count);
                    }

                    // Ultima inspeccion realizada en la maquina ORACLE.
                    new_last_inspection = DateTime.Parse(panel.fecha + " " + panel.hora);
                }

                if (new_last_inspection.Year.Equals(1))
                {
                    new_last_inspection = oracle.GetSysDate();
                }
                #endregion

                if (!Config.debugMode)
                {
                    inspMachine.LogBroadcast("debug",
                                             string.Format("Actualizando horario de ultima inspeccion de maquina {0}", new_last_inspection.ToString("HH:mm:ss"))
                                             );

                    // TENGO QUE DESCOMENTAR ESTO PARA ACTUALIZAR LA ULTIMA INSPECCION
                    Machine.UpdateInspectionDate(inspMachine.mysql_id, new_last_inspection);
                }
            }
            else
            {
                inspMachine.LogBroadcast("notify", "No se encontraron inspecciones");
            }

            inspMachine.Ping();
        }
Ejemplo n.º 8
0
        public void Simple_Select_With_WhereClause_Should_Work_As_Expected()
        {
            var exp = "select * from HumanResources.Employee where VacationHours >= 60";
            var exp2 = "select * from HumanResources.Employee where JobTitle = 'Research and Development Engineer'";

            Query query = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .Where("VacationHours >= 60");

            Query query2 = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .Where("JobTitle = 'Research and Development Engineer'");

            Assert.AreEqual(exp, query.ToString(), true);
            Assert.AreEqual(exp2, query2.ToString(), true);
        }
Ejemplo n.º 9
0
 public void Calling_Method_Take_Passing_Negative_Number_Should_Throw()
 {
     var q = new SqlServerQuery()
         .Select("*").From("Person.Person").OrderBy("PersonID").Take(-1);
 }
Ejemplo n.º 10
0
 public List <string> GetTables(string connectionString)
 {
     return(SqlServerQuery.GetTables(connectionString));
 }
Ejemplo n.º 11
0
        public void Simple_Select_With_WhereClause_Using_StartsWith()
        {
            var exp = "select * from Person.Person where FirstName LIKE 'Em%'";

            var q = new SqlServerQuery()
                .Select("*")
                .From("Person.Person")
                .WhereField("FirstName")
                .StartsWith("Em");

            Assert.AreEqual(exp, q.ToString(), true);
        }
Ejemplo n.º 12
0
        public void Simple_Select_With_WhereClause_Using_Contains()
        {
            var exp = "select * from HumanResources.Employee where JobTitle LIKE '%Manager%'";
            var q = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .WhereField("JobTitle")
                .Contains("Manager");

            Assert.AreEqual(exp, q.ToString(), true);
        }
Ejemplo n.º 13
0
 public HttpResponseMessage RemoveData([FromUri] string connectionString, [FromUri] string tableName, [FromBody] List <crud.web.Data.Data> row)
 {
     return(Request.CreateResponse(HttpStatusCode.OK, SqlServerQuery.DeleteData(connectionString, tableName, row)));
 }
Ejemplo n.º 14
0
 public JsonResult GetData(string connectionString, string tableName)
 {
     return(new JsonResult {
         Data = JsonConvert.SerializeObject(SqlServerQuery.GetData(connectionString, tableName))
     });
 }
Ejemplo n.º 15
0
        public void HandlePendientInspection()
        {
            List <Pendiente> pendList = Pendiente.Download(aoiConfig.machineNameKey);

            aoiLog.debug("Verificando inspecciones pendientes. Total: " + pendList.Count);

            if (pendList.Count > 0)
            {
                int count = 0;
                aoiWorker.SetProgressTotal(pendList.Count);

                foreach (Pendiente pend in pendList)
                {
                    // Busco ultimo estado del barcode
                    string    query     = SqlServerQuery.ListPanelBarcodeInfo(pend);
                    DataTable dt        = sqlserver.Query(query);
                    int       totalRows = dt.Rows.Count;

                    if (totalRows > 0)
                    {
                        count++;
                        DataRow lastRow     = dt.Rows[0];
                        Machine inspMachine = Machine.list.Single(obj => obj.tipo == aoiConfig.machineNameKey && obj.mysql_id == pend.idMaquina);

                        if (Config.isByPassMode(inspMachine))
                        {
                            // SKIP MACHINE
                            inspMachine.LogBroadcast("warning",
                                                     string.Format("{0} {1} | En ByPass, no se analiza modo pendiente de {2}",
                                                                   inspMachine.maquina,
                                                                   inspMachine.smd,
                                                                   pend.barcode)
                                                     );
                        }
                        else
                        {
                            ZenithPanel panel = new ZenithPanel(sqlserver, lastRow, inspMachine);

                            if (panel.pendiente)
                            {
                                inspMachine.LogBroadcast("info",
                                                         string.Format("+ Sigue pendiente Programa: [{0}] | PanelBarcode: {1} | Bloques: {2} | Pendiente: {3}", panel.programa, panel.barcode, panel.totalBloques, panel.pendiente)
                                                         );
                            }
                            else
                            {
                                inspMachine.LogBroadcast("info",
                                                         string.Format("+ Inspeccion detectada! Programa: [{0}] | PanelBarcode: {1} | Bloques: {2} | Pendiente: {3}", panel.programa, panel.barcode, panel.totalBloques, panel.pendiente)
                                                         );
                                panel.pendienteDelete = true;

                                // TENGO QUE DESCOMENTAR ESTO PARA GUARDAR EN TRAZA
                                panel.TrazaSave(aoiConfig.xmlExportPath);

                                // ELIMINO LA INSPECCION PENDIENTE
                                Pendiente.Delete(panel);
                            }
                        }
                    }
                    else
                    {
                        aoiLog.debug("No se detectaron actualizaciones de estado");
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public void Simple_Select_With_WhereClause_With_Two_Conditions_Should_Work_As_Expected()
        {
            var exp = "select * from HumanResources.Employee where VacationHours >= 60 AND SickLeaveHours < 100";

            Query q = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .Where("VacationHours >= 60")
                .Where("SickLeaveHours < 100");

            Assert.AreEqual(exp, q.ToString(), true);
        }
Ejemplo n.º 17
0
 public List <string> GetDatabases(string connectionString)
 {
     return(SqlServerQuery.Connect(connectionString));
 }