示例#1
0
        // GET: Library/Details/5
        public ActionResult Detail(int id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (Session["username"] != null)
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }

            var articleModel = _literatureService.GetDetail(id);

            var listArticleFileModel = _articleFileBs.GetListByArtikelId(id);

            ViewBag.ListFile = listArticleFileModel.Count == 0 ? null : listArticleFileModel;

            ViewBag.UseFullLink = _articleBs.getUseFullLink();
            return(View(articleModel));
        }
        public ActionResult Login()
        {
            ViewBag.connmain = SharepointHelper.PushConf()["primaindb"];
            ViewBag.connsec  = SharepointHelper.PushConf()["secdbempmst"];
            try
            {
                ViewBag.UrlApp     = WebConfigure.GetDomain();
                ViewBag.CheckLogin = WebConfigure.GetLoginPortal();

                if (Common.CheckAdmin())
                {
                    _userBService.EndDelegate();
                    return(View());
                }
                else
                {
                    return(RedirectToAction("Index", "Default"));
                }
            }
            catch (Exception er)
            {
                _logErrorBService.WriteLog("Account", MethodBase.GetCurrentMethod().Name, er.ToString());

                throw;
            }
        }
        private bool LoginValidate(User model)
        {
            bool ret;

            if (WebConfigure.GetLoginPortal() == "false")
            {
                return(true);
            }

            if (Common.GetUserXupj().ToLower() != model.Username.ToLower())
            {
                ModelState.AddModelError("Username", "Username and Login portal not match");
                ret = false;
            }
            else if (_userBService.CheckUserName(model.Username))
            {
                ret = true;
            }
            else
            {
                ModelState.AddModelError("Username", "Username not active or not registered");
                ret = false;
            }
            return(ret);
        }
        // GET: Library/Delete/5
        public ActionResult Delete(int id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            Article articleObject = _articleBs.Detail(id);

            ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
            SetDropdownArtikelCategory(articleObject);

            var tags = _articleTagsService.GetTagsByArticle(id);

            ViewBag.Tags = tags;
            var attachments = _articleFileBs.GetListByArtikelId(id);
            List <TicketAttachmentsAPI> listAttachment = new List <TicketAttachmentsAPI>();
            string attachmentsPath = System.Web.HttpContext.Current.Server.MapPath("~/Upload/Article/");

            if (attachments != null)
            {
                string[] imgExt = { ".jpg", ".png", ".jpeg", ".gif", ".bmp", ".tif", ".tiff" };
                foreach (var attachment in attachments)
                {
                    if (imgExt.Contains(Path.GetExtension(attachment.Name)))
                    {
                        listAttachment.Add(new TicketAttachmentsAPI
                        {
                            Id   = attachment.ArticleFileId,
                            Name = Common.ImageToBase64(attachmentsPath + attachment.Name),
                            Type = Path.GetExtension(attachment.Name),
                            NameWithOutBase64 = attachment.Name
                        });
                    }
                    else
                    {
                        listAttachment.Add(new TicketAttachmentsAPI
                        {
                            Id   = attachment.ArticleFileId,
                            Name = attachment.Name,
                            Type = Path.GetExtension(attachment.Name),
                            NameWithOutBase64 = attachment.Name
                        });
                    }
                }
            }
            ViewBag.Attachments = listAttachment;
            ViewBag.HeaderImg   = WebConfigure.GetDomain() + "/Upload/Article/Header/" + articleObject.HeaderImage;
            if (articleObject == null)
            {
                return(HttpNotFound());
            }
            return(View(articleObject));
        }
示例#5
0
        public ActionResult FileNotFound()
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            ViewBag.Alert = "File Not Found";
            return(View("Index", "Literation"));
        }
 public ActionResult Draft()
 {
     ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
     if (Session["userid"] == null)
     {
         return(View("LoginRedirect"));
     }
     else
     {
         if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
         {
             return(View("LoginRedirect"));
         }
         return(View(_articleBs.GetMyDraft(Convert.ToInt32(Session["userid"]))));
     }
 }
        // GET: Library/Details/5
        public ActionResult Detail(int id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            try
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                if (Session["username"] != null)
                {
                    if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                    {
                        return(RedirectToAction("Login", "Account"));
                    }
                }

                var articleModel = _articleBs.Approved(id);

                var listArticleFileModel = _articleFileBs.GetListByArtikelId(id);
                var listArticleTagsModel = _articleTagsService.GetTagsByArticle(id);

                ViewBag.ListFile   = listArticleFileModel.Count == 0 ? null : listArticleFileModel;
                ViewBag.ArticleTag = listArticleTagsModel.Count == 0 ? null : listArticleTagsModel;
                ViewBag.PathImg    = articleModel.HeaderImage == null?WebConfigure.GetDomain() + "/assets/images/repository/empty-image.jpg" : WebConfigure.GetDomain() + "/Upload/Article/Header/" + articleModel.HeaderImage;

                ViewBag.Domain = WebConfigure.GetDomain();

                ViewBag.RecentArticle = _articleBs.GetRecent();
                ViewBag.UseFullLink   = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
                return(View(articleModel));
            }
            catch (Exception ex)
            {
                _logErrorBService.WriteLog("Detail Library", MethodBase.GetCurrentMethod().Name, ex.ToString());
                throw;
            }
        }
 public ActionResult List()
 {
     ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
     if (Session["userid"] == null)
     {
         return(View("LoginRedirect"));
     }
     else
     {
         if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
         {
             return(View("LoginRedirect"));
         }
         var         listArtikel = _articleBs.GetMyList(Convert.ToInt32(Session["userid"]));
         List <User> userData    = new List <User>();
         if (listArtikel != null)
         {
             foreach (var item in listArtikel)
             {
                 User userdata = _userBService.GetDetail(item.CreatedBy);
                 if (userdata != null)
                 {
                     User userobject = new User()
                     {
                         UserId = item.ArticleId,
                         Name   = userdata.Name
                     };
                     userData.Add(userobject);
                 }
                 else
                 {
                     User userobject = new User()
                     {
                         UserId = item.ArticleId,
                         Name   = null
                     };
                     userData.Add(userobject);
                 }
             }
         }
         ViewBag.UserData = userData;
         return(View(listArtikel));
     }
 }
        // GET: Library
        public ActionResult Index(String keyword = "", String category = "")
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            try
            {
                ViewBag.Download = WebConfigure.GetDomain() + "/Upload/Document/" + WebConfigure.GetUserGuideNameFileWithExtention();
                ViewBag.Domain   = WebConfigure.GetDomain();
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                if (Session["username"] != null)
                {
                    if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                    {
                        return(RedirectToAction("Login", "Account"));
                    }
                }

                ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
                ViewBag.key         = keyword;
                ViewBag.Category    = category;
                return(View());
            }
            catch (Exception ex)
            {
                _logErrorBService.WriteLog("Library Index", MethodBase.GetCurrentMethod().Name, ex.ToString());
                throw;
            }
        }
 // GET: Library/Create
 public ActionResult Create()
 {
     ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
     if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
     {
         return(RedirectToAction("Login", "Account"));
     }
     if (Session["username"] != null)
     {
         if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
         {
             return(RedirectToAction("Login", "Account"));
         }
     }
     if (!Common.CheckUserYellow())
     {
         return(RedirectToAction("Login", "Account"));
     }
     ViewBag.EmptyImg      = WebConfigure.GetDomain() + "/assets/images/repository/empty-image.jpg";
     ViewBag.ListCategory1 = _articleCategoryBs.GetListParent(0);
     ViewBag.UseFullLink   = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
     return(View());
 }
示例#11
0
        public ActionResult Delete(string id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }

                if (id != null)
                {
                    Ticket tickets = _ticketBs.GetDetail(int.Parse(id));
                    if (Convert.ToInt32(Session["DelegateStatus"]) != 1)
                    {
                        if (Convert.ToInt32(Session["userid"]).Equals(tickets.Submiter) && tickets.Status == 1)
                        {
                            _ticketBs.Delete(tickets);
                            return(RedirectToAction("Index", "MyTechnicalRequest"));
                        }
                        else
                        {
                            return(Content("<script language='javascript' type='text/javascript'>alert('You are Not Included with This Technical Request'); location.href = '" + WebConfigure.GetDomain() + "/MyTechnicalRequest';</script>"));
                        }
                    }
                    else
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Cant Delete Technical Request During Delegation Period'); location.href = '" + WebConfigure.GetDomain() + "/MyTechnicalRequest';</script>"));
                    }
                }

                return(RedirectToAction("Index", "MyTechnicalRequest"));
            }
        }
示例#12
0
        public ActionResult Update(string id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                ViewBag.Domain = WebConfigure.GetDomain() + "/Upload/TechnicalRequestAttachments/";
                if (id != null)
                {
                    string ticketCategory = _ticketBs.GetCategoryName(id);

                    var ticket             = _ticketBs.GetByTicketNumber(id);
                    var ticketParticipants = _ticketParticipantBusinessService.GetByTicket(ticket.TicketId);
                    if (!((ticket.Status.Equals(2) && Convert.ToInt32(Session["userid"]) == ticket.Responder) || (ticket.Status.Equals(1) && Convert.ToInt32(Session["userid"]) == ticket.Submiter)))
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('You are Not Included with This Technical Request'); location.href = '" + WebConfigure.GetDomain() + "/MyTechnicalRequest';</script>"));
                    }
                    if (Convert.ToInt32(Session["DelegateStatus"]) == 1)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Cant Update Technical Request During Delegation Period'); location.href = '" + WebConfigure.GetDomain() + "/MyTechnicalRequest';</script>"));
                    }
                    if (ticket.Status == 1 && ticket.Submiter != Convert.ToInt32(Session["userid"]))
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('The Technical Request is Not Found'); location.href = '" + WebConfigure.GetDomain() + "/TechnicalRequest';</script>"));
                    }
                    var responder   = _userBusinessService.GetDetail(ticket.Responder);
                    var attachments = _ticketAttachmentBs.GetFullByTicketId(ticket.TicketId);
                    List <TicketAttachmentsAPI> listAttachment = new List <TicketAttachmentsAPI>();
                    string attachmentsPath = System.Web.HttpContext.Current.Server.MapPath("~/Upload/TechnicalRequestAttachments/");
                    if (attachments != null)
                    {
                        foreach (var attachment in attachments)
                        {
                            string[] imgExt = { ".jpg", ".png", ".jpeg", ".gif", ".bmp", ".tif", ".tiff" };

                            if (imgExt.Contains(Path.GetExtension(attachment.Name)))
                            {
                                listAttachment.Add(new TicketAttachmentsAPI
                                {
                                    Id                = attachment.TicketAttachmentId,
                                    Name              = Common.ImageToBase64(attachmentsPath + attachment.Name),
                                    Level             = attachment.LevelUser,
                                    Type              = Path.GetExtension(attachment.Name),
                                    NameWithOutBase64 = attachment.Name
                                });
                            }
                            else
                            {
                                listAttachment.Add(new TicketAttachmentsAPI
                                {
                                    Id                = attachment.TicketAttachmentId,
                                    Name              = attachment.Name,
                                    Level             = attachment.LevelUser,
                                    Type              = Path.GetExtension(attachment.Name),
                                    NameWithOutBase64 = attachment.Name
                                });
                            }
                        }
                    }

                    var tags = _articleTagBs.GetTagsByTicket(ticket.TicketId);
                    WarrantyTypeBusinessService warrantyTypeBusinessService = Factory.Create <WarrantyTypeBusinessService>("WarrantyType", ClassType.clsTypeBusinessService);
                    ViewBag.warrantyType = warrantyTypeBusinessService.Get();
                    ViewBag.Ticket       = ticket;
                    ViewBag.Attachments  = listAttachment;
                    ViewBag.Tags         = tags;
                    ViewBag.Responder    = responder;

                    if (ticketParticipants != null)
                    {
                        ViewBag.Participants = _ticketParticipantBusinessService.GetParticipantWithName(ticketParticipants);
                    }
                    ViewBag.Recent = TechnicalRequest.GetRecentTR(Convert.ToInt32(Session["userid"]));

                    SetListDropdown(int.Parse(Session["userid"].ToString()));

                    return(View("../TechnicalRequest/Update" + ticketCategory));
                }

                return(RedirectToAction("Index", "MyTechnicalRequest"));
            }
        }
        public ActionResult Login()
        {
            string userPortal = Common.GetUserXupj().ToLower();

            try
            {
                if (Session["userid"] != null)
                {
                    ClearSessionData();
                }
                ViewBag.Download   = WebConfigure.GetDomain() + "/Upload/Document/" + WebConfigure.GetUserGuideNameFileWithExtention();
                ViewBag.UrlApp     = WebConfigure.GetDomain();
                ViewBag.CheckLogin = WebConfigure.GetLoginPortal();

                if (WebConfigure.GetLoginPortal() == "false")
                {
                    ViewBag.ListUser = _userBService.GetList();
                    return(View());
                }
                else
                {
                    if (userPortal != "")
                    {
                        var user = _userBService.GetDetailbyUsername(userPortal);

                        if (user != null)// User registered at TREND system
                        {
                            if (user.Status.Equals(7))
                            {
                                Session["userid"]      = user.UserId;
                                Session["role"]        = user.RoleId;
                                Session["roleColor"]   = _userRoleBService.GetDetail(user.RoleId).Description;
                                Session["username"]    = user.Username;
                                Session["name"]        = user.Name;
                                Session["status"]      = user.Status;
                                Session["photo"]       = user.PhotoProfile;
                                Session["loginPortal"] = WebConfigure.GetLoginPortal();

                                if (user.IsDelegate != 0)
                                {
                                    Delegation delegationData = _userBService.GetDetailDelegation(user.IsDelegate);
                                    Session["DelegateStatus"] = delegationData.Status;
                                    Session["DelegateTo"]     = _userBService.GetDetail(delegationData.ToUser).Name;
                                    Session["DelegateUntil"]  = delegationData.EndDate;
                                    Session["DelegateStart"]  = delegationData.StartDate;
                                }
                                else if (user.IsDelegate == 0)
                                {
                                    Session["DelegateStatus"] = null;
                                    Session["DelegateUntil"]  = null;
                                    Session["DelegateTo"]     = null;
                                    Session["DelegateStart"]  = null;
                                }
                                _logReportBService.WriteLog("[SUCCESS] Account Login", MethodBase.GetCurrentMethod().Name, "User Portal :" + userPortal + " has Login");
                                return(RedirectToAction("Index", "Library"));
                            }
                            else
                            {
                                Session["userid"]         = user.UserId;
                                Session["role"]           = user.RoleId;
                                Session["roleColor"]      = "Guest";
                                Session["username"]       = user.Username;
                                Session["name"]           = user.Name;
                                Session["status"]         = user.Status;
                                Session["photo"]          = user.PhotoProfile;
                                Session["loginPortal"]    = WebConfigure.GetLoginPortal();
                                Session["DelegateStatus"] = 0;
                                Session["DelegateUntil"]  = null;
                                Session["DelegateTo"]     = null;
                                Session["DelegateStart"]  = null;
                                _logReportBService.WriteLog("[SUCCESS] Account Login", MethodBase.GetCurrentMethod().Name, "User Portal :" + userPortal + " has Login");
                                return(RedirectToAction("Index", "Library"));
                            }
                        }
                        else //As Guest
                        {
                            EmployeeMaster UserfromPortal = _mstEmployeeBService.GetDetailbyUserName(userPortal);
                            if (UserfromPortal != null)
                            {
                                User model = new User();
                                model.CreatedAt = DateTime.Now;
                                model.Status    = 0;
                                var mEmployee = userPortal.Equals("ict.development") ? _mstEmployeeBService.GetDetailbyUserName("XUPJ21IYN") : UserfromPortal;
                                model.Name       = mEmployee.Employee_Name;
                                model.EmployeeId = mEmployee.Employee_Id;
                                model.Username   = userPortal.Equals("ict.development") ? "ict.development" : mEmployee.Employee_xupj;
                                model.Position   = mEmployee.Position_Name;
                                model.Email      = mEmployee.Email;
                                model.AreaCode   = mEmployee.Location_Id;
                                model.AreaName   = mEmployee.Location_Name;
                                model.BranchCode = mEmployee.Branch_Id;
                                model.Dob        = DateTime.ParseExact(mEmployee.Birth_date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                                model.RoleId     = 0;
                                model            = _userBService.Add(model);

                                var userguest = _userBService.GetDetailbyUsername(userPortal);
                                Session["userid"]         = userguest.UserId;
                                Session["role"]           = userguest.RoleId;
                                Session["roleColor"]      = "Guest";
                                Session["username"]       = userPortal;
                                Session["name"]           = userguest.Name;
                                Session["status"]         = userguest.Status;
                                Session["photo"]          = userguest.PhotoProfile;
                                Session["loginPortal"]    = WebConfigure.GetLoginPortal();
                                Session["DelegateStatus"] = 0;
                                Session["DelegateUntil"]  = null;
                                Session["DelegateTo"]     = null;
                                Session["DelegateStart"]  = null;
                                _logReportBService.WriteLog("[SUCCESS] Account Login", MethodBase.GetCurrentMethod().Name, "User Portal :" + userPortal + " has Login");
                                return(RedirectToAction("Index", "Library"));
                            }
                            else
                            {
                                var userguest = _userBService.GetDetailbyUsername("Guest");
                                Session["userid"]         = userguest.UserId;
                                Session["role"]           = userguest.RoleId;
                                Session["roleColor"]      = "Guest";
                                Session["username"]       = userguest.Username;
                                Session["name"]           = userPortal;
                                Session["status"]         = userguest.Status;
                                Session["photo"]          = userguest.PhotoProfile;
                                Session["loginPortal"]    = WebConfigure.GetLoginPortal();
                                Session["DelegateStatus"] = 0;
                                Session["DelegateUntil"]  = null;
                                Session["DelegateTo"]     = null;
                                Session["DelegateStart"]  = null;
                                return(Content("<script language='javascript' type='text/javascript'>alert('Your Portal Account Has Not Registered in Employee Master Database'); location.href = '" + WebConfigure.GetDomain() + "/Library';</script>"));
                                // return RedirectToAction("Index", "Library");
                            }
                        }
                    }
                    else
                    {
                        Uri    uri       = new Uri(ConfigurationManager.AppSettings["Domain"]);
                        string requested = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port;
                        string protokol  = Common.GetProtocol();
                        string portalUrl = WebConfigure.GetLoginHost() + "/_layouts/15/Trakindo/Authentication/Login.aspx?ReturnUrl=" + protokol + uri.Host + uri.AbsolutePath + "/Library";
                        ViewBag.portalDomain = portalUrl;
                        return(View("RedirectToPortal"));
                    }
                }
            }
            catch (Exception er)
            {
                _logErrorBService.WriteLog("[FAILED] Account Login", MethodBase.GetCurrentMethod().Name, er.ToString(), userPortal);
                return(RedirectToAction("Index", "Library"));
                //ClearSessionData();
                //Uri uri = new Uri(ConfigurationManager.AppSettings["Domain"]);
                //string requested = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port;
                //string protokol = Common.GetProtocol();
                //string portalUrl = WebConfigure.GetLoginHost() + "/_layouts/15/Trakindo/Authentication/Login.aspx?ReturnUrl=" + protokol + uri.Host + uri.AbsolutePath + "/Library";
                //ViewBag.portalDomain = portalUrl;
                //return View("RedirectToPortal");
            }
        }
示例#14
0
        public ActionResult Index(int?page, int Category = 0, String keyword = "")
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            ViewBag.Download     = WebConfigure.GetDomain() + "/Upload/Document/" + WebConfigure.GetUserGuideNameFileWithExtention();
            ViewBag.Domain       = domain(isLocal);
            ViewBag.CategoryName = Category == 0 ? null : _articleCategoryBs.GetDetail(Category).Name;
            ViewBag.IconCategory = Category == 0 ? null : _articleCategoryBs.GetDetail(Category).Icon;
            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (Session["username"] != null)
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
            List <Article> listArtikel = null;

            //var start = 6 * (Convert.ToInt32(1) - 1);
            if (Category == 0)
            {
                listArtikel = _literatureService.GetListkeyword(keyword);
            }
            else
            {
                listArtikel = _literatureService.GetListbyCategory(Category, keyword);
            }

            #region Category

            ViewBag.Domain        = WebConfigure.GetDomain();
            ViewBag.ListCategory1 = _articleCategoryBs.GetListCategoryMostUsedLiterature(0);
            ViewBag.key           = keyword;
            #endregion

            List <ArticleFileData>   ArticleData     = new List <ArticleFileData>();
            List <CustomArticleTags> ArticleTagsData = new List <CustomArticleTags>();
            if (listArtikel != null)
            {
                foreach (var item in listArtikel)
                {
                    List <String> FileData = _articleFileBs.GetNamefileByRoleColor(item.ArticleId, item.LevelUser);
                    if (FileData.Count > 0)
                    {
                        ArticleFileData filedata = new ArticleFileData()
                        {
                            idFile = item.ArticleId,
                            Name   = FileData,
                            Level  = _articleFileBs.GetLevelFileByRoleColor(item.ArticleId, item.LevelUser)
                        };
                        ArticleData.Add(filedata);
                    }
                    var TagsData           = _articleTagsBs.GetTagsByArticle(item.ArticleId);
                    CustomArticleTags tags = new CustomArticleTags()
                    {
                        ArticleId = item.ArticleId,
                        Object    = TagsData.Count == 0 ? null : TagsData
                    };
                    ArticleTagsData.Add(tags);
                }
            }
            ViewBag.LiteratureTags = ArticleTagsData;
            ViewBag.keyword        = keyword;
            ViewBag.LiteratureItem = ArticleData;
            int pageSize   = 50;
            int pageNumber = (page ?? 1);
            return(View(listArtikel.ToPagedList(pageNumber, pageSize)));
        }
