public void UpdateRequestStatus(string url, SiteRequestStatus status, string statusMessage) { UsingContext(ctx => { Log.Info("Provisioning.Common.Data.Impl.UpdateRequestStatus", PCResources.SiteRequestUpdate_Successfull, url, status.ToString()); var web = ctx.Web; if (!web.ListExists(SiteRequestList.TITLE)) { this.HandleSiteRequestList(ctx); } var _list = ctx.Web.Lists.GetByTitle(SiteRequestList.TITLE); var _query = new CamlQuery(); _query.ViewXml = string.Format(CAML_GETREQUEST_BY_URL, url); ListItemCollection _itemCollection = _list.GetItems(_query); ctx.Load(_itemCollection); ctx.ExecuteQuery(); if (_itemCollection.Count != 0) { ListItem _item = _itemCollection.FirstOrDefault(); _item[SiteRequestFields.PROVISIONING_STATUS_NAME] = status.ToString(); if (!string.IsNullOrEmpty(statusMessage)) { _item[SiteRequestFields.STATUSMESSAGE_NAME] = statusMessage; } _item.Update(); ctx.ExecuteQuery(); } }); }
public void UpdateRequestStatus(string url, SiteRequestStatus status, string statusMessage) { Log.Info("SPSiteRequestManager.UpdateRequestStatus", "Entering UpdateRequestStatus url {0} status {1} status message", url, status.ToString(), statusMessage); UsingContext(ctx => { Stopwatch _timespan = Stopwatch.StartNew(); var _web = ctx.Web; ctx.Load(_web); if (!_web.ListExists(SiteRequestList.TITLE)) { var _message = String.Format("The List {0} does not exist in Site {1}", SiteRequestList.TITLE, _web.Url); Log.Fatal("SPSiteRequestManager.UpdateRequestStatus", _message); throw new DataStoreException(_message); } var _list = ctx.Web.Lists.GetByTitle(SiteRequestList.TITLE); var _query = new CamlQuery(); _query.ViewXml = string.Format(CAML_GETREQUEST_BY_URL, url); ListItemCollection _itemCollection = _list.GetItems(_query); ctx.Load(_itemCollection); ctx.ExecuteQuery(); if (_itemCollection.Count != 0) { ListItem _item = _itemCollection.FirstOrDefault(); _item[SiteRequestFields.PROVISIONING_STATUS_NAME] = status.ToString(); if (!string.IsNullOrEmpty(statusMessage)) { _item[SiteRequestFields.STATUSMESSAGE_NAME] = statusMessage; } _item.Update(); ctx.ExecuteQuery(); } _timespan.Stop(); Log.Info("SPSiteRequestManager.UpdateRequestStatus", PCResources.SiteRequestUpdate_Successful, url, status.ToString()); Log.TraceApi("SharePoint", "SPSiteRequestManager.UpdateRequestStatus", _timespan.Elapsed); }); }
public void UpdateRequestStatus(string url, SiteRequestStatus status, string statusMessage) { UsingContext(client => { try { Task <Task <Database> > _taskResult = Task.FromResult <Task <Database> >(this.GetOrCreateDatabaseAsync(client)); Database _db; if (!_taskResult.IsFaulted) { if (!_taskResult.Result.IsFaulted) { _db = _taskResult.Result.Result; var _dbCollectionTasks = Task.FromResult(this.GetOrCreateCollectionAsync(client, _db.SelfLink, DB_COLLECTION_ID)); if (!_dbCollectionTasks.Result.IsFaulted) { var _siteInfo = this.GetSiteRequestByUrl(client, _dbCollectionTasks.Result.Result.DocumentsLink, url); if (_siteInfo != null) { if (statusMessage.Length >= 255) { statusMessage = statusMessage.Substring(0, 252) + "..."; } var doc = this.UpdateSiteRequestStatusByUrl(client, _dbCollectionTasks.Result.Result.SelfLink, _siteInfo, status, statusMessage); } } } } } catch (DocumentClientException de) { Exception baseException = de.GetBaseException(); Log.Error("AzureDocDbRequestManager.UpdateRequestStatus", "{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message); } catch (Exception ex) { Exception baseException = ex.GetBaseException(); Log.Error("AzureDocDbRequestManager.UpdateRequestStatus", "Error: {0}, Message: {1}", ex.Message, baseException.Message); } }); }
/// <summary> /// Internal Member to Return a Site Request By Status /// </summary> /// <param name="client"></param> /// <param name="collectionLink"></param> /// <param name="status"></param> /// <returns></returns> private List<SiteInformation> GetSiteRequestsByStatus(DocumentClient client, string collectionLink, SiteRequestStatus status) { List<SiteInformation> _returnResults = new List<SiteInformation>(); var siteRequests = from record in client.CreateDocumentQuery<SiteInformation>(collectionLink) where record.RequestStatus == status.ToString() select record; _returnResults = siteRequests.ToList(); return _returnResults; }
/// <summary> /// Internal Member to Update Request and Status properties Azure DocumentDB by url /// </summary> /// <param name="client"></param> /// <param name="selfLink"></param> /// <param name="request"></param> /// <param name="status"></param> /// <param name="message"></param> /// <returns></returns> private Document UpdateSiteRequestStatusByUrl(DocumentClient client, string selfLink, SiteInformation request, SiteRequestStatus status, string message) { dynamic _requestDocument = client.CreateDocumentQuery<Document>(selfLink).Where(d => d.Id == request.Id).AsEnumerable().FirstOrDefault(); Document _d = _requestDocument; //Cast to Document to get the Selflink property Document _dReturnResult = null; SiteInformation _requestToUpdate = _requestDocument; if(!string.IsNullOrEmpty(message)) { _requestToUpdate.RequestStatusMessage = message; } _requestToUpdate.EnumStatus = status; var savedRequestTask = Task.FromResult(client.ReplaceDocumentAsync(_d.SelfLink, _requestToUpdate)); if (!savedRequestTask.Result.IsFaulted) { _dReturnResult = savedRequestTask.Result.Result; } return _dReturnResult; }
public void UpdateRequestStatus(string url, SiteRequestStatus status, string statusMessage) { UsingContext(client => { try { Task<Task<Database>> _taskResult = Task.FromResult<Task<Database>>(this.GetOrCreateDatabaseAsync(client)); Database _db; if (!_taskResult.IsFaulted) { if (!_taskResult.Result.IsFaulted) { _db = _taskResult.Result.Result; var _dbCollectionTasks = Task.FromResult(this.GetOrCreateCollectionAsync(client, _db.SelfLink, DB_COLLECTION_ID)); if (!_dbCollectionTasks.Result.IsFaulted) { var _siteInfo = this.GetSiteRequestByUrl(client, _dbCollectionTasks.Result.Result.DocumentsLink, url); if (_siteInfo != null) { var doc = this.UpdateSiteRequestStatusByUrl(client, _dbCollectionTasks.Result.Result.SelfLink, _siteInfo, status, statusMessage); } } } } } catch (DocumentClientException de) { Exception baseException = de.GetBaseException(); Log.Error("AzureDocDbRequestManager.UpdateRequestStatus", "{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message); } catch (Exception ex) { Exception baseException = ex.GetBaseException(); Log.Error("AzureDocDbRequestManager.UpdateRequestStatus", "Error: {0}, Message: {1}", ex.Message, baseException.Message); } }); }
public void UpdateRequestStatus(string url, SiteRequestStatus status) { this.UpdateRequestStatus(url, status, string.Empty); }
public void UpdateRequestStatus(string url, SiteRequestStatus status) { Log.Info("SPSiteRequestManager.UpdateRequestStatus", "Entering UpdateRequestStatus url {0} status {1}", url, status.ToString()); this.UpdateRequestStatus(url, status, string.Empty); }
public void UpdateRequestStatus(string url, SiteRequestStatus status, string statusMessage) { Log.Info("SPSiteRequestManager.UpdateRequestStatus", "Entering UpdateRequestStatus url {0} status {1} status message", url, status.ToString(), statusMessage); UsingContext(ctx => { Stopwatch _timespan = Stopwatch.StartNew(); var _web = ctx.Web; ctx.Load(_web); if (!_web.ListExists(SiteRequestList.TITLE)) { var _message = String.Format("The List {0} does not exist in Site {1}", SiteRequestList.TITLE, _web.Url); Log.Fatal("SPSiteRequestManager.UpdateRequestStatus", _message); throw new DataStoreException(_message); } var _list = ctx.Web.Lists.GetByTitle(SiteRequestList.TITLE); var _query = new CamlQuery(); _query.ViewXml = string.Format(CAML_GETREQUEST_BY_URL, url); ListItemCollection _itemCollection =_list.GetItems(_query); ctx.Load(_itemCollection); ctx.ExecuteQuery(); if (_itemCollection.Count != 0) { ListItem _item = _itemCollection.FirstOrDefault(); _item[SiteRequestFields.PROVISIONING_STATUS_NAME] = status.ToString(); if (!string.IsNullOrEmpty(statusMessage)) { _item[SiteRequestFields.STATUSMESSAGE_NAME] = statusMessage; } _item.Update(); ctx.ExecuteQuery(); } _timespan.Stop(); Log.Info("SPSiteRequestManager.UpdateRequestStatus", PCResources.SiteRequestUpdate_Successful, url, status.ToString()); Log.TraceApi("SharePoint", "SPSiteRequestManager.UpdateRequestStatus", _timespan.Elapsed); }); }
/// <summary> /// Internal Member to Return a Site Request By Status /// </summary> /// <param name="client"></param> /// <param name="collectionLink"></param> /// <param name="status"></param> /// <returns></returns> private List <SiteInformation> GetSiteRequestsByStatus(DocumentClient client, string collectionLink, SiteRequestStatus status) { List <SiteInformation> _returnResults = new List <SiteInformation>(); var siteRequests = from record in client.CreateDocumentQuery <SiteInformation>(collectionLink) where record.RequestStatus == status.ToString() select record; _returnResults = siteRequests.ToList(); return(_returnResults); }
/// <summary> /// Internal Member to Update Request and Status properties Azure DocumentDB by url /// </summary> /// <param name="client"></param> /// <param name="selfLink"></param> /// <param name="request"></param> /// <param name="status"></param> /// <param name="message"></param> /// <returns></returns> private Document UpdateSiteRequestStatusByUrl(DocumentClient client, string selfLink, SiteInformation request, SiteRequestStatus status, string message) { dynamic _requestDocument = client.CreateDocumentQuery <Document>(selfLink).Where(d => d.Id == request.Id).AsEnumerable().FirstOrDefault(); Document _d = _requestDocument; //Cast to Document to get the Selflink property Document _dReturnResult = null; SiteInformation _requestToUpdate = _requestDocument; if (!string.IsNullOrEmpty(message)) { _requestToUpdate.RequestStatusMessage = message; } _requestToUpdate.EnumStatus = status; var savedRequestTask = Task.FromResult(client.ReplaceDocumentAsync(_d.SelfLink, _requestToUpdate)); if (!savedRequestTask.Result.IsFaulted) { _dReturnResult = savedRequestTask.Result.Result; } return(_dReturnResult); }