예제 #1
0
        public bool GetPreviousSequenceMachinesByProcessId(int processId, out List <ProductSequenceItem> machines)
        {
            machines = new List <ProductSequenceItem>(0);
            var check = CheckIfInitialized();

            if (!check)
            {
                return(false);
            }


            var result = new SqlParameter("@result", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output
            };
            var parameters = new[]
            {
                new SqlParameter("@processId", SqlDbType.NVarChar, 30)
                {
                    SqlValue = processId
                },
                result
            };

            try
            {
                var dataset = SqlHelper.ExecuteDataset(_dbConnection, CommandType.StoredProcedure, "GetPreviousSequenceMachinesByProcessId", parameters);
                if (dataset.Tables.Count <= 0)
                {
                    return(false);
                }
                var tables   = dataset.Tables[0];
                var rowCount = tables.Rows.Count;
                if (rowCount <= 0)
                {
                    return(false);
                }
                machines = new List <ProductSequenceItem>(rowCount);

                foreach (DataRow row in tables.Rows)
                {
                    var machine = new ProductSequenceItem
                    {
                        Id                = row.Field <int>("Id"),
                        Level             = row.Field <int>("Level"),
                        MachineFamilyId   = row.Field <int>("MachineFamilyId"),
                        ProductSequenceId = row.Field <int>("ProductSequenceId"),
                        MachineFamilyname = row.Field <string>("MachineFamilyname")
                    };
                    machines.Add(machine);
                }
                return(true);
            }
            catch (Exception exception)
            {
                MachineHookException?.Invoke(@"Get Sequence Machine : " + exception.Message);
                return(false);
            }
        }
예제 #2
0
 public bool UnloadReference()
 {
     _thisMachinePreviousSequenceMachineFamily = new ProductSequenceItem();
     _thisMachineReference = new Product();
     return(true);
 }
예제 #3
0
        public bool GetMachineSequenceItem()
        {
            _thisMachineSequenceItem = new ProductSequenceItem();
            var check = CheckIfInitialized();

            if (!check)
            {
                return(false);
            }
            var result = new SqlParameter("@result", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output,
            };

            var parameters = new[]
            {
                new SqlParameter("@SequenceId", SqlDbType.Int)
                {
                    SqlValue = _thisMachineReference.SequenceId
                },
                new SqlParameter("@MachineFamilyId", SqlDbType.Int)
                {
                    SqlValue = _thisMachine.MachineFamilyId
                },
                result
            };

            try
            {
                var prev = SqlHelper.ExecuteDataset(_dbConnection, CommandType.StoredProcedure,
                                                    "usp_GetMachineSequenceItem",
                                                    parameters);
                var code = Convert.ToInt32(result.SqlValue.ToString());
                if (code < 1)
                {
                    return(false);
                }

                if (prev?.Tables.Count > 0)
                {
                    if (prev.Tables[0].Rows.Count > 0)
                    {
                        var row = prev.Tables[0].Rows[0];
                        _thisMachineSequenceItem = new ProductSequenceItem()
                        {
                            Id                = row.Field <int>("Id"),
                            Level             = row.Field <int>("Level"),
                            MachineFamilyId   = row.Field <int>("MachineFamilyId"),
                            ProductSequenceId = row.Field <int>("ProductSequenceId"),
                            MachineFamilyname = row.Field <string>("MachineFamilyname")
                        };
                        return(true);
                    }
                }
            }
            catch (Exception exception)
            {
                MachineHookException?.Invoke(exception.Message);
            }
            return(false);
        }