Exemplo n.º 1
0
        /// <summary>
        /// 匯入 ME & 明細檔 & 設備明細檔
        /// </summary>
        /// <returns></returns>
        public string ImportExcel(HttpPostedFileBase uploadName, string FlowChart_Version_Comment, int FlowChart_Master_UID)
        {
            string                   errorInfo          = string.Empty;
            bool                     isEdit             = false;
            List <RP_VM>             rP_VM              = new List <RP_VM>();
            List <RP_ME_D_Equipment> equipmentList      = new List <RP_ME_D_Equipment>();
            List <RP_ME_D_Equipment> autoEquipmentList  = new List <RP_ME_D_Equipment>();
            List <RP_ME_D_Equipment> auxiliaryEquipList = new List <RP_ME_D_Equipment>();

            if (FlowChart_Master_UID > 0)
            {
                isEdit    = true;
                errorInfo = new ProductiongPlanningImport().RP_ImportCheck(uploadName, FlowChart_Master_UID, FlowChart_Version_Comment, isEdit, rP_VM, equipmentList, autoEquipmentList, auxiliaryEquipList);
            }
            else
            {
                errorInfo = new ProductiongPlanningImport().RP_ImportCheck(uploadName, 0, FlowChart_Version_Comment, isEdit, rP_VM, equipmentList, autoEquipmentList, auxiliaryEquipList);
            }
            if (string.IsNullOrEmpty(errorInfo))
            {
                RP_All_VM all_VM = new RP_All_VM();
                all_VM.RP_VM = rP_VM;
                all_VM.ProcessingEquipList = equipmentList;
                all_VM.AutoEquipList       = autoEquipmentList;
                all_VM.AuxiliaryEquipList  = auxiliaryEquipList;
                all_VM.IsEdit    = isEdit;
                all_VM.AccountID = this.CurrentUser.AccountUId;
                string api = "ProductionResourcePlan/ProductionPlanningAPI";
                HttpResponseMessage responMessage = APIHelper.APIPostAsync(all_VM, api);
            }
            return(errorInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 匯入ME資料
        /// </summary>
        /// <param name="all_vm">資料集合</param>
        public void ImportFlowchartME(RP_All_VM all_vm)
        {
            using (var trans = DataContext.Database.BeginTransaction())
            {
                decimal _RP_Flowchart_Master_UID = 0;
                foreach (var _RP in all_vm.RP_VM)
                {
                    var masterUidSql = "SELECT  SCOPE_IDENTITY();";

                    // 如果為編輯, 版號+1
                    if (all_vm.IsEdit)
                    {
                        var LatestMain = DataContext.RP_Flowchart_Master.Where(r => r.RP_Flowchart_Master_UID == _RP.RP_M.RP_Flowchart_Master_UID).Single();
                        _RP.RP_M.FlowChart_Version = LatestMain.FlowChart_Version + 1;
                    }
                    // 新增主檔資料(RP_Flowchart_Master)
                    string insertMasterSql = InsertMasterSql(_RP.RP_M);
                    DataContext.Database.ExecuteSqlCommand(insertMasterSql);
                    _RP_Flowchart_Master_UID = DataContext.Database.SqlQuery <decimal>(masterUidSql).First();

                    if (_RP_Flowchart_Master_UID > 0)
                    {
                        //新增 明細檔 & 設備明細檔 (RP_Flowchart_Detail_ME, RP_Flowchart_Detail_ME_Equipment)
                        foreach (var _RP_ME_D in _RP.RP_ME_D)
                        {
                            // 新增明細檔
                            string insertDetailMeSql = InsertDetailMeSql(_RP_ME_D, _RP_Flowchart_Master_UID);
                            DataContext.Database.ExecuteSqlCommand(insertDetailMeSql);
                            // 主鍵
                            var detailMeUID = DataContext.Database.SqlQuery <decimal>(masterUidSql).First();

                            // 主加工設備
                            var processingEquipList = all_vm.ProcessingEquipList.Where(m => m.Process_Seq == _RP_ME_D.Process_Seq).ToList();
                            foreach (var processingEquipItem in processingEquipList)
                            {
                                string insertProcessingEquipSql = InsertEquipSql(processingEquipItem, detailMeUID);
                                DataContext.Database.ExecuteSqlCommand(insertProcessingEquipSql);
                            }
                            // 自動化設備
                            var autoEquipList = all_vm.AutoEquipList.Where(m => m.Process_Seq == _RP_ME_D.Process_Seq).ToList();
                            foreach (var autoEquipItem in autoEquipList)
                            {
                                string insertAutoEquipSql = InsertEquipSql(autoEquipItem, detailMeUID);
                                DataContext.Database.ExecuteSqlCommand(insertAutoEquipSql);
                            }
                            // 輔助設備
                            var auxiliaryEquipList = all_vm.AuxiliaryEquipList.Where(m => m.Process_Seq == _RP_ME_D.Process_Seq).ToList();
                            foreach (var auxiliaryEquipItem in auxiliaryEquipList)
                            {
                                string insertAuxiliaryEquipSql = InsertEquipSql(auxiliaryEquipItem, detailMeUID);
                                DataContext.Database.ExecuteSqlCommand(insertAuxiliaryEquipSql);
                            }
                        }
                    }
                }
                trans.Commit();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 匯入ME資料
 /// </summary>
 /// <param name="all_vm">資料集合</param>
 public void ImportFlowchartME(RP_All_VM all_vm)
 {
     rP_Flowchart_MasterRepository.ImportFlowchartME(all_vm);
 }
Exemplo n.º 4
0
 public void ProductionPlanningAPI(RP_All_VM all_vm)
 {
     PRP_Service.ImportFlowchartME(all_vm);
 }