예제 #1
0
파일: items.aspx.cs 프로젝트: lnyousif/zlnk
        protected void deleteUserButton_Click(object sender, EventArgs e)
        {
            LinkButton button = sender as LinkButton;

            string[] p            = button.CommandArgument.Split(new char[] { '|' });
            string   partitionKey = p[0];
            string   rowKey       = p[1];

            usr u = new usr()
            {
                PartitionKey = partitionKey,
                RowKey       = rowKey
            };


            zlnkDC svc = new zlnkDC();

            svc.AttachTo("usrs", u, "*");
            svc.DeleteObject(u);

            try
            {
                svc.SaveChanges();
            }
            catch (DataServiceRequestException e2)
            {
            }
        }
예제 #2
0
        public ActionResult Login(usr user)
        {
            var usr = db.usrs.Where(u => u.userName == user.userName && u.userPassword == user.userPassword).FirstOrDefault();

            if (usr != null)
            {
                Session["UserId"]   = usr.userId.ToString();
                Session["Username"] = usr.userName.ToString();
                Session["UserType"] = usr.userType.ToString();
                if (Session["UserType"].ToString() == "Admin")
                {
                    return(RedirectToAction("Index", "users"));
                }
                else if (Session["UserType"].ToString() == "Agent")
                {
                    return(RedirectToAction("Index", "Bookings"));
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
            else
            {
                ModelState.AddModelError("", "Username or Password is wrong.");
            }

            return(View());
        }
예제 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            usr usr = db.usrs.Find(id);

            db.usrs.Remove(usr);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
 public ActionResult Edit([Bind(Include = "userId,userName,userPassword,userType")] usr usr)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usr).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(usr));
 }
예제 #5
0
        public ActionResult Create([Bind(Include = "userId,userName,userPassword,userType")] usr usr)
        {
            if (ModelState.IsValid)
            {
                db.usrs.Add(usr);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(usr));
        }
예제 #6
0
 public ActionResult Search(string search, usr x)
 {
     //if a user choose the radio button option as Subject
     if (search != "")
     {
         //Index action method will return a view with a student records based on what a user specify the value in textbox
         return(View("Index", db.usrs.Where(db => db.userName == search).ToList()));
     }
     else
     {
         return(View(db.usrs.ToList()));
     }
 }
예제 #7
0
 public void render_me(auth a)
 {
     if (a.result)
     {
         pr = Instantiate(prefab_pr, new Vector3(), new Quaternion());
         usr p = pr.GetComponent <usr>();
         p.ini(a.value.photo);
         p.id       = a.value.id;
         p.name     = a.value.name;
         p.position = new Vector3((float)a.value.coord[0], (float)a.value.coord[0], 0);
         p.status   = a.value.status;
     }
 }
예제 #8
0
        // GET: users/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            usr usr = db.usrs.Find(id);

            if (usr == null)
            {
                return(HttpNotFound());
            }
            return(View(usr));
        }
예제 #9
0
파일: items.aspx.cs 프로젝트: lnyousif/zlnk
        protected void ActivateUserButton_Click(object sender, EventArgs e)
        {
            LinkButton button = sender as LinkButton;

            string[] p            = button.CommandArgument.Split(new char[] { '|' });
            string   partitionKey = p[0];
            string   rowKey       = p[1];

            zlnkDC svc = new zlnkDC();
            usr    us  = (from u in svc.usrs where u.PartitionKey == partitionKey && u.RowKey == rowKey select u).FirstOrDefault <usr>();

            us.IsActive = us.IsActive ? false : true;

            svc.UpdateObject(us);
            svc.SaveChanges();
        }
예제 #10
0
파일: zapp.cs 프로젝트: lnyousif/zlnk
 public static bool GetUserDomain(string sUN, out string sShortDN, out string sLongDN)
 {
     try
     {
         zlnkDC svc = new zlnkDC();
         usr    us  = (from u in svc.usrs where u.UN == sUN && u.IsActive.Equals(true) select u).First <usr>();
         sShortDN = us.ShortDN;
         sLongDN  = us.LongDN;
         return(true);
     }
     catch
     {
         sShortDN = "";
         sLongDN  = "";
         return(false);
     }
 }
예제 #11
0
파일: login.aspx.cs 프로젝트: lnyousif/zlnk
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            zlnkDC svc = new zlnkDC();

            try
            {
                usr us = (from u in svc.usrs where u.UN == txtUN0.Text && u.Pwd == CryptoHelper.Encrypt(txtPwd0.Text) select u).First <usr>();

                if (us.IsActive)
                {
                    LoadLinks();
                }
            }
            catch
            {
                lblMesssage.Text = "your account info is wrong";
            }
        }