示例#15
0
        // GET: MyTechnicalRequest
        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            if (Session["userid"] == null)
            {
                return(View("LoginRedirect"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(View("LoginRedirect"));
                }

                ViewBag.CurrentSort    = sortOrder;
                ViewBag.DateSortParm   = String.IsNullOrEmpty(sortOrder) ? "DateDesc" : "";
                ViewBag.TitleSortParm  = sortOrder == "Title" ? "TitleDesc" : "Title";
                ViewBag.StatusSortParm = sortOrder == "Status" ? "StatusDesc" : "Status";

                if (searchString != null)
                {
                    page = 1;
                }
                else
                {
                    searchString = currentFilter;
                }

                ViewBag.CurrentFilter = searchString;

                var tickets = _ticketBs.GetQueryableByUserConected(int.Parse(Session["userid"].ToString()));
                //Search MyTR
                if (!String.IsNullOrEmpty(searchString))
                {
                    int userlogin = int.Parse(Session["userid"].ToString());
                    if ("waiting your feedback".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                (ticket.Status == 2 && userlogin.Equals(ticket.NextCommenter) && (userlogin.Equals(ticket.Responder) || userlogin.Equals(ticket.Submiter))) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("pra".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                (ticket.Status == 2 && !userlogin.Equals(ticket.NextCommenter) && ticket.NextCommenter.Equals(ticket.Responder)) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("psa".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                (ticket.Status == 2 && !userlogin.Equals(ticket.NextCommenter) && ticket.NextCommenter.Equals(ticket.Submiter)) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("draft".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                ticket.Status.Equals(1) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("solved".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                ticket.Status.Equals(6) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("closed".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                ticket.Status.Equals(3) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else
                    {
                        int[] UserParticipant = _ticketParticipantBusinessService.GetTicketIdBySearchUserId(searchString).ToArray();
                        int[] User            = _userBusinessService.GetListSearchUser(searchString).ToArray();
                        int[] tagTicket       = _articleTagBs.searchTagTicket(searchString).ToArray();
                        if (tagTicket.Length > 0)
                        {
                            tickets = tickets.Where(ticket =>
                                                    ticket.Title.Contains(searchString) ||
                                                    ticket.TicketNo.Contains(searchString) ||
                                                    ticket.SerialNumber.Contains(searchString) ||
                                                    ticket.DPPMno.Contains(searchString) ||
                                                    ticket.Description.Contains(searchString) ||
                                                    ticket.EmailCC.Contains(searchString) || (tagTicket.Contains(ticket.TicketId) && ticket.Status != 1) || ((User.Contains(ticket.Responder) || User.Contains(ticket.Submiter) || UserParticipant.Contains(ticket.TicketId)) && ticket.Status != 1));
                        }
                        else
                        {
                            tickets = tickets.Where(ticket =>
                                                    ticket.Title.Contains(searchString) ||
                                                    ticket.TicketNo.Contains(searchString) ||
                                                    ticket.SerialNumber.Contains(searchString) ||
                                                    ticket.DPPMno.Contains(searchString) ||
                                                    ticket.Description.Contains(searchString) ||
                                                    ticket.EmailCC.Contains(searchString) || ((User.Contains(ticket.Responder) || User.Contains(ticket.Submiter) || UserParticipant.Contains(ticket.TicketId)) && ticket.Status != 1));
                        }
                    }
                }
                List <Ticket> recent = new List <Ticket>();
                if (tickets != null)
                {
                    foreach (var item in tickets)
                    {
                        Ticket recentDate = new Ticket()
                        {
                            TicketId  = item.TicketId,
                            CreatedAt = new[] { item.CreatedAt, item.LastReply, item.UpdatedAt, item.LastStatusDate }.Max()
                        };
                        recent.Add(recentDate);
                    }
                    ViewBag.RecentDate = recent;
                }
                else
                {
                    ViewBag.RecentDate = null;
                }
                switch (sortOrder)
                {
                case "DateDesc":
                    tickets = tickets.OrderBy(t => new[] { t.CreatedAt, t.LastReply, t.UpdatedAt, t.LastStatusDate }.Max());
                    break;

                case "Title":
                    tickets = tickets.OrderBy(t => t.Title);
                    break;

                case "TitleDesc":
                    tickets = tickets.OrderByDescending(t => t.Title);
                    break;

                case "Status":
                    tickets = tickets.OrderBy(t => t.Status);
                    break;

                case "StatusDesc":
                    tickets = tickets.OrderByDescending(t => t.Status);
                    break;

                default:
                    tickets = tickets.OrderByDescending(t => new[] { t.CreatedAt, t.LastReply, t.UpdatedAt, t.LastStatusDate }.Max());
                    break;
                }

                ViewBag.Recent = TechnicalRequest.GetRecentTR(Convert.ToInt32(Session["userid"]));
                var ticketPreview = _ticketPreviewBusinessService.MakeFrom(tickets, Convert.ToInt32(Session["userid"]));

                List <InvolvedUser>     submitter     = new List <InvolvedUser>();
                List <InvolvedUser>     responders    = new List <InvolvedUser>();
                List <InvolvedUser>     involvedUsers = new List <InvolvedUser>();
                List <TicketResolution> Resolutions   = new List <TicketResolution>();
                if (ticketPreview != null)
                {
                    foreach (var ticket in ticketPreview)
                    {
                        User submitterData = _userBusinessService.GetDetail(ticket.Submiter);
                        ticket.IsEscalated = _ticketBs.IsEscalated(ticket.TicketId, Convert.ToInt32(Session["userid"]));
                        TicketResolution resolution = _ticketResolutionBs.GetByTicket(ticket.TicketId);
                        if (resolution != null)
                        {
                            TicketResolution resolutionObj = new TicketResolution()
                            {
                                TicketId    = ticket.TicketId,
                                Description = resolution.Description,
                                CreatedAt   = resolution.CreatedAt
                            };
                            Resolutions.Add(resolutionObj);
                        }
                        else
                        {
                            TicketResolution resolutionObj = new TicketResolution()
                            {
                                TicketId    = ticket.TicketId,
                                Description = null,
                                CreatedAt   = null
                            };
                            Resolutions.Add(resolutionObj);
                        }
                        if (submitterData != null)
                        {
                            InvolvedUser submitterUser = new InvolvedUser()
                            {
                                TicketNo    = ticket.TicketNo,
                                EmployeName = _userBusinessService.GetDetail(ticket.Submiter).Name
                            };

                            submitter.Add(submitterUser);
                        }
                        else
                        {
                            InvolvedUser submitterUser = new InvolvedUser()
                            {
                                TicketNo    = ticket.TicketNo,
                                EmployeName = ""
                            };

                            submitter.Add(submitterUser);
                        }

                        if (ticket.Responder != 0)
                        {
                            User responderData = _userBusinessService.GetDetail(ticket.Responder);
                            if (responderData != null)
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = _userBusinessService.GetDetail(ticket.Responder).Name
                                };
                                responders.Add(responder);
                            }
                            else
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = ""
                                };
                                responders.Add(responder);
                            }
                        }
                        else
                        {
                            if (ticket.Status != 1)
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = "TREND Admin"
                                };
                                responders.Add(responder);
                            }
                            else
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = ""
                                };
                                responders.Add(responder);
                            }
                        }

                        var participants = _ticketParticipantBusinessService.GetByTicket(ticket.TicketId);
                        if (participants != null)
                        {
                            foreach (var participantItem in participants)
                            {
                                var useCek = _userBusinessService.GetDetail(participantItem.UserId);

                                if (useCek != null)
                                {
                                    InvolvedUser participant = new InvolvedUser()
                                    {
                                        TicketNo    = ticket.TicketNo,
                                        EmployeName = useCek.Name,
                                        UserId      = useCek.UserId
                                    };
                                    involvedUsers.Add(participant);
                                }
                            }
                        }
                    }
                }
                ViewBag.Resolutions   = Resolutions;
                ViewBag.Submiters     = submitter;
                ViewBag.Responders    = responders;
                ViewBag.InvolvedUsers = involvedUsers;

                int pageSize   = 10;
                int pageNumber = (page ?? 1);
                return(View("Index", ticketPreview.ToPagedList(pageNumber, pageSize)));
            }
        }
        // GET: DashboardTechnicalOverview
        public ActionResult DashboardTechnicalOverview(int filterType = 0, string Area = null, string Model = null, string Family = null, string Industry = null, string SerialNumber = null, string Customer = null, string SalesOffice = null, string deliveryDate = null, string purchaseDate = null, string repairDate = null, string SMURangeFrom = null, string SMURangeTo = null, string ModelMEP = null, string SerialNumberMEP = null, string CustomerMEP = null, string Plant = null, string Product = null, string hid = null, string rental = null, string other = null, string paramsModel = null, string paramsSerialNumber = null, bool btnPOST = false)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                this.setViewBag();
                var modelFormCollection = new GetFormCollectionOverview();
                var strArea             = Area;
                var strSalesOffice      = SalesOffice;
                var strCustomer         = CustomerMEP;
                var strFamily           = Family;
                var strIndustry         = Industry;
                var strModel            = ModelMEP;
                var strSerialNumber     = SerialNumberMEP;
                var strSMURangeFrom     = SMURangeFrom;
                var strSMURangeTo       = SMURangeTo;
                var strpurchaseDateFrom = String.Empty;
                var strdeliveryDateFrom = String.Empty;
                var strrepairDateFrom   = String.Empty;
                var strpurchaseDateEnd  = String.Empty;
                var strdeliveryDateEnd  = String.Empty;
                var strrepairDateEnd    = String.Empty;
                var Hid             = hid;
                var Rental          = rental;
                var Others          = other;
                var strcustomer     = "";
                var strmodel        = "";
                var strserialnumber = "";
                var strplant        = "";
                var strproduct      = "";
                if (filterType == 1)
                {
                    strcustomer     = Customer;
                    strmodel        = Model;
                    strserialnumber = SerialNumber;
                    strplant        = Plant;
                    strproduct      = Product;
                }
                else
                {
                    strcustomer     = CustomerMEP;
                    strmodel        = ModelMEP;
                    strserialnumber = SerialNumberMEP;
                    if (purchaseDate != null)
                    {
                        var strList = purchaseDate.Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            strpurchaseDateFrom = strList[0];
                            strpurchaseDateEnd  = strList[4];
                        }
                        else
                        {
                            strpurchaseDateFrom = strList[0];
                        }
                    }
                    else
                    {
                        strpurchaseDateFrom = String.Empty;
                        strpurchaseDateEnd  = String.Empty;
                    }

                    if (deliveryDate != null)
                    {
                        var strList = deliveryDate.Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            strdeliveryDateFrom = strList[0];
                            strdeliveryDateEnd  = strList[4];
                        }
                        else
                        {
                            strdeliveryDateFrom = strList[0];
                        }
                    }
                    else
                    {
                        strdeliveryDateFrom = "";
                        strdeliveryDateEnd  = "";
                    }

                    if (repairDate != null)
                    {
                        var strList = repairDate.Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            strrepairDateFrom = strList[0];
                            strrepairDateEnd  = strList[4];
                        }
                        else
                        {
                            strrepairDateFrom = strList[0];
                        }
                    }
                    else
                    {
                        strrepairDateFrom = String.Empty;
                        strrepairDateEnd  = String.Empty;
                    }
                }

                modelFormCollection.HID                = Hid;
                modelFormCollection.Rental             = Rental;
                modelFormCollection.Others             = Others;
                modelFormCollection.Area               = strArea;
                modelFormCollection.SalesOffice        = strSalesOffice;
                modelFormCollection.Customer           = strCustomer;
                modelFormCollection.Family             = strFamily;
                modelFormCollection.Industry           = strIndustry;
                modelFormCollection.Model              = strModel;
                modelFormCollection.SerialNumber       = strSerialNumber;
                modelFormCollection.SMURangeFrom       = String.IsNullOrWhiteSpace(strSMURangeFrom) ? 0 : Convert.ToInt32(strSMURangeFrom);
                modelFormCollection.SMURangeTo         = String.IsNullOrWhiteSpace(strSMURangeTo) ? 0 : Convert.ToInt32(strSMURangeTo);
                modelFormCollection.PurchaseDateFrom   = strpurchaseDateFrom;
                modelFormCollection.DeliveryDateFrom   = strdeliveryDateFrom;
                modelFormCollection.LastRepairDateFrom = strrepairDateFrom;
                modelFormCollection.PurchaseDateEnd    = strpurchaseDateEnd;
                modelFormCollection.DeliveryDateEnd    = strdeliveryDateEnd;
                modelFormCollection.LastRepairDateEnd  = strrepairDateEnd;
                modelFormCollection.Customer           = strcustomer;
                modelFormCollection.Model              = strmodel;
                modelFormCollection.SerialNumber       = strserialnumber;
                modelFormCollection.Product            = strproduct;
                modelFormCollection.Plant              = strplant;

                ViewBag.FilterType = filterType;
                ViewBag.urlModel   = WebConfigure.GetDomain() + "/Dashboard/DashboardTechnicalOverview?filterType=" + filterType
                                     + "&Area=" + Area
                                     + "&Model=" + Model
                                     + "&Family=" + Family
                                     + "&Industry=" + Industry
                                     + "&SerialNumber=" + SerialNumber
                                     + "&Customer=" + Customer
                                     + "&SalesOffice=" + SalesOffice
                                     + "&deliveryDate=" + deliveryDate
                                     + "&purchaseDate=" + purchaseDate
                                     + "&repairDate=" + repairDate
                                     + "&SMURangeFrom=" + SMURangeFrom
                                     + "&SMURangeTo=" + SMURangeTo
                                     + "&ModelMEP=" + ModelMEP
                                     + "&SerialNumberMEP=" + SerialNumberMEP
                                     + "&CustomerMEP=" + CustomerMEP
                                     + "&Plant=" + Plant
                                     + "&Product=" + Product
                                     + "&hid=" + hid
                                     + "&rental=" + rental
                                     + "&other=" + other
                                     + "&btnPOST=" + btnPOST
                ;

                var ModelParams        = "";
                var SerialNumberParams = "";
                if (!String.IsNullOrWhiteSpace(paramsModel))
                {
                    ModelParams = paramsModel;
                    modelFormCollection.paramsModel = ModelParams;
                    ViewBag.Model = ModelParams;
                }
                if (!String.IsNullOrWhiteSpace(paramsSerialNumber))
                {
                    SerialNumberParams = paramsSerialNumber;
                    modelFormCollection.paramsSerialNumber = SerialNumberParams;
                    ViewBag.SerialNumber = SerialNumberParams;
                }
                var RelatedDPPM = GetTableRelatedDPPMOverviewGet(modelFormCollection, Hid, Rental, Others, modelFormCollection.paramsModel, modelFormCollection.paramsSerialNumber, btnPOST);
                var RelatedTR   = getListTableRelatedTROverviewGet(modelFormCollection, Hid, Rental, Others, modelFormCollection.paramsModel, modelFormCollection.paramsSerialNumber, btnPOST);
                ViewBag.RelatedDPPMData         = RelatedDPPM.Item1;
                ViewBag.RelatedDPPMDataCount    = RelatedDPPM.Item2;
                ViewBag.TicketDataOverview      = RelatedTR.Item1;
                ViewBag.TicketDataCountOverview = RelatedTR.Item2;
                ViewBag.FilterType = filterType;
                ViewBag.ModelFormCollectionOverview = modelFormCollection;
                return(View());
            }
        }
