Esempio n. 1
0
        public void GetStorageByStorageCode(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            OleExec sfcdb = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                string StorageCode                    = Data["StorageCode"].ToString();
                List <C_STORAGE_CODE> Storage         = new List <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.GetByStorageCode(StorageCode, 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 添加StorageItem
        /// </summary>
        /// <param name="requestValue"></param>
        /// <param name="Data"></param>
        /// <param name="StationReturn"></param>
        public void AddNewStorageItem(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn)
        {
            OleExec sfcdb = null;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                string ItemName    = Data["ItemName"].ToString().Trim();
                string ItemSon     = Data["ItemSon"].ToString().Trim();
                string StorageCode = Data["StorageCode"].ToString().Trim();
                if (ItemName.Length <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("ItemName");
                    this.DBPools["SFCDB"].Return(sfcdb);
                    return;
                }
                if (ItemSon.Length <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("ItemSon");
                    this.DBPools["SFCDB"].Return(sfcdb);
                    return;
                }
                if (StorageCode.Length <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("StorageCode");
                    this.DBPools["SFCDB"].Return(sfcdb);
                    return;
                }
                T_C_STORAGE_ITEM      TC_STORAGE_ITEM     = new T_C_STORAGE_ITEM(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                T_C_STORAGE_CODE      TC_STORAGE_CODE     = new T_C_STORAGE_CODE(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                List <C_STORAGE_CODE> GetSTORAGE_CODEList = new List <C_STORAGE_CODE>();
                C_STORAGE_ITEM        GetSTORAGE_ITEM     = new C_STORAGE_ITEM();
                GetSTORAGE_CODEList = TC_STORAGE_CODE.GetByStorageCode(StorageCode, sfcdb);
                if (GetSTORAGE_CODEList == null || GetSTORAGE_CODEList.Count() <= 0)
                {
                    StationReturn.Data        = "";
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000007";
                    StationReturn.MessagePara.Add("StorageCode:" + StorageCode);
                }
                else
                {
                    GetSTORAGE_ITEM = TC_STORAGE_ITEM.GetByItemNameAndItemSonAndStorageCode(ItemName, ItemSon, StorageCode, sfcdb);
                    if (GetSTORAGE_ITEM != null)
                    {
                        StationReturn.Data        = "";
                        StationReturn.Status      = StationReturnStatusValue.Fail;
                        StationReturn.MessageCode = "MES00000008";
                        StationReturn.MessagePara.Add("ItemName:" + ItemName + ",ItemSon:" + ItemSon + ",StorageCode:" + StorageCode);
                    }
                    else
                    {
                        C_STORAGE_ITEM NewStorageItem = new C_STORAGE_ITEM();
                        NewStorageItem.ID           = TC_STORAGE_ITEM.GetNewID(BU, sfcdb);
                        NewStorageItem.ITEM_NAME    = ItemName;
                        NewStorageItem.ITEM_SON     = ItemSon;
                        NewStorageItem.STORAGE_CODE = StorageCode;
                        NewStorageItem.EDIT_EMP     = LoginUser.EMP_NO;
                        NewStorageItem.EDIT_TIME    = GetDBDateTime();
                        int result = TC_STORAGE_ITEM.Add(NewStorageItem, sfcdb);
                        if (result > 0)
                        {
                            StationReturn.Data        = NewStorageItem;
                            StationReturn.Status      = StationReturnStatusValue.Pass;
                            StationReturn.MessageCode = "MES00000001";
                        }
                        else
                        {
                            StationReturn.Data        = "";
                            StationReturn.Status      = StationReturnStatusValue.Fail;
                            StationReturn.MessageCode = "MES00000021";
                            StationReturn.MessagePara.Add("C_STORAGE_ITEM");
                        }
                    }
                }
                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);
            }
        }