Esempio n. 1
0
        public void OpenFile(string path, string folder)
        {
            MethodInvoker mi = delegate
            {
                string temppath = path;
                string remoteFileName = Path.GetFileName(temppath);
                Bll_File fileInstance = new Bll_File();

                try
                {
                    fileInstance.ftp.GotoDirectory(".");
                    if (fileInstance.ftp.DirectoryExist(folder))
                    {
                        fileInstance.ftp.GotoDirectory(folder);
                        if (fileInstance.ftp.FileExist(remoteFileName))
                        {
                            string basePath = QX.Helper.XmlHelper.GetConfig("LocalPath");
                            string filename = Path.Combine(basePath, remoteFileName);
                            if (File.Exists(filename))
                            {
                                File.Delete(filename);
                            }
                            fileInstance.ftp.DownloadFile(remoteFileName, basePath);

                            System.Diagnostics.Process proc = new System.Diagnostics.Process();
                            proc.StartInfo.FileName = Path.Combine(basePath, remoteFileName);
                            ////打开资源管理器
                            //proc.StartInfo.Arguments = @"/select,"+path;
                            //选中"这个路径的"这个程序,即记事本
                            proc.Start();
                        }
                        else
                        {
                            Alert.Show("未找到与当前选中行对应的文档!");
                        }

                    }
                }
                catch (Exception ex)
                {

                }

            };

            mi.BeginInvoke(null, null);

            //           打开文件夹: sfd为SaveFileDialog的实例
            //System.Diagnostics.Process.Start("explorer.exe",sfd.FileName.Substring(0,sfd.FileName.LastIndexOf(@"\")));
            //System.Diagnostics.Process.Start("explorer.exe", "/select,"+path);
        }
Esempio n. 2
0
        private void Login()
        {
            string userName = this.txtUserName.Text.Trim();

            string password = this.txtPassword.Text.Trim();

            LoginResultEnum re = loginInstance.CheckLogin(userName, password, out CurEmp);
            Bll_File fileInstance=new Bll_File();
            switch (re)
            {
                case LoginResultEnum.Success:
                    bool isCon = true;
                    //try
                    //{
                    //    var re1 = fileInstance.ftp.DirectoryExist("Test");
                    //}
                    //catch (Exception ex)
                    //{
                    //    isCon = false;
                    //}

                    //if (isCon)
                    //{

                        Success();
                    //}
                    //else
                    //{
                    //    Alert.Show("请确认当前网络是否连通或FTP服务器已开启!");
                    //}
                    break;
                case LoginResultEnum.InValidName:
                    Alert.Show("用户名无效!");
                    break;
                case LoginResultEnum.InValidPwd:
                    Alert.Show("密码输入错误!");
                    break;
                case LoginResultEnum.NoExsist:
                    Alert.Show("当前用户已失效!");
                    break;
                case LoginResultEnum.Fail:
                    Alert.Show("登录出现异常,请查证后重新登录!");
                    break;
            }
        }
Esempio n. 3
0
        void btnDownload_Click1(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            if (DialogResult.OK == dialog.ShowDialog())
            {
                StringBuilder sb = new StringBuilder();
                string path = dialog.SelectedPath;
                Bll_File fileInstance = new Bll_File();

                List<Prod_Pool> list = GetGridCheckBoxDataForChanged();
                if (list.Count == 0)
                {
                    Alert.Show("请选择要转储的成品!");
                    return;
                }
                string currentFile = string.Empty; ;
                foreach (var l in list)
                {
                    if (!Directory.Exists(l.PRP_ProdCode))
                    {
                        Directory.CreateDirectory(l.PRP_ProdCode);
                    }
                    try
                    {
                        //成品文件夹
                        fileInstance.ftp.GotoDirectory("./" + l.PRP_ProdCode);

                        foreach (var f in fileInstance.ftp.ListFilesAndDirectories())
                        {
                            if (f.IsDirectory)
                            {
                                string tem = Path.Combine(path, l.PRP_ProdCode + "/" + f.Name);
                                if (!Directory.Exists(tem))
                                {
                                    Directory.CreateDirectory(tem);
                                }
                                fileInstance.ftp.GotoDirectory("./" + l.PRP_ProdCode + "/" + f.Name);
                                //创建文件夹成功
                                if (Directory.Exists(tem))
                                {
                                    foreach (var ff in fileInstance.ftp.ListFiles())
                                    {
                                        currentFile = ff.Name;
                                        if (File.Exists(Path.Combine(tem, currentFile)))
                                        {

                                            File.Delete(Path.Combine(tem, currentFile));
                                        }
                                        fileInstance.ftp.DownloadFile(ff.Name, tem);

                                    }
                                }

                            }
                        }
                        compInstance.SetProdChange(l);

                    }//如果发生异常则抛弃此次循环
                    catch (Exception ex)
                    {
                        //写入数据库日志
                        PlateLog.WriteError(QX.Gen.Shared.SessionConfig.UserID, QX.Gen.Shared.SessionConfig.UserName,
                            "", this.Name + "|" + this.ToString(),
                           ex.Message, PlateLog.LogMessageType.Error, ex);
                        sb.Append(currentFile).Append(",");
                        continue;
                    }
                }//end foreach

                string result = sb.ToString().TrimEnd(',');

                if (!string.IsNullOrEmpty(result))
                {
                    Alert.Show(string.Format("以下文件未能下载成功:{0}", result));
                }
                else
                {
                    Alert.Show("转储成功!");
                    BindData();
                }

            }
        }
Esempio n. 4
0
        //public void SyncProdDocument()
        //{
        //    Bll_File fileInstance = new Bll_File();
        //    if (!string.IsNullOrEmpty(GModel.PRDC_ProdCode))
        //    {
        //        var flag = fileInstance.ftp.GotoDirectory("./" + GModel.PRDC_CompNo);
        //        if (!flag)
        //        {
        //            return;
        //        }
        //        foreach (var f in fileInstance.ftp.ListFiles())
        //        {
        //            fileInstance.ftp.CopyFileToAnotherDirectoryOverWrite(f.Name, "./" + GModel.PRDC_ProdCode + "/" + GModel.PRDC_CompNo);
        //        }
        //    }
        //}
        public void SyncProdDocument()
        {
            Bll_File fileInstance = new Bll_File();
            if (!string.IsNullOrEmpty(GModel.PRDC_ProdCode))
            {
                string parent = GModel.PRDC_CompNo;
                //共享文件目标路径(零件)
                string lastpath = GlabolConfiguration.SeverPath + "\\" + parent;

                string descPath = GlabolConfiguration.SeverPath + "\\" + GModel.PRDC_ProdCode + "\\" + parent;

                if (!Directory.Exists(descPath))
                {
                    try
                    {
                        Directory.CreateDirectory(lastpath);
                    }
                    catch (Exception ex)
                    {

                    }
                }

                CopyFile(lastpath, descPath);

            }
        }
Esempio n. 5
0
        void btnDownload_Click(object sender, EventArgs e)
        {
            if (this.comGrid.Rows.Count == 0)
            {
                return;
            }
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            if (DialogResult.OK == dialog.ShowDialog())
            {
                string path = dialog.SelectedPath;
                Bll_File fileInstance = new Bll_File();
                StringBuilder sb = new StringBuilder();
                foreach (var row in this.comGrid.Rows)
                {
                    var obj = row.Cells["CCF_Directory"].Value;
                    //string filename = string.Empty;
                    try
                    {

                        if (obj == null || string.IsNullOrEmpty(obj.ToString()))
                        {
                            continue;
                        }
                        //string remotepath = Path.GetDirectoryName(obj.ToString());
                        //fileInstance.GotoDirectory("." + remotepath);
                        //string file =Path.GetFileName(obj.ToString());
                        fileInstance.DownloadFile(path, obj.ToString());
                    }
                    catch (Exception ex)
                    {
                        if (obj != null)
                        {
                            string file = Path.GetFileName(obj.ToString());
                            sb.Append(file).Append(",");
                        }
                    }
                }

                if (sb.Length != 0)
                {
                    string message = string.Format("以下文件未能成功下载:{0}", sb.ToString().Trim(','));
                    Alert.Show(message);
                }
                else
                {
                    Alert.Show("文档已完成下载!");
                }

            }
        }
