public static Dictionary <string, string> RetrieveUserMap(string machine = "", string username = "")
        {
            var ret = new Dictionary <string, string>();

            var sql = "select machine,username from machineusermap where 1 = 1";

            if (!string.IsNullOrEmpty(machine))
            {
                sql = sql + " and machine = '<machine>'";
                sql = sql.Replace("<machine>", machine);
            }
            if (!string.IsNullOrEmpty(username))
            {
                sql = sql + " and username = '******'";
                sql = sql.Replace("<username>", username);
            }

            var dbret = DBUtility.ExeLocalSqlWithRes(sql);

            foreach (var line in dbret)
            {
                var tempvm = new MachineUserMap();
                tempvm.machine  = Convert.ToString(line[0]);
                tempvm.username = Convert.ToString(line[1]);
                if (!ret.ContainsKey(tempvm.machine))
                {
                    ret.Add(tempvm.machine, tempvm.username);
                }
            }
            return(ret);
        }
Exemple #2
0
        public static void StoreUserScore(string ma, string iname, string vid, string cans, string uans, string usc)
        {
            var uname = iname.Split(new string[] { "@" }, StringSplitOptions.RemoveEmptyEntries)[0].ToUpper().Trim();

            MachineUserMap.TryAddMachineUserMap(ma, uname);

            if (ScoreExist(uname, vid).Count == 0)
            {
                var videos = TechVideoVM.RetrieveVideoByID(vid);
                if (videos.Count > 0)
                {
                    UpdateUserRank(uname, usc);

                    var sql   = @"insert into VTestScore(MACHINE,UserName,VID,VSubject,CorrectiveAnswer,UserAnswer,UserScore,UpdateTime)  
                                values(@MACHINE,@UserName,@VID,@VSubject,@CorrectiveAnswer,@UserAnswer,@UserScore,@UpdateTime)";
                    var param = new Dictionary <string, string>();
                    param.Add("@MACHINE", ma);
                    param.Add("@UserName", uname);
                    param.Add("@VID", vid);
                    param.Add("@VSubject", videos[0].VSubject);
                    param.Add("@CorrectiveAnswer", cans);
                    param.Add("@UserAnswer", uans);
                    param.Add("@UserScore", usc);
                    param.Add("@UpdateTime", DateTime.Now.ToString());
                    DBUtility.ExeLocalSqlNoRes(sql, param);
                }
            }
        }