Ejemplo n.º 1
0
        protected void panelonload(object sender, EventArgs e)
        {
            try
            {
                var sc = new RecipeServiceSoapClient();
                List<MongoMap> mn = new List<MongoMap>();
                //Response.Write(sc.Search("mango"));
                mn = JsonConvert.DeserializeObject<List<MongoMap>>(sc.DataAnalytics());
                // String ca = null, data;

                Dictionary<String,Double> dic=new Dictionary<string, Double>();
                foreach (var map in mn)
                {
                    dic.Add(map._id,map.value.count);
                    //Response.Write(map._id+"-"+map.value.count+"<br/>");
                    if (map.value.count > 100)
                    {
                        // ca += map._id.Replace("PT", "") + ",";
                        BarChartSeries a = new BarChartSeries();
                        a.Name = map._id.Replace("PT", "");
                        a.BarColor = GenerateRandomColour().ToString();
                        a.Data = new[] { Convert.ToDecimal(map.value.count) };
                        BarChart1.Series.Add(a);
                      
                    }
                 
                    GridView2.DataSource = dic;
                    GridView2.DataBind();
                }
                // BarChart1.CategoriesAxis = ca.Substring(0, ca.Count() - 1);
            }
            catch (Exception ex)
            {
                Response.Write(ex);
            }
        }
Ejemplo n.º 2
0
        // DATA ACCESS CONFIGURE SECTION
        //---------------------------------------------------------------------

        //*** create factory (different DbContext for RecipeRow and RemainRow)
        //*** how to use config manager
        private static void ConfigureDataAccess(IApplicationController controller)
        {
            // APP CONFIG SECTION
            //---------------------------------------------

            var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            var senderConfig = new SenderConfigurationManager(config);

            controller.RegisterInstance <IConfigurationManager <SenderConfiguration> >(senderConfig);

            var connectionConfig = new ConnectionStringsConfigurationManager(config);

            controller.RegisterInstance <IConfigurationManager <ConnectionStringConfiguration> >(connectionConfig);

            var ftpConfig = new FtpConfigurationManager(config);

            controller.RegisterInstance <IConfigurationManager <FtpConfiguration> >(ftpConfig);

            var guidesConfig = new GuidesConfigurationManager(config);

            controller.RegisterInstance <IConfigurationManager <GuidesConfiguration> >(guidesConfig);

            var webServiceConfig = new WebServiceConfigurationManager(config);

            controller.RegisterInstance <IConfigurationManager <WebServiceConfiguration> >(webServiceConfig);


            controller.RegisterService <IConfigurationManager <ConverterTask>, ConverterTaskConfigurationManager>();



            // DB CONTEXT SECTION
            //---------------------------------------------

            var recipesConnection = connectionConfig.Get("recipes");
            var recipesDbContext  = new DbContext(recipesConnection.ConnectionString, recipesConnection.ProviderName);

            var remainsConnection = connectionConfig.Get("remains");
            var remainsDbContext  = new DbContext(remainsConnection.ConnectionString, remainsConnection.ProviderName);

            var guidesConnection = connectionConfig.Get("guides");
            var guidesDbContext  = new DbContext(guidesConnection.ConnectionString, guidesConnection.ProviderName);


            //*** inject into IRepositoty<RecipeRow>
            controller.RegisterInstance <DbContext, IRepository <RecipeRow> >(recipesDbContext);

            //*** inject into IRepositoty<RemainRow>
            controller.RegisterInstance <DbContext, IRepository <RemainRow> >(remainsDbContext);

            //*** inject into guides repositories
            controller.RegisterInstance <DbContext, IRepository <Mnn> >(guidesDbContext);
            controller.RegisterInstance <DbContext, IRepository <TradeName> >(guidesDbContext);
            controller.RegisterInstance <DbContext, IRepository <Drug> >(guidesDbContext);
            controller.RegisterInstance <DbContext, IRepository <Drugform> >(guidesDbContext);



            // REPOSITORY SECTION
            //---------------------------------------------

            controller.RegisterService <IRepository <RecipeRow>, RecipeRepository>();
            controller.RegisterService <IRepository <RemainRow>, RemainRepository>();
            controller.RegisterService <IGuideRepository <Mnn>, MnnRepository>();
            controller.RegisterService <IGuideRepository <TradeName>, TradeNameRepository>();
            controller.RegisterService <IGuideRepository <Drug>, DrugRepository>();
            controller.RegisterService <IGuideRepository <Drugform>, DrugformRepository>();

            var logRepo = new LogRepository("logs/");

            controller.RegisterInstance <IRepository <LogRow> >(logRepo);


            var recipesWebServiceConfig = webServiceConfig.Get("RecipeServiceSoap");

            var recipesSoapClient = new RecipeServiceSoapClient(recipesWebServiceConfig.Name,
                                                                recipesWebServiceConfig.RemoteAddress);

            controller.RegisterInstance <RecipeServiceSoap>(recipesSoapClient);

            var remainWebServiceConfig = webServiceConfig.Get("DrugstoreServiceSoap");

            var drugstoreSoapClient = new DrugstoreServiceSoapClient(remainWebServiceConfig.Name,
                                                                     remainWebServiceConfig.RemoteAddress);

            controller.RegisterInstance <DrugstoreServiceSoap>(drugstoreSoapClient);
        }