Esempio n. 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cc">当前文档</param>
        public void SaveRefPath(CC_File cc)
        {
            Bll_File fileInstance = new Bll_File();
            //如果存在该文档
            if (RefCompList.Keys.Contains(cc.CCF_DCode))
            {
                var compList = RefCompList[cc.CCF_DCode];

                foreach (var comp in compList)
                {
                    string lastpath = GlabolConfiguration.SeverPath + "\\" + comp.PRDC_CompNo;
                    if (!Directory.Exists(lastpath))
                    {
                        try
                        {
                            Directory.CreateDirectory(lastpath);
                        }
                        catch (Exception ex)
                        {
                            //写入数据库日志
                            PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                                "", "CompManage 多零件同步",
                               ex.Message, PlateLog.LogMessageType.Error, ex);
                        }
                    }
                    //fileInstance.ftp.GotoDirectory(".");

                    //if (!fileInstance.ftp.DirectoryExist(comp.PRDC_CompNo))
                    //{
                    //    fileInstance.ftp.MakeDirectory(comp.PRDC_CompNo);
                    //}

                    //fileInstance.ftp.GotoDirectory("." + Path.GetDirectoryName(cc.CCF_Directory));

                    //var flag = fileInstance.ftp.CopyFileToAnotherDirectoryOverWrite(Path.GetFileName(cc.CCF_Directory), "./" + comp.PRDC_CompNo);

                    File.Copy(GlabolConfiguration.SeverPath + cc.CCF_Directory.Replace('/', '\\'), lastpath + "\\" + cc.CCF_Name + ".pdf");

                }
            }
        }
