public void DeleteSkuRouteMappingByObject(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            T_R_SKU_ROUTE table   = null;
            OleExec       sfcdb   = null;
            string        result  = string.Empty;
            R_SKU_ROUTE   mapping = null;

            try
            {
                if (Data["MappingObject"] != null && !string.IsNullOrEmpty(Data["MappingObject"].ToString()))
                {
                    sfcdb   = this.DBPools["SFCDB"].Borrow();
                    table   = new T_R_SKU_ROUTE(sfcdb, DBTYPE);
                    mapping = (R_SKU_ROUTE)JsonConvert.Deserialize(Data["MappingObject"].ToString(), typeof(R_SKU_ROUTE));
                    result  = table.DeleteMapping(mapping, sfcdb);
                    if (Int32.Parse(result) > 0)
                    {
                        StationReturn.Status      = StationReturnStatusValue.Pass;
                        StationReturn.MessageCode = "MES00000035";
                        StationReturn.MessagePara.Add(result);
                        StationReturn.Data = result;
                    }
                    else
                    {
                        StationReturn.Status      = StationReturnStatusValue.Pass;
                        StationReturn.MessageCode = "MES00000036";
                        StationReturn.Data        = result;
                    }
                    if (sfcdb != null)
                    {
                        this.DBPools["SFCDB"].Return(sfcdb);
                    }
                }
            }
            catch (Exception e)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(e.Message);
                StationReturn.Data = e.Message;


                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }

                //throw e;
            }
        }
Exemple #2
0
        public void UpdateSkuRouteMapping(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            T_R_SKU_ROUTE table         = null;
            R_SKU_ROUTE   mapping       = null;
            OleExec       sfcdb         = null;
            string        result        = string.Empty;
            string        MappingObject = string.Empty;

            //MappingObject = @"{
            //    'ID': 'HWD000000000000000000000000000003',
            //    'DEFAULT_FLAG': 'Y',
            //    'SKU': {
            //        'ID': '111',
            //        'SKUNO': '222',
            //        'VERSION':'333'
            //    },
            //    'ROUTE': {
            //        'ID':'666',
            //        'ROUTE_NAME':'777'
            //    },
            //    'EDIT_TIME': '2017/12/21 17:13:21'

            //}";

            try
            {
                if (Data["MappingObject"] != null && !string.IsNullOrEmpty(Data["MappingObject"].ToString()))
                {
                    sfcdb         = this.DBPools["SFCDB"].Borrow();
                    table         = new T_R_SKU_ROUTE(sfcdb, DBTYPE);
                    MappingObject = Data["MappingObject"].ToString();
                    mapping       = (R_SKU_ROUTE)JsonConvert.Deserialize(MappingObject, typeof(R_SKU_ROUTE));
                    result        = table.UpdateMapping(mapping, sfcdb);
                    if (Int32.Parse(result) > 0)
                    {
                        StationReturn.Status      = StationReturnStatusValue.Pass;
                        StationReturn.MessageCode = "MES00000035";
                        StationReturn.MessagePara.Add(result);
                        StationReturn.Data = result;
                    }
                    else
                    {
                        StationReturn.Status      = StationReturnStatusValue.Pass;
                        StationReturn.MessageCode = "MES00000036";
                        StationReturn.Data        = result;
                    }
                    if (sfcdb != null)
                    {
                        this.DBPools["SFCDB"].Return(sfcdb);
                    }
                }
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(result))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000005";
                    StationReturn.Data        = e.Message + ":" + result;
                }
                else
                {
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000037";
                    StationReturn.MessagePara.Add(e.Message);
                    StationReturn.Data = e.Message;
                }

                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }

                throw e;
            }
        }
        public void AddSKuRouteMapping(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            T_R_SKU_ROUTE table         = null;
            R_SKU_ROUTE   mapping       = null;
            OleExec       sfcdb         = null;
            string        result        = string.Empty;
            string        MappingObject = string.Empty;

            //MappingObject = @"{
            //    'DEFAULT_FLAG': 'Y',
            //    'SKU': {
            //        'ID': '111',
            //        'SKUNO': '222',
            //        'VERSION':'333'
            //    },
            //    'ROUTE': {
            //        'ID':'HWD00000000000000000000000000001X',
            //        'ROUTE_NAME':'555'
            //    }
            //}";

            try
            {
                if (Data["MappingObject"] != null && !string.IsNullOrEmpty(Data["MappingObject"].ToString()))
                {
                    sfcdb         = this.DBPools["SFCDB"].Borrow();
                    table         = new T_R_SKU_ROUTE(sfcdb, DBTYPE);
                    MappingObject = Data["MappingObject"].ToString();
                    mapping       = (R_SKU_ROUTE)JsonConvert.Deserialize(MappingObject, typeof(R_SKU_ROUTE));
                    if (mapping.ROUTE_ID != null)
                    {
                        T_C_ROUTE ROUTE   = new T_C_ROUTE(sfcdb, DBTYPE);
                        C_ROUTE   C_ROUTE = ROUTE.GetByRouteName(mapping.ROUTE_ID, sfcdb);
                        mapping.ROUTE_ID  = C_ROUTE.ID;
                        mapping.EDIT_EMP  = LoginUser.EMP_NO;
                        mapping.EDIT_TIME = GetDBDateTime();
                        result            = table.AddMapping(mapping, BU, sfcdb);
                        if (Int32.Parse(result) > 0)
                        {
                            StationReturn.Status      = StationReturnStatusValue.Pass;
                            StationReturn.MessageCode = "MES00000035";
                            StationReturn.MessagePara.Add(result);
                            StationReturn.Data = result;
                            //throw
                        }
                        else
                        {
                            StationReturn.Status      = StationReturnStatusValue.Pass;
                            StationReturn.MessageCode = "MES00000036";
                            StationReturn.Data        = result;
                        }
                        if (sfcdb != null)
                        {
                            this.DBPools["SFCDB"].Return(sfcdb);
                        }
                    }
                    else
                    {
                        StationReturn.Status      = StationReturnStatusValue.Fail;
                        StationReturn.MessageCode = "MES00000204";
                        StationReturn.Data        = result;
                    }
                }
            }
            catch (Exception e)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(e.Message);
                StationReturn.Data = e.Message;


                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                //throw e;
            }
        }