예제 #1
0
        public void GetStorageById(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            OleExec sfcdb = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                string           strId           = Data["Id"].ToString();
                C_STORAGE_CODE   Storage         = new C_STORAGE_CODE();
                T_C_STORAGE_CODE TC_STORAGE_CODE = new T_C_STORAGE_CODE(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                Storage                   = TC_STORAGE_CODE.GetById(strId, sfcdb);
                StationReturn.Data        = Storage;
                StationReturn.Status      = StationReturnStatusValue.Pass;
                StationReturn.MessageCode = "MES00000001";
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception ex)
            {
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                StationReturn.Data        = "";
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ex.Message);
            }
        }
예제 #2
0
        public void DeleteByIdArray(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            OleExec sfcdb = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                T_C_STORAGE_CODE TC_STORAGE_CODE   = new T_C_STORAGE_CODE(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                C_STORAGE_CODE   GetC_STORAGE_CODE = new C_STORAGE_CODE();
                string           strIdArray        = Data["IdArray"].ToString().Trim();
                strIdArray = strIdArray.Replace("[", "").Replace("]", "");
                strIdArray = strIdArray.Replace("\"", "");
                string[] IdArray = strIdArray.Replace("\r\n", "").Split(',');
                bool     isError = false;
                if (IdArray == null || IdArray.Length <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("IdArray");
                }
                else
                {
                    isError = false;
                    sfcdb.BeginTrain();
                    for (int i = 0; i < IdArray.Length; i++)
                    {
                        GetC_STORAGE_CODE = TC_STORAGE_CODE.GetById(IdArray[i].Trim(), sfcdb);
                        if (GetC_STORAGE_CODE != null)
                        {
                            int result = TC_STORAGE_CODE.DeleteById(IdArray[i].Trim(), sfcdb);
                            if (result <= 0)
                            {
                                StationReturn.Data        = IdArray[i].Trim();
                                StationReturn.Status      = StationReturnStatusValue.Fail;
                                StationReturn.MessageCode = "MES00000023";
                                StationReturn.MessagePara.Add("C_STORAGE_CODE");
                                isError = true;
                                break;
                            }
                        }
                        else
                        {
                            StationReturn.Data        = "";
                            StationReturn.Status      = StationReturnStatusValue.Fail;
                            StationReturn.MessageCode = "MES00000007";
                            StationReturn.MessagePara.Add("Id:" + IdArray[i].Trim());
                            isError = true;
                            break;
                        }
                    }
                    if (isError)
                    {
                        sfcdb.RollbackTrain();
                    }
                    else
                    {
                        sfcdb.CommitTrain();
                        StationReturn.Data        = "";
                        StationReturn.Status      = StationReturnStatusValue.Pass;
                        StationReturn.MessageCode = "MES00000001";
                    }
                }
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception ex)
            {
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                StationReturn.Data        = "";
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ex.Message);
            }
        }
예제 #3
0
        public void UpdateStorageById(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            OleExec sfcdb = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                T_C_STORAGE_CODE TC_STORAGE_CODE   = new T_C_STORAGE_CODE(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                C_STORAGE_CODE   GetC_STORAGE_CODE = new C_STORAGE_CODE();
                string           strId             = Data["Id"].ToString();
                string           strPlant          = Data["Plant"].ToString().Trim();
                string           strStorageCode    = Data["StorageCode"].ToString().Trim();
                string           strDescription    = Data["Descriptions"].ToString().Trim();
                if (strPlant.Length <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("Plant");
                    this.DBPools["SFCDB"].Return(sfcdb);
                    return;
                }
                if (strStorageCode.Length <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("StorageCode");
                    this.DBPools["SFCDB"].Return(sfcdb);
                    return;
                }
                GetC_STORAGE_CODE = TC_STORAGE_CODE.GetById(strId, sfcdb);
                if (GetC_STORAGE_CODE != null)
                {
                    GetC_STORAGE_CODE = TC_STORAGE_CODE.GetByPlantAndStorageCode(strPlant, strStorageCode, sfcdb);
                    if (GetC_STORAGE_CODE != null && GetC_STORAGE_CODE.ID != strId)
                    {
                        StationReturn.Data        = "";
                        StationReturn.Status      = StationReturnStatusValue.Fail;
                        StationReturn.MessageCode = "MES00000007";
                        StationReturn.MessagePara.Add("Plant:" + strPlant + ",StorageCode:" + strStorageCode);
                    }
                    else
                    {
                        C_STORAGE_CODE NewStorageCode = new C_STORAGE_CODE();
                        NewStorageCode.ID           = strId;
                        NewStorageCode.PLANT        = strPlant;
                        NewStorageCode.STORAGE_CODE = strStorageCode;
                        NewStorageCode.DESCRIPTION  = strDescription;
                        NewStorageCode.EDIT_EMP     = LoginUser.EMP_NO;
                        NewStorageCode.EDIT_TIME    = GetDBDateTime();
                        int result = TC_STORAGE_CODE.UpdateById(NewStorageCode, sfcdb);
                        if (result > 0)
                        {
                            StationReturn.Data        = NewStorageCode;
                            StationReturn.Status      = StationReturnStatusValue.Pass;
                            StationReturn.MessageCode = "MES00000001";
                        }
                        else
                        {
                            StationReturn.Data        = "";
                            StationReturn.Status      = StationReturnStatusValue.Fail;
                            StationReturn.MessageCode = "MES00000025";
                            StationReturn.MessagePara.Add("C_STORAGE_CODE");
                        }
                    }
                }
                else
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000007";
                    StationReturn.MessagePara.Add("Id:" + strId);
                }
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception ex)
            {
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                StationReturn.Data        = "";
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ex.Message);
            }
        }