示例#17
0
        public ActionResult LoadMore(int?page, int Category = 0, String keyword = "")
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            ViewBag.Download     = WebConfigure.GetDomain() + "/Upload/Document/" + WebConfigure.GetUserGuideNameFileWithExtention();
            ViewBag.CategoryName = Category == 0 ? null : _articleCategoryBs.GetDetail(Category).Name;
            ViewBag.IconCategory = Category == 0 ? null : _articleCategoryBs.GetDetail(Category).Icon;

            ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
            List <Article> listArtikel = null;

            if (Category == 0)
            {
                listArtikel = _literatureService.GetListkeyword(keyword);
            }
            else
            {
                listArtikel = _literatureService.GetListbyCategory(Category, keyword);
            }
            #region Category
            ViewBag.Domain        = domain(isLocal);
            ViewBag.ListCategory1 = _articleCategoryBs.GetListCategoryMostUsedLiterature(0);
            #endregion

            List <ArticleFile>       ArticleData     = new List <ArticleFile>();
            List <CustomArticleTags> ArticleTagsData = new List <CustomArticleTags>();
            if (listArtikel != null)
            {
                foreach (var artikel in listArtikel)
                {
                    var FileData = _articleFileBs.GetListByArtikelId(artikel.ArticleId);
                    if (FileData != null)
                    {
                        foreach (var FileItem in FileData)
                        {
                            var fileCek = _articleFileBs.GetDetail(FileItem.ArticleId);
                            if (fileCek != null)
                            {
                                ArticleFile file = new ArticleFile()
                                {
                                    ArticleId = artikel.ArticleId,
                                    Name      = fileCek.Name,
                                };
                                ArticleData.Add(file);
                            }
                            var TagsData           = _articleTagsBs.GetTagsByArticle(artikel.ArticleId);
                            CustomArticleTags tags = new CustomArticleTags()
                            {
                                ArticleId = artikel.ArticleId,
                                Object    = TagsData.Count == 0 ? null : TagsData
                            };
                            ArticleTagsData.Add(tags);
                        }
                    }
                }
            }
            ViewBag.LiteratureTags = ArticleTagsData;
            ViewBag.LiteratureData = listArtikel;
            ViewBag.LiteratureItem = ArticleData;
            int pageSize   = 50;
            int pageNumber = (page ?? 1);
            return(View(listArtikel.ToPagedList(pageNumber, pageSize)));
        }
        public ActionResult DashboardTechnicalOverview(FormCollection fc)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                this.setViewBag();
                var modelFormCollection = new GetFormCollectionOverview();

                bool btnPOST = true;
                ViewBag.urlModel = WebConfigure.GetDomain() + "/Dashboard/DashboardTechnicalOverview?filterType=" + fc["filterType"]
                                   + "&Area=" + fc["Area"]
                                   + "&Model=" + fc["Model"]
                                   + "&Family=" + fc["Family"]
                                   + "&Industry=" + fc["Industry"]
                                   + "&SerialNumber=" + fc["SerialNumber"]
                                   + "&Customer=" + fc["Customer"]
                                   + "&SalesOffice=" + fc["SalesOffice"]
                                   + "&deliveryDate=" + fc["deliveryDate"]
                                   + "&purchaseDate=" + fc["purchaseDate"]
                                   + "&repairDate=" + fc["repairDate"]
                                   + "&SMURangeFrom=" + fc["SMURangeFrom"]
                                   + "&SMURangeTo=" + fc["SMURangeTo"]
                                   + "&ModelMEP=" + fc["ModelMEP"]
                                   + "&SerialNumberMEP=" + fc["SerialNumberMEP"]
                                   + "&CustomerMEP=" + fc["CustomerMEP"]
                                   + "&Plant=" + fc["PlantDescription"]
                                   + "&Product=" + fc["Product"]
                                   + "&hid=" + fc["hid"]
                                   + "&rental=" + fc["rental"]
                                   + "&other=" + fc["other"]
                                   + "&btnPOST=" + btnPOST
                ;


                if (Convert.ToInt32(fc["filterType"]) == 1)
                {
                    var strSerialNumber     = (fc["SerialNumber"] != null) ? fc["SerialNumber"] : String.Empty;
                    var strCustomer         = (fc["Customer"] != null) ? fc["Customer"] : String.Empty;
                    var strModel            = (fc["Model"] != null) ? fc["Model"] : String.Empty;
                    var strplantDescription = (fc["PlantDescription"] != null) ? fc["PlantDescription"] : String.Empty;
                    var strplantProduct     = (fc["Product"] != null) ? fc["Product"] : String.Empty;
                    modelFormCollection.Customer     = strCustomer;
                    modelFormCollection.Model        = strModel;
                    modelFormCollection.SerialNumber = strSerialNumber;
                    modelFormCollection.Plant        = strplantDescription;
                    modelFormCollection.Product      = strplantProduct;
                }
                else
                {
                    var purchasedatefrom = "";
                    var purchasedateto   = "";
                    var deliverydatefrom = "";
                    var deliverydateto   = "";
                    var repairdatefrom   = "";
                    var repairdateto     = "";
                    if (fc["purchaseDate"] != null)
                    {
                        var strList = fc["purchaseDate"].Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            purchasedatefrom = strList[0];
                            purchasedateto   = strList[4];
                        }
                        else
                        {
                            purchasedatefrom = strList[0];
                        }
                    }
                    else
                    {
                        purchasedatefrom = "";
                        purchasedateto   = "";
                    }

                    if (fc["deliveryDate"] != null)
                    {
                        var strList = fc["deliveryDate"].Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            deliverydatefrom = strList[0];
                            deliverydateto   = strList[4];
                        }
                        else
                        {
                            deliverydatefrom = strList[0];
                        }
                    }
                    else
                    {
                        deliverydatefrom = "";
                        deliverydateto   = "";
                    }

                    if (fc["repairDate"] != null)
                    {
                        var strList = fc["repairDate"].Split(' ', 't', 'o', ' ');
                        if (strList.Count() == 5)
                        {
                            repairdatefrom = strList[0];
                            repairdateto   = strList[4];
                        }
                        else
                        {
                            repairdatefrom = strList[0];
                        }
                    }
                    else
                    {
                        repairdatefrom = "";
                        repairdateto   = "";
                    }
                    var strArea         = (fc["Area"] != null) ? fc["Area"] : String.Empty;
                    var strSalesOffice  = (fc["SalesOffice"] != null) ? fc["SalesOffice"] : String.Empty;
                    var strCustomer     = (fc["CustomerMEP"] != null) ? fc["CustomerMEP"] : String.Empty;
                    var strFamily       = (fc["Family"] != null) ? fc["Family"] : String.Empty;
                    var strIndustry     = (fc["Industry"] != null) ? fc["Industry"] : String.Empty;
                    var strModel        = (fc["ModelMEP"] != null) ? fc["ModelMEP"] : String.Empty;
                    var strSerialNumber = (fc["SerialNumberMEP"] != null) ? fc["SerialNumberMEP"] : String.Empty;
                    var strSMURangeFrom = (!String.IsNullOrWhiteSpace(fc["SMURangeFrom"])) ? Convert.ToInt32(fc["SMURangeFrom"]) : 0;
                    var strSMURangeTo   = (!String.IsNullOrWhiteSpace(fc["SMURangeTo"])) ? Convert.ToInt32(fc["SMURangeTo"]) : 0;

                    modelFormCollection.Area               = strArea;
                    modelFormCollection.SalesOffice        = strSalesOffice;
                    modelFormCollection.Customer           = strCustomer;
                    modelFormCollection.Family             = strFamily;
                    modelFormCollection.Industry           = strIndustry;
                    modelFormCollection.Model              = strModel;
                    modelFormCollection.SerialNumber       = strSerialNumber;
                    modelFormCollection.SMURangeFrom       = strSMURangeFrom;
                    modelFormCollection.SMURangeTo         = strSMURangeTo;
                    modelFormCollection.PurchaseDateFrom   = purchasedatefrom;
                    modelFormCollection.PurchaseDateEnd    = purchasedateto;
                    modelFormCollection.DeliveryDateEnd    = deliverydateto;
                    modelFormCollection.DeliveryDateFrom   = deliverydatefrom;
                    modelFormCollection.LastRepairDateEnd  = repairdateto;
                    modelFormCollection.LastRepairDateFrom = repairdatefrom;
                }
                var Hid    = (fc["hid"] != null) ? fc["hid"] : "";
                var Rental = (fc["rental"] != null) ? fc["rental"] : "";
                var Others = (fc["other"] != null) ? fc["other"] : "";
                modelFormCollection.HID                = Hid;
                modelFormCollection.Rental             = Rental;
                modelFormCollection.Others             = Others;
                modelFormCollection.paramsModel        = String.Empty;
                modelFormCollection.paramsSerialNumber = String.Empty;
                modelFormCollection.btnPOST            = btnPOST;
                var DataRelatedTicketOverview = getListTableRelatedTROverview(fc, Hid, Rental, Others, fc["model"], null, btnPOST);
                var DataRelatedDPPMOverview   = GetTableRelatedDPPMOverview(fc, Hid, Rental, Others, fc["model"], null, btnPOST);
                ViewBag.TicketDataOverview          = DataRelatedTicketOverview.Item1;
                ViewBag.TicketDataCountOverview     = DataRelatedTicketOverview.Item2;
                ViewBag.RelatedDPPMData             = DataRelatedDPPMOverview.Item1;
                ViewBag.RelatedDPPMDataCount        = DataRelatedDPPMOverview.Item2;
                ViewBag.ModelFormCollectionOverview = modelFormCollection;
                ViewBag.FilterType = Convert.ToInt32(fc["filterType"]);

                return(View());
            }
        }
