public static Args parseArgs(string args, bool isAllVals = true, int beg = 0) { var argsL = Exec.ParseArgs(args); if (isAllVals) { var argsR = new Args(new string[] { }); foreach (var arg in argsL) { argsR.Vals.Add(arg); } return argsR; } else { return parseArgs(argsL, beg); } }
protected virtual CovProc RunSupported(String tid, SupportedL sp, FCfg cfg, Args args, String src, String dst_f) { CovProc cov = null; String prefix = ""; int maxw, maxh; switch (sp) { case SupportedL.Word: args.IntVal(3, out maxw, 768); args.IntVal(4, out maxh, 1024); args.StringVal(5, out prefix, ""); cov = new WordCov(src, dst_f, maxw, maxh); break; case SupportedL.Excel: args.IntVal(3, out maxw, 768); args.IntVal(4, out maxh, 1024); args.StringVal(5, out prefix, ""); cov = new ExcelCov(src, dst_f, maxw, maxh, cfg.Val("density_x", 96), cfg.Val("density_y", 96)); break; case SupportedL.PowerPoint: args.StringVal(3, out prefix, ""); cov = new PowerPointCov(src, dst_f); break; case SupportedL.Pdf: args.IntVal(3, out maxw, 768); args.IntVal(4, out maxh, 1024); args.StringVal(5, out prefix, ""); cov = new PdfCov(src, dst_f, maxw, maxh, cfg.Val("density_x", 96), cfg.Val("density_y", 96)); break; case SupportedL.Img: args.IntVal(3, out maxw, 768); args.IntVal(4, out maxh, 1024); args.StringVal(5, out prefix, ""); cov = new ImgCov(src, dst_f, maxw, maxh); break; default: throw new ArgumentException("the not supported command", "sp"); } cov.State = tid; cov.Proc = this.OnCovProc; cov.ShowLog = cfg.Val("showlog", 0) == 1; cov.Exec(); cov.Dispose(); if (prefix.Length > 0) { cov.Result.Trim(prefix); } return cov; }
protected virtual void RunSupportedProc(String tid, SupportedL sp, FCfg cfg, Args args, String cmds, String src, String dst_f) { L.I("DocCov calling Supported({2}) by (\n{0}\n) by tid({1})", cmds, tid, sp); var beg = Util.Now(); var rargs = Util.NewDict(); rargs["tid"] = tid; try { CovProc cov = this.RunSupported(tid, sp, cfg, args, src, dst_f); rargs["code"] = cov.Result.Code; if (cov.Fails.Count > 0) { rargs["err"] = String.Format("{0} exeception found, see DocCov log for detail", cov.Fails.Count); L.E("DocCov calling Supported({3}) by (\n{0}\n) by tid({1}) fail with->\n{2}\n", cmds, tid, cov.ToString(), sp); } else { rargs["data"] = cov.Result; } } catch (Exception e) { rargs["code"] = 500; rargs["err"] = String.Format("{0} exeception found, see DocCov log for detail", 1); L.E(e, "DocCov calling Supported({3}) by (\n{0}\n) by tid({1}) fail with error->{2}", cmds, tid, e.Message, sp); } var used = Util.Now() - beg; rargs["used"] = used; try { this.SendDone(rargs); L.I("DocCov calling Supported({2}) success by (\n{0}\n) by tid({1})", cmds, tid, sp); } catch (Exception e) { L.E(e, "DocCov calling Supported({3}) by (\n{0}\n) by tid({1}) fail with send done err->", cmds, tid, e.Message, sp); } }
protected virtual void RunSupported(String tid, SupportedL sp, FCfg cfg, Args args, String cmds) { String src, dst_f; if (!(args.StringVal(1, out src) && args.StringVal(2, out dst_f))) { throw new ArgumentException("Word argument is invalid, please confirm arguments using by <src dst_f maxw maxh>"); } ThreadPool.QueueUserWorkItem(this.RunSupportedProc_, new object[] { tid, sp, cfg, args, cmds, src, dst_f }); }