RoadFlow2.1 临时演示

WorkFlowForm.cs 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web.UI.WebControls;
  6. using System.Data;
  7. namespace RoadFlow.Platform
  8. {
  9. /// <summary>
  10. /// 流程表单相关类
  11. /// </summary>
  12. public class WorkFlowForm
  13. {
  14. private RoadFlow.Data.Interface.IWorkFlowForm dataWorkFlowForm;
  15. public WorkFlowForm()
  16. {
  17. this.dataWorkFlowForm = Data.Factory.Factory.GetWorkFlowForm();
  18. }
  19. /// <summary>
  20. /// 新增
  21. /// </summary>
  22. public int Add(RoadFlow.Data.Model.WorkFlowForm model)
  23. {
  24. return dataWorkFlowForm.Add(model);
  25. }
  26. /// <summary>
  27. /// 更新
  28. /// </summary>
  29. public int Update(RoadFlow.Data.Model.WorkFlowForm model)
  30. {
  31. return dataWorkFlowForm.Update(model);
  32. }
  33. /// <summary>
  34. /// 查询所有记录
  35. /// </summary>
  36. public List<RoadFlow.Data.Model.WorkFlowForm> GetAll()
  37. {
  38. return dataWorkFlowForm.GetAll();
  39. }
  40. /// <summary>
  41. /// 查询单条记录
  42. /// </summary>
  43. public RoadFlow.Data.Model.WorkFlowForm Get(Guid id)
  44. {
  45. return dataWorkFlowForm.Get(id);
  46. }
  47. /// <summary>
  48. /// 删除
  49. /// </summary>
  50. public int Delete(Guid id)
  51. {
  52. return dataWorkFlowForm.Delete(id);
  53. }
  54. /// <summary>
  55. /// 查询记录条数
  56. /// </summary>
  57. public long GetCount()
  58. {
  59. return dataWorkFlowForm.GetCount();
  60. }
  61. /// <summary>
  62. /// 得到验证提示方式Radio字符串
  63. /// </summary>
  64. /// <returns></returns>
  65. public string GetValidatePropTypeRadios(string name, string value, string att = "")
  66. {
  67. ListItem[] items = new ListItem[]{
  68. new ListItem("弹出(alert)","0"){ Selected="0"==value},
  69. new ListItem("图标和提示信息","1"){ Selected="1"==value},
  70. new ListItem("图标","2"){ Selected="2"==value}
  71. };
  72. return RoadFlow.Utility.Tools.GetRadioString(items, name, att);
  73. }
  74. /// <summary>
  75. /// 得到流程文本框输入类型Radio字符串
  76. /// </summary>
  77. /// <returns></returns>
  78. public string GetInputTypeRadios(string name, string value, string att="")
  79. {
  80. ListItem[] items = new ListItem[]{
  81. new ListItem("明文","text"){ Selected="0"==value},
  82. new ListItem("密码","password"){ Selected="1"==value}
  83. };
  84. return RoadFlow.Utility.Tools.GetRadioString(items, name, att);
  85. }
  86. /// <summary>
  87. /// 得到待选事件选择项
  88. /// </summary>
  89. /// <returns></returns>
  90. public string GetEventOptions(string name, string value, string att = "")
  91. {
  92. ListItem[] items = new ListItem[]{
  93. new ListItem("onclick","onclick"){ Selected="onclick"==value},
  94. new ListItem("onchange","onchange"){ Selected="onchange"==value},
  95. new ListItem("ondblclick","ondblclick"){ Selected="ondblclick"==value},
  96. new ListItem("onfocus","onfocus"){ Selected="onfocus"==value},
  97. new ListItem("onblur","onblur"){ Selected="onblur"==value},
  98. new ListItem("onkeydown","onkeydown"){ Selected="onkeydown"==value},
  99. new ListItem("onkeypress","onkeypress"){ Selected="onkeypress"==value},
  100. new ListItem("onkeyup","onkeyup"){ Selected="onkeyup"==value},
  101. new ListItem("onmousedown","onmousedown"){ Selected="onmousedown"==value},
  102. new ListItem("onmouseup","onmouseup"){ Selected="onmouseup"==value},
  103. new ListItem("onmouseover","onmouseover"){ Selected="onmouseover"==value},
  104. new ListItem("onmouseout","onmouseout"){ Selected="onmouseout"==value},
  105. };
  106. return RoadFlow.Utility.Tools.GetOptionsString(items);
  107. }
  108. /// <summary>
  109. /// 得到流程值类型选择项字符串
  110. /// </summary>
  111. /// <returns></returns>
  112. public string GetValueTypeOptions(string value)
  113. {
  114. ListItem[] items = new ListItem[]{
  115. new ListItem("字符串","0"){ Selected="0"==value},
  116. new ListItem("整数","1"){ Selected="1"==value},
  117. new ListItem("实数","2"){ Selected="2"==value},
  118. new ListItem("正整数","3"){ Selected="3"==value},
  119. new ListItem("正实数","4"){ Selected="4"==value},
  120. new ListItem("负整数","5"){ Selected="5"==value},
  121. new ListItem("负实数","6"){ Selected="6"==value},
  122. new ListItem("手机号码","7"){ Selected="7"==value}
  123. };
  124. return RoadFlow.Utility.Tools.GetOptionsString(items);
  125. }
  126. /// <summary>
  127. /// 得到默认值下拉选项字符串
  128. /// </summary>
  129. /// <param name="value"></param>
  130. /// <returns></returns>
  131. public string GetDefaultValueSelect(string value)
  132. {
  133. StringBuilder options = new StringBuilder(1000);
  134. options.Append("<option value=\"\"></option>");
  135. options.Append("<optgroup label=\"组织机构相关选项\"></optgroup>");
  136. options.AppendFormat("<option value=\"u_@RoadFlow.Platform.Users.CurrentUserID.ToString()\" {0}>当前步骤用户ID</option>", "10" == value ? "selected=\"selected\"" : "");
  137. options.AppendFormat("<option value=\"@(RoadFlow.Platform.Users.CurrentUserName)\" {0}>当前步骤用户姓名</option>", "11" == value ? "selected=\"selected\"" : "");
  138. options.AppendFormat("<option value=\"@(RoadFlow.Platform.Users.CurrentDeptID)\" {0}>当前步骤用户部门ID</option>", "12" == value ? "selected=\"selected\"" : "");
  139. options.AppendFormat("<option value=\"@(RoadFlow.Platform.Users.CurrentDeptName)\" {0}>当前步骤用户部门名称</option>", "13" == value ? "selected=\"selected\"" : "");
  140. options.AppendFormat("<option value=\"u_@(new RoadFlow.Platform.WorkFlowTask().GetFirstSnderID(FlowID.ToGuid(), GroupID.ToGuid(), true))\" {0}>流程发起者ID</option>", "14" == value ? "selected=\"selected\"" : "");
  141. options.AppendFormat("<option value=\"@(new RoadFlow.Platform.Users().GetName(new RoadFlow.Platform.WorkFlowTask().GetFirstSnderID(FlowID.ToGuid(), GroupID.ToGuid(), true)))\" {0}>流程发起者姓名</option>", "15" == value ? "selected=\"selected\"" : "");
  142. options.AppendFormat("<option value=\"@(new RoadFlow.Platform.WorkFlowTask().GetFirstSnderDeptID(FlowID.ToGuid(), GroupID.ToGuid()))\" {0}>流程发起者部门ID</option>", "16" == value ? "selected=\"selected\"" : "");
  143. options.AppendFormat("<option value=\"@(new RoadFlow.Platform.Users().GetName(new RoadFlow.Platform.WorkFlowTask().GetFirstSnderDeptID(FlowID.ToGuid(), GroupID.ToGuid())))\" {0}>流程发起者部门名称</option>", "17" == value ? "selected=\"selected\"" : "");
  144. options.Append("<optgroup label=\"日期时间相关选项\"></optgroup>");
  145. options.AppendFormat("<option value=\"@(RoadFlow.Utility.DateTimeNew.ShortDate)\" {0}>短日期格式(2014-4-15)</option>", "20" == value ? "selected=\"selected\"" : "");
  146. options.AppendFormat("<option value=\"@(RoadFlow.Utility.DateTimeNew.LongDate)\" {0}>长日期格式(2014年4月15日)</option>", "21" == value ? "selected=\"selected\"" : "");
  147. options.AppendFormat("<option value=\"@(RoadFlow.Utility.DateTimeNew.ShortTime)\" {0}>短时间格式(23:59)</option>", "22" == value ? "selected=\"selected\"" : "");
  148. options.AppendFormat("<option value=\"@(RoadFlow.Utility.DateTimeNew.LongTime)\" {0}>长时间格式(23时59分)</option>", "23" == value ? "selected=\"selected\"" : "");
  149. options.AppendFormat("<option value=\"@(RoadFlow.Utility.DateTimeNew.ShortDateTime)\" {0}>短日期时间格式(2014-4-15 22:31)</option>", "24" == value ? "selected=\"selected\"" : "");
  150. options.AppendFormat("<option value=\"@(RoadFlow.Utility.DateTimeNew.LongDateTime)\" {0}>长日期时间格式(2014年4月15日 22时31分)</option>", "25" == value ? "selected=\"selected\"" : "");
  151. options.Append("<optgroup label=\"流程实例相关选项\"></optgroup>");
  152. options.AppendFormat("<option value=\"@Html.Raw(BWorkFlow.GetFlowName(FlowID.ToGuid()))\" {0}>当前流程名称</option>", "30" == value ? "selected=\"selected\"" : "");
  153. options.AppendFormat("<option value=\"@Html.Raw(BWorkFlow.GetStepName(StepID.ToGuid(), FlowID.ToGuid(), true))\" {0}>当前步骤名称</option>", "31" == value ? "selected=\"selected\"" : "");
  154. return options.ToString();
  155. }
  156. /// <summary>
  157. /// 得到默认值下拉选项字符串
  158. /// </summary>
  159. /// <param name="value"></param>
  160. /// <returns></returns>
  161. public string GetDefaultValueSelectByAspx(string value)
  162. {
  163. StringBuilder options = new StringBuilder(1000);
  164. options.Append("<option value=\"\"></option>");
  165. options.Append("<optgroup label=\"组织机构相关选项\"></optgroup>");
  166. options.AppendFormat("<option value=\"u_<%=RoadFlow.Platform.Users.CurrentUserID.ToString()%>\" {0}>当前步骤用户ID</option>", "10" == value ? "selected=\"selected\"" : "");
  167. options.AppendFormat("<option value=\"<%=RoadFlow.Platform.Users.CurrentUserName%>\" {0}>当前步骤用户姓名</option>", "11" == value ? "selected=\"selected\"" : "");
  168. options.AppendFormat("<option value=\"<%=RoadFlow.Platform.Users.CurrentDeptID%>\" {0}>当前步骤用户部门ID</option>", "12" == value ? "selected=\"selected\"" : "");
  169. options.AppendFormat("<option value=\"<%=RoadFlow.Platform.Users.CurrentDeptName%>\" {0}>当前步骤用户部门名称</option>", "13" == value ? "selected=\"selected\"" : "");
  170. options.AppendFormat("<option value=\"u_<%=new RoadFlow.Platform.WorkFlowTask().GetFirstSnderID(FlowID.ToGuid(), GroupID.ToGuid(), true)%>\" {0}>流程发起者ID</option>", "14" == value ? "selected=\"selected\"" : "");
  171. options.AppendFormat("<option value=\"<%=new RoadFlow.Platform.Users().GetName(new RoadFlow.Platform.WorkFlowTask().GetFirstSnderID(FlowID.ToGuid(), GroupID.ToGuid(), true))%>\" {0}>流程发起者姓名</option>", "15" == value ? "selected=\"selected\"" : "");
  172. options.AppendFormat("<option value=\"<%=new RoadFlow.Platform.WorkFlowTask().GetFirstSnderDeptID(FlowID.ToGuid(), GroupID.ToGuid())%>\" {0}>流程发起者部门ID</option>", "16" == value ? "selected=\"selected\"" : "");
  173. options.AppendFormat("<option value=\"<%=new RoadFlow.Platform.Users().GetName(new RoadFlow.Platform.WorkFlowTask().GetFirstSnderDeptID(FlowID.ToGuid(), GroupID.ToGuid()))%>\" {0}>流程发起者部门名称</option>", "17" == value ? "selected=\"selected\"" : "");
  174. options.Append("<optgroup label=\"日期时间相关选项\"></optgroup>");
  175. options.AppendFormat("<option value=\"<%=RoadFlow.Utility.DateTimeNew.ShortDate%>\" {0}>短日期格式(2014-4-15)</option>", "20" == value ? "selected=\"selected\"" : "");
  176. options.AppendFormat("<option value=\"<%=RoadFlow.Utility.DateTimeNew.LongDate%>\" {0}>长日期格式(2014年4月15日)</option>", "21" == value ? "selected=\"selected\"" : "");
  177. options.AppendFormat("<option value=\"<%=RoadFlow.Utility.DateTimeNew.ShortTime%>\" {0}>短时间格式(23:59)</option>", "22" == value ? "selected=\"selected\"" : "");
  178. options.AppendFormat("<option value=\"<%=RoadFlow.Utility.DateTimeNew.LongTime%>\" {0}>长时间格式(23时59分)</option>", "23" == value ? "selected=\"selected\"" : "");
  179. options.AppendFormat("<option value=\"<%=RoadFlow.Utility.DateTimeNew.ShortDateTime%>\" {0}>短日期时间格式(2014-4-15 22:31)</option>", "24" == value ? "selected=\"selected\"" : "");
  180. options.AppendFormat("<option value=\"<%=RoadFlow.Utility.DateTimeNew.LongDateTime%>\" {0}>长日期时间格式(2014年4月15日 22时31分)</option>", "25" == value ? "selected=\"selected\"" : "");
  181. options.Append("<optgroup label=\"流程实例相关选项\"></optgroup>");
  182. options.AppendFormat("<option value=\"<%=BWorkFlow.GetFlowName(FlowID.ToGuid())%>\" {0}>当前流程名称</option>", "30" == value ? "selected=\"selected\"" : "");
  183. options.AppendFormat("<option value=\"<%=BWorkFlow.GetStepName(StepID.ToGuid(), FlowID.ToGuid(), true)%>\" {0}>当前步骤名称</option>", "31" == value ? "selected=\"selected\"" : "");
  184. return options.ToString();
  185. }
  186. /// <summary>
  187. /// 得到流程文本域模式Radio字符串
  188. /// </summary>
  189. /// <returns></returns>
  190. public string GetTextareaModelRadios(string name, string value, string att = "")
  191. {
  192. ListItem[] items = new ListItem[]{
  193. new ListItem("普通","default"){ Selected="default"==value},
  194. new ListItem("HTML","html"){ Selected="html"==value}
  195. };
  196. return RoadFlow.Utility.Tools.GetRadioString(items, name, att);
  197. }
  198. /// <summary>
  199. /// 得到数据源Radio字符串
  200. /// </summary>
  201. /// <returns></returns>
  202. public string GetDataSourceRadios(string name, string value, string att = "")
  203. {
  204. ListItem[] items = new ListItem[]{
  205. new ListItem("数据字典","0"){ Selected="0"==value},
  206. new ListItem("自定义","1"){ Selected="1"==value},
  207. new ListItem("SQL语句","2"){ Selected="2"==value}
  208. };
  209. return RoadFlow.Utility.Tools.GetRadioString(items, name, att);
  210. }
  211. /// <summary>
  212. /// 得到组织机构选择范围Radio字符串
  213. /// </summary>
  214. /// <returns></returns>
  215. public string GetOrgRangeRadios(string name, string value, string att = "")
  216. {
  217. ListItem[] items = new ListItem[]{
  218. new ListItem("发起者部门","0"){ Selected="0"==value},
  219. new ListItem("处理者部门","1"){ Selected="1"==value},
  220. };
  221. return RoadFlow.Utility.Tools.GetRadioString(items, name, att);
  222. }
  223. /// <summary>
  224. /// 得到组织机构选择类型Radio字符串
  225. /// </summary>
  226. /// <returns></returns>
  227. public string GetOrgSelectTypeCheckboxs(string name, string value, string att = "")
  228. {
  229. ListItem[] items = new ListItem[]{
  230. new ListItem("部门","0"){ Selected="0"==value},
  231. new ListItem("岗位","1"){ Selected="1"==value},
  232. new ListItem("人员","2"){ Selected="2"==value},
  233. new ListItem("工作组","3"){ Selected="3"==value},
  234. new ListItem("单位","4"){ Selected="4"==value}
  235. };
  236. return RoadFlow.Utility.Tools.GetCheckBoxString(items, name, value.Split(','), att);
  237. }
  238. /// <summary>
  239. /// 得到从表编辑模式选择
  240. /// </summary>
  241. /// <returns></returns>
  242. public string GetEditmodeOptions(string value)
  243. {
  244. ListItem[] items = new ListItem[]{
  245. new ListItem("无",""){ Selected=""==value},
  246. new ListItem("文本框","text"){ Selected="text"==value},
  247. new ListItem("文本域","textarea"){ Selected="textarea"==value},
  248. new ListItem("下拉列表","select"){ Selected="select"==value},
  249. new ListItem("复选框","checkbox"){ Selected="checkbox"==value},
  250. new ListItem("单选框","radio"){ Selected="radio"==value},
  251. new ListItem("日期时间","datetime"){ Selected="datetime"==value},
  252. new ListItem("组织机构选择","org"){ Selected="org"==value},
  253. new ListItem("数据字典选择","dict"){ Selected="dict"==value},
  254. new ListItem("附件","files"){ Selected="files"==value}
  255. };
  256. return RoadFlow.Utility.Tools.GetOptionsString(items);
  257. }
  258. /// <summary>
  259. /// 得到从表显示模式选择
  260. /// </summary>
  261. /// <returns></returns>
  262. public string GetDisplayModeOptions(string value)
  263. {
  264. ListItem[] items = new ListItem[]{
  265. new ListItem("常规","normal"){ Selected="normal"==value},
  266. new ListItem("数据字典ID显示为标题","dict_id_title"){ Selected="dict_id_title"==value},
  267. new ListItem("数据字典ID显示为代码","dict_id_code"){ Selected="dict_id_code"==value},
  268. new ListItem("数据字典ID显示为值","dict_id_value"){ Selected="dict_id_value"==value},
  269. new ListItem("数据字典ID显示为备注","dict_id_note"){ Selected="dict_id_note"==value},
  270. new ListItem("数据字典ID显示为其它","dict_id_other"){ Selected="dict_id_other"==value},
  271. new ListItem("数据字典唯一代码显示为标题","dict_code_title"){ Selected="dict_code_title"==value},
  272. new ListItem("数据字典唯一代码显示为ID","dict_code_id"){ Selected="dict_code_id"==value},
  273. new ListItem("数据字典唯一代码显示为值","dict_code_value"){ Selected="dict_code_value"==value},
  274. new ListItem("数据字典唯一代码显示为备注","dict_code_note"){ Selected="dict_code_note"==value},
  275. new ListItem("数据字典唯一代码显示为其它","dict_code_other"){ Selected="dict_code_other"==value},
  276. new ListItem("组织机构ID显示为名称","organize_id_name"){ Selected="organize_id_name"==value},
  277. new ListItem("附件显示为连接","files_link"){ Selected="files_link"==value},
  278. new ListItem("附件显示为图片","files_img"){ Selected="files_img"==value},
  279. new ListItem("日期时间显示为指定格式","datetime_format"){ Selected="datetime_format"==value},
  280. new ListItem("数字显示为指定格式","number_format"){ Selected="number_format"==value},
  281. new ListItem("字符串时间显示为指定格式","string_format"){ Selected="string_format"==value},
  282. new ListItem("关联显示为其它表字段值","table_fieldvalue"){ Selected="table_fieldvalue"==value}
  283. };
  284. return RoadFlow.Utility.Tools.GetOptionsString(items);
  285. }
  286. /// <summary>
  287. /// 根据显示方式得到显示的字符串
  288. /// </summary>
  289. /// <param name="value"></param>
  290. /// <param name="displayModel"></param>
  291. /// <returns></returns>
  292. public string GetDisplayString(string value, string displayModel, string format = "", string dbconnID = "", string sql = "")
  293. {
  294. string value1 = string.Empty;
  295. switch ((displayModel ?? "").ToLower())
  296. {
  297. case "normal":
  298. default:
  299. value1 = value;
  300. break;
  301. case "dict_id_title":
  302. var dict = new Dictionary().Get(value.ToGuid());
  303. value1 = dict == null ? "" : dict.Title;
  304. break;
  305. case "dict_id_code":
  306. var dict1 = new Dictionary().Get(value.ToGuid());
  307. value1 = dict1 == null ? "" : dict1.Code;
  308. break;
  309. case "dict_id_value":
  310. var dict2 = new Dictionary().Get(value.ToGuid());
  311. value1 = dict2 == null ? "" : dict2.Value;
  312. break;
  313. case "dict_id_note":
  314. var dict3 = new Dictionary().Get(value.ToGuid());
  315. value1 = dict3 == null ? "" : dict3.Note;
  316. break;
  317. case "dict_id_other":
  318. var dict4 = new Dictionary().Get(value.ToGuid());
  319. value1 = dict4 == null ? "" : dict4.Other;
  320. break;
  321. case "dict_code_title":
  322. var dict5 = new Dictionary().GetByCode(value);
  323. value1 = dict5 == null ? "" : dict5.Title;
  324. break;
  325. case "dict_code_id":
  326. var dict6 = new Dictionary().GetByCode(value);
  327. value1 = dict6 == null ? "" : dict6.ID.ToString();
  328. break;
  329. case "dict_code_value":
  330. var dict7 = new Dictionary().GetByCode(value);
  331. value1 = dict7 == null ? "" : dict7.Value;
  332. break;
  333. case "dict_code_note":
  334. var dict8 = new Dictionary().GetByCode(value);
  335. value1 = dict8 == null ? "" : dict8.Note;
  336. break;
  337. case "dict_code_other":
  338. var dict9 = new Dictionary().GetByCode(value);
  339. value1 = dict9 == null ? "" : dict9.Other;
  340. break;
  341. case "organize_id_name":
  342. value1 = new Organize().GetNames(value);
  343. break;
  344. case "files_link":
  345. string[] files = value.Split('|');
  346. StringBuilder links = new StringBuilder();
  347. //links.Append("<div>");
  348. foreach (string file in files)
  349. {
  350. links.AppendFormat("<a target=\"_blank\" class=\"blue\" href=\"{0}\">{1}</a><br/>", file, System.IO.Path.GetFileName(file));
  351. }
  352. //links.Append("</div>");
  353. value1 = links.ToString();
  354. break;
  355. case "files_img":
  356. string[] files1 = value.Split('|');
  357. StringBuilder links1 = new StringBuilder();
  358. //links.Append("<div>");
  359. foreach (string file in files1)
  360. {
  361. links1.AppendFormat("<img src=\"{0}\" />", file);
  362. }
  363. //links.Append("</div>");
  364. value1 = links1.ToString();
  365. break;
  366. case "datetime_format":
  367. value1 = value.ToDateTime().ToString(format ?? Utility.Config.DateFormat);
  368. break;
  369. case "number_format":
  370. value1 = value.ToDecimal().ToString(format);
  371. break;
  372. case "table_fieldvalue":
  373. DBConnection dbconn = new DBConnection();
  374. DataTable dt = dbconn.GetDataTable(dbconn.Get(dbconnID.ToGuid()), sql + "'" + value + "'");
  375. value1 = dt.Rows.Count > 0 && dt.Columns.Count > 0 ? dt.Rows[0][0].ToString() : "";
  376. break;
  377. }
  378. return value1;
  379. }
  380. /// <summary>
  381. /// 得到状态显示
  382. /// </summary>
  383. /// <param name="status"></param>
  384. /// <returns></returns>
  385. public string GetStatusTitle(int status)
  386. {
  387. string title = string.Empty;
  388. switch (status)
  389. {
  390. case 0:
  391. title = "已保存";break;
  392. case 1:
  393. title = "已发布";break;
  394. case 2:
  395. title = "已作废";break;
  396. }
  397. return title;
  398. }
  399. /// <summary>
  400. /// 得到编译页面的头部
  401. /// </summary>
  402. /// <param name="serverScript">服务端脚本</param>
  403. /// <returns></returns>
  404. public string GetHeadHtml(string serverScript)
  405. {
  406. return "";
  407. }
  408. /// <summary>
  409. /// 根据一个地址得到下拉列表项
  410. /// </summary>
  411. /// <param name="url"></param>
  412. /// <param name="value"></param>
  413. /// <returns></returns>
  414. public string GetOptionsFromUrl(string url, string value)
  415. {
  416. string uri = url + (url.IndexOf('?') >= 0 ? "&" : "?") + "values=" + value;
  417. if (!uri.Contains("http", StringComparison.CurrentCultureIgnoreCase)
  418. && !uri.Contains("https", StringComparison.CurrentCultureIgnoreCase))
  419. {
  420. var add = System.Web.HttpContext.Current.Request.Url;
  421. uri = add.ToString().Substring(0, add.ToString().IndexOf("//") + 2) + add.Authority + uri;
  422. }
  423. try
  424. {
  425. string options = Utility.HttpHelper.SendGet(uri);
  426. return options;
  427. }
  428. catch(Exception err)
  429. {
  430. return err.Message;
  431. }
  432. }
  433. /// <summary>
  434. /// 根据sql得到下拉列表项
  435. /// </summary>
  436. /// <param name="dbconn"></param>
  437. /// <param name="sql"></param>
  438. /// <returns></returns>
  439. public string GetOptionsFromSql(string connID, string sql, string value)
  440. {
  441. Guid cid;
  442. if(!connID.IsGuid(out cid))
  443. {
  444. return "";
  445. }
  446. DBConnection dbConn = new DBConnection();
  447. var dbconn = dbConn.Get(cid);
  448. if (dbconn == null)
  449. {
  450. return "";
  451. }
  452. DataTable dt = dbConn.GetDataTable(dbconn, sql.ReplaceSelectSql());
  453. if (dt.Rows.Count == 0)
  454. {
  455. return "";
  456. }
  457. List<ListItem> items = new List<ListItem>();
  458. foreach (DataRow dr in dt.Rows)
  459. {
  460. if (dt.Columns.Count == 0)
  461. {
  462. continue;
  463. }
  464. string value1 = dr[0].ToString();
  465. string title = value1;
  466. if (dt.Columns.Count > 1)
  467. {
  468. title = dr[1].ToString();
  469. }
  470. items.Add(new ListItem(title, value1) { Selected = value == value1 });
  471. }
  472. return RoadFlow.Utility.Tools.GetOptionsString(items.ToArray());
  473. }
  474. /// <summary>
  475. /// 根据sql得到单选按钮组
  476. /// </summary>
  477. /// <param name="dbconn"></param>
  478. /// <param name="sql"></param>
  479. /// <returns></returns>
  480. public string GetRadioFromSql(string connID, string sql, string name, string value, string attr = "")
  481. {
  482. Guid cid;
  483. if (!connID.IsGuid(out cid))
  484. {
  485. return "";
  486. }
  487. DBConnection dbConn = new DBConnection();
  488. var dbconn = dbConn.Get(cid);
  489. if (dbconn == null)
  490. {
  491. return "";
  492. }
  493. DataTable dt = dbConn.GetDataTable(dbconn, sql.ReplaceSelectSql());
  494. if (dt.Rows.Count == 0)
  495. {
  496. return "";
  497. }
  498. List<ListItem> items = new List<ListItem>();
  499. foreach (DataRow dr in dt.Rows)
  500. {
  501. if (dt.Columns.Count == 0)
  502. {
  503. continue;
  504. }
  505. string value1 = dr[0].ToString();
  506. string title = value1;
  507. if (dt.Columns.Count > 1)
  508. {
  509. title = dr[1].ToString();
  510. }
  511. items.Add(new ListItem(title, value1) { Selected = value == value1 });
  512. }
  513. return RoadFlow.Utility.Tools.GetRadioString(items.ToArray(), name, attr);
  514. }
  515. /// <summary>
  516. /// 根据sql得到复选框
  517. /// </summary>
  518. /// <param name="dbconn"></param>
  519. /// <param name="sql"></param>
  520. /// <returns></returns>
  521. public string GetCheckboxFromSql(string connID, string sql, string name, string value, string attr="")
  522. {
  523. Guid cid;
  524. if (!connID.IsGuid(out cid))
  525. {
  526. return "";
  527. }
  528. DBConnection dbConn = new DBConnection();
  529. var dbconn = dbConn.Get(cid);
  530. if (dbconn == null)
  531. {
  532. return "";
  533. }
  534. DataTable dt = dbConn.GetDataTable(dbconn, sql.ReplaceSelectSql());
  535. if (dt.Rows.Count == 0)
  536. {
  537. return "";
  538. }
  539. List<ListItem> items = new List<ListItem>();
  540. foreach (DataRow dr in dt.Rows)
  541. {
  542. if (dt.Columns.Count == 0)
  543. {
  544. continue;
  545. }
  546. string value1 = dr[0].ToString();
  547. string title = value1;
  548. if (dt.Columns.Count > 1)
  549. {
  550. title = dr[1].ToString();
  551. }
  552. items.Add(new ListItem(title, value1));
  553. }
  554. return RoadFlow.Utility.Tools.GetCheckBoxString(items.ToArray(), name, (value ?? "").Split(','), attr);
  555. }
  556. /// <summary>
  557. /// 得到Grid的html
  558. /// </summary>
  559. /// <param name="dataFormat"></param>
  560. /// <param name="dataSource"></param>
  561. /// <param name="dataSource1"></param>
  562. /// <returns></returns>
  563. public string GetFormGridHtml(string connID, string dataFormat, string dataSource, string dataSource1)
  564. {
  565. if (!dataFormat.IsInt() || !dataSource.IsInt() || dataSource1.IsNullOrEmpty())
  566. {
  567. return "";
  568. }
  569. switch (dataSource)
  570. {
  571. case "0":
  572. DBConnection dbConn = new DBConnection();
  573. var dbconn = dbConn.Get(connID.ToGuid());
  574. if (dbconn == null)
  575. {
  576. return "";
  577. }
  578. DataTable dt = dbConn.GetDataTable(dbconn, dataSource1.ReplaceSelectSql());
  579. switch (dataFormat)
  580. {
  581. case "0":
  582. return dataTableToHtml(dt);
  583. case "1":
  584. return dt.Rows.Count > 0 ? dt.Rows[0][0].ToString() : "";
  585. case "2":
  586. return dt.Rows.Count > 0 ? jsonToHtml(dt.Rows[0][0].ToString()) : "";
  587. default:
  588. return "";
  589. }
  590. case "1":
  591. string str = string.Empty;
  592. try
  593. {
  594. str = RoadFlow.Utility.HttpHelper.SendGet(dataSource1);
  595. switch (dataFormat)
  596. {
  597. case "0":
  598. case "1":
  599. return str;
  600. case "2":
  601. return jsonToHtml(str);
  602. default:
  603. return "";
  604. }
  605. }
  606. catch
  607. {
  608. return "";
  609. }
  610. case "2":
  611. RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams();
  612. eventParams.FlowID = (System.Web.HttpContext.Current.Request.QueryString["FlowID"] ?? "").ToGuid();
  613. eventParams.GroupID = (System.Web.HttpContext.Current.Request.QueryString["GroupID"] ?? "").ToGuid();
  614. eventParams.StepID = (System.Web.HttpContext.Current.Request.QueryString["StepID"] ?? "").ToGuid();
  615. eventParams.TaskID = (System.Web.HttpContext.Current.Request.QueryString["TaskID"] ?? "").ToGuid();
  616. eventParams.InstanceID = System.Web.HttpContext.Current.Request.QueryString["InstanceID"] ?? "";
  617. object obj = null;
  618. try
  619. {
  620. obj = new WorkFlowTask().ExecuteFlowCustomEvent(dataSource1, eventParams);
  621. switch (dataFormat)
  622. {
  623. case "0":
  624. return dataTableToHtml((DataTable)obj);
  625. case "1":
  626. return obj.ToString();
  627. case "2":
  628. return jsonToHtml(obj.ToString());
  629. default:
  630. return "";
  631. }
  632. }
  633. catch
  634. {
  635. return "";
  636. }
  637. }
  638. return "";
  639. }
  640. /// <summary>
  641. /// 将一个DataTable转换为HTML表格
  642. /// </summary>
  643. /// <param name="dt"></param>
  644. /// <returns></returns>
  645. private string dataTableToHtml(DataTable dt)
  646. {
  647. StringBuilder table = new StringBuilder(2000);
  648. table.Append("<table border=\"1\" style=\"border-collapse:collapse;width:100%;\">");
  649. table.Append("<thead><tr style=\"height:25px;\">");
  650. foreach (DataColumn column in dt.Columns)
  651. {
  652. table.AppendFormat("<th>{0}</th>", column.ColumnName);
  653. }
  654. table.Append("</tr></thead>");
  655. table.Append("<tbody>");
  656. foreach (DataRow dr in dt.Rows)
  657. {
  658. table.Append("<tr style=\"height:22px;\">");
  659. for (int i = 0; i < dt.Columns.Count; i++)
  660. {
  661. table.AppendFormat("<td>{0}</td>", dr[i].ToString().HtmlEncode());
  662. }
  663. table.Append("</tr>");
  664. }
  665. table.Append("</tbody>");
  666. table.Append("</table>");
  667. return table.ToString();
  668. }
  669. /// <summary>
  670. /// 将json转换为HTML表格
  671. /// </summary>
  672. /// <param name="json"></param>
  673. /// <returns></returns>
  674. private string jsonToHtml(string jsonStr)
  675. {
  676. LitJson.JsonData json = LitJson.JsonMapper.ToObject(jsonStr);
  677. if (!json.IsArray)
  678. {
  679. return "";
  680. }
  681. StringBuilder table = new StringBuilder(2000);
  682. table.Append("<table border=\"1\" style=\"border-collapse:collapse;width:100%;\">");
  683. table.Append("<tbody><tr style=\"height:25px;\">");
  684. foreach (LitJson.JsonData tr in json)
  685. {
  686. table.Append("<tr style=\"height:22px;\">");
  687. foreach(LitJson.JsonData td in tr)
  688. {
  689. table.AppendFormat("<td>{0}</td>", td.ToString());
  690. }
  691. table.Append("</tr>");
  692. }
  693. table.Append("</tbody>");
  694. table.Append("</table>");
  695. return table.ToString();
  696. }
  697. /// <summary>
  698. /// 得到下级ID字符串
  699. /// </summary>
  700. /// <param name="id"></param>
  701. /// <returns></returns>
  702. public string GetAllChildsIDString(Guid id, bool isSelf = true)
  703. {
  704. return new Dictionary().GetAllChildsIDString(id, true);
  705. }
  706. /// <summary>
  707. /// 查询一个分类所有记录
  708. /// </summary>
  709. public List<RoadFlow.Data.Model.WorkFlowForm> GetAllByType(Guid id)
  710. {
  711. return dataWorkFlowForm.GetAllByType(GetAllChildsIDString(id));
  712. }
  713. /// <summary>
  714. /// 得到类型选择项
  715. /// </summary>
  716. /// <returns></returns>
  717. public string GetTypeOptions(string value = "")
  718. {
  719. return new Dictionary().GetOptionsByCode("FormTypes", Dictionary.OptionValueField.ID, value);
  720. }
  721. /// <summary>
  722. /// 根据sql得到Combox列表项
  723. /// </summary>
  724. /// <param name="dbconn"></param>
  725. /// <param name="sql"></param>
  726. /// <returns></returns>
  727. public string GetComboxTableHtmlFromSql(string connID, string sql, string value)
  728. {
  729. Guid cid;
  730. if (!connID.IsGuid(out cid))
  731. {
  732. return "";
  733. }
  734. DBConnection dbConn = new DBConnection();
  735. var dbconn = dbConn.Get(cid);
  736. if (dbconn == null)
  737. {
  738. return "";
  739. }
  740. DataTable dt = dbConn.GetDataTable(dbconn, sql.ReplaceSelectSql());
  741. if (dt.Rows.Count == 0)
  742. {
  743. return "";
  744. }
  745. StringBuilder html = new StringBuilder(2000);
  746. html.Append("<table><thead><tr>");
  747. for (int i = 0; i < dt.Columns.Count; i++)
  748. {
  749. if (dt.Columns.Count > 1 && i == 0) continue;
  750. html.Append("<th>");
  751. html.Append(dt.Columns[i].ColumnName);
  752. html.Append("</th>");
  753. }
  754. html.Append("</thead>");
  755. html.Append("<tbody>");
  756. for (int i = 0; i < dt.Rows.Count; i++)
  757. {
  758. html.Append("<tr>");
  759. for (int j = 0; j < dt.Columns.Count; j++)
  760. {
  761. if (dt.Columns.Count > 1 && j == 0) continue;
  762. html.AppendFormat("<td value=\"{0}\"{1}>", dt.Rows[i][0], dt.Rows[i][0].ToString().Equals(value, StringComparison.CurrentCultureIgnoreCase) ? " selected=\"selected\"" : "");
  763. html.Append(dt.Rows[i][j]);
  764. html.Append("</td>");
  765. }
  766. html.Append("</tr>");
  767. }
  768. html.Append("</tr></tbody></table>");
  769. return html.ToString();
  770. }
  771. /// <summary>
  772. /// 得到归档HTML
  773. /// </summary>
  774. /// <param name="formHtml"></param>
  775. /// <param name="commentHtml"></param>
  776. /// <returns></returns>
  777. public string GetArchivesString(string formHtml, string commentHtml)
  778. {
  779. string html = "<link href=\"/Platform/WorkFlowRun/Scripts/Forms/flowform_print.css\" rel=\"stylesheet\" />"
  780. + " <style type=\"text/css\" media=\"print\">"
  781. + " .Noprint { display: none; }"
  782. + " </style>"
  783. + " <link href=\"/Platform/WorkFlowRun/Scripts/Forms/flowform.css\" rel=\"stylesheet\" type=\"text/css\" />"
  784. + " <script src=\"/Platform/WorkFlowRun/Scripts/Forms/common.js\" type=\"text/javascript\" ></script>"
  785. + "<div style=\"width:98%; margin:-10px auto 0 auto;\">";
  786. html += formHtml;
  787. html += "<script type=\"text/javascript\">fieldStatus ={};</script>";
  788. html += "</div>";
  789. return html;
  790. }
  791. }
  792. }