示例#19
0
        public ActionResult SaveFile(int id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
            {
                return(RedirectToAction("Login", "Account"));
            }

            List <ArticleFile> FileData = _articleFileBs.GetListByArtikelId(id);

            try
            {
                String FileName = "Trakindo TREND-Literature.zip";
                if (FileData.Count == 1)
                {
                    foreach (var data in FileData)
                    {
                        if (Session["roleColor"].ToString().ToLower().Contains("guest"))
                        {
                            if (data.LevelUser.ToLower().Contains("guest"))
                            {
                                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                                Response.ClearContent();
                                Response.Clear();
                                Response.ContentType = "application/msi";
                                Response.AppendHeader("Content-Disposition", "attachment; filename=" + data.Name);
                                Response.TransmitFile(Server.MapPath("~/Upload/Article/Attachments/") + data.Name);
                                Response.End();
                            }
                        }
                        else if (Session["roleColor"].ToString().ToLower().Contains("green"))
                        {
                            if (data.LevelUser.ToLower().Contains("guest") || data.LevelUser.ToLower().Contains("green"))
                            {
                                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                                Response.ClearContent();
                                Response.Clear();
                                Response.ContentType = "application/msi";
                                Response.AppendHeader("Content-Disposition", "attachment; filename=" + data.Name);
                                Response.TransmitFile(Server.MapPath("~/Upload/Article/Attachments/") + data.Name);
                                Response.End();
                            }
                        }
                        else if (Session["roleColor"].ToString().ToLower().Contains("yellow"))
                        {
                            Response.Cache.SetCacheability(HttpCacheability.NoCache);
                            Response.ClearContent();
                            Response.Clear();
                            Response.ContentType = "application/msi";
                            Response.AppendHeader("Content-Disposition", "attachment; filename=" + data.Name);
                            Response.TransmitFile(Server.MapPath("~/Upload/Article/Attachments/") + data.Name);
                            Response.End();
                        }
                    }
                    return(File(FileName, "application/msi"));
                }
                else
                {
                    using (ZipOutputStream zipOutputStream = new ZipOutputStream(System.IO.File.Create(Server.MapPath("~/Upload/Article/Attachments/") + FileName)))
                    {
                        zipOutputStream.SetLevel(9);
                        byte[] buffer   = new Byte[4096];
                        var    DataList = new List <string>();
                        foreach (var datafile in FileData)
                        {
                            if (Session["roleColor"].ToString().ToLower() == "guest")
                            {
                                if (datafile.LevelUser.ToLower() == "guest")
                                {
                                    DataList.Add(Server.MapPath("~/Upload/Article/Attachments/") + datafile.Name);
                                }
                            }
                            else if (Session["roleColor"].ToString().ToLower() == "green")
                            {
                                if (datafile.LevelUser.ToLower() == "guest" || datafile.LevelUser.ToLower() == "green")
                                {
                                    DataList.Add(Server.MapPath("~/Upload/Article/Attachments/") + datafile.Name);
                                }
                            }
                            else if (Session["roleColor"].ToString().ToLower() == "yellow")
                            {
                                DataList.Add(Server.MapPath("~/Upload/Article/Attachments/") + datafile.Name);
                            }
                        }
                        for (int i = 0; i < DataList.Count; i++)
                        {
                            ZipEntry entry = new ZipEntry(Path.GetFileName(DataList[i]));
                            entry.DateTime      = DateTime.Now;
                            entry.IsUnicodeText = true;
                            zipOutputStream.PutNextEntry(entry);

                            using (FileStream fileStream = System.IO.File.OpenRead(DataList[i]))
                            {
                                int sourcebytes;
                                do
                                {
                                    sourcebytes = fileStream.Read(buffer, 0, buffer.Length);
                                    zipOutputStream.Write(buffer, 0, sourcebytes);
                                } while (sourcebytes > 0);
                            }
                        }
                        zipOutputStream.Finish();
                        zipOutputStream.Flush();
                        zipOutputStream.Close();
                    }
                    var    path        = Server.MapPath("~/Upload/Article/Attachments/") + FileName;
                    byte[] finalresult = System.IO.File.ReadAllBytes(path);

                    return(File(finalresult, "application/zip", FileName));
                }
            }
            catch (FileNotFoundException er)
            {
                _LogErrorBs.WriteLog("Download ZIP Literature", MethodBase.GetCurrentMethod().Name, er.ToString());
                return(Content("<script language='javascript' type='text/javascript'>alert('File Literature is Not Found'); location.href = '" + WebConfigure.GetDomain() + "/Literation';</script>"));
                //return RedirectToAction("Index", "Literation");
            }
        }
        public ActionResult Create(Article articleObject, FormCollection collection)
        {
            ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (Session["username"] != null)
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            if (!Common.CheckUserYellow())
            {
                return(RedirectToAction("Login", "Account"));
            }

            articleObject.Position = 0;
            if (articleObject.Category1Id != 0)
            {
                articleObject.Category1 = _articleCategoryBs.GetDetail(articleObject.Category1Id).Name ?? "-";
            }
            if (articleObject.Category2Id != 0)
            {
                articleObject.Category2 = _articleCategoryBs.GetDetail(articleObject.Category2Id).Name ?? "-";
            }
            if (articleObject.Category3Id != 0)
            {
                articleObject.Category3 = _articleCategoryBs.GetDetail(articleObject.Category3Id).Name ?? "-";
            }
            if (articleObject.Category4Id != 0)
            {
                articleObject.Category4 = _articleCategoryBs.GetDetail(articleObject.Category4Id).Name ?? "-";
            }
            if (articleObject.Category5Id != 0)
            {
                articleObject.Category5 = _articleCategoryBs.GetDetail(articleObject.Category5Id).Name ?? "-";
            }
            if (articleObject.Category6Id != 0)
            {
                articleObject.Category6 = _articleCategoryBs.GetDetail(articleObject.Category6Id).Name ?? "-";
            }
            if (articleObject.Category7Id != 0)
            {
                articleObject.Category7 = _articleCategoryBs.GetDetail(articleObject.Category7Id).Name ?? "-";
            }

            articleObject.CreatedAt = DateTime.Now;
            if (collection["type"] == "draft")
            {
                articleObject.Status = 2;
            }
            else
            {
                articleObject.Status = 0;
            }
            articleObject.CreatedBy = Convert.ToInt32(Session["userid"]);

            String token = Common.AccessToken() + DateTime.Now.ToString("ddMMyyyy");

            token = token.Replace("/", "");
            token = token.Replace("+", "");
            articleObject.Token = token;
            var articleModel = _articleBs.Add(articleObject);

            if (Request.Files.Count > 0)
            {
                //ArticleFile articleFile = Factory.Create<ArticleFile>("ArticleFile", ClassType.clsTypeDataModel);

                //for (int i = 0, iLen = Request.Files.Count; i < iLen; i++)
                //{
                //    var file = Request.Files[i];
                //    string response = Common.ValidateFileUpload(file);

                //    if (response.Equals("true"))
                //    {
                //        articleFile.ArticleId = articleModel.ArticleId;
                //        articleFile.Name = Common.UploadFileArticle(file, articleModel.ArticleId + "-" + i.ToString());
                //        articleFile.CreatedAt = DateTime.Now;

                //        _articleFileBs.Add(articleFile);
                //    }
                //}
                for (int i = 0, iLen = Request.Files.Count; i < iLen; i++)
                {
                    if (Request.Files.GetKey(i) == "header")
                    {
                        var    file     = Request.Files.Get(i);
                        string response = Common.ValidateFileUpload(file);

                        if (response.Equals("true"))
                        {
                            if (file != null)
                            {
                                var fileName = articleModel.ArticleId + Path.GetExtension(file.FileName);

                                var path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Upload/Article/Header/"), fileName);

                                file.SaveAs(path);

                                articleModel.HeaderImage = fileName;
                            }

                            _articleBs.Edit(articleModel);
                        }
                    }
                }
                if (Request.Files.AllKeys.Contains("attachment[]"))
                {
                    ArticleFile artikelFile     = Factory.Create <ArticleFile>("ArticleFile", ClassType.clsTypeDataModel);
                    int         attachmentIndex = 1;
                    string[]    fileLevel       = collection["file_level[]"].Split(',');
                    for (int i = 0, iLen = Request.Files.Count; i < iLen; i++)
                    {
                        if (Request.Files.GetKey(i) == "attachment[]")
                        {
                            var    file       = Request.Files[i];
                            string response   = Common.ValidateFileUpload(file);
                            string dateString = DateTime.Now.ToString("yyyyMMddHmmss");
                            if (response.Equals("true"))
                            {
                                artikelFile.ArticleId = articleModel.ArticleId;
                                artikelFile.Name      = Common.UploadFileArticle(file, Path.GetFileNameWithoutExtension(file.FileName) + "-" + dateString + "-" + attachmentIndex);
                                artikelFile.LevelUser = fileLevel[i - 1];
                                artikelFile.CreatedAt = DateTime.Now;

                                _articleFileBs.Add(artikelFile);
                                attachmentIndex += 1;
                            }
                        }
                    }
                }
            }
            if (collection["type"] == "draft")
            {
                return(RedirectToAction("Draft", "Library"));
            }
            else
            {
                Email.SendMailPublishArticle(articleModel);
                Email.SendMailNeedApp1Article(articleModel);
                return(RedirectToAction("List", "Library"));
            }
        }
        public ActionResult Edit(Article artikelObject, FormCollection collection)
        {
            ViewBag.UseFullLink = _articleBs.getUseFullLink().Count > 0 ? _articleBs.getUseFullLink() : null;
            if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj() != "" && Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (Session["username"] != null)
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            if (!Common.CheckUserYellow())
            {
                return(RedirectToAction("Login", "Account"));
            }
            SetDropdownArtikelCategory(artikelObject);

            var artikelModel = ParsingEdit(artikelObject, collection);

            artikelModel = _articleBs.Edit(artikelModel);

            if (collection.AllKeys.Contains("tag-input[]"))
            {
                string tags = collection["tag-input[]"];
                UpdateArticleTags(tags, artikelModel.ArticleId);
            }
            //upload
            if (Request.Files.Count > 0)
            {
                for (int i = 0, iLen = Request.Files.Count; i < iLen; i++)
                {
                    if (Request.Files.GetKey(i) == "header")
                    {
                        var    file     = Request.Files.Get(i);
                        string response = Common.ValidateFileUpload(file);

                        if (response.Equals("true"))
                        {
                            if (file != null)
                            {
                                var fileName = artikelModel.ArticleId + Path.GetExtension(file.FileName);

                                var path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Upload/Article/Header/"), fileName);

                                file.SaveAs(path);

                                artikelModel.HeaderImage = fileName;
                            }

                            _articleBs.Edit(artikelModel);
                        }
                    }
                }

                if (Request.Files.AllKeys.Contains("attachment[]"))
                {
                    _articleFileBs.DeleteAll(artikelModel.ArticleId);
                    ArticleFile artikelFile     = Factory.Create <ArticleFile>("ArticleFile", ClassType.clsTypeDataModel);
                    int         attachmentIndex = 1;
                    string[]    fileLevel       = collection["file_level[]"].Split(',');
                    for (int i = 0, iLen = Request.Files.Count; i < iLen; i++)
                    {
                        if (Request.Files.GetKey(i) == "attachment[]")
                        {
                            var    file       = Request.Files[i];
                            string response   = Common.ValidateFileUpload(file);
                            string dateString = DateTime.Now.ToString("yyyyMMddHmmss");
                            if (response.Equals("true"))
                            {
                                artikelFile.ArticleId = artikelModel.ArticleId;
                                artikelFile.Name      = Common.UploadFileArticle(file, Path.GetFileNameWithoutExtension(file.FileName) + "-" + dateString + "-" + attachmentIndex);
                                artikelFile.LevelUser = fileLevel[i - 1];
                                artikelFile.CreatedAt = DateTime.Now;

                                _articleFileBs.Add(artikelFile);
                                attachmentIndex += 1;
                            }
                        }
                    }
                }
            }
            if (collection["type"] == "draft")
            {
                return(RedirectToAction("Draft", "Library"));
            }
            else
            {
                Email.SendMailPublishArticle(artikelModel);
                Email.SendMailNeedApp1Article(artikelModel);
                return(RedirectToAction("List", "Library"));
            }
        }
#pragma warning disable 1998
        public async Task <ActionResult> Login(User model)
#pragma warning restore 1998
        {
            ViewBag.Download = WebConfigure.GetDomain() + "/Upload/Document/" + WebConfigure.GetUserGuideNameFileWithExtention();
            ViewBag.Domain   = WebConfigure.GetDomain();
            try
            {
                if (ModelState.IsValid)
                {
                    #region cek EmployeeID
                    if (LoginValidate(model))
                    {
                        #region session User

                        var user = _userBService.GetDetailbyUsername(model.Username);

                        if (user != null)// User registered at TREND system
                        {
                            if (user.Status.Equals(7))
                            {
                                var userT = _userBService.GetDetailbyUsername(model.Username);
                                Session["userid"]      = userT.UserId;
                                Session["role"]        = userT.RoleId;
                                Session["roleColor"]   = _userRoleBService.GetDetail(userT.RoleId).Description;
                                Session["username"]    = userT.Username;
                                Session["name"]        = userT.Name;
                                Session["status"]      = userT.Status;
                                Session["photo"]       = userT.PhotoProfile;
                                Session["loginPortal"] = WebConfigure.GetLoginPortal();

                                if (userT.IsDelegate != 0)
                                {
                                    Delegation delegationData = _userBService.GetDetailDelegation(userT.IsDelegate);
                                    Session["DelegateStatus"] = delegationData.Status;
                                    Session["DelegateTo"]     = _userBService.GetDetail(delegationData.ToUser).Name;
                                    Session["DelegateUntil"]  = delegationData.EndDate;
                                    Session["DelegateStart"]  = delegationData.StartDate;
                                }
                                else if (user.IsDelegate == 0)
                                {
                                    Session["DelegateStatus"] = null;
                                    Session["DelegateUntil"]  = null;
                                    Session["DelegateTo"]     = null;
                                    Session["DelegateStart"]  = null;
                                }
                                return(RedirectToAction("Summary", "TechnicalRequest"));

                                #endregion
                            }
                            else//user Registered but Inactive
                            {
                                Session["userid"]         = user.UserId;
                                Session["role"]           = user.RoleId;
                                Session["roleColor"]      = "Guest";
                                Session["username"]       = user.Username;
                                Session["name"]           = user.Name;
                                Session["status"]         = user.Status;
                                Session["photo"]          = user.PhotoProfile;
                                Session["loginPortal"]    = WebConfigure.GetLoginPortal();
                                Session["DelegateStatus"] = null;
                                Session["DelegateUntil"]  = null;
                                Session["DelegateTo"]     = null;
                                Session["DelegateStart"]  = null;
                                return(RedirectToAction("Index", "Library"));
                            }
                        }
                        else if (user == null)
                        {//As Guest
                         //return RedirectToAction("Register", "Account");
                            var userguest = _userBService.GetDetailbyUsername("Guest");
                            Session["userid"]         = userguest.UserId;
                            Session["role"]           = userguest.RoleId;
                            Session["roleColor"]      = "Guest";
                            Session["username"]       = userguest.Username;
                            Session["name"]           = userguest.Name;
                            Session["status"]         = userguest.Status;
                            Session["photo"]          = userguest.PhotoProfile;
                            Session["loginPortal"]    = WebConfigure.GetLoginPortal();
                            Session["DelegateStatus"] = null;
                            Session["DelegateUntil"]  = null;
                            Session["DelegateTo"]     = null;
                            Session["DelegateStart"]  = null;
                            return(RedirectToAction("Index", "Library"));
                        }
                    }
                    #endregion
                }

                return(View(model));
            }
            catch (Exception er)
            {
                _logErrorBService.WriteLog("Account", MethodBase.GetCurrentMethod().Name, er.ToString());
                return(View("Login", "Default"));
            }
        }