Exemplo n.º 1
0
        public static void CreateRootDir(string NetPath)
        {
            string MaxCreateDirPath = ConfigerHelper.GetAppConfig("MaxCreateDirPath");

            try
            {
                int maxCreateDirPath = Convert.ToInt32(MaxCreateDirPath);
                for (int i = 1; i < maxCreateDirPath; i++)
                {
                    string url = NetPath + i.ToString();

                    filepath filepath = new filepath()
                    {
                        file_Path        = url,
                        file_innerTxt    = "",
                        file_Type_id     = 10,
                        file_status_id   = 0,
                        file_CreateTime  = DateTime.Now,
                        file_parent_path = "0"
                    };
                    Tool.InsertfilePathByLinq(filepath);
                }
            }
            catch (Exception)
            {
                MyMessageBox.Add("创建根目录时发生错误!");
            }
        }
Exemplo n.º 2
0
        //public void prepareOperation(IRenderExecutionContext context)
        //{
        //    String _pt = sourcepath.toPath("", context.data);
        //    template = openBase.openFileToString(_pt, true, false);
        //}

        public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
        {
            var level = composer.elementLevel;

            if (level == sourceRender.levelOfNewFile)
            {
                string filename = dict[composer.path].getProperString("", templateFieldBasic.path_output);

                string parentPath = composer.path;
                if (composer.parent != null)
                {
                    parentPath = composer.parent.path;
                }

                string folderPath = context.data.getProperString(parentPath, templateFieldBasic.path_folder, templateFieldBasic.document_path, templateFieldBasic.documentset_path);

                // filename = context.directoryScope.FullName.add(filename, "\\");
                filepath fp = new filepath(filename);
                //String templateFilename = fp.filename.add(fp.extension, "."); //.toPathWithExtension("", format.getDefaultExtension());
                string templateFilename = fp.toPathWithExtension("", format.getDefaultExtension());

                // context.regFileOutput(templateFilename, folderPath, description);
                // dict[composer.path].Add(templateFieldBasic.path_output, filename);
            }
            else
            {
                // dict[composer.path].Add(templateFieldBasic.path_file, "");
            }

            //throw new NotImplementedException();
            return(dict);
        }
Exemplo n.º 3
0
        public bool run(string attrName, filepath fileEntity)
        {
            bool success = false;

            HtmlNodeCollection hnCollection;
            HtmlNodeCollection titleCollection;

            //获取目录地址
            try
            {
                HtmlDocument htmlDocument = HtmlTool.LoadHtml(fileEntity.file_Path);
                hnCollection    = HtmlTool.GetNodeCollect(htmlDocument, HtmlModelTool.htmlModel.Match);
                titleCollection = HtmlTool.GetNodeCollect(htmlDocument, "//head/title");
            }
            catch (Exception EX)
            {
                Console.WriteLine("线程 {0} 获取文件 {1} 时发生了错误,错误信息 {2} ,错误详情 {3} ", System.Threading.Thread.CurrentThread.ManagedThreadId, fileEntity.file_Path, EX.Message, EX.Data);
                //InsertSql(fileType,URL);
                return(success);
            }


            if (hnCollection == null)
            {
                //errorList.Add(URL);
                Console.WriteLine("线程 {0} 获取文件 {1} 时发生了错误 ,未能加载网页!", System.Threading.Thread.CurrentThread.ManagedThreadId, fileEntity.file_Path);
                //InsertSql(fileType, URL);
                return(success);
            }
            // Console.WriteLine("线程 {0} 获取文件 {1} 正在操作,锁定中……", System.Threading.Thread.CurrentThread.ManagedThreadId, URL);
            foreach (HtmlNode hn in hnCollection)
            {
                string path     = hn.Attributes[attrName].Value;
                string innerTxt = string.IsNullOrEmpty(hn.InnerHtml) ? !string.IsNullOrEmpty(hn.InnerText) ? hn.InnerText : (titleCollection != null ? "" : (titleCollection.Count > 0 ? titleCollection[0].InnerHtml : "")) : hn.InnerHtml;
                if (!string.IsNullOrEmpty(path))
                {
                    if (!dirPathEntity.Any(p => p.file_Path.Equals(path)))
                    // if (!dirPath.Contains(path))
                    {
                        dirPath.Add(path);
                        try
                        {
                            //  InsertfilePath(path, innerTxt, fileType, 0, URL);
                        }
                        catch
                        {
                            return(success);
                        }
                        success = true;
                    }
                    //else if(!dirPathEntity.Any(p=>p.file_innerTxt))
                    //  else
                    success = true;
                    //}
                }
            }


            return(success);
        }
