コード例 #1
0
 public Models.EF.Maintenance_Schedule getScheduleRecord(int MS_Id)
 {
     if (MS_Id == 0)
     {
         throw new Exception("schedule primary key required and cannot be zero.");
     }
     Models.EF.Maintenance_Schedule record = null;
     try
     {
         context.Configuration.LazyLoadingEnabled = false;
         record = (from x in context.Maintenance_Schedule where x.MS_Id == MS_Id select x).FirstOrDefault();
     } finally
     {
         context.Dispose();
     }
     return(record);
 }
コード例 #2
0
        private IList <Helpers.PageInput> mapScheduleValues(IList <Helpers.PageInput> mobileInputs, int MS_Id, string CID)
        {
            if (MS_Id == 0)
            {
                return(mobileInputs);
            }

            Helpers.CtxService service = new Helpers.CtxService(null, CID);

            Models.EF.Maintenance_Schedule schedule = service.getScheduleRecord(MS_Id);

            if (schedule == null)
            {
                return(mobileInputs);
            }

            Helpers.objectMapper <Maintenance_Schedule> mapper = new Helpers.objectMapper <Maintenance_Schedule>();

            Hashtable hash = mapper.createPropertyInfoHash();

            ICollection keys = hash.Keys;

            if (keys.Count > 0)
            {
                foreach (var item in mobileInputs)
                {
                    try
                    {
                        if (hash[item.input.id.ToUpper()] != null)
                        {
                            PropertyInfo info = (PropertyInfo)hash[item.input.id.ToUpper()];
                            if (info != null && item.input != null)
                            {
                                var val = info.GetValue(schedule);
                                if (val == null)
                                {
                                    val = "";
                                }
                                if (info.PropertyType.Name.ToUpper() == "DATETIME")
                                {
                                    DateTime realdate = Convert.ToDateTime(val);
                                    item.input.value = realdate.ToString("yyyy-MM-dd");
                                }
                                else
                                {
                                    item.input.value = mapper.ConvertType(val.ToString(), "STRING").ToString();
                                }
                            }
                        }
                    } catch (Exception ex)
                    {
                        if (item.input != null)
                        {
                            item.errorFlag    = true;
                            item.errorMessage = ex.Message;
                        }
                    }
                }
            }

            return(mobileInputs);
        }