Esempio n. 1
0
 /// <summary>
 /// Activates the List items
 /// </summary>
 /// <param name="siteURL">The site URL.</param>
 /// <param name="listName">Name of the list.</param>
 /// <param name="rowID">The row ID.</param>
 /// <param name="auditlistName">Name of the auditlist.</param>
 /// <param name="updatePageSequence">if set to <c>true</c> [update page sequence].</param>
 /// <param name="updateAuditHistory">if set to <c>true</c> [update audit history].</param>
 /// <returns>bool</returns>
 public bool ActivateListValues(string siteURL, string listName, int rowID, string auditlistName, bool updatePageSequence, bool updateAuditHistory)
 {
     objCommonDAL = new CommonDAL();
     objCommonUtility = new CommonUtility();
     objCommonDAL.ListStatusUpdate(siteURL, listName, rowID, NO, updatePageSequence);
     if (updateAuditHistory)
     {
         objCommonDAL.UpdateListAuditHistory(siteURL, auditlistName, rowID, objCommonUtility.GetUserName(), AUDIT_ACTION_ACTIVATE);
     }
     return true;
 }
Esempio n. 2
0
        /// <summary>
        /// Updates comments for Well Book Page.
        /// </summary>
        /// <param name="parentSiteURL">The site URL.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="listEntry">ListEntry object contains the Comments.</param>
        /// <param name="actionPerformed">Audit action.</param>
        /// <returns>True/False</returns>
        /// <exception cref="">Handled in calling method.</exception>
        internal bool UpdateComments(string siteURL, string listName, string auditListName, ListEntry listEntry, string actionPerformed)
        {
            SPList list;
            SPListItem objListItem;
            SPFieldLookupValue lookupField;
            bool blnUpdateSuccess = false;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        if (string.Compare(AUDIT_ACTION_COMMENT_ADDED, actionPerformed, true) == 0)
                        {
                            if (listEntry != null && listEntry.PageComments != null)
                            {
                                objListItem = list.Items.Add();
                                objListItem["Page_ID"] = Convert.ToInt32(listEntry.PageComments.PageID);
                                objListItem["UserName"] = listEntry.PageComments.UserName;
                                objListItem["Comment"] = listEntry.PageComments.Comments;
                                /// Lookup column
                                if (!string.IsNullOrEmpty(listEntry.PageComments.DisciplineID))
                                {
                                    lookupField = new SPFieldLookupValue(listEntry.PageComments.DisciplineID);
                                    objListItem["Discipline"] = lookupField;
                                }
                                objListItem["Shared"] = listEntry.PageComments.ShareComments;
                                objListItem.Update();

                                objCommonDAL = new CommonDAL();
                                objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, Int32.Parse(listEntry.PageComments.PageID), listEntry.PageComments.UserName, actionPerformed);
                                blnUpdateSuccess = true;
                            }
                        }
                        web.AllowUnsafeUpdates = false;
                    }
                }
            });
               return blnUpdateSuccess;
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the Pages to the Chapter Directly.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <returns>ID of the Chapter Page Created.</returns>
        /// <exception cref="">Handled in calling method.</exception>
        internal string AddPageToChapter(string siteURL, ListEntry listEntry, string listName, string auditListtname, string username, string actionPerformed)
        {
            string strPageID = string.Empty;
            SPList list;
            SPListItem objListItem;
            int intRowId = 0;
            int intPageSequence = 0;
            DataTable dtlistItem = null;
            int intMappingRowId = 0;
            DataView dtDataView = null;
            SPQuery query;
            string strCamlQuery = string.Empty;
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(siteURL))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            web.AllowUnsafeUpdates = true;
                            list = web.Lists[listName];
                            objCommonDAL = new CommonDAL();
                            for (int i = 0; i < listEntry.ChapterPagesMapping.Count; i++)
                            {
                                objListItem = list.Items.Add();
                                objListItem["Master_Page_ID"] = listEntry.ChapterPagesMapping[i].MasterPageID;
                                objListItem["Page_Actual_Name"] = listEntry.ChapterPagesMapping[i].PageActualName;
                                objListItem["Page_Name"] = listEntry.ChapterPagesMapping[i].PageName;
                                objListItem["Owner"] = listEntry.ChapterPagesMapping[i].PageOwner;
                                objListItem["Discipline"] = listEntry.ChapterPagesMapping[i].Discipline;
                                objListItem["Chapter_ID"] = listEntry.ChapterDetails.RowID;
                                objListItem["Asset_Type"] = listEntry.ChapterPagesMapping[i].AssetType;
                                if (!string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].Empty))
                                    objListItem["Empty"] = listEntry.ChapterPagesMapping[i].Empty;
                                objListItem["Page_Sequence"] = listEntry.ChapterPagesMapping[i].PageSequence;
                                if (!string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].SignOffStatus))
                                {
                                    objListItem["Sign_Off_Status"] = listEntry.ChapterPagesMapping[i].SignOffStatus;
                                }
                                objListItem["Connection_Type"] = listEntry.ChapterPagesMapping[i].ConnectionType;
                                objListItem["Standard_Operating_Procedure"] = listEntry.ChapterPagesMapping[i].StandardOperatingProc;
                                if (!string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].PageURL))
                                {
                                    objListItem["Page_URL"] = listEntry.ChapterPagesMapping[i].PageURL;
                                }
                                objListItem.Update();
                                /// Assing the Item ID to return
                                strPageID = Convert.ToString(objListItem["ID"]);

                                int.TryParse(Convert.ToString(objListItem["ID"]), out intRowId);
                                listEntry.ChapterPagesMapping[i].RowId = intRowId;
                                strCamlQuery = @"<Where><Eq><FieldRef Name='Chapter_ID' /><Value Type='Number'>" + listEntry.ChapterDetails.RowID + "</Value></Eq></Where>";
                                query = new SPQuery();
                                query.Query = strCamlQuery;
                                query.ViewFields = @"<FieldRef Name='Chapter_ID' /><FieldRef Name='ID' /><FieldRef Name='Page_Sequence' />";
                                dtlistItem = list.GetItems(query).GetDataTable();
                                if (dtlistItem != null && dtlistItem.Rows.Count > 0)
                                {
                                    dtDataView = dtlistItem.DefaultView;
                                    dtDataView.Sort = "Page_Sequence asc";
                                    for (int j = 0; j < dtDataView.Count; j++)
                                    {
                                        intPageSequence = intPageSequence + 10;
                                        intMappingRowId = (int)dtDataView[j]["ID"];
                                        if (intMappingRowId != intRowId)
                                        {
                                            objListItem = list.GetItemById(intMappingRowId);
                                            objListItem["Page_Sequence"] = intPageSequence;

                                            objListItem.Update();
                                        }
                                    }
                                }
                                objCommonDAL.UpdateListAuditHistory(siteURL, auditListtname, intRowId, username, actionPerformed);

                            }

                            web.AllowUnsafeUpdates = false;
                        }

                    }
                });
            }
            finally
            {
                if (dtlistItem != null) dtlistItem.Dispose();
            }
            return strPageID;
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the Page sequence
        /// </summary>
        /// <param name="parentSiteUrl">Site URL.</param>
        /// <param name="listName">List Name.</param>
        /// <param name="auditListName">Name of the audit list.</param>
        /// <param name="dvUpdateListitems">DataView.</param>
        /// <param name="actionPerformed">Audit Action ID.</param>
        /// <param name="userName">Name of the user.</param>
        public void UpdateChapterSequence(string parentSiteUrl, string listName, string auditListName,
            DataView dvUpdateListitems, string actionPerformed, string userName)
        {
            objCommonDAL = new CommonDAL();

            objCommonDAL.UpdateSequence(parentSiteUrl, listName, dvUpdateListitems, "Chapter_Sequence");
            if (dvUpdateListitems != null && dvUpdateListitems.Count > 0)
            {
                for (int rowIndex = 0; rowIndex < dvUpdateListitems.Count; rowIndex++)
                {
                    objCommonDAL.UpdateListAuditHistory(parentSiteUrl, auditListName,
                        int.Parse(dvUpdateListitems[rowIndex]["ID"].ToString()), userName, actionPerformed);
                }
            }
            if (dvUpdateListitems != null)
                dvUpdateListitems.Dispose();
        }
Esempio n. 5
0
        /// <summary>
        /// Changes the Sign of status and the Chapter Page mapping list.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="signOffStatus">The sign off status.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="username">The username.</param>
        /// <param name="bookId">The book id.</param>
        /// <param name="actionPerformed">The action performed.</param>
        public void ChangeSignOffStatus(string siteURL, string signOffStatus, string listName, string username, string bookId, string actionPerformed)
        {
            objWellBookDAL = new WellBookDAL();
            objCommonDAL = new CommonDAL();
            objCommonBLL = new CommonBLL();
            StringBuilder strChapterPageId = new StringBuilder();
            Dictionary<string, string> listItemCollection =
                new Dictionary<string, string>();
            listItemCollection.Add("Sign_Off_Status", signOffStatus);
            string strCAMLQuery = "<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + bookId + "</Value></Eq></Where>";
            WellBookDAL.UpdateListItemCollectionValues(siteURL, listName,
                strCAMLQuery, listItemCollection);
            int intBookId = 0;
            if (!string.IsNullOrEmpty(bookId))
            {
                intBookId = int.Parse(bookId);
            }
            objCommonDAL.UpdateListAuditHistory(siteURL, DWBWELLBOOKAUDITLIST, intBookId, username, actionPerformed);

            #region Code Commented as per confirmation of UAT Feedback
            /// Update Signoff Status for all pages in Book
            //dtResult = GetPagesForBook(siteURL, bookId, "No");
            //if (dtResult != null && dtResult.Rows.Count > 0)
            //{
            //    for (int intRowIndex = 0; intRowIndex < dtResult.Rows.Count; intRowIndex++)
            //    {
            //        strChapterPageId.Append(Convert.ToString(dtResult.Rows[intRowIndex][IDCOLUMN]));
            //        strChapterPageId.Append(";");
            //    }
            //    strCAMLQuery = objCommonBLL.CreateCamlQueryWithoutWhere(strChapterPageId.ToString(), IDCOLUMN, IDCOLUMNTYPE);
            //    listItemCollection.Clear();
            //    listItemCollection.Add("Sign_Off_Status", signOffStatus);
            //    WellBookDAL.UpdateListItemCollectionValues(siteURL, chapterpageList, strCAMLQuery, listItemCollection);
            //}
            //if (dtResult != null)
            //{
            //    dtResult.Dispose();
            //}
            #endregion Code Commented as per UAT Feedback
        }
Esempio n. 6
0
        /// <summary>
        /// Updates the Sign of Status
        /// </summary>        
        /// <param name="siteUrl">Site URL.</param>
        /// <param name="listName">List Name.</param>    
        /// <param name="signOffStatus">Yes/No.</param>
        /// <param name="pageId">Page ID.</param>
        /// <param name="actionperformed">ID of Audit Action.</param>
        public void UpdateWellBookPageSignOffStatus(string siteURL, string listName, string signOffStatus, int pageId, string actionPerformed)
        {
            objWellBookDAL = new WellBookDAL();
            Dictionary<string, string> listItemCollection =
              new Dictionary<string, string>();
            listItemCollection.Add("Sign_Off_Status", signOffStatus);
            string strCAMLQuery = "<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + pageId + "</Value></Eq></Where>";
            WellBookDAL.UpdateListItemCollectionValues(siteURL, listName, strCAMLQuery, listItemCollection);
            objCommonDAL = new CommonDAL();

            Shell.SharePoint.DREAM.Utilities.CommonUtility objCommonUtility = new Shell.SharePoint.DREAM.Utilities.CommonUtility();
            string strUserName = objCommonUtility.GetUserName();
            objCommonDAL.UpdateListAuditHistory(siteURL, CHAPTERPAGESMAPPINGAUDITLIST, pageId, strUserName, actionPerformed);
        }
Esempio n. 7
0
        /// <summary>
        /// Updates the list entry for Add/Edit template.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <exception cref="">Handled in calling class.</exception>
        internal void UpdateListEntry(string siteUrl, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed)
        {
            SPList list;
            SPQuery query;
            SPListItem objListItem;
            SPListItemCollection objListCollection;
            SPFieldLookupValue lookupField;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        query = new SPQuery();
                        objListItem = list.Items.Add();

                        if (string.Equals(actionPerformed, AUDIT_ACTION_UPDATION))
                        {
                            query.Query = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Number'>" +
                      listEntry.TemplateDetails.RowId + "</Value></Eq></Where>";
                            objListCollection = list.GetItems(query);
                            foreach (SPListItem objList in objListCollection)
                            {
                                objListItem = objList;
                            }
                        }
                        /// Default Title column is renamed as Template_Name. Internal Name remains same as "Title"
                        objListItem["Title"] = listEntry.TemplateDetails.Title;

                        lookupField = new SPFieldLookupValue(listEntry.TemplateDetails.AssetID);
                        /// Asset_Type
                        objListItem["Asset_Type"] = lookupField;
                        /// Terminate_Status
                        objListItem["Terminate_Status"] = listEntry.TemplateDetails.Terminated;

                        objListItem.Update();
                        web.AllowUnsafeUpdates = false;
                        objCommonDAL = new CommonDAL();
                        objCommonDAL.UpdateListAuditHistory(siteUrl,auditListName, Int32.Parse(objListItem["ID"].ToString()), userName, actionPerformed);
                    }
                }
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Updates the Narrative for Book Page.
        /// </summary>
        /// <param name="parentSiteUrl">Site URL.</param>
        /// <param name="listName">List Name.</param>
        /// <param name="auditListName"></param>
        /// <param name="camlQuery">CAML Query.</param>
        /// <param name="pageID">Page ID.</param>
        /// <param name="narrative">Narrative.</param>
        /// <param name="userName">User Name.</param>
        /// <exception cref="">Handled in calling method.</exception>
        internal void UpdateNarrative(string siteURL, string listName, string auditListName, string camlQuery, string pageID, string narrative, string userName)
        {
            SPList list;
            SPQuery query;
            SPListItemCollection objListItems;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        query = new SPQuery();
                        query.Query = camlQuery;
                        objListItems = list.GetItems(query);

                        if (objListItems.Count > 1)
                        {
                            foreach (SPListItem objListItem in objListItems)
                            {
                                objListItem["Narrative"] = narrative;
                                objListItem["Page_ID"] = Convert.ToInt32(pageID);
                                objListItem.Update();
                            }
                        }
                        else
                        {
                            SPListItem objListItem = list.Items.Add();
                            objListItem["Narrative"] = narrative;
                            objListItem["Page_ID"] = Convert.ToInt32(pageID);
                            objListItem.Update();
                        }

                        objCommonDAL = new CommonDAL();
                        objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, Convert.ToInt32(pageID), userName, "9");
                        web.AllowUnsafeUpdates = false;
                    }
                }
            });
        }
Esempio n. 9
0
        /// Updating the Discipline column is added.
        /// discipline parameter is added for the same.
        /// <summary>
        /// Updates the Page Owner details.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <exception cref="">Handled in calling method.</exception>
        internal void UpdatePageOwner(string siteURL, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed,string discipline)
        {
            SPList list;
            SPQuery query;
            SPListItem objListItem;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        query = new SPQuery();
                        for (int intIndex = 0; intIndex < listEntry.ChapterPagesMapping.Count; intIndex++)
                        {
                            objListItem = list.GetItemById(listEntry.ChapterPagesMapping[intIndex].RowId);
                            objListItem["Owner"] = userName;
                            #region DREAM 4.0 - eWB 2.0 - Change discipline when page owner changed
                            objListItem["Discipline"] = discipline;
                            #endregion
                            objListItem.Update();
                        }
                        web.AllowUnsafeUpdates = false;
                        objCommonDAL = new CommonDAL();
                        for (int intIndex = 0; intIndex < listEntry.ChapterPagesMapping.Count; intIndex++)
                        {
                            /// userName contains the value of new page owner selected.
                            /// Instead of new page owner, current login user name should be used for audit history.
                            /// Fix is applied.
                            userName = string.Empty;
                            CommonUtility objCommonUtility = new CommonUtility();
                            userName = objCommonUtility.GetUserName();
                            objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, listEntry.ChapterPagesMapping[intIndex].RowId, userName, actionPerformed);
                        }

                    }
                }
            });
        }
Esempio n. 10
0
        /// <summary>
        /// Updates the list entry.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <exception cref="">Handled in calling method.</exception>
        internal void UpdateListEntry(string siteURL, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed)
        {
            SPList list;
            SPQuery query;
            SPListItem objListItem;
            SPFieldLookupValue lookupField;
            int intRowId = 0;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        query = new SPQuery();
                        objListItem = list.Items.Add();
                        if (string.Compare(actionPerformed, AUDIT_ACTION_BOOK_TITLE_UPDATED, true) == 0 || string.Compare(actionPerformed, AUDIT_ACTION_UPDATION, true) == 0)
                        {
                            objListItem = list.GetItemById(listEntry.WellBookDetails.RowId);
                        }
                        objListItem["Title"] = listEntry.WellBookDetails.Title;
                        if (!string.IsNullOrEmpty(listEntry.WellBookDetails.TeamID))
                        {
                            lookupField = new SPFieldLookupValue(listEntry.WellBookDetails.
                                TeamID);
                            objListItem["Team"] = lookupField;
                            int.TryParse(listEntry.WellBookDetails.TeamID, out intRowId);
                            objListItem["Team_ID"] = intRowId;
                        }

                        if (!string.IsNullOrEmpty(listEntry.WellBookDetails.BookOwnerID))
                        {
                            lookupField = new SPFieldLookupValue(listEntry.WellBookDetails.BookOwnerID);
                            objListItem["Owner"] = lookupField;
                        }

                        objListItem.Update();
                        listEntry.WellBookDetails.RowId = int.Parse(objListItem["ID"].ToString());

                        web.AllowUnsafeUpdates = false;
                        objCommonDAL = new CommonDAL();
                        CommonUtility objCommonUtility = new CommonUtility();
                        userName = objCommonUtility.GetUserName();
                        objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, listEntry.WellBookDetails.RowId, userName, actionPerformed);

                    }
                }
            });
        }
Esempio n. 11
0
        /// <summary>
        /// Updates the Pages details in a Well Book.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <exception cref="">Handled in calling method.</exception>
        internal void UpdateBookPage(string siteURL, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed)
        {
            SPList list;
            SPListItem objListItem;
            DataTable dtlistItem = null;
            int intId = 0;
            int intRowId = 0;
            int intPageSequence = 0;
            DataView dvResultView;
            SPQuery query = null;
            string strCAMLQuery = string.Empty;
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(siteURL))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            web.AllowUnsafeUpdates = true;
                            list = web.Lists[listName];
                            objListItem = list.Items.Add();
                            if (string.Equals(actionPerformed, AUDIT_ACTION_UPDATION))
                            {
                                objListItem = list.GetItemById(listEntry.MasterPage.RowId);
                            }
                            objListItem["Page_Name"] = listEntry.MasterPage.Name;
                            objListItem["Page_Actual_Name"] = listEntry.MasterPage.TemplateTitle;
                            objListItem["Page_Sequence"] = listEntry.MasterPage.PageSequence;
                            objListItem["Standard_Operating_Procedure"] = listEntry.MasterPage.SOP;
                            objListItem["Discipline"] = listEntry.MasterPage.SignOffDiscipline;
                            objListItem.Update();
                            int.TryParse((objListItem["ID"].ToString()), out intId);
                            listEntry.MasterPage.RowId = intId;
                            /// start
                            query = new SPQuery();
                            query.Query = @"<Where><And><Eq><FieldRef Name='Terminate_Status' />
              <Value Type='Choice'>No</Value></Eq><Eq><FieldRef Name='Chapter_ID' />
              <Value Type='Number'>" + Convert.ToString(objListItem["Chapter_ID"]) + "</Value></Eq></And></Where>";
                            dtlistItem = list.GetItems(query).GetDataTable();
                            if (dtlistItem != null && dtlistItem.Rows.Count > 0)
                            {
                                dvResultView = dtlistItem.DefaultView;
                                dvResultView.Sort = "Page_Sequence asc";
                                for (int intIndex = 0; intIndex < dvResultView.Count; intIndex++)
                                {
                                    intPageSequence = intPageSequence + 10;
                                    intRowId = (int)dvResultView[intIndex]["ID"];
                                    objListItem = list.GetItemById(intRowId);
                                    objListItem["Page_Sequence"] = intPageSequence;

                                    objListItem.Update();
                                }
                            }
                            /// end
                            web.AllowUnsafeUpdates = false;
                            objCommonDAL = new CommonDAL();
                            objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, listEntry.MasterPage.RowId, userName, actionPerformed);
                            /// Update the values to StoryBoard list
                            WellBookChapterDAL objWellBookChapterDAL = new WellBookChapterDAL();
                            StoryBoard objStoryBoard = new StoryBoard();
                            objListItem = list.GetItemById(listEntry.MasterPage.RowId);

                            if (objListItem != null)
                            {
                                objStoryBoard.PageId = Int32.Parse(Convert.ToString(objListItem["ID"]));
                                objStoryBoard.SOP = Convert.ToString(objListItem["Standard_Operating_Procedure"]);
                                objStoryBoard.PageTitle = Convert.ToString(objListItem["Page_Actual_Name"]);
                                objStoryBoard.Discipline = Convert.ToString(objListItem["Discipline"]);

                                strCAMLQuery = string.Empty;
                                strCAMLQuery = @"<Where><Eq><FieldRef Name='Page_ID' /><Value Type='Number'>" + objStoryBoard.PageId.ToString() + "</Value></Eq></Where>";
                                objWellBookChapterDAL.UpdateStoryBoard(siteURL, DWBSTORYBOARD, CHAPTERPAGESMAPPINGAUDITLIST, strCAMLQuery, objStoryBoard.PageId.ToString(), objStoryBoard, actionPerformed, userName);
                            }
                        }
                    }
                });
            }
            finally
            {
                if (dtlistItem != null) dtlistItem.Dispose();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Updates the Mapping between master page and template in DWB Template Pages Mapping list
        /// </summary>
        /// <param name="siteURL">URL of the Site where list available.</param>
        /// <param name="listEntry">ListEntry object.</param>
        /// <param name="listName">Template List Name.(DWB Template Pages Mapping)</param>
        /// <param name="auditListName">Template Audit List Name.(DWB Template Pages Mapping Audit Trial)</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <param name="selectedTemplateID">TemplateID.</param>
        /// <exception cref="">Handled in calling class.</exception>
        internal void UpdateTemplatePageMapping(string siteUrl, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed, string selectedTemplateID)
        {
            /// Query the Template Mapping List for the selected Template ID
            /// If no records exist then insert all the new records
            /// If records for the particular Template exists, update the existing records and insert if any new pages are added
            int intNoOfMasterPages = 0;
            DataTable dtListItemCollection = null;
            DataTable dtresult = null;
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(siteUrl))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            web.AllowUnsafeUpdates = true;
                            SPList list = web.Lists[listName];

                            /// Insert the pages entry for the new template
                            if (string.Compare(actionPerformed, AUDIT_ACTION_CREATION, true) == 0)
                            {
                                if (listEntry != null && listEntry.TemplateConfiguration != null)
                                {
                                    foreach (TemplateConfiguration objTemplateConfiguration in listEntry.TemplateConfiguration)
                                    {
                                        SPListItem objListItem = list.Items.Add();
                                        objListItem["Page_Title_Template"] = objTemplateConfiguration.TemplateTitle;
                                        objListItem["Page_Sequence"] = objTemplateConfiguration.PageSequence;
                                        objListItem["Title"] = objTemplateConfiguration.MasterPageTitle;
                                        objListItem["Master_Page_ID"] = objTemplateConfiguration.LinkedMasterPageId;
                                        objListItem["Master_Page_Name"] = objTemplateConfiguration.MasterPageTitle;
                                        objListItem["Asset_Type"] = objTemplateConfiguration.AssetType;
                                        objListItem["Discipline"] = objTemplateConfiguration.Discipline;
                                        objListItem["Connection_Type"] = objTemplateConfiguration.ConnectionType;
                                        objListItem["Page_Owner"] = objTemplateConfiguration.PageOwner;
                                        if (!string.IsNullOrEmpty(objTemplateConfiguration.PageURL))
                                        {
                                            objListItem["Page_URL"] = objTemplateConfiguration.PageURL;
                                        }
                                        objListItem["Standard_Operating_Procedure"] = objTemplateConfiguration.StandardOperatingProcedure;
                                        objListItem["Template_ID"] = objTemplateConfiguration.TemplateID;

                                        objListItem.Update();
                                        intNoOfMasterPages++;
                                        objCommonDAL = new CommonDAL();
                                        objCommonDAL.UpdateListAuditHistory(siteUrl, auditListName, Convert.ToInt32(objListItem["ID"]),
                                            userName, actionPerformed);
                                    }
                                    /// Update the Has_MasterPage column in DWB Templates list if no of master pages in a template >=1
                                    UpdateHasMasterPageColumn(siteUrl, TEMPLATELIST, selectedTemplateID, intNoOfMasterPages);
                                }
                            }
                            else if (string.Compare(actionPerformed, AUDIT_ACTION_UPDATION, true) == 0)/// UPdate the pages details for the template
                            {
                                SPQuery query = new SPQuery();
                                query.Query = @"<OrderBy><FieldRef Name='Master_Page_ID'/></OrderBy><Where><Eq><FieldRef Name='Template_ID' /><Value Type='Number'>" +
                                 selectedTemplateID + "</Value></Eq></Where>";
                                SPListItemCollection objListItemCollection = list.GetItems(query);

                                List<string> itemTobeAddedOrDeleted = new List<string>();
                                List<string> itemToAdded = new List<string>();
                                bool blnMasterPageFound = false;

                                /// If the entry in List Box is not in SPListItemCollection, add it
                                /// If the entry in List Box is in SPListItemCollection, update it
                                /// If the entry is not in ListBox but present in SPListItemCollection delete it
                                if (objListItemCollection != null)
                                {
                                    string strMasterPageID = string.Empty;
                                    foreach (SPListItem item in objListItemCollection)
                                    {
                                        blnMasterPageFound = false;
                                        strMasterPageID = string.Empty;
                                        strMasterPageID = item["ID"].ToString();

                                        if (listEntry != null)
                                        {
                                            if (listEntry.TemplateConfiguration != null && listEntry.TemplateConfiguration.Count > 0)
                                            {
                                                foreach (TemplateConfiguration objTemplateConfiguration in listEntry.TemplateConfiguration)
                                                {
                                                    if (string.Compare(strMasterPageID, objTemplateConfiguration.LinkedMasterPageId) == 0)
                                                    {
                                                        blnMasterPageFound = true;
                                                        break;
                                                    }

                                                }

                                            }

                                            if (!blnMasterPageFound && !itemTobeAddedOrDeleted.Contains(item["ID"].ToString()))
                                            {
                                                itemTobeAddedOrDeleted.Add(item["ID"].ToString());
                                            }
                                        }
                                    }
                                }
                                for (int index = 0; index < itemTobeAddedOrDeleted.Count; index++)
                                {
                                    list.Items.DeleteItemById(Int32.Parse(itemTobeAddedOrDeleted[index]));
                                }
                                objListItemCollection = list.GetItems(query);
                                if (objListItemCollection != null)
                                {
                                    dtListItemCollection = objListItemCollection.GetDataTable();
                                }
                                if (listEntry != null && listEntry.TemplateConfiguration != null)
                                {

                                    SPListItem objListItem = null;
                                    string[] splitter = { "New" };
                                    string strRowID = string.Empty;
                                    string strMasterPageID = string.Empty;
                                    string[] strSplitted = null;
                                    DataRow[] dtRow = null;
                                    string strCAMLQuery = string.Empty;
                                    string strfieldsToView = string.Empty;
                                    foreach (TemplateConfiguration objTemplateConfiguration in listEntry.TemplateConfiguration)
                                    {

                                        objListItem = list.Items.Add();
                                         strRowID = string.Empty;
                                         strMasterPageID = string.Empty;
                                        /// Check the LinkedMasterPageId contains "New" string
                                        /// If contains split the string and assign the value at index 1
                                        /// Else the assign the LinkedMasterPageId value to

                                        if (objTemplateConfiguration.LinkedMasterPageId.IndexOf("New") != -1)
                                        {
                                            strSplitted = null;
                                            strSplitted = objTemplateConfiguration.LinkedMasterPageId.Split(splitter, StringSplitOptions.None);
                                            if (strSplitted != null && strSplitted.Length >= 2)
                                            {
                                                strMasterPageID = strSplitted[1];
                                            }
                                        }
                                        else
                                        {
                                            strRowID = objTemplateConfiguration.LinkedMasterPageId;
                                            strMasterPageID = objTemplateConfiguration.LinkedMasterPageId;
                                        }
                                        dtRow = null;
                                        if (dtListItemCollection != null && !string.IsNullOrEmpty(strRowID))
                                        {
                                            dtRow = dtListItemCollection.Select("ID = " + strRowID);
                                        }
                                        if (dtRow != null && dtRow.Length > 0)
                                        {
                                            objListItem = list.Items.GetItemById(Convert.ToInt32(dtRow[0]["ID"]));
                                            objListItem.Update();
                                            intNoOfMasterPages++;

                                            objCommonDAL = new CommonDAL();
                                            objCommonDAL.UpdateListAuditHistory(siteUrl, auditListName, Convert.ToInt32(objListItem["ID"]),
                                                userName, actionPerformed);
                                        }
                                        else
                                        {
                                            strCAMLQuery = string.Empty;
                                            strCAMLQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + strMasterPageID + "</Value></Eq></Where>";
                                            strfieldsToView = string.Empty;
                                            /// Title column is renamed to MasterPageName - internal name remains as Title
                                            strfieldsToView = "<FieldRef Name='Title' /><FieldRef Name='Title_Template' /><FieldRef Name='Page_Owner' /><FieldRef Name='Sign_Off_Discipline' /><FieldRef Name='Connection_Type' /><FieldRef Name='ID' /><FieldRef Name='Page_Sequence' /><FieldRef Name='Asset_Type' /><FieldRef Name='Page_URL' /><FieldRef Name='Standard_Operating_Procedure' /><FieldRef Name='Page_Sequence' /><FieldRef Name='Page_Sequence' />";
                                            objCommonDAL = new CommonDAL();
                                            dtresult = objCommonDAL.ReadList(siteUrl, MASTERPAGELIST, strCAMLQuery, strfieldsToView);

                                            if (dtresult != null && dtresult.Rows.Count > 0)
                                            {
                                                foreach (DataRow objdataRow in dtresult.Rows)
                                                {
                                                    objListItem["Page_Title_Template"] = objdataRow["Title_Template"].ToString();
                                                    objListItem["Page_Sequence"] = Int32.Parse(objdataRow["Page_Sequence"].ToString());
                                                    objListItem["Title"] = objdataRow["Title_Template"].ToString();
                                                    objListItem["Master_Page_ID"] = Int32.Parse(objdataRow["ID"].ToString());
                                                    objListItem["Master_Page_Name"] = objdataRow["Title"].ToString();
                                                    objListItem["Asset_Type"] = objdataRow["Asset_Type"].ToString();
                                                    objListItem["Discipline"] = objdataRow["Sign_Off_Discipline"].ToString();
                                                    objListItem["Connection_Type"] = objdataRow["Connection_Type"].ToString();
                                                    objListItem["Page_Owner"] = objdataRow["Page_Owner"].ToString();
                                                    if (!string.IsNullOrEmpty(objdataRow["Page_URL"].ToString()))
                                                    {
                                                        objListItem["Page_URL"] = objdataRow["Page_URL"].ToString();
                                                    }
                                                    objListItem["Standard_Operating_Procedure"] = objdataRow["Standard_Operating_Procedure"].ToString();
                                                    objListItem["Template_ID"] = selectedTemplateID;

                                                    objListItem.Update();
                                                    intNoOfMasterPages++;
                                                    objCommonDAL = new CommonDAL();
                                                    objCommonDAL.UpdateListAuditHistory(siteUrl, auditListName, Convert.ToInt32(objListItem["ID"]),
                                                        userName, actionPerformed);
                                                }
                                            }
                                        }
                                    }
                                    UpdateHasMasterPageColumn(siteUrl, TEMPLATELIST, selectedTemplateID, intNoOfMasterPages);
                                }
                            }
                            web.AllowUnsafeUpdates = false;
                        }
                    }
                });
            }
            finally
            {
                if (dtListItemCollection != null)
                    dtListItemCollection.Dispose();
                if (dtresult != null)
                    dtresult.Dispose();
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Updates the Templates column in DWB Master Page list
        /// </summary>
        /// <param name="siteUrl">Site URL.</param>
        /// <param name="listEntry">ListEntry object.</param>
        /// <param name="listName">List Name(DWB Master Page).</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <exception cref="">Handled in calling class.</exception>
        internal void UpdateTemplateIDinMasterPageList(string siteUrl, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed)
        {
            DataTable dtAddMasterPages = null;
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(siteUrl))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            web.AllowUnsafeUpdates = true;
                            SPList list = web.Lists[listName];
                            SPQuery query = new SPQuery();
                            string strTemplate_IDs = string.Empty;
                            string strTempIDs = string.Empty;
                            string strTemplateIDAdded = string.Empty;
                            if (listEntry != null)
                            {
                                /// Filter ListItems by AssetType and Terminated Status
                                query.Query = @"<Where><And><Eq><FieldRef Name='Asset_Type' /><Value Type='LookUp'>" + listEntry.TemplateDetails.AssetType + "</Value></Eq><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq></And></Where>";
                                string strSelectedTemplateID = listEntry.TemplateDetails.RowId.ToString();

                                SPListItemCollection objListItemCollection = list.GetItems(query);

                                /// LinkedMasterPageId property holds the item ID of the Template Page Mapping list or ID of the Master Page in Master Pages List prefixed with "New";
                                /// Get the MasterPages collection from DWB Template Master Page List for the selected TemplateID
                                /// Loop through each object in the collection and find the Master Page ID [objListItem["ID"].ToString()] is equal to
                                /// LinkedMasterPageID [dtRow["Master_Page_ID"].
                                /// If Equals, the master page is mapped to template, check the Template_ID column contains the selected TemplateID or not
                                /// If doesn't contains, append else do nothing
                                /// If not Equals, the master page is not mapped to the selected template, remove the TemplateID from the Template_ID column

                                SPList mappingList = web.Lists[TEMPLATEPAGESMAPPINGLIST];
                                SPQuery mappingQuery = new SPQuery();
                                mappingQuery.Query = @"<OrderBy><FieldRef Name='Page_Sequence' /></OrderBy><Where><Eq><FieldRef Name='Template_ID' /><Value Type='Number'>" + strSelectedTemplateID + "</Value></Eq></Where>";
                                mappingQuery.ViewFields = @"<FieldRef Name='Page_Sequence' /><FieldRef Name='ID' /><FieldRef Name='Master_Page_Name' /><FieldRef Name='Master_Page_ID' />";
                                SPListItemCollection objAddedMasterPages = mappingList.GetItems(mappingQuery);

                                if (objAddedMasterPages != null)
                                {
                                    dtAddMasterPages = objAddedMasterPages.GetDataTable();
                                }
                                DataRow[] dtRow = null;
                                int index = -1;
                                foreach (SPListItem objListItem in objListItemCollection)
                                {
                                    strTemplate_IDs = string.Empty;
                                    strTempIDs = string.Empty;
                                    if (objListItem["Template_ID"] != null)
                                    {
                                        strTemplate_IDs = objListItem["Template_ID"].ToString();
                                    }
                                    dtRow = null;
                                    if (dtAddMasterPages != null)
                                    {
                                        dtRow = dtAddMasterPages.Select("Master_Page_ID = " + objListItem["ID"].ToString());
                                    }
                                    if (dtRow != null && dtRow.Length > 0)
                                    {
                                        /// The Master Pages exist in Mapping List for the selected Template
                                        /// Check whether the TemplateID present in Template_ID column or not
                                        /// If not exist, append else do nothing
                                        strTempIDs = ";" + strTemplate_IDs;
                                        index = strTempIDs.IndexOf(";" + strSelectedTemplateID + ";");
                                        if (index == -1)
                                        {
                                            strTemplate_IDs = strTemplate_IDs + strSelectedTemplateID + ";";
                                        }
                                    }
                                    else
                                    {
                                        /// The Master Page is not mapped to selected Template in Mapping List
                                        /// Check whether the TemplateID present in Template_ID column or not
                                        /// If exists remove and update the item else do nothing
                                        strTempIDs = ";" + strTemplate_IDs;
                                        index = strTempIDs.IndexOf(";" + strSelectedTemplateID + ";");
                                        if (index != -1)
                                        {
                                            strTemplate_IDs = strTemplate_IDs.Remove(index, strSelectedTemplateID.Length + 1);
                                        }
                                    }

                                    objListItem["Template_ID"] = strTemplate_IDs;
                                    objListItem.Update();
                                    objCommonDAL = new CommonDAL();
                                    objCommonDAL.UpdateListAuditHistory(siteUrl, auditListName, Convert.ToInt32(objListItem["ID"]),
                                        userName, actionPerformed);
                                }

                                web.AllowUnsafeUpdates = false;
                            }
                        }// Ends using SPWeb
                    }// Ends using SPSite
                }); // Ends using RunWithElevatedPrivileges
            }
            finally
            {
                if (dtAddMasterPages != null)
                    dtAddMasterPages.Dispose();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Updates the details of the Master Page whiled edited
        /// Called from MasterPage.ascx
        /// </summary>
        /// <param name="siteUrl">Site URL.</param>
        /// <param name="listName">List Name.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="objListEntry">List Entry object.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <param name="userName">User Name.</param>
        /// <returns>returns the TemplateID associated with the master page.</returns>
        /// <exception cref="">Handled in calling method.</exception>
        internal int UpdateMasterPageDetail(string siteUrl, string listName, string auditListName, ListEntry objListEntry, string actionPerformed, string userName)
        {
            int intTemplateID = 0;

            SPSecurity.RunWithElevatedPrivileges(delegate()
               {
                   using (SPSite site = new SPSite(siteUrl))
                   {
                       using (SPWeb web = site.OpenWeb())
                       {
                           web.AllowUnsafeUpdates = true;
                           SPList list = web.Lists[listName];

                           if (objListEntry != null && objListEntry.MasterPage != null)
                           {
                               SPListItem listItem = list.GetItemById(objListEntry.MasterPage.RowId);
                               if (listItem != null)
                               {
                                   listItem["Discipline"] = objListEntry.MasterPage.SignOffDiscipline;//Discipline
                                   listItem["Standard_Operating_Procedure"] = objListEntry.MasterPage.SOP;//Standard_Operating_Procedure
                                   listItem["Page_Title_Template"] = objListEntry.MasterPage.TemplateTitle;//Page_Title_Template
                                   listItem["Master_Page_Name"] = objListEntry.MasterPage.Name;//Master_Page_Name
                                   listItem.Update();
                                   intTemplateID = Convert.ToInt32(listItem["Template_ID"]);
                               }

                               web.AllowUnsafeUpdates = false;
                               objCommonDAL = new CommonDAL();
                               objCommonDAL.UpdateListAuditHistory(siteUrl, auditListName, objListEntry.MasterPage.RowId,
                                   userName, actionPerformed);
                           }
                       }
                   }
               });
            return intTemplateID;
        }
Esempio n. 15
0
        /// <summary>
        /// Updates the list entry.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <returns>ID of the Chapter Created/Updated.</returns>
        /// <exception cref="">Handled in calling method.</exception>
        internal string UpdateListEntry(string siteURL, ListEntry listEntry, string listName, string auditListName, string userName, string actionPerformed)
        {
            SPList list;
            SPQuery query;
            SPListItem objListItem;
            SPListItemCollection objListItemCollection;
            SPFieldLookupValue lookupField;
            int intPageSequence = 10;
            int intListItemId = 0;
            string strListGuid = string.Empty;
            StringBuilder sbMethodBuilder = new StringBuilder();

            string strChapterID = string.Empty;
            string strBatch = string.Empty;
            string strBatchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
              "<ows:Batch OnError=\"Return\">{0}</ows:Batch>";

            string strMethodFormat = "<Method ID=\"{0}\">" +
             "<SetList>{1}</SetList>" +
             "<SetVar Name=\"Cmd\">Save</SetVar>" +
             "<SetVar Name=\"ID\">{2}</SetVar>" +
             "<SetVar Name=\"urn:schemas-microsoft-com:office:office#Chapter_Sequence\">{3}</SetVar>" +
            "</Method>";

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];

                        query = new SPQuery();
                        strListGuid = list.ID.ToString();
                        objListItem = list.Items.Add();
                        if (string.Equals(actionPerformed, AUDIT_ACTION_UPDATION))
                        {
                            objListItem = list.GetItemById(listEntry.ChapterDetails.RowID);
                        }
                        objListItem["Title"] = listEntry.ChapterDetails.ChapterTitle;
                        objListItem["Asset_Value"] = listEntry.ChapterDetails.AssetValue;
                        objListItem["Actual_Asset_Value"] = listEntry.ChapterDetails.ActualAssetValue;
                        objListItem["Country"] = listEntry.ChapterDetails.Country;
                        objListItem["Criteria"] = listEntry.ChapterDetails.Criteria;
                        objListItem["Column_Name"] = listEntry.ChapterDetails.ColumnName;
                        objListItem["Book_ID"] = listEntry.ChapterDetails.BookID;
                        if (!string.IsNullOrEmpty(listEntry.ChapterDetails.AssetType))
                        {
                            lookupField = new SPFieldLookupValue(Convert.ToInt32(listEntry.ChapterDetails.AssetType), "");
                            objListItem["Asset_Type"] = lookupField;
                        }

                        objListItem["Chapter_Description"] = listEntry.ChapterDetails.ChapterDescription;
                        objListItem["Template_ID"] = listEntry.ChapterDetails.TemplateID;

                        if (!string.IsNullOrEmpty(listEntry.ChapterDetails.Terminated))
                        {
                            objListItem["Terminate_Status"] = listEntry.ChapterDetails.Terminated;
                        }

                        objListItem.Update();
                        strChapterID = objListItem["ID"].ToString();
                        listEntry.ChapterDetails.RowID = int.Parse(objListItem["ID"].ToString());
                        string strNoOfActiveChapters = string.Empty;
                        if (string.Equals(actionPerformed, AUDIT_ACTION_CREATION))
                        {
                            query.Query = @"<OrderBy><FieldRef Name='Chapter_Sequence' /></OrderBy><Where><And><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq><Eq><FieldRef Name='Book_ID' /><Value Type='Number'>" + listEntry.ChapterDetails.BookID.ToString() + "</Value></Eq></And></Where>";
                            objListItemCollection = list.GetItems(query);

                            if (objListItemCollection != null && objListItemCollection.Count > 0)
                            {
                                strNoOfActiveChapters = objListItemCollection.Count.ToString();

                                for (int intIndex = 0; intIndex < objListItemCollection.Count; intIndex++)
                                {
                                    int.TryParse(Convert.ToString(objListItemCollection[intIndex]["ID"]), out intListItemId);
                                    if (intListItemId != listEntry.ChapterDetails.RowID)
                                    {
                                        intPageSequence = intPageSequence + 10;
                                        sbMethodBuilder.AppendFormat(strMethodFormat, intListItemId, strListGuid, intListItemId, intPageSequence);
                                    }
                                    else
                                    {
                                        sbMethodBuilder.AppendFormat(strMethodFormat, intListItemId, strListGuid, intListItemId, 10);

                                    }
                                }
                                strBatch = string.Format(strBatchFormat, sbMethodBuilder.ToString());
                                web.ProcessBatchData(strBatch);
                            }
                            objCommonDAL = new CommonDAL();
                            /// Update the DWB Books list with no of active chapters
                            objCommonDAL.UpdateNoOfActiveChapters(siteURL, DWBBOOKLIST, listEntry.ChapterDetails.BookID.ToString(), strNoOfActiveChapters.ToString());
                        }

                        web.AllowUnsafeUpdates = false;
                        objCommonDAL = new CommonDAL();

                        objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, listEntry.ChapterDetails.RowID, userName, actionPerformed);

                    }
                }
            });
            return strChapterID;
        }
Esempio n. 16
0
        /// <summary>
        /// Updates the list entry.
        /// </summary>
        /// <param name="siteURL">The site URL.</param>
        /// <param name="listEntry">The list entry.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <returns>ID of the Chapter Page Created.</returns>
        /// <exception cref="">Handled in calling method.</exception>
        internal string AddChapterMasterPageMapping(string siteURL, ListEntry listEntry, string listName, string auditListtname, string username, string actionPerformed)
        {
            SPList list;
            SPListItem objListItem;
            int intRowId = 0;
            StringBuilder strTemplatePageMappingRowId = new StringBuilder();
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        objCommonDAL = new CommonDAL();

                        string strCAMLQuery = string.Empty;
                        string strViewFields = string.Empty;
                        string strBookTeamID = string.Empty;
                        string strPageOwner = string.Empty;
                        string strUserID = string.Empty;
                        DataTable dtTeamStaff = null;
                        DataTable dtBook = null;
                        DataTable dtUser = null;
                        if (listEntry != null)
                        {
                            /// Get the Team of the book
                            if (listEntry.ChapterDetails != null)
                            {
                                strCAMLQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + listEntry.ChapterDetails.BookID.ToString() + "</Value></Eq></Where>";
                                strViewFields =@"<FieldRef Name='ID' /><FieldRef Name='Team' /><FieldRef Name='Team_ID' />";
                                dtBook = objCommonDAL.ReadList(siteURL, DWBBOOKLIST, strCAMLQuery, strViewFields);
                                if (dtBook != null && dtBook.Rows.Count > 0)
                                {
                                    strBookTeamID = Convert.ToString(dtBook.Rows[0]["Team_ID"]);
                                }
                            }

                            for (int i = 0; i < listEntry.ChapterPagesMapping.Count; i++)
                            {
                                strPageOwner = string.Empty;
                                objListItem = list.Items.Add();
                                objListItem["Master_Page_ID"] = listEntry.ChapterPagesMapping[i].MasterPageID;
                                objListItem["Page_Actual_Name"] = listEntry.ChapterPagesMapping[i].PageActualName;
                                objListItem["Page_Name"] = listEntry.ChapterPagesMapping[i].PageName;

                                objListItem["Discipline"] = listEntry.ChapterPagesMapping[i].Discipline;
                                objListItem["Chapter_ID"] = listEntry.ChapterDetails.RowID;
                                objListItem["Asset_Type"] = listEntry.ChapterPagesMapping[i].AssetType;
                                if (!string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].Empty))
                                    objListItem["Empty"] = listEntry.ChapterPagesMapping[i].Empty;
                                objListItem["Page_Sequence"] = listEntry.ChapterPagesMapping[i].PageSequence;
                                if (!string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].SignOffStatus))
                                {
                                    objListItem["Sign_Off_Status"] = listEntry.ChapterPagesMapping[i].SignOffStatus;
                                }
                                objListItem["Standard_Operating_Procedure"] = listEntry.ChapterPagesMapping[i].StandardOperatingProc;
                                objListItem["Connection_Type"] = listEntry.ChapterPagesMapping[i].ConnectionType;
                                if (!string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].PageURL))
                                {
                                    objListItem["Page_URL"] = listEntry.ChapterPagesMapping[i].PageURL;
                                }
                                strCAMLQuery = string.Empty;
                                strViewFields = string.Empty;
                                /// Retrieve the User with Rank =1 for the selected Team(Book) and Discipline(MasterPage) , "DWB Team Staff" and  assign to "Owner" column
                                if (!string.IsNullOrEmpty(strBookTeamID) && !string.IsNullOrEmpty(listEntry.ChapterPagesMapping[i].Discipline))
                                {
                                    strCAMLQuery = @"<OrderBy><FieldRef Name='User_Rank' Ascending='TRUE' /></OrderBy><Where><And><And><Eq><FieldRef Name='Team_ID' /><Value Type='Number'>" + strBookTeamID + "</Value></Eq><Eq><FieldRef Name='Discipline' /><Value Type='Text'>" + listEntry.ChapterPagesMapping[i].Discipline + "</Value></Eq></And><Eq><FieldRef Name='User_Rank' /><Value Type='Number'>" + "1" + "</Value></Eq></And></Where>";
                                    strViewFields = @"<FieldRef Name='ID' /><FieldRef Name='Team_ID' /><FieldRef Name='Discipline' /><FieldRef Name='User_Rank' /><FieldRef Name='User_ID' /><FieldRef Name='Title' />";
                                    dtTeamStaff = objCommonDAL.ReadList(siteURL, DWBTEAMSTAFFLIST, strCAMLQuery, strViewFields);
                                }
                                if (dtTeamStaff != null && dtTeamStaff.Rows.Count > 0)
                                {
                                    strUserID = Convert.ToString(dtTeamStaff.Rows[0]["User_ID"]);
                                    strCAMLQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + strUserID + "</Value></Eq></Where>";
                                    strViewFields = @"<FieldRef Name='ID' /><FieldRef Name='Windows_User_ID' />";
                                    dtUser = objCommonDAL.ReadList(siteURL, DWBUSERLIST, strCAMLQuery, strViewFields);
                                    if (dtUser != null && dtUser.Rows.Count > 0)
                                    {
                                        strPageOwner = dtUser.Rows[0]["Windows_User_ID"].ToString();
                                    }
                                }
                                if (!string.IsNullOrEmpty(strPageOwner))
                                {
                                    objListItem["Owner"] = strPageOwner;
                                }
                                else /// If no user with Rank =1 or no user for the selected discipline available, assign the Master Page Owner to "Owner" column
                                {
                                    objListItem["Owner"] = listEntry.ChapterPagesMapping[i].PageOwner;
                                }
                                objListItem.Update();
                                int.TryParse(Convert.ToString(objListItem["ID"]), out intRowId);
                                listEntry.ChapterPagesMapping[i].RowId = intRowId;
                                objCommonDAL.UpdateListAuditHistory(siteURL, auditListtname, intRowId, username, actionPerformed);

                            }
                        }

                        web.AllowUnsafeUpdates = false;
                        if (dtBook != null)
                        {
                            dtBook.Dispose();
                        }
                        if (dtTeamStaff != null)
                        {
                            dtTeamStaff.Dispose();
                        }
                        if (dtUser != null)
                        {
                            dtUser.Dispose();
                        }
                    }
                }
            });

            return strTemplatePageMappingRowId.ToString();
        }
Esempio n. 17
0
 /// <summary>
 /// Updates the Audit Trail
 /// </summary>
 /// <param name="siteURL">The site URL.</param>
 /// <param name="pageId">The page id.</param>
 /// <param name="auditListName">Name of the audit list.</param>
 /// <param name="userName">Name of the user.</param>
 /// <param name="actionPerformed">The action performed.</param>
 public void UpdateAuditTrail(string siteURL, string pageId, string auditListName, string userName, string actionPerformed)
 {
     objCommonDAL = new CommonDAL();
     objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, Convert.ToInt32(pageId), userName, actionPerformed);
 }
Esempio n. 18
0
        /// <summary>
        /// Updates the Story board.
        /// </summary>
        /// <param name="parentSiteURL">The site URL.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="camlQuery">CAML Query.</param>
        /// <param name="pageID">Page ID.</param>
        /// <param name="pageStoryBoard">StoryBoard object.</param>
        /// <param name="actionPerformed">Audit action.</param>
        /// <param name="userName">User Name.</param>
        /// <exception cref="">Handled in calling method.</exception>
        internal void UpdateStoryBoard(string siteURL, string listName, string auditListName, string camlQuery, string pageID, StoryBoard pageStoryBoard, string actionPerformed, string userName)
        {
            SPList list;
            SPListItem objListItem;
            SPQuery spQuery = null;
            SPListItemCollection objListItemCollection = null;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        list = web.Lists[listName];
                        spQuery = new SPQuery();
                        spQuery.Query = camlQuery;

                        objListItemCollection = list.GetItems(spQuery);
                        if (objListItemCollection.Count > 0)
                        {
                            objListItem = objListItemCollection[0];
                        }
                        else
                        {
                            objListItem = list.Items.Add();
                        }
                        if (pageStoryBoard.PageId > 0)
                            objListItem["Page_ID"] = pageStoryBoard.PageId;
                        if (!string.IsNullOrEmpty(pageStoryBoard.PageTitle))
                            objListItem["Page_Title"] = pageStoryBoard.PageTitle;
                        if (!string.IsNullOrEmpty(pageStoryBoard.ConnectionType))
                            objListItem["Connection_Type"] = pageStoryBoard.ConnectionType;
                        if (!string.IsNullOrEmpty(pageStoryBoard.Source))
                            objListItem["Source"] = pageStoryBoard.Source;
                        if (!string.IsNullOrEmpty(pageStoryBoard.Discipline))
                            objListItem["Discipline"] = pageStoryBoard.Discipline;
                        if (!string.IsNullOrEmpty(pageStoryBoard.MasterPageName))
                            objListItem["Master_Page"] = pageStoryBoard.MasterPageName;
                        if (!string.IsNullOrEmpty(pageStoryBoard.ApplicationTemplate))
                            objListItem["Application_Template"] = pageStoryBoard.ApplicationTemplate;
                        if (!string.IsNullOrEmpty(pageStoryBoard.ApplicationPage))
                            objListItem["Application_Page"] = pageStoryBoard.ApplicationPage;
                        if (!string.IsNullOrEmpty(pageStoryBoard.SOP))
                            objListItem["SOP"] = pageStoryBoard.SOP;
                        if (!string.IsNullOrEmpty(pageStoryBoard.CreatedBy))
                            objListItem["Created_By"] = pageStoryBoard.CreatedBy;
                        if (!string.IsNullOrEmpty(pageStoryBoard.CreationDate))
                            objListItem["Creation_Date"] = Convert.ToDateTime(pageStoryBoard.CreationDate).ToString("yyyy-MM-ddTHH:mm:ssZ");
                        if (!string.IsNullOrEmpty(pageStoryBoard.PageOwner))
                            objListItem["Page_Owner"] = pageStoryBoard.PageOwner;
                        if (!string.IsNullOrEmpty(pageStoryBoard.PageType))
                            objListItem["Page_Type"] = pageStoryBoard.PageType;
                        objListItem.Update();
                        web.AllowUnsafeUpdates = false;
                        if (string.Compare(actionPerformed, AUDIT_ACTION_STORYBOARD_UPDATED, true) == 0)
                        {
                            objCommonDAL = new CommonDAL();
                            objCommonDAL.UpdateListAuditHistory(siteURL, auditListName, Convert.ToInt32(pageID), userName, actionPerformed);
                        }
                    }
                }
            });
        }
Esempio n. 19
0
        /// <summary>
        /// Method to update the Page Sequence for Master Pages in a Template
        /// </summary>
        /// <param name="siteURL">Site URL.</param>
        /// <param name="listName">List Name.</param>
        /// <param name="auditListName">Audit List Name.</param>
        /// <param name="actionPerformed">Audit Action.</param>
        /// <param name="userName">User Name.</param>
        /// <param name="dvUpdateListitems">DataView.</param>
        public void UpdatePageSequence(string siteURL, string listName, string auditListName, string actionPerformed, string userName, DataView dvUpdateListitems)
        {
            objCommonDAL = new CommonDAL();
            objCommonDAL.UpdateSequence(siteURL, listName, dvUpdateListitems, "Page_Sequence");

            if (dvUpdateListitems != null && dvUpdateListitems.Count > 0)
            {
                for (int i = 0; i < dvUpdateListitems.Count; i++)
                {
                    objCommonDAL.UpdateListAuditHistory(siteURL, auditListName,
                        int.Parse(dvUpdateListitems[i]["ID"].ToString()), userName, actionPerformed);
                }
            }
            dvUpdateListitems.Dispose();
        }