Esempio n. 7
0
        public void SyncDeleteDocument(List<CC_File> list)
        {
            Bll_File fileInstance = new Bll_File();
            try
            {
                if (!string.IsNullOrEmpty(GModel.PRDC_ProdCode))
                {

                    var flag = fileInstance.ftp.GotoDirectory("./" + GModel.PRDC_ProdCode + "/" + GModel.PRDC_CompNo);
                    if (!flag)
                    {
                        return;
                    }
                    foreach (var f in list)
                    {
                        if (fileInstance.ftp.FileExist(f.CCF_Name + ".pdf"))
                        {
                            fileInstance.ftp.DeleteFile(f.CCF_Name + ".pdf");
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                //写入数据库日志
                PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                    "", "CompManage",
                   ex.Message, PlateLog.LogMessageType.Error, ex);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 当发生删除操作时,进行文件同步
        /// </summary>
        public void DeleteDocument()
        {
            List<CC_File> deleteFile = new List<CC_File>();
            try
            {
                BLL.Bll_File fileInstance = new QX.BLL.Bll_File();
                var d = comGrid.DataSource as BindingSource;
                var list = d.List as List<Prod_Doc>;
                fileInstance.GotoDirectory("./" + GModel.PRDC_CompNo);
                //与原数据源对比
                foreach (var dd in CurrentDataSource)
                {
                    //如果已经删除则同步一次文件
                    if (list.FirstOrDefault(o => o.PRDQ_Code == dd.CCF_DCode) == null)
                    {
                        List<Prod_Doc> ll = compInstance.GetPDocBySelf(dd.CCF_DCode);
                        if (ll.Count != 1)
                        {
                            continue;
                        }
                        var flag = fileInstance.ftp.FileExist(dd.CCF_Name + ".pdf");

                        if (flag)
                        {
                            fileInstance.ftp.DeleteFile(dd.CCF_Name + ".pdf");

                            deleteFile.Add(dd);
                            compInstance.DeleteDocument(dd);

                        }

                    }
                }
            }
            catch (Exception ex)
            {
                //写入数据库日志
                PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                    "", "CompManage",
                   ex.Message, PlateLog.LogMessageType.Error, ex);
            }
            finally
            {

                SyncDeleteDocument(deleteFile);
            }
        }
Esempio n. 9
0
        public void SavePath()
        {
            Bll_Doc docInstance = new Bll_Doc();

            try
            {
                string compno = compNoEditor.Text;
                string parent = compno;
                Bll_File fileInstance = new Bll_File();
                //fileInstance.GotoDirectory(".");

                //if (!fileInstance.ftp.DirectoryExist(parent))
                //{
                //    try
                //    {

                //        fileInstance.ftp.MakeDirectory(parent);
                //    }
                //    catch
                //    {
                //        Alert.Show("请确认网路是否通畅!");
                //    }
                //}

                string lastpath = GlabolConfiguration.SeverPath + "\\" + parent;

                if (!Directory.Exists(lastpath))
                {
                    try
                    {
                        Directory.CreateDirectory(lastpath);

                    }
                    catch (Exception ex)
                    {

                    }

                }

                //fileInstance.ftp.GotoDirectory(parent);

                foreach (var file in CCFileList)
                {
                    string source = file.CCF_Directory;
                    file.CCF_Code = docInstance.GenerateCCFileCode();
                    file.CCF_Directory = "/" + parent + "/" + file.CCF_Name + ".pdf";
                    file.CCF_iType = "Comp";
                    file.CCF_CompNo = parent;
                    docInstance.AddCCFile(file);
                    File.Copy(source, lastpath + "\\" + file.CCF_Name + ".pdf", true);

                }//当前窗体对应的零件文档上传 end

                foreach (var cc in CCFileList)
                {
                    SaveRefPath(cc);
                }
            }
            catch (Exception e)
            {
                //写入数据库日志
                PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                    "", "CompManage",
                   e.Message, PlateLog.LogMessageType.Error, e);
            }//保存完毕后清除需要上传的文件
            finally
            {
                if (CCFileList.Count != 0)
                {
                    SyncProdDocument();
                }

                CCFileList = new List<CC_File>();

            }

            //if (IsDeleted)
            //{
            //    DeleteDocument();
            //}
        }
Esempio n. 10
0
        public void SavePath()
        {
            Bll_Doc docInstance = new Bll_Doc();
            Bll_File fileInstance1 = new Bll_File();

            try
            {
                var com = bmHelper.FindCtl<UltraCombo>(this.pnlGrid.Controls, "PRM_ProdCode");
                string parent = com.Value.ToString();

                string lastpath = GlabolConfiguration.SeverPath + "\\" + parent;
                if (!Directory.Exists(lastpath))
                {
                    try
                    {
                        Directory.CreateDirectory(lastpath);

                    }
                    catch (Exception ex)
                    {

                    }

                }

                foreach (var file in CCFileList)
                {
                    string source = file.CCF_Directory;
                    file.CCF_Code = docInstance.GenerateCCFileCode();
                    file.CCF_Directory = "/" + parent + "/" + file.CCF_Name + ".pdf";
                    file.CCF_iType = "ProdRepair";
                    file.CCF_CompNo = parent;
                    docInstance.AddCCFile(file);

                    File.Copy(source, lastpath + "\\" + file.CCF_Name + ".pdf", true);

                }

                //fileInstance1.GotoDirectory(".");
                //if (!fileInstance1.ftp.DirectoryExist(parent))
                //{
                //    try
                //    {
                //        fileInstance1.ftp.MakeDirectory(parent);
                //    }
                //    catch (Exception ex)
                //    {

                //    }
                //}

                //fileInstance1.ftp.GotoDirectory(parent);

                //foreach (var file in CCFileList)
                //{
                //    switch (opType)
                //    {

                //        case OperationTypeEnum.Add:
                //            {
                //                var flag = fileInstance1.ftp.UploadLocalFileWithOverWrite(file.CCF_Directory);

                //                if (flag)
                //                {

                //                    file.CCF_Code = docInstance.GenerateCCFileCode();
                //                    file.CCF_Directory = "/" + parent + "/" + file.CCF_Name + ".pdf";
                //                    file.CCF_iType = "Prod";
                //                    file.CCF_CompNo = parent;
                //                    docInstance.AddCCFile(file);
                //                }
                //                break;
                //            }
                //        case OperationTypeEnum.Edit:
                //            {

                //                var flag = fileInstance1.ftp.UploadLocalFileWithOverWrite(file.CCF_Directory);

                //                if (flag)
                //                {

                //                    file.CCF_Code = docInstance.GenerateCCFileCode();
                //                    file.CCF_Directory = "/" + parent + "/" + file.CCF_Name + ".pdf";
                //                    file.CCF_iType = "Prod";
                //                    file.CCF_CompNo = parent;
                //                    docInstance.AddCCFile(file);
                //                }

                //                break;
                //            }
                //    }

                //}//当前窗体对应的零件文档上传

            }
            catch (Exception e)
            {
                //写入数据库日志
                PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                    "", "ProdIO",
                   e.Message, PlateLog.LogMessageType.Error, e);
            }//保存完毕后清除需要上传的文件
            finally
            {

                CCFileList = new List<CC_File>();
            }

            //if (IsDeleted)
            //{
            //    DeleteDocument();
            //}
        }
Esempio n. 11
0
        /// <summary>
        /// 当发生删除操作时,进行文件同步
        /// </summary>
        public void DeleteDocument()
        {
            List<CC_File> deleteFile = new List<CC_File>();
            try
            {
                BLL.Bll_File fileInstance = new QX.BLL.Bll_File();
                var d = this.prodDocGrid.DataSource as BindingSource;
                var list = d.List as List<Prod_Doc>;
                fileInstance.GotoDirectory("./" + GModel.PRM_Code);

                foreach (var dd in CurrentDataSource)
                {
                    //如果已经删除则同步一次文件
                    if (list.FirstOrDefault(o => o.PRDQ_Code == dd.CCF_DCode) == null)
                    {

                        var flag = fileInstance.ftp.FileExist(dd.CCF_Name + ".pdf");

                        if (flag)
                        {
                            fileInstance.ftp.DeleteFile(dd.CCF_Name + ".pdf");

                            deleteFile.Add(dd);
                            compInstance.DeleteDocument(dd);

                        }

                    }
                }
            }
            catch (Exception ex)
            {
                //写入数据库日志
                PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                    "", this.Name + "|" + this.ToString(),
                   ex.Message, PlateLog.LogMessageType.Error, ex);
            }
            finally
            {
            }
        }
