private ArrayList FindNearestFiles(DateTime[] times, ArrayList allFiles, int n) { ArrayList result = new ArrayList(); for (int i = 0; i < n; i++) { foreach (DateTime time in times) { TimeSpan diff = TimeSpan.MaxValue; int minindex = 0; for (int j = 0; j < allFiles.Count; j++) { SFile sfile = (SFile)allFiles[j]; TimeSpan tmp = sfile.fileCreated - time; tmp = tmp.Duration(); if (tmp < diff) { diff = tmp; minindex = j; } } result.Add((SFile)allFiles[minindex]); allFiles.RemoveAt(minindex); } } return(result); }
public static void OnMapStart() { using (var listfileStream = new StormFileStream(SFile.OpenFileEx(IntPtr.Zero, "(listfile)", 0))) using (var listfileReader = new StreamReader(listfileStream)) { Trace.WriteLine("Files"); var listfile = listfileReader.ReadToEnd(); var files = listfile.Replace("\r\n", "*").Replace("\r", "*").Replace("\n", "*").Split('*'); for (var i = 0; i < files.Length - 1; i++) { Trace.WriteLine(" * '" + files[i] + "'"); if (files[i].EndsWith(".dll")) { using (var pluginStream = new StormFileStream(SFile.OpenFileEx(IntPtr.Zero, files[i], 0))) { var pluginBuffer = new byte[pluginStream.Length]; pluginStream.Read(pluginBuffer, 0, pluginBuffer.Length); var pluginAssembly = Assembly.Load(pluginBuffer); foreach (var t in pluginAssembly.GetTypes()) { if (typeof(IMapPlugin).IsAssignableFrom(t)) { mapPlugins.Add((IMapPlugin)Activator.CreateInstance(t)); } } } } } } foreach (var mapPlugin in mapPlugins) { mapPlugin.OnMapStart(); } }
public int SaveFile(SFile f) { string sql = "insert into userfile(fname,fcontent,fcno,funo) values('" + f.Fname + "','" + f.Fcontent + "','" + f.Fcno + "','" + f.Funo + "')"; return(SQLOperate.ExecuteSql(sql)); }
public SkladDataFile(string dir, SFile file, Encoding enc) { _soubor = file; string header = ""; int dataStartIndex = 0; var fileName = Path.Combine(dir, _soubor.ToString() + ".TXT"); var lines = File.ReadAllLines(fileName, enc); foreach (string line in lines) { dataStartIndex++; if (dataStartIndex == 1) { continue; } if (line.StartsWith("--DATA--")) { break; } header += line; } var data = lines[dataStartIndex..lines.Length];
//树列表双击事件 private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode node = treeView1.SelectedNode; if (node.Nodes.Count == 0 && node.Level == 1)//点击笔记 { SFile sf = fo.OpenFile(Convert.ToInt32(node.Tag)); rtbWdj.Text = sf.Fcontent.Trim(); myFile.Path = currentPath; myFile.Name = sf.Fname.Trim() + ".txt"; myFile.Content = sf.Fcontent.Trim(); tssWdj1.Text = sf.Fname.Trim(); } else//点击分类 { if (node.Tag.ToString() == "-1")//新建分类 { AddCategory(); } else { for (int i = 0; i < clist.Count; i++) { if (Convert.ToInt32(node.Tag.ToString()) == clist[i].Cno) { comboWdj.SelectedIndex = i; } } } } }
async void getAsync() { var a = await SFile.GetBasicPropertiesAsync(); Size = a.Size; PublDate = a.ItemDate.DateTime; Debug.WriteLine($"::Dates> {SFile.DateCreated:yy-MM-dd HHmm} - {a.DateModified:yy-MM-dd HHmm} - {a.ItemDate:yy-MM-dd HHmm} = {a.DateModified-a.ItemDate:hhmm}"); }
public MyFile SFileToMyFile(SFile sf, string username) { string sql = "select * from cate where cno = '" + sf.Fcno + "'"; string cateName = SQLOperate.QueryTable(sql).Rows[0][2].ToString().Trim(); MyFile mf = new MyFile(); mf.Path = "D:\\WdjNote\\" + username + "\\" + cateName; mf.Name = sf.Fname.Trim() + ".txt"; mf.Content = sf.Fcontent.Trim(); return(mf); }
//保存到数据库 private void 到云端ToolStripMenuItem_Click(object sender, EventArgs e) { if (CanSave()) { SFile sf = new SFile(0, tssWdj1.Text, rtbWdj.Text, category.Cno, user.Uno); fo.SaveFile(sf); MessageBox.Show("上传成功!"); LoadData(); } else { MessageBox.Show("请先打开或新建一个笔记!"); } }
public override void Push(CStream Stream_) { { Files.Clear(); Int32 Cnt = 0; Stream_.Pop(ref Cnt); for (Int32 i = 0; i < Cnt; ++i) { String Key = ""; Stream_.Pop(ref Key); SFile Value = new SFile(); Stream_.Pop(Value); Files.Add(Key, Value); } } }
public SFile OpenFile(int fno) { string sql = "select * from userfile where fno = " + fno; DataTable dt = SQLOperate.QueryTable(sql); SFile sf = null; if (dt.Rows.Count > 0) { sf = new SFile(Convert.ToInt32(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString().Trim(), dt.Rows[0][2].ToString().Trim(), Convert.ToInt32(dt.Rows[0][3].ToString()), Convert.ToInt32(dt.Rows[0][4].ToString())); } return(sf); }
public List <SFile> ReadFileByCno(int cno, int uno) { string sql = "select * from userfile where fcno='" + cno + "'and funo='" + uno + "'"; DataTable dt = SQLOperate.QueryTable(sql); List <SFile> sfList = new List <SFile>(); for (int i = 0; i < dt.Rows.Count; i++) { SFile sf = new SFile(Convert.ToInt32(dt.Rows[i][0].ToString()), dt.Rows[i][1].ToString().Trim(), dt.Rows[i][2].ToString().Trim(), Convert.ToInt32(dt.Rows[i][3].ToString()), Convert.ToInt32(dt.Rows[i][4].ToString())); sfList.Add(sf); } return(sfList); }
public static string GetNazev(string id, SFile f) { switch (f) { case SFile.CPOHYBV: return("Faktura " + id); case SFile.CPOHYBVP: return("Prodejka " + id); case SFile.CPOHYBOV: return("Ostatní výdej " + id); case SFile.CPOHYBZ: return("Zakázka " + id); case SFile.CPOHYBP: return("Příjemka " + id); case SFile.KARTYINV: return("Úvodní stav zásob"); } return(id); }
public static string GetID(string id, SFile f) { switch (f) { case SFile.CPOHYBV: return("FA" + id); case SFile.CPOHYBVP: return("VP" + id); case SFile.CPOHYBOV: return("OV" + id); case SFile.CPOHYBZ: return("ZA" + id); case SFile.CPOHYBP: return("PR" + id); case SFile.KARTYINV: return("PR" + id); } return(id); }
public IActionResult Upload(SFile file) { //lets find out if the file exist if (file.myFile.Name != null) { var fullPath = Path.GetFullPath(file.myFile.FileName); Debug.WriteLine("file : " + fullPath); filesLists.Add(file); // upload the file to amazon s3 _s3_adapter.uploadFile(fullPath); // save the link of the file to dynamodb _db_adapter.insertFile(file.myFile.FileName, file.comments); } return(View("Home", filesLists)); }
private string CreateTrainTxt(DateTime[] times) { ArrayList list = new ArrayList(); foreach (string path in Directory.GetFiles(string.Format("{0}\\{1}", _biosandboxHome, _tmpSavePath))) { DateTime fileCreated = File.GetCreationTime(path); SFile sfile = new SFile(); sfile.filePath = path; sfile.fileCreated = fileCreated; list.Add(sfile); } ArrayList nearestFiles = FindNearestFiles(times, list, 1); string traintxt = string.Format("train{0}.txt", Tools.RandomString(6)); string trainpath = string.Format("{0}\\{1}", _biosandboxHome, traintxt); // Create a file to write to. if (!File.Exists(trainpath)) { using (StreamWriter sw = File.CreateText(trainpath)) { for (int i = 0; i < nearestFiles.Count; i++) { SFile nearest = (SFile)nearestFiles[i]; if (i == nearestFiles.Count - 1) { sw.Write(nearest.filePath); } else { sw.WriteLine(nearest.filePath); } } sw.Close(); } } return(traintxt); }
public void Set(SFile Obj_) { IsAdded = Obj_.IsAdded; SubVersion = Obj_.SubVersion; }
public SFile(SFile Obj_) { IsAdded = Obj_.IsAdded; SubVersion = Obj_.SubVersion; }
public SubObject(sub_object sub_object, ref int totalPrimitiveIndex, int[] hierarchy, Helpers.TextureFlags textureFlags, int subObjectIndex, SFile sFile, SharedShape sharedShape)
//rename上傳文件 public static void rename_attach(SqlCommand cmd, string prgid, int HTProgRight, string HTProgCap, string source, string source_sqlno, string attach_sqlno) { //系統文件(舊): //web01:將文件從web01/job/data/temp 移到 web01/job/data/sysdoc //sin20:將文件從sin20/job/data/temp 移到 \\sin07\systemDoc //web08:將文件從\\web08\data\document\Njob\temp 移到 \\web08\data\document\SystemDoc //sin17:將文件從\\sin17\data$\document\Njob\temp 移到 \\sin07\systemDoc //工作管理文件 //web08:將文件從\\web08\data\document\Njob\temp\上傳人員薪號 → \\web08\data\document\文件主分類\上傳年度(西元) //sin25:將文件從\\sin17\data$\document\Njob\temp\上傳人員薪號 → \\sin07\data\document\文件主分類\上傳年度(西元) int nrec = 1; string isql = ""; string usql = ""; string attach_folder = ""; string attach_path = ""; string attach_name = ""; //求取需執行rename的檔案 isql = "SELECT a.*"; isql += ", (SELECT code_name FROM cust_code WHERE code_type = 'doc_class1' AND cust_code = a.doc_class1) AS doc_class1nm"; isql += " FROM job_attach AS a"; isql += " WHERE 1=1"; if (attach_sqlno.Length > 0) { isql += " AND a.attach_sqlno = " + Funcs.pkN(attach_sqlno); } else { isql += " AND a.source = " + Funcs.pkStr(source); isql += " AND a.source_sqlno = " + Funcs.pkN(source_sqlno); } isql += " AND a.attach_flag<>'D'"; isql += " AND ISNULL(a.rename_flag, '')<>'Y'"; isql += " ORDER BY a.attach_sqlno"; if ((HTProgRight & 512) > 0 && HttpContext.Current.Request.Form["chkTest"] != null && HttpContext.Current.Request.Form["chkTest"] == "TEST") { HttpContext.Current.Response.Write(isql + "<br/><br/>"); } cmd.CommandText = isql; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { switch (dr["source"].ToString().Trim().ToLower()) { case "job": //工作:文件主分類/上傳年度(西元) attach_folder = "upload/job/" + dr["doc_class1"].ToString().Trim() + "_" + dr["doc_class1nm"].ToString().Trim() + "/" + Convert.ToDateTime(dr["in_date"].ToString()).Year; break; case "comp_att": //廠商聯絡人 attach_folder = "upload/comp_att/" + dr["doc_class1"].ToString().Trim() + "_" + dr["doc_class1nm"].ToString().Trim() + "/" + Convert.ToDateTime(dr["in_date"].ToString()).Year; break; case "comp_job": //廠商往來紀錄 attach_folder = "upload/comp_job/" + dr["doc_class1"].ToString().Trim() + "_" + dr["doc_class1nm"].ToString().Trim() + "/" + Convert.ToDateTime(dr["in_date"].ToString()).Year; break; } //if (source == "job") // attach_name = dr["jobno"].ToString() + "_" + dr["source_name"].ToString(); //else // attach_name = dr["source_name"].ToString(); //求取原始檔案之副檔名 int n = dr["source_name"].ToString().LastIndexOf("."); string sExt = (n < 0) ? "" : dr["source_name"].ToString().Substring(n); //檔名rename規則:原始檔名+_+attach_sqlno attach_name = dr["source_name"].ToString().Replace(sExt, "") + "_" + dr["attach_sqlno"].ToString() + sExt; attach_path = attach_folder + "/" + attach_name; //檢查檔案是否存在,若存在才執行rename if (File.Exists(HttpContext.Current.Server.MapPath("~/" + dr["attach_path"].ToString()))) { if ((HTProgRight & 512) > 0 && HttpContext.Current.Request.Form["chkTest"] != null && HttpContext.Current.Request.Form["chkTest"] == "TEST") { HttpContext.Current.Response.Write("原檔名:" + dr["attach_name"].ToString() + "<br/>"); HttpContext.Current.Response.Write("新檔名:" + attach_name + "<br/>"); HttpContext.Current.Response.Write("rename後路徑:" + attach_folder + "/" + attach_name + "<br/><br/>"); } //判斷目的地檔案目錄是否存在,若不存在則建立 //if (source == "sysdoc") // SFile.create_folder(HttpContext.Current.Application["systemdoc"].ToString(), HttpContext.Current.Server.MapPath("~/" + attach_folder).Replace(HttpContext.Current.Application["systemdoc"].ToString(), "")); //else // SFile.create_folder(HttpContext.Current.Application["upload"].ToString(), HttpContext.Current.Server.MapPath("~/" + attach_folder).Replace(HttpContext.Current.Application["upload"].ToString(), "")); SFile.create_folder(HttpContext.Current.Application["upload"].ToString(), HttpContext.Current.Server.MapPath("~/" + attach_folder).Replace(HttpContext.Current.Application["upload"].ToString(), "")); //判斷目的地檔案是否存在,若存在則rename if (File.Exists(HttpContext.Current.Server.MapPath("~/" + attach_folder) + "\\" + attach_name)) { File.Move(HttpContext.Current.Server.MapPath("~/" + attach_folder) + "\\" + attach_name, HttpContext.Current.Server.MapPath("~/" + attach_folder) + "\\" + SFile.backup_file(attach_name)); } //移動檔案 File.Move(HttpContext.Current.Server.MapPath("~/" + dr["attach_path"].ToString()), HttpContext.Current.Server.MapPath("~/" + attach_folder) + "\\" + attach_name); //組usql,最後執行一次update usql += " UPDATE job_attach SET"; usql += " attach_path = " + Funcs.pkNStr(attach_path); usql += ", attach_name = " + Funcs.pkNStr(attach_name); usql += ", rename_flag = 'Y'"; usql += ", tran_date = GETDATE()"; usql += ", tran_scode = " + Funcs.pkStr(HttpContext.Current.Session["scode"].ToString()); usql += " OUTPUT 'U', GETDATE(), " + Funcs.pkStr(HttpContext.Current.Session["scode"].ToString()) + "," + Funcs.pkStr(prgid) + "," + "DELETED.* INTO job_attach_log"; usql += " WHERE attach_sqlno = " + Funcs.pkN(dr["attach_sqlno"].ToString()); usql += ";"; } } dr.Close(); if (usql.Length > 0) { //執行sql if ((HTProgRight & 512) > 0 && HttpContext.Current.Request.Form["chkTest"] != null && HttpContext.Current.Request.Form["chkTest"] == "TEST") { HttpContext.Current.Response.Write(usql + "<br/><br/>"); } cmd.CommandText = usql; nrec = cmd.ExecuteNonQuery(); if (nrec <= 0) { throw new System.Exception(HTProgCap + "-rename失敗!"); } } }