public static void SharedJp(List <string> jplist, string filePath, string filename, string keyword) { foreach (string jpPerson in jplist) { string staffno = UserUtil.GetJpUserStaffNo(jpPerson); string id = AdUtil.GetUserIdByUsername(GlobalService.User, "kmhk.local"); string directory = @"\\kdthk-dm1\project\KDTHK-DM\littlecloud\"; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string nfilepath = filePath.Replace("''", "'"); string newFileName = Path.GetFileName(nfilepath); string newFilePath = directory + newFileName; if (!File.Exists(newFilePath)) { File.Copy(nfilepath, newFilePath, true); } if (newFilePath.Contains("'")) { newFilePath = newFilePath.Replace("'", "''"); } string query = string.Format("if not exists (select * from S_OUT_SHARE where o_path = N'{0}' and o_from = N'{4}' and o_toid = '{5}') " + "insert into S_OUT_SHARE (o_path, o_filename, o_keyword, o_fromid, o_from, o_toid, o_to, o_date, o_pathnew) values (N'{0}', N'{1}', N'{2}', '{3}', N'{4}', '{5}', N'{6}', '{7}', N'{8}')", filePath, filename, keyword, id, GlobalService.User, staffno, jpPerson, DateTime.Today.ToString("yyyy/MM/dd"), newFilePath); //DataService.GetInstance().ExecuteNonQuery(query); DataServiceMes.GetInstance().ExecuteNonQuery(query); UpdateFilePath(filePath, newFilePath); } }