Ejemplo n.º 1
0
        //#################################################################################################
        public IActionResult AddFilter(string filtername)
        {
            LogController.Begin();
            Program.indexModel.ErrorFilterList  = null;
            Program.indexModel.ExceptionMessage = null;
            if (!String.IsNullOrEmpty(filtername))
            {
                try
                {
                    if (Program.indexModel.FilterList == null)
                    {
                        Program.indexModel.FilterList = new Classes.FList();
                    }
                    Program.indexModel.FilterList.Add(new Classes.Filter(filtername, ""));
                }
                catch (Exception ex)
                {
                    Program.indexModel.ErrorFilterList = ex.Message;
                }
            }


            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 2
0
        //#################################################################################################

        public static Message GetMessage(string msgcode)
        {
            try
            {
                Controllers.LogController.Begin();
                StartZeit = DateTime.Now;

                LogController.LogMessage(string.Format("GetMessage: MsgCode: '{0}', Language:'{1}'", msgcode, language));

                Message       msg         = new Message();
                string        strFilename = Path.Combine("Config", "Messages.xml");
                XmlTextReader reader      = new XmlTextReader("Messages.xml");

                XmlDocument doc = new XmlDocument();
                try
                {
                    doc.Load(strFilename);
                }
                catch
                {
                    if (System.IO.File.Exists(strFilename))
                    {
                        Controllers.LogController.LogError($"Error loading {strFilename}.");
                    }
                    else
                    {
                        Controllers.LogController.LogError($"Could not load {strFilename}. File does not exist");
                    }
                }
                XmlNode messages = doc.SelectSingleNode("messages");

                foreach (XmlNode node in messages.SelectNodes("message"))
                {
                    if (node.SelectSingleNode("msgcode") == null)
                    {
                        continue;
                    }

                    if (!node.SelectSingleNode("msgcode").InnerText.ToLower().Equals(msgcode.ToLower()))
                    {
                        continue;
                    }

                    if (node.SelectSingleNode("text") != null)
                    {
                        if (node.SelectSingleNode(string.Format("text/{0}", language)) != null)
                        {
                            msg.txt = node.SelectSingleNode("text/" + language).InnerText;
                        }
                    }


                    if (msg.txt == "" || msg.txt == null)
                    {
                        msg.txt = string.Format("{0} for lanuage '{1}' isn't available.", msgcode, language);
                        LogController.LogError(string.Format("{0} for lanuage '{1}' isn't available.", msgcode, language));
                    }

                    if (node.SelectSingleNode("extern") != null)
                    {
                        if (node.SelectSingleNode(string.Format("extern/{0}", language)) != null)
                        {
                            msg.ext = node.SelectSingleNode("extern/" + language).InnerText;
                        }
                    }

                    if (node.SelectSingleNode("type") != null)
                    {
                        msg.type = node.SelectSingleNode("type").Value;
                    }
                    else
                    {
                        msg.type = "default";
                    }

                    break;
                }



                Controllers.LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit));
                return(msg);
            } catch
            {
                Controllers.LogController.LogError("Message could not be produced");
                Message msg = new Message();
                msg.txt = "'Empty'";
                return(msg);
            }
        }
