Ejemplo n.º 1
0
 //SONNT: has modified
 //public void addRecommdationSchedule(RecommdationSchedule schedule)
 //{
 //    string strQuery = "INSERT INTO [RS].[RECOMMENDATION_SCHEDULE_TBL] ([StartTime] ,[Log] ,[LoginID]) VALUES ( GETDATE(), @Log , @LoginID)";
 //    Dictionary<string, object> parameters = new Dictionary<string, object>();
 //    parameters.Add("@Log", schedule.Log);
 //    parameters.Add("@LoginID", schedule.LoginID);
 //    executeNonQuery(strQuery, parameters);
 //}
 public RecommdationSchedule addRecommdationSchedule(RecommdationSchedule schedule)
 {
     string strQuery = "INSERT INTO [RS].[RECOMMENDATION_SCHEDULE_TBL] ([StartTime] ,[Log] ,[LoginID]) VALUES ( GETDATE(), @Log , @LoginID)";
     Dictionary<string, object> parameters = new Dictionary<string, object>();
     parameters.Add("@Log", schedule.Log);
     parameters.Add("@LoginID", schedule.LoginID);
     executeNonQuery(strQuery, parameters);
     //query the schedule also
     strQuery = "SELECT TOP 1 [ScheduleID],[StartTime],[StopTime],[Log],[LoginID] FROM [RS].[RECOMMENDATION_SCHEDULE_TBL] ORDER BY [StartTime] DESC";
     SqlDataReader dr = executeReader(strQuery);
     if (dr.Read())
     {
         schedule.ScheduleID = dr.GetInt32(dr.GetOrdinal("ScheduleID"));
     }
     dr.Close();
     return schedule;
 }
Ejemplo n.º 2
0
        public List<RecommdationSchedule> getSchedules()
        {
            string strSelect = "SELECT [ScheduleID],[StartTime],[StopTime],[Log] FROM [RS].[RECOMMENDATION_SCHEDULE_TBL] ORDER BY [StartTime] DESC";
            SqlDataReader dr = executeReader(strSelect);

            List<RecommdationSchedule> list = new List<RecommdationSchedule>();
            while (dr.Read())
            {
                RecommdationSchedule obj = new RecommdationSchedule();
                obj.ScheduleID = dr.GetInt32(dr.GetOrdinal("ScheduleID"));
                obj.Log = dr.GetString(dr.GetOrdinal("Log"));
                obj.StartTime = dr.GetDateTime(dr.GetOrdinal("StartTime"));
                obj.StopTime = (dr["StopTime"] == System.DBNull.Value) ? (DateTime?)null : dr.GetDateTime(dr.GetOrdinal("StopTime"));
                list.Add(obj);
            }
            dr.Close();
            return list;
        }
Ejemplo n.º 3
0
 public void updateRecommdationSchedule(RecommdationSchedule schedule)
 {
     string strQuery = "UPDATE [RS].RECOMMENDATION_SCHEDULE_TBL SET [StopTime] = GETDATE(),[Log] = @Log WHERE [ScheduleID] in (SELECT TOP 1 [ScheduleID] FROM [RS].RECOMMENDATION_SCHEDULE_TBL ORDER BY [StartTime] DESC) ";
     Dictionary<string, object> parameters = new Dictionary<string, object>();
     parameters.Add("@Log", schedule.Log);
     executeNonQuery(strQuery, parameters);
 }
Ejemplo n.º 4
0
 public void R4(Predict_DAO_MC dao, RecommdationSchedule schedule, double paramR4, Dictionary<string, double> UCA, List<QTY_GAP> lst)
 {
     List<Recommendation_Meta_Item> list = GetRecommendationR4(dao, paramR4, UCA);
     Normaliser(list);
     AddGAPtoListRecommends(lst, list);
     dao.InsertList(list, schedule);
 }
Ejemplo n.º 5
0
 public void R3(Predict_DAO_MC dao, RecommdationSchedule schedule, int nbR3, Dictionary<string, double> UCA, List<QTY_GAP> lst)
 {
     List<Recommendation_Meta_Item> list = GetRecommendationR3(dao, nbR3);
     list = GetQuantityTraditionalUsersR3(dao, list, UCA);
     dao.RemoveDuplicateR3R1();
     Normaliser(list);
     AddGAPtoListRecommends(lst, list);
     dao.InsertList(list, schedule);
 }
Ejemplo n.º 6
0
 public void R1R4_FOR_NEW_USERS(Predict_DAO_MC dao, RecommdationSchedule schedule, Dictionary<string, double> UCA)
 {
     List<Recommendation_Meta_Item> lrc_ForNewUsers = GetListR1R4_ForNewUsers(dao, UCA);
     // lrc_ForNewUsers = GetQuantityNewUsers(dao, lrc_ForNewUsers);
     Normaliser(lrc_ForNewUsers);
     dao.InsertListNewUser(lrc_ForNewUsers, schedule);
 }
