Ejemplo n.º 1
0
 void DisplaySession(SavedSession session)
 {
     if (session != null)
     {
         txtFile.Text = session.ConfigFile;
     }
 }
Ejemplo n.º 2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            FactoryConfigurationItem item = new FactoryConfigurationItem();

            item.Key       = "test";
            item.ClassInfo = "dsfas";
            item.ClassName = "asdfa";
            item.DllName   = "sadfasdf";

            List <FactoryConfigurationItem> items = new List <FactoryConfigurationItem>();

            items.Add(item);
            string xml = Utility.Serializer.XML.Serialize(items);
            //System.IO.File.WriteAllText("test.dat", xml);

            SessionList  list    = new SessionList();
            SavedSession session = new SavedSession();

            session.ConfigFile  = System.IO.Directory.GetCurrentDirectory() + "/test.dat";
            session.CreatedDate = DateTime.Now;
            session.SessionName = "Test";

            list.Sessions.Add(session);
            xml = Utility.Serializer.XML.Serialize(list);
            //System.IO.File.WriteAllText("SavedSessions.dat", xml);
            InitComboSession();
            LoadSessions();
            this.WindowState = FormWindowState.Maximized;
        }
Ejemplo n.º 3
0
        public void SearchForDuplicates(string rootFolder, CriteriaSettings pCriteria)
        {
            DuplicateCollector collector = new DuplicateCollector(rootFolder, pCriteria);

            collector.FileAdded += x =>
            {
                SendMessage(Messages.FileAdded, new NotificationEventArgs(x));
            };
            collector.DuplicateFileFound += x =>
            {
                if (FoundDuplicate != null)
                {
                    FoundDuplicate(x);
                }
            };

            SendMessage(Messages.NotifyString, new NotificationEventArgs("Starting count of files..."));
            var count = collector.CountAllFiles();

            SendMessage(Messages.FilesCount, new NotificationEventArgs(count.ToString()));
            SendMessage(Messages.NotifyString, new NotificationEventArgs("Total of: " + count.ToString() + " files found."));

            SendMessage(Messages.NotifyString, new NotificationEventArgs("Starting MD5 Calculation..."));
            AllFiles = collector.ScanFileInfo();
            SendMessage(Messages.NotifyString, new NotificationEventArgs("MD5 Calculation Completed."));
            SendMessage(Messages.NotifyString, new NotificationEventArgs(String.Format(@"Saving results to ""{0}""", DataFile)));

            if (File.Exists(DataFile))
            {
                File.Delete(DataFile);
            }
            var SerializationObject = new SavedSession()
            {
                Duplicates = AllFiles, SelectedPath = rootFolder, Settings = pCriteria
            };

            BinarySerializationAssistor.Serialize(SerializationObject, DataFile);
            SendMessage(Messages.NotifyString, new NotificationEventArgs("Saved."));

            SendMessage(Messages.NotifyString, new NotificationEventArgs("Looking for duplicates..."));
            collector.CalculateDuplicate();
            AllDuplicates = collector.AllDuplicated;
            SendMessage(Messages.NotifyString, new NotificationEventArgs("Done."));
            SendMessage(Messages.NotifyString, new NotificationEventArgs(String.Format("Found {0} duplicated files.", collector.AllDuplicated.Count)));
            SendMessage(Messages.WorkingChanged, new NotificationEventArgs("false"));
            SendMessage(Messages.FilesCompleted, new NotificationEventArgs());
        }
Ejemplo n.º 4
0
        public SessionItemCollection GetSessions(Identifiable parent)
        {
            DataTable             sessionTable;
            SessionItemCollection sessionList;
            SessionItem           tempSession;

            sessionList = new SessionItemCollection();

            //Get any sessions under the parent.
            sessionTable = MyDataServer.GetSessions(parent.ID);
            for (int i = 0; i < sessionTable.Rows.Count; i++)
            {
                switch (sessionTable.Rows[i]["type"].ToString())
                {
                case "AnalyzedGenotypeSet":
                    tempSession = new OldSavedSession((int)sessionTable.Rows[i]["wset_id"],
                                                      sessionTable.Rows[i]["identifier"].ToString(),
                                                      sessionTable.Rows[i]["description"].ToString());
                    break;

                case "ResultGenotypeSet":
                    tempSession = new OldApprovedSession((int)sessionTable.Rows[i]["wset_id"],
                                                         sessionTable.Rows[i]["identifier"].ToString(),
                                                         sessionTable.Rows[i]["description"].ToString());
                    break;

                case "SavedSession":
                    tempSession = new SavedSession((int)sessionTable.Rows[i]["wset_id"],
                                                   sessionTable.Rows[i]["identifier"].ToString(),
                                                   sessionTable.Rows[i]["description"].ToString());
                    break;

                case "ApprovedSession":
                    tempSession = new ApprovedSession((int)sessionTable.Rows[i]["wset_id"],
                                                      sessionTable.Rows[i]["identifier"].ToString(),
                                                      sessionTable.Rows[i]["description"].ToString());
                    break;

                default:
                    throw new Exception("Unknown session type " + sessionTable.Rows[i]["type"].ToString());
                }
                sessionList.Add(tempSession);
            }

            return(sessionList);
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SavedSession session = new SavedSession();

            session.CreatedDate = DateTime.Now;
            session.SessionName = txtSessionName.Text;
            session.ConfigFile  = this.ConfigFile;

            SessionList list = GetSessionList();

            list.Sessions.Add(session);

            SaveSessionList(list);
            this.IsCanceled = false;
            SavedSession    = session;
            this.Close();
        }
 private static SavedSession LoadSession(string solutionFolder, string sessionFile)
 {
     try
     {
         var s = new SavedSession()
         {
             SolutionFolder = solutionFolder,
             ProjectFolder  = Path.GetDirectoryName(Path.GetDirectoryName(sessionFile)),
             SessionFile    = sessionFile
         };
         s.Load();
         return(s);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> SaveSession([FromBody] SavedSession savedSession)
        {
            var lang          = Request.Headers["language"].ToString();
            var errorMessages = new List <string>();

            try
            {
                if (savedSession.SessionId == null || string.IsNullOrEmpty(savedSession.UserId))
                {
                    errorMessages.Add(_translator.GetTranslation("ERROR", lang));
                    return(BadRequest(new { errors = errorMessages }));
                }

                var user = await _userManager.FindByIdAsync(savedSession.UserId);

                var session = _sessionRepository.FindById(savedSession.SessionId.Value);

                if (user == null || session == null)
                {
                    errorMessages.Add(_translator.GetTranslation("ERROR", lang));
                    return(BadRequest(new { errors = errorMessages }));
                }

                var newSavedSession = new SavedSession()
                {
                    Session      = session,
                    SessionId    = session.Id,
                    User         = user,
                    UserId       = user.Id,
                    SaveDateTime = DateTime.Now,
                    SessionUrl   = savedSession.SessionUrl
                };

                var createdSavedSession = _savedSessionRepository.Create(newSavedSession);


                return(Ok(new { createdSavedSession }));
            }
            catch
            {
                errorMessages.Add(_translator.GetTranslation("ERROR", lang));
                return(BadRequest(new { errors = errorMessages }));
            }
        }
Ejemplo n.º 8
0
 public void SetItem(int Index, SavedSession Item)
 {
     List[Index] = Item;
 }
Ejemplo n.º 9
0
 public void Add(SavedSession newItem)
 {
     List.Add(newItem);
 }
 public SavedSession Create(SavedSession savedSession)
 {
     dBContext.SavedSessions.Add(savedSession);
     dBContext.SaveChanges();
     return(savedSession);
 }