Beispiel #1
0
        public override bool PrePushToRabbitMq(out string fileSavePath, out string errorMsg)
        {
            fileSavePath = string.Empty;
            errorMsg     = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(customId))
                {
                    errorMsg = "wordreport缺少customID";
                    return(false);
                }

                string sysPrimaryKey = string.Empty;
                if (!dicData.TryGetValue("SYSPRIMARYKEY", out sysPrimaryKey))
                {
                    errorMsg = "wordreport缺少SYSPRIMARYKEY";
                    return(false);
                }

                string suffix = "doc";
                if (!dicData.TryGetValue("REPORTTYPES", out suffix))
                {
                    suffix = "doc";
                }

                if (string.IsNullOrWhiteSpace(suffix))
                {
                    suffix = "doc";
                }

                //附件___blob___

                //bool hasData = false;

                if (cmdAttach != null)
                {
                    #region 附件处理

                    string relativePath = string.Format("{0}\\{1}\\{2}\\{3}.{4}",
                                                        FSSelector.GetSafeFilename(customId),
                                                        DateTime.Now.ToString("yyyy-MM"),
                                                        FSSelector.GetSafeFilename(sysPrimaryKey),
                                                        FSSelector.GetSafeFilename(pk), suffix);

                    string baseFileDir = FSSelector.GetFSWordUrl(customId);
                    string filePath    = Path.Combine(baseFileDir, relativePath);

                    string fileFolder = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fileFolder))
                    {
                        Directory.CreateDirectory(fileFolder);
                    }

                    try
                    {
                        File.WriteAllBytes(filePath, cmdAttach);
                        fileSavePath = filePath;

                        //hasData = true;
                        //dicData["WORDREPORTPATH"] = filePath;
                        //dicData["ISLOCALSTORE"] = "0";
                        //if (cmdAttach.Length >= limitedSized * 1024 * 1024)
                        //{
                        //    //标识为大型文件,通过wcf的stream模式传输
                        //    dicData["ISLOCALSTORE"] = "1";
                        //}
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.WriteErrorLog(logger, ex);
                        errorMsg = string.Format("[ErrorMsg:{0}]-[StackTrace:{1}]-[Source:{2}]",
                                                 ex.Message,
                                                 ex.StackTrace,
                                                 ex.Source);
                        return(false);
                    }

                    #endregion
                }

                #region old code

                //if (dicData.ContainsKey("IMAGE") && cmdAttach != null)
                //{
                //    var binaryIndexs = dicData["IMAGE"];
                //    if (binaryIndexs.Contains("___blob___"))
                //    {
                //        var bData = GetBinaryByIndexs(binaryIndexs);
                //        if (bData != null)
                //        {
                //            //
                //            #region 附件处理

                //            string relativePath = string.Format("{0}\\{1}\\{2}\\{3}.{4}",
                //                FSSelector.GetSafeFilename(customId),
                //                DateTime.Now.ToString("yyyy-MM"),
                //                FSSelector.GetSafeFilename(sysPrimaryKey),
                //                FSSelector.GetSafeFilename(pk),
                //                suffix);
                //            string baseFileDir = FSSelector.GetFSWordUrl(customId);
                //            string filePath = Path.Combine(baseFileDir, relativePath);

                //            string fileFolder = Path.GetDirectoryName(filePath);
                //            if (!Directory.Exists(fileFolder))
                //            {
                //                Directory.CreateDirectory(fileFolder);
                //            }

                //            try
                //            {
                //                File.WriteAllBytes(filePath, bData);
                //                hasData = true;
                //                dicData["WORDREPORTPATH"] = filePath;
                //                dicData["ISLOCALSTORE"] = "0";
                //                if (bData.Length >= limitedSized * 1024 * 1024)
                //                {
                //                    //标识为大型文件,通过wcf的stream模式传输
                //                    dicData["ISLOCALSTORE"] = "1";
                //                }
                //            }
                //            catch (Exception ex)
                //            {
                //                LoggerHelper.WriteErrorLog(logger, ex);
                //                errorMsg = string.Format("[ErrorMsg:{0}]-[StackTrace:{1}]-[Source:{2}]",
                //                    ex.Message,
                //                    ex.StackTrace,
                //                    ex.Source);
                //                return false;
                //            }


                //            #endregion

                //            //Task.Factory.StartNew(() => SaveToRavenDB(filePath, ms));
                //        }

                //    }
                //}

                #endregion

                //if (!hasData)
                //{
                //    dicData["NODATA"] = "1";
                //    LoggerHelper.WriteCustomLog(logger, "无附件 " + cmdData, "CWorkNoReport", false);
                //}

                return(true);
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog(logger, ex);
                errorMsg = ex.Message;
                return(false);
            }
        }
        public override bool PrePushToRabbitMq(out string fileSavePath, out string errorMsg)
        {
            fileSavePath = string.Empty;
            errorMsg     = string.Empty;

            if (string.IsNullOrWhiteSpace(customId))
            {
                errorMsg = "PKR据缺少customID";
                return(false);
            }

            string reportNum = string.Empty;

            if (!dicData.TryGetValue("REPORTNUM", out reportNum))
            {
                errorMsg = "PKR数据缺少reportNum";
                return(false);
            }


            //无机构id,则reportnum拼接customid
            //接收的时候只要在reportNum值前面加注册码就可以
            if (!reportNum.Contains(customId))
            {
                dicData["REPORTNUM"] = string.Format("{0}{1}", customId, reportNum);
            }


            try
            {
                #region 附件
                //附件___blob___

                //bool hasData = false;

                if (cmdAttach != null)
                {
                    string relativePath = string.Format("{0}\\{1}\\{2}.cll",
                                                        FSSelector.GetSafeFilename(customId),
                                                        DateTime.Now.ToString("yyyy-MM"),
                                                        FSSelector.GetSafeFilename(reportNum));

                    string baseFileDir = FSSelector.GetFSPKRUrl(customId);
                    string filePath    = Path.Combine(baseFileDir, relativePath);

                    string fileFolder = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fileFolder))
                    {
                        Directory.CreateDirectory(fileFolder);
                    }

                    try
                    {
                        File.WriteAllBytes(filePath, cmdAttach);
                        fileSavePath = filePath;
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.WriteErrorLog(logger, ex);
                        errorMsg = string.Format("[ErrorMsg:{0}]-[StackTrace:{1}]-[Source:{2}]",
                                                 ex.Message,
                                                 ex.StackTrace,
                                                 ex.Source);
                        return(false);
                    }
                }

                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog(logger, ex);
                errorMsg = ex.Message;
                return(false);
            }
        }
