Пример #1
0
        private List <ConsignmentInfo> InitRevData(string revPath)
        {
            SearchCondition condition = new SearchCondition();

            condition.AddCondition("EnableStatus", (Int32)EnableStatus.启用, SqlOperator.Equal);
            string where = condition.BuildConditionSql().Replace("Where", "");
            List <ConsignmentInfo> list = BLLFactory <Consignment> .Instance.GetAllConsignmentInfo(where);

            // 更新consignmentInfo.Data1 确认文件是否都到期了
            foreach (ConsignmentInfo consignmentInfo in list)
            {
                string checkPath = revPath + "\\" + consignmentInfo.SysValue;
                if (!DirectoryUtil.IsExistDirectory(checkPath))
                {
                    DirectoryUtil.CreateDirectory(checkPath);
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_WARN, string.Format("系统创建了 {0} 文件夹", checkPath), typeof(FrmDealConsignment));
                }

                if (DirectoryUtil.ContainFile(checkPath, "*.*"))
                {
                    consignmentInfo.Data1 = "1";
                }
                else
                {
                    consignmentInfo.Data1 = "0";
                }
            }

            return(list);
        }
Пример #2
0
        //add by jiang 测试小红外
        public ActionResult UploadInfrared(HttpPostedFileBase fileData, string folder, int pid, int infraredid, string maxtemp, string mintemp)
        {
            if (fileData != null)
            {
                try
                {
                    ControllerContext.HttpContext.Request.ContentEncoding  = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.Charset         = "UTF-8";

                    // 文件上传后的保存路径
                    string url      = "~/UploadFiles/" + folder + "/" + DateTime.Now.ToString("yyyyMM") + "/";
                    string filePath = Server.MapPath(url);
                    DirectoryUtil.CreateDirectory(filePath);

                    string fileName      = Path.GetFileName(fileData.FileName); //原始文件名称
                    string fileExtension = Path.GetExtension(fileName);         //文件扩展名
                    //string saveName = Guid.NewGuid().ToString() + fileExtension; //保存文件名称
                    string saveName = DateTime.Now.Ticks + fileExtension;
                    fileData.SaveAs(filePath + saveName);
                    byte[] FileData   = ReadFileBytes(fileData);
                    double fileSize   = FileData.Length;
                    double fileSizeKB = fileSize / 1024;
                    fileSizeKB = Math.Round(fileSizeKB, 2);
                    string fSize = fileSizeKB + "KB";
                    string fullurl = url + saveName;
                    string imgpath = "", reportpath = "", filetype = "doc";
                    if (fileExtension.Contains("doc"))
                    {
                        reportpath = fullurl;
                        imgpath    = "";
                        filetype   = "doc";
                    }
                    else
                    {
                        reportpath = "";
                        imgpath    = fullurl;
                        filetype   = "image";
                    }
                    //string strsql = "INSERT INTO t_SM_InfraredPic(PID,ChannelID,ChannelName,PositionName,ImgPath,ImgNameOld,FileSize,MaxTemp,MinTemp,ReportPath,CommitTime,NewnCCDW,NewnIRW,NewnIRH)VALUES(" + pid + "," + channelid + ",'" + channelname + "','" + positionName + "','" + imgpath + "','" + fileName + "','" + fSize + "'," + maxtemp + "," + mintemp + ",'" + reportpath + "',getdate()," + iNewnCCDW + "," + iNewnIRW + "," + iNewnIRH + ");";
                    //strsql = strsql + "INSERT INTO t_cm_files([FileName],FilePath,FileType,FileSize,FileExtension,Modules,Fk_ID,FSource,MaxTemp,MinTemp,Remark,CommitUser,CommitTime)VALUES('" + fileName + "','" + fullurl + "','" + filetype + "','" + fSize + "','" + fileExtension + "','shuangshi',0,'pc'," + maxtemp + "," + mintemp + ",'双视上传','双视桌面版',getdate());";
                    //bll.ExecuteStoreCommand(strsql, null);
                    return(Content("success"));
                }
                catch (Exception ex)
                {
                    //return Content(ex.ToString());
                    return(Content("false"));;
                }
            }
            else
            {
                return(Content("false"));
            }
        }