Ejemplo n.º 7
0
 //Corrected by MC. NGUYEN 22.10.2014
 public void R1(Predict_DAO_MC dao, RecommdationSchedule schedule, int nbR1, Dictionary<string, double> UCA, List<QTY_GAP> list)
 {
     //Get recommendations for traditional users
     List<Recommendation_Meta_Item> lrc_ForUserTra = getListRecommendation_R1_TraditionalUsers(dao, nbR1);
     lrc_ForUserTra = GetQuantityTraditionalUsers(dao, lrc_ForUserTra, UCA);
     Normaliser(lrc_ForUserTra);
     AddGAPtoListRecommends(list, lrc_ForUserTra);
     dao.InsertList(lrc_ForUserTra, schedule);
 }
Ejemplo n.º 8
0
        public void InsertListNewUser(List<Recommendation_Meta_Item> list, RecommdationSchedule schedule)
        {
            try
            {
                int i = 0;
                foreach (Recommendation_Meta_Item item in list)
                {

                    string str = i.ToString();
                    Dictionary<string, object> parameters = new Dictionary<string, object>();
                    string[] MetaID = item.MetaItemID.Split('_');
                    item.MetaItemID = MetaID[0];
                    item.ItemFamillyCode = MetaID[1];

                    parameters.Add("@F1", schedule.ScheduleID);
                    parameters.Add("@F2", item.Quantity.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
                    parameters.Add("@F3", item.Score.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
                    command.Parameters.Clear();
                    foreach (KeyValuePair<string, object> pair in parameters)
                    {
                        command.Parameters.AddWithValue(pair.Key, pair.Value);
                    }
                    command.CommandText = "INSERT INTO [RS].[RECOMMENDATION_NEWUSERS_TBL]([ScheduleID],[MetaItemID],[U_SubCategoryID],[Quantity],[Score],[RecommendType],[ItemFamillyCode]) " +
                                          "VALUES (@F1, '" + item.MetaItemID + "','" + item.UserID + "',@F2, @F3, '" + item.RecommendType + "','" + item.ItemFamillyCode + "')";
                    int nbRow = command.ExecuteNonQuery();
                    i++;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 9
0
 public void setRCPurchasedItems(Predict_DAO dao, RecommdationSchedule schedule, int nbR2, List<QTY_GAP> lst)
 {
     //Content is cleared by M.C. Nguyen 19.9.2015
 }
Ejemplo n.º 10
0
        public void LoadRecommendation(string LoginID)
        {
            Predict_DAO_MC dao = null;

            RecommdationSchedule schedule = new RecommdationSchedule();
            schedule.Log = "Recommendation";
            schedule.LoginID = LoginID;
            Predict_MC predictMC = new Predict_MC();

            try
            {
                dao = new Predict_DAO_MC();
                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();

                //Learn the quantity GAP
                List<ADDGAP> lstADDGAP = predictMC.GetListOfNewGAP(dao);       //get list of new GAP
                List<QTY_GAP> lstGAP = predictMC.UpdateQTYGap(dao, lstADDGAP);   //Update new GAP and return the GAP Matrix

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

                /*
                 *
                 *
                 * this paragraph need to rewrite
                 *
                 * */
                //C4
                ComputeConfident(dao);
                // C5
                ComputeDIST(dao);

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

                //dao.CLEAN_RECOMMENDATION();

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

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

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

                //// C9 - MC
                DateTime startC9 = DateTime.Now;
                predictMC.R4(dao, currentSchedule, r.paramR4, UCA, lstGAP);
                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.º 11
0
 public void setRCPurchasedItems(Predict_DAO dao, RecommdationSchedule schedule, int nbR2, List<QTY_GAP> lst)
 {
 }
Ejemplo n.º 12
0
 public void R4(Predict_DAO_MCol dao, RecommdationSchedule schedule)
 {
     List<Recommendation_Meta_Item> recommendationR4 = this.GetRecommendationR4(dao, 2.0);
     this.Normaliser(recommendationR4);
     dao.InsertList(recommendationR4, schedule);
 }
Ejemplo n.º 13
0
 public void R3(Predict_DAO_MCol dao, RecommdationSchedule schedule)
 {
     List<Recommendation_Meta_Item> recommendationR3 = this.GetRecommendationR3(dao);
     List<Recommendation_Meta_Item> traditionalUsersR3 = this.GetQuantityTraditionalUsersR3(dao, recommendationR3);
     this.Normaliser(traditionalUsersR3);
     dao.InsertList(traditionalUsersR3, schedule);
 }
Ejemplo n.º 14
0
 public void R1(Predict_DAO_MCol dao, RecommdationSchedule schedule)
 {
     List<Recommendation_Meta_Item> traditionalUsers1 = this.getListRecommendation_R1_TraditionalUsers(dao);
     List<Recommendation_Meta_Item> traditionalUsers2 = this.GetQuantityTraditionalUsers(dao, traditionalUsers1);
     this.Normaliser(traditionalUsers2);
     dao.InsertList(traditionalUsers2, schedule);
 }