Beispiel #3
0
        public override bool PrePushToRabbitMq(out string fileSavePath, out string errorMsg)
        {
            fileSavePath = string.Empty;
            errorMsg     = string.Empty;
            if (string.IsNullOrWhiteSpace(customId))
            {
                errorMsg = "曲线数据缺少customID";
                return(false);
            }

            if (string.IsNullOrWhiteSpace(itemName))
            {
                errorMsg = "曲线数据缺少检测项目";
                return(false);
            }

            string sampleName = string.Empty;

            if (!dicData.TryGetValue("SAMPLENUM", out sampleName))
            {
                errorMsg = "曲线数据缺少样本编号";
                return(false);
            }

            try
            {
                #region 附件

                if (cmdAttach != null)
                {
                    sampleName = FSSelector.GetSafeFilename(sampleName);

                    // 270001/2017-10/CEMT/17Q030200-OO1111/PK 格式
                    string relFilePath = string.Format("{0}\\{1}\\{2}\\{3}\\{4}.txt",
                                                       FSSelector.GetSafeFilename(customId),
                                                       DateTime.Now.ToString("yyyy-MM"),
                                                       FSSelector.GetSafeFilename(itemName),
                                                       FSSelector.GetSafeFilename(sampleName),
                                                       FSSelector.GetSafeFilename(pk));
                    string baseFileDir = FSSelector.GetFSAcsUrl(customId);
                    string filePath    = Path.Combine(baseFileDir, relFilePath);

                    string fileFolder = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fileFolder))
                    {
                        Directory.CreateDirectory(fileFolder);
                    }

                    try
                    {
                        File.WriteAllBytes(filePath, cmdAttach);
                        fileSavePath = filePath;
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.WriteErrorLog(logger, ex);
                        errorMsg = string.Format("[ErrorMsg:{0}]-[StackTrace:{1}]-[Source:{2}]",
                                                 ex.Message,
                                                 ex.StackTrace,
                                                 ex.Source);
                        return(false);
                    }
                }

                #endregion



                return(true);
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog(logger, ex);
                errorMsg = ex.Message;
                return(false);
            }
        }