Пример #3
0
        /// <summary>
        /// 根据属性配置自动保存图片
        /// </summary>
        public void AutoCaptureScreen()
        {
            DirectoryUtil.AssertDirExist(this.ImageSavePath);
            if (DirectoryUtil.IsExistDirectory(this.ImageSavePath))
            {
                string SubPath = Path.Combine(this.ImageSavePath, DateTimeHelper.GetServerDate());
                DirectoryUtil.CreateDirectory(SubPath);

                DateTime snapTime     = DateTimeHelper.GetServerDateTime2();
                string   baseFilename = snapTime.ToString("yyyy_MM_dd-HH_mm_ss");
                string   fullFilename = Path.Combine(SubPath, baseFilename);
                if (!string.IsNullOrEmpty(this.ImageExtension.Trim('.')))
                {
                    fullFilename += "." + this.ImageExtension.Trim('.');
                }
                else
                {
                    fullFilename += "." + this.ImageFormat.ToString();
                }
                CaptureScreenToFile(fullFilename, ImageFormat);
            }
        }
Пример #4
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="fileData"></param>
        /// <param name="folder"></param>
        /// <param name="pid">配电室编号</param>
        /// <param name="ctype"></param>
        /// <returns></returns>
        public ActionResult Upload(HttpPostedFileBase fileData, string folder, string ctype = "file", int pid = 1)
        {
            if (fileData != null)
            {
                try
                {
                    //备注
                    string Remark = string.Empty;
                    //上传用户
                    string CommitUser = string.Empty;
                    //资料类型(图片,视频,文档)
                    string FileType = string.Empty;
                    //来源(web,app)
                    string FSource = string.Empty;
                    //所属模块
                    string Modules = string.Empty;

                    ControllerContext.HttpContext.Request.ContentEncoding  = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.Charset         = "UTF-8";

                    // 文件上传后的保存路径
                    string url      = "~/UploadFiles/PDR/";
                    string filePath = Server.MapPath(url);

                    DirectoryUtil.CreateDirectory(filePath);

                    string fileName      = Path.GetFileName(fileData.FileName); //原始文件名称
                    string fileExtension = Path.GetExtension(fileName);         //文件扩展名
                    //string saveName = Guid.NewGuid().ToString() + fileExtension; //保存文件名称
                    string saveName = DateTime.Now.Ticks + fileExtension;
                    fileData.SaveAs(filePath + saveName);
                    byte[] FileData   = ReadFileBytes(fileData);
                    double fileSize   = FileData.Length;
                    double fileSizeKB = fileSize / 1024;
                    fileSizeKB = Math.Round(fileSizeKB, 2);
                    string fSize = fileSizeKB + "KB";

                    //上传文件到t_cm_files表

                    //资料类型(图片,视频,文档)
                    FileType = ctype;
                    //来源(web,app)
                    FSource = "web";
                    //所属模块
                    Modules = "PDR";
                    //保存到资料库t_cm_files表
                    t_cm_files obj = new t_cm_files();
                    obj.CommitTime    = DateTime.Now;
                    obj.CommitUser    = CurrentUser.UserName;
                    obj.FileName      = fileName;
                    obj.FilePath      = url + saveName;
                    obj.FileExtension = fileExtension;
                    obj.FileSize      = fSize;
                    obj.FileType      = FileType;
                    obj.Fk_ID         = pid;
                    obj.FSource       = FSource;
                    obj.MaxTemp       = 0;
                    obj.MinTemp       = 0;
                    obj.Remark        = Remark;
                    obj.Modules       = Modules;
                    bll.t_cm_files.AddObject(obj);
                    bll.SaveChanges();
                    return(Content(saveName));
                }
                catch (Exception ex)
                {
                    return(Content(ex.ToString()));
                }
            }
            else
            {
                return(Content("false"));
            }
        }