Esempio n. 12
0
        public void SavePath()
        {
            Bll_Doc docInstance = new Bll_Doc();

            try
            {
                string compno = compNoEditor.Text;
                string parent = compno;
                Bll_File fileInstance = new Bll_File();
                //fileInstance.GotoDirectory(".");

                //if (!fileInstance.ftp.DirectoryExist(parent))
                //{
                //    try
                //    {

                //        fileInstance.ftp.MakeDirectory(parent);
                //    }
                //    catch
                //    {
                //        Alert.Show("请确认网路是否通畅!");
                //    }
                //}

                string lastpath = GlabolConfiguration.SeverPath + "\\" + parent;

                if (!Directory.Exists(lastpath))
                {
                    try
                    {
                        Directory.CreateDirectory(lastpath);

                    }
                    catch (Exception ex)
                    {

                    }

                }

                //fileInstance.ftp.GotoDirectory(parent);

                foreach (var file in CCFileList)
                {
                    //switch (opType)
                    //{
                    //    ///添加零件的话  需要创建零件编号文件夹
                    //    case OperationTypeEnum.Add:
                    //        {
                    //var flag = fileInstance.UploadFile(file.CCF_Directory, true);

                    //var flag = fileInstance.ftp.UploadLocalFileWithOverWrite(file.CCF_Directory);

                    //if (flag)
                    //{
                    string source = file.CCF_Directory;
                    file.CCF_Code = docInstance.GenerateCCFileCode();
                    file.CCF_Directory = "/" + parent + "/" + file.CCF_Name + ".pdf";
                    file.CCF_iType = "Other";
                    file.CCF_CompNo = compno;
                    docInstance.AddCCFile(file);

                    File.Copy(source, lastpath + "\\" + file.CCF_Name + ".pdf", true);

                    //}
                    //        break;
                    //    }
                    //case OperationTypeEnum.Edit:
                    //    {

                    //        var flag = fileInstance.ftp.UploadLocalFileWithOverWrite(file.CCF_Directory);
                    //        if (flag)
                    //        {

                    //            file.CCF_Code = docInstance.GenerateCCFileCode();
                    //            file.CCF_Directory = "/" + parent + "/" + file.CCF_Name + ".pdf";
                    //            file.CCF_iType = "Comp";
                    //            file.CCF_CompNo = compno;
                    //            docInstance.AddCCFile(file);
                    //        }

                    //        break;
                    //    }
                    //}

                }//当前窗体对应的零件文档上传 end

            }
            catch (Exception e)
            {
                //写入数据库日志
                PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                    "", "OtherCompOp",
                   e.Message, PlateLog.LogMessageType.Error, e);
            }//保存完毕后清除需要上传的文件
            finally
            {
                if (CCFileList.Count != 0)
                {
                    //SyncProdDocument();
                }

                CCFileList = new List<CC_File>();

            }

            //if (IsDeleted)
            //{
            //    DeleteDocument();
            //}
        }
