Пример #1
0
        /// <summary>
        /// Gets the camlQuery based on the report type
        /// </summary>
        /// <returns></returns>
        private string GetsCAMLQuery()
        {
            string strTerminated = string.Empty;
            string strCamlQuery = string.Empty;
            string strMasterID = string.Empty;
            if (!ActiveStatus)
                strTerminated = STATUS_TERMINATED;
            else
                strTerminated = STATUS_ACTIVE;
            switch (ListReportName)
            {
                case "Audit Trail":
                    {
                        strMasterID = HttpContext.Current.Request.QueryString["auditID"];
                        strCamlQuery = @"<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy><Where><Eq><FieldRef Name='Master_ID' /><Value Type='Number'>" + strMasterID + "</Value></Eq></Where>";
                        break;
                    }
                case MASTERPAGEREPORT:
                    {
                        strCamlQuery = @"<OrderBy><FieldRef Name='Page_Sequence' /></OrderBy><Where><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" +
                   strTerminated + "</Value></Eq></Where>";
                        break;
                    }
                case CHAPTERPAGEMAPPINGREPORT:
                    {
                        strCamlQuery = GetCAMLQueryForWellBookPages();
                        if (strCamlQuery.Length == 0)
                        {
                            strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>-9999</Value></Eq></Where>";
                        }
                        break;
                    }
                case WELLBOOKPAGEVIEW:
                    {
                        strCamlQuery = GetCAMLQueryForWellBookSummaryPages();
                        if (strCamlQuery.Length == 0)
                        {
                            strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>-9999</Value></Eq></Where>";
                        }
                        break;
                    }
                case CHAPTERREPORT:
                    {
                        strCamlQuery = GetCAMLQueryForWellBookChapters();
                        if (strCamlQuery.Length == 0)
                        {
                            #region DREAM 4.0 - eWB2.0 - Deletion Module
                            /// <Eq><FieldRef Name='ToBeDeleted' /><Value Type='Choice'>No</Value></Eq></And> is added.
                            /// And condition added to the CAML query
                            //strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>-9999</Value></Eq></Where>";
                            strCamlQuery = @"<Where><And><Eq><FieldRef Name='ID' /><Value Type='Counter'>-9999</Value></Eq>   <Or>
             <IsNull>
            <FieldRef Name='ToBeDeleted' />
             </IsNull><Eq>
            <FieldRef Name='ToBeDeleted' />
            <Value Type='Choice'>No</Value>
             </Eq>      </Or>
              </And></Where>";
                            #endregion
                        }
                        break;
                    }
                case CHAPTERPAGEREPORT:
                    {
                        strCamlQuery = @"<OrderBy><FieldRef Name='Page_Sequence' /></OrderBy><Where><And><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" +
                   strTerminated + "</Value></Eq><Eq><FieldRef Name='Chapter_ID'/><Value Type='Number'>" + HttpContext.Current.Request.QueryString["ChapterID"] + "</Value></Eq></And></Where>";
                        break;
                    }
                case TEMPLATEREPORT:
                    {
                        /// Title column in DWB Templates list is renamed to "Template_Name". the Internal name remains as "Title";
                        strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" + strTerminated + "</Value></Eq></Where>";
                        break;
                    }
                case TEMPLATEPAGESREPORT:
                    {
                        strCamlQuery = GetCAMLQueryForTemplatePages();
                        break;
                    }
                case USERREGISTRATION:
                    {
                        strCamlQuery = @"<OrderBy><FieldRef Name='DWBUserName' /></OrderBy><Where><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" + strTerminated + "</Value></Eq></Where>";
                        break;
                    }
                case TEAMREGISTRATION:
                    {
                        object objStoredPrivilege = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPrivileges.ToString());
                        if (objStoredPrivilege != null)
                        {
                            Privileges objPrivileges = (Privileges)objStoredPrivilege;
                            if (objPrivileges != null)
                            {

                                if (objPrivileges.SystemPrivileges != null)
                                {
                                    if (objPrivileges.SystemPrivileges.AdminPrivilege)
                                    {
                                        /// Get all the teams from "DWB Team"
                                        strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" + strTerminated + "</Value></Eq></Where>";
                                    }
                                    else if (objPrivileges.SystemPrivileges.BookOwner)
                                    {
                                        /// Get the teams where loggedin user is member
                                        objCommonBLL = new CommonBLL();
                                        strCamlQuery = objCommonBLL.GetCAMLQueryForBOUsers(strSiteURL, "ID", "Counter", strTerminated,false);
                                    }
                                }

                            }
                        }

                        break;
                    }
                case STAFFREGISTRATION:
                    {
                        strCamlQuery = @"<OrderBy><FieldRef Name='Discipline' /><FieldRef Name='User_Rank' /></OrderBy><Where><Eq><FieldRef Name='Team_ID' /><Value Type='Number'>" + HttpContext.Current.Request.QueryString[IDVALUEQUERYSTRING] + "</Value></Eq></Where>";
                        break;
                    }
                case WELLBOOKREPORT:
                    {
                        strCamlQuery = string.Empty;
                        object objStoredPrivilege = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPrivileges.ToString());
                        if (objStoredPrivilege != null)
                        {
                            Privileges objPrivileges = (Privileges)objStoredPrivilege;
                            if (objPrivileges != null && objPrivileges.SystemPrivileges != null)
                            {
                                if (objPrivileges.SystemPrivileges.AdminPrivilege)
                                {
                                    /// <Eq><FieldRef Name='ToBeDeleted' /><Value Type='Choice'>No</Value></Eq></And> is added.
                                    /// And condition added to the CAML query

               //                         strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" +
                                    //strTerminated + "</Value></Eq></Where>";
                                    #region DREAM 4.0 - eWB2.0 - Deletion Module
                                    strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><And><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" +
               strTerminated + "</Value></Eq><Or><IsNull><FieldRef Name='ToBeDeleted' /></IsNull><Eq><FieldRef Name='ToBeDeleted' /><Value Type='Choice'>No</Value></Eq></Or></And></Where>";
                                    #endregion
                                }
                                else if (objPrivileges.SystemPrivileges.BookOwner)
                                {
                                    /// Find the Team_IDs where user is member "DWB Team Staff" list
                                    /// and Get Only the Books where Team (DWB Books) == Team_Name(Title) in "DWB Team" list
                                    /// <TODO>
                                    /// Add the <Eq><FieldRef Name='ToBeDeleted' /><Value Type='Choice'>No</Value></Eq> at proper location
                                    /// </TODO>
                                    objCommonBLL = new CommonBLL();
                                    strCamlQuery = objCommonBLL.GetCAMLQueryForBOUsers(strSiteURL, "Team_ID", "Number", strTerminated,true);
                                }
                                else if (objPrivileges.SystemPrivileges.PageOwner || objPrivileges.SystemPrivileges.DWBUser)
                                {
                                    if (objPrivileges.FocalPoint != null && !string.IsNullOrEmpty(objPrivileges.FocalPoint.BookIDs))
                                    {
                                        objCommonUtility = new CommonUtility();
                                        /// Get only the Books where "Owner" = logged in user
                                        //strCamlQuery = @" <Where> <And><Eq><FieldRef Name='Owner' /><Value Type='Lookup'>" + objCommonUtility.GetUserName() + "</Value></Eq><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq></And></Where>";
                                        #region DREAM 4.0 - eWB2.0 - Deletion Module
                                        /// <Eq><FieldRef Name='ToBeDeleted' /><Value Type='Choice'>No</Value></Eq></And> is added.
                                        /// Another And condition added to the CAML query
                                        strCamlQuery = @" <Where><And> <Eq><FieldRef Name='Owner' /><Value Type='Lookup'>" + objCommonUtility.GetUserName() + "</Value></Eq><And><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq> <Or><IsNull><FieldRef Name='ToBeDeleted' /></IsNull><Eq><FieldRef Name='ToBeDeleted' /><Value Type='Choice'>No</Value></Eq></Or></And></And></Where>";
                                        #endregion
                                    }
                                }
                            }
                        }
                        break;
                    }
                case DWBHOME:
                    {
                        objCommonBLL = new CommonBLL();
                        strCamlQuery = @"<Where><Eq><FieldRef Name='Windows_User_ID' /><Value Type='Text'>" +
                         GetUserName() + "</Value></Eq></Where>";

                        DataTable dtListDetails = objCommonBLL.ReadList(strSiteURL, USERLIST, strCamlQuery);

                        string strFavoriteBooksIds = string.Empty;
                        if (dtListDetails.Rows.Count > 0)
                            strFavoriteBooksIds = Convert.ToString(dtListDetails.Rows[0]["FavoriteBooks"]);

                        ((HiddenField)FindControl("hdnUserFavorites")).Value = strFavoriteBooksIds;

                        RadioButtonList rdblFavorites = (RadioButtonList)FindControl("rdoFavourites");
                        if (rdblFavorites != null)
                        {
                            if (rdblFavorites.SelectedIndex == 0)
                            {
                                /// Get all the Books
                                /// strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><And><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq><Gt><FieldRef Name='NoOfActiveChapters' /><Value Type='Number'>0</Value></Gt></And></Where>";
                                #region DREAM 4.0 - eWB2.0 - Deletion Module
                                strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><And><And><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq>  <Or>
             <IsNull>
            <FieldRef Name='ToBeDeleted' />
             </IsNull>

            <Eq>
               <FieldRef Name='ToBeDeleted' />
               <Value Type='Choice'>No</Value>
            </Eq>
                </Or>
             </And><Gt><FieldRef Name='NoOfActiveChapters' /><Value Type='Number'>0</Value></Gt></And></Where>";
                                #endregion
                            }
                            else if (rdblFavorites.SelectedIndex == 1)
                            {
                                /// Get only Favourite Books
                                string[] strBookIds = strFavoriteBooksIds.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                                strCamlQuery = CreateCAMLQuery(strBookIds);
                            }
                        }
                        if (dtListDetails != null)
                        {
                            dtListDetails.Dispose();
                        }
                        break;
                    }
                default:
                    strCamlQuery = @"<OrderBy><FieldRef Name='Title' /></OrderBy><Where><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>" +
             strTerminated + "</Value></Eq></Where>";
                    break;

            }

            return strCamlQuery;
        }
Пример #2
0
 /// <summary>
 /// Gets the CAML query for BO users.
 /// </summary>
 /// <param name="strSiteURL">The STR site URL.</param>
 /// <param name="columName">Name of the colum.</param>
 /// <param name="columnType">Type of the column.</param>
 /// <param name="terminated">The terminated.</param>
 /// <returns></returns>
 protected string GetCAMLQueryForBOUsers(string strSiteURL, string columName, string columnType, string terminated, bool bookMaintenance)
 {
     objCommonBLL = new CommonBLL();
     return objCommonBLL.GetCAMLQueryForBOUsers(strSiteURL, columName, columnType, terminated, bookMaintenance);
 }