Example #1
0
        private bool UpdateAlarmFile(String cFileName)
        {
            JActiveTable aMaster = new JActiveTable();

            aMaster.TableName = "XT_IMG_REC";

            String  cFileExt   = Path.GetExtension(cFileName);
            String  cREC_ID    = Path.GetFileName(cFileName).Replace(cFileExt, "");
            String  cWebUrl    = INIConfig.ReadString("Config", AppConfig.WEB_URL);
            String  cUrl       = "http://" + cWebUrl + "/api/dfs.ashx?UPLOAD_FIELD=UPLOAD_FLAG";
            Boolean UploadFlag = CopyUnit.PostFile(cFileName, cWebUrl);

            if (UploadFlag)
            {
                log4net.WriteLogFile("REC_ID为:" + cREC_ID + "的图片,已上传!");
                aMaster.ClearField();
                aMaster.AddField("UPLOAD_FLAG", 1);
                aMaster.AddField("UPDATE_TIME", DateUtils.getDayTimeNum());
                int iCode = WebSQL.ExecSQL(aMaster.getUpdateSQL(" REC_ID='" + cREC_ID + "' "));

                try
                {
                    File.Delete(cFileName);
                }
                catch (Exception ex)
                {
                    log4net.WriteLogFile("UploadTask.Execute." + ex.Message);
                }
                log4net.WriteLogFile("REC_ID为:" + cREC_ID + "的图片,本删除成功!");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public bool UpdateAnalyseFile(String cFileName)
        {
            Boolean      isUpload = false;
            JActiveTable aMaster  = new JActiveTable();
            JActiveTable aSlave   = new JActiveTable();

            aSlave.TableName  = "XT_IMG_LIST";
            aMaster.TableName = "XT_IMG_REC";

            log4net.WriteLogFile("分析线程正在运行中......");
            if (String.IsNullOrWhiteSpace(cFileName))
            {
                return(false);
            }

            String          cFileExt        = Path.GetExtension(cFileName);
            String          cREC_ID         = Path.GetFileName(cFileName).Replace(cFileExt, "");
            List <KeyValue> ImageList       = IMGAI.getImageList(cFileName, iMinVal, iMaxVal, iGrayMinVal, iGrayMaxVal);
            String          cExportFileName = Application.StartupPath + "\\" + cREC_ID + ".zip";
            int             iCode           = 0;
            Boolean         MustRemoveFile  = false;

            if ((ImageList != null) && (ImageList.Count > 0))
            {
                List <String> sqls = new List <string>();
                for (int k = 0; (ImageList != null) && (k < ImageList.Count); k++)
                {
                    Application.DoEvents();
                    KeyValue rowKey = ImageList[k];
                    aSlave.ClearField();
                    String cKeyID = StringEx.getString(k + 1000);
                    aSlave.AddField("ID", AutoID.getAutoID() + "_" + cKeyID);
                    aSlave.AddField("ALARM_FLAG", 0);
                    aSlave.AddField("REC_ID", cREC_ID);
                    aSlave.AddField("CREATE_TIME", DateUtils.getDayTimeNum());
                    aSlave.AddField("POINT_LIST", rowKey.Val);
                    sqls.Add(aSlave.getInsertSQL());
                }
                sqls.Insert(0, "DELETE FROM XT_IMG_REC WHERE REC_ID='" + cREC_ID + "'");
                iCode = WebSQL.ExecSQL(sqls);

                if (iCode > 0)
                {
                    if (File.Exists(cExportFileName))
                    {
                        SftpClient ftp = getAnalyseClient();
                        isUpload = CopyUnit.SSH_Upload(ftp, cExportFileName, "ANALYSE");
                    }
                }
                if (isUpload)
                {
                    MustRemoveFile = true;
                    log4net.WriteLogFile("UploadTask.文件上传成功!");
                }
                else
                {
                    log4net.WriteLogFile("UploadTask." + cREC_ID + ":文件上传失败!");
                }
            }
            else
            {
                log4net.WriteLogFile("UploadTask." + cREC_ID + ":图片拆分失败!");
                MustRemoveFile = true;
            }
            if (MustRemoveFile)
            {
                try
                {
                    File.Delete(cFileName);
                }
                catch (Exception ex)
                {
                    log4net.WriteLogFile(ex.Message);
                }
                try
                {
                    File.Delete(cExportFileName);
                }
                catch (Exception ex)
                {
                    log4net.WriteLogFile(ex.Message);
                }
            }

            aMaster.ClearField();
            if (iCode > 0)
            {
                aMaster.AddField("AI_FLAG", 1);
            }
            else
            {
                aMaster.AddField("AI_FLAG", 2);
            }
            iCode = WebSQL.ExecSQL(aMaster.getUpdateSQL(" REC_ID='" + cREC_ID + "' "));
            if (iCode > 0)
            {
                log4net.WriteLogFile("REC_ID为:" + cREC_ID + "的图片抠图成功!");
            }
            return(true);
        }