Beispiel #4
0
        public override bool PrePushToRabbitMq(out string fileSavePath, out string errorMsg)
        {
            fileSavePath = string.Empty;
            errorMsg     = string.Empty;
            try
            {
                if (string.IsNullOrWhiteSpace(customId))
                {
                    errorMsg = "wordreport缺少customID";
                    return(false);
                }

                string sysPrimaryKey = string.Empty;
                if (!dicData.TryGetValue("SYSPRIMARYKEY", out sysPrimaryKey))
                {
                    errorMsg = "wordreport缺少SYSPRIMARYKEY";
                    return(false);
                }

                string suffix = "doc";
                if (!dicData.TryGetValue("FILETYPE", out suffix))
                {
                    suffix = "doc";
                }

                if (string.IsNullOrWhiteSpace(suffix))
                {
                    suffix = "doc";
                }



                if (cmdAttach != null)
                {
                    #region 附件处理

                    string relativePath = string.Format("{0}\\{1}\\{2}\\{3}.{4}",
                                                        FSSelector.GetSafeFilename(customId),
                                                        DateTime.Now.ToString("yyyy-MM-dd"),
                                                        FSSelector.GetSafeFilename(sysPrimaryKey),
                                                        FSSelector.GetSafeFilename(pk),
                                                        suffix);
                    string baseFileDir = FSSelector.GetFSWordUrl(customId);
                    string filePath    = Path.Combine(baseFileDir, relativePath);

                    string fileFolder = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fileFolder))
                    {
                        Directory.CreateDirectory(fileFolder);
                    }

                    try
                    {
                        File.WriteAllBytes(filePath, cmdAttach);
                        fileSavePath = filePath;
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.WriteErrorLog(logger, ex);
                        errorMsg = string.Format("[ErrorMsg:{0}]-[StackTrace:{1}]-[Source:{2}]",
                                                 ex.Message,
                                                 ex.StackTrace,
                                                 ex.Source);
                        return(false);
                    }

                    #endregion
                }


                return(true);
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog(logger, ex);
                errorMsg = ex.Message;
                return(false);
            }
        }
Beispiel #5
0
        public override bool PrePushToRabbitMq(out string fileSavePath, out string errorMsg)
        {
            fileSavePath = string.Empty;
            errorMsg     = string.Empty;

            string sysPrimaryKey = string.Empty;
            string unitcode      = string.Empty;

            if (!dicData.TryGetValue("UNITCODE", out unitcode))
            {
                errorMsg = "t_sys_files数据缺少UNITCODE";
                return(false);
            }

            string fkey = string.Empty;

            if (!dicData.TryGetValue("FKEY", out fkey))
            {
                errorMsg = "t_sys_files数据缺少fkey";
                return(false);
            }

            sysPrimaryKey            = unitcode + fkey;
            dicData["SYSPRIMARYKEY"] = sysPrimaryKey;

            string filename = string.Empty;

            if (!dicData.TryGetValue("FILENAME", out filename))
            {
                filename = "";
            }
            if (string.IsNullOrEmpty(filename))
            {
                filename = Guid.NewGuid() + "noname.doc";
            }
            try
            {
                #region 附件

                if (cmdAttach != null)
                {
                    string relFilePath = string.Format("{0}\\{1}\\{2}",
                                                       FSSelector.GetSafeFilename(customId),
                                                       DateTime.Now.ToString("yyyy-MM"),
                                                       FSSelector.GetSafeFilename(filename));
                    string baseFileDir = FSSelector.GetFSYiWuNewCReportUrl(customId);
                    string filePath    = Path.Combine(baseFileDir, relFilePath);

                    string fileFolder = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fileFolder))
                    {
                        Directory.CreateDirectory(fileFolder);
                    }

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    try
                    {
                        File.WriteAllBytes(filePath, cmdAttach);
                        fileSavePath = filePath;

                        //hasData = true;
                        //dicData["REALDATAPATH"] = filePath;//平台的路径
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.WriteErrorLog(logger, ex);
                        errorMsg = string.Format("[ErrorMsg:{0}]-[StackTrace:{1}]-[Source:{2}]",
                                                 ex.Message,
                                                 ex.StackTrace,
                                                 ex.Source);
                        return(false);
                    }
                }


                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog(logger, ex);
                errorMsg = ex.Message;
                return(false);
            }
        }