Exemplo n.º 1
0
        public void CheckIn()
        {
            string lastVersion;
            NewFile currentFile = GetLastFile();
            int id = GetUserId();

            if (currentFile.Locked != null && currentFile.Locked != id)
            {
                MessageBox.Show("This file is check out from user another and cannot check in execute!");
            }
            else
            {
                bool isSame = this.textFile.Text != this.GetLastFile().File1;
                string lastFileContent = this.GetLastFile().File1;

                NewFile newFile = new NewFile()
                {
                    File1 = (lastFileContent == null || isSame) ? textFile.Text : lastFileContent,
                    Comment = textBoxComments.Text,
                    SaveDirectory = savePath
                };

                this.files.Add(newFile);
                this.files.SaveChanges();


                try
                {
                    lastVersion = this.GetLatestVersion();
                }
                catch (NullReferenceException)
                {

                    NewFile lastFile = GetLastFile();

                    int userId = GetUserId();

                    FileVersion newVersion = new FileVersion()
                    {
                        Creator = userId,
                        Date = DateTime.Now,
                        FileId = lastFile.Id
                    };
                    this.versions.Add(newVersion);
                    this.versions.SaveChanges();

                    MessageBox.Show("Check_In Completed!");
                }

                if (!IsEqual(this.GetLatestVersion(), this.GetLastFile().File1))
                {
                    NewFile lastFile = GetLastFile();

                    int userId = GetUserId();

                    FileVersion newVersion = new FileVersion()
                    {
                        Creator = userId,
                        Date = DateTime.Now,
                        FileId = lastFile.Id
                    };
                    this.versions.Add(newVersion);
                    this.versions.SaveChanges();

                    MessageBox.Show("Check_In Completed!");
                }
                else
                {
                    MessageBox.Show("Current file is already exist in database and Check_In operation is'n possible!");
                }
                this.textBoxComments.Clear();
                this.buttonCheck_In.Enabled = false;
            }
        }
Exemplo n.º 2
0
        public void AddFileToVCS()
        {
            this.SaveFileInDirectory(textFile.Text);
            try
            {
                string lastFile = this.GetLastFile().File1;
            }
            catch (NullReferenceException)
            {
                NewFile newFile = new NewFile()
                {
                    File1 = textFile.Text,
                    Comment = textBoxComments.Text,
                    SaveDirectory = savePath

                };

                this.files.Add(newFile);
                this.files.SaveChanges();
                MessageBox.Show("Add file to Version Control Systems is Completed!");
            }


            if (!IsEqual(this.GetLastFile().File1, textFile.Text))
            {
                NewFile newFile = new NewFile()
                {
                    File1 = textFile.Text,
                    Comment = textBoxComments.Text
                };

                this.files.Add(newFile);
                this.files.SaveChanges();
                MessageBox.Show("Add file to Version Control Systems is Completed!");
            }
            else
            {
                MessageBox.Show("This file already added in Version Control Systems!");
            }


        }