コード例 #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 LoadDRMProLine()
        {
            var prodlist = CfgUtility.GetSysConfig(this)["DMRTRACEPRODUCTLINES"].Split(new string[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
            var ret      = new JsonResult();

            ret.MaxJsonLength = Int32.MaxValue;
            ret.Data          = new {
                prodlist = prodlist
            };
            return(ret);
        }
コード例 #3
0
        private void UserAuth()
        {
            string IP       = Request.UserHostName;
            var    compName = DetermineCompName(IP);

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

            if (glbcfg.ContainsKey(ViewBag.compName.ToUpper()))
            {
                ViewBag.LogAdmin = true;
            }
        }
コード例 #4
0
        private void UserAuth()
        {
            string IP       = Request.UserHostName;
            var    compName = DetermineCompName(IP);

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

            if (glbcfg["ASSETADMIN"].ToUpper().Contains(ViewBag.compName))
            {
                ViewBag.AssetAdmin = true;
            }
        }
コード例 #5
0
        public ActionResult SnapFile()
        {
            var username = MachineUserMap.GetUseNameByIP(Request.UserHostName);

            if (string.IsNullOrEmpty(username))
            {
                return(RedirectToAction("Welcome", "FileShare"));
            }

            if (CheckIE())
            {
                return(View("ReviewIEError"));
            }

            var syscfg = CfgUtility.GetSysConfig(this);
            var tags   = syscfg["SNAPFILETAGS"].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            ViewBag.taglist = CreateSelectList(tags, "");

            return(View());
        }
コード例 #6
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();

            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;
            }
        }
コード例 #7
0
        public JsonResult VideoLog()
        {
            UserAuth();

            var uselog = false;
            var cfg    = CfgUtility.GetSysConfig(this);

            if (cfg.ContainsKey("UseLog4Net") && cfg["UseLog4Net"].ToUpper().Contains("TRUE"))
            {
                uselog = true;
            }
            else
            {
                uselog = false;
            }

            var vid   = Request.Form["vid"];
            var vname = Request.Form["vname"];

            if (!string.IsNullOrEmpty(vid))
            {
                if (uselog)
                {
                    VideoLogVM.WriteLog(ViewBag.username.ToUpper(), DetermineCompName(Request.UserHostName),
                                        Request.Url.ToString(), "TVideoSite", "ViewVideo", vid, VideoLogType.TechVideo, VLog4NetLevel.Info, vname);
                }
                else
                {
                    VideoLogVM.WriteLog2(ViewBag.username.ToUpper(), DetermineCompName(Request.UserHostName),
                                         Request.Url.ToString(), "TVideoSite", "ViewVideo", vid, VideoLogType.TechVideo, VLog4NetLevel.Info, vname);
                }
            }
            var res = new JsonResult();

            res.Data = new { success = true };
            return(res);
        }
コード例 #8
0
        public JsonResult AddBorrowRequest()
        {
            var borrow_user = Request.Form["borrow_user"];
            var pro_no      = Request.Form["pro_no"];
            var islong      = Request.Form["islong"];
            var sdate       = Request.Form["sdate"];
            var edate       = Request.Form["edate"];
            var comment     = Request.Form["comment"];
            var assets      = (List <string>)Newtonsoft.Json.JsonConvert.DeserializeObject(Request.Form["assets"], (new List <string>()).GetType());
            var borrowlist  = new List <AssetBorrowHistoryVM>();
            var rid         = DateTime.Now.ToString("yyyyMMddHHmmss");
            var table       = new List <List <string> >();
            var e_tmp       = new List <string>();

            e_tmp.Add("RequestID");
            e_tmp.Add("CN");
            e_tmp.Add("English Name");
            e_tmp.Add("Chinese Name");
            e_tmp.Add("Model");
            table.Add(e_tmp);
            foreach (var item in assets)
            {
                var tmp = new AssetBorrowHistoryVM();
                tmp.RequestID     = rid;
                tmp.AssetID       = item;
                tmp.BorrowUser    = borrow_user;
                tmp.ProjectNo     = pro_no;
                tmp.IsLong        = islong;
                tmp.StartDate     = sdate;
                tmp.EndDate       = edate;
                tmp.BorrowComment = comment;
                borrowlist.Add(tmp);
            }
            AssetBorrowHistoryVM.NewBorrow(borrowlist);
            //send confirm email
            var asset_info = AssetVM.GetAssetList("", "", "", "('" + string.Join("','", assets) + "')");

            foreach (var item in asset_info)
            {
                e_tmp = new List <string>();
                e_tmp.Add(rid);
                e_tmp.Add(item.Value.CN);
                e_tmp.Add(item.Value.EnglishName);
                e_tmp.Add(item.Value.ChineseName);
                e_tmp.Add(item.Value.Supplier);
                table.Add(e_tmp);
            }
            var towho       = borrow_user.Split(new char[] { '@' })[0];
            var greeting    = "Hi, " + towho;
            var description = "The following device(s) have been borrowed by you on " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            var content     = EmailUtility.CreateTableHtml(greeting, description, null, table);
            var glbcfg      = CfgUtility.GetSysConfig(this);
            var towholist   = new List <string>();

            towholist.Add(borrow_user);
            if (!string.IsNullOrEmpty(glbcfg["ASSETADMINUSER"]))
            {
                var user_list = glbcfg["ASSETADMINUSER"].Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
                towholist.AddRange(user_list);
            }
            EmailUtility.SendEmail(this, "Borrow Device(s) -- " + DateTime.Now.ToString("MM/dd/yyyy"), towholist, content, true);

            var res = new JsonResult();

            res.Data = new { success = true };
            return(res);
        }