public virtual bool DownloadFile(string url, string filename, Action <ERRORLEVEL> _OnCompleted)
 {
     DownloderAsync.__DebugOutput("AsyncDownloder.DownloadFile : " + url);
     this.ErrorString     = string.Empty;
     this.ErrorLevel      = ERRORLEVEL.SUCCESS;
     this.OnCompletedFile = _OnCompleted;
     this.client          = new WebClient();
     this.client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.OnDownloadFileProgressChanged);
     this.client.DownloadFileCompleted   += new AsyncCompletedEventHandler(this.OnCompleted_File);
     this.client.DownloadFileAsync(new Uri(url), filename);
     return(true);
 }
 public virtual bool DownloadString(string url, Action <ERRORLEVEL, string> _OnCompleted)
 {
     this.isNeedRetry       = true;
     this.OnCompletedString = _OnCompleted;
     this.ErrorString       = string.Empty;
     this.ErrorLevel        = ERRORLEVEL.SUCCESS;
     this.client            = new WebClient();
     this.client.Encoding   = Encoding.UTF8;
     this.client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(this.OnCompleted_String);
     this.client.DownloadStringAsync(new Uri(url));
     DownloderAsync.__DebugOutput("AsyncDownloder.DownloadString : " + url);
     return(true);
 }
예제 #3
0
 public static void WriteLog(string log, ERRORLEVEL errorLevel)
 {
     Logger.__wrtie_log(log, errorLevel.ToString());
 }
 public DownloderAsync()
 {
     this.ErrorString = string.Empty;
     this.ErrorLevel  = ERRORLEVEL.SUCCESS;
 }
예제 #5
0
        public static WriteableBitmap EncodeQR(this string content, Color fgcolor, Color bgcolor, ERRORLEVEL ECL)
        {
            WriteableBitmap result = new WriteableBitmap(1, 1);

            if (content.Length <= 0)
            {
                return(result);
            }

            ErrorCorrectionLevel ecl = ErrorCorrectionLevel.L;

            switch (ECL)
            {
            case ERRORLEVEL.L:
                ecl = ErrorCorrectionLevel.L;
                break;

            case ERRORLEVEL.M:
                ecl = ErrorCorrectionLevel.M;
                break;

            case ERRORLEVEL.Q:
                ecl = ErrorCorrectionLevel.Q;
                break;

            case ERRORLEVEL.H:
                ecl = ErrorCorrectionLevel.H;
                break;

            default:
                ecl = ErrorCorrectionLevel.L;
                break;
            }

            var bw = new BarcodeWriter();

            bw.Options.Width       = 1024;
            bw.Options.Height      = 1024;
            bw.Options.PureBarcode = false;
            bw.Options.Hints.Add(EncodeHintType.ERROR_CORRECTION, ecl);
            bw.Options.Hints.Add(EncodeHintType.MARGIN, 2);
            bw.Options.Hints.Add(EncodeHintType.DISABLE_ECI, true);
            bw.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");

            bw.Format   = BarcodeFormat.QR_CODE;
            bw.Renderer = new WriteableBitmapRenderer()
            {
                Foreground = fgcolor, Background = bgcolor
            };

            //var renderer = new SvgRenderer();
            //var img = renderer.Render(new BitMatrix(512), BarcodeFormat.QR_CODE, content);
            var text = content.Length > 984 ? content.Substring(0, 984) : content;

            result = bw.Write(text);
            return(result);
        }
 public virtual void OnFinish(ERRORLEVEL errorLevel, string errorString)
 {
 }