예제 #1
0
        public SigmaResultType ImportFile()
        {
            SigmaResultType result = new SigmaResultType();
            try
            {
                var queryStr = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters;
                string fileType = queryStr["filetype"];
                string filePath = queryStr["filepath"];

                //string rootPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentUpload"];
                //string targetPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentFolderRoot"];

                string rootPath = ConfigMgr.GetImportFilePath();

                filePath = rootPath + filePath;

                //fileType = "DrawingImage";

                // ImportFile
                switch (fileType)
                {
                    case "Drawing":
                        //importDrawing importDrawing = new ImportDrawing();
                        ImportDrawingMgr importDrawing = new ImportDrawingMgr();
                        result = importDrawing.AddDrawing(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "DrawingImage":
                        //ImportDrawing importDrawingImage = new ImportDrawing();
                        ImportDrawingMgr importDrawingImage = new ImportDrawingMgr();
                        //result = importDrawingImage.AddDrawingImage(filePath, targetPath);
                        result = importDrawingImage.AddDrawingImage(filePath, ConfigMgr.GetTargetPath());
                        break;
                    case "MTO":
                        ImportMgr importMgr = new ImportMgr();
                        result = importMgr.ImportMTOFromExcel(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "CostCode":
                        CostCodeMgr costcodeMgr = new CostCodeMgr();
                        result = costcodeMgr.ImportCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "ProjectCostCode":
                        CostCodeMgr projectcostcodeMgr = new CostCodeMgr();
                        result = projectcostcodeMgr.ImportProjectCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "ClientCostCode":
                        CostCodeMgr clientcostcodeMgr = new CostCodeMgr();
                        result = clientcostcodeMgr.ImportClientCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "HR":
                        PersonnelMgr personnelMgr = new PersonnelMgr();
                        result = personnelMgr.ImportPersonnelFromExcel(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "User":
                        SigmaUserMgr sigmauserMgr = new SigmaUserMgr();
                        result = sigmauserMgr.ImportSigmaUserFromExcel(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "MeterialLibrary":
                        ImportMgr importMeterial = new ImportMgr();
                        result = importMeterial.ImportMeterialLib(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "EquipmentLibrary":
                        ImportMgr importEquipment = new ImportMgr();
                        result = importEquipment.ImportEquipmentLib(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "ConsumableLibrary":
                        ImportMgr importConsumable = new ImportMgr();
                        result = importConsumable.ImportConsumableLib(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    case "DrawingType":
                        ImportMgr importDrawingType = new ImportMgr();
                        result = importDrawingType.ImportDrawingTypeLib(filePath, ConfigMgr.GetExportFilePath());
                        break;
                    default:
                        break;
                }
                return result;

            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }