Ejemplo n.º 1
0
 public ProcessFile(ILogger <ProcessFile> logger, ReadFromFile readFromFile,
                    WriteTextFile writeTextFile, MoveFile moveFile)
 {
     _logger        = logger;
     _readFromFile  = readFromFile;
     _writeTextFile = writeTextFile;
     _moveFile      = moveFile;
     _logger.LogWarning("Iniciado processamento do arquivo de entrada.");
 }
Ejemplo n.º 2
0
        public FileIn(WriteTextFile writeTextFile, MoveFile moveFile, string fileName,
                      List <string> fileLines)
        {
            _writeTextFile = writeTextFile;
            _moveFile      = moveFile;
            Name           = fileName;
            _fileLines     = fileLines;
            _pathFolderOut = $@"{Directory.GetCurrentDirectory()}\{FolderOut}";

            ProcessSalesman();
            ProcessClient();
            ProcessSale();
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 动态设置Iframe路径
    /// </summary>
    /// <param name="url">url</param>
    public void Setframe(string url)
    {
        string parm    = url.Substring(0, url.LastIndexOf("/") + 1);
        string PdfPath = "";
        bool   exist   = true;
        int    count   = 0;

        while (exist)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath(url)))
            {
                bool b = true;
                int  i = 0;
                while (string.IsNullOrEmpty(PdfPath) || b)
                {
                    MoveFile mf = new MoveFile("/Preview");
                    mf.DeleteFile(HttpContext.Current.Server.MapPath(url));
                    string path = mf.GetFilePath(HttpContext.Current.Server.MapPath(url)).Replace("\\", "/");
                    PdfPath = path;
                    FileInfo info = new FileInfo(HttpContext.Current.Server.MapPath(PdfPath));
                    if (info.Exists && info.Length > 1000)
                    {
                        b     = false;
                        exist = false;
                    }
                    ++i;
                    //Thread.Sleep(i * 100);
                }
            }
            else
            {
                if (count >= 100)
                {
                    PrinterLOG.WriterLog(@"Cannot find the file:" + url, "Setframe", true);
                    break;
                }
                ++count;
                exist = true;
                Thread.Sleep(500);
            }
        }

        HttpContext.Current.Response.Write(PdfPath + "?datetime=" + parm);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 动态设置Iframe路径
    /// </summary>
    /// <param name="url">url</param>
    public void Setframe(string url)
    {
        string   parm    = url.Substring(0, url.LastIndexOf("/") + 1);
        string   PdfPath = "";
        bool     exist   = true;
        DateTime dt1     = new DateTime();

        while (exist)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath(url)))
            {
                bool b = true;
                int  i = 0;
                while (string.IsNullOrEmpty(PdfPath) || b)
                {
                    MoveFile mf = new MoveFile("/Preview");
                    mf.DeleteFile(HttpContext.Current.Server.MapPath(url));
                    string path = mf.GetFilePath(HttpContext.Current.Server.MapPath(url)).Replace("\\", "/");
                    PdfPath = path;
                    FileInfo info = new FileInfo(HttpContext.Current.Server.MapPath(PdfPath));
                    if (info.Exists && info.Length > 1000)
                    {
                        b     = false;
                        exist = false;
                    }
                    ++i;
                    Thread.Sleep(i * 100);
                }
            }
            else
            {
                TimeSpan ts = new DateTime() - dt1;
                if (ts.Minutes == 60)
                {
                    break;
                }
                exist = true;
                Thread.Sleep(3000);
            }
        }

        HttpContext.Current.Response.Write(PdfPath + "?datetime=" + parm);
    }
Ejemplo n.º 5
0
        internal override ICommand Parse(string userInput)
        {
            string[]      inputArguments = SplitInputArguments(userInput);
            string        commandName    = $"{inputArguments[0]} {inputArguments[1]}".ToLower();
            List <string> commandOptions = ParseCommandOptions(inputArguments);
            ICommand      parsedCommand;

            switch (commandName)
            {
            case SupportedCommandConstants.FileDelete:
                parsedCommand = new DeleteFile(_fileService, commandOptions);
                break;

            case SupportedCommandConstants.FileDownload:
                parsedCommand = new DownloadFile(_fileService, commandOptions);
                break;

            case SupportedCommandConstants.FileInfo:
                parsedCommand = new InfoFile(_fileService, commandOptions);
                break;

            case SupportedCommandConstants.FileMove:
                parsedCommand = new MoveFile(_fileService, commandOptions);
                break;

            case SupportedCommandConstants.FileUpload:
                parsedCommand = new UploadFile(_fileService, commandOptions);
                break;

            case SupportedCommandConstants.UserInfo:
                parsedCommand = new InfoUser(_fileService);
                break;

            default: throw new Exception("Non-existent command!");
            }

            return(parsedCommand);
        }