Пример #5
0
        /// <summary>
        /// 生成底单
        /// </summary>
        public void BuildImage()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            UpdateControlText1 updateControl = updateControlText;

            try
            {
                if (_list == null || _list.Count == 0)
                {
                    return;
                }
                for (int i = 0; i < _list.Count; i++)
                {
                    if (string.IsNullOrEmpty(_list[i].BillCode))
                    {
                        continue;
                    }
                    _printFileName = !string.IsNullOrEmpty(_list[i].BillCode) ? _list[i].BillCode : DateTime.Now.Ticks.ToString();
                    _tempList.Add(_list[i]);
                    ++_tempIndex;
                    // http://blog.csdn.net/szstephenzhou/article/details/12838961
                    // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
                    if (this.IsHandleCreated)
                    {
                        this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count));
                    }
                    //  2016-1-31下午 这一行代码一定要写,因为要导出模板的面单图片,所以一定要设置true,如果不想要就设置成false就行了,grid++的客服还是很不错的,qq:grid++ report  641243789
                    // _report.BackImagePrint = true;
                    // 直接调用ExportDirect方法执行导出任务,这里我只是导出图片哦
                    _report.ExportDirect(GRExportType.gretIMG, _printFileName, false, false);
                    _tempList.Clear();
                }
                if (_tempIndex > 0)
                {
                    if (ckAddSystemWaterMark.Checked)
                    {
                        string waterMarkFolder = BillPrintHelper.SaveFilePath + "\\水印底单";
                        if (!DirectoryUtil.IsExistDirectory(waterMarkFolder))
                        {
                            DirectoryUtil.CreateDirectory(waterMarkFolder);
                        }
                        var files = DirectoryUtil.GetFileNames(BillPrintHelper.SaveFilePath);
                        foreach (string file in files)
                        {
                            if (Utilities.FileUtil.FileIsExist(file))
                            {
                                // img对象一定要释放,不然内存上升,杨恒连,2016年7月24日15:25:35
                                using (var img = ImageHelper.WatermarkText(Image.FromFile(file), BaseSystemInfo.SoftFullName, ImageHelper.WatermarkPosition.BottomRight, new Font("Verdana", 10, FontStyle.Bold), new SolidBrush(Color.Blue)))
                                {
                                    string fileName = Utilities.FileUtil.GetFileNameNoExtension(file);
                                    img.Save(string.Format(waterMarkFolder + "\\" + fileName + ".png", fileName));
                                }
                            }
                        }
                    }
                    // alertBuildImageInfo.Show(this, "生成底单", string.Format("成功生成{0}张底单图片", _list.Count));
                    //   XtraMessageBox.Show(string.Format("成功生成{0}张底单图片,是否打开文件夹查看?", _list.Count), AppMessage.MSG0000, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //if ( == DialogResult.Yes)
                    //{
                    //    Process.Start(BillPrintHelper.SaveFilePath);
                    //}
                }
            }
            catch (Exception exception)
            {
                //   XtraMessageBox.Show(exception.Message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.WriteException(exception);
            }
            finally
            {
                btnBuildImage.Enabled = true;
                _tempIndex            = 0;
                if (_list != null)
                {
                    stopWatch.Stop();
                    TimeSpan ts          = stopWatch.Elapsed;
                    string   elapsedTime = string.Format("{0}分{1}秒{2}毫秒", ts.Minutes, ts.Seconds, ts.Milliseconds);
                    // http://blog.csdn.net/szstephenzhou/article/details/12838961
                    // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
                    if (this.IsHandleCreated)
                    {
                        this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count) + "  耗时:" + elapsedTime);
                    }
                }
            }
        }
 static Screenshoter()
 {
     DirectoryUtil.CreateDirectory(ResourcesUtil.ScreenshotsFolder);
 }