Ejemplo n.º 3
0
        public IActionResult SaveToCsv(Models.IndexModel indexModel, int newSite = -1, int newCps = -1)
        {
            LogController.Begin();
            Program.indexModel.ErrorFilterList  = indexModel.ErrorFilterList;
            Program.indexModel.ExceptionMessage = indexModel.ExceptionMessage;
            int num = 0;

            //change only the actual shown part of the contentlist
            for (int i = 0 + Program.indexModel.cps * Program.indexModel.actSite; i < Program.indexModel.ContentList.Count && i < Program.indexModel.cps * (Program.indexModel.actSite + 1); i++)
            {
                int j = i % Program.indexModel.cps;
                Program.indexModel.ContentList[i].download = indexModel.PartialContentList[j].download;

                if (Program.indexModel.ContentList[i].download)
                {
                    num++;
                }
            }
            if (num > 5)
            {
                Program.indexModel.ExceptionMessage = HelperController.GetMessage("Index.Err.ToManyFiles").txt;
                return(RedirectToAction("Index", "Home"));
            }

            if (newSite >= 0)
            {
                return(SetActSite(newSite));
            }
            if (newCps >= 0)
            {
                return(SetCps(newCps));
            }



            switch (Program.indexModel.database.KeyName)
            {
            case ("geoprofiles"):

                var zipFile = FileController.DownloadAndProcessGEOProfiles(Program.indexModel.ContentList);

                if (zipFile != null && System.IO.File.Exists(zipFile))
                {
                    var bArray = System.IO.File.ReadAllBytes(zipFile);
                    return(File(bArray, "application/octet-stream", "export.zip"));
                }
                else
                {
                    Controllers.LogController.LogError($"Zipfile could not be accessed at {zipFile}");
                }
                //break;
                var csv = FileController.WriteListToCsv(Program.indexModel.ContentList);
                if (csv != null)
                {
                    var bArray = System.Text.Encoding.UTF8.GetBytes(csv.ToString());
                    return(File(bArray, "application/octet-stream", "export.csv"));
                }
                break;

            case ("gds"):
                var processedPath = FileController.DowloadAndProcessGDS(Program.indexModel.ContentList);
                if (processedPath != null)
                {
                    return(RedirectToAction("Upload", "Upload"));
                }
                break;
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 4
0
        //#################################################################################################
        public IActionResult UploadFile(Models.UploadModel uploadModel)
        {
            try
            {
                Controllers.LogController.Begin();
                StartZeit = DateTime.Now;

                Program.uploadModel.ExceptionMessage = null;
                Program.uploadModel.Step             = 1;

                Directory.CreateDirectory(tmpPath);
                Directory.CreateDirectory(dataPath);
                Directory.CreateDirectory(csvPath);
                Directory.CreateDirectory(processedPath);

                if (uploadModel.file != null)
                {
                    try
                    {
                        using (var stream = System.IO.File.Create(Path.Combine(dataPath, uploadModel.file.FileName)))
                        {
                            uploadModel.file.CopyTo(stream);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogController.LogError(String.Format(HelperController.GetMessage("UploadController.Err.UploadFile1").txt, ex.ToString()));
                        Program.uploadModel.ExceptionMessage = HelperController.GetMessage("UploadController.Err.UploadFile1").ext;
                        return(Upload());
                    }
                }
                else
                {
                    try
                    {
                        if (uploadModel.fileString.IndexOf("data:") >= 0)
                        {
                            uploadModel.fileString = Regex.Replace(uploadModel.fileString, "data:([^,]+)", String.Empty);
                            uploadModel.fileString = uploadModel.fileString.Remove(0, 1);
                        }
                        System.IO.File.WriteAllBytesAsync(Path.Combine(dataPath, uploadModel.fileName), Convert.FromBase64String(uploadModel.fileString));
                    }
                    catch (Exception ex)
                    {
                        LogController.LogError(String.Format(HelperController.GetMessage("UploadController.Err.UploadFile2").txt, ex.ToString()));
                        Program.uploadModel.ExceptionMessage = HelperController.GetMessage("UploadController.Err.UploadFile2").ext;
                        return(Upload());
                    }
                }

                Program.uploadModel.FileList = new List <Classes.File>();
                FileController.MoveAndExtractFiles(dataPath, csvPath);



                FileController.MoveAndExtractFiles(csvPath, processedPath);
                LogController.End(String.Format("verstrichene Zeit: {0}", DateTime.Now - StartZeit));
                return(Preview(processedPath));
            }
            catch (Exception ex)
            {
                LogController.LogError(String.Format(HelperController.GetMessage("UploadController.Err.Total").txt, ex.ToString()));
                Program.uploadModel.ExceptionMessage = HelperController.GetMessage("UploadController.Err.Total").ext;
                FileController.ClearDirectory(@"C:\temp\tmp_upload_" + Program.GuidString);
                Program.uploadModel.FileList = null;
                return(Upload());
            }
        }