Ejemplo n.º 1
0
        private void ImportTuringMachineMenuItem_Click(object sender, RoutedEventArgs e)
        {
            TuringMachine ImportedMachine;

            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.DefaultExt = "tmf";
            dlg.Filter     = "Turing machine file | *.tmf";
            try
            {
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                ImportedMachine = FileDAL.LoadTuringMachine(dlg.FileName);

                Vertex MachineVertex = new Vertex(ImportedMachine.Name, new Point(20, 20));
                MachineVertex.ContainingMachine = ImportedMachine;
                ContainingMachine.Vertices.Add(MachineVertex);
                InvalidateMachineGraph();
            }
            catch
            {
                System.Windows.MessageBox.Show("There was a problem loading the machine. machine file may be corrupted.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        public static List <MyFileInfo> InsertFiles(string directoryStr)
        {
            String[]  path = Directory.GetFiles(directoryStr, "*", SearchOption.AllDirectories);
            ArrayList fis  = new ArrayList();
            String    lowerCase;

            String[] extensions = { ".avi", ".wmv", ".rmvb", ".iso", ".rm", ".afs", ".flv", ".pdf", ".vob", ".rar", ".mpg", ".mpeg", ".mds", ".jpg", ".bmp", ".jpeg", ".mkv", ".dat", ".tif", ".mp4", "zip", ".mov", ".mpe", ".dat", ".bik", ".asx", ".wvx", ".mpa", ".bt!", ".m4v", ".divx", ".asf", ".nrg", ".ogm", ".mdf", ".md0", ".md1", ".md2", ".md3", ".md4", ".m4v", ".ogv", ".exe", ".rar", ".msi", ".7z", ".r00", ".m2ts" };

            foreach (String p in path)
            {
                FileInfo fileInfo = new FileInfo(p);

                string sub = fileInfo.Extension;
                lowerCase = sub.ToLower();
                Console.WriteLine(fileInfo.Extension);


                if (extensions.Contains(lowerCase))
                {
                    MyFileInfo myFileInfo = new MyFileInfo();
                    myFileInfo.FileName       = fileInfo.Name.Replace("'", "''");
                    myFileInfo.Directory      = fileInfo.Directory.Name;
                    myFileInfo.DirectoryName  = fileInfo.DirectoryName;
                    myFileInfo.Extension      = fileInfo.Extension;
                    myFileInfo.LastAccessTime = fileInfo.LastAccessTime.ToString();
                    myFileInfo.LastWriteTime  = fileInfo.LastWriteTime.ToString();
                    myFileInfo.Length         = (double)((int)(fileInfo.Length / 1024.0 / 1024.0 * 100)) / 100;

                    myFileInfo.Mark = "";
                    fis.Add(myFileInfo);
                }
            }

            return(FileDAL.Insert(fis));
        }
Ejemplo n.º 3
0
        private void SaveProjectMenuItem_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.MenuItem item = sender as System.Windows.Controls.MenuItem;
            if (ContainingProject.FileDir == null | item.Header.ToString() == "Save _As")
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.DefaultExt = "TPF";
                dlg.Filter     = "Turing project file | *.TPF";
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ContainingProject.FileDir = dlg.FileName;
                }
            }

            else
            {
                try
                {
                    FileDAL.SaveProject(ContainingProject);
                }
                catch
                {
                    System.Windows.MessageBox.Show("There was a problem saving the project, try using another directory.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 4
0
        private void OpenProjectMenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = "tpf";
            dlg.Filter     = "Tura project file | *.tpf";
            try
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ContainingProject = FileDAL.LoadProject(dlg.FileName);
                }
                else
                {
                    return;
                }

                InvalidateMachinesGrid();
                IsProjectLoaded = true;
                Title          += " - " + ContainingProject.Name;
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("There was a problem loading the project. project file may be corrupted", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 5
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            MyFileInfo myFileInfo = new MyFileInfo();

            try
            {
                int row = e.RowIndex;
                myFileInfo.FileId         = Convert.ToInt32(dataGridView1["FileId", row].Value);
                myFileInfo.FileName       = dataGridView1["FileName", row].Value.ToString();
                myFileInfo.Directory      = dataGridView1["Directory", row].Value.ToString();
                myFileInfo.DirectoryName  = dataGridView1["DirectoryName", row].Value.ToString();
                myFileInfo.Extension      = dataGridView1["Extension", row].Value.ToString();
                myFileInfo.LastAccessTime = dataGridView1["LastAccessTime", row].Value.ToString();
                myFileInfo.LastWriteTime  = dataGridView1["LastWriteTime", row].Value.ToString();
                myFileInfo.Length         = Convert.ToInt32(dataGridView1["length", row].Value);
                myFileInfo.Mark           = dataGridView1["mark", row].Value.ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            if (FileDAL.Update(myFileInfo) > 0)
            {
                //MessageBox.Show("Seccess");
                ;
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Ejemplo n.º 6
0
        private ArrayList processPic(string path)
        {
            ArrayList duplicatePics = new ArrayList();

            String[] pathes = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
            foreach (string p in pathes)
            {
                FileInfo fileInfo = new FileInfo(p);

                Pic pic = new Pic();
                pic.Md5    = GetMd5(p);
                pic.Name   = Path.GetFileName(path);
                pic.Length = fileInfo.Length / 1024;
                pic.Path   = p;

                if (!FileDAL.CheckPic(pic))
                {
                    FileDAL.InsertPic(pic);
                }
                else
                {
                    duplicatePics.Add(pic);
                }
            }
            return(duplicatePics);
        }
Ejemplo n.º 7
0
        static Provaider()
        {
            string typeDAL = ConfigurationManager.AppSettings["typeDAL"];
            string typeBLL = ConfigurationManager.AppSettings["typeBLL"];

            switch (typeDAL)
            {
            case "Files":
                DAL = new FileDAL();
                break;

            case "Memory":
                break;
            }
            switch (typeBLL)
            {
            case "Basic":
                BLL = new UserLogic(DAL);
                break;

            case "Fake":
            {
            }
            break;
            }
        }
Ejemplo n.º 8
0
        void updateVid()
        {
            Regex             idRegex = new Regex("[A-Z]{1,}-[0-9]{1,}|[A-Z]{1,}[0-9]{1,}");
            List <MyFileInfo> list    = FileDAL.selectMyFileInfo("");
            Regex             reg1    = new Regex("[A-Z]");

            foreach (MyFileInfo myFileInfo in list)
            {
                if (myFileInfo.Length > 100)
                {
                    if (myFileInfo.FileName.Length > 40 && !CheckChinese(myFileInfo.FileName))
                    {
                        continue;
                    }
                    string vid = idRegex.Match(Path.GetFileNameWithoutExtension(myFileInfo.FileName).ToUpper().Replace("-", "")).ToString();

                    if (vid.Length > 0)
                    {
                        string letter        = "";
                        string number        = "";
                        bool   isEndofLetter = false;
                        for (int i = 0; i < vid.Length; i++)                           //修改   对于出现KIDM235A  KIDM235B
                        {
                            if (reg1.IsMatch(vid[i].ToString()))
                            {
                                if (isEndofLetter)
                                {
                                    break;
                                }
                                else
                                {
                                    letter += vid[i];
                                }
                            }
                            else
                            {
                                number       += vid[i];
                                isEndofLetter = true;
                            }
                        }
                        if (letter.Length > 6 || letter.Length == 1)
                        {
                            continue;
                        }
                        if (number.Length > 8)
                        {
                            continue;
                        }
                        myFileInfo.Vid = vid;
                        FileDAL.UpdateVid(myFileInfo);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void SaveMahcineMenuItem_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.MenuItem item = sender as System.Windows.Controls.MenuItem;

            System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
            dlg.DefaultExt = "tmf";
            dlg.Filter     = "Turing machine file | *.tmf";
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FileDAL.SaveTuringMachine(ContainingMachine, dlg.FileName);
            }
        }
Ejemplo n.º 10
0
        public static List <MyFileInfo> InsertFiles(string directoryStr)
        {
            String[]  path = Directory.GetFiles(directoryStr, "*", SearchOption.TopDirectoryOnly);
            ArrayList fis  = new ArrayList();
            String    lowerCase;

            //String[] extensions = { ".avi", ".wmv", ".rmvb", ".iso", ".rm", ".afs", ".flv", ".pdf",".mpg","mpeg" };
            String[] extensions = { ".avi", ".wmv", ".rmvb", ".iso", ".rm", ".afs", ".flv", ".pdf", ".vob", ".rar", ".mpg", ".mpeg", ".mds", ".jpg", ".bmp", ".jpeg", ".mkv", ".dat", ".tif", ".mp4", "zip", ".mov", ".mpe", ".dat", ".bik", ".asx", ".wvx", ".mpa", ".bt!", "m4v", ".nrg", ".ogm", ".mdf" };

            foreach (String p in path)
            {
                FileInfo fileInfo = new FileInfo(p);

                //Console.WriteLine(f);
                //Console.WriteLine(f.LastIndexOf("."));
                string sub = fileInfo.Extension;
                lowerCase = sub.ToLower();
                Console.WriteLine(fileInfo.Extension);

                //if (sub == "avi" || sub=="wmv"||sub=="rmvb"||sub=="iso"||sub=="rm"||sub=="afs"||sub=="flv"||sub.Contains("md")||sub=="pdf")
                if (extensions.Contains(lowerCase))
                {
                    //Console.WriteLine(f.Substring(f.LastIndexOf(".")));
                    //Console.WriteLine(p);
                    //listStr += p + "\n";
                    //fis.Add(myFileInfo);
                    MyFileInfo myFileInfo = new MyFileInfo();
                    myFileInfo.FileName       = fileInfo.Name.Replace("'", "''");
                    myFileInfo.Directory      = fileInfo.Directory.Name;
                    myFileInfo.DirectoryName  = fileInfo.DirectoryName;
                    myFileInfo.Extension      = fileInfo.Extension;
                    myFileInfo.LastAccessTime = fileInfo.LastAccessTime.ToString();
                    myFileInfo.LastWriteTime  = fileInfo.LastWriteTime.ToString();
                    myFileInfo.Length         = (double)((int)(fileInfo.Length / 1024.0 / 1024.0 * 100)) / 100;

                    myFileInfo.Mark = "";
                    fis.Add(myFileInfo);
                }
            }

            StreamReader sr      = new StreamReader(@"D:\pages\02-2\25.htm");
            string       content = sr.ReadToEnd();

            sr.Close();
            string content1 = content.Split(new string[] { "<div class=\"image\">", "</span></div>" }, StringSplitOptions.RemoveEmptyEntries)[1];

            Console.WriteLine(content1);



            return(FileDAL.Insert(fis));
        }
Ejemplo n.º 11
0
        public IActionResult Index()
        {
            List <string> fileList    = FileDAL.getAll();
            List <string> newFileList = new List <string>();

            foreach (string cad in fileList)
            {
                //string[] s = cad.Split("https://deltacargostorage.blob.core.windows.net/pdf/");
                int pos = cad.LastIndexOf("/");
                newFileList.Add(cad.Substring(pos + 1));
            }
            ViewBag.fileList = newFileList;
            return(View());
        }
Ejemplo n.º 12
0
        private void OpenMachineMenuItem_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.DefaultExt = "tmf";
            dlg.Filter     = "Turing machine file | *.tmf";
            try
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ContainingMachine = FileDAL.LoadTuringMachine(dlg.FileName);
                }

                InvalidateMachineGraph();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("There was a problem loading the machine. machine file may be corrupted.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 13
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            MyFileInfo myFileInfo = new MyFileInfo();

            try
            {
                int row = e.RowIndex;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            if (FileDAL.Update(myFileInfo) > 0)
            {
                //MessageBox.Show("Seccess");
                ;
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Ejemplo n.º 14
0
 public List <Folder> Folder_Tree(Folder model)
 {
     return(FileDAL.Folder_List(model).ToList());
 }
Ejemplo n.º 15
0
 public IES.Resource.Model.Folder Folder_ADD(Folder model)
 {
     return(FileDAL.Folder_ADD(model));
 }
Ejemplo n.º 16
0
 public List <Folder> Folder_ALL_Tree(int userId)
 {
     return(FileDAL.Folder_ALL_Tree(userId));
 }
Ejemplo n.º 17
0
 public List <Folder> Folder_List(Folder folder)
 {
     return(FileDAL.Folder_List(folder).ToList());
 }
Ejemplo n.º 18
0
 public bool File_ShareRange_Upd(File model)
 {
     return(FileDAL.File_ShareRange_Upd(model));
 }
Ejemplo n.º 19
0
 public Folder Folder_GetModel(Folder folder)
 {
     return(FileDAL.Folder_GetModel(folder));
 }
Ejemplo n.º 20
0
 public FileChapterKen File_Chapter_Ken(int FileID)
 {
     return(FileDAL.File_Chapter_Ken(FileID));
 }
Ejemplo n.º 21
0
 public bool File_Chapter_Ken_Edit(File model, Chapter chapter, Ken ken)
 {
     return(FileDAL.File_Chapter_Ken_Edit(model, chapter, ken));
 }
Ejemplo n.º 22
0
 public bool Folder_Name_Upd(Folder model)
 {
     return(FileDAL.Folder_Name_Upd(model));;
 }
Ejemplo n.º 23
0
 public bool Folder_Del(Folder folder)
 {
     return(FileDAL.Folder_Del(folder));
 }
Ejemplo n.º 24
0
 public bool Folder_Batch_ShareRange(string folderIds, int shareRange)
 {
     return(FileDAL.Folder_Batch_ShareRange(folderIds, shareRange));
 }
Ejemplo n.º 25
0
 public bool Folder_ShareRange_Upd(Folder model)
 {
     return(FileDAL.Folder_ShareRange_Upd(model));
 }
Ejemplo n.º 26
0
 public string File_Del(File model)
 {
     return(FileDAL.File_Del(model));
 }
Ejemplo n.º 27
0
 public bool Folder_ParentID_Upd(Folder model)
 {
     return(FileDAL.Folder_ParentID_Upd(model));
 }
Ejemplo n.º 28
0
 public Folder Folder_Get()
 {
     return(FileDAL.Folder_Get());
 }
Ejemplo n.º 29
0
 public bool Folder_Batch_Del(string FolderIDS)
 {
     return(FileDAL.Folder_Batch_Del(FolderIDS));
 }
Ejemplo n.º 30
0
 public bool File_Batch_Del(string FileIDS)
 {
     return(FileDAL.File_Batch_Del(FileIDS));
 }