Beispiel #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;
            }
        }
        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);
        }
        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;
            }
        }
        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;
            }
        }
        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());
        }
Beispiel #6
0
        public ActionResult CreateNewTopic()
        {
            UserAuth();
            var employlist = new List <string>();

            employlist.AddRange(CoTopicVM.GetNewPeopleList());
            employlist.AddRange(CfgUtility.GetEmployeeList(this));
            ViewBag.EmployeeList = Newtonsoft.Json.JsonConvert.SerializeObject(employlist.ToArray());

            var pjlist = new List <string>();

            pjlist.AddRange(CoTopicVM.GetNewPJList());
            pjlist.AddRange(CfgUtility.GetPJList(this));
            ViewBag.PJList  = Newtonsoft.Json.JsonConvert.SerializeObject(pjlist.ToArray());
            ViewBag.TopicId = CoTopicVM.GetUniqKey();

            var tempnavlist = new List <string>();

            tempnavlist.AddRange(new string[] { TopicBelongType.ICreate, TopicBelongType.IAssign, TopicBelongType.IRelated, TopicBelongType.Completed });
            ViewBag.NavList = tempnavlist;

            return(View());
        }
        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;
            }
        }
        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);
        }
        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);
        }
Beispiel #10
0
        // GET: CoWork
        public ActionResult Home(string activenavitem, string topicid, string searchkey)
        {
            UserAuth();

            if (string.Compare(ViewBag.username, ViewBag.compName) == 0)
            {
                return(RedirectToAction("Welcome"));
            }

            var employlist = new List <string>();

            employlist.AddRange(CoTopicVM.GetNewPeopleList());
            employlist.AddRange(CfgUtility.GetEmployeeList(this));
            ViewBag.EmployeeList = Newtonsoft.Json.JsonConvert.SerializeObject(employlist.ToArray());

            var pjlist = new List <string>();

            pjlist.AddRange(CoTopicVM.GetNewPJList());
            pjlist.AddRange(CfgUtility.GetPJList(this));
            ViewBag.PJList = Newtonsoft.Json.JsonConvert.SerializeObject(pjlist.ToArray());

            //nav list
            var tempnavlist = new List <string>();

            tempnavlist.AddRange(new string[] { TopicBelongType.IAssign, TopicBelongType.IRelated, TopicBelongType.Completed });
            ViewBag.NavList = tempnavlist;


            if (!string.IsNullOrEmpty(topicid))
            {
                ViewBag.ActiveTopicid = topicid;
                List <CoTopicVM> CurrentTopic1 = CoTopicVM.RetrieveTopic(ViewBag.ActiveTopicid);
                ViewBag.CurrentTopic = CurrentTopic1;

                //query string only contains topicid
                if (string.IsNullOrEmpty(activenavitem))
                {
                    //base on topic status decide the active nav
                    if (string.Compare(CurrentTopic1[0].status, TopicStatus.Working) == 0)
                    {
                        if (CoTopicVM.IsTopicOwner(topicid, ViewBag.username))
                        {
                            ViewBag.ActiveNav = TopicBelongType.IAssign;
                        }
                        else
                        {
                            ViewBag.ActiveNav = TopicBelongType.IRelated;
                        }
                    }
                    else
                    {
                        ViewBag.ActiveNav = TopicBelongType.Completed;
                    }
                }
                else
                {
                    ViewBag.ActiveNav = activenavitem;
                }

                if (string.Compare(ViewBag.ActiveNav, TopicBelongType.Completed) == 0)
                {
                    ViewBag.topiclist = CoTopicVM.RetrieveCompleteTopic4List(ViewBag.username, searchkey);
                }
                else
                {
                    ViewBag.topiclist = CoTopicVM.RetrieveTopic4List(ViewBag.username, ViewBag.ActiveNav, TopicStatus.Working, searchkey);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(activenavitem))
                {
                    ViewBag.ActiveNav = tempnavlist[0];
                }
                else
                {
                    ViewBag.ActiveNav = activenavitem;
                }

                if (string.Compare(ViewBag.ActiveNav, TopicBelongType.Completed) == 0)
                {
                    ViewBag.topiclist = CoTopicVM.RetrieveCompleteTopic4List(ViewBag.username, searchkey);
                }
                else
                {
                    ViewBag.topiclist = CoTopicVM.RetrieveTopic4List(ViewBag.username, ViewBag.ActiveNav, TopicStatus.Working, searchkey);
                }

                //choose a default topic
                if (ViewBag.topiclist.Count > 0)
                {
                    ViewBag.ActiveTopicid = ViewBag.topiclist[0].topicid;
                    ViewBag.CurrentTopic  = CoTopicVM.RetrieveTopic(ViewBag.ActiveTopicid);
                }
            }

            if (!string.IsNullOrEmpty(ViewBag.ActiveTopicid))
            {
                CoTopicVM.UpdateTopicIsRead(ViewBag.ActiveTopicid, ViewBag.username, true);
            }

            return(View());
        }