/// <summary>
        /// 对相关文件进行FTP中的操作
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="fileID">文件ID</param>
        /// <param name="sortID">类别ID</param>
        /// <param name="error">错误信息</param>
        public void OperatorFTPSystemFile(DepotManagementDataContext ctx, int fileID, int sortID)
        {
            FileServiceSocket serverFTP = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                GlobalObject.GlobalParameter.FTPServerAdvancedPassword);

            var varFile = from a in ctx.FM_FileList
                          where a.FileID == fileID
                          select a;

            FM_FileList lnqChangeFile = varFile.Single();
            FM_FileSort lnqSort       = SortInfo(sortID);

            if (lnqSort == null)
            {
                lnqChangeFile.DeleteFlag = true;
            }
            else
            {
                lnqChangeFile.SortID = sortID;
            }

            if (serverFTP.Errormessage.Length != 0)
            {
                throw new Exception(serverFTP.Errormessage);
            }
        }
        /// <summary>
        /// 删除流程
        /// </summary>
        /// <param name="sdbNo">流程编号</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回false </returns>
        public bool DeleteProcess(string sdbNo, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                string strSql = " select SDBNo,a.FileUnique,FilePath from ( " +
                                " select FileUnique,SDBNo from dbo.FM_ReviewProcess " +
                                " union all " +
                                " select AuditorFileUnique,SDBNo  from dbo.FM_ReviewProcess " +
                                " union all " +
                                " select JudgeFileUnique,SDBNo  from dbo.FM_ReviewProcess " +
                                " union all " +
                                " select FileUnique,SDBNo from  dbo.FM_ReviewProcessPointListInfo) as a " +
                                " inner join FM_FilePath as b on a.FileUnique = b.FileUnique " +
                                " where a.FileUnique is not null and SDBNo = '" + sdbNo + "'";

                DataTable tempDT = GlobalObject.DatabaseServer.QueryInfo(strSql);

                var varData = from a in ctx.FM_ReviewProcess
                              where a.SDBNo == sdbNo
                              select a;

                ctx.FM_ReviewProcess.DeleteAllOnSubmit(varData);

                if (tempDT != null)
                {
                    FileServiceSocket serverFTP = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                        GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                        GlobalObject.GlobalParameter.FTPServerAdvancedPassword);

                    foreach (DataRow dr in tempDT.Rows)
                    {
                        serverFTP.Delete(dr["FilePath"].ToString());

                        var varFileInfo = from a in ctx.FM_FilePath
                                          where a.FileUnique == (Guid)dr["FileUnique"]
                                          select a;

                        ctx.FM_FilePath.DeleteAllOnSubmit(varFileInfo);
                    }
                }

                ctx.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="guid">唯一编码</param>
        /// <param name="systemPath">系统路径</param>
        /// <param name="type">操作文件访问方式</param>
        public static void File_UpLoad(Guid guid, string systemPath, CE_CommunicationMode type)
        {
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.FM_FilePath
                              where a.FileUnique == guid
                              select a;

                if (varData.Count() == 0)
                {
                    FM_FilePath fileInfo = new FM_FilePath();

                    fileInfo.FileUnique = guid;
                    fileInfo.FilePath   =
                        "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/" + fileInfo.FileUnique.ToString();
                    fileInfo.FileType      = systemPath.Substring(systemPath.LastIndexOf("."));
                    fileInfo.OperationDate = ServerTime.Time;

                    ctx.FM_FilePath.InsertOnSubmit(fileInfo);

                    DateTime tempdateTime = ServerTime.Time;

                    if (type == CE_CommunicationMode.Socket)
                    {
                        FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverSocket.Upload(systemPath, fileInfo.FilePath);
                    }
                    else if (type == CE_CommunicationMode.FTP)
                    {
                        FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedPassword);

                        serverFTP.Upload(systemPath, fileInfo.FilePath);
                    }

                    TimeSpan span = ServerTime.Time - tempdateTime;

                    ctx.SubmitChanges();
                }
                else
                {
                    throw new Exception("文件唯一编码重复");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="type"></param>
        public static void File_Look(Guid guid, CE_CommunicationMode type)
        {
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.FM_FilePath
                              where a.FileUnique == guid
                              select a;

                if (varData.Count() == 1)
                {
                    FM_FilePath   tempPath = varData.Single();
                    string        temp     = System.Environment.GetEnvironmentVariable("TEMP");
                    DirectoryInfo info     = new DirectoryInfo(temp);
                    string        guidFile = (Guid.NewGuid()).ToString() + "\\";
                    string        filePath = info.FullName + "\\" + guidFile + tempPath.FileUnique + tempPath.FileType;

                    if (type == CE_CommunicationMode.Socket)
                    {
                        FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverSocket.Download(varData.Single().FilePath, filePath);
                    }
                    else if (type == CE_CommunicationMode.FTP)
                    {
                        FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverFTP.Download(varData.Single().FilePath, filePath);
                    }

                    System.Diagnostics.Process.Start(filePath);
                }
                else
                {
                    throw new Exception("文件唯一编码重复");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 文件删除
        /// </summary>
        /// <param name="guid">文件唯一编码</param>
        /// <param name="type">操作文件访问方式</param>
        public static void File_Delete(Guid guid, CE_CommunicationMode type)
        {
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.FM_FilePath
                              where a.FileUnique == guid
                              select a;

                if (varData.Count() == 1)
                {
                    ctx.FM_FilePath.DeleteAllOnSubmit(varData);

                    if (type == CE_CommunicationMode.Socket)
                    {
                        FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverSocket.Delete(varData.Single().FilePath);
                    }
                    else if (type == CE_CommunicationMode.FTP)
                    {
                        FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverFTP.Delete(varData.Single().FilePath);
                    }

                    ctx.SubmitChanges();
                }
                else if (varData.Count() == 0)
                {
                    return;
                }
                else
                {
                    throw new Exception("文件唯一编码重复");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 文件下载
        /// </summary>
        /// <param name="guid">文件唯一编码</param>
        /// <param name="systemPath">系统路径</param>
        /// <param name="type">操作文件访问方式</param>
        public static void File_DownLoad(Guid guid, string systemPath, CE_CommunicationMode type)
        {
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.FM_FilePath
                              where a.FileUnique == guid
                              select a;

                if (varData.Count() == 0)
                {
                    throw new Exception("文件不存在");
                }
                else if (varData.Count() == 1)
                {
                    if (type == CE_CommunicationMode.Socket)
                    {
                        FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                               GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverSocket.Download(varData.Single().FilePath, systemPath + varData.Single().FileType);
                    }
                    else if (type == CE_CommunicationMode.FTP)
                    {
                        FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                      GlobalObject.GlobalParameter.FTPServerAdvancedPassword);
                        serverFTP.Download(varData.Single().FilePath, systemPath + varData.Single().FileType);
                    }
                }
                else
                {
                    throw new Exception("文件唯一编码重复");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 更新流程
        /// </summary>
        /// <param name="billNo">单据号</param>
        /// <param name="advise">意见</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True,失败返回False</returns>
        public bool UpdateInfo(string billNo, string advise, out string error)
        {
            error = null;

            IBillMessagePromulgatorServer serverBill            = BasicServerFactory.GetServerModule <IBillMessagePromulgatorServer>();
            ISystemFileBasicInfo          m_serverFileBasicInfo = Service_Quality_File.ServerModuleFactory.GetServerModule <ISystemFileBasicInfo>();
            FileServiceSocket             m_serverFTP           = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP,
                                                                                        GlobalObject.GlobalParameter.FTPServerAdvancedUser,
                                                                                        GlobalObject.GlobalParameter.FTPServerAdvancedPassword);

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            try
            {
                var varData = from a in ctx.FM_InstitutionProcess
                              where a.BillNo == billNo
                              select a;

                FM_InstitutionProcess lnqProcess = varData.Single();

                serverBill.BillType = serverBill.GetBillTypeEnum(lnqProcess.TypeCode).ToString();
                CE_BillTypeEnum       billType   = GlobalObject.GeneralFunction.StringConvertToEnum <CE_BillTypeEnum>(serverBill.BillType);
                InstitutionBillStatus billStatus = GlobalObject.GeneralFunction.StringConvertToEnum <InstitutionBillStatus>(lnqProcess.BillStatus);

                var varList = from a in ctx.FM_InstitutionProcessPointDept
                              where a.BillNo == billNo
                              select a;

                FM_InstitutionProcessPointDept        lnqPoint = new FM_InstitutionProcessPointDept();
                List <FM_InstitutionProcessPointDept> list     = varList.ToList();
                List <string> listTemp = new List <string>();

                switch (billStatus)
                {
                case InstitutionBillStatus.新建流程:
                    break;

                case InstitutionBillStatus.等待科长审查:

                    lnqProcess.BillStatus  = InstitutionBillStatus.等待负责人审查.ToString();
                    lnqProcess.Chief       = BasicInfo.LoginName;
                    lnqProcess.ChiefAdvise = advise;
                    lnqProcess.ChiefTime   = ServerTime.Time;

                    serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                               BillFlowMessage_ReceivedUserType.角色, serverBill.GetDeptPrincipalRoleName(UniversalFunction.GetPersonnelInfo(lnqProcess.Propoer).部门编码).ToList());
                    break;

                case InstitutionBillStatus.等待负责人审查:

                    lnqProcess.BillStatus           = InstitutionBillStatus.等待相关负责人审查.ToString();
                    lnqProcess.DepartmentHead       = BasicInfo.LoginName;
                    lnqProcess.DepartmentHeadAdvise = advise;
                    lnqProcess.DepartmentHeadTime   = ServerTime.Time;

                    if (billType == CE_BillTypeEnum.制度销毁申请流程)
                    {
                        lnqProcess.BillStatus = InstitutionBillStatus.等待分管领导审查.ToString();

                        serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                   BillFlowMessage_ReceivedUserType.角色, serverBill.GetDeptLeaderRoleName(UniversalFunction.GetPersonnelInfo(lnqProcess.Propoer).部门编码).ToList());
                    }
                    else
                    {
                        listTemp = (from a in list
                                    where a.PersonnelType == RoleStyle.负责人.ToString()
                                    select a.Personnel).ToList();

                        serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                   BillFlowMessage_ReceivedUserType.用户, listTemp);
                    }

                    break;

                case InstitutionBillStatus.等待相关负责人审查:

                    lnqPoint = (from a in list
                                where a.Personnel == BasicInfo.LoginID &&
                                a.PersonnelType == RoleStyle.负责人.ToString()
                                select a).Single();

                    lnqPoint.PersonnelTime = ServerTime.Time;
                    lnqPoint.Advise        = advise;

                    var varHead = from a in list
                                  where a.PersonnelType == RoleStyle.负责人.ToString() &&
                                  a.PersonnelTime == null
                                  select a;

                    if (varHead.Count() == 0)
                    {
                        if (IsThreeTripFile(lnqProcess.SortID))
                        {
                            lnqProcess.BillStatus = InstitutionBillStatus.等待分管领导审查.ToString();

                            serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                       BillFlowMessage_ReceivedUserType.角色, serverBill.GetDeptLeaderRoleName(UniversalFunction.GetPersonnelInfo(lnqProcess.Propoer).部门编码).ToList());
                        }
                        else
                        {
                            lnqProcess.BillStatus = InstitutionBillStatus.等待相关分管领导审查.ToString();

                            listTemp = (from a in list
                                        where a.PersonnelType == RoleStyle.分管领导.ToString()
                                        select a.Personnel).ToList();

                            serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                       BillFlowMessage_ReceivedUserType.用户, listTemp);
                        }
                    }
                    else
                    {
                        listTemp = (from a in varHead
                                    select a.Personnel).ToList();

                        serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                   BillFlowMessage_ReceivedUserType.用户, listTemp);
                    }

                    break;

                case InstitutionBillStatus.等待相关分管领导审查:
                    lnqPoint = (from a in list
                                where a.Personnel == BasicInfo.LoginID &&
                                a.PersonnelType == RoleStyle.分管领导.ToString()
                                select a).Single();

                    lnqPoint.PersonnelTime = ServerTime.Time;
                    lnqPoint.Advise        = advise;

                    var varLead = from a in list
                                  where a.PersonnelType == RoleStyle.分管领导.ToString() &&
                                  a.PersonnelTime == null
                                  select a;

                    if (varLead.Count() == 0)
                    {
                        lnqProcess.BillStatus = InstitutionBillStatus.等待总经理审查.ToString();

                        serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                   BillFlowMessage_ReceivedUserType.角色, CE_RoleEnum.总经理.ToString());
                    }
                    else
                    {
                        listTemp = (from a in varLead
                                    select a.Personnel).ToList();

                        serverBill.PassFlowMessage(lnqProcess.BillNo, string.Format("【文件编号】:{0} 【文件名】:{1} ※※※ 等待处理", lnqProcess.FileNo, lnqProcess.FileName),
                                                   BillFlowMessage_ReceivedUserType.用户, listTemp);
                    }

                    break;

                case InstitutionBillStatus.等待分管领导审查:
                case InstitutionBillStatus.等待总经理审查:

                    lnqProcess.BillStatus           = InstitutionBillStatus.流程已结束.ToString();
                    lnqProcess.GeneralManager       = BasicInfo.LoginName;
                    lnqProcess.GeneralManagerAdvise = advise;
                    lnqProcess.GeneralManagerTime   = ServerTime.Time;

                    FM_FileList fileInfo = new FM_FileList();

                    if (lnqProcess.FileID != null)
                    {
                        var varFileInfo = from a in ctx.FM_FileList
                                          where a.FileID == lnqProcess.FileID
                                          select a;

                        if (varFileInfo.Count() == 1)
                        {
                            fileInfo = varFileInfo.Single();
                        }
                    }

                    if (billType == CE_BillTypeEnum.制度发布流程)
                    {
                        string strVersion = "1.0";

                        if (lnqProcess.ReplaceFileID == null)
                        {
                            DataTable dtTemp = m_serverFileBasicInfo.GetFilesInfo(lnqProcess.FileNo, null);
                        }
                        else
                        {
                            m_serverFileBasicInfo.OperatorFTPSystemFile(ctx, Convert.ToInt32(lnqProcess.ReplaceFileID), 29);
                            strVersion =
                                (Convert.ToDouble(m_serverFileBasicInfo.GetFile(Convert.ToInt32(lnqProcess.ReplaceFileID)).Version) + 0.1).ToString();
                        }

                        FM_FileList lnqFile = new FM_FileList();

                        lnqFile.Department = lnqProcess.Department;
                        lnqFile.FileName   = lnqProcess.FileName;
                        lnqFile.FileNo     = lnqProcess.FileNo;
                        lnqFile.FileUnique = lnqProcess.FileUnique;
                        lnqFile.SortID     = lnqProcess.SortID;
                        lnqFile.Version    = strVersion;

                        ctx.FM_FileList.InsertOnSubmit(lnqFile);

                        if (m_serverFTP.Errormessage.Length != 0)
                        {
                            throw new Exception(m_serverFTP.Errormessage);
                        }
                    }
                    else if (billType == CE_BillTypeEnum.制度修订废弃申请流程 && lnqProcess.OperationMode == "废弃")
                    {
                        if (fileInfo != null)
                        {
                            fileInfo.SortID = 29;
                        }
                    }
                    else if (billType == CE_BillTypeEnum.制度销毁申请流程)
                    {
                        ctx.FM_FileList.DeleteOnSubmit(fileInfo);
                    }

                    serverBill.EndFlowMessage(lnqProcess.BillNo,
                                              string.Format("{0}号文件审查流程已结束", lnqProcess.BillNo), null,
                                              (from a in varList select a.Personnel).ToList());

                    break;

                case InstitutionBillStatus.流程已结束:
                    break;

                default:
                    break;
                }

                ctx.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }