Exemplo n.º 1
0
        /// <summary>
        /// Adds a new request to the SharePoint site. 
        /// </summary>
        /// <param name="input">A VpnRequest model</param>
        public void addRequest(VpnRequest input)
        {
            List spList = clientContext.Web.Lists.GetByTitle(requestNames.ListName);
            clientContext.Load(spList);

            var itemCreateInfo = new ListItemCreationInformation();
            var listItem = spList.AddItem(itemCreateInfo);

            //pulling up the current user information
            User user = clientContext.Web.EnsureUser(HttpContext.Current.User.Identity.Name);
            clientContext.Load(user);
            clientContext.ExecuteQuery();
            FieldUserValue userValue = new FieldUserValue();
            userValue.LookupId = user.Id;

            //pulling up the manager information
            var manager = clientContext.Web.EnsureUser(input.Manager);
            clientContext.Load(manager);
            clientContext.ExecuteQuery();
            FieldUserValue userValue2 = new FieldUserValue();
            userValue2.LookupId = manager.Id;

            listItem[requestNames.internalCreatedBy] = userValue;
            listItem[requestNames.internalVpnRecipientFirst] = input.VPN_recipientFirst;
            listItem[requestNames.internalVpnRecipientLast] = input.VPN_recipientLast;
            listItem[requestNames.internalWorkPhone] = input.Work_Phone;
            listItem[requestNames.internalEmail] = input.VPN_recipientEmail;
            listItem[requestNames.internalUserCode] = input.VPN_userCode;
            listItem[requestNames.internalManager] = userValue2;
            listItem[requestNames.internalUserDept] = input.VPN_userDept;
            listItem[requestNames.internalUserStatus] = input.VPN_userStatus;
            listItem[requestNames.internalSystemsList] = input.Systems_List;
            listItem[requestNames.internalJustification] = input.VPN_justification;
            listItem[requestNames.internalAccessStart] = input.VPN_accessStart;
            listItem[requestNames.internalAccessEnd] = input.VPN_accessEnd;
            listItem[requestNames.internalCompanyName] = input.Company_Name;
            listItem[requestNames.internalCompanyOther] = input.Company_Other;
            listItem[requestNames.internalOfficeLocation] = input.Office_Location;
            listItem[requestNames.internalOfficeAddress] = input.Office_Address;
            listItem[requestNames.internalMachineOwner] = input.Machine_Owner;
            listItem[requestNames.internalExtCode] = input.Ext_code;
            listItem[requestNames.internalAgency] = input.Agency;

            listItem.Update();
            clientContext.ExecuteQuery();
        }
Exemplo n.º 2
0
        //takes in a running list of request and a list of strings
        //takes the list of strings, finds all VPN Requests with the same ID on the SP Server
        //returns an updated list of requests
        //currentRequests = currentRequests + col
        /// <summary>
        /// Takes a running list of VpnRequest and adds more VpnRequests based on ID
        /// </summary>
        /// <param name="currentRequests">A running list of VpnRequests</param>
        /// <param name="col">List of VPN Request IDs</param>
        /// <returns>A list of VPN Requests equivalent to the original list given combined with another VPN Request list (given in ID)</returns>
        private List<VpnRequest> loadList(List<VpnRequest> currentRequests, List<string> col)
        {
            List spList = clientContext.Web.Lists.GetByTitle(requestNames.ListName);
            clientContext.Load(spList);

            //remove any duplicates from col
            col = col.Distinct().ToList();

            //going to traverse the list of strings (which represent VPN Request IDs) to generate a list of ListItems
            List<ListItem> spRequestList = new List<ListItem>();
            foreach(string current in col)
            {
                spRequestList.Add(spList.GetItemById(Int32.Parse(current) - 1000));
            }

            //converting the list of ListItems in to a list of VpnRequests
            foreach(ListItem item in spRequestList)
            {
                try
                {
                    clientContext.Load(item);
                    clientContext.ExecuteQuery();

                    VpnRequest temp = new VpnRequest();
                    temp.VPN_requestID = Int32.Parse((string)item[requestNames.internalID]);
                    temp.DateSubmitted = ((DateTime)item[requestNames.internalCreated]).ToString("MM/dd/yyyy");
                    temp.VPN_requestStatus = (string)item[requestNames.internalRequestStatus];
                    temp.VPN_accessEnd = ((DateTime)item[requestNames.internalAccessEnd]).ToString();
                    temp.VPN_accessStart = ((DateTime)item[requestNames.internalAccessStart]).ToString();
                    temp.VPN_recipientFirst = (string)item[requestNames.internalVpnRecipientFirst];
                    temp.VPN_recipientLast = (string)item[requestNames.internalVpnRecipientLast];
                    temp.Work_Phone = (string)item[requestNames.internalWorkPhone];
                    temp.VPN_recipientEmail = (string)item[requestNames.internalEmail];
                    temp.VPN_userCode = Convert.ToInt32(((double)item[requestNames.internalUserCode]));
                    temp.Manager = ((FieldUserValue)item[requestNames.internalManager]).LookupValue;
                    temp.Systems_List = (string)item[requestNames.internalSystemsList];
                    temp.VPN_justification = (string)item[requestNames.internalJustification];
                    temp.VPN_userDept = (string)item[requestNames.internalUserDept];
                    temp.Company_Name = (string)item[requestNames.internalCompanyName];
                    temp.Company_Other = (string)item[requestNames.internalCompanyOther];
                    temp.Office_Location = (string)item[requestNames.internalOfficeLocation];
                    temp.Office_Address = (string)item[requestNames.internalOfficeAddress];
                    temp.Machine_Owner = (string)item[requestNames.internalMachineOwner];
                    temp.VPN_userStatus = (string)item[requestNames.internalUserStatus];
                    temp.Agency = (string)item[requestNames.internalAgency];
                    temp.VPN_requestor = ((FieldUserValue)item[requestNames.internalCreatedBy]).LookupValue;
                    try
                    {
                        temp.Ext_code = Convert.ToInt32((double)item[requestNames.internalExtCode]);
                        temp.Reviewer_Comments = (string)item[requestNames.internalComments];
                    }
                    catch (System.ArgumentNullException e)
                    {
                        //extension code can be null, so we'll skip over this
                    }catch (System.NullReferenceException f)
                    {
                        //extension code can be null, so we'll skip over this
                    }
                    currentRequests.Add(temp);
                }
                catch (System.ArgumentNullException e)
                {
                    //if something critical is null, we won't add it to the viewbag list
                    continue;
                }
            }
            return currentRequests;
        }
