Esempio n. 1
0
        public static string GetChartData(string data)
        {
            try
            {
                PositionDateRangeItem pdItem = new PositionDateRangeItem();
                pdItem = JsonConvert.DeserializeObject <PositionDateRangeItem>(data);
                List <QueryResultItem> chartData = new List <QueryResultItem>();

                MongoManager          mongoManager = new MongoManager();
                List <CollectionItem> positions    = new List <CollectionItem>();

                if (string.IsNullOrEmpty(pdItem.Positions))
                {
                    positions = mongoManager.GetAllCollectionsOfType(Constants.Database.CollectionType.Humiture);
                }
                else
                {
                    string[] pos = pdItem.Positions.Split(',');

                    foreach (string s in pos)
                    {
                        positions.Add(new CollectionItem(s, CollectionType.Humiture));
                    }
                }

                chartData = mongoManager.SelectFromCollections(positions, FilterBuilder.Humiture.BuildFilter(pdItem.FromDate, pdItem.ToDate));
                return(JsonConvert.SerializeObject(chartData));
            }
            catch (Exception ex)
            {
                LoggingManager.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
            }
            return("");
        }
Esempio n. 2
0
        public static string GetAllPositions()
        {
            try
            {
                List <string>         collectionNames = new List <string>();
                List <CollectionItem> collectionItems = new List <CollectionItem>();

                MongoManager mongoManager = new MongoManager();
                collectionItems = mongoManager.GetAllCollectionsOfType(Constants.Database.CollectionType.Humiture);

                foreach (CollectionItem item in collectionItems)
                {
                    collectionNames.Add(item.Name);
                }

                return(JsonConvert.SerializeObject(collectionNames));
            }
            catch (Exception ex)
            {
                LoggingManager.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
            }
            return("");
        }