private void DiscoverFiles(string rootPath, string searchText)
        {
            CurrentFiles.Clear();
            CurrentFilesSelected.Clear();

            if (rootPath != String.Empty)
            {
                DirectoryInfo di = new DirectoryInfo(rootPath);

                var files = di.EnumerateFiles("*", SearchOption.AllDirectories)
                            .Where(f => ResourceExtensions.ValidExtensions.Contains(f.Extension))
                            .Where(f => f.Name != PACKAGES_FILENAME);

                if (!string.IsNullOrWhiteSpace(searchText))
                {
                    files = files.Where(f => f.FullName.Contains(searchText));
                }

                foreach (FileInfo f in files)
                {
                    CurrentFiles.Add(f);
                }
                OnPropertyChanged("CurrentFiles");
            }
        }
Beispiel #2
0
 void SetCurrentFiles()
 {
     CurrentFiles.Clear();
     if (!string.IsNullOrEmpty(SelectedPath) && Directory.Exists(SelectedPath))
     {
         FileError = false;
         DirectoryInfo directory = new DirectoryInfo(SelectedPath);
         try
         {
             foreach (FileSystemInfo f in directory.GetFileSystemInfos())
             {
                 CurrentFiles.Add(f);
             }
         }
         catch (UnauthorizedAccessException ex)
         {
             if (_log.IsWarnEnabled)
             {
                 _log.Warn("Error Getting File System Infos.  Selected Path=" + SelectedPath, ex);
             }
             FileError = true;
         }
         if (!FileError)
         {
             SetWatcher();
         }
     }
     else
     {
         fsw.EnableRaisingEvents = false;
     }
 }
        private void DeleteSelectedPackage()
        {
            if (SelectedPackage != null)
            {
                var toBeDeleted = Packages.Where(x => x == SelectedPackage).FirstOrDefault();

                if (toBeDeleted != null)
                {
                    if (ActivePackage == SelectedPackage)
                    {
                        ActivePackage = null;
                        //Also, clear out any dependencies
                        CurrentFiles.Clear();
                        CurrentFilesSelected.Clear();
                        WebResourceInfos.Clear();
                        WebResourceInfosSelected.Clear();
                    }
                    Packages.Remove(toBeDeleted);
                    SelectedPackage = null;
                }
                SavePackages();
            }
        }
Beispiel #4
0
        private void LoadData(DataSet ds)
        {
            const int TBL_GENERAL        = 0;
            const int TBL_LOCATIONS      = 1;
            const int TBL_STATUS_HISTORY = 2;
            const int TBL_CURRENT_ICONS  = 3;
            const int TBL_CURRENT_FILES  = 4;
            const int TBL_CURRENT_ACCESS = 5;

            const int ROW_FIRST = 0;

            DataTable dtGeneral = ds.Tables[TBL_GENERAL];

            if (dtGeneral.Rows.Count > 0)
            {
                DataRow dr = dtGeneral.Rows[ROW_FIRST];

                // badge info
                Badge.BadgeID           = (int)dr["BadgeID"];
                Badge.BadgeNumber       = (string)dr["BadgeNumber"];
                Badge.BadgeColor        = (string)dr["BadgeColor"];
                Badge.WhenBecomesActive = (DateTime)dr["WhenBadgeBecomesActive"];
                Badge.WhenExpires       = (DateTime)dr["WhenBadgeExpires"];
                Badge.BadgeStatus       = (string)dr["BadgeStatus"];

                // person info
                Person.NamePrefix = (string)dr["NamePrefixDescription"];
                Person.FirstName  = (string)dr["FirstName"];
                Person.MiddleName = (string)dr["MiddleName"];
                Person.LastName   = (string)dr["LastName"];
                Person.NameSuffix = (string)dr["NameSuffixDescription"];

                // Unknown info
                Miscellaneous.FingerprintDate = Badge.WhenBecomesActive;
                Miscellaneous.PrintDate       = Badge.WhenBecomesActive;
                Miscellaneous.PrintUser       = "******";

                // Company info
                Company.CompanyCode     = (string)dr["CompanyCode"];
                Company.CompanyID       = (int)dr["CompanyID"];
                Company.CorporationName = (string)dr["CorporationName"];

                // Division info
                Division.DivisionID   = (int)dr["DivisionID"];
                Division.DivisionCode = (string)dr["DivisionCode"];
                Division.DivisionName = (string)dr["DivisionName"];

                if (dr.Table.Columns.Contains("DivisionTypeName"))
                {
                    Division.DivisionTypeName = (string)dr["DivisionTypeName"];
                }

                Division.JobRole = (string)dr["JobRoleDescription"];
            }


            DataTable dtLocations = ds.Tables[TBL_LOCATIONS];

            if (dtLocations.Rows.Count > 0)
            {
                foreach (DataRow row in dtLocations.Rows)
                {
                    Locations.Add(new Location(row));
                }

                SelectedLocation = Locations[0];
            }

            DataTable dtStatusHistory = ds.Tables[TBL_STATUS_HISTORY];

            StatusHistory.Clear();
            if (dtStatusHistory.Rows.Count > 0)
            {
                foreach (DataRow row in dtStatusHistory.Rows)
                {
                    StatusHistory.Add(new BadgeStatusPeriod(row));
                }
            }

            DataTable dtCurrentIcons = ds.Tables[TBL_CURRENT_ICONS];

            CurrentIcons.Clear();
            if (dtCurrentIcons.Rows.Count > 0)
            {
                foreach (DataRow row in dtCurrentIcons.Rows)
                {
                    CurrentIcons.Add(new BadgeIcon(row));
                }
            }

            DataTable dtCurrentFiles = ds.Tables[TBL_CURRENT_FILES];

            CurrentFiles.Clear();
            if (dtCurrentFiles.Rows.Count > 0)
            {
                foreach (DataRow row in dtCurrentFiles.Rows)
                {
                    CurrentFiles.Add(new BadgeFile(row));
                }
            }

            /****
             *                      else
             *                      {
             *                              CurrentFiles.Add(new BadgeFile("text file (54) (spoofed data)", "54", "text/plain"));
             *                              CurrentFiles.Add(new BadgeFile("pdf file (5) (spoofed data)", "5", "application/pdf"));
             *                      }
             */

            DataTable dt = ds.Tables[TBL_CURRENT_ACCESS];

            CurrentAccess.Clear();
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    CurrentAccess.Add(new BadgeAccessCategory(row));
                }
            }

            /***
             * else
             * {
             *      CurrentAccess.Add(new BadgeAccessCategory());
             *      CurrentAccess.Add(new BadgeAccessCategory());
             *      CurrentAccess.Add(new BadgeAccessCategory());
             *      CurrentAccess.Add(new BadgeAccessCategory());
             * }
             */
        }