Ejemplo n.º 1
0
        public List<ClusterInfo> GetListCluster()
        {
            Predict_DAO_MCol a = new Predict_DAO_MCol();
            List<ClusterInfo> list = new List<ClusterInfo>();

            try
            {
                a.beginTransaction();
                list = a.GetListCluster();
                a.commitTransaction();
                return list;
            }
            catch (Exception ex)
            {
                a.rollbackTransaction();
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public void LoadRecommendation(string LoginID)
        {
            Predict_DAO_MCol dao = null;

            RecommdationSchedule schedule = new RecommdationSchedule();
            schedule.Log = "Recommendation";
            schedule.LoginID = LoginID;
            Predict_MC predictMC = new Predict_MC();
            try
            {
                dao = new Predict_DAO_MCol();
                dao.beginTransaction();
                RecommdationSchedule currentSchedule = dao.addRecommdationSchedule(schedule);
                //Settings st = getSettings();
                Settings r = predictMC.GetRecommendationSeting(dao);
                Dictionary<string, double> UCA = predictMC.getUCA(dao);

                //Data service
                IntergrationManager manager = new IntergrationManager();
                manager.execute();

                //Clustering service
                new ClusterUsers().startClusteringAuto();

                /*
                 *
                 *
                 * this paragraph need to rewrite
                 *
                 * */
                //calculate confident matrix - c4
                ComputeConfident(dao);
                // calculate dist matrix - C5
                ComputeDIST(dao);

                //=====================================================================================

                dao.CLEAN_RECOMMENDATION();

                // R1
                DateTime startC6 = DateTime.Now;
                // predictMC.R1(dao, currentSchedule, r.nbR1, UCA, lstGAP);
                predictMC.R1(dao, currentSchedule);
                DateTime endC6 = DateTime.Now;
                int time_Seconds_CLC6 = Convert.ToInt32((endC6 - startC6).TotalSeconds);

                //////R2
                //DateTime startC7 = DateTime.Now;
                //setRCPurchasedItems(dao, currentSchedule, r.nbR2, lstGAP);
                //DateTime endC7 = DateTime.Now;
                //int time_Seconds_CLC7 = Convert.ToInt32((endC7 - startC7).TotalSeconds);

                //// R3
                DateTime startC8 = DateTime.Now;
                // predictMC.R3(dao, currentSchedule, r.nbR3, UCA, lstGAP);
                predictMC.R3(dao, currentSchedule);
                DateTime endC8 = DateTime.Now;
                int time_Seconds_CLC8 = Convert.ToInt32((endC8 - startC8).TotalSeconds);

                //// R4
                DateTime startC9 = DateTime.Now;
                // predictMC.R4(dao, currentSchedule, r.paramR4, UCA, lstGAP);
                predictMC.R4(dao, currentSchedule);
                DateTime endC9 = DateTime.Now;
                int time_Seconds_CLC9 = Convert.ToInt32((endC9 - startC9).TotalSeconds);

                ////Get R1R4 for new users
                DateTime startR1R4NewUsers = DateTime.Now;
                predictMC.R1R4_FOR_NEW_USERS(dao, currentSchedule, UCA);
                DateTime endR1R4NewUsers = DateTime.Now;
                int time_second_R1R4NewUsers = Convert.ToInt32((endR1R4NewUsers - startR1R4NewUsers).TotalSeconds);

                //GetPrice
                //dao.GetPrice();

                Console.WriteLine("FINISH");

                // build statistic log
                List<string[]> lstStatic = dao.getStaticsData();
                foreach (string[] statics in lstStatic)
                {
                    schedule.Log += statics[0] + statics[1] + ". ";
                }

                schedule.Log += "Time to find LRS01 : " + time_Seconds_CLC6.ToString() + ". ";
                //schedule.Log += "Time to find LRS02 : " + time_Seconds_CLC7.ToString() + ". ";
                schedule.Log += "Time to find LRS03 : " + time_Seconds_CLC8.ToString() + ". ";
                schedule.Log += "Time to find LRS04 : " + time_Seconds_CLC9.ToString() + ". ";
                schedule.Log += "Time to find recommendations for new clients : " + time_second_R1R4NewUsers.ToString() + ". ";
                schedule.Log += "System successfully stopped at " + DateTime.Now.ToString();

                dao.updateRecommdationSchedule(schedule);
                dao.commitTransaction();

            }
            catch (Exception ex)
            {
                dao.rollbackTransaction();
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public Settings GetRecommendationSeting(Predict_DAO_MCol a)
        {
            Settings st = new Settings();

            try
            {
                List<Recommendation_Setting> listCs = a.GetRecommendationSetting();

                if (null != listCs && listCs.Count > 0)
                    foreach (var item in listCs)
                    {
                        if (item.Key.Equals(ConstantValues.nb_R1))
                        {
                            foreach (var cs_detail in item.Values)
                                if (cs_detail.isDedault.Equals(true))
                                {
                                    st.nbR1 = Convert.ToInt32(cs_detail.Value.Trim());
                                    break;
                                }
                        }
                        else
                            if (item.Key.Equals(ConstantValues.nb_R2))
                            {
                                foreach (var cs_detail in item.Values)
                                    if (cs_detail.isDedault.Equals(true))
                                    {
                                        st.nbR2 = Convert.ToInt32(cs_detail.Value.Trim());
                                        break;
                                    }
                            }
                            else if (item.Key.Equals(ConstantValues.nb_R3))
                            {
                                foreach (var cs_detail in item.Values)
                                    if (cs_detail.isDedault.Equals(true))
                                    {
                                        st.nbR3 = Convert.ToInt32(cs_detail.Value.Trim());
                                        break;
                                    }
                            }
                            else if (item.Key.Equals(ConstantValues.param_R4))
                            {
                                foreach (var cs_detail in item.Values)
                                    if (cs_detail.isDedault.Equals(true))
                                    {
                                        st.paramR4 = Convert.ToDouble(cs_detail.Value.Trim(), CultureInfo.CreateSpecificCulture("en-GB"));
                                        break;
                                    }
                            }
                    }

            }
            catch (Exception ex)
            {
                a.rollbackTransaction();
                throw ex;
            }
            return st;
        }
Ejemplo n.º 4
0
 public List<Recommendation_Meta_Item> GetRecommendations(string sql)
 {
     Predict_DAO_MCol a = new Predict_DAO_MCol();
     try
     {
         a.beginTransaction();
         List<Recommendation_Meta_Item> list = a.GetRecommendations(sql);
         a.commitTransaction();
         return list;
     }
     catch (Exception ex)
     {
         a.rollbackTransaction();
         throw ex;
     }
 }