Exemple #1
0
        //- To get the GetSites for Service Order Process Page
        public List<Site> GetSites(string userName)
        {
            List<Site> siteList = new List<Site> { };
            IAXHelper axHelper = ObjectFactory.GetInstance<IAXHelper>();
            try
            {
                DataTable resultTable = axHelper.GetSitesList(userName);

                foreach (DataRow row in resultTable.Rows)
                {
                    Site siteObject = new Site();
                    siteObject.SiteID = row["SiteID"].ToString();
                    siteObject.SiteName = row["SiteName"].ToString();
                    siteList.Add(siteObject);

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return siteList;
        }
        // GET: /ServiceOrderProcess/
        public ActionResult ServiceOrderProcess()
        {
            string userName = "";
            TempData["ServiceOrderId"] = Session["SID"];
            TempData["WorkOrderSiteId"] = Session["SiteID"];
            userName = User.Identity.Name.ToString().Split('\\')[1];
            SerivceOrderPartLine serivceOrderPartLineObject = new SerivceOrderPartLine();
            ServiceOrderLine serivceOrderLineObject = new ServiceOrderLine();
            List<ServiceOrderLine> serviceOrderLineList = new List<ServiceOrderLine>();

            try
            {
                if (HttpContext.Session != null)
                {
                    if (Session["SiteID"] == null)
                    {
                        return RedirectToAction("ServiceOrderWithHistory");
                    }
                }
                if (TempData["ServiceOrderId"] != null)
                {

                    serivceOrderLineObject.ServiceOrderLineList = serviceOrderLineList;
                    serivceOrderPartLineObject.ServiceOrderLine = serivceOrderLineObject;

                    FailureCode failureCodeObject = new FailureCode();
                    IEnumerable<FailureCode> failureCodeCollection = failureCodeObject.GetFailureCode(userName);
                    failureCodeObject.FailureCodeList = new SelectList(failureCodeCollection, "FailureCodeNo", "FailureDescription", null);
                    ViewData["FailureCodeList"] = failureCodeObject.FailureCodeList;

                    PartDetails partDetails = new PartDetails();
                    partDetails.PartDetailsList = new SelectList(partDetails.GetItemNumbers(userName), "ItemNumber", "ItemNumber", null);
                    ViewData["PartNumberList"] = partDetails.PartDetailsList;

                    LineProperty LinePropertyObject = new LineProperty();
                    IEnumerable<LineProperty> LinePropertyCollection = LinePropertyObject.GetLineProperty(userName);
                    LinePropertyObject.LinePropertyList = new SelectList(LinePropertyCollection, "LinePropertyCode", "LinePropertyDescription", null);
                    ViewData["LinePropertyList"] = LinePropertyObject.LinePropertyList;

                    IEnumerable<SerivceOrderPartLine> serviceOrderPartLineCollection = null;

                    serviceOrderPartLineCollection = serivceOrderPartLineObject.GetSerialNumberByServiceOrder(TempData["ServiceOrderId"].ToString(), userName);

                    serivceOrderPartLineObject.ServiceOrderPartLineList = new SelectList(serviceOrderPartLineCollection, "ServiceObjectRelation", "SerialNumber", null);

                    ViewData["SORelationList"] = serivceOrderPartLineObject.ServiceOrderPartLineList;
                    ViewData["WorkSerialNumberList"] = serivceOrderPartLineObject.ServiceOrderPartLineList;
                    ViewData["ServiceOrderPartLines"] = GetServiceOrderPartLinesByServiceOrderID(TempData["ServiceOrderId"].ToString());

                    ServiceOrder ServiceOrder = new ServiceOrder();
                    ServiceOrder.ServiceOrderList = GetServiceOrderDetailsByServiceOrder(TempData["WorkOrderSiteId"].ToString(), TempData["ServiceOrderId"].ToString());
                    serivceOrderPartLineObject.ServiceOrders = ServiceOrder;
                    ViewData["ServiceOrderLineinProcess"] = serivceOrderPartLineObject.ServiceOrders.ServiceOrderList;

                    ServiceTechnician serviceTechnician = new ServiceTechnician();
                    IEnumerable<ServiceTechnician> serviceTechnicianCollection = null;
                    serviceTechnicianCollection=serviceTechnician.GetTechnicians(userName);

                    if (!String.IsNullOrEmpty(TempData["Technician"].ToString()))
                    {
                        serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", serviceTechnicianCollection.First<ServiceTechnician>().ServiceTechnicianNo = TempData["Technician"].ToString());
                    }
                    else
                    {
                        serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", null);
                    }
                    ViewData["ServiceTechnicianLoadList"] = serviceTechnician.ServiceTechnicianList;

                    Site site = new Site();
                    IEnumerable<Site> siteCollection = null;
                    siteCollection = site.GetSites(userName);
                    if (!String.IsNullOrEmpty(TempData["WorkOrderSiteId"].ToString()))
                    {
                        site.SiteList = new SelectList(siteCollection, "SiteId", "SiteName", siteCollection.First<Site>().SiteID = TempData["WorkOrderSiteId"].ToString());
                    }
                    else
                    {
                        site.SiteList = new SelectList(siteCollection, "SiteId", "SiteName", siteCollection.First<Site>().SiteID);
                    }

                    ViewData["siteList"] = site.SiteList;
                    ViewData["TranasactionTypes"] = TransactionType.GetTransactionTypes();
                    TempData.Keep();
                }
                else
                {
                   return RedirectToAction("ServiceOrderWithHistory");
                   // return View("ServiceOrderWithHistory", serivceOrderPartLineObject);
                    //throw new Exception("Select the service order number in Service Order with history page");

                }
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
               // throw new Exception("Select the service order number in Service Order with history page");
                //return RedirectToAction("ServiceOrderWithHistory");
             //  return Json("Select the service order number in Service Order with history page",JsonRequestBehavior.AllowGet);

            }

            return View(serivceOrderPartLineObject);
        }
        //Get Sites for the authenticated user
        private string GetSites()
        {
            Site site = new Site();
            IEnumerable<Site> siteCollection = null;
            string userName = null;
            userName = User.Identity.Name.ToString().Split('\\')[1];
            try
            {
                if (site.SiteList == null)
                {

                    siteCollection = site.GetSitesListByUsername(userName);
                    if (siteCollection.Count() > 0)
                    {
                        site.SiteList = new SelectList(siteCollection, "SiteId", "SiteName", siteCollection.First<Site>().SiteID);
                        TempData["SiteId"] = siteCollection.First<Site>().SiteID;
                        Session["SiteID"] = TempData["SiteId"];
                        TempData["AllSites"] = siteCollection;
                        TempData["FeaturedSites"] = site.SiteList;
                        ViewData["FeaturedSites"] = site.SiteList;
                        TempData.Keep();
                    }
                    else
                    {
                        throw new Exception("No Sites assigned for this user in AX Dynamics");
                    }

                }

            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
                throw ex;
                //return Json("Select the service order number in Service Order with history page", JsonRequestBehavior.AllowGet);
            }
            return siteCollection.First<Site>().SiteID;
        }
        public ActionResult ServiceOrderWithHistory(string siteId, string process)
        {
            string userName = null;
            userName = User.Identity.Name.ToString().Split('\\')[1];
            try
            {

                if (String.IsNullOrEmpty(siteId))
                {
                    GetSites();
                    if (process == null)
                    {
                        process = "-1";
                    }
                }
                else
                {
                    TempData["SiteId"] = siteId;
                    Session["SiteID"] = siteId;
                    Site site = new Site();
                    IEnumerable<Site> existingSites = (IEnumerable<Site>)TempData["AllSites"];
                    site.SiteList = new SelectList(existingSites, "SiteId", "SiteName", siteId);
                    TempData["FeaturedSites"] = site.SiteList;
                    ViewData["FeaturedSites"] = site.SiteList;
                    TempData.Keep();
                }
                ViewData["ServiceOrder"] = GetServiceOrders(TempData["SiteId"].ToString(), process);
                ViewData["ServiceOrderLine"] = GetServiceOrderLinesByServiceOrderID("");
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
                //return Json("No Sites assigned for this user in AX Dynamics", JsonRequestBehavior.AllowGet);
                //return RedirectToAction("ServiceOrderWithHistory");
            }
            return View("ServiceOrderWithHistory");
        }
Exemple #5
0
        //- To get the GetSites  for sites
        public IEnumerable<Site> GetSitesListByUsername(string userName)
        {
            List<Site> siteList = new List<Site> { };
            IAXHelper axHelper = ObjectFactory.GetInstance<IAXHelper>();

            try
            {

                DataTable resultTable = axHelper.GetDefaultSitesByUsername(userName);

                foreach (DataRow row in resultTable.Rows)
                {
                    Site currentSite = new Site();
                    currentSite.Username = row["User"].ToString();
                    currentSite.SiteID = row["Sites"].ToString();
                    currentSite.SiteName = row["SitesName"].ToString();
                    currentSite.IsDefault = row["Default"].ToString();
                    siteList.Add(currentSite);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return siteList.AsEnumerable<Site>();
        }