예제 #12
0
 public void render_or(user_info a)
 {
     if (ini.finBbyId(a.id) == null)
     {
         GameObject ty = Instantiate(prefab_pr, new Vector3(), new Quaternion());
         ty.name = "fd_" + a.id;
         usr p = ty.GetComponent <usr>();
         p.ini(a.photo);
         p.id                  = a.id;
         p.position            = new Vector3((float)a.coord[0], (float)a.coord[0], 0);
         p.status              = a.status;
         ty.transform.position = new Vector3((float)a.coord[0], (float)a.coord[0], 0);
     }
     else
     {
         GameObject ty = ini.finBbyId(a.id);
         ty.transform.position = new Vector3((float)a.coord[0], (float)a.coord[0], 0);
     }
 }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            using (var db = new ddiarydbEntities())
            {
                var user = new usr();

                if (Regex.IsMatch(context.UserName, @"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}", RegexOptions.IgnoreCase))
                {
                    user = db.usrs.FirstOrDefault(x => x.Email == context.UserName);
                }
                else if (Regex.IsMatch(context.UserName, @"(\d*-)?\d{10}", RegexOptions.IgnoreCase))
                {
                    user = (from x in db.Doctor_Master
                            join u in db.usrs on x.User_id equals u.Id
                            where x.Doctor_contact == context.UserName
                            select u).FirstOrDefault();
                }
                else
                {
                    user = null;
                }

                if (user != null && user.passwd == context.Password)
                {
                    identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
                    identity.AddClaim(new Claim("username", user.Email));
                    identity.AddClaim(new Claim(ClaimTypes.Name, user.Firstname + " " + user.Lastname));
                    context.Validated(identity);
                }
                else
                {
                    context.SetError("invalid_grant", "Provided username and password is incorrect");
                    return;
                }
            }
        }
예제 #14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            zlnkDC svc = new zlnkDC();

            if (txtSDN.Text.EndsWith("/"))
            {
                txtSDN.Text = txtSDN.Text.Remove(txtSDN.Text.Length - 1);
            }

            if (txtODN.Text.EndsWith("/"))
            {
                txtODN.Text = txtODN.Text.Remove(txtODN.Text.Length - 1);
            }

            string PLID = "free";

            if (txtSDN.Text.Trim() != "http://zlnk.net")
            {
                PLID = "pro1";
            }


            try
            {
                usr us = (from u in svc.usrs where u.UN == txtUN.Text select u).First <usr>();
                lblMesssage.Text = "Username is already in use";
            }
            catch
            {
                usr user = new usr(txtUN.Text, CryptoHelper.Encrypt(txtPwd.Text), txtSDN.Text, txtODN.Text, txtEmail.Text, PLID);
                user.IsActive = true;

                svc.AddObject("usrs", user);
                svc.SaveChanges();

                lblMesssage.Text = "Your user account got created";
            }
        }
예제 #15
0
        public string Post([FromBody] JObject jObj)
        {
            DBEntities    db     = new DBEntities();
            List <usr>    uData  = db.usr.ToList();
            List <course> cData  = db.course.ToList();
            List <uc>     ucData = db.uc.ToList();

            string type = jObj["type"].ToString();       //客户端操作类型

            if (type.Equals("login"))
            {
                string inNo = jObj["no"].ToString();
                string inPw = jObj["pw"].ToString();
                //匹配成功,返回users的id,密码错误返回-1, 账号不存在返回0
                for (int i = 0; i < uData.Count; i++)
                {
                    if (uData[i].no == inNo)
                    {
                        if (uData[i].pw == inPw)
                        {
                            return(uData[i].uid.ToString());
                        }
                        else
                        {
                            return("-1");
                        }
                    }
                }
                return("0");
            }
            else if (type.Equals("register"))
            {
                string no     = jObj["no"].ToString();
                string pw     = jObj["pw"].ToString();
                string school = jObj["school"].ToString();
                string major  = jObj["major"].ToString();

                usr uTmp = db.usr.Where(usr => usr.no == no).FirstOrDefault();
                if (uTmp == null)
                {
                    usr u = new usr()
                    {
                        no = no, pw = pw, school = school, major = major
                    };
                    db.usr.Add(u);
                    if (db.SaveChanges() > 0)
                    {
                        return("1");
                    }
                    return("-1");
                }
                else
                {
                    return("0");
                }
            }
            else if (type.Equals("getCourseInfo"))
            {
                int           uid      = int.Parse(jObj["uid"].ToString()); //得到客户端当前登录用户的id
                List <course> cUidData = new List <course>();               //储存匹配到的当前用户的课程信息
                for (int i = 0; i < ucData.Count; i++)
                {
                    if (ucData[i].uid == uid)
                    {
                        for (int j = 0; j < cData.Count; j++)
                        {
                            if (cData[j].cid == ucData[i].cid)
                            {
                                course c = new course();      //一条课程记录
                                c.cid        = cData[j].cid;
                                c.coursename = cData[j].coursename;
                                c.teacher    = cData[j].teacher;
                                c.classroom  = cData[j].classroom;
                                c.classstart = cData[j].classstart;
                                c.classend   = cData[j].classend;
                                c.day        = cData[j].day;
                                cUidData.Add(c);
                            }
                        }
                    }
                }
                return(JsonConvert.SerializeObject(cUidData));
            }

            else if (type.Equals("addCourse") || type.Equals("editCourse") || type.Equals("delCourse"))
            {
                int uid = int.Parse(jObj["uid"].ToString());       //得到当前用户的id
                int cid = int.Parse(jObj["cid"].ToString());       //得到课程id,若type为edit则为修改前的id,若为del则为要删除的id, 若为add则为0(防止空指针异常)


                if (type.Equals("delCourse"))       //删除操作
                {
                    uc ucTmp = db.uc.Where(uc => uc.uid == uid && uc.cid == cid).FirstOrDefault();
                    db.uc.Remove(ucTmp);
                }
                else
                {
                    //得到修改后的课程
                    string cn  = jObj["coursename"].ToString();
                    string tn  = jObj["teacher"].ToString();
                    string cr  = jObj["classroom"].ToString();
                    int    cs  = int.Parse(jObj["classstart"].ToString());
                    int    ce  = int.Parse(jObj["classend"].ToString());
                    int    day = int.Parse(jObj["day"].ToString());
                    if (type.Equals("addCourse"))        //若添加的课程与已存在的课程时间段有重合,则添加失败
                    {
                        List <course> cSEList   = db.course.Where(course => course.classstart >= cs && course.classend <= ce && course.day == day).ToList();
                        List <uc>     ucUidList = db.uc.Where(uc => uc.uid == uid).ToList();
                        for (int i = 0; i < cSEList.Count; i++)
                        {
                            for (int j = 0; j < ucUidList.Count; j++)
                            {
                                if (cSEList[i].cid == ucUidList[j].cid)
                                {
                                    return("0");
                                }
                            }
                        }
                    }

                    course cTmp1 = db.course.Where(course => course.coursename == cn &&
                                                   course.teacher == tn &&
                                                   course.classroom == cr &&
                                                   course.classstart == cs &&
                                                   course.classend == ce &&
                                                   course.day == day
                                                   ).FirstOrDefault();

                    course c     = new course();
                    course cTmp2 = new course();
                    if (cTmp1 == null)
                    {
                        cTmp2.coursename = cn;
                        cTmp2.teacher    = tn;
                        cTmp2.classroom  = cr;
                        cTmp2.classstart = cs;
                        cTmp2.classend   = ce;
                        cTmp2.day        = day;
                        db.course.Add(cTmp2);
                        db.SaveChanges();
                        c = cTmp2;
                    }
                    else
                    {
                        c = cTmp1;
                    }

                    if (type.Equals("addCourse"))        //添加操作
                    {
                        uc ucTmp = new uc()
                        {
                            uid = uid, cid = c.cid
                        };
                        db.uc.Add(ucTmp);
                    }
                    else if (type.Equals("editCourse"))     //编辑操作
                    {
                        uc ucUid = db.uc.Where(uc => uc.uid == uid && uc.cid == cid).FirstOrDefault();
                        ucUid.cid = c.cid;
                    }
                    cid = c.cid;        //便于返回cid
                }
                if (db.SaveChanges() > 0)
                {
                    return(cid.ToString());
                }
                return("0");
            }
            return("0");
        }
예제 #16
0
        public static void show_stat(stats form_stat)
        {
            form_stat.fLP.Controls.Clear();


            List <stat> stat = load_stat("data\\results\\results.csv");

            if (stat == null)
            {
                MessageBox.Show("Проидите хотя бы один тест");

                return;
            }


            string[] users = new string[stat.Count];
            for (int i = 0; i < stat.Count; i++)
            {
                users[i] = stat[i].login;
            }
            users = users.Distinct().ToArray();

            List <usr> struct_users = new List <usr>();
            usr        tmp_user     = new usr();

            foreach (string user in users)
            {
                List <stat> s = stat.FindAll(a => a.login == user);
                int         sum = 0, percent = 0;
                foreach (var test in s)
                {
                    sum += Convert.ToInt32(test.percent);
                }

                percent       = sum / s.Count;
                tmp_user.user = user; tmp_user.percent = percent; tmp_user.fio = s[0].fio;
                struct_users.Add(tmp_user);
            }

            //	соритровка по кол-ву баллов
            struct_users.Sort((a, b) => (b.percent.CompareTo(a.percent)));

            foreach (usr user in struct_users)
            {
                Label lb = new Label();
                lb.AutoSize = true;
                lb.Anchor   = AnchorStyles.None;
                lb.Dock     = DockStyle.Fill;
                //lb.TextAlign = ContentAlignment.MiddleCenter;
                lb.TextAlign = ContentAlignment.MiddleLeft;
                lb.ForeColor = Color.FromArgb(255, 200, 255, 255);
                lb.Font      = new Font("Times New Roman", 15, FontStyle.Bold);

                lb.Text = "\r\n" + user.fio + ": " + user.percent + "%\r\n";
                form_stat.fLP.WrapContents = false;
                form_stat.fLP.Controls.Add(lb);
            }
            // Sort((a, b) => (a.ToString()[0].CompareTo(b.ToString()[0])));

            form_stat.Show();
        }