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

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

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

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


            //get datastuctureType
            model.DataStructureType       = GetDataStructureType();
            model.SupportedFileExtentions = UploadWizardHelper.GetExtentionList(model.DataStructureType, this.Session.GetTenant());

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

            model.serverFileList = GetServerFileList();



            return(PartialView(model));
        }
        public ActionResult SelectAFile(int index)
        {
            TaskManager = (EasyUploadTaskManager)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(EasyUploadTaskManager.FILENAME))
            {
                model.SelectedFileName = TaskManager.Bus[EasyUploadTaskManager.FILENAME].ToString();
            }

            //get datastuctureType
            model.SupportedFileExtentions = supportedExtensions;

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

            model.serverFileList = GetServerFileList();

            return(PartialView(model));
        }
Example #3
0
        private void AllButton_Click(object sender, RoutedEventArgs e)
        {
            SelectFileViewModel vm = DataContext as SelectFileViewModel;

            string[] files = new string[FileList.Items.Count];
            for (int i = 0; i < FileList.Items.Count; i++)
            {
                files[i] = System.IO.Path.Combine(vm.BaseDir, FileList.Items[i] as string);
            }
            vm.SelectedFileNames = files;

            DialogResult = true;
            Close();
        }
Example #4
0
        public void LoadSingleFile()
        {
            // Second check for only file
            if (FileList.Items.Count == 1)
            {
                SelectFileViewModel vm    = DataContext as SelectFileViewModel;
                string[]            files = new string[1];
                files[0]             = System.IO.Path.Combine(vm.BaseDir, FileList.Items[0] as string);
                vm.SelectedFileNames = files;

                DialogResult = true;
                Close();
            }
        }
        // GET: UploadPublication
        public ActionResult Index(long entityId, DataStructureType type = DataStructureType.Unstructured)
        {
            var fileExtentions = Helper.Settings.get("FileExtentions").ToString().Split(',');

            SelectFileViewModel model = new SelectFileViewModel();

            foreach (string extention in fileExtentions)
            {
                model.SupportedFileExtentions.Add(extention);
            }

            model.EntityId = entityId;

            return(View("UploadFile", model));
        }
Example #6
0
        public ActionResult SelectAFile(object[] data)
        {
            var model = new SelectFileViewModel();

            TaskManager = (TaskManager)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(TaskManager.FILEPATH))
                {
                    if (IsSupportedExtention(TaskManager))
                    {
                        try
                        {
                            if (GetDataStructureType().Equals(DataStructureType.Structured))
                            {
                                #region structured datastructure
                                //try save FileStream
                                var filePath = TaskManager.Bus[TaskManager.FILEPATH].ToString();
                                //if extention like a makro excel FileStream
                                if (TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".xlsm"))
                                {
                                    // open FileStream
                                    var reader = new ExcelReader();
                                    Stream = reader.Open(filePath);
                                    //Session["Stream"] = Stream;

                                    //check is it template

                                    if (reader.IsTemplate(Stream))
                                    {
                                        TaskManager.Current().SetValid(true);
                                        TaskManager.AddToBus(TaskManager.IS_TEMPLATE, "true");
                                    }
                                    else
                                    {
                                        model.ErrorList.Add(new Error(ErrorType.Other, "File is not a Template"));
                                        TaskManager.AddToBus(TaskManager.IS_TEMPLATE, "false");
                                    }

                                    if (!ExcelReader.SUPPORTED_APPLICATIONS.Contains(reader.Application))
                                    {
                                        model.ErrorList.Add(new Error(ErrorType.Other, "The document was created in an application " + reader.Application + " that will currently not support"));
                                    }

                                    Stream.Close();
                                }
                                else
                                {
                                    TaskManager.AddToBus(TaskManager.IS_TEMPLATE, "false");
                                    // excel FileStream
                                    if (TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".xls"))
                                    {
                                        // open FileStream
                                        var reader = new ExcelReader();
                                        Stream = reader.Open(filePath);
                                        //Session["Stream"] = Stream;
                                        TaskManager.Current().SetValid(true);

                                        Stream.Close();
                                    }
                                    // text ór csv FileStream
                                    else if (TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".csv") || TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".txt"))
                                    {
                                        // open FileStream
                                        var reader = new AsciiReader();
                                        Stream = reader.Open(filePath);
                                        //Session["Stream"] = Stream;
                                        TaskManager.Current().SetValid(true);

                                        Stream.Close();
                                    }
                                }
                                #endregion
                            }

                            if (GetDataStructureType().Equals(DataStructureType.Unstructured))
                            {
                                #region unstructured datastructure
                                //try save FileStream
                                var filePath = TaskManager.Bus[TaskManager.FILEPATH].ToString();

                                if (FileHelper.FileExist(filePath))
                                {
                                    TaskManager.Current().SetValid(true);
                                }


                                #endregion
                            }
                        }
                        catch (Exception ex)
                        {
                            model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                        }
                    }
                    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."));
                }

                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() }
                    }));
                }
            }

            model.serverFileList = GetServerFileList();
            //get datastuctureType
            model.DataStructureType       = GetDataStructureType();
            model.SupportedFileExtentions = UploadWizardHelper.GetExtentionList(model.DataStructureType, this.Session.GetTenant());

            return(PartialView(model));
        }
        public ActionResult SelectAFile(object[] data)
        {
            SelectFileViewModel model = new SelectFileViewModel();

            TaskManager = (EasyUploadTaskManager)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(EasyUploadTaskManager.FILEPATH))
                {
                    if (IsSupportedExtention(TaskManager))
                    {
                        try
                        {
                            string filePath = TaskManager.Bus[EasyUploadTaskManager.FILEPATH].ToString();

                            //TaskManager.AddToBus(EasyUploadTaskManager.IS_TEMPLATE, "false");

                            TaskManager.Current().SetValid(true);
                        }
                        catch
                        {
                            model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                        }
                    }
                    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."));
                }

                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() }
                    }));
                }
            }

            model.serverFileList          = GetServerFileList();
            model.SupportedFileExtentions = supportedExtensions;

            return(PartialView(model));
        }
Example #8
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));
        }