public static T_ShiftArrangeTemplate Create(ShiftTemplate item)
 {
     T_ShiftArrangeTemplate tst = new T_ShiftArrangeTemplate();
     tst.ID = item.ID;
     tst.Name = item.Name;
     tst.Options = item.Options;
     tst.Memo = item.Memo;
     if (item.Items != null && item.Items.Count > 0)
     {
         try
         {
             using (StringWriter writer = new StringWriter())
             {
                 XmlSerializer ser = new XmlSerializer(typeof(List<TemplateItem>));
                 ser.Serialize(writer, item.Items);
                 if (writer.GetStringBuilder() != null)
                 {
                     tst.Value = writer.GetStringBuilder().ToString();
                 }
             }
         }
         catch (Exception ex)
         {
             LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
         }
     }
     return tst;
 }
 public CommandResult Update(ShiftTemplate info)
 {
     ShiftTemplate original = ProviderFactory.Create<IShiftTemplateProvider>(_RepoUri).GetByID(info.ID).QueryObject;
     if (original != null)
     {
         return ProviderFactory.Create<IShiftTemplateProvider>(_RepoUri).Update(info, original);
     }
     else
     {
         return new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord));
     }
 }
 public CommandResult Add(ShiftTemplate info)
 {
     string id = ProviderFactory.Create<IStringIDCreater>(_RepoUri).CreateID("T", 3, "ShiftTemplate");
     if (!string.IsNullOrEmpty(id))
     {
         info.ID = id;
         return ProviderFactory.Create<IShiftTemplateProvider>(_RepoUri).Insert(info);
     }
     else
     {
         return new CommandResult(ResultCode.Fail, "创建ID失败");
     }
 }
 public static ShiftTemplate Create(T_ShiftArrangeTemplate item)
 {
     ShiftTemplate st = new ShiftTemplate();
     st.ID = item.ID;
     st.Name = item.Name;
     st.Options = item.Options;
     st.Memo = item.Memo;
     if (!string.IsNullOrEmpty(item.Value))
     {
         try
         {
             using (StringReader reader = new StringReader(item.Value))
             {
                 XmlSerializer ser = new XmlSerializer(typeof(List<TemplateItem>));
                 st.Items = ser.Deserialize(reader) as List<TemplateItem>;
             }
         }
         catch (Exception ex)
         {
             LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
         }
     }
     return st;
 }
 protected override object GetItemFromInput()
 {
     ShiftTemplate item = UpdatingItem as ShiftTemplate;
     if (item == null)
     {
         item = new ShiftTemplate();
     }
     item.Name = txtName.Text;
     item.Options = TemplateOptions.None;
     if (chkHolidayShifted.Checked) item.Options |= TemplateOptions.HolidayShifted;
     if (chkWeekendShifted.Checked) item.Options |= TemplateOptions.WeekendShifted;
     if (item.Items == null) item.Items = new List<TemplateItem>();
     item.Items.Clear();
     for (int i = 1; i <= 6; i++)
     {
         if ((this.Controls["chkShift" + i.ToString()] as CheckBox).Checked)
         {
             TemplateItem it = new TemplateItem();
             it.Shifts = (this.Controls["txtShifts" + i.ToString()] as TextBox).Tag as List<Shift>;
             it.Duration = (int)(this.Controls["txtDuration" + i.ToString()] as NumericUpDown).Value;
             Control panel = this.Controls["panel" + i.ToString()];
             it.DurationUnit = (panel.Controls["rdTime" + i.ToString()] as RadioButton).Checked ? 1 : 0;
             it.RestDays = (int)(this.Controls["txtRest" + i.ToString()] as NumericUpDown).Value;
             item.Items.Add(it);
         }
     }
     item.Memo = txtMemo.Text;
     return item;
 }
 public CommandResult Delete(ShiftTemplate info)
 {
     return ProviderFactory.Create<IShiftTemplateProvider>(_RepoUri).Delete(info);
 }