This project is read-only.

6. Decision (Are the days over three days?) : According to the input value to judge if the days are over three days.

C#: 

  1.         public class GreaterThan3Days : IRule
  2.         {
  3.              public string Execute(System.Collections.Generic.Dictionary<string, object> variable)
  4.              {
  5.                              string result = "非大於3天";
  6.                              string xmlData = null;
  7.                              if ((!variable.TryGetValue("formData", out xmlData))) {
  8.                                              result = "非大於3天";
  9.                              } else {
  10.                                             result = CheckFormData(xmlData);
  11.                             }
  12.                             return result;
  13.             }
  14.             private string CheckFormData(string xmlStr)
  15.             {
  16.                             DataSet ds = new DataSet();
  17.                             TextReader reader = new StringReader(xmlStr);
  18.                             string resultStr = "非大於3天";
  19.                             ds.ReadXml(reader);
  20.                             int leaveDays = int.Parse(ds.Tables["LeaveInfo"](0)("LeaveDay").ToString());
  21.                             if ((leaveDays > 3)) {
  22.                                             resultStr = "大於3天";
  23.                             }
  24.                             reader.Close();
  25.                             return resultStr;
  26.             }
  27.        }

Last edited Jun 25, 2012 at 11:21 AM by cathysung, version 2

Comments

No comments yet.