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;
 }
Exemple #2
0
        protected override void DeletingItem(ShiftTemplate info, AttendanceDataContext attendance)
        {
            T_ShiftArrangeTemplate item = T_ShiftArrangeTemplate.Create(info);

            attendance.GetTable <T_ShiftArrangeTemplate>().Attach(item);
            attendance.GetTable <T_ShiftArrangeTemplate>().DeleteOnSubmit(item);
        }
        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);
        }
        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);
        }
Exemple #5
0
        protected override ShiftTemplate GetingItemByID(string id, AttendanceDataContext attendance)
        {
            T_ShiftArrangeTemplate tst = attendance.GetTable <T_ShiftArrangeTemplate>().SingleOrDefault(item => item.ID == id);

            if (tst != null)
            {
                return(T_ShiftArrangeTemplate.Create(tst));
            }
            return(null);
        }
Exemple #6
0
        protected override List <ShiftTemplate> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <T_ShiftArrangeTemplate> ret   = attendance.GetTable <T_ShiftArrangeTemplate>();
            List <T_ShiftArrangeTemplate>       items = ret.ToList();

            List <ShiftTemplate> templates = new List <ShiftTemplate>();

            if (items != null && items.Count > 0)
            {
                foreach (T_ShiftArrangeTemplate item in items)
                {
                    templates.Add(T_ShiftArrangeTemplate.Create(item));
                }
            }
            return(templates);
        }
 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;
 }
Exemple #8
0
 protected override void UpdatingItem(ShiftTemplate newVal, ShiftTemplate original, AttendanceDataContext attendance)
 {
     attendance.GetTable <T_ShiftArrangeTemplate>().Attach(T_ShiftArrangeTemplate.Create(newVal), T_ShiftArrangeTemplate.Create(original));
 }
Exemple #9
0
        protected override void InsertingItem(ShiftTemplate info, AttendanceDataContext attendance)
        {
            T_ShiftArrangeTemplate template = T_ShiftArrangeTemplate.Create(info);

            attendance.GetTable <T_ShiftArrangeTemplate>().InsertOnSubmit(template);
        }