Ejemplo n.º 1
0
 public void addMapResult(Dictionary <string, S3ObjectMetadata> mapResult)
 {
     foreach (KeyValuePair <string, S3ObjectMetadata> pair in mapResult)
     {
         if (MapResult.ContainsKey(pair.Key))
         {
             MapResult[pair.Key].Add(pair.Value);
             MapFiles.Add(pair.Value);
         }
         else
         {
             MapResult.Add(pair.Key, new List <S3ObjectMetadata>()
             {
                 pair.Value
             });
             MapFiles.Add(pair.Value);
         }
     }
 }
Ejemplo n.º 2
0
        // GET: Intel
        public ActionResult Index()
        {
            try
            {
                var path  = Server.MapPath("~/Maps");
                var dInfo = new System.IO.DirectoryInfo(path);
                var maps  = new Dictionary <string, string>();
                dInfo.GetFiles().ToList().ForEach(f => maps.Add(f.Name.Replace(".svg", "").Replace("_", " "), f.Name.Replace(".svg", "")));

                var viewModel = new MapFiles();

                if (SSOUserManager.SiteUser != null && System.IO.Directory.Exists(string.Concat(path, "/", SSOUserManager.SiteUser.GroupName)))
                {
                    dInfo = new System.IO.DirectoryInfo(string.Concat(path, "/", SSOUserManager.SiteUser.GroupName));
                    dInfo.GetFiles().ToList().ForEach(f =>
                    {
                        maps[f.Name.Replace(".svg", "").Replace("_", " ")] = string.Concat(SSOUserManager.SiteUser.GroupName, "/", f.Name.Replace(".svg", ""));
                    });
                }

                maps.OrderBy(o => o.Key).ForEach(f => viewModel.Add(f.Key.Replace("_", " "), f.Value));;

                if (SSOUserManager.SiteUser == null)
                {
                    viewModel.InitialMap = maps["The Citadel"];
                }
                else
                {
                    viewModel.InitialMap = maps[SSOUserManager.SiteUser.DefaultRegion];
                }

                return(View(viewModel));
            }
            catch
            {
                return(RedirectToAction("SSOLogin", "Home"));
            }
        }
Ejemplo n.º 3
0
        private MapFiles WalkDirectoryTree(System.IO.DirectoryInfo root)
        {
            logger.DebugFormat("{0}mapping directory: {1}", Environment.NewLine, root.FullName);
            MapFiles mfs = new MapFiles();
            try
            {
                System.IO.FileInfo[] files = null;
                System.IO.DirectoryInfo[] subDirs = null;

                // First, process all the files directly under this folder
                try
                {
                    files = root.GetFiles("*.*");
                }
                #region catch errors
                // This is thrown if even one of the files requires permissions greater
                // than the application provides.
                catch (UnauthorizedAccessException ex)
                {
                    // This code just writes out the message and continues to recurse.
                    logger.DebugFormat("Unable to process {1}{0}drive: {2}{0}Error: {3}"
                        , Environment.NewLine
                        , GetThisMethodName()
                        , root.FullName
                        , ex.Message);

                }
                catch (System.IO.DirectoryNotFoundException ex)
                {
                    logger.DebugFormat("Unable to process {1}{0}drive: {2}{0}Error: {3}"
                        , Environment.NewLine
                        , GetThisMethodName()
                        , root.FullName
                        , ex.Message);
                }
                catch (System.IO.PathTooLongException ex)
                {
                    // This code just writes out the message and continues to recurse.
                    logger.DebugFormat("Unable to process {1}{0}drive: {2}{0}Error: {3}"
                        , Environment.NewLine
                        , GetThisMethodName()
                        , root.Name
                        , ex.Message);
                    //Console.ReadKey();
                }
                catch (Exception ex)
                {
                    // This code just writes out the message and continues to recurse.
                    logger.DebugFormat("Unable to process {1}{0}drive: {2}{0}Error: {3}"
                        , Environment.NewLine
                        , GetThisMethodName()
                        , root.FullName
                        , ex.Message);
                    // Console.ReadKey();
                }
                #endregion catch errors

                if (files != null)
                {
                    foreach (System.IO.FileInfo fi in files)
                    {
                        try
                        {
                            MapFile mf = new MapFile().LoadData(fi);
                            string json = JsonConvert.SerializeObject(mf);
                            mfs.Add(mf);
                        }
                        #region catch errors
                        catch (System.IO.PathTooLongException ex)
                        {
                            // This code just writes out the message and continues to recurse.
                            logger.DebugFormat("Unable to process {1}{0}drive: {2}{0}Error: {3}"
                                , Environment.NewLine
                                , GetThisMethodName()
                                , fi.Name
                                , ex.Message);
                            //Console.ReadKey();
                        }
                        catch (Exception ex)
                        {
                            // This code just writes out the message and continues to recurse.
                            logger.DebugFormat("Unable to process {1}{0}drive: {2}{0}Error: {3}"
                                , Environment.NewLine
                                , GetThisMethodName()
                                , fi.Name
                                , ex.Message);
                            // Console.ReadKey();
                        }
                        #endregion catch errors
                    }

                    // Now find all the subdirectories under this directory.
                    subDirs = root.GetDirectories();
                    foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                    {
                        // Resursive call for each subdirectory.
                        var more = WalkDirectoryTree(dirInfo);
                        mfs.AddRange(more);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.DebugFormat("Unable to process {1}{0}root: {2}{0}Error: {3}"
                    , Environment.NewLine
                    , GetThisMethodName()
                    , root.FullName
                    , ex.Message);
            }
            using (BulkLoadFiles blc = new BulkLoadFiles(logger))
            {
                var dtc = blc.ConfigureDataTable();
                dtc = blc.LoadDataTableWithFiles(mfs, dtc);
                blc.BulkCopy<MapFiles>(dtc, "DCMaperContext");
            }
            return mfs;
        }