Пример #1
0
        public Web CreateSubSite(Microsoft.SharePoint.Client.ClientContext ctx, Web hostWeb, string txtUrl,
                                 string template, string title, string description)
        {
            // Create web creation configuration
            WebCreationInformation information = new WebCreationInformation();
            information.WebTemplate = template;
            information.Description = description;
            information.Title = title;
            information.Url = txtUrl;
            // Currently all english, could be extended to be configurable based on language pack usage
            information.Language = 1033;

            Microsoft.SharePoint.Client.Web newWeb = null;
            newWeb = hostWeb.Webs.Add(information);
            ctx.ExecuteQuery();

            ctx.Load(newWeb);
            ctx.ExecuteQuery();

            // Add sub site link override
            new LabHelper().AddJsLink(ctx, newWeb, this.Request);

            // Set oob theme to the just created site
            new LabHelper().SetThemeBasedOnName(ctx, newWeb, hostWeb, "Orange");

            // All done, let's return the newly created site
            return newWeb;
        }
        public bool Validate(FileCollection sourceFiles, Microsoft.SharePoint.Client.ClientContext ctx)
        {
            int scount = 0;
            int tcount = 0;

            foreach (var sf in sourceFiles)
            {
                scount++;
                string fileName = sf.Src;
                string folderName = sf.Folder;
                string fileUrl = UrlUtility.Combine(ctx.Web.ServerRelativeUrl, folderName + "/" + fileName);
                var file = ctx.Web.GetFileByServerRelativeUrl(UrlUtility.Combine(ctx.Web.ServerRelativeUrl, folderName + "/" + fileName));
                ctx.Load(file, f => f.Exists, f => f.Length);
                ctx.ExecuteQuery();

                if (file.Exists)
                {
                    tcount++;

                    #region File - Security
                    if (sf.Security != null)
                    {
                        ctx.Load(file, f => f.ListItemAllFields);
                        ctx.ExecuteQuery();
                        bool isSecurityMatch = ValidateSecurityCSOM(ctx, sf.Security, file.ListItemAllFields);
                        if (!isSecurityMatch)
                        {
                            return false;
                        }

                    }
                    #endregion

                    #region Overwrite validation
                    if (sf.Overwrite == false)
                    {
                        // lookup the original added file size...should be different from the one we retrieved from SharePoint since we opted to NOT overwrite
                        var files = System.IO.Directory.GetFiles(@".\framework\functional\templates");
                        foreach (var f in files)
                        {
                            if (f.Contains(sf.Src))
                            {
                                if (new System.IO.FileInfo(f).Length == file.Length)
                                {
                                    return false;
                                }
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    return false;
                }
            }

            return true;
        }
        public override void Provision(Microsoft.SharePoint.Client.ClientContext context, Microsoft.SharePoint.Client.Web web)
        {
            //get the web's property bag
            var props = web.AllProperties;
            context.Load(props);
            context.ExecuteQuery();

            //set the ContosoBusinessImpact property and update
            props["ContosoBusinessImpact"] = cboSensitivity.SelectedValue;
            web.Update();
            context.ExecuteQuery();

            //call the base
            base.Provision(context, web);
        }
Пример #4
0
        private void AddJsLink(Microsoft.SharePoint.Client.ClientContext ctx)
        {

            Web web = ctx.Web;
            ctx.Load(web, w => w.UserCustomActions);
            ctx.ExecuteQuery();

            ctx.Load(web, w => w.UserCustomActions, w => w.Url, w => w.AppInstanceId);
            ctx.ExecuteQuery();

            UserCustomAction userCustomAction = web.UserCustomActions.Add();
            userCustomAction.Location = "Microsoft.SharePoint.StandardMenu";
            userCustomAction.Group = "SiteActions";
            BasePermissions perms = new BasePermissions();
            perms.Set(PermissionKind.ManageWeb);
            userCustomAction.Rights = perms;
            userCustomAction.Sequence = 100;
            userCustomAction.Title = "Modify Site";

            string realm = TokenHelper.GetRealmFromTargetUrl(new Uri(ctx.Url));
            string issuerId = WebConfigurationManager.AppSettings.Get("ClientId");

            var modifyPageUrl = string.Format("https://{0}/Pages/Modify.aspx?{{StandardTokens}}", Request.Url.Authority);
            string url = "javascript:LaunchApp('{0}', 'i:0i.t|ms.sp.ext|{1}@{2}','{3}',{{width:300,height:200,title:'Modify Site'}});";
            url = string.Format(url, Guid.NewGuid().ToString(), issuerId, realm, modifyPageUrl);

            userCustomAction.Url = url;
            userCustomAction.Update();
            ctx.ExecuteQuery();

            // Remove the entry from the 'Recents' node
            NavigationNodeCollection nodes = web.Navigation.QuickLaunch;
            ctx.Load(nodes, n => n.IncludeWithDefaultProperties(c => c.Children));
            ctx.ExecuteQuery();
            var recent = nodes.Where(x => x.Title == "Recent").FirstOrDefault();
            if (recent != null)
            {
                var appLink = recent.Children.Where(x => x.Title == "Site Modifier").FirstOrDefault();
                if (appLink != null) appLink.DeleteObject();
                ctx.ExecuteQuery();
            }
        }
Пример #5
0
        private void AddSiteInformationJsLink(Microsoft.SharePoint.Client.ClientContext clientContext)
        {
            Web web = clientContext.Web;
            clientContext.Load(web, w => w.UserCustomActions, w => w.Url, w => w.AppInstanceId);
            clientContext.ExecuteQuery();

            string issuerId = ConfigurationManager.AppSettings.Get("ClientId");

            DeleteExistingActions(clientContext, web);

            UserCustomAction userCustomAction = web.UserCustomActions.Add();
            userCustomAction.Location = "Microsoft.SharePoint.StandardMenu";
            userCustomAction.Group = "SiteActions";
            BasePermissions perms = new BasePermissions();
            perms.Set(PermissionKind.ManageWeb);
            userCustomAction.Rights = perms;
            userCustomAction.Sequence = 100;
            userCustomAction.Title = "Site Information";
            userCustomAction.Name = "SiteInformationApp";

            string realm = TokenHelper.GetRealmFromTargetUrl(new Uri(clientContext.Url));

            string host = "";
            foreach (Uri u in OperationContext.Current.Host.BaseAddresses)
            {
                if (u.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase))
                {
                    host = u.Authority;
                }
            }

            var appPageUrl = string.Format("https://{0}/Pages/Default.aspx?{{StandardTokens}}", host);
            string url = "javascript:LaunchApp('{0}', 'i:0i.t|ms.sp.ext|{1}@{2}','{3}', {{width:600,height:400,title:'Site Information'}});";
            url = string.Format(url, Guid.NewGuid().ToString(), issuerId, realm, appPageUrl);

            userCustomAction.Url = url;
            userCustomAction.Update();
            clientContext.ExecuteQuery();
        }
Пример #6
0
        private void AddComposedLooks(Microsoft.SharePoint.Client.ClientContext context, ShWeb configWeb, Web web, ShComposedLook composedLook)
        {
            if (composedLook != null)
            {
                Log.Debug("Setting Composed Look for web " + configWeb.Name);
                var themeUrl = string.Empty;
                var fontSchemeUrl = string.Empty;

                List themeList = web.GetCatalog(124);
                web.Context.Load(themeList);
                web.Context.ExecuteQuery();

                // We are assuming that the theme exists
                CamlQuery query = new CamlQuery();
                string camlString = @"
                <View>
                    <Query>
                        <Where>
                            <Eq>
                                <FieldRef Name='Name' />
                                <Value Type='Text'>{0}</Value>
                            </Eq>
                        </Where>
                        </Query>
                </View>";
                camlString = string.Format(camlString, composedLook.Name);
                query.ViewXml = camlString;
                var found = themeList.GetItems(query);
                web.Context.Load(found);
                web.Context.ExecuteQuery();

                if (found.Count == 0)
                {
                    if (!web.IsObjectPropertyInstantiated("ServerRelativeUrl"))
                    {
                        context.Load(web);
                        context.ExecuteQuery();
                    }

                    ListItemCreationInformation itemInfo = new ListItemCreationInformation();
                    Microsoft.SharePoint.Client.ListItem item = themeList.AddItem(itemInfo);
                    item["Name"] = composedLook.Name;
                    item["Title"] = composedLook.Title;
                    if (!string.IsNullOrEmpty(composedLook.ThemeUrl))
                    {
                        themeUrl = Url.Combine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(composedLook.ThemeUrl)));
                        item["ThemeUrl"] = themeUrl;
                    }
                    if (!string.IsNullOrEmpty(composedLook.FontSchemeUrl))
                    {
                        fontSchemeUrl = Url.Combine(web.ServerRelativeUrl, string.Format("/_catalogs/theme/15/{0}", System.IO.Path.GetFileName(composedLook.FontSchemeUrl)));
                        item["FontSchemeUrl"] = fontSchemeUrl;
                    }
                    if (string.IsNullOrEmpty(composedLook.MasterPageUrl))
                    {
                        item["MasterPageUrl"] = Url.Combine(web.ServerRelativeUrl, "/_catalogs/masterpage/seattle.master");
                    }
                    else
                    {
                        item["MasterPageUrl"] = Url.Combine(web.ServerRelativeUrl, string.Format("/_catalogs/masterpage/{0}", Path.GetFileName(composedLook.MasterPageUrl)));
                    }
                    item["DisplayOrder"] = 11;
                    item.Update();
                    context.ExecuteQuery();
                }
                else
                {
                    Microsoft.SharePoint.Client.ListItem item = found[0];
                    themeUrl = MakeAsRelativeUrl((item["ThemeUrl"] as FieldUrlValue).Url);
                    fontSchemeUrl = MakeAsRelativeUrl((item["FontSchemeUrl"] as FieldUrlValue).Url);
                }

                web.ApplyTheme(themeUrl, fontSchemeUrl, null, false);
                context.ExecuteQuery();
            }
        }
Пример #7
0
        /// <summary>
        /// Queries a Windows Installer database to determine if one or more rows exist in the Property table.
        /// </summary>
        /// <param name="db">Database to query.</param>
        /// <param name="property">Property to examine.</param>
        /// <returns>True if query matches at least one result.</returns>
        private static bool HasProperty(Microsoft.Deployment.WindowsInstaller.Database db, string property)
        {
            try
            {
                return 0 < db.ExecuteQuery(PropertyQuery(property)).Count;
            }
            catch (Microsoft.Deployment.WindowsInstaller.InstallerException)
            {
            }

            return false;
        }
Пример #8
0
        public bool Validate(PageCollection sourcePages, Microsoft.SharePoint.Client.ClientContext ctx)
        {
            int scount = 0;
            int tcount = 0;

            Web web = ctx.Web;
            ctx.Load(web, w => w.Url, w => w.ServerRelativeUrl);
            ctx.ExecuteQuery();

            foreach (var sourcePage in sourcePages)
            {

                string pageUrl = sourcePage.Url.ToString();
                pageUrl = pageUrl.Replace("{site}", web.ServerRelativeUrl);

                Microsoft.SharePoint.Client.File file = web.GetFileByServerRelativeUrl(pageUrl);
                ctx.Load(file, page => page.ListItemAllFields, page => page.ListItemAllFields.RoleAssignments.Include(roleAsg => roleAsg.Member,
                  roleAsg => roleAsg.RoleDefinitionBindings.Include(roleDef => roleDef.Name)));
                ctx.ExecuteQuery();

                if (file != null)
                {
                    #region Page - Fields

                    if (sourcePage.Fields.Count > 0)
                    {
                        scount = 0;
                        tcount = 0;
                        string sourceWikifield = sourcePage.Fields["WikiField"].ToString();
                        string targetwikiField = (string)file.ListItemAllFields["WikiField"];

                        if (sourceWikifield.Trim() != RemoveHTMLTags(targetwikiField).Trim())
                        {
                            return false;
                        }
                    }

                    #endregion

                    #region  Page - Webparts

                    if (!ctx.Web.IsNoScriptSite() && sourcePage.WebParts.Count > 0)
                    {
                        LimitedWebPartManager wpm = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
                        ctx.Load(wpm.WebParts, wps => wps.Include(wp => wp.WebPart.Title, wp => wp.WebPart.Properties));
                        ctx.ExecuteQuery();

                        if (wpm.WebParts.Count > 0)
                        {
                            foreach (var spwp in sourcePage.WebParts)
                            {
                                scount++;
                                foreach (WebPartDefinition wpd in wpm.WebParts)
                                {
                                    if (spwp.Title == wpd.WebPart.Title)
                                    {
                                        tcount++;

                                        //Page - Webpart Properties
                                        Microsoft.SharePoint.Client.WebParts.WebPart wp = wpd.WebPart;
                                        var isWebPropertiesMatch = CSOMWebPartPropertiesValidation(spwp.Contents, wp.Properties);
                                        if (!isWebPropertiesMatch)
                                        {
                                            return false;
                                        }
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                }
                            }
                            if (scount != tcount)
                            {
                                return false;
                            }
                        }
                        else
                        {
                            return false;
                        }
                    }

                    #endregion

                    #region Page - Security

                    scount = 0;
                    tcount = 0;

                    if (sourcePage.Security != null && file.ListItemAllFields.RoleAssignments.Count > 0)
                    {
                        bool securityResult = ValidateSecurityCSOM(ctx, sourcePage.Security, file.ListItemAllFields);

                        if (!securityResult)
                        {
                            return false;
                        }
                    }
                    #endregion
                }
                else
                {
                    return false;
                }
            }

            return true;
        }
Пример #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hostWebUrl"></param>
        /// <param name="txtUrl"></param>
        /// <param name="template"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="cc"></param>
        /// <param name="page"></param>
        /// <param name="baseConfiguration"></param>
        /// <returns></returns>
        public Web CreateSiteCollection(string hostWebUrl, string txtUrl, string template, string title, string description,
                                    Microsoft.SharePoint.Client.ClientContext cc, Page page, XDocument baseConfiguration)
        {
            //get the template element
            XElement templateConfig = GetTemplateConfig(template, baseConfiguration);
            string siteTemplate = SolveUsedTemplate(template, templateConfig);

            //get the base tenant admin urls
            var tenantStr = hostWebUrl.ToLower().Replace("-my", "").Substring(8);
            tenantStr = tenantStr.Substring(0, tenantStr.IndexOf("."));

            //get the current user to set as owner
            var currUser = cc.Web.CurrentUser;
            cc.Load(currUser);
            cc.ExecuteQuery();

            //create site collection using the Tenant object
            var webUrl = String.Format("https://{0}.sharepoint.com/{1}/{2}", tenantStr, templateConfig.Attribute("ManagedPath").Value, txtUrl);
            var tenantAdminUri = new Uri(String.Format("https://{0}-admin.sharepoint.com", tenantStr));
            string realm = TokenHelper.GetRealmFromTargetUrl(tenantAdminUri);
            var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, tenantAdminUri.Authority, realm).AccessToken;
            using (var adminContext = TokenHelper.GetClientContextWithAccessToken(tenantAdminUri.ToString(), token))
            {
                var tenant = new Tenant(adminContext);
                var properties = new SiteCreationProperties()
                {
                    Url = webUrl,
                    Owner = currUser.Email,
                    Title = title,
                    Template = siteTemplate,
                    StorageMaximumLevel = Convert.ToInt32(templateConfig.Attribute("StorageMaximumLevel").Value),
                    UserCodeMaximumLevel = Convert.ToDouble(templateConfig.Attribute("UserCodeMaximumLevel").Value)
                };

                //start the SPO operation to create the site
                SpoOperation op = tenant.CreateSite(properties);
                adminContext.Load(tenant);
                adminContext.Load(op, i => i.IsComplete);
                adminContext.ExecuteQuery();

                //check if site creation operation is complete
                while (!op.IsComplete)
                {
                    //wait 30seconds and try again
                    System.Threading.Thread.Sleep(30000);
                    op.RefreshLoad();
                    adminContext.ExecuteQuery();
                }
            }

            //get the new site collection
            var siteUri = new Uri(webUrl);
            token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, siteUri.Authority, realm).AccessToken;
            using (var newWebContext = TokenHelper.GetClientContextWithAccessToken(siteUri.ToString(), token))
            {
                var newWeb = newWebContext.Web;
                newWebContext.Load(newWeb);
                newWebContext.ExecuteQuery();

                //process the remiander of the template configuration
                DeployFiles(newWebContext, newWeb, templateConfig);
                DeployCustomActions(newWebContext, newWeb, templateConfig);
                DeployLists(newWebContext, newWeb, templateConfig);
                DeployNavigation(newWebContext, newWeb, templateConfig);
                DeployTheme(newWebContext, newWeb, templateConfig, baseConfiguration);
                SetSiteLogo(newWebContext, newWeb, templateConfig);

                // All done, let's return the newly created site
                return newWeb;
            }
        }
Пример #10
0
        /// <summary>
        /// This is simple demo on sub site creation based on selected "template" with configurable options
        /// </summary>
        /// <param name="txtUrl"></param>
        /// <param name="template"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="cc"></param>
        /// <param name="page"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public Web CreateSubSite(string txtUrl, string template, string title, string description,
                                    Microsoft.SharePoint.Client.ClientContext cc, Page page, XDocument baseConfiguration,
                                    bool isChildSite = false, Web subWeb = null)
        {
            // Resolve the template configuration to be used for chosen template
            XElement templateConfig = GetTemplateConfig(template, baseConfiguration);
            string siteTemplate = SolveUsedTemplate(template, templateConfig);

            // Create web creation configuration
            WebCreationInformation information = new WebCreationInformation();
            information.WebTemplate = siteTemplate;
            information.Description = description;
            information.Title = title;
            information.Url = txtUrl;
            // Currently all english, could be extended to be configurable based on language pack usage
            information.Language = 1033;

            Microsoft.SharePoint.Client.Web newWeb = null;
            //if it's child site from xml, let's do somethign else
            if (!isChildSite)
            {
                // Load host web and add new web to it.
                Microsoft.SharePoint.Client.Web web = cc.Web;
                cc.Load(web);
                cc.ExecuteQuery();
                newWeb = web.Webs.Add(information);
            }
            else
            {
                newWeb = subWeb.Webs.Add(information);
            }
            cc.ExecuteQuery();
            cc.Load(newWeb);
            cc.ExecuteQuery();

            DeployFiles(cc, newWeb, templateConfig);
            DeployCustomActions(cc, newWeb, templateConfig);
            DeployLists(cc, newWeb, templateConfig);
            DeployNavigation(cc, newWeb, templateConfig);
            DeployTheme(cc, newWeb, templateConfig, baseConfiguration);
            SetSiteLogo(cc, newWeb, templateConfig);

            if (!isChildSite)
            {
                DeploySubSites(cc, newWeb, templateConfig, page, baseConfiguration);
            }

            // All done, let's return the newly created site
            return newWeb;
        }
Пример #11
0
 private void DeleteExistingActions(Microsoft.SharePoint.Client.ClientContext clientContext, Web web)
 {
     for (int i = 0; i < web.UserCustomActions.Count - 1; i++)
     {
         if (!String.IsNullOrEmpty(web.UserCustomActions[i].Name) && web.UserCustomActions[i].Name.Equals("SiteInformationApp", StringComparison.InvariantCultureIgnoreCase))
         {
             web.UserCustomActions[i].DeleteObject();
         }
     }
     clientContext.ExecuteQuery();
 }
Пример #12
0
        public bool Validate(Core.Framework.Provisioning.Model.FileCollection sourceFiles, Microsoft.SharePoint.Client.ClientContext ctx)
        {
            int scount = 0;
            int tcount = 0;

            try
            {
                // Check if this is not a noscript site as we're not allowed to write to the web property bag is that one
                bool isNoScriptSite = ctx.Web.IsNoScriptSite();

                foreach (var sf in sourceFiles)
                {
                    scount++;
                    string fileName = sf.Src;
                    string folderName = sf.Folder;
                    string fileUrl = UrlUtility.Combine(ctx.Web.ServerRelativeUrl, folderName + "/" + fileName);

                    // Skip the files we skipped to provision (if any)
                    if (ObjectFiles.SkipFile(isNoScriptSite, fileName, folderName))
                    {
                        continue;
                    }

                    var file = ctx.Web.GetFileByServerRelativeUrl(UrlUtility.Combine(ctx.Web.ServerRelativeUrl, folderName + "/" + fileName));
                    ctx.Load(file, f => f.Exists, f => f.Length);
                    ctx.ExecuteQuery();

                    if (file.Exists)
                    {
                        tcount++;

                        #region File - Security
                        if (sf.Security != null)
                        {
                            ctx.Load(file, f => f.ListItemAllFields);
                            ctx.ExecuteQuery();
                            bool isSecurityMatch = ValidateSecurityCSOM(ctx, sf.Security, file.ListItemAllFields);
                            if (!isSecurityMatch)
                            {
                                return false;
                            }

                        }
                        #endregion

                        #region Overwrite validation
                        if (sf.Overwrite == false)
                        {
                            // lookup the original added file size...should be different from the one we retrieved from SharePoint since we opted to NOT overwrite
                            var files = System.IO.Directory.GetFiles(@".\framework\functional\templates");
                            foreach (var f in files)
                            {
                                if (f.Contains(sf.Src))
                                {
                                    if (new System.IO.FileInfo(f).Length == file.Length)
                                    {
                                        return false;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch(Exception ex)
            {
                // Return false if we get an exception
                Console.WriteLine(ex.ToDetailedString());
                return false;
            }

            return true;
        }
Пример #13
0
        public Web CreateSubSite(Microsoft.SharePoint.Client.ClientContext ctx, Web hostWeb, string txtUrl,
                                string template, string title, string description)
        {
            // Create web creation configuration
            WebCreationInformation information = new WebCreationInformation();
            information.WebTemplate = template;
            information.Description = description;
            information.Title = title;
            information.Url = txtUrl;
            // Currently all English, could be extended to be configurable based on language pack usage
           
            

            Microsoft.SharePoint.Client.Web newWeb = null;
            newWeb = hostWeb.Webs.Add(information);
            ctx.ExecuteQuery();

            ctx.Load(newWeb);
            ctx.ExecuteQuery();

            // Add sub site link override
            new subsitehelper().AddJsLink(ctx, newWeb, this.Request);

            // Let's first upload the custom theme to host web
            new subsitehelper().DeployThemeToWeb(hostWeb, "MyCustomTheme",
                            HostingEnvironment.MapPath(string.Format("~/{0}", "Pages/subsite/resources/custom.spcolor")),
                            string.Empty,
                            HostingEnvironment.MapPath(string.Format("~/{0}", "Pages/subsite/resources/custombg.jpg")),
                            string.Empty);

            // Setting the Custom theme to host web
            new subsitehelper().SetThemeBasedOnName(ctx, newWeb, hostWeb, "MyCustomTheme");

            // Set logo to the site

            // Get the path to the file which we are about to deploy
            new subsitehelper().UploadAndSetLogoToSite(ctx.Web, System.Web.Hosting.HostingEnvironment.MapPath(
                                                            string.Format("~/{0}", "Pages/subsite/resources/template-icon.png")));

            // All done, let's return the newly created site
            return newWeb;
        }
Пример #14
0
        /// <summary> 
        /// <c>UpdateAttributes</c>   member function
        /// this member function updates metatags in sharepoint document library
        /// </summary>
        /// <param name="udataitem"></param>
        /// <param name="result"></param>
        /// <param name="ct"></param>
        /// <param name="cmproperty"></param>
        /// <param name="UploadDocLibraryName"></param>
        /// <returns></returns>
        private static string UpdateAttributes(SharePoint_Link.UserModule.UploadItemsData udataitem, string result, Microsoft.SharePoint.Client.ClientContext ct, CommonProperties cmproperty, string UploadDocLibraryName)
        {
            List list;
            string doclibtitle = UploadDocLibraryName;
            try
            {
                list = ct.Web.Lists.GetByTitle(UploadDocLibraryName);
                ct.Load(list); ct.ExecuteQuery();
            }
            catch (Exception ex)
            {
                ListCollection lc = ct.Web.Lists;
                ct.Load(lc); ct.ExecuteQuery();
                foreach (List item in lc)
                {
                    string siteurlroot = cmproperty.LibSite.Remove(cmproperty.LibSite.Length - 1);
                    string url = siteurlroot + item.DefaultViewUrl;
                    if (url == cmproperty.CompletedoclibraryURL)
                    {
                        doclibtitle = item.Title;
                        break;
                    }
                }

            }

            list = ct.Web.Lists.GetByTitle(doclibtitle);
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml =
            @"<View>
                <Query>
                  <Where>
                    <Eq>
                      <FieldRef Name='FileLeafRef' />
                      <Value Type='Text' >" + udataitem.UploadFileName + @" </Value>
                    </Eq>
                  </Where>
                </Query>
                <RowLimit>100</RowLimit>
              </View>";
            ListItemCollection listItems = list.GetItems(camlQuery);

            ct.Load(listItems);
            ct.ExecuteQuery();

            foreach (ListItem l in listItems)
            {
                result = l["ID"].ToString();

                try
                {

                    l["Title"] = HashingClass.Mailsubject;
                    l.Update();
                    ct.ExecuteQuery();

                    l["ModifiedDate"] = HashingClass.Modifieddate;

                    l.Update();
                    ct.ExecuteQuery();

                }
                catch (Exception ex)
                {

                }

            }
            return result;
        }