Esempio n. 13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cc">当前文档</param>
        public void SaveRefPath(CC_File cc)
        {
            Bll_File fileInstance = new Bll_File();
            //如果存在该文档
            if (RefCompList.Keys.Contains(cc.CCF_DCode))
            {
                var compList = RefCompList[cc.CCF_DCode];

                foreach (var comp in compList)
                {
                    string lastpath = GlabolConfiguration.SeverPath + "\\" + comp.PRDC_CompNo;
                    if (!Directory.Exists(lastpath))
                    {
                        try
                        {
                            Directory.CreateDirectory(lastpath);
                        }
                        catch (Exception ex)
                        {
                            //写入数据库日志
                            PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                                "", "CompManage 多零件同步",
                               ex.Message, PlateLog.LogMessageType.Error, ex);
                        }
                    }

                    File.Copy(GlabolConfiguration.SeverPath + cc.CCF_Directory.Replace('/', '\\'), lastpath + "\\" + cc.CCF_Name + ".pdf");

                }
            }
        }
Esempio n. 14
0
        public void OpenFile(string path)
        {
            MethodInvoker mi = delegate
            {
                string temppath = path;
                string remoteFileName = Path.GetFileName(temppath);
                Bll_File fileInstance = new Bll_File();

                fileInstance.ftp.GotoDirectory("./" + GModel.PRDC_CompNo);
                string basePath = QX.Helper.XmlHelper.GetConfig("LocalPath");
                if (fileInstance.ftp.FileExist(remoteFileName))
                {

                    string filename = Path.Combine(basePath, remoteFileName);
                    if (File.Exists(filename))
                    {

                        File.Delete(filename);
                    }
                    fileInstance.ftp.DownloadFile(remoteFileName, basePath);

                    Process proc = new Process();
                    proc.StartInfo.FileName = Path.Combine(basePath, remoteFileName);
                    ////打开资源管理器
                    //proc.StartInfo.Arguments = @"/select,"+path;
                    //选中"这个路径的"这个程序,即记事本
                    proc.Start();
                }
                else
                {
                    try
                    {
                        Process proc = new Process();
                        proc.StartInfo.FileName = Path.Combine(basePath, remoteFileName);
                        ////打开资源管理器
                        //proc.StartInfo.Arguments = @"/select,"+path;
                        //选中"这个路径的"这个程序,即记事本
                        proc.Start();
                    }
                    catch (Exception e)
                    {
                        //写入数据库日志
                        PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName,
                            "", "CompManage",
                           e.Message, PlateLog.LogMessageType.Error, e);
                    }
                }

            };

            mi.BeginInvoke(null, null);

            //           打开文件夹: sfd为SaveFileDialog的实例
            //System.Diagnostics.Process.Start("explorer.exe",sfd.FileName.Substring(0,sfd.FileName.LastIndexOf(@"\")));
            //System.Diagnostics.Process.Start("explorer.exe", "/select,"+path);
        }