Пример #1
0
        private void FileWatcher_Load(object sender, EventArgs e)
        {
            var hlpr = new DHMisc(AppWrapper.AppWrapper.DevTrkrConnectionString);

            _notableFiles = hlpr.GetNotableFileExtensions();

            fileSystemWatcher1.Filter = "*.*";
            fileSystemWatcher1.Path   = @"c:\"; // txtFile.Text + "\\";
                                                //}
                                                //else
                                                //{
                                                //fileWatcher1.Filter = txtFile.Text.Substring(txtFile.Text.LastIndexOf('\\') + 1);
                                                //fileWatcher1.Path = txtFile.Text.Substring(0, txtFile.Text.Length - m_Watcher.Filter.Length);
                                                //}

            //if (chkSubFolder.Checked)
            //{
            fileSystemWatcher1.IncludeSubdirectories = true;
            //}

            fileSystemWatcher1.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
                                              | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            //fileWatcher1.Changed += new FileSystemEventHandler();
            //fileWatcher1.Created += new FileSystemEventHandler(OnChanged);
            //fileWatcher1.Deleted += new FileSystemEventHandler(OnChanged);
            //fileWatcher1.Renamed += new RenamedEventHandler(OnRenamed);
            fileSystemWatcher1.EnableRaisingEvents = true;
        }
Пример #2
0
        private void frmReporter_Load(object sender, EventArgs e)
        {
            Application.DoEvents();
            var hlpr = new DHMisc();

            // i think getting syncs is unneeded since devprojects has the syncid in it
            // and handling syncs and projects is over complicating this issue
            // SyncList = hlpr.GetProjectSyncs();
            //TODO: look for ssms projects which are not .master
            ProjList = hlpr.GetProjectsForReporting();
            lvProjects.Items.Clear();
            string syncID = string.Empty;

            foreach (var item in ProjList.Projects)
            {
                string sync = item.SyncID;
                if (sync == syncID)
                {
                    continue;
                }
                syncID = sync;
                var lvi = new ListViewItem(item.DevProjectName);
                lvi.SubItems.Add(item.DevProjectCount.ToString());
                var displayName = ProjList.Names.Find(x => x.UserName == item.UserName);
                lvi.SubItems.Add(displayName != null ? displayName.DisplayName : item.UserName);
                lvProjects.Items.Add(lvi);
            }

            lbDevelopers.Items.Clear();
            lbDevelopers.Items.Add("All");
            List <DeveloperNames> developers = hlpr.GetDeveloperNames();

            if (AppWrapper.AppWrapper.UserPermissionLevel == PermissionLevel.Developer)
            {
                var devObj = developers.Find(o => o.UserName.ToLower() == Environment.UserName.ToLower());
                if (devObj != null)
                {
                    lbDevelopers.Items.Add(devObj.UserName + " - " + devObj.UserDisplayName);
                    lbDevelopers.SelectedIndex = 1;
                    lbDevelopers.Enabled       = false;
                }
            }
            else
            {
                foreach (var developer in developers)
                {
                    lbDevelopers.Items.Add(developer.UserName + " - " + developer.UserDisplayName);
                }
            }
            AppList = hlpr.GetNotableApplications();
            lbApplications.Items.Clear();
            lbApplications.Items.Add("All Applications");
            lbApplications.Items.Add("All Listed Applications");

            foreach (var item in AppList)
            {
                lbApplications.Items.Add(item.AppFriendlyName);
            }
        }
Пример #3
0
        public Tuple <string, string> IsProjectInNonIDETitle(string title)
        {
            var hlpr      = new DHMisc();
            var projects  = hlpr.GetDevProjects();
            var prjObject = projects.Find(x => title.Contains(x.DevProjectName));

            return(prjObject == null ? null : Tuple.Create(prjObject.DevProjectName, prjObject.SyncID));
        }
