コード例 #1
0
        /// <summary>
        /// Raise alert for file when threshold time for file ends for rule3
        /// </summary>
        /// <param name="folderName"></param>
        public void RaiseAlert_Rule3(string folderName, int thresholdInterval)
        {
            lock (thisLock)
            {
                DateTime currentTime = DateTime.Now;

                if (Program.FileCreationList.Count > 0)
                {
                    if (Program.FolderLastAccessTimeList.Count > 0)
                    {
                        foreach (var file in Program.FileCreationList)
                        {
                            if (file.Value.Foldername == folderName)
                            {
                                if (RuleFileRemain.chekFileRemains(null, currentTime, file.Value.FileCreationTime, thresholdInterval) == true)
                                {
                                    if (Program.FileRemainingList.ContainsKey(file.Key) == false)
                                    {
                                        Program.FileRemainingList.Add(file.Key, file.Value);
                                    }
                                    objLogger.WritelogWaning("File:" + file.Key + " remained in folder" + folderName + " for long time");
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// chek file how long remains in folder
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="LastFileAccessTime"></param>
 public void CheckFileRemain(FileDetails objFile, DateTime LastFileAccessTime)
 {
     lock (thisLock)
     {
         if (Program.FolderLastAccessTimeList.Count > 0)
         {
             var last = Program.FolderLastAccessTimeList.Where(t => t.Key == objFile.Foldername).FirstOrDefault().Value;
             if (last != null)
             {
                 if (RuleFileRemain.chekFileRemains(null, last, LastFileAccessTime, objFile.Interval) == true)
                 {
                     if (Program.FileRemainingList.ContainsKey(objFile.Fullfilepath) == false)
                     {
                         Program.FileRemainingList.Add(objFile.Fullfilepath, objFile);
                         //  Program.FileRemainingList.Add(fileName, DateTime.Now);
                         objLogger.WritelogWaning("File:" + objFile.Filename + " remained in folder " + objFile.Foldername + " for long time");
                     }
                 }
             }
         }
     }
 }