コード例 #1
0
 public bool CheckIfInitialized()
 {
     if (_thisMachine.Id <= 0)
     {
         MachineHookErrorOccured?.Invoke("Traceability Not Initialized");
         return(false);
     }
     return(true);
 }
コード例 #2
0
        public bool StartProductTraceability(string productFullName, string remarks, out int status)
        {
            status = -1;
            var check = CheckIfInitialized();

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

            ReferenceParsed parsed;
            var             checkName = ParseProductFullName(productFullName, out parsed);

            if (!checkName)
            {
                return(false);
            }
            if (_thisMachinePreviousSequenceMachineFamily.Id > 0)
            {
                MachineHookErrorOccured?.Invoke("Machine is not an Id Generator");
                return(false);
            }

            var result = new SqlParameter("@result", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output,
            };
            var parameters = new[]
            {
                new SqlParameter("@productFullName", SqlDbType.NVarChar, 50)
                {
                    SqlValue = productFullName
                },
                new SqlParameter("@reference", SqlDbType.NVarChar, 30)
                {
                    SqlValue = parsed.ReferencePart
                },
                new SqlParameter("@machineId", SqlDbType.Int)
                {
                    SqlValue = _thisMachine.Id
                },
                new SqlParameter("@workOrderId", SqlDbType.Int)
                {
                    SqlValue = _thisMachineWorkorder.Id
                },
                new SqlParameter("@Remarks", SqlDbType.NVarChar, 50)
                {
                    SqlValue = remarks
                },
                new SqlParameter("@SequenceItemId", SqlDbType.Int)
                {
                    SqlValue = _thisMachineSequenceItem.Id
                },
                new SqlParameter("@ProcessResult", SqlDbType.Int)
                {
                    SqlValue = ProcessResult.Generated
                },
                result
            };

            try
            {
                var i = SqlHelper.ExecuteNonQuery(_dbConnection, CommandType.StoredProcedure,
                                                  "usp_StartProductTraceability",
                                                  parameters);
            }
            catch (Exception exception)
            {
                MachineHookException?.Invoke(exception.Message);
                return(false);
            }
            status = result.Value != null?Convert.ToInt32(result.SqlValue.ToString()) : -1;

            if (status > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public bool UpdateProductStatusNOk(string productFullName, string remarks, out int status)
        {
            status = -1;
            var check = CheckIfInitialized();

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

            ReferenceParsed parsed;

            ParseProductFullName(productFullName, out parsed);
            if (parsed.ReferencePart != _thisMachineReference.Reference)
            {
                MachineHookErrorOccured?.Invoke("Reference Not Matched");
                return(false);
            }
            var result = new SqlParameter("@result", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output
            };
            var parameters = new[]
            {
                new SqlParameter("@ProductFullName", SqlDbType.NVarChar, 50)
                {
                    SqlValue = productFullName
                },
                new SqlParameter("@Reference", SqlDbType.NVarChar, 20)
                {
                    SqlValue = parsed.ReferencePart
                },
                new SqlParameter("@Remarks", SqlDbType.NVarChar, 20)
                {
                    SqlValue = remarks
                },
                new SqlParameter("@machineId", SqlDbType.Int)
                {
                    SqlValue = _thisMachine.Id
                },
                new SqlParameter("@SequenceId", SqlDbType.Int)
                {
                    SqlValue = _thisMachineReference.SequenceId
                },
                new SqlParameter("@ProductId", SqlDbType.Int)
                {
                    SqlValue = _thisMachineReference.Id
                },
                new SqlParameter("@MachineFamilyId", SqlDbType.Int)
                {
                    SqlValue = _thisMachine.MachineFamilyId
                },
                result
            };

            try
            {
                var i = SqlHelper.ExecuteNonQuery(_dbConnection, CommandType.StoredProcedure, "usp_UpdateProductStatusNOk", parameters);
            }
            catch (Exception exception)
            {
                MachineHookException?.Invoke(exception.Message);
                return(false);
            }
            status = Convert.ToInt32(result.SqlValue.ToString());

            if (status > 0)
            {
                return(true);
            }

            return(false);
        }