Exemplo n.º 4
0
        public string javaSet([FromBody] filepath csv_file_path)
        {
            var count = data.Database.SqlQuery <int>(@"select exam_set_counts from Exam_List where exam_id=1").FirstOrDefault <int>();

            if (count <= 2)
            {
                var       free      = data.Database.SqlQuery <string>(@"select top 1 table_name from Java_Sets where availability = 'yes'").FirstOrDefault <string>();
                string    tableName = free;
                CSVtoSQL  c         = new CSVtoSQL();
                DataTable csvData   = FileReader.CSVtoSQL.GetDataTabletFromCSVFile(csv_file_path.csv_file_path);
                Console.WriteLine("Rows count:" + csvData.Rows.Count);

                c.InsertDataIntoSQLServerUsingSQLBulkCopy(csvData, tableName);
                foreach (var column in csvData.Columns)
                {
                    Console.WriteLine(column);
                }
                data.Database.ExecuteSqlCommand(@"update Java_Sets set availability = 'no' where table_name=@tablename", new SqlParameter("@tablename", free));
                data.Database.ExecuteSqlCommand(@"update Exam_List set exam_set_counts = exam_set_counts + 1 where exam_id =1");
                return("Added Successfully");
            }
            else
            {
                return("No More Set Can be Added");
            }
        }
Exemplo n.º 5
0
        public List <string> available([FromBody] filepath subject)
        {
            var free  = subject.subject + "_Sets";
            var avail = data.Database.SqlQuery <string>(@"select table_name from " + free + " where availability = 'no'").ToList();

            return(avail);
        }
Exemplo n.º 6
0
        public List <setTable> uploadSet([FromBody] filepath subject)
        {
            var free  = subject.subject + "_Sets";
            var avail = data.Database.SqlQuery <setTable>(@"select table_name, availability from " + free).ToList();

            return(avail);
        }
