public RecentCalibrationsViewModel(Document document, CustomerContact customerContact) { if (document == null) { return; } UserId = document.UserId; Created = document.Created; DocumentId = document.Id; CompanyName = document.CompanyName; DocumentTypeEnum = DocumentTypeHelper.Parse(document); DocumentType = DocumentTypeEnum.AsDisplayString(); DocumentIcon = DocumentType.Replace(" ", ""); Expiration = document.InspectionDate.GetValueOrDefault().Date.AddYears(2); Registration = document.RegistrationNumber; Technician = document.Technician; Customer = document.CustomerContact; DepotName = document.DepotName; if (customerContact != null) { PrimaryEmailAddress = customerContact.Email; SecondaryEmailAddress = customerContact.SecondaryEmail; } }
public virtual IEnumerable <TContent> GetChildrenOfExactType <TContent>(int parentNodeId) where TContent : DocumentTypeBase { var parent = NodeRepository.GetNodeById(parentNodeId); return(GetFromNodes <TContent>(NodeRepository.GetChildrenOfType(parent, DocumentTypeHelper.GetDocumentTypeAlias <TContent>()))); }
/// <summary> /// Get particular pagetye data based on widget properties /// </summary> /// <param name="className">Current page type name</param> /// <param name="selectedPath">Selected page path</param> /// <param name="count">Number of records display</param> /// <param name="columns">Selected columns</param> /// <param name="whereCondition">Where condition filter data</param> /// <param name="orderBy">Order by filter data</param> /// <param name="maxNestingLevel">Selected nesting Level</param> /// <param name="pageSize">Current page size in pagination</param> /// <param name="pageNumber">Current page number</param> /// <param name="paginationEnable">If pagination enalbe true/false</param> /// <param name="selectOnlyPublish">If select only publish true/false</param> /// <returns>Particular pagetype data based on these parameters</returns> public List <TreeNode> GetParticularTreeNodeData(string className, string selectedPath, string count, string columns, string whereCondition, string orderBy, string maxNestingLevel, int pageSize, int pageNumber, bool paginationEnable, bool selectOnlyPublish) { List <TreeNode> pages = new List <TreeNode>(); if (DocumentTypeHelper.GetDocumentTypeClasses().WhereEquals("ClassName", className).TypedResult.Count() >= 1) { //Create object for TreeProvider TreeProvider tree = new TreeProvider(); count = count == null ? "0" : count; int maximumNestingLevel = int.Parse(maxNestingLevel == null ? "-1" : maxNestingLevel); columns = columns == null ? "" : columns; whereCondition = whereCondition == null ? "" : whereCondition; orderBy = orderBy == null ? "" : orderBy; //Get current culture code string cultureCode = LocalizationContext.CurrentCulture.CultureCode == null ? "en-Us" : LocalizationContext.CurrentCulture.CultureCode; //Get current sitename string siteName = SiteContext.CurrentSiteName == null ? "" : SiteContext.CurrentSiteName; selectedPath = selectedPath + "/%"; if (paginationEnable) { //Fetch the data based on the current page size pages = DocumentHelper.GetDocuments(siteName, selectedPath, cultureCode, false, className, whereCondition, orderBy, maximumNestingLevel, selectOnlyPublish, int.Parse(count), columns, tree).Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList(); } else { pages = DocumentHelper.GetDocuments(siteName, selectedPath, cultureCode, false, className, whereCondition, orderBy, maximumNestingLevel, selectOnlyPublish, int.Parse(count), columns, tree).ToList(); } } return(pages); }
/// <summary> /// Fills dropdown list with document types. /// </summary> private void FillDocumentTypesDDL() { drpDocTypes.Items.Clear(); // Add (All) record drpDocTypes.Items.Add(new ListItem(GetString("general.selectall"), "0")); // Select only document types from current site marked as product DataSet ds = DocumentTypeHelper.GetDocumentTypeClasses() .OnSite(SiteContext.CurrentSiteID) .WhereTrue("ClassIsProduct") .OrderBy("ClassDisplayName") .Columns("ClassID", "ClassDisplayName"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { string name = ValidationHelper.GetString(dr["ClassDisplayName"], ""); int id = ValidationHelper.GetInteger(dr["ClassID"], 0); if (!string.IsNullOrEmpty(name) && (id > 0)) { // Handle document name name = ResHelper.LocalizeString(MacroResolver.Resolve(name)); drpDocTypes.Items.Add(new ListItem(name, id.ToString())); } } } }
public Dictionary <DateTime, Dictionary <string, T> > GetDocumentsInDateRange <T>(DateTime fromDateTime, DateTime endDateTime) where T : IOutputJson { logger.LogToConsole($"Requesting for ('{projectName}') documents of '({DocumentTypeHelper.GetDocumentType<T>()}') type in date range: {fromDateTime} to {endDateTime}."); var documents = dataDocumentRepository.GetDocumentsInDateRange <T>(projectName, DocumentTypeHelper.GetDocumentType <T>(), fromDateTime, endDateTime); var data = ConvertDataFromCosmosDb(documents); logger.LogToConsole($"Received {data.Count} ('{projectName}') documents of '({DocumentTypeHelper.GetDocumentType<T>()}') type in date range: {fromDateTime} to {endDateTime}."); return(data); }
private static IClassificationFormatMap GetFormatMapWithoutFallback(String documentType) { foreach (var item in ClassificationFormatMap) { if (DocumentTypeHelper.AreDocumentTypesSame(item.Key, documentType)) { return(item.Value); } } return(null); }
private DateTime GetDateBasedOnDocumentType(IList <T> data) { var documentType = DocumentTypeHelper.GetDocumentType <T>(); if (documentType == DocumentType.BugDatabase) { var workItem = data[0] as WorkItem; return(workItem.ClosedDate); } var dailyCodeChurn = data[0] as DailyCodeChurn; return(dailyCodeChurn.GetDateTimeAsDateTime()); }
/// <summary> /// Returns a collection of classes for which their source code will be generated. /// </summary> private IEnumerable <DataClassInfo> GetDataClasses() { var classes = DocumentTypeHelper.GetDocumentTypeClasses() .WhereEqualsOrNull("ClassIsProduct", false) .OnSite(ucSite.SiteID); if (!chkIncludeContainerPageTypes.Checked) { // Filter-out container page types classes = classes.WhereTrue("ClassIsCoupledClass"); } return(classes.TypedResult); }
private static IClassificationFormatMap GetFormatMapWithFallback(String documentType) { while (documentType.Length != 0) { IClassificationFormatMap formatMapWithoutFallback = GetFormatMapWithoutFallback(documentType); if (formatMapWithoutFallback != null) { return(formatMapWithoutFallback); } documentType = DocumentTypeHelper.GetParentDocumentType(documentType); } return(new DefaultClassificationFormatMap()); }
public ActionResult Index() { var properties = GetProperties(); List <TreeNode> pages = new List <TreeNode>(); if (DocumentTypeHelper.GetDocumentTypeClasses().WhereEquals("ClassName", properties.PageType).TypedResult.Count() >= 1) { pages = DocumentHelper.GetDocuments() .Type(properties.PageType) .Path(properties.Path, PathTypeEnum.Children) .OnCurrentSite() .TypedResult .ToList(); } var types = DocumentTypeHelper.GetDocumentTypeClasses() .WhereEquals("ClassIsContentOnly", true) .TypedResult .ToList(); var filtered = types.Where(t => ClassHasRequiredFields(t)); var pagetypes = new List <SelectListItem>(); foreach (var type in filtered) { pagetypes.Add(new SelectListItem() { Text = type.ClassDisplayName, Value = type.ClassName, Selected = (type.ClassName == properties.PageType) }); } return(PartialView("Widgets/_CarouselWidget", new CarouselWidgetViewModel { AvailableTypes = pagetypes, CarouselItems = pages, Path = properties.Path, Delay = properties.Delay, Swiping = properties.Swiping, Rows = properties.Rows, ContainerID = properties.ContainerID, ItemsPerRow = properties.ItemsPerRow, DoAutoplay = properties.DoAutoplay, PageType = properties.PageType })); }
/// <summary> /// Get all page types data /// </summary> /// <param name="selectedPage">Selected page type</param> /// <returns>All page types classes of particular site</returns> public List <SelectListItem> GetTreeData(string selectedPage) { //Get All page types classes var types = DocumentTypeHelper.GetDocumentTypeClasses().WhereEquals("ClassIsContentOnly", true).TypedResult.ToList(); var pagetypes = new List <SelectListItem>(); foreach (var type in types) { pagetypes.Add(new SelectListItem() { Text = type.ClassDisplayName, Value = type.ClassName, Selected = (type.ClassName == selectedPage) }); } return(pagetypes); }
/// <summary> /// Get total records count based on condition for pagination total pages purpose /// </summary> /// <param name="className">Selected pagetype name</param> /// <param name="selectedPath"></param> /// <param name="count">Selected topN records value</param> /// <param name="columns">Selected columns</param> /// <param name="whereCondition">Specific where condition</param> /// <param name="orderBy">Order by filter data</param> /// <param name="maxNestingLevel">Selected nesting Level</param> /// <param name="selectOnlyPublish">If select only publish true/false</param> /// <returns>Count of total records of a particular page type</returns> public int GetTotalPagesCount(string className, string selectedPath, string count, string columns, string whereCondition, string orderBy, string maxNestingLevel, bool selectOnlyPublish) { TreeProvider tree = new TreeProvider(); int totalItemsCount = 0; if (DocumentTypeHelper.GetDocumentTypeClasses().WhereEquals("ClassName", className).TypedResult.Count() >= 1) { count = count == null ? "0" : count; int maximumNestingLevel = int.Parse(maxNestingLevel == null ? "-1" : maxNestingLevel); columns = columns == null ? "" : columns; whereCondition = whereCondition == null ? "" : whereCondition; orderBy = orderBy == null ? "" : orderBy; string cultureCode = LocalizationContext.CurrentCulture.CultureCode == null ? "en-Us" : LocalizationContext.CurrentCulture.CultureCode; string siteName = SiteContext.CurrentSiteName == null ? "" : SiteContext.CurrentSiteName; selectedPath = selectedPath + "/%"; totalItemsCount = DocumentHelper.GetDocuments(siteName, selectedPath, cultureCode, false, className, whereCondition, orderBy, maximumNestingLevel, selectOnlyPublish, int.Parse(count), columns, tree).Count(); } return(totalItemsCount); }
/// <summary> /// OnAfterSave event handler. /// </summary> protected void editElem_OnAfterSave(object sender, EventArgs e) { string newClassName = DocumentType.ClassName; bool classNameChanged = !string.Equals(oldClassName, newClassName, StringComparison.InvariantCultureIgnoreCase); if (classNameChanged) { // Move icons if class name was changed RefreshIcon(oldClassName, newClassName, DocumentType.ClassIsCoupledClass, null); RefreshIcon(oldClassName, newClassName, DocumentType.ClassIsCoupledClass, "48x48"); } // Ensure (update) the inheritance int inheritedID = DocumentType.ClassInheritsFromClassID; if (inheritedID != oldInheritedID) { if (inheritedID > 0) { // Update the inherited fields DataClassInfo parentClass = DataClassInfoProvider.GetDataClassInfo(inheritedID); if (parentClass != null) { FormHelper.UpdateInheritedClass(parentClass, DocumentType); } } else { // Remove the inherited fields FormHelper.RemoveInheritance(DocumentType, false); } // Clear class structures ClassStructureInfo.Remove(DocumentType.ClassName, true); } // Synchronize site bindings if (oldResourceID != DocumentType.ClassResourceID) { DocumentTypeHelper.SynchronizeSiteBindingsWithResource(DocumentType as DocumentTypeInfo); } }
public static IClassificationFormatMap SelectClassificationFormatMap(String documentType) { if (documentType == null) { throw new ArgumentNullException("documentType"); } if (_cachedFormatMaps == null) { _cachedFormatMaps = new Dictionary <String, IClassificationFormatMap>(); } documentType = DocumentTypeHelper.GetNormalizedDocumentType(documentType); IClassificationFormatMap formatMapWithFallback = null; if (!_cachedFormatMaps.TryGetValue(documentType, out formatMapWithFallback)) { formatMapWithFallback = GetFormatMapWithFallback(documentType); _cachedFormatMaps[documentType] = formatMapWithFallback; } return(formatMapWithFallback); }
public CalibrationsDueViewModel(Document document) { if (document == null) { return; } UserId = document.UserId; Created = document.Created; DocumentId = document.Id; DocumentTypeEnum = DocumentTypeHelper.Parse(document); DocumentType = DocumentTypeEnum.AsDisplayString(); DocumentIcon = DocumentType.Replace(" ", ""); Date = document.InspectionDate.GetValueOrDefault(); Expiration = document.InspectionDate.GetValueOrDefault().AddYears(2); Registration = document.RegistrationNumber; Technician = document.Technician; Customer = document.CustomerContact; DepotName = document.DepotName; var tachographDocument = document as TachographDocument; VehicleManufacturer = tachographDocument != null ? tachographDocument.VehicleMake : string.Empty; }
private Dictionary <DateTime, Dictionary <string, T> > ConvertDataFromCosmosDb <T>(List <CosmosDataDocument <T> > documents) where T : IOutputJson { var data = new Dictionary <DateTime, Dictionary <string, T> >(); if (documents == null || documents.Count == 0) { logger.LogToConsole($"[Converting Cosmos Data] Could not find any documents for project: ('{projectName}') of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); return(data); } logger.LogToConsole($"[Converting Cosmos Data] Found: {data.Count} documents for project: ('{projectName}') of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); ConvertDataFromCosmosDb(documents, data); logger.LogToConsole($"[Converting Cosmos Data] Finished converting cosmos data. Returning {data.Count} ('{projectName}') documents with data of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); return(data); }
public Dictionary <DateTime, Dictionary <string, T> > GetAllDocumentsByProjectNameAndDocumentType <T>() where T : IOutputJson { logger.LogToConsole($"Requesting for all ('{projectName}') documents of '({DocumentTypeHelper.GetDocumentType<T>()}') type."); var documents = dataDocumentRepository.GetAllDocumentsByProjectAndDocumentType <T>(projectName, DocumentTypeHelper.GetDocumentType <T>()); var data = ConvertDataFromCosmosDb(documents); logger.LogToConsole($"Received {data.Count} ('{projectName}') documents of '({DocumentTypeHelper.GetDocumentType<T>()}') type."); return(data); }
private void EnsureAngularJsMasterExists() { // crea un'istanza del documento Ng di base Umbraco.Core.Models.IContentType ngJsMasterDocType = DocumentTypeHelper.GetAngularJsMasterDocType(); Umbraco.Core.Models.IContentType currentNgDocType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(ngJsMasterDocType.Alias); if (currentNgDocType == null) { ApplicationContext.Current.Services.ContentTypeService.Save(ngJsMasterDocType); } else { // proprietà aggiornabili senza effetti collaterali currentNgDocType.CreateDate = ngJsMasterDocType.CreateDate; currentNgDocType.Icon = ngJsMasterDocType.Icon; currentNgDocType.Name = ngJsMasterDocType.Name; currentNgDocType.Thumbnail = ngJsMasterDocType.Thumbnail; currentNgDocType.UpdateDate = ngJsMasterDocType.UpdateDate; // TODO update // identificare le proprietà da aggiornare // e quelle da impostare obbligatoriamente, // altrimenti copiando a tappeto tutte le proprietà // si rischia di riportare valori nulli o non validi // con effetti collaterali in esecuzione // Es. check enableAngularJs nel backend //currentNgDocType.Alias = ngJsMasterDocType.Alias; //currentNgDocType.AllowedAsRoot = ngJsMasterDocType.AllowedAsRoot; //currentNgDocType.AllowedContentTypes = ngJsMasterDocType.AllowedContentTypes; //currentNgDocType.AllowedTemplates = ngJsMasterDocType.AllowedTemplates; //currentNgDocType.ContentTypeComposition = ngJsMasterDocType.ContentTypeComposition; //currentNgDocType.SetDefaultTemplate(ngJsMasterDocType.DefaultTemplate); //currentNgDocType.CreatorId = ngJsMasterDocType.CreatorId; //currentNgDocType.Description = ngJsMasterDocType.Description; //currentNgDocType.IsContainer = ngJsMasterDocType.IsContainer; //currentNgDocType.Level = ngJsMasterDocType.Level; //currentNgDocType.NoGroupPropertyTypes = ngJsMasterDocType.NoGroupPropertyTypes; //currentNgDocType.ParentId = ngJsMasterDocType.ParentId; //currentNgDocType.Path = ngJsMasterDocType.Path; //currentNgDocType.SortOrder = ngJsMasterDocType.SortOrder; foreach (Umbraco.Core.Models.PropertyGroup defaultPropertyGroup in ngJsMasterDocType.PropertyGroups) { // se il docType attuale non contiene i "tab" predefiniti, allora vengono aggiunti if (!currentNgDocType.PropertyGroups.Contains(defaultPropertyGroup.Name)) { currentNgDocType.PropertyGroups.Add(defaultPropertyGroup); } } foreach (Umbraco.Core.Models.PropertyType defaultPropertyType in ngJsMasterDocType.PropertyTypes) { // se il docType attuale non contiene le proprietà predefinite, allora vengono aggiunte if (!currentNgDocType.PropertyTypes.Contains(defaultPropertyType)) { currentNgDocType.AddPropertyType(defaultPropertyType); } } } ApplicationContext.Current.Services.ContentTypeService.Save(currentNgDocType); }
public void ProcessOutput <T>(OutputType outputType, string outputFile, Dictionary <DateTime, Dictionary <string, T> > dict) where T : IOutputJson { dict = dict.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); logger.LogToConsole($"Started inserting documents for ('{projectName}') project of '({DocumentTypeHelper.GetDocumentType<T>()}') type."); var listOfFilesPerDay = dataConverter.ConvertDictToOrderedListPerDay(dict); var cosmosDocumentsToInsert = (from x in listOfFilesPerDay from valueValue in x.Value.Values select ConvertOutputJsonToCosmosDataDocument(valueValue, DocumentTypeHelper.GetDocumentType <T>(), x.Key)).ToList(); if (cosmosDocumentsToInsert.Count >= batchSize) { logger.LogToConsole("Inserting documents with batches."); BatchDeleteDocuments <T>(dict.First().Key, dict.Last().Key); BatchInsertDocuments(cosmosDocumentsToInsert); } else { DeleteDocuments(cosmosDocumentsToInsert); InsertDocuments(cosmosDocumentsToInsert); } logger.LogToConsole($"Finished inserting documents to cosmos for ('{projectName}') project of '({DocumentTypeHelper.GetDocumentType<T>()}') type."); }
private void BatchDeleteDocuments <T>(DateTime fromDateTime, DateTime toDateTime) where T : IOutputJson { logger.LogToConsole($"Deleting existing ('{projectName}') documents between: {fromDateTime} and {toDateTime} of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); var deleteSummary = dataDocumentRepository.BatchDeleteDocuments(fromDateTime, toDateTime, projectName, DocumentTypeHelper.GetDocumentType <T>()); logger.LogToConsole($"Finished deleting of ('{projectName}') {deleteSummary.NumberOfDocumentsDeleted} existing documents in {deleteSummary.TotalTimeTaken} sec(s) of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); }
protected void menuNew_OnReloadData(object sender, EventArgs e) { int nodeId = ValidationHelper.GetInteger(menuNew.Parameter, 0); // Get the node TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode node = tree.SelectSingleNode(nodeId); if (node != null) { if (CurrentUser.IsAuthorizedToCreateNewDocument(node, null)) { DocumentTypeScopeInfo scope = DocumentTypeScopeInfoProvider.GetScopeInfo(node); if (scope != null) { plcNewLink.Visible = scope.ScopeAllowLinks; } pnlSepNewLinkVariant.Visible = plcNewLink.Visible; string where = "ClassID IN (SELECT ChildClassID FROM CMS_AllowedChildClasses WHERE ParentClassID=" + ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0) + ") " + "AND ClassID IN (SELECT ClassID FROM CMS_ClassSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")"; if (!string.IsNullOrEmpty(DocumentTypeWhere)) { where = SqlHelper.AddWhereCondition(where, DocumentTypeWhere); } if (scope != null) { // Apply document type scope where = SqlHelper.AddWhereCondition(where, DocumentTypeScopeInfoProvider.GetScopeClassWhereCondition(scope).ToString(true)); } // Get the allowed child classes DataSet ds = DocumentTypeHelper.GetDocumentTypeClasses() .Where(where) .OrderBy(DocumentTypeOrderBy) .TopN(50) .Columns("ClassID", "ClassName", "ClassDisplayName"); var rows = new List <DataRow>(); if (!DataHelper.DataSourceIsEmpty(ds)) { // Check user permissions for "Create" permission bool hasNodeAllowCreate = (CurrentUser.IsAuthorizedPerTreeNode(node, NodePermissionsEnum.Create) == AuthorizationResultEnum.Allowed); bool isAuthorizedToCreateInContent = CurrentUser.IsAuthorizedPerResource("CMS.Content", "Create"); DataTable resultTable = ds.Tables[0].DefaultView.ToTable(); for (int i = 0; i < resultTable.Rows.Count; ++i) { DataRow dr = resultTable.Rows[i]; string doc = DataHelper.GetStringValue(dr, "ClassName"); // Document type is not allowed, remove it from the data set if (!isAuthorizedToCreateInContent && !CurrentUser.IsAuthorizedPerClassName(doc, "Create") && (!CurrentUser.IsAuthorizedPerClassName(doc, "CreateSpecific") || !hasNodeAllowCreate)) { rows.Add(dr); } } // Remove the document types foreach (DataRow dr in rows) { resultTable.Rows.Remove(dr); } bool classesRemoved = false; // Leave only first 15 rows while (resultTable.Rows.Count > 15) { resultTable.Rows.RemoveAt(resultTable.Rows.Count - 1); classesRemoved = true; } if (!DataHelper.DataSourceIsEmpty(resultTable)) { // Add show more item if (classesRemoved) { DataRow dr = resultTable.NewRow(); dr["ClassID"] = 0; dr["ClassName"] = "more"; dr["ClassDisplayName"] = ResHelper.GetString("class.showmore"); resultTable.Rows.InsertAt(dr, resultTable.Rows.Count); } // Create temp column int rowCount = resultTable.Rows.Count; DataColumn tmpColumn = new DataColumn("Count"); tmpColumn.DefaultValue = rowCount; resultTable.Columns.Add(tmpColumn); repNew.DataSource = resultTable; repNew.DataBind(); } else { DisplayErrorMessage(scope != null ? "Content.ScopeApplied" : "Content.NoPermissions"); } } else { DisplayErrorMessage(scope != null ? "Content.ScopeApplied" : "NewMenu.NoChildAllowed"); } } else { DisplayErrorMessage("Content.NoPermissions"); } } }
/// <summary> /// Setups grid where condition to filter out by given restrictions. /// </summary> private void SetupGridFilterWhereCondition() { string where = String.Empty; // Set proper base where condition switch (ListingType) { case ListingTypeEnum.CheckedOut: where = "DocumentCheckedOutByUserID = @UserID"; break; case ListingTypeEnum.MyDocuments: where = "NodeOwner = @UserID"; break; case ListingTypeEnum.RecentDocuments: where = "((DocumentCreatedByUserID = @UserID OR DocumentModifiedByUserID = @UserID OR DocumentCheckedOutByUserID = @UserID))"; break; case ListingTypeEnum.PendingDocuments: where = "DocumentWorkflowStepID IN (SELECT StepID FROM CMS_WorkflowStep WHERE " + WorkflowStepInfoProvider.GetWorkflowPendingStepsWhereCondition(currentUserInfo, new SiteInfoIdentifier(SiteName)).ToString(false) + ")"; break; case ListingTypeEnum.OutdatedDocuments: where = "DocumentCreatedByUserID = @UserID OR DocumentModifiedByUserID = @UserID OR DocumentCheckedOutByUserID = @UserID"; break; case ListingTypeEnum.All: where = String.Format("(UserID1 = {0} OR UserID2 = {0} OR UserID3 = {0})", currentUserInfo.UserID); break; } gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, where); // Selected site filter if (!String.IsNullOrEmpty(SiteName) && (SiteName != UniGrid.ALL)) { selectedSiteInfo = SiteInfoProvider.GetSiteInfo(SiteName); if (selectedSiteInfo != null) { gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODESITEID + " = " + selectedSiteInfo.SiteID); } } // Site running filter if ((SiteName == UniGrid.ALL) && DisplayOnlyRunningSites) { gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "NodeSiteID IN (SELECT SiteID FROM CMS_Site WHERE SiteStatus = 'RUNNING')"); } // Path filter if (Path != String.Empty) { gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, ((ListingType == ListingTypeEnum.All) ? SOURCE_DOCUMENTNAMEPATH : SOURCE_NODEALIASPATH) + " LIKE N'" + SqlHelper.EscapeQuotes(MacroResolver.ResolveCurrentPath(Path)) + "'"); } // Document type filer if (!String.IsNullOrEmpty(DocumentType)) { string classNames = DocumentTypeHelper.GetClassNames(DocumentType); gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SqlHelper.GetWhereCondition <string>(SOURCE_CLASSNAME, classNames.Split(';'), true)); } // Document name filter if (DocumentName != String.Empty) { gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAME + " LIKE N'%" + SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(DocumentName)) + "%'"); } }
private void InsertDocuments <T>(List <CosmosDataDocument <T> > listOfFilesPerDay) where T : IOutputJson { logger.LogToConsole($"Found: {listOfFilesPerDay.Count} ('{projectName}') documents of ('{DocumentTypeHelper.GetDocumentType<T>()}') type to upload."); foreach (var document in listOfFilesPerDay) { dataDocumentRepository.CreateDataDocument(document); } logger.LogToConsole($"Inserted: {listOfFilesPerDay.Count} ('{projectName}') documents of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); }
public int Extract() { var files = fileSystem.GetFiles(pathToJsonFiles, "*.json").ToList(); logger.LogToConsole($"Reading {files.Count} files from ('{pathToJsonFiles}') of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); var data = new Dictionary <DateTime, Dictionary <string, T> >(); foreach (var file in files) { var codeChurnList = jsonListParser.ParseFile(file.FileName); logger.LogToConsole($"Processing file: ('{file.FileName}')."); var outputData = codeChurnList.ToDictionary(fileData => fileData.GetFileLongName()); logger.LogToConsole($"Found: {outputData.Keys.Count} data to insert."); data.Add(GetDateBasedOnDocumentType(codeChurnList), outputData); } outputProcessor.ProcessOutput(OutputType.CosmosDb, cosmosProjectName, data); logger.LogToConsole($"Finished processing files from: ('{pathToJsonFiles}')."); return(0); }
public virtual IEnumerable <TContent> GetFromNodesOfExactType <TContent>(IEnumerable <Node> nodes) where TContent : DocumentTypeBase { return(GetFromNodes <TContent>(NodeRepository.FilterByType(nodes, DocumentTypeHelper.GetDocumentTypeAlias <TContent>()))); }
protected void menuNew_OnReloadData(object sender, EventArgs e) { int nodeId = ValidationHelper.GetInteger(menuNew.Parameter, 0); // Get the node TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode node = tree.SelectSingleNode(nodeId); plcNewVariant.Visible = false; if (node != null) { if (CurrentUser.IsAuthorizedToCreateNewDocument(node, null)) { DocumentTypeScopeInfo scope = DocumentTypeScopeInfoProvider.GetScopeInfo(node); if (scope != null) { plcNewLink.Visible = scope.ScopeAllowLinks; } // AB test variant settings if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSABTestingEnabled") && EnableABTestVariant && CurrentUser.IsAuthorizedPerResource("cms.ABTest", "Read") && ModuleEntryManager.IsModuleLoaded(ModuleName.ONLINEMARKETING) && ResourceSiteInfoProvider.IsResourceOnSite("CMS.ABTest", SiteContext.CurrentSiteName) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.ABTesting) && (node.NodeAliasPath != "/") && (node.NodeClassName != "CMS.Folder") && ((scope == null) || scope.ScopeAllowABVariant) && CurrentUser.IsAuthorizedToCreateNewDocument(node, node.ClassName)) { plcNewVariant.Visible = true; } pnlSepNewLinkVariant.Visible = (plcNewVariant.Visible || plcNewLink.Visible); string where = "ClassID IN (SELECT ChildClassID FROM CMS_AllowedChildClasses WHERE ParentClassID=" + ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0) + ") " + "AND ClassID IN (SELECT ClassID FROM CMS_ClassSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")"; if (!string.IsNullOrEmpty(DocumentTypeWhere)) { where = SqlHelper.AddWhereCondition(where, DocumentTypeWhere); } if (scope != null) { // Apply document type scope where = SqlHelper.AddWhereCondition(where, DocumentTypeScopeInfoProvider.GetScopeClassWhereCondition(scope)); } // Get the allowed child classes DataSet ds = DocumentTypeHelper.GetDocumentTypeClasses() .Where(where) .OrderBy(DocumentTypeOrderBy) .TopN(50) .Columns("ClassID", "ClassName", "ClassDisplayName", "(CASE WHEN (ClassName = 'CMS.MenuItem' OR ClassName = 'CMS.Wireframe') THEN 0 ELSE 1 END) AS MenuItemOrder"); var rows = new List <DataRow>(); if (!DataHelper.DataSourceIsEmpty(ds)) { // Check user permissions for "Create" permission bool hasNodeAllowCreate = (CurrentUser.IsAuthorizedPerTreeNode(node, NodePermissionsEnum.Create) == AuthorizationResultEnum.Allowed); bool isAuthorizedToCreateInContent = CurrentUser.IsAuthorizedPerResource("CMS.Content", "Create"); DataTable resultTable = ds.Tables[0].DefaultView.ToTable(); for (int i = 0; i < resultTable.Rows.Count; ++i) { DataRow dr = resultTable.Rows[i]; string doc = ValidationHelper.GetString(DataHelper.GetDataRowValue(dr, "ClassName"), ""); // Document type is not allowed, remove it from the data set if (!isAuthorizedToCreateInContent && !CurrentUser.IsAuthorizedPerClassName(doc, "Create") && (!CurrentUser.IsAuthorizedPerClassName(doc, "CreateSpecific") || !hasNodeAllowCreate)) { rows.Add(dr); } else if (doc.EqualsCSafe("cms.wireframe", true) && !CurrentUser.IsAuthorizedPerResource("CMS.Design", "Wireframing")) { rows.Add(dr); } } // Remove the document types foreach (DataRow dr in rows) { resultTable.Rows.Remove(dr); } bool classesRemoved = false; // Leave only first 15 rows while (resultTable.Rows.Count > 15) { resultTable.Rows.RemoveAt(resultTable.Rows.Count - 1); classesRemoved = true; } if (!DataHelper.DataSourceIsEmpty(resultTable)) { // Add show more item if (classesRemoved) { DataRow dr = resultTable.NewRow(); dr["ClassID"] = 0; dr["ClassName"] = "more"; dr["ClassDisplayName"] = ResHelper.GetString("class.showmore"); resultTable.Rows.InsertAt(dr, resultTable.Rows.Count); } // Create temp column int rowCount = resultTable.Rows.Count; DataColumn tmpColumn = new DataColumn("Count"); tmpColumn.DefaultValue = rowCount; resultTable.Columns.Add(tmpColumn); repNew.DataSource = resultTable; repNew.DataBind(); } else { DisplayErrorMessage(scope != null ? "Content.ScopeApplied" : "Content.NoPermissions"); } } else { DisplayErrorMessage(scope != null ? "Content.ScopeApplied" : "NewMenu.NoChildAllowed"); } } else { DisplayErrorMessage("Content.NoPermissions"); } } }
private void DeleteDocuments <T>(List <CosmosDataDocument <T> > listOfFilesPerDay) where T : IOutputJson { logger.LogToConsole($"Deleting: existing ('{projectName}') documents of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); var documentsDeleted = dataDocumentRepository.DeleteMultipleDocuments(listOfFilesPerDay); logger.LogToConsole($"Deleted: {documentsDeleted} existing ('{projectName}') documents of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); }
public virtual IEnumerable <TContent> GetRootLevelContentsOfExactType <TContent>() where TContent : DocumentTypeBase { return(GetFromNodes <TContent>( NodeRepository.GetChildrenOfType(NodeRepository.RootNode, DocumentTypeHelper.GetDocumentTypeAlias <TContent>()))); }
private void BatchInsertDocuments <T>(List <CosmosDataDocument <T> > listOfFilesPerDay) where T : IOutputJson { logger.LogToConsole($"Starting to batch upload {listOfFilesPerDay.Count} ('{projectName}') doc(s) to cosmos of ('{DocumentTypeHelper.GetDocumentType<T>()}') type."); var summary = dataDocumentRepository.BatchInsertCosmosDocuments(listOfFilesPerDay, LogBatchDetails); logger.LogToConsole($"Finished upload of {summary.NumberOfDocumentsInserted} ('{projectName}') doc(s) of ('{DocumentTypeHelper.GetDocumentType<T>()}') type in {summary.TotalTimeTaken.TotalSeconds} sec(s)."); }