예제 #1
0
        public static void SharedCN(List <string> cnlist, string filePath, string filename, string keyword)
        {
            foreach (string cnPerson in cnlist)
            {
                string staffno = UserUtil.GetCnUserStaffNo(cnPerson);

                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_pathnew = N'{8}' 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, cnPerson, DateTime.Today.ToString("yyyy/MM/dd"), newFilePath);

                //Debug.WriteLine("Query: " + query);

                //DataService.GetInstance().ExecuteNonQuery(query);
                DataServiceMes.GetInstance().ExecuteNonQuery(query);

                UpdateFilePath(filePath, newFilePath);
            }
        }