Ejemplo n.º 6
0
        public static string[] SplitedString; // The Splited String
        public static void ReadAsync(string Command)
        {
            SplitedString = Command.Split(' '); // The Splited String

            // Format the current Taiyou Line
            for (int i = 0; i < SplitedString.Length; i++)
            {
                // FORMATATION
                SplitedString[i] = SplitedString[i].Replace("%N", Environment.NewLine); // New Line

                for (int i2 = 0; i2 < GlobalVars_String_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$STRING_" + GlobalVars_String_Names[i2] + "$", GlobalVars_String_Content[i2].Replace(" ", ""));
                }
                for (int i2 = 0; i2 < GlobalVars_Bool_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$BOOL_" + GlobalVars_Bool_Names[i2] + "$", Convert.ToString(GlobalVars_Bool_Content[i2]));
                }
                for (int i2 = 0; i2 < GlobalVars_Int_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$INT_" + GlobalVars_Int_Names[i2] + "$", Convert.ToString(GlobalVars_Int_Content[i2]));
                }
                for (int i2 = 0; i2 < GlobalVars_Float_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$FLOAT_" + GlobalVars_Float_Names[i2] + "$", Convert.ToString(GlobalVars_Float_Content[i2]));
                }



                if (SplitedString[i].Contains("%RANDOM%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    Random   RND = new Random();

                    SplitedString[i] = SplitedString[i].Replace("%RANDOM%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(RND.Next(Convert.ToInt32(Arg1), Convert.ToInt32(Arg2))));
                }

                if (SplitedString[i].Contains("%ADD%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');

                    string Arg1       = SubSplitedString[2]; // Number 1
                    string Arg2       = SubSplitedString[3]; // Number 2
                    int    MathResult = Convert.ToInt32(Arg1) + Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%ADD%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%DECREASE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = Convert.ToInt32(Arg1) - Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%DECREASE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%MULTIPLY%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // MultiplyTimes
                    int      MathResult       = Convert.ToInt32(Arg1) * Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%MULTIPLY%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%DIVIDE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = Convert.ToInt32(Arg1) / Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%DIVIDE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%DIFERENCE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = Math.Abs(Convert.ToInt32(Arg1) - Convert.ToInt32(Arg2));


                    SplitedString[i] = SplitedString[i].Replace("%DIFERENCE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%PERCENTAGE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = (int)Math.Round((double)(100 * Convert.ToInt32(Arg1)) / Convert.ToInt32(Arg2));


                    SplitedString[i] = SplitedString[i].Replace("%PERCENTAGE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%LOCATION_OF%"))
                {
                    string[]  SubSplitedString = SplitedString[i].Split('%');
                    string    Arg1             = SubSplitedString[2]; // Render Type
                    string    Arg2             = SubSplitedString[3]; // Render Name
                    string    Arg3             = SubSplitedString[4]; // Value Type
                    Rectangle RectObject       = GlobalVars_Rectangle_Content[RenderQuee.Main.RenderCommand_RectangleVar.IndexOf(Arg2)];

                    int RenderNameIndex = -1;
                    if (Arg1 == "SPRITE")
                    {
                        RenderNameIndex = RenderQuee.Main.RenderCommand_Name.IndexOf(Arg2);
                    }
                    ;
                    if (Arg1 == "TEXT")
                    {
                        RenderNameIndex = RenderQuee.Main.TextRenderCommand_Name.IndexOf(Arg2);
                    }
                    ;
                    int ValToReturn = 0;
                    if (Arg3 == "X" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.X;
                    }
                    ;
                    if (Arg3 == "X" && Arg1 == "TEXT")
                    {
                        ValToReturn = RenderQuee.Main.TextRenderCommand_X[RenderNameIndex];
                    }

                    if (Arg3 == "Y" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.Y;
                    }
                    ;
                    if (Arg3 == "Y" && Arg1 == "TEXT")
                    {
                        ValToReturn = RenderQuee.Main.TextRenderCommand_Y[RenderNameIndex];
                    }
                    ;

                    if (Arg3 == "W" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.Width;
                    }
                    ;
                    if (Arg3 == "H" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.Height;
                    }
                    ;


                    SplitedString[i] = SplitedString[i].Replace("%LOCATION_OF%" + Arg1 + "%" + Arg2 + "%" + Arg3 + "%", Convert.ToString(ValToReturn));
                }

                if (SplitedString[i].Contains("%COLOR_VALUE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // ColorVarName
                    string   Arg2             = SubSplitedString[3]; // CodeName
                    int      ColorVarIndex    = GlobalVars_Color_Names.IndexOf(Arg1);
                    string   ValToReturn      = "0";
                    if (ColorVarIndex == -1)
                    {
                        throw new Exception("Color Variable [" + Arg1 + "] does not exist.");
                    }

                    if (Arg2.Equals("R"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].R);
                    }
                    ;
                    if (Arg2.Equals("G"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].G);
                    }
                    ;
                    if (Arg2.Equals("B"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].B);
                    }
                    ;
                    if (Arg2.Equals("A"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].A);
                    }
                    ;
                    if (Arg2.Equals("ALL"))
                    {
                        ValToReturn = GlobalVars_Color_Content[ColorVarIndex].R + "," + GlobalVars_Color_Content[ColorVarIndex].G + "," + GlobalVars_Color_Content[ColorVarIndex].B + "," + GlobalVars_Color_Content[ColorVarIndex].A;
                    }
                    ;


                    SplitedString[i] = SplitedString[i].Replace("%COLOR_VALUE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(ValToReturn));
                }


                if (SplitedString[i].Contains("%LIST_VALUE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   ValToReturn      = "null_or_incorrect";
                    string   Arg1             = SubSplitedString[2]; // ListType
                    string   Arg2             = SubSplitedString[3]; // ListName
                    string   Arg3             = SubSplitedString[4]; // Index

                    if (Arg1.Equals("STRING"))
                    {
                        int ListNameIndex = GlobalVars_StringList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        ValToReturn = GlobalVars_StringList_Content[ListNameIndex][Index];
                    }

                    if (Arg1.Equals("INT"))
                    {
                        int ListNameIndex = GlobalVars_IntList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        ValToReturn = Convert.ToString(GlobalVars_IntList_Content[ListNameIndex][Index]);
                    }

                    if (Arg1.Equals("COLOR"))
                    {
                        int ListNameIndex = GlobalVars_ColorList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        Color  ColorGetted       = GlobalVars_ColorList_Content[ListNameIndex][Index];
                        string ColorCodeToReturn = ColorGetted.R + "," + ColorGetted.G + "," + ColorGetted.B + "," + ColorGetted.A;

                        ValToReturn = ColorCodeToReturn;
                    }

                    if (Arg1.Equals("FLOAT"))
                    {
                        int ListNameIndex = GlobalVars_FloatList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        ValToReturn = Convert.ToString(GlobalVars_FloatList_Content[ListNameIndex][Index]);
                    }

                    if (Arg1.Equals("RECTANGLE"))
                    {
                        int ListNameIndex = GlobalVars_RectangleList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        Rectangle RectGetted    = GlobalVars_RectangleList_Content[ListNameIndex][Index];
                        string    RectangleCode = RectGetted.X + "," + RectGetted.Y + "," + RectGetted.Width + "," + RectGetted.Height;

                        ValToReturn = Convert.ToString(RectangleCode);
                    }


                    SplitedString[i] = SplitedString[i].Replace("%LIST_VALUE%" + Arg1 + "%" + Arg2 + "%" + Arg3 + "%", Convert.ToString(ValToReturn));
                }
            }


            // Begin Command Interpretation
            if (SplitedString[0].Equals("0x0"))
            {
                Clear.Initialize();
            }
            if (SplitedString[0].Equals("0x1"))
            {
                Call.Initialize(SplitedString[1]);
            }
            if (SplitedString[0].Equals("0x2"))
            {
                Write.Initialize(SplitedString[1]);
            }
            if (SplitedString[0].Equals("0x3"))
            {
                WriteLine.Initialize(SplitedString[1]);
            }
            if (SplitedString[0].Equals("0x4"))
            {
                WriteFile.Initialize(SplitedString[1], SplitedString[2]);
            }
            if (SplitedString[0].Equals("0x5"))
            {
                TaiyouIF.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("0x6"))
            {
                Abort.Initialize();
            }
            if (SplitedString[0].Equals("0x7"))
            {
                Declare.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("0x8"))
            {
                WriteVar.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("0x9"))
            {
                MathOP.Intialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x0"))
            {
                Goto.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x1"))
            {
                FileExists.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x2"))
            {
                ReadFile.Intialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x3"))
            {
                DirectoryExists.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x4"))
            {
                DownloadServerString.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x5"))
            {
                CopyFile.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x6"))
            {
                MoveFile.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x7"))
            {
                DeleteFile.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x8"))
            {
                AddRenderQuee.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x9"))
            {
                AddEvent.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x0"))
            {
                CheckEvent.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x1"))
            {
                ChangeWindowPropertie.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x2"))
            {
                Colision.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x3"))
            {
                Reload.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x4"))
            {
                GetKeyPressed.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x5"))
            {
                AddRenderTextQuee.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x6"))
            {
                ChangeRenderProp.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("2x7"))
            {
                ChangeBackgroundColor.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("2x8"))
            {
                Undeclare.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("2x9"))
            {
                SendBGMCommand.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("3x0"))
            {
                MasterVolume.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("3x1"))
            {
                LanguageSystemManager.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("3x2"))
            {
                // FIXME Not Working
                //VarMath.Initialize(SplitedString);
            }



            if (Global.IsLowLevelDebugEnabled)
            {
                for (int i = 0; i < SplitedString.Length; i++)
                {
                    Console.Write(SplitedString[i] + " ");
                }
                Console.Write("\n");
            }
        }
Ejemplo n.º 7
0
    /// <summary>
    /// 虚拟打印
    /// </summary>
    /// <param name="GetNums">报表相关参数</param>
    /// <param name="GetMargin">打印机边距数组</param>
    /// <param name="printCount">打印份数</param>
    /// <param name="url">ref 虚拟打印生成的文件路径</param>
    /// <param name="printName">ref 打印机名称</param>
    /// <param name="fielParam">生成文件名的参数数组</param>
    /// <returns>实现打印并返回ReportDocument</returns>
    public ReportDocument VirtualPrint(string[] GetNums, double[] GetMargin, int printCount, ref string url, string folder, ref string printName, string[] fileParam)
    {
        string         msgStr = "【" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "】  准备参数 \r\n";
        ReportDocument doc    = new ReportDocument();

        try
        {
            //string folder = Server.MapPath("PDF");

            string PaperSize = "";

            string fileName = GetfileName(ref PaperSize, fileParam);   // 获取 纸张类型  ,文件名称
            if (fileParam[0].ToLower() == "blsample" && Convert.ToInt32(GetNums[4]) > -1)
            {
                fileName = fileName.Insert(fileName.LastIndexOf("_"), "_" + GetNums[4]);
            }

            if (string.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            // 设置文件类型
            string ff     = HttpContext.Current.Request["format"];
            int    format = string.IsNullOrEmpty(ff) ? 4 : Convert.ToInt32(ff);

            GetPrintName(ref printName, PaperSize, PrintImgSetting.PIS.FileFormat(format)); // 获取可用的打印机名称

            UpdatePrinterStatus(printName, 1, fileParam);                                   // 更新打印机状态

            //PrintImgSetting pis = new PrintImgSetting();    // 配置虚拟打印机 相关属性


            //文件打印像素
            int size = 240;

            // 设置文件是否连续显示
            string cm   = HttpContext.Current.Request["CreateMode"];
            int    mode = string.IsNullOrEmpty(cm) ? 0 : Convert.ToInt32(cm);

            string randomFolder = "/PreviewTemp/" + (string.IsNullOrEmpty(folder) ? DateTime.Now.ToString("hhmmssffff") : folder);

            MoveFile mf = new MoveFile();
            mf.CreateDirectory(HttpContext.Current.Server.MapPath(randomFolder));

            //设置文件目录
            //PrintImgSetting.PIS.SetFileFolder(printName, HttpContext.Current.Server.MapPath(randomFolder));
            //Thread.Sleep(300);
            //PrintImgSetting.PIS.SetFileName(printName, fileName);           //设置文件名称
            //Thread.Sleep(300);
            //PrintImgSetting.PIS.SetFileFormat(printName, format);           //设置文件路径
            //Thread.Sleep(300);
            //PrintImgSetting.PIS.SetCreateMode(printName, mode);             //设置文件连续显示
            //Thread.Sleep(300);
            PrintZanSetting.PrintSetting(printName, HttpContext.Current.Server.MapPath(randomFolder), fileName, null);


            msgStr += "【" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "】  开始打印,打印机:" + printName + " ; 用户:" + FSecurityHelper.CurrentUserDataGET()[0] + "," + FSecurityHelper.CurrentUserDataGET()[12] + " ; 报表类型:" + GetNums[0].Substring(GetNums[0].LastIndexOf("\\") + 1) + " ; SeedID :" + GetNums[3] + "\r\n";
            doc     = ToPrintPaper(GetNums, GetMargin, printCount, printName); //实现打印功能
            msgStr += "【" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "】  打印完成,开始执行预览 \r\n------------------------------------------------------\r\n";

            //打印机生成的文件路径
            url = randomFolder + "/" + fileName + "." + PrintImgSetting.PIS.FileFormat(format);

            //Thread.Sleep(1000);                             // 等待打印文件读写

            UpdatePrinterStatus(printName, 0, fileParam);              // 更新打印机状态
            PrinterLOG.WriterLog(msgStr, printName, false);

            return(doc);
            //Setframe(url);
        }
        catch (Exception exp)
        {
            PrinterLOG.WriterLog(exp.Message, printName, true);
            UpdatePrinterStatus(printName, 0, fileParam);              // 更新打印机状态
            return(null);
            //HttpContext.Current.Response.Write(exp.Message);
            //HttpContext.Current.Response.Flush();
            //HttpContext.Current.Response.Close();
        }
    }
Ejemplo n.º 8
0
 private void MoveButton_Click(object sender, EventArgs e)
 {
     MoveFile?.Invoke();
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 虚拟打印
    /// </summary>
    /// <param name="GetNums">报表相关参数</param>
    /// <param name="GetMargin">打印机边距数组</param>
    /// <param name="printCount">打印份数</param>
    /// <param name="url">ref 虚拟打印生成的文件路径</param>
    /// <param name="printName">ref 打印机名称</param>
    /// <param name="fielParam">生成文件名的参数数组</param>
    /// <returns>实现打印并返回ReportDocument</returns>
    public ReportDocument VirtualPrint(string[] GetNums, double[] GetMargin, int printCount, ref string url, string folder, ref string printName, string[] fileParam)
    {
        ReportDocument doc = new ReportDocument();

        try
        {
            //string folder = Server.MapPath("PDF");

            string PaperSize = "";

            string fileName = GetfileName(ref PaperSize, fileParam);   // 获取 纸张类型  ,文件名称
            if (fileParam[0].ToLower() == "blsample" && Convert.ToInt32(GetNums[4]) > -1)
            {
                fileName = fileName.Insert(fileName.LastIndexOf("_"), "_" + GetNums[4]);
            }

            if (string.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            GetPrintName(ref printName, PaperSize);         // 获取可用的打印机名称

            UpdatePrinterStatus(printName, 1, fileParam);   // 更新打印机状态

            //PrintImgSetting pis = new PrintImgSetting();    // 配置虚拟打印机 相关属性

            // 设置文件类型
            string ff     = HttpContext.Current.Request["format"];
            int    format = string.IsNullOrEmpty(ff) ? 4 : Convert.ToInt32(ff);

            //文件打印像素
            int size = 240;

            // 设置文件是否连续显示
            string cm   = HttpContext.Current.Request["CreateMode"];
            int    mode = string.IsNullOrEmpty(cm) ? 0 : Convert.ToInt32(cm);

            string randomFolder = "/PreviewTemp/" + (string.IsNullOrEmpty(folder) ? DateTime.Now.ToString("hhmmssffff") : folder);

            MoveFile mf = new MoveFile();
            mf.CreateDirectory(HttpContext.Current.Server.MapPath(randomFolder));

            //设置文件目录
            PrintImgSetting.PIS.SetFileFolder(printName, HttpContext.Current.Server.MapPath(randomFolder));
            Thread.Sleep(300);
            PrintImgSetting.PIS.SetFileName(printName, fileName);           //设置文件名称
            Thread.Sleep(300);
            PrintImgSetting.PIS.SetFileFormat(printName, format);           //设置文件路径
            Thread.Sleep(300);
            PrintImgSetting.PIS.SetCreateMode(printName, mode);             //设置文件连续显示
            Thread.Sleep(300);

            doc = ToPrintPaper(GetNums, GetMargin, printCount, printName);  //实现打印功能

            //打印机生成的文件路径
            url = randomFolder + "/" + fileName + "." + PrintImgSetting.PIS.FileFormat(format);

            Thread.Sleep(2000);                             // 等待打印文件读写

            UpdatePrinterStatus(printName, 0, fileParam);   // 更新打印机状态

            return(doc);
            //Setframe(url);
        }
        catch (Exception exp)
        {
            UpdatePrinterStatus(printName, 0, fileParam);              // 更新打印机状态
            return(null);
            //HttpContext.Current.Response.Write(exp.Message);
            //HttpContext.Current.Response.Flush();
            //HttpContext.Current.Response.Close();
        }
    }