예제 #1
0
        public ActionResult SelectAFile(int index)
        {
            TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            //set current stepinfo based on index
            if (TaskManager != null)
            {
                TaskManager.SetCurrent(index);
            }

            //Get Bus infomations
            SelectFileViewModel model = new SelectFileViewModel();

            if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.FILENAME))
            {
                model.SelectedFileName = TaskManager.Bus[ImportMetadataStructureTaskManager.FILENAME].ToString();
            }

            //get datastuctureType
            model.SupportedFileExtentions = ImportMetadataStructureWizardHelper.GetExtentionList();

            //Get StepInfo
            model.StepInfo = TaskManager.Current();

            model.serverFileList = GetServerFileList();

            return(PartialView(model));
        }
예제 #2
0
        /// <summary>
        /// returns true if Extention in the Bus will supported
        /// </summary>
        /// <param name="taskManager"></param>
        /// <returns></returns>
        private bool IsSupportedExtention(ImportMetadataStructureTaskManager taskManager)
        {
            if (taskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.EXTENTION))
            {
                string ext = taskManager.Bus[ImportMetadataStructureTaskManager.EXTENTION].ToString();
                if (ImportMetadataStructureWizardHelper.GetExtentionList().Contains(ext.ToLower()))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public ActionResult SelectAFile(object[] data)
        {
            SelectFileViewModel model = new SelectFileViewModel();

            TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            if (data != null)
            {
                TaskManager.AddToBus(data);
            }

            model.StepInfo = TaskManager.Current();

            TaskManager.Current().SetValid(false);

            if (TaskManager != null)
            {
                // is path of FileStream exist
                if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.FILEPATH))
                {
                    if (IsSupportedExtention(TaskManager))
                    {
                        try
                        {
                            //check if file exist and add to taskmanager
                            string filePath = TaskManager.Bus[ImportMetadataStructureTaskManager.FILEPATH].ToString();
                            if (FileHelper.FileExist(filePath))
                            {
                                TaskManager.Current().SetValid(true);
                                TaskManager.Current().SetStatus(StepStatus.success);
                            }
                            else
                            {
                                model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                            }
                        }
                        catch
                        {
                            model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                        }


                        try
                        {
                            LoadXSDSchema(GetUsernameOrDefault());
                        }
                        catch (Exception ex)
                        {
                            ModelState.AddModelError("", ex.Message);
                            model.ErrorList.Add(new Error(ErrorType.Other, "Can not find any dependent files to the selected schema. Please upload missing files to server and try it again."));
                            TaskManager.Current().SetValid(false);
                        }



                        if (TaskManager.Current().IsValid())
                        {
                            TaskManager.AddExecutedStep(TaskManager.Current());
                            TaskManager.GoToNext();
                            Session["TaskManager"] = TaskManager;
                            ActionInfo actionInfo = TaskManager.Current().GetActionInfo;
                            return(RedirectToAction(actionInfo.ActionName, actionInfo.ControllerName, new RouteValueDictionary {
                                { "area", actionInfo.AreaName }, { "index", TaskManager.GetCurrentStepInfoIndex() }
                            }));
                        }
                    }
                    else
                    {
                        model.ErrorList.Add(new Error(ErrorType.Other, "File is not supported."));
                    }
                }
                else
                {
                    model.ErrorList.Add(new Error(ErrorType.Other, "No FileStream selected or submitted."));
                }
            }

            model.serverFileList          = GetServerFileList();
            model.SupportedFileExtentions = ImportMetadataStructureWizardHelper.GetExtentionList();

            return(PartialView(model));
        }