Beispiel #1
0
        public List <Param> getVariables(Site site)
        {
            IParamRepository paramRepo  = new ParamRepository();
            List <Param>     paramListe = (List <Param>)paramRepo.ForSite(site.Id, "Adresse API", null);

            return(paramListe);
        }
Beispiel #2
0
        public IDictionary <Param, IList <HisValue> > applyScaleFactory(IDictionary <Param, IList <HisValue> > data)
        {
            IParamRepository paramRepo = new ParamRepository();
            var mapValueConverted      = new Dictionary <Param, IList <HisValue> >();

            if (data != null)
            {
                foreach (var listValeurs in data)
                {
                    IList <HisValue> ListValeurValide = new List <HisValue>();

                    if (listValeurs.Key.TypeConversion != 0)
                    {
                        foreach (var val in listValeurs.Value)
                        {
                            HisValue convertedValue = paramRepo.ApplyScaleToValue(listValeurs.Key, val);

                            ListValeurValide.Add(convertedValue);
                        }
                    }
                    else
                    {
                        ListValeurValide = listValeurs.Value;
                    }

                    mapValueConverted.Add(listValeurs.Key, ListValeurValide);
                }
            }
            return(mapValueConverted);
        }
        public ActionResult Edit(string id, ParamRepository value)
        {
            if (AccessDenied(System.Web.HttpContext.Current.Session.SessionID))
            {
                return(RedirectToAction("Index", "Home"));
            }

            value.mensagem = new Validate();

            if (ModelState.IsValid)
            {
                try
                {
                    ControllerFactory <ParamModel> factory = new ControllerFactory <ParamModel>();

                    #region gravar os dados do parâmetro
                    value.parametro.parametroID = int.Parse(id);
                    value = (ParamRepository)factory.Edit(value);
                    if (value.mensagem.Code > 0)
                    {
                        throw new PinheiroSereniException(value.mensagem);
                    }
                    #endregion

                    return(RedirectToAction("Browse", new { sucesso = MensagemPadrao.Message(0).ToString() }));
                }
                catch (PinheiroSereniException ex)
                {
                    ModelState.AddModelError(value.mensagem.Field, ex.Result.Message);
                    return(View(value));
                }
            }
 public SingerManageController()
 {
     paramRepository      = ClassInstance <ParamRepository> .Instance;
     singerRepository     = ClassInstance <SingerRepository> .Instance;
     singerTypeRepository = ClassInstance <SingerTypeRepository> .Instance;
     songBookRepository   = ClassInstance <SongBookRepository> .Instance;
 }
        public Repository getObject(Object id)
        {
            using (db = new PinheiroSereniContext())
            {
                ParamRepository r = new ParamRepository()
                {
                    mensagem  = new Validate(),
                    parametro = db.Parametros.Find((int)id)
                };

                return(r);
            }
        }
        public Repository Update(Repository value)
        {
            using (db = new PinheiroSereniContext())
            {
                try
                {
                    value.mensagem = new Validate()
                    {
                        Code = 0, Message = MensagemPadrao.Message(0).ToString()
                    };
                    ParamRepository r = (ParamRepository)value;
                    db.Entry(r.parametro).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
                {
                    value.mensagem.Code        = 36;
                    value.mensagem.MessageBase = MensagemPadrao.Message(36).ToString();
                    if ((ex.Message.ToUpper().Contains("FOREIGN KEY") || ex.Message.ToUpper().Contains("REFERENCE")) ||
                        (ex.InnerException.ToString().ToUpper().Contains("FOREIGN KEY") || ex.InnerException.ToString().ToUpper().Contains("REFERENCE")))
                    {
                        value.mensagem.Code    = 16;
                        value.mensagem.Message = MensagemPadrao.Message(16).ToString();
                    }
                    else if (ex.Message.ToUpper().Contains("PRIMARY KEY") ||
                             ex.InnerException.ToString().ToUpper().Contains("PRIMARY KEY"))
                    {
                        value.mensagem.Code    = 37;
                        value.mensagem.Message = MensagemPadrao.Message(37).ToString();
                    }
                    else
                    {
                        value.mensagem.Message = MensagemPadrao.Message(17).ToString();
                    }
                    PinheiroSereniException.saveError(ex, GetType().FullName);
                }
                catch (Exception ex)
                {
                    PinheiroSereniException.saveError(ex, GetType().FullName);
                    value.mensagem.Code        = 17;
                    value.mensagem.MessageBase = ex.InnerException.InnerException.Message ?? ex.Message;
                    value.mensagem.Message     = new PinheiroSereniException(ex.Message, GetType().FullName).Message;
                }
            }

            return(value);
        }
Beispiel #7
0
        /// <summary>
        /// Configures the api.
        /// </summary>
        /// <param name="modelCache">The optional model cache</param>
        /// <param name="imageProcessor">The optional image processor</param>
        private void Setup(IContentServiceFactory factory, ICache modelCache = null, IImageProcessor imageProcessor = null)
        {
            cache = modelCache;

            var cacheLevel = (int)App.CacheLevel;

            Aliases    = new AliasRepository(this, db, cacheLevel > 2 ? cache : null);
            Archives   = new ArchiveRepository(this, db);
            Categories = new CategoryRepository(this, db, cacheLevel > 2 ? cache : null);
            Media      = new MediaRepository(this, db, storage, cacheLevel > 2 ? cache : null, imageProcessor);
            Pages      = new PageRepository(this, db, factory, cacheLevel > 2 ? cache : null);
            PageTypes  = new PageTypeRepository(db, cacheLevel > 1 ? cache : null);
            Params     = new ParamRepository(db, cacheLevel > 0 ? cache : null);
            Posts      = new PostRepository(this, db, factory, cacheLevel > 2 ? cache : null);
            PostTypes  = new PostTypeRepository(db, cacheLevel > 1 ? cache : null);
            Sites      = new SiteRepository(this, db, cacheLevel > 0 ? cache : null);
            Tags       = new TagRepository(db, cacheLevel > 2 ? cache : null);
        }
Beispiel #8
0
        public string GetSiteData(IList <Site> listSites)
        {
            IParamRepository paramRepo = new ParamRepository();

            string ReadingFeedback = null;

            foreach (var site in listSites)
            {
                IApiProtocol proto = null;
                mapLineApiProtocol.TryGetValue(site.Ligne, out proto);//getProtocolForSite(site.Id);
                if (proto != null)
                {
                    Thread th = Thread.CurrentThread;
                    if (String.IsNullOrEmpty(th.Name))
                    {
                        th.Name = "PCCOMApi_getSiteData_ " + site.Id;
                    }

                    // Insertion de traces dans la table log_application
                    //DiagBoxApp.Instance.GetLogger("EventLogTable").Trace(
                    //          message: string.Format("Launching new thread to retrieve data from PCComApi in the thread {0}", th.Name),
                    //        categories: "DiagBox;Applications;PCCOMAPI;PCCOMAPI;SpoolerPCComApi");


                    // get data from last acquisition to now, if not date acquisition get from 7 days. get from 7 days max
                    lock (proto)
                    {
                        var paramsValues = proto.readDataSite((site.DateAcquisition.HasValue && site.DateAcquisition.Value > DateTime.Now.AddDays(G_DAYS_BACKUP)) ? site.DateAcquisition.Value : DateTime.Now.AddDays(G_DAYS_BACKUP), DateTime.Now, site);


                        // insertion en base dans his_valeur en HQL et 1000lignes max par requêtes
                        bool ReadingOk = InsertPCComApiValues(paramsValues, site);
                        if (!ReadingOk)
                        {
                            ReadingFeedback = "Failed";
                        }
                    }
                }
            }
            return(ReadingFeedback);
        }
Beispiel #9
0
        public bool InsertPCComApiValues(IDictionary <Param, IList <HisValue> > data, Site site)
        {
            // get des doublons
            var valideParamsValues = checkDoublon(data);

            // gestion des bornes
            var ValuesWithEdge = applyScaleFactory(valideParamsValues);

            bool             insertFeedback = false;
            ISiteRepository  siteRepo       = new SiteRepository();
            IParamRepository paramRepo      = new ParamRepository();

            IFastHisValeurRepository valeurRepo = new FastHisValeurRepository();

            foreach (var values in ValuesWithEdge.Values)
            {
                try
                {
                    valeurRepo.InsertPCComApiValues(values);
                }
                catch (Exception ex)
                {
                }
            }

            try
            {
                insertFeedback = true;

                // insertion de la date d'acquisiton dans site
                var siteLocal = siteRepo.FindById(site.Id);
                siteLocal.DateAcquisition = DateTime.Now;
                siteRepo.Update(siteLocal);
            }

            catch (Exception ex)
            {
                insertFeedback = false;
            }
            return(insertFeedback);
        }
        public ActionResult Edit(string id, string sucesso = "")
        {
            if (AccessDenied(System.Web.HttpContext.Current.Session.SessionID))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ControllerFactory <ParamModel> factory = new ControllerFactory <ParamModel>();
            ParamRepository value = (ParamRepository)factory.getObject(int.Parse(id));

            if (sucesso != null)
            {
                if (sucesso.Trim() != "")
                {
                    value.mensagem = new Validate()
                    {
                        Code = 0, Message = sucesso
                    };
                    ViewBag.Sucesso = sucesso;
                }
            }

            return(View(value));
        }
Beispiel #11
0
        //
        // GET: /param/edit/1

        public ActionResult Edit(int id)
        {
            var model = new ParamRepository().Items.Single(x => x.Id == id);

            return(View(model));
        }
Beispiel #12
0
        public int GetNextParamTypeId(ParamType paramType)
        {
            var x = db.Params.Max("ParamId", x => x.ParamType == paramType, true);

            return(ParamRepository.Find(x).ParamId);
        }