Ejemplo n.º 1
0
 private SP.ListItemCollection GetItemsFromSharepointList(string listName, string viewName)
 {
     try
     {
         // get the list from context
         SP.List readList = SharepointMethods.GetListFromWeb(
             _context,
             listName);
         // get view from list by view name
         SP.View readView = SharepointMethods.GetViewFromList(
             _context,
             readList,
             viewName);
         // get items from list by view
         SP.ListItemCollection readListItems = SharepointMethods.GetViewItemsFromList(
             _context,
             readList,
             readView);
         return(readListItems);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return(null);
     }
 }
Ejemplo n.º 2
0
        private SP.ListItem LogTransaction(SP.ListItem project, string transactionTypeId)
        {
            Dictionary <string, string> transactionInfo = ParseTransactionInfo(project, "19");

            SP.List transactionsList = SharepointMethods.GetListFromWeb(
                _context,
                SharepointConstants.Links.transactionsList);
            SP.ListItem transaction = SharepointMethods.AddItemToList(
                _context,
                transactionsList,
                transactionInfo
                );

            return(transaction);
        }
Ejemplo n.º 3
0
        private SP.ListItem LogProject(SP.ListItem selectedProject, SP.ListItem transaction)
        {
            // parse the project info
            Dictionary <string, string> projectInfo = ParseProjectInfo(selectedProject, transaction);

            // get write list
            SP.List linkedProjectsList = SharepointMethods.GetListFromWeb(
                _context,
                SharepointConstants.Links.linkedProjectList);

            // write the project info to sharepoint
            SP.ListItem loggedProject = SharepointMethods.AddItemToList(
                _context,
                linkedProjectsList,
                projectInfo
                );

            return(loggedProject);
        }
Ejemplo n.º 4
0
        private List <Dictionary <string, string> > HandleUpload()
        {
            using (ProgressDialog pd = new ProgressDialog("Upload", 5))
            {
                pd.Show();
                // collect rooms from the model, return false if there are none
                pd.StartTask("Collecting placed rooms");
                IList <SpatialElement> placedRooms = RevitMethods.GetPlacedRooms(_doc);
                if (placedRooms == null)
                {
                    pd.Close();
                    return(null);
                }
                pd.Increment();

                // check if the custom room parameters exist
                pd.StartTask("Checking room parameters");
                bool roomParametersCheck = RevitMethods.CheckParametersExist(
                    placedRooms,
                    SharepointConstants.Dictionaries.newRevitRoomParameters);
                if (roomParametersCheck == false)
                {
                    pd.Close();
                    return(null);
                }
                pd.Increment();

                // collect the room info for writing to sharepoint
                pd.StartTask("Parsing room data");
                List <Dictionary <string, string> > placedRoomsData = RevitMethods.ParseRoomData(
                    placedRooms,
                    SharepointConstants.Dictionaries.newRevitRoomParameters);
                if (placedRoomsData == null)
                {
                    pd.Close();
                    return(null);
                }
                pd.Increment();

                // retrieve write list from sharepoint
                pd.StartTask("Connecting to Sharepoint");
                SP.List SPWriteList = SharepointMethods.GetListFromWeb(
                    _context,
                    SharepointConstants.Links.spWriteList);
                if (SPWriteList == null)
                {
                    pd.Close();
                    return(null);
                }
                pd.Increment();

                // write the room data to the write list
                pd.StartTask("Writing data to Sharepoint");
                bool roomsUploaded = SharepointMethods.AddItemsToList(
                    _context,
                    SPWriteList,
                    placedRoomsData);
                if (roomsUploaded == false)
                {
                    pd.Close();
                    return(null);
                }
                pd.Increment();

                // if we get to the end then return the written data
                return(placedRoomsData);
            }
        }