Exemplo n.º 3
0
        /// <summary>
        /// (Model Mapping Method) CSOM -> VpnRequest
        /// Converts each ListItem in a ListItemCollection to a VpnRequest.
        /// Adds each VpnRequest to an ongoing list of VpnRequests. 
        /// </summary>
        /// <param name="currentRequests">A running list of VpnRequests</param>
        /// <param name="col">CSOM equivalent to VpnRequest</param>
        /// <returns>A list of VPN Requests</returns>
        private List<VpnRequest> loadList(List<VpnRequest> currentRequests, ListItemCollection col)
        {
            //this method takes a ListItemCollection and converts it into a list of VpnRequest (A model Kevin created)
            //if an ongoing list is passed in, requests are added
            //if there is no ongoing list, pass in an empty List<VpnRequest>
            List spList = clientContext.Web.Lists.GetByTitle(requestNames.ListName);
            clientContext.Load(spList);
            foreach (ListItem item in col)
            {
                try
                {
                    clientContext.Load(item);
                    clientContext.ExecuteQuery();

                    VpnRequest temp = new VpnRequest();
                    temp.VPN_requestID = Int32.Parse((string)item[requestNames.internalID]);
                    temp.DateSubmitted = ((DateTime)item[requestNames.internalCreated]).ToString("MM/dd/yyyy");
                    temp.VPN_requestStatus = (string)item[requestNames.internalRequestStatus];
                    temp.VPN_accessEnd = ((DateTime)item[requestNames.internalAccessEnd]).ToString();
                    temp.VPN_accessStart = ((DateTime)item[requestNames.internalAccessStart]).ToString();
                    temp.VPN_recipientFirst = (string)item[requestNames.internalVpnRecipientFirst];
                    temp.VPN_recipientLast = (string)item[requestNames.internalVpnRecipientLast];
                    temp.Work_Phone = (string)item[requestNames.internalWorkPhone];
                    temp.VPN_recipientEmail = (string)item[requestNames.internalEmail];
                    temp.VPN_userCode = Convert.ToInt32(((double)item[requestNames.internalUserCode]));
                    temp.Manager = ((FieldUserValue)item[requestNames.internalManager]).LookupValue;
                    temp.Systems_List = (string)item[requestNames.internalSystemsList];
                    temp.VPN_justification = (string)item[requestNames.internalJustification];
                    temp.VPN_userDept = (string)item[requestNames.internalUserDept];
                    temp.Company_Name = (string)item[requestNames.internalCompanyName];
                    temp.Company_Other = (string)item[requestNames.internalCompanyOther];
                    temp.Office_Location = (string)item[requestNames.internalOfficeLocation];
                    temp.Office_Address = (string)item[requestNames.internalOfficeAddress];
                    temp.Machine_Owner = (string)item[requestNames.internalMachineOwner];
                    temp.VPN_userStatus = (string)item[requestNames.internalUserStatus];
                    temp.Agency = (string)item[requestNames.internalAgency];
                    temp.VPN_requestor = ((FieldUserValue)item[requestNames.internalCreatedBy]).LookupValue;
                    try
                    {
                        temp.Ext_code = Convert.ToInt32((double)item[requestNames.internalExtCode]);
                        temp.Reviewer_Comments = (string)item[requestNames.internalComments];

                    }
                    catch (System.ArgumentNullException e)
                    {
                        //extension code can be null, so we'll skip over this
                    }
                    catch (System.NullReferenceException f)
                    {

                    }
                    currentRequests.Add(temp);
                }
                catch (System.ArgumentNullException e)
                {
                    //if something critical is null, we won't add it to the viewbag list
                    continue;
                }
            }
            return currentRequests;
        }
Exemplo n.º 4
0
        public ActionResult VPNRequest(VpnRequest input)
        {
            //formating some input
            input.VPN_requestStatus = "Pending Manager Approval";
            input.DateSubmitted = DateTime.Now.ToString("M/d/yyyy");

            SpConnectionVPN spConnect = new SpConnectionVPN();
            spConnect.addRequest(input);

            return RedirectToAction("/ThankYou", "Portal");
        }
Exemplo n.º 5
0
        public ViewResult ReviewRequestIT(VpnRequest current)
        {
            ViewBag.details = current;
            SpConnectionVPN spConnection = new SpConnectionVPN();
            ViewBag.radiusSelector = spConnection.getVpnRadiusProfileSelect();

            return View("ReviewRequestIT");
        }