Exemplo n.º 1
0
 //public virtual string CoCoRaHSDoAddChanges()
 //{
 //    try
 //    {
 //        CoCoRaHSdb.SaveChanges();
 //    }
 //    catch (Exception ex)
 //    {
 //        return string.Format(ServiceRes.CouldNotAddError_, ex.Message);
 //    }
 //    return "";
 //}
 //public virtual string CoCoRaHSDoDeleteChanges()
 //{
 //    try
 //    {
 //        CoCoRaHSdb.SaveChanges();
 //    }
 //    catch (Exception ex)
 //    {
 //        return string.Format(ServiceRes.CouldNotDeleteError_, ex.Message);
 //    }
 //    return "";
 //}
 //public virtual string CoCoRaHSDoUpdateChanges()
 //{
 //    try
 //    {
 //        CoCoRaHSdb.SaveChanges();
 //    }
 //    catch (Exception ex)
 //    {
 //        return string.Format(ServiceRes.CouldNotUpdateError_, ex.Message);
 //    }
 //    return "";
 //}
 public virtual string DoAddChanges()
 {
     try
     {
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         return(string.Format(ServiceRes.CouldNotAddError_, ex.Message));
     }
     return("");
 }
Exemplo n.º 2
0
        public TVItemModel MarkSamplesWithMWQMSampleIDForOpenDataDB(int MWQMSampleID, bool UseForOpenData)
        {
            using (CSSPDBEntities dd = new CSSPDBEntities())
            {
                MWQMSample mwqmSample = (from s in dd.MWQMSamples
                                         where s.MWQMSampleID == MWQMSampleID
                                         select s).FirstOrDefault();

                if (mwqmSample == null)
                {
                    return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MWQMSample, ServiceRes.MWQMSampleID, MWQMSampleID.ToString())));
                }

                mwqmSample.UseForOpenData = UseForOpenData;

                try
                {
                    dd.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(ReturnError(string.Format(ServiceRes.CouldNotUpdateError_, ex.Message + " InnerException: " + (ex.InnerException != null ? ex.InnerException.Message : ""))));
                }
            }

            return(ReturnError(""));
        }
Exemplo n.º 3
0
        public TVItemModel ToggleUseForOpenDataFlagOfAllSamplesUnderMWQMSiteTVItemIDDB(int MWQMSiteTVItemID, DateTime StartDate, DateTime EndDate, bool UseForOpenData)
        {
            string RoutineTxt = ((int)SampleTypeEnum.Routine).ToString() + ",";

            TVItem tvItemSite = new TVItem();

            using (CSSPDBEntities dd = new CSSPDBEntities())
            {
                tvItemSite = (from c in dd.TVItems
                              where c.TVItemID == MWQMSiteTVItemID
                              select c).FirstOrDefault();
            }

            if (tvItemSite == null)
            {
                return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MWQMSite, ServiceRes.MWQMSiteTVItemID, MWQMSiteTVItemID.ToString())));
            }

            using (CSSPDBEntities dd = new CSSPDBEntities())
            {
                List <MWQMSample> mwqmSampleList = (from t in dd.TVItems
                                                    from s in dd.MWQMSamples
                                                    where t.TVItemID == s.MWQMSiteTVItemID &&
                                                    t.TVItemID == MWQMSiteTVItemID &&
                                                    t.TVType == (int)TVTypeEnum.MWQMSite &&
                                                    s.SampleTypesText.Contains(RoutineTxt) &&
                                                    s.UseForOpenData == !UseForOpenData &&
                                                    s.SampleDateTime_Local >= StartDate &&
                                                    s.SampleDateTime_Local <= EndDate
                                                    select s).ToList();

                foreach (MWQMSample mwqmSample in mwqmSampleList)
                {
                    mwqmSample.UseForOpenData = UseForOpenData;
                }

                try
                {
                    dd.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(ReturnError(string.Format(ServiceRes.CouldNotUpdateError_, ex.Message + " InnerException: " + (ex.InnerException != null ? ex.InnerException.Message : ""))));
                }
            }

            return(ReturnError(""));
        }