Пример #4
0
        //public FileSystemWatcher fileWatcher1;
        //private FileSystemWatcher fileWatcher2;
        #endregion

        #region ..ctor
        public FileWatcher()
        {
            try
            {
                // determine what we have to watch on this machine
                // if database is not setup, watch the C:\ drive
                var hlpr = new DHMisc(string.Empty);
                List <ConfigOption> dirList = hlpr.GetConfigOptions(AppWrapper.AppWrapper.FileWatcherDirecory);
                var o = dirList.Find(x => x.Value.StartsWith(Environment.MachineName));

                string[] drives;
                if (o == null)
                {
                    Watch(@"C:\");
                }
                else
                {
                    string s = o.Value.Substring(o.Value.IndexOf("|") + 1);
                    drives = s.Split(',');
                    for (int i = 0; i < drives.Length; i++)
                    {
                        Watch(drives[i]);
                    }
                }

                #region single filewatcher setup no longer used
                //fileWatcher1 = new FileSystemWatcher
                //{
                //    Path = @"C:\",
                //    Filter = "*.*",
                //    NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
                //    IncludeSubdirectories = true
                //};

                //fileWatcher1.Changed +=
                //      new FileSystemEventHandler(fileSystemWatcher1_Changed);
                //fileWatcher1.Created +=
                //    new FileSystemEventHandler(fileSystemWatcher1_Created);
                //fileWatcher1.Deleted +=
                //    new FileSystemEventHandler(fileSystemWatcher1_Deleted);
                //fileWatcher1.Renamed +=
                //    new RenamedEventHandler(fileSystemWatcher1_Renamed);

                //fileWatcher1.EnableRaisingEvents = true;
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + "No FileWatcher is Running", AppWrapper.AppWrapper.ProgramError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void WriteErrorLogToDB(StringBuilder sb, string moduleAndMethod)
        {
            Tuple <string, string> mm = SplitModuleFromMethod(moduleAndMethod);
            var hlpr = new DHMisc();

            _ = hlpr.WriteErrorLog(new ErrorLog
            {
                Module      = mm.Item1,
                Method      = mm.Item2,
                Message     = sb.ToString(),
                DateCreated = DateTime.Now,
                Machine     = Environment.MachineName,
                Username    = Environment.UserName
            });
        }
Пример #6
0
        static void Main(string[] args)
        {
            // test DevProjects
            var mp = new MaintainProject();

            //mp.UpdateSLNPathInDevProjects();
            mp.PopulateSyncTableFromDevProjects();



            var path = @"C:\VS2019 Projects\DevTracker\.git\config";

            DHMisc hlpr = new DHMisc();
            List <NotableFileExtension> notableFileExtensions = hlpr.GetNotableFileExtensions();

            // Tuple<string, string, string> tuple = mp.GetProjectFromGitConfigSaved(path, notableFileExtensions);

            path = @"C:\VS2019 Projects\DevTracker\Classes\FileWatcher.cs";


            //Tuple<string, string, string> tuple = mp.GetProjectFromDevFileActivity(path, notableFileExtensions, "cs");

            var url = mp.GetGitURLFromConfigFile(@"C:\GitRepo\hell-world\.git\config");

            url = mp.GetGitURLFromPath(@"C:\GitRepo\hell-world\helloworld.csproj");
            Console.WriteLine(url);

            // test fileanalyzer
            //var cc = new CodeCounter.FileLineCounter();
            //var ret = cc.Process(@"C:\VS2019 Projects\DevTracker\Forms\MiscContainer.cs");
            string projectPath    = string.Empty;
            string devProjectName = GetProjectPath(@"C:\DevTrkr DLLs\MaintainDevProject\Properties\AssemblyInfo.cs", out projectPath, "csproj");

            Console.WriteLine("Project: " + devProjectName + "Path: " + projectPath);
            Console.ReadLine();
        }
Пример #7
0
        public static void SetupCachedDatabaseData()
        {
            lock (Globals.SyncLockObject)
            {
                CacheTimer.Enabled = false;
                var hlpr = new DHMisc(AppWrapper.AppWrapper.DevTrkrConnectionString);
                Globals.NotableFiles        = hlpr.GetNotableFileExtensions();
                Globals.IDEMatches          = hlpr.GetProjectNameMatches();
                Globals.NotableApplications = hlpr.GetNotableApplications();
                Globals.ConfigOptions       = hlpr.GetConfigOptions();

                AppWrapper.AppWrapper.UserPermissionLevel = hlpr.GetCurrentUserPermissionLevel(Environment.UserName);

                //NOTE: ProjectList will grow so large not feasible to maintain in cache
                // Also, only used on occassion, so removing 6/2/2020
                //Globals.ProjectList = hlpr.GetDevProjects(Environment.UserName, Environment.MachineName);

                // following code is obsolete since we save only develpment files and
                // we no longer need this FilesToSave property
                //var fso = Globals.ConfigOptions.Find(o => o.Name == "RECORDFILES");
                //if (fso != null)
                //    Globals.FilesToSave =
                //        fso.Value.Equals("A") ? FileSaveOption.All
                //        : fso.Value.Equals("N") ? FileSaveOption.None
                //        : fso.Value.Equals("S") ? FileSaveOption.Selected
                //        : FileSaveOption.None;

                var ce = Globals.ConfigOptions.Find(o => o.Name == "CACHEEXPIRATIONTIME");
                Globals.CacheTimeout = ce != null?int.Parse(ce.Value) : 15;

                // set up current user displayname
                try
                {
                    Globals.DisplayName = UserPrincipal.Current.DisplayName;
                }
                catch (Exception ex)
                {
                    Globals.DisplayName = Environment.UserName;
                }

                //NOTE: discontinued this 3/11/20 at 11:35am b/c windows has a Windows Default Lock Screen which
                // appears when the screen is locked, thus uncomplicating the locking situation
                // as it becomes the active screen until unlocked and then the screen that was extant at lock time
                // starts a new time...(._.) the appname is LockApp.exe
                //Globals.workLock = new CheckForWorkstationLocking();
                //Globals.workLock.Run();

                //NOTE: Calendar querying is checked here and only done once a day to get yesterdays mtgs
                var queryDate = Globals.ConfigOptions.Find(o => o.Name == AppWrapper.AppWrapper.CalendarQueriedTime);
                if (queryDate != null && DateTime.Parse(queryDate.Value) < DateTime.Today)
                {
                    //NOTE ***** we started getting contextdeadlocks when this was implemented
                    //TODO query for today must be implemented here, next line is a dummy
                    // in the future we must read the calendar and write the data to the Meetings table
                    // for now we simply write one calendar entry per day.

                    //TODO: uncomment to run simulated calendar query _ = new CalendarQuery(DateTime.Today, true);

                    // now update the date in configoptions so we won't do this again today
                    queryDate.Value = DateTime.Today.ToString("MM/dd/yyyy HH:mm:ss");
                    _ = hlpr.InsertUpdateConfigOptions(queryDate);
                }

                CacheTimer.Tick    += new EventHandler(CacheTimerProcessser);
                CacheTimer.Interval = Globals.CacheTimeout * 1000 * 60;
                CacheTimer.Enabled  = true;
            }
        }