Exemplo n.º 7
0
        private void CreateDirAndDownLoad(filepath entity)
        {
            var path = entity.file_Path;

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            var dirName = entity.file_innerTxt;

            //List<string> dirPathNameList = _dirPathList.Where(item => item.file_Path == entity.file_parent_path).Select(item => item.file_innerTxt).Distinct( ).ToList();
            //string dealString = (string.IsNullOrEmpty(dirName) ? (dirPathNameList.Count != 0 ? dirPathNameList[0].ToString( ) : (fileNames[fileNames.Length - 3] + @"\"
            //      + fileNames[fileNames.Length - 2])) : dirName);
            //dealString = dealString.ToCharArray( ).Where(ch => !(@"\/*|:?*<> ".ToCharArray( ).Contains(ch))).Aggregate(string.Empty, ( f, ch ) => f + ch);

            try
            {
                var fileNames = path.Split('/');
                if (fileNames.Length == 0)
                {
                    return;
                }
                var fileName = fileNames[fileNames.Length - 1];

                var dealString = string.IsNullOrEmpty(dirName)
                    ? fileNames[fileNames.Length - 3] + @"\"
                                 + fileNames[fileNames.Length - 2]
                    : dirName;
                //处理目录中非法的字符
                dealString =
                    dealString.ToCharArray()
                    .Where(ch => !@"\/*|:?*<> ".ToCharArray().Contains(ch))
                    .Aggregate(string.Empty, (f, ch) => f + ch);
                var createDir =
                    (SaveFilePath.EndsWith(@"\") ? SaveFilePath : SaveFilePath + @"\")
                    + dealString + @"\";

                if (!Directory.Exists(createDir))
                {
                    try
                    {
                        Directory.CreateDirectory(createDir);
                    }
                    catch
                    {
                        MyMessageBox.Add(string.Format("路径 {0} 存在错误!文件名 {1} ", createDir, fileName));
                        Console.WriteLine("路径 {0} 存在错误!文件名 {1} ", createDir, fileName);
                    }
                }
                fileName = createDir + fileName;
                Tool.DownLoad(path, fileName);
                //  Console.WriteLine("线程 {0} 执行完了! 下载地址 {1} 本机地址 {2} ", Thread.CurrentThread.ManagedThreadId, path, fileName);
            }
            catch (Exception)
            {
                // Console.WriteLine(e.Data + "\n" + e.Message);
            }
        }
Exemplo n.º 8
0
        public string removeJava([FromBody] filepath set)
        {
            var free = "javaQuestion" + set.set;

            data.Database.ExecuteSqlCommand(@"truncate table javaQuestion" + set.set);
            data.Database.ExecuteSqlCommand(@"update Java_Sets set availability = 'yes' where table_name=@tablename", new SqlParameter("@tablename", free));
            data.Database.ExecuteSqlCommand(@"update Exam_List set exam_set_counts = exam_set_counts - 1 where exam_id =1");
            return("Deleted");
        }
Exemplo n.º 9
0
    public void PostData()
    {
        filepath fp = new filepath();

        fp.file_path = Application.persistentDataPath + "/ocrtext.txt";

        string json = JsonUtility.ToJson(fp);

        StartCoroutine(PostRequest("http://127.0.0.1:5000/list_add", json));
    }
Exemplo n.º 10
0
        public List <questionR> level2([FromBody] filepath filepath)
        {
            var free   = filepath.subject + "_Sets";
            var avail  = data.Database.SqlQuery <string>(@"select table_name from " + free + " where availability = 'no'").ToList();
            var random = new Random();
            int index  = random.Next(avail.Count);

            char[] questionSet = avail[index].ToArray();
            filepath.set = questionSet[questionSet.Length - 1].ToString();
            var all = data.Database.SqlQuery <questionR>(@"select top 20  sno,question,option1, option2, option3, option4, [correct option] as correct_option, difficulty from " + filepath.subject + "Question" + filepath.set + " where difficulty = 'medium' order by NEWID()").ToList();

            return(all);
        }
Exemplo n.º 11
0
        public void InsertfilePath(string path, string innerTxt, int fileType, int file_status_id, string URL)
        {
            filepath filepath = new filepath( )
            {
                file_Path        = path,
                file_innerTxt    = innerTxt,
                file_Type_id     = fileType,
                file_status_id   = file_status_id,
                file_CreateTime  = DateTime.Now,
                file_parent_path = URL
            };

            Tool.InsertfilePathByLinq(filepath);
            //  InfoDAL.InsertfilePath(path, innerTxt, fileType, file_status_id, URL);
        }
        public void FillMusicAndPath(List<string> PathOndevice)
        {
            using (var musik = new pcindexEntities())
            {
                var pathlist = (from p in musik.filepaths
                                         select p.FilePath1
                                        ).ToList();

                PathOndevice = listcompair(PathOndevice, pathlist);

                if (PathOndevice.Count >= 1)
                {

                    foreach (var onpath in PathOndevice)
                    {
                        var path = new filepath();
                        path.Device_UUIDDevice = _GUIDDevice;
                        path.UUIDPath = Guid.NewGuid().ToString();
                        path.FilePath1 = onpath;
                        musik.filepaths.Add(path);
                        musik.SaveChanges();

                        IFileIndexer indexer = new FolderAndFileReader();
                        indexer.SetIndexPath(onpath);

                        List<IMetadataReader> mdata = indexer.GetMetaData();

                        FillAAG(mdata);
                        fillMusicdata(mdata,path.UUIDPath);

                    }

                }

            }
            //see if pathes is allready is assigned to ip
            // if not add pathes
        }
Exemplo n.º 13
0
 public static void InsertfilePathByLinq(filepath filepath)
 {
     new BaseDataQuery <filepath>().Add(filepath);
 }
Exemplo n.º 14
0
 protected void setupForGeneratedItem(string __outputFilename)
 {
     outputpath = new filepath(__outputFilename);
 }
Exemplo n.º 15
0
 protected void setupForTemplatedItem(string __sourcepath)
 {
     sourcepath = new filepath(__sourcepath);
 }
Exemplo n.º 16
0
 /// <summary>
 /// 将实体数据插入到filepath
 /// </summary>
 /// <param name="filepath"></param>
 public static void InsertfilePathByLinq(filepath filepath)
 {
     InfoDal.InsertfilePathByLinq(filepath);
 }