Пример #1
0
        private void UserAuth()
        {
            string IP       = Request.UserHostName;
            var    compName = DetermineCompName(IP);

            ViewBag.compName = compName.ToUpper();
            var glbcfg = CfgUtility.GetSysConfig(this);

            var usermap = MachineUserMap.RetrieveUserMap();

            foreach (var item in usermap)
            {
                if (!glbcfg.ContainsKey(item.machine))
                {
                    glbcfg.Add(item.machine, item.username);
                }
            }

            if (glbcfg.ContainsKey(ViewBag.compName))
            {
                ViewBag.username = glbcfg[ViewBag.compName].Trim().ToUpper();
            }
            else
            {
                ViewBag.username = ViewBag.compName;
            }
        }
Пример #2
0
        public JsonResult ShareToList()
        {
            var dict = MachineUserMap.RetrieveUserMap();
            var ret  = new JsonResult();

            ret.Data = new
            {
                sharetolist = dict.Values.ToList()
            };
            return(ret);
        }
        private void UserAuth()
        {
            string IP       = Request.UserHostName;
            var    compName = DetermineCompName(IP);

            ViewBag.compName = compName.ToUpper();
            var glbcfg = CfgUtility.GetSysConfig(this);

            var usermap = MachineUserMap.RetrieveUserMap();

            if (usermap.ContainsKey(ViewBag.compName))
            {
                ViewBag.username = usermap[ViewBag.compName].Trim().ToUpper();
                if (glbcfg["VideoAdmin"].ToUpper().Contains(ViewBag.username))
                {
                    ViewBag.VideoAdmin = true;
                }
            }
            else
            {
                ViewBag.username = ViewBag.compName;
            }
        }
        // GET: SmartLinks
        public ActionResult All()
        {
            ViewBag.isie8        = false;
            ViewBag.showie8modal = false;

            var browse = Request.Browser;

            if (string.Compare(browse.Browser, "IE", true) == 0 &&
                (string.Compare(browse.Version, "7.0", true) == 0 ||
                 string.Compare(browse.Version, "8.0", true) == 0))
            {
                ViewBag.isie8 = true;
            }

            //var logonnames = Request.LogonUserIdentity.Name;
            //if (!string.IsNullOrEmpty(logonnames))
            //{
            //    var splitnames = logonnames.Split(new string[] { "/", "\\" }, StringSplitOptions.RemoveEmptyEntries);
            //    ViewBag.logonname = splitnames[splitnames.Length - 1];
            //}

            var machine = string.Empty;
            var ckdict  = CookieUtility.UnpackCookie(this);

            if (!ckdict.ContainsKey("reqmachine"))
            {
                string IP       = Request.UserHostName;
                string compName = DetermineCompName(IP);
                if (!string.IsNullOrEmpty(compName))
                {
                    var tempdict = new Dictionary <string, string>();
                    tempdict.Add("reqmachine", compName);
                    CookieUtility.SetCookie(this, tempdict);
                    machine = compName.ToUpper();
                } //end if
            }     //end
            else
            {
                machine = ckdict["reqmachine"].ToUpper();
            }

            ViewBag.logonname = machine;
            var mudict = MachineUserMap.RetrieveUserMap(machine);

            if (mudict.ContainsKey(machine))
            {
                ViewBag.logonname = mudict[machine];
            }

            if (!string.IsNullOrEmpty(machine))
            {
                ViewBag.machine = machine;
                if (ViewBag.isie8)
                {
                    if (!MachineLink.IsNeverShowIE8Modal(machine))
                    {
                        ViewBag.showie8modal = true;
                    }
                }
            }

            return(View());
        }
        public ActionResult RedirectToLink(string linkname)
        {
            var vm      = new List <LinkVM>();
            var machine = string.Empty;

            var ckdict = CookieUtility.UnpackCookie(this);

            if (!ckdict.ContainsKey("reqmachine"))
            {
                string IP       = Request.UserHostName;
                string compName = DetermineCompName(IP);
                if (!string.IsNullOrEmpty(compName))
                {
                    var tempdict = new Dictionary <string, string>();
                    tempdict.Add("reqmachine", compName);
                    machine = compName.ToUpper();
                    CookieUtility.SetCookie(this, tempdict);
                } //end if
                vm = LinkVM.RetrieveLinks();
            }     //end
            else
            {
                vm      = RetrieveAllLinks(ckdict["reqmachine"]);
                machine = ckdict["reqmachine"].ToUpper();
            }


            var validlink = string.Empty;

            foreach (var item in vm)
            {
                if (string.Compare(linkname, item.LinkName) == 0)
                {
                    validlink = item.Link;
                    if (!string.IsNullOrEmpty(machine))
                    {
                        MachineLink.UpdateFrequence(item.LinkName, item.Link, item.Logo, item.Comment, machine);
                    }
                    break;
                }
            }

            if (!string.IsNullOrEmpty(validlink))
            {
                //var logonnames = Request.LogonUserIdentity.Name;
                //if (!string.IsNullOrEmpty(logonnames))
                //{
                //    var splitnames = logonnames.Split(new string[] { "/", "\\" }, StringSplitOptions.RemoveEmptyEntries);
                //    ViewBag.logonname = splitnames[splitnames.Length - 1];
                //    LinkVM.UpdateSmartLinkLog(ViewBag.logonname,machine, validlink);
                //}

                ViewBag.logonname = machine;
                var mudict = MachineUserMap.RetrieveUserMap(machine);
                if (mudict.ContainsKey(machine))
                {
                    ViewBag.logonname = mudict[machine];
                    LinkVM.UpdateSmartLinkLog(ViewBag.logonname, machine, validlink);
                }


                if (validlink.Contains("wux-engsys01"))
                {
                    var now       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    var timestamp = now + "_joke";
                    using (MD5 md5Hash = MD5.Create())
                    {
                        var smartkey1 = GetMd5Hash(md5Hash, timestamp) + "::" + now;
                        var smartkey2 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(smartkey1));
                        var smartkey  = HttpUtility.UrlEncode(smartkey2);
                        return(Redirect(validlink + "?smartkey=" + smartkey));
                    }
                }
                else
                {
                    return(Redirect(validlink));
                }
            }
            else
            {
                return(RedirectToAction("All", "SmartLinks"));
            }
        }