Esempio n. 1
0
 public User getCurrentUser(string userid)
 {
     return(BELDataAccessLayer.EnsureUser(this.context, this.web, userid));
 }
Esempio n. 2
0
        /// <summary>
        /// Gets the DCN details.
        /// </summary>
        /// <param name="objDict">The object dictionary.</param>
        /// <returns>byte array</returns>
        public List <DCRDetails> RetrieveAllDCRNos(IDictionary <string, string> objDict)
        {
            List <DCRDetails> dcrs = new List <DCRDetails>();
            List      spList       = this.web.Lists.GetByTitle(DCRDCNListNames.DCRLIST);
            CamlQuery query        = new CamlQuery();

            if (objDict != null && objDict.ContainsKey("UserEmail"))
            {
                User loggedinuser = BELDataAccessLayer.EnsureUser(context, web, objDict["UserEmail"].ToString());
                query.ViewXml = @"<View>
                                        <Query>
                                                  <Where>
                                                        <And>
                                                            <Eq>
                                                                    <FieldRef Name='FinalDesignEngineer' /><Value Type='User'>" + loggedinuser.Title + @"</Value>
                                                            </Eq>
                                                        <And>
                                                            <Eq>
                                                                    <FieldRef Name='Status' />
                                                                    <Value Type='Text'>" + FormStatus.COMPLETED + @"</Value>
                                                            </Eq>
                                                            <Eq>
                                                                    <FieldRef Name='IsDCNGenerated' />
                                                                    <Value Type='Boolean'>0</Value>
                                                            </Eq>
                                                    </And>
                                                   </And>
                                                 </Where>
                                        </Query>
                            </View>";
            }
            else
            {
                query.ViewXml = @"<View>
                                                        <Query>
                                                                  <Where>
                                                                    <And>
                                                                      <Eq>
                                                                            <FieldRef Name='Status' />
                                                                            <Value Type='Text'>" + FormStatus.COMPLETED + @"</Value>
                                                                       </Eq>
                                                                       <Eq>
                                                                             <FieldRef Name='IsDCNGenerated' />
                                                                             <Value Type='Boolean'>0</Value>
                                                                       </Eq>
                                                                    </And>
                                                                 </Where>
                                                        </Query>
                                            </View>";
            }
            //  query.ViewXml = @"<View><ViewFields><FieldRef Name='ID' /><FieldRef Name='DCRNo' /><FieldRef Name='ProductName' /><FieldRef Name='RequestDate' /><FieldRef Name='ProposedBy' /></ViewFields></View>";
            ListItemCollection items = spList.GetItems(query);

            this.context.Load(items);
            this.context.ExecuteQuery();
            if (items != null && items.Count != 0)
            {
                foreach (ListItem item in items)
                {
                    DCRDetails dcr = new DCRDetails();
                    dcr.DCRNo = Convert.ToString(item["DCRNo"]);
                    dcr.ID    = item.Id;
                    FieldUserValue user = item["ProposedBy"] as FieldUserValue;
                    dcr.ProposedBy  = BELDataAccessLayer.GetNameFromPersonField(context, web, user);
                    dcr.ProductName = Convert.ToString(item["ProductName"]);
                    dcr.RequestDate = Convert.ToDateTime(item["RequestDate"]);
                    dcrs.Add(dcr);
                }
            }
            return(dcrs);
        }