Пример #1
0
        /// <summary>
        /// 加載對應的路由信息
        /// </summary>
        /// <param name="DB"></param>
        public SKU LoadRoute(OleExec DB)
        {
            T_R_SKU_ROUTE      table    = null;
            List <R_SKU_ROUTE> mappings = new List <R_SKU_ROUTE>();

            if (!this.SkuBase.ID.Equals(""))
            {
                if (this._DBType.Equals(DB_TYPE_ENUM.Oracle))
                {
                    table = new T_R_SKU_ROUTE(DB, this._DBType);
                    if (this.SkuBase.ID != null && !string.IsNullOrEmpty(this.SkuBase.ID))
                    {
                        mappings = table.GetMappingBySkuId(this.SkuBase.ID, DB);
                        foreach (R_SKU_ROUTE mapping in mappings)
                        {
                            this.SkuRoutes.Add(new Route(mapping.ROUTE_ID, GetRouteType.ROUTEID, DB, this._DBType));
                        }
                    }
                    else
                    {
                        throw new MESReturnMessage("Please call this function by an instance of SKU class");
                    }
                }
                else
                {
                    string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { _DBType.ToString() });
                    throw new MESReturnMessage(errMsg);
                }
                return(this);
            }
            else
            {
                throw new MESReturnMessage("Please ensure the C_SKU property is not null before using other methods.");
            }
        }
Пример #2
0
        public void GetLockStation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            string        lockType    = Data["LockType"].ToString().Trim();
            string        lockData    = Data["LockData"].ToString().Trim();
            DataTable     routeTable  = new DataTable();
            List <string> stationList = new List <string>();
            OleExec       sfcdb       = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                T_C_ROUTE_DETAIL t_c_route_detail = new T_C_ROUTE_DETAIL(sfcdb, DBTYPE);
                if (lockType == "LockByWo")
                {
                    T_R_WO_BASE t_r_wo_base = new T_R_WO_BASE(sfcdb, DBTYPE);
                    R_WO_BASE   r_wo_base   = t_r_wo_base.GetWo(lockData, sfcdb).GetDataObject();
                    stationList = t_c_route_detail.GetByRouteIdOrderBySEQASC(r_wo_base.ROUTE_ID, sfcdb).Select(route => route.STATION_NAME).ToList();
                }
                else if (lockType == "LockByLot")
                {
                    T_R_LOT_STATUS   t_r_lot_status = new T_R_LOT_STATUS(sfcdb, DBTYPE);
                    Row_R_LOT_STATUS rowLotStatus   = t_r_lot_status.GetByLotNo(lockData, sfcdb);
                    if (rowLotStatus.ID == null)
                    {
                        throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000161", new string[] { }));
                    }
                    R_LOT_STATUS       r_lot_status     = rowLotStatus.GetDataObject();
                    T_C_SKU            t_c_sku          = new T_C_SKU(sfcdb, DBTYPE);
                    C_SKU              c_sku            = t_c_sku.GetSku(r_lot_status.SKUNO, sfcdb, DBTYPE).GetDataObject();
                    T_R_SKU_ROUTE      t_r_sku_route    = new T_R_SKU_ROUTE(sfcdb, DBTYPE);
                    List <R_SKU_ROUTE> r_sku_route_list = t_r_sku_route.GetMappingBySkuId(c_sku.ID, sfcdb);
                    if (r_sku_route_list.Count > 0)
                    {
                        //t_c_route_detail.GetByRouteIdOrderBySEQASC(r_sku_route_list[0].ROUTE_ID, sfcdb);
                        stationList = t_c_route_detail.GetByRouteIdOrderBySEQASC(r_sku_route_list[0].ROUTE_ID, sfcdb).Select(route => route.STATION_NAME).ToList();
                    }
                    else
                    {
                        throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000179", new string[] {  }));
                    }
                }
                else
                {
                    routeTable = t_c_route_detail.GetALLStation(sfcdb);
                    foreach (DataRow row in routeTable.Rows)
                    {
                        stationList.Add(row["station_name"].ToString());
                    }
                    stationList.Sort();
                }

                this.DBPools["SFCDB"].Return(sfcdb);
                StationReturn.Data        = stationList;
                StationReturn.Status      = StationReturnStatusValue.Pass;
                StationReturn.MessageCode = "MES00000001";
            }
            catch (Exception exception)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(exception.Message);
                StationReturn.Data = exception.Message;
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
        }