示例#1
0
        private static string Get_RootDirectory(FTP_PhanMem pm)
        {
            var sReturn = "";

            switch (pm)
            {
            //case FTP_PhanMem.QuanLyCongViec:
            //    sReturn = "QuanLyCongViec";
            //    break;
            //case FTP_PhanMem.NhanSu:
            //    sReturn = "NhanSu";
            //    break;
            //case FTP_PhanMem.DonHang:
            //    sReturn = "DonHang";
            //    break;
            //case FTP_PhanMem.KyThuat:
            //    sReturn = "KyThuat";
            //    break;
            //case FTP_PhanMem.SanXuat:
            //    sReturn = "SanXuat";
            //    break;
            //case FTP_PhanMem.QuanLyCongViec_M10:
            //    sReturn = "QuanLyCongViec_M10";
            //    break;
            case FTP_PhanMem.QuanLyCongViec:
                sReturn = "QuanLyCongViec";
                break;
            }
            return(sReturn);
        }
示例#2
0
        public static bool UpLoad_TaiLieuDungChung(FTP_PhanMem phanMem, FTP_FileType fileType, string fileIdentity,
                                                   string filePath, string fileName, string GhiChu)
        {
            try
            {
                if (IsFileInUse(filePath, fileName))
                {
                    BaseMessages.ShowWarningMessage("Không được mở file tải lên!");
                    return(false);
                }
                var iID_Files = 0;
                var sRootDic  = "";

                sRootDic = Get_RootDirectory(phanMem);
                //sTenFile = fileName.Substring(fileName.LastIndexOf(@"\") + 1, fileName.Length - (fileName.LastIndexOf(@"\") + 1));

                var oFile = new clsFTP_Files();
                //Insert file
                try
                {
                    oFile.ID_FileType  = (short)fileType;
                    oFile.FilePath     = "";
                    oFile.FileName     = fileName;
                    oFile.FileIdentity = fileIdentity;
                    oFile.TaiKhoan_Lap = oFile.TaiKhoan_SuaCuoi = (short)GlobalVariables.iCurrentUser;
                    oFile.Ngay_Lap     = oFile.Ngay_SuaCuoi = GlobalVariables.GetCurrentDateTime();
                    oFile.GhiChu       = GhiChu;
                    oFile.TonTai       = false;
                    oFile.Insert();
                    iID_Files = oFile.ID_Files.Value;
                }
                catch
                {
                    BaseMessages.ShowWarningMessage("Không kết nối được máy chủ!");
                    return(false);
                }
                //Tạo thư mục chứa DL
                if (!FTP_MakeDir(iID_Files.ToString(), sRootDic))
                {
                    oFile.Delete();
                    BaseMessages.ShowWarningMessage("Không kết nối được FileServer!");
                    return(false);
                }

                sRootDic = sRootDic + "/" + iID_Files;
                if (!FTP_Upload(filePath + @"\" + fileName, sRootDic))
                {
                    oFile.Delete();
                    BaseMessages.ShowWarningMessage("Không kết nối được FileServer!");
                    return(false);
                }

                oFile.FilePath = sRootDic;
                oFile.TonTai   = true;
                oFile.Update();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            return(true);
        }