/// <summary> /// Validates and returns selected schedule interval. /// </summary> private ObjectParameters GetValidScheduleInterval() { if (!editForm.StopProcessing) { if (ucScheduleInterval.ScheduleInterval == String.Empty) { ShowError(GetString("ma.trigger.invalidinterval")); editForm.StopProcessing = true; } if (!DataTypeManager.IsValidDate(ucScheduleInterval.StartTime.SelectedDateTime)) { ShowError($"{GetString("BasicForm.ErrorInvalidDateTime")} {DateTime.Now}."); editForm.StopProcessing = true; } if (!ucScheduleInterval.CheckOneDayMinimum()) { ShowError(GetString("ma.trigger.nodayselected")); editForm.StopProcessing = true; } } var triggerParameters = new ObjectParameters(); triggerParameters.SetValue(TriggerDataConstants.TRIGGER_DATA_INTERVAL, ucScheduleInterval.ScheduleInterval); return(triggerParameters); }
public DataAttributeModel(bool showConstraints) { Id = 0; Name = ""; ShortName = ""; Description = ""; InUse = false; ShowConstraints = showConstraints; DataType = new DataTypeItemModel(); Unit = new UnitItemModel(); try { dataTypeManager = new DataTypeManager(); unitManager = new UnitManager(); dataTypeManager.Repo.Get().OrderBy(dt => dt.Name).ToList().ForEach(dt => DataTypes.Add(new DataTypeItemModel(dt))); unitManager.Repo.Get().OrderBy(u => u.Name).ToList().ForEach(u => Units.Add(new UnitItemModel(u))); } finally { dataTypeManager.Dispose(); unitManager.Dispose(); } RangeConstraints = new List <RangeConstraintModel>(); DomainConstraints = new List <DomainConstraintModel>(); PatternConstraints = new List <PatternConstraintModel>(); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { uniSelector.IsLiveSite = IsLiveSite; // Return form name or ID according to type of field (if no field specified form name is returned) if ((FieldInfo != null) && DataTypeManager.IsInteger(TypeEnum.Field, FieldInfo.DataType)) { // Store old value object value = uniSelector.Value; uniSelector.ReturnColumnName = "FormID"; uniSelector.SelectionMode = SelectionModeEnum.SingleDropDownList; ShowSiteFilter = false; uniSelector.AllowEmpty = true; // Reset previously saved value uniSelector.Value = value; } else { uniSelector.ReturnColumnName = "FormName"; } // Add sites filter if (ShowSiteFilter) { uniSelector.FilterControl = "~/CMSFormControls/Filters/SiteFilter.ascx"; uniSelector.SetValue("DefaultFilterValue", (SiteID > 0) ? SiteID : SiteContext.CurrentSiteID); uniSelector.SetValue("FilterMode", "bizform"); } // Select bizforms depending on a site if not filtered by uniselector site filter else { int siteId = (SiteID == 0) ? SiteContext.CurrentSiteID : SiteID; uniSelector.WhereCondition = SqlHelper.AddWhereCondition(uniSelector.WhereCondition, "FormSiteID = " + siteId); } }
/// <summary> /// Handles the Click event of the btnSubmit control. /// </summary> private void btnSubmit_Click(object sender, EventArgs e) { if (EditEnabled && propertiesForm.SaveData(null, false)) { var properties = new NameValueCollection(); propertiesForm.Fields.ForEach(fieldName => { var fieldDataType = propertiesForm.FormInformation.GetFormField(fieldName).DataType; var fieldValue = propertiesForm.Data.GetValue(fieldName); var value = DataTypeManager.GetStringValue(TypeEnum.Field, fieldDataType, fieldValue, CultureHelper.EnglishCulture); properties.Add(fieldName, value); }); try { WidgetService.StoreWidgetProperties(widgetInstanceGuid, properties); hdnSaveStatus.Value = "1"; } catch (InvalidOperationException exception) { Service.Resolve <IEventLogService>().LogException("Newsletter", "SAVEWIDGETPROP", exception); } } }
/// <summary> /// Reloads the data in the selector. /// </summary> /// <param name="forced">Indicates whether UniSelector Reload data should be called</param> public void ReloadData(bool forced) { // Return forum name or ID according to type of field (if no field specified forum name is returned) if ((FieldInfo != null) && DataTypeManager.IsInteger(TypeEnum.Field, FieldInfo.DataType)) { uniSelector.WhereCondition = "BoardSiteID = " + SiteID; uniSelector.ReturnColumnName = "BoardID"; ShowGroupBoards = true; } else { uniSelector.WhereCondition = "BoardSiteID = " + SiteID + " AND " + (GroupID > 0 ? "BoardGroupID = " + GroupID : "((BoardGroupID = 0) OR (BoardGroupID IS NULL))"); } uniSelector.IsLiveSite = IsLiveSite; uniSelector.SelectionMode = SelectionModeEnum.SingleDropDownList; uniSelector.AllowEmpty = false; uniSelector.AllowAll = false; if (AddAllItemsRecord) { uniSelector.SpecialFields.Add(new SpecialField() { Text = GetString("general.selectall"), Value = String.Empty }); } if (forced) { uniSelector.Reload(true); } }
public ColumnMapTypeExpression() : base() { if (manager == null) { manager = new DataTypeManager(); } }
public RS.ResourceStructureAttribute CreateResourceStructureAttribute(string name, string description) { Contract.Requires(!string.IsNullOrWhiteSpace(name)); Contract.Requires(!String.IsNullOrWhiteSpace(description)); using (DataTypeManager dataTypeManager = new DataTypeManager()) { DataType type = dataTypeManager.Repo.Get(p => p.SystemType.Equals("String")).FirstOrDefault(); if (type == null) { type = dataTypeManager.Create("String", "string", TypeCode.String); } RS.ResourceStructureAttribute resourceStrucAtt = new RS.ResourceStructureAttribute() { Name = name, Description = description, DataType = type, }; using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <RS.ResourceStructureAttribute> repo = uow.GetRepository <RS.ResourceStructureAttribute>(); repo.Put(resourceStrucAtt); uow.Commit(); } return(resourceStrucAtt); } }
public static void Highlighting(RichTextBox richTextBox, DatabaseType databaseType, bool keepPosition = true, int?startIndex = null, int?stopIndex = null) { int start = richTextBox.SelectionStart; var dataTypes = DataTypeManager.GetDataTypeSpecifications(databaseType).Select(item => item.Name); var keywords = KeywordManager.GetKeywords(databaseType); var functions = FunctionManager.GetFunctionSpecifications(databaseType).Select(item => item.Name).Except(keywords); string dataTypesRegex = $@"\b({string.Join("|", dataTypes)})\b"; string keywordsRegex = $@"\b({string.Join("|", keywords)})\b"; string functionsRegex = $@"\b({string.Join("|", functions)})\b"; string stringRegex = $@"(['][^'^(^)]*['])"; Highlighting(richTextBox, dataTypesRegex, RegexOptions.IgnoreCase, Color.Blue); Highlighting(richTextBox, keywordsRegex, RegexOptions.IgnoreCase, Color.Blue); Highlighting(richTextBox, functionsRegex, RegexOptions.IgnoreCase, ColorTranslator.FromHtml("#FF00FF")); Highlighting(richTextBox, stringRegex, RegexOptions.IgnoreCase, Color.Red); string commentString = databaseType == DatabaseType.MySql ? "#" : "--"; string commentRegex = $@"({commentString}).*[\n]?"; Highlighting(richTextBox, commentRegex, RegexOptions.IgnoreCase, Color.Green); richTextBox.SelectionStart = keepPosition ? start : 0; richTextBox.SelectionLength = 0; richTextBox.Focus(); }
private void setup() { bool inUse = false; Unit = new Unit(); Unit.Dimension = new Dimension(); DataTypeList = new List <DataType>(); DimensionList = new List <Dimension>(); UnitManager unitManager = null; DataTypeManager dataTypeManager = null; try { dataTypeManager = new DataTypeManager(); unitManager = new UnitManager(); DataTypeList = dataTypeManager.Repo.Get().ToList(); DimensionList = unitManager.DimensionRepo.Get().ToList(); } finally { dataTypeManager.Dispose(); unitManager.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { // Return GroupID if field type is integer if ((FieldInfo != null) && DataTypeManager.IsInteger(TypeEnum.Field, FieldInfo.DataType)) { usGroups.ReturnColumnName = "GroupID"; usGroups.AllowEmpty = true; DisplayCurrentGroup = DisplayNoneValue = DisplayNoneWhenEmpty = false; } if (StopProcessing) { usGroups.StopProcessing = true; } else { EnsureChildControls(); // Ensure correct livesite setting for uniselector IsLiveSite = IsLiveSite; usGroups.WhereCondition = BuildWhereCondition(); usGroups.OnSelectionChanged += new EventHandler(usGroups_OnSelectionChanged); } }
private List <DataType> updataAssociatedDataType(Unit unit, long[] newDataTypeIds, UnitManager unitManager) { if (unit != null) { DataTypeManager dataTypeManger = null; try { dataTypeManger = new DataTypeManager(); List <DataType> existingDataTypes = unit.AssociatedDataTypes.ToList(); List <DataType> newDataTypes = newDataTypeIds == null ? new List <DataType>() : dataTypeManger.GetUnitOfWork().GetReadOnlyRepository <DataType>().Query().Where(p => newDataTypeIds.Contains(p.Id)).ToList(); List <DataType> tobeAddedDataTypes = newDataTypes.Except(existingDataTypes).ToList(); if (tobeAddedDataTypes != null && tobeAddedDataTypes.Count > 0) { unitManager.AddAssociatedDataType(unit, tobeAddedDataTypes); } existingDataTypes = unit.AssociatedDataTypes.ToList(); List <DataType> toBeRemoved = existingDataTypes.Except(newDataTypes).ToList(); if (toBeRemoved != null && toBeRemoved.Count() > 0) { unitManager.RemoveAssociatedDataType(unit, toBeRemoved); } return(unit.AssociatedDataTypes.ToList()); } finally { dataTypeManger.Dispose(); } } return(null); }
/// <summary> /// Loads DataRow for BasicForm with data from FormFieldInfo settings and optionally with form control's default values. /// </summary> /// <param name="loadDefaultValues">Indicates if data container should be initialized with form control's default data</param> private DataRowContainer GetData(bool loadDefaultValues) { DataRowContainer result = new DataRowContainer(FormInfo.GetDataRow(loadDefaultValues)); if (loadDefaultValues) { // Load default values for visible properties (values of hidden form control properties shouldn't be stored in form definition) FormInfo.LoadDefaultValues(result, FormResolveTypeEnum.None, true); } if (Settings != null) { // Load settings of the existing field foreach (string columnName in Settings.Keys) { if (result.ContainsColumn(columnName)) { object value = Settings[columnName]; var settingField = FormInfo.GetFormField(columnName); if (!String.IsNullOrEmpty(Convert.ToString(value)) && IsDataTypeValid(value, settingField)) { result[columnName] = DataTypeManager.ConvertToSystemType(TypeEnum.Field, settingField.DataType, value, SystemContext.EnglishCulture); } } } } return(result); }
protected TLeafElement ReadLeaf(ExcelWorksheet sheet, int row, string parentKeyPath) { string leafName = sheet.Cells[row, Configuration.DataNameColumn].Value?.ToString().Trim(); if (string.IsNullOrEmpty(leafName)) { return(null); } TLeafElement leaf = new TLeafElement() { Name = leafName, Description = sheet.Cells[row, Configuration.DataDescriptionColumn].Value?.ToString().Trim(), Guid = GuidHelper.Create(Configuration.Guid_CompatibilityMode ? GuidHelper.LegacyGuids.DnsNamespace : LeafTypeGuid, (UseParentKeyInLeafGuid ? parentKeyPath + "++" : "") + leafName, false).ToString(), BaseType = sheet.Cells[row, Configuration.BaseTypeColumn].Value?.ToString().Trim(), Type = sheet.Cells[row, Configuration.DataTypeColumn].Value?.ToString().Trim().ToLower(), }; ReadLeafProperties(leaf, sheet, row); try { if (leaf.BaseType is null && !string.IsNullOrEmpty(leaf.Type)) { DataTypeManager.SetDataType(leaf.Type, leaf); SetLengthAndDecimals(sheet, row, leaf); } } catch (Exception ex) { Console.WriteLine("Error parsing Data Type for row " + row); HandleException(sheet.Name, ex); } return(leaf); }
public async Task <bool> WriteNodeValueAsync(string serverUrl, VariableNode variableNode, VariableState state) { Session session = await GetSessionAsync(serverUrl); var typeManager = new DataTypeManager(session); WriteValueCollection writeValues = new WriteValueCollection(); WriteValue writeValue = new WriteValue { NodeId = variableNode.NodeId, AttributeId = Attributes.Value, Value = typeManager.GetDataValueFromVariableState(state, variableNode) }; writeValues.Add(writeValue); session.Write(null, writeValues, out var results, out _); if (!StatusCode.IsGood(results[0])) { if (results[0] == StatusCodes.BadTypeMismatch) { throw new ValueToWriteTypeException("Wrong Type Error: data sent are not of the type expected. Check your data and try again"); } throw new ValueToWriteTypeException(results[0].ToString()); } return(true); }
// create read units in bpp public void CreateUnits(ref DataTable mappedUnits) { UnitManager unitManager = null; DataTypeManager dataTypeManger = null; try { // Javad: The whole loop can be improved! var dimentionRepo = unitManager.GetUnitOfWork().GetReadOnlyRepository <Dimension>(); foreach (DataRow mapUnitsRow in mappedUnits.Rows) { unitManager = new UnitManager(); dataTypeManger = new DataTypeManager(); Unit unit = new Unit(); // Javad: this can not be out of the loop. in that case, it keeps its link to the session objects and causes the previous unit to be overriden as well as creating a new one!! // values of the unit unit.Name = mapUnitsRow["Name"].ToString(); unit.Abbreviation = mapUnitsRow["Abbreviation"].ToString(); unit.Description = mapUnitsRow["Description"].ToString(); if (unit.Description.Length > 255) { unit.Description = unit.Description.Substring(0, 255); } unit.Dimension = dimentionRepo.Get(Convert.ToInt64(mapUnitsRow["DimensionId"])); // find measurement system foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem))) { if (msCheck.ToString().Equals(mapUnitsRow["MeasurementSystem"].ToString())) { unit.MeasurementSystem = msCheck; } } // set data type to created unit or add data type to existing unit List <string> Types = mapUnitsRow["DataTypes"].ToString().Split(' ').Distinct().ToList(); // get existing unit or create Unit existU = unitManager.Repo.Get(u => u.Name.ToLower().Equals(unit.Name.ToLower())).FirstOrDefault(); if (existU == null) { unit = unitManager.Create(unit.Name, unit.Abbreviation, unit.Description, unit.Dimension, unit.MeasurementSystem); addDataTypes(unit.Id, Types, unitManager, dataTypeManger); } else { addDataTypes(existU.Id, Types, unitManager, dataTypeManger); } // add unit-ID to the mappedUnits Table mapUnitsRow["UnitId"] = unit.Id; } } finally { unitManager.Dispose(); dataTypeManger.Dispose(); } }
protected ADataManager(ApplicationSettings applicationSettings, WebSettings webSettings, ActionManager <TArachnodeDAO> actionManager, DataTypeManager <TArachnodeDAO> dataTypeManager, DiscoveryManager <TArachnodeDAO> discoveryManager, RuleManager <TArachnodeDAO> ruleManager, IArachnodeDAO arachnodeDAO) : base(applicationSettings, webSettings) { _dataTypeManager = dataTypeManager; _discoveryManager = discoveryManager; _ruleManager = ruleManager; _actionManager = actionManager; _arachnodeDAO = arachnodeDAO; }
public ColumnTranslator(DbInterpreter sourceInterpreter, DbInterpreter targetInterpreter, List <TableColumn> columns) : base(sourceInterpreter, targetInterpreter) { this.columns = columns; this.sourceDbType = sourceInterpreter.DatabaseType; this.targetDbType = targetInterpreter.DatabaseType; this.sourceDataTypeSpecs = DataTypeManager.GetDataTypeSpecifications(this.sourceDbType); this.targetDataTypeSpecs = DataTypeManager.GetDataTypeSpecifications(this.targetDbType); }
public async Task <UaValue> ReadUaValueAsync(string serverUrl, VariableNode variableNode) { Session session = await GetSessionAsync(serverUrl); var typeManager = new DataTypeManager(session); return(typeManager.GetUaValue(variableNode)); }
public DataAttributeModel(DataAttribute dataAttribute, bool showConstraints = false) { Id = dataAttribute.Id; Name = dataAttribute.Name; ShortName = dataAttribute.ShortName; Description = dataAttribute.Description; ShowConstraints = showConstraints; DataType = new DataTypeItemModel(dataAttribute.DataType); Unit = new UnitItemModel(dataAttribute.Unit); try { dataTypeManager = new DataTypeManager(); unitManager = new UnitManager(); dataTypeManager.Repo.Get().OrderBy(dt => dt.Name).ToList().ForEach(dt => DataTypes.Add(new DataTypeItemModel(dt))); unitManager.Repo.Get().OrderBy(u => u.Name).ToList().ForEach(u => Units.Add(new UnitItemModel(u))); } finally { dataTypeManager.Dispose(); unitManager.Dispose(); } RangeConstraints = new List <RangeConstraintModel>(); DomainConstraints = new List <DomainConstraintModel>(); PatternConstraints = new List <PatternConstraintModel>(); dataAttribute.Constraints.ToList().Where(c => c.GetType().Equals(typeof(RangeConstraint))).ToList().ForEach(rc => RangeConstraints.Add(RangeConstraintModel.Convert((RangeConstraint)rc, Id))); dataAttribute.Constraints.ToList().Where(c => c.GetType().Equals(typeof(PatternConstraint))).ToList().ForEach(pc => PatternConstraints.Add(PatternConstraintModel.Convert((PatternConstraint)pc, Id))); dataAttribute.Constraints.ToList().Where(c => c.GetType().Equals(typeof(DomainConstraint))).ToList().ForEach(dc => DomainConstraints.Add(DomainConstraintModel.Convert((DomainConstraint)dc, Id))); if (dataAttribute.UsagesAsVariable != null && dataAttribute.UsagesAsVariable.Count > 0) { InUse = true; } if (dataAttribute.Constraints.Count > 0) { foreach (Constraint c in dataAttribute.Constraints) { if (c is RangeConstraint) { RangeConstraints.Add(RangeConstraintModel.Convert((RangeConstraint)c, Id)); } if (c is PatternConstraint) { PatternConstraints.Add(PatternConstraintModel.Convert((PatternConstraint)c, Id)); } if (c is DomainConstraint) { DomainConstraints.Add(DomainConstraintModel.Convert((DomainConstraint)c, Id)); } } } }
/// <summary> /// Show default value control and required control according to attribute type. /// </summary> public void ShowDefaultControl() { plcDefaultValue.Visible = true; SetFieldForTranslations(); SetReferenceToField(); var dataType = DataTypeManager.GetDataType(TypeEnum.Field, AttributeType); HandleRequiredVisibility(dataType); // Hide all default value controls first txtDefaultValue.Visible = false; chkDefaultValue.Visible = false; rbDefaultValue.Visible = false; txtLargeDefaultValue.Visible = false; datetimeDefaultValue.Visible = false; if ((dataType != null) && dataType.HasConfigurableDefaultValue) { var systemType = dataType.Type; // Date and time types if (systemType == typeof(DateTime)) { // Use date time picker for date and time types datetimeDefaultValue.Visible = true; var calendarControl = ((FormEngineUserControl)datetimeDefaultValue.NestedControl); lblDefaultValue.AssociatedControlClientID = EditingFormControl.GetInputClientID(calendarControl.Controls); } else if (systemType == typeof(bool)) { // Use checkbox or radio button for boolean types chkDefaultValue.Visible = !AllowEmpty; rbDefaultValue.Visible = AllowEmpty; lblDefaultValue.AssociatedControlClientID = AllowEmpty ? EditingFormControl.GetInputClientID(rbDefaultValue.NestedControl.Controls) : EditingFormControl.GetInputClientID(chkDefaultValue.NestedControl.Controls); } else if (AttributeType == FieldDataType.LongText) { // Special case for long text to provide rich editor txtLargeDefaultValue.Visible = true; lblDefaultValue.AssociatedControlClientID = EditingFormControl.GetInputClientID(txtLargeDefaultValue.NestedControl.Controls); } else { // Use textbox for other types txtDefaultValue.Visible = true; lblDefaultValue.AssociatedControlClientID = EditingFormControl.GetInputClientID(txtDefaultValue.NestedControl.Controls); } } else { // Hide default value for types without default value plcDefaultValue.Visible = false; } }
/// <summary> /// Initializes all builders by creating a cache of pre-built properties /// for ValueTypes. This should be called after any DataTypeExtensions have /// been loaded and MUST be called before NitroCast runs. /// </summary> public static void RefreshCache() { typeCache.Clear(); foreach (KeyValuePair <string, ValueTypeBuilder> builder in builders) { ValueTypeCollection valueTypes = DataTypeManager.Make(builder.Value); typeCache.Add(builder.Value, valueTypes); } }
/// <summary> /// Reload data. /// </summary> /// <param name="setAutomatically">Indicates whether search options should be set automatically</param> public void ReloadSearch(bool setAutomatically) { ClassFields.ItemID = ItemID; ClassFields.ReloadData(setAutomatically, true); // Initialize properties List <IDataDefinitionItem> itemList = null; if (ClassInfo != null) { // Load XML definition fi = FormHelper.GetFormInfo(ClassInfo.ClassName, true); if (CMSString.Compare(ClassInfo.ClassName, "cms.user", true) == 0) { plcImage.Visible = false; ClassFields.DisplaySetAutomatically = false; pnlIndent.Visible = true; document = DataClassInfoProvider.GetDataClassInfo("cms.usersettings"); if (document != null) { FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true); fi.CombineWithForm(fiSettings, true, String.Empty); } } // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { if (itemList.Any()) { pnlIndent.Visible = true; } // Store each field to array foreach (var item in itemList) { var formField = item as FormFieldInfo; if (formField != null) { object[] obj = { formField.Name, DataTypeManager.GetSystemType(TypeEnum.Field, formField.DataType) }; attributes.Add(obj); } } } if (AdvancedMode) { ReloadControls(); } }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { // Return form name or ID according to type of field (if no field specified form name is returned) if ((FieldInfo != null) && DataTypeManager.IsInteger(TypeEnum.Field, FieldInfo.DataType)) { object value = uniSelector.Value; uniSelector.SelectionMode = SelectionModeEnum.SingleDropDownList; uniSelector.AllowEmpty = true; uniSelector.Value = value; ShowGroupPolls = true; } else { uniSelector.OnSelectionChanged += new EventHandler(uniSelector_OnSelectionChanged); } uniSelector.IsLiveSite = IsLiveSite; uniSelector.ReturnColumnName = "PollID"; // Check if running in group poll webpart if (IsGroupPollWidget() || IsGroupPollWebpart()) { // Restrict list to current group int groupId = QueryHelper.GetInteger("groupid", 0); if ((groupId == 0) && (DocumentContext.CurrentPageInfo != null)) { groupId = DocumentContext.CurrentPageInfo.NodeGroupID; } string where = "PollGroupID=" + groupId; uniSelector.WhereCondition = SqlHelper.AddWhereCondition(uniSelector.WhereCondition, where); uniSelector.ObjectType = PollInfo.OBJECT_TYPE_GROUP; } else { if (ShowSiteFilter && AllowGlobalPolls) { // Init site filter uniSelector.FilterControl = "~/CMSModules/Polls/Controls/Filters/SiteSelector.ascx"; } // Set selector WHERE condition according to user permissions int siteId = SiteContext.CurrentSiteID; string where = null; if (!ShowGroupPolls) { where = "PollGroupID IS NULL"; } where = SqlHelper.AddWhereCondition(where, "PollSiteID=" + siteId); if (AllowGlobalPolls) { where = SqlHelper.AddWhereCondition(where, "PollSiteID IS NULL AND PollID IN (SELECT PollID FROM Polls_PollSite WHERE SiteID=" + siteId + ")", "OR"); } uniSelector.WhereCondition = SqlHelper.AddWhereCondition(uniSelector.WhereCondition, where); } }
/// <summary> /// Visible or hides size attribute. /// </summary> public void EnableOrDisableAttributeSize() { var fieldType = AttributeType; // Check if data type has variable size var dataType = DataTypeManager.GetDataType(TypeEnum.Field, fieldType); if ((dataType != null) && dataType.VariableSize) { if (IsSystemFieldSelected) { plcAttributeSize.Visible = false; } else { plcAttributeSize.Visible = true; // Set default size for new field if ((IsNewItemEdited || String.IsNullOrEmpty(txtAttributeSize.Text)) && (dataType.DefaultSize > 0)) { txtAttributeSize.Text = dataType.DefaultSize.ToString(); } } } else { plcAttributeSize.Visible = false; txtAttributeSize.Text = String.Empty; } if ((dataType != null) && dataType.VariablePrecision) { if (IsSystemFieldSelected) { plcAttributePrecision.Visible = false; } else { plcAttributePrecision.Visible = true; // Set default precision for new field if ((IsNewItemEdited || String.IsNullOrEmpty(txtAttributePrecision.Text)) && (dataType.DefaultPrecision > 0)) { txtAttributePrecision.Text = dataType.DefaultPrecision.ToString(); } } } else { plcAttributePrecision.Visible = false; txtAttributePrecision.Text = String.Empty; } }
/// <summary> /// Processes a FilesRow after crawling. /// </summary> /// <param name = "filesRow">The files row.</param> /// <param name="webClient"></param> /// <param name="actionManager"></param> /// <param name="consoleManager"></param> /// <param name="discoveryManager"></param> /// <param name = "fileManager">The file manager.</param> /// <param name = "fileManager">The file manager.</param> /// <param name="memoryManager"></param> /// <param name="ruleManager"></param> /// <param name = "arachnodeDAO">The arachnode DAO.</param> /// <param name = "imageManager">The image manager.</param> public static void ProcessFile(ApplicationSettings applicationSettings, WebSettings webSettings, Crawler <TArachnodeDAO> crawler, ArachnodeDataSet.FilesRow filesRow, WebClient <TArachnodeDAO> webClient, Cache <TArachnodeDAO> cache, ActionManager <TArachnodeDAO> actionManager, ConsoleManager <TArachnodeDAO> consoleManager, CrawlerPeerManager <TArachnodeDAO> crawlerPeerManager, DiscoveryManager <TArachnodeDAO> discoveryManager, FileManager <TArachnodeDAO> fileManager, MemoryManager <TArachnodeDAO> memoryManager, RuleManager <TArachnodeDAO> ruleManager, IArachnodeDAO arachnodeDAO) { CacheManager <TArachnodeDAO> cacheManager = new CacheManager <TArachnodeDAO>(applicationSettings, webSettings); CookieManager cookieManager = new CookieManager();; CrawlRequestManager <TArachnodeDAO> crawlRequestManager = new CrawlRequestManager <TArachnodeDAO>(applicationSettings, webSettings, cache, consoleManager, discoveryManager); DataTypeManager <TArachnodeDAO> dataTypeManager = new DataTypeManager <TArachnodeDAO>(applicationSettings, webSettings); EncodingManager <TArachnodeDAO> encodingManager = new EncodingManager <TArachnodeDAO>(applicationSettings, webSettings); PolitenessManager <TArachnodeDAO> politenessManager = new PolitenessManager <TArachnodeDAO>(applicationSettings, webSettings, cache); ProxyManager <TArachnodeDAO> proxyManager = new ProxyManager <TArachnodeDAO>(applicationSettings, webSettings, consoleManager); HtmlManager <TArachnodeDAO> htmlManager = new HtmlManager <TArachnodeDAO>(applicationSettings, webSettings, discoveryManager); Crawl <TArachnodeDAO> crawl = new Crawl <TArachnodeDAO>(applicationSettings, webSettings, crawler, actionManager, consoleManager, cookieManager, crawlRequestManager, dataTypeManager, discoveryManager, encodingManager, htmlManager, politenessManager, proxyManager, ruleManager, true); //create a CrawlRequest as this is what the internals of SiteCrawler.dll expect to operate on... CrawlRequest <TArachnodeDAO> crawlRequest = new CrawlRequest <TArachnodeDAO>(new Discovery <TArachnodeDAO>(filesRow.AbsoluteUri), 1, UriClassificationType.Host, UriClassificationType.Host, 0, RenderType.None, RenderType.None); crawlRequest.Crawl = crawl; crawlRequest.Discovery.DiscoveryType = DiscoveryType.File; crawlRequest.Discovery.ID = filesRow.ID; crawlRequest.Data = filesRow.Source; crawlRequest.ProcessData = true; crawlRequest.WebClient = webClient; crawlRequest.WebClient.HttpWebResponse.Headers.Clear(); //parse the ResponseHeaders from the FilesRow.ResponseHeaders string... foreach (string responseHeader in filesRow.ResponseHeaders.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { string[] responseHeaderSplit = responseHeader.Split(":".ToCharArray()); string name = responseHeaderSplit[0]; string value = UserDefinedFunctions.ExtractResponseHeader(filesRow.ResponseHeaders, name, true).Value; crawlRequest.WebClient.HttpWebResponse.Headers.Add(name, value); } //refresh the DataTypes in the DataTypeManager... (if necessary)... if (dataTypeManager.AllowedDataTypes.Count == 0) { dataTypeManager.RefreshDataTypes(); } crawlRequest.DataType = dataTypeManager.DetermineDataType(crawlRequest); if (applicationSettings.InsertFiles) { crawlRequest.Discovery.ID = arachnodeDAO.InsertFile(crawlRequest.Parent.Uri.AbsoluteUri, crawlRequest.Discovery.Uri.AbsoluteUri, crawlRequest.WebClient.HttpWebResponse.Headers.ToString(), applicationSettings.InsertFileSource ? crawlRequest.Data : new byte[] { }, crawlRequest.DataType.FullTextIndexType, applicationSettings.ClassifyAbsoluteUris); } crawlRequest.ManagedDiscovery = fileManager.ManageFile(crawlRequest, crawlRequest.Discovery.ID.Value, crawlRequest.Discovery.Uri.AbsoluteUri, crawlRequest.Data, crawlRequest.DataType.FullTextIndexType, applicationSettings.ExtractFileMetaData, applicationSettings.InsertFileMetaData, applicationSettings.SaveDiscoveredFilesToDisk); actionManager.PerformCrawlActions(crawlRequest, CrawlActionType.PostRequest, arachnodeDAO); discoveryManager.CloseAndDisposeManagedDiscovery(crawlRequest, arachnodeDAO); }
public DataSaver(GitDBSettings settings, DataTypeManager typeManager, DataIdManager idManager, DataPreparer preparer, DataLinker linker, DataChecker checker, Gitter gitter) : base(settings) { Settings = settings; IdManager = idManager; TypeManager = typeManager; Preparer = preparer; Checker = checker; Linker = linker; Gitter = gitter; Namer = new FileNamer (settings.Location); }
/// <summary> /// Fill attribute types list. /// </summary> /// <param name="selectedType">Type that will be selected after loading the list.</param> private void LoadAndSelectAttributeType(string selectedType = FieldDataType.Text) { var objectType = DataClassInfo.OBJECT_TYPE; // Get object type based on class name var dci = DataClassInfoProvider.GetDataClassInfo(ClassName); if (dci != null) { objectType = dci.TypeInfo.ObjectType; } var types = DataTypeManager.GetFieldTypes(objectType).ToHashSetCollection(); // Remove file type for these objects switch (Mode) { case FieldEditorModeEnum.ClassFormDefinition: case FieldEditorModeEnum.AlternativeClassFormDefinition: if (!IsDocumentType) { types.Remove(FieldDataType.File); } break; case FieldEditorModeEnum.WebPartProperties: case FieldEditorModeEnum.CustomTable: case FieldEditorModeEnum.SystemTable: case FieldEditorModeEnum.FormControls: case FieldEditorModeEnum.ProcessActions: case FieldEditorModeEnum.Widget: case FieldEditorModeEnum.AlternativeCustomTable: case FieldEditorModeEnum.AlternativeSystemTable: case FieldEditorModeEnum.InheritedFormControl: case FieldEditorModeEnum.EmailWidget: types.Remove(FieldDataType.File); break; } // Ensure selected type types.Add(selectedType); drpAttributeType.DataSource = types .Select(type => new ListItem(ResHelper.GetString($"TemplateDesigner.FieldTypes.{type}"), type)) .OrderBy(x => x.Text); drpAttributeType.DataBind(); if (drpAttributeType.Items.Count > 0) { drpAttributeType.SelectedValue = selectedType; } }
private void deleteClass(object sender, System.EventArgs e) { TreeNode selectedNode; ModelFolder parentFolder; ModelClass deleteClass; ModelClass scanClass; parentFolder = null; selectedNode = modelTree.SelectedNode; if (selectedNode.Tag is ModelClass) { // Check to make sure there are no immediate dependencies // otherwise display error. Also find the entry's parent // folder if the class can be deleted. deleteClass = (ModelClass)selectedNode.Tag; foreach (ModelFolder folder in model.Folders) { foreach (object i in folder.Items) { if (i is ModelClass) { scanClass = (ModelClass)i; if (deleteClass == scanClass) { parentFolder = folder; } foreach (ReferenceField child in scanClass.ReferenceFields) { if (child.ReferenceType.ParentClassEntry == deleteClass) { return; } } } } } // Since the loop completed, that means there // were not references found. Delete the class. if (parentFolder != null) { parentFolder.Items.Remove(deleteClass); DataTypeManager.DeleteDataType(deleteClass); refreshTree(); } } }
/// <summary> /// Returns WHERE condition for selected form. /// </summary> public override string GetWhereCondition() { // Return correct WHERE condition for integer if none value is selected if ((FieldInfo != null) && DataTypeManager.IsInteger(TypeEnum.Field, FieldInfo.DataType)) { int id = ValidationHelper.GetInteger(usGroups.Value, 0); if (id > 0) { return(base.GetWhereCondition()); } } return(null); }
/// <summary> /// Schedules mail-out of the issue to the future. /// </summary> private bool SendScheduled() { if (DataTypeManager.IsValidDate(calendarControl.SelectedDateTime)) { RemovePreviousTaskAndSendIssue(calendarControl.SelectedDateTime); } else { ErrorMessage = GetString("newsletter.incorrectdate"); } return(String.IsNullOrEmpty(ErrorMessage)); }
public ActionResult _getDataTypes(long unitId) { List <ItemStruct> DataTypes = new List <ItemStruct>(); UnitManager um = null; try { um = new UnitManager(); Unit unit = um.Repo.Get(unitId); if (unit.Name.ToLower() != "none") { foreach (DataType dt in unit.AssociatedDataTypes) { DataTypes.Add(new ItemStruct() { Name = dt.Name, Id = dt.Id, Description = dt.Description }); } return(PartialView("_dropdown", DataTypes.OrderBy(dt => dt.Name).ToList())); } else { DataTypeManager dtm = null; try { dtm = new DataTypeManager(); foreach (DataType dt in dtm.Repo.Get()) { DataTypes.Add(new ItemStruct() { Name = dt.Name, Id = dt.Id, Description = dt.Description }); } return(PartialView("_dropdown", DataTypes.OrderBy(dt => dt.Name).ToList())); } finally { dtm.Dispose(); } } } finally { um.Dispose(); } }
public void Test_Add() { var context = GetMockGitDB (); var typeManager = new DataTypeManager (context.Settings, context.Gitter); var exampleType = typeof(ExampleArticle); typeManager.Add (exampleType); var filePath = context.Settings.Location.GetPath (typeManager.TypesFileName); var typesString = File.ReadAllText(filePath); var expectedTypesString = exampleType.FullName + typeManager.TypeNamesParser.PairSeparator + exampleType.FullName + ", " + exampleType.Assembly.GetName().Name; Assert.AreEqual (expectedTypesString, typesString); }
public void Test_GetType() { var context = GetTestContext (); var typeManager = new DataTypeManager (context.Keys, context.DataClient); var exampleType = typeof(ExampleArticle); var typesString = exampleType.Name + typeManager.PairSeparator + exampleType.AssemblyQualifiedName; var key = context.Settings.Prefix + "-Types"; context.DataClient.Data [key] = typesString; var type = typeManager.GetType (exampleType.Name); Assert.IsNotNull (type); Assert.AreEqual (exampleType, type); }
public void Test_GetType() { var context = GetMockGitDB (); var typeManager = new DataTypeManager (context.Settings, context.Gitter); var exampleType = typeof(ExampleArticle); var typesString = exampleType.Name + typeManager.TypeNamesParser.PairSeparator + exampleType.FullName + ", " + exampleType.Assembly.GetName().Name; var filePath = context.Settings.Location.GetPath (typeManager.TypesFileName); File.WriteAllText(filePath, typesString); var type = typeManager.GetType (exampleType.Name); Assert.IsNotNull (type); Assert.AreEqual (exampleType, type); }
public void Test_Add() { var context = GetTestContext (); var typeManager = new DataTypeManager (context.Keys, context.DataClient); var exampleType = typeof(ExampleArticle); typeManager.Add (exampleType); var data = context.DataClient.Data; var key = context.Settings.Prefix + "-Types"; var typesString = data [key]; var expectedTypesString = exampleType.Name + typeManager.PairSeparator + exampleType.AssemblyQualifiedName; Assert.AreEqual (expectedTypesString, typesString); }
public TestContext() { DataClient = new MockRedisClientWrapper (); Settings = new DataManagerSettings (); Settings.IsVerbose = true; Keys = new DataKeys (Settings); IdManager = new DataIdManager (Keys, DataClient); TypeManager = new DataTypeManager (Keys, DataClient); EntityLinker = new EntityLinker (); var preparer = new DataPreparer (DataClient); Preparer = preparer; var reader = new DataReader (TypeManager, IdManager, Keys, DataClient); Reader = reader; var checker = new DataChecker (reader, Settings); Checker = checker; var saver = new DataSaver (Settings, TypeManager, IdManager, Keys, preparer, null, checker, DataClient); // The linker argument is null because it needs to be set after it's created below Saver = saver; var updater = new DataUpdater (Settings, Keys, null, preparer, checker, DataClient); // The linker argument is null because it needs to be set after it's created below Updater = updater; var linker = new DataLinker (Settings, reader, saver, updater, checker, EntityLinker); Linker = linker; // TODO: Is there a way to avoid this messy hack? // Make sure the linker is set to the saver and updater saver.Linker = linker; updater.Linker = linker; }
public void Test_GetTypes() { var context = GetTestContext (); var typeManager = new DataTypeManager (context.Keys, context.DataClient); var exampleType = typeof(ExampleArticle); var typesString = exampleType.Name + typeManager.PairSeparator + exampleType.AssemblyQualifiedName; var key = context.Settings.Prefix + "-Types"; context.DataClient.Data [key] = typesString; var types = typeManager.GetTypes(); Assert.AreEqual (1, types.Count); Assert.IsTrue (types.ContainsKey (exampleType.Name)); var fullTypeName = types [exampleType.Name]; Assert.AreEqual (exampleType.AssemblyQualifiedName, fullTypeName); }