コード例 #1
0
        /// <summary>
        /// Get Container Stock By Container Number
        /// </summary>
        /// <param name="cont"></param>
        /// <param name="isSetMessage"></param>
        /// <returns></returns>
        public List <ContInOut> GetContainerStockByContainerNumber(string cont, bool isSetMessage)
        {
            List <ContInOut> listContInOut = new List <ContInOut>();

            try
            {
                using (NpgsqlConnection npgsqlConnection = AppConfig.GetConnection())
                {
                    if (npgsqlConnection.State == ConnectionState.Closed)
                    {
                        npgsqlConnection.Open();
                    }
                    string query = string.Format("SELECT {0} FROM {1} " +
                                                 "  WHERE cont LIKE @Container " +
                                                 "      AND dtmout IS NULL " +
                                                 "  ORDER BY cont,dtmin ",
                                                 string.Format(DEFAULT_COLUMN, string.Empty),
                                                 DEFAULT_TABLE);
                    using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(query, npgsqlConnection))
                    {
                        npgsqlCommand.Parameters.AddWithValue("@Container", cont + '%');
                        using (NpgsqlDataReader npgsqlDataReader = npgsqlCommand.ExecuteReader())
                        {
                            while (npgsqlDataReader.Read())
                            {
                                ContInOut contInOut = new ContInOut();
                                MappingDataReaderToContCard(npgsqlDataReader, contInOut);
                                if (isSetMessage)
                                {
                                    BlackListDAL blackListDAL = new BlackListDAL();
                                    contInOut.Message = blackListDAL.GetMessageByContainerNumber(contInOut.Cont);
                                }
                                listContInOut.Add(contInOut);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listContInOut);
        }
コード例 #2
0
            public DefinedContainerItem(string container)
            {
                ContInOutDAL contInOutDAL = new ContInOutDAL();
                BlackListDAL blackListDAL = new BlackListDAL();

                container = container.Trim();
                container = container.Replace(GlobalConstant.STRING_SPACE, string.Empty);
                if (container.Length != 11)
                {
                    container = "ERRORLENGTH";
                }
                string prefix = container.Substring(0, 4);
                string num1   = container.Substring(4, 3);
                string num2   = container.Substring(7, 3);
                string num3   = container.Substring(10, 1);

                _container = prefix + " " + num1 + " " + num2 + " " + num3;

                try
                {
                    ContInOut contInOut = new ContInOut();
                    contInOut = contInOutDAL.FillContInOutByContainerNumber(_container);
                    if (contInOut.ContInOutId <= 0)
                    {
                        return;
                    }
                    _size         = contInOut.Size;
                    _type         = contInOut.Type;
                    _dtmIn        = contInOut.DtmIn;
                    _dtmOut       = contInOut.DtmOut;
                    _customerCode = contInOut.CustomerCode;
                    _condition    = contInOut.Condition;
                    if (_dtmOut.Length == 0)
                    {
                        DateTime start = DateTime.Parse(_dtmIn);
                        DateTime end   = GlobalWebServiceDAL.GetServerDtm();
                        TimeSpan ts    = end.Subtract(start);
                        int      days  = 1 + ts.Days;
                        _duration = days.ToString();
                    }
                    else
                    {
                        DateTime start = DateTime.Parse(_dtmIn);
                        DateTime end   = DateTime.Parse(_dtmOut);
                        TimeSpan ts    = end.Subtract(start);
                        int      days  = 1 + ts.Days;
                        _duration = days.ToString();
                    }

                    List <BlackList> listBlackList = blackListDAL.GetBlackListByContainerNumber(contInOut.Cont);
                    string           message       = string.Empty;
                    DateTime         n             = GlobalWebServiceDAL.GetServerDtm();
                    foreach (BlackList blackList in listBlackList)
                    {
                        if (blackList.Disabled)
                        {
                            continue;
                        }
                        if (blackList.DisabledUntil >= n)
                        {
                            continue;
                        }
                        if (message.Length > 0)
                        {
                            message += " ";
                        }
                        message += blackList.Message;
                    }
                    this._specialMessage = message;
                }
                catch (Exception)
                {
                    //ignore error
                }
            }