/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un FormMenuItem en un FormMenuItemWpf para ser usado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <returns></returns> public static FormMenuItemWpf ConvertEntityToFormMenuItem(ComponentEntity componentEntity) { FormMenuItemWpf formMenuItem = new FormMenuItemWpf(componentEntity.Text, componentEntity.StringHelp, (FontName)componentEntity.FontName); formMenuItem.Bold = componentEntity.Bold; formMenuItem.HelpText = componentEntity.StringHelp; formMenuItem.Width = componentEntity.Width; formMenuItem.Height = componentEntity.Height; formMenuItem.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, formMenuItem); if (componentEntity.InputDataContext != null) { formMenuItem.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); } if (componentEntity.OutputDataContext != null) { formMenuItem.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); } formMenuItem.FontColor = componentEntity.FontColor; formMenuItem.FontName = (FontName)componentEntity.FontName; formMenuItem.Text = componentEntity.Text; formMenuItem.TextAlign = (TextAlign)componentEntity.TextAlign; formMenuItem.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; formMenuItem.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; formMenuItem.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; formMenuItem.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; return(formMenuItem); }
private static void IndexComponentEntity(ComponentEntity componentEntity, Dictionary <int, ConnectionWidgetEntity> connectionWidgetDictionary, Dictionary <int, ComponentEntity> componentDictionary, Dictionary <int, ConnectionPointEntity> connectionPointDictionary, Dictionary <int, TableEntity> tableDictionary, Dictionary <int, FieldEntity> fieldDictionary) { AddDictionary(componentDictionary, componentEntity.Id, componentEntity); if (componentEntity.MenuItems != null) { foreach (ComponentEntity menuItem in componentEntity.MenuItems) { IndexComponentEntity(menuItem, connectionWidgetDictionary, componentDictionary, connectionPointDictionary, tableDictionary, fieldDictionary); } } if (componentEntity.InputConnectionPoint != null) { AddDictionary(connectionPointDictionary, componentEntity.InputConnectionPoint.Id, componentEntity.InputConnectionPoint); } if (componentEntity.OutputConnectionPoint != null) { AddDictionary(connectionPointDictionary, componentEntity.OutputConnectionPoint.Id, componentEntity.OutputConnectionPoint); } // Template if (componentEntity.TemplateListFormDocument != null) { IndexItems(componentEntity.TemplateListFormDocument, connectionWidgetDictionary, componentDictionary, connectionPointDictionary, tableDictionary, fieldDictionary); } }
/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un EnterSingleDataForm en un EnterSingleDataFormWpf para ser usado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <returns></returns> public static EnterSingleDataFormWpf ConvertEntityToEnterSingleData(ComponentEntity componentEntity) { EnterSingleDataFormWpf enterSingleDataFormWpf = new EnterSingleDataFormWpf(); enterSingleDataFormWpf.BackgroundColor = componentEntity.BackgroundColor; enterSingleDataFormWpf.Height = componentEntity.Height; enterSingleDataFormWpf.Width = componentEntity.Width; enterSingleDataFormWpf.InputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, enterSingleDataFormWpf); enterSingleDataFormWpf.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, enterSingleDataFormWpf);; enterSingleDataFormWpf.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); enterSingleDataFormWpf.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); // enterSingleDataForm.IsListGiver = componentEntity.IsListGiver; //enterSingleDataForm.IsRegisterGiver = componentEntity.IsRegisterGiver; enterSingleDataFormWpf.DataType = (DataType)componentEntity.DataTypes; // Recupero el DataName de ComponentEntity.Text para reutilizar este atributo y no agregar otro en el componentEntity llamado "DataName". enterSingleDataFormWpf.DataName = componentEntity.Text; enterSingleDataFormWpf.StringHelp = componentEntity.StringHelp; enterSingleDataFormWpf.DescriptiveText = componentEntity.DescriptiveText; enterSingleDataFormWpf.Title = componentEntity.Title; enterSingleDataFormWpf.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; enterSingleDataFormWpf.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; enterSingleDataFormWpf.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; enterSingleDataFormWpf.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; return(enterSingleDataFormWpf); }
/// <summary> /// Obtener una lista de Número de registro/cantidad de clicks. /// </summary> /// <param name="ListFormComponent">El componente ListForm para el cual generar la estadística.</param> /// <param name="session">El identificador de sesión del cliente móvil.</param> /// <returns>Un lista de pares nombre/valor.</returns> public List <DictionaryEntry> GetRegistersClickAmount(ComponentEntity listFormComponent, string session) { List <UserActionEntity> userActionsPartial = new List <UserActionEntity>(new UserActionDataAccess().LoadWhere(UserActionEntity.DBIdComponent, listFormComponent.Id, false, OperatorType.Equal)); Dictionary <int, DictionaryEntry> registerClickAmount = new Dictionary <int, DictionaryEntry>(); foreach (UserActionEntity uae in userActionsPartial) { if (uae.ActionType == 3) { DictionaryEntry nameValue; // Grupo de servicios if (registerClickAmount.TryGetValue((int)uae.IdRegister, out nameValue)) { nameValue.Value = (int)nameValue.Value + 1; registerClickAmount[(int)uae.IdRegister] = nameValue; } else { nameValue = new DictionaryEntry(); nameValue.Key = uae.IdRegister.ToString(CultureInfo.InvariantCulture); nameValue.Value = 1; registerClickAmount.Add((int)uae.IdRegister, nameValue); } } } List <DictionaryEntry> listOfServiceAccesses = new List <DictionaryEntry>(registerClickAmount.Values); return(listOfServiceAccesses); }
/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un MenuForm en un MenuFormWpf para ser usado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <returns></returns> public static MenuFormWpf ConvertEntityToMenuForm(ComponentEntity componentEntity) { MenuFormWpf menuFromWpf = new MenuFormWpf(); menuFromWpf.BackgroundColor = componentEntity.BackgroundColor; menuFromWpf.Height = componentEntity.Height; menuFromWpf.Width = componentEntity.Width; menuFromWpf.InputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, menuFromWpf); menuFromWpf.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, menuFromWpf); if (componentEntity.InputDataContext != null) { menuFromWpf.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); } if (componentEntity.OutputDataContext != null) { menuFromWpf.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); } // menuFrom.IsListGiver = componentEntity.IsListGiver; //menuFrom.IsRegisterGiver = componentEntity.IsRegisterGiver; menuFromWpf.StringHelp = componentEntity.StringHelp; menuFromWpf.Title = componentEntity.Title; menuFromWpf.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; menuFromWpf.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; menuFromWpf.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; menuFromWpf.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; foreach (ComponentEntity formMenuItemEntity in componentEntity.MenuItems) { FormMenuItemWpf formMenuItem = ConvertEntityToFormMenuItem(formMenuItemEntity); formMenuItem.Parent = menuFromWpf; menuFromWpf.AddMenuItem(formMenuItem); } return(menuFromWpf); }
/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un DataSource en un DataSourceWpf para ser usado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <param name="dataModel">modelo de datos</param> /// <returns></returns> public static DataSourceWpf ConvertEntityToDataSource(ComponentEntity componentEntity, DataModel dataModel) { DataSourceWpf dataSourceWpf = new DataSourceWpf(new Table("Stub")); // dataSource.AssociateTable(ConvertEntityToTable(componentEntity.RelatedTable)); dataSourceWpf.RelatedTable = dataModel.GetTable(componentEntity.RelatedTable.Name); dataSourceWpf.Height = componentEntity.Height; dataSourceWpf.Width = componentEntity.Width; dataSourceWpf.InputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, dataSourceWpf); dataSourceWpf.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); dataSourceWpf.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, dataSourceWpf); dataSourceWpf.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); dataSourceWpf.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; dataSourceWpf.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; dataSourceWpf.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; dataSourceWpf.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; if (componentEntity.RelatedTable.IsStorage == false) { dataSourceWpf.FieldToOrder = dataSourceWpf.RelatedTable.GetField(componentEntity.FieldToOrder.Name); // dataSource.IsListGiver = componentEntity.IsListGiver; //dataSource.IsRegisterGiver = componentEntity.IsRegisterGiver; dataSourceWpf.TypeOrder = (OrderType)componentEntity.TypeOrder; } return(dataSourceWpf); }
/// <summary> /// Obtiene la URL para la imagen que representa el tipo del componente. /// </summary> /// <param name="component">El componente cuyo tipo se relaciona con la URL de búsqueda.</param> /// <returns>String con la URL imagen del tipo de componente.</returns> private string GetImageURL(ComponentEntity component) { string result = null; // Carga la cadena URL desde los recursos locales, según el tipo de componente. switch ((ComponentType)component.ComponentType) { case ComponentType.ListForm: result = GetLocalResourceObject("ListImageURL").ToString(); break; case ComponentType.MenuForm: result = GetLocalResourceObject("MenuImageURL").ToString(); break; case ComponentType.EnterSingleDataFrom: result = GetLocalResourceObject("EnterSingleDataImageURL").ToString(); break; case ComponentType.ShowDataForm: result = GetLocalResourceObject("ShowDataImageURL").ToString(); break; } return(result); }
public List <ComponentEntity> GetSelectedComponentsByModuleSubAuto(String moduleSubAutoList) { var result = new List <ComponentEntity>(); using (var dataEntities = new InfoTrakDataEntities()) { var moduleArray = moduleSubAutoList.Split(','); var components = from generalComponents in dataEntities.GENERAL_EQ_UNIT join comp in dataEntities.LU_COMPART on generalComponents.compartid_auto equals comp.compartid_auto //join equipment in dataEntities.EQUIPMENTs on generalComponents.equipmentid_auto equals equipment.equipmentid_auto join module in dataEntities.LU_Module_Sub on generalComponents.module_ucsub_auto equals module.Module_sub_auto join crsf in dataEntities.CRSFs on module.crsf_auto equals crsf.crsf_auto join cust in dataEntities.CUSTOMERs on crsf.customer_auto equals cust.customer_auto //join mmta in dataEntities.LU_MMTA on module.mmtaid_auto equals mmta.mmtaid_auto //join family in dataEntities.TYPEs on mmta.type_auto equals family.type_auto join model in dataEntities.MODELs on module.model_auto equals model.model_auto join compType in dataEntities.LU_COMPART_TYPE on comp.comparttype_auto equals compType.comparttype_auto join system in dataEntities.LU_SYSTEM on compType.system_auto equals system.system_auto where moduleArray.Contains(module.Module_sub_auto.ToString()) && (system.system_desc == "undercarriage" || system.system_desc == "U/C") orderby generalComponents.side, compType.sorder, generalComponents.pos select new { comp.compartid_auto, generalComponents.equnit_auto, comp.comparttype_auto, comp.compartid, comp.compart, compType.comparttype, generalComponents.side, generalComponents.pos, module.Module_sub_auto }; foreach (var component in components) { var newComponent = new ComponentEntity { ComponentId = component.equnit_auto, ComponentType = component.comparttype_auto, ComponentIdAuto = component.compartid_auto, PartNo = component.comparttype + ": " + component.compartid, ComponentName = component.compart, ComponentSide = (Convert.ToInt16(component.side) == 1) ? "Left" : "Right", ComponentPosition = (Convert.ToInt32(component.pos)), ComponentImage = GetComponentImage(component.comparttype_auto), DefaultTool = GetComponentDefaultTool(component.compartid_auto), ComponentMethod = GetComponentMethod(component.compartid_auto), ModuleSubAuto = component.Module_sub_auto, }; result.Add(newComponent); } } return(result); }
public static NetConnection GetConnection(this ComponentEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(entity.Components.Get <Component <NetConnection> >().Entity); }
public static Player GetPlayer(this ComponentEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(entity.Components.Get <Component <Player> >().Entity); }
private static string DataSource(ComponentEntity component) { // Reemplaza elementos de plantilla string tpl = DataSourcesItemTemplate; tpl = tpl.Replace("%NAME%", Utilities.GetValidIdentifier(component.RelatedTable.Name, false)); tpl = tpl.Replace("%STORAGE%", component.RelatedTable.IsStorage ? "true" : "false"); return(tpl); }
/// <summary> /// Constructor /// </summary> /// <param name="formEntity">ComponentEntity</param> /// <param name="form">Formulario involucrado</param> /// <param name="session">Identificador de sesión</param> /// <param name="parent">Canvas padre</param> public StatisticsWpf(ComponentEntity formEntity, IDrawAbleWpf form, string session, Canvas parent) : base() { this.form = form; this.formEntity = formEntity; this.canvasPath = "CanvasStatistics.xaml"; this.parent = parent; this.MakeCanvas(); ((TextBlock)myCanvas.FindName("textBlockComment")).Text = GenerateStatisticSummary(formEntity, session); }
private static string GetNameForComponent(ComponentEntity component, bool usedOnString) { if (String.IsNullOrEmpty(component.Title)) { return("Menu" + component.Id.ToString(NumberFormatInfo.InvariantInfo)); } else { return(Utilities.GetValidIdentifier(component.Title, usedOnString)); } }
private static void RecGet(ComponentEntity item, List <ComponentEntity> result, List <ComponentEntity> allControl) { var children = allControl.Where(o => o.ParentId.Equals(item.Id, StringComparison.OrdinalIgnoreCase)); if (!children.IsNullOrEmpty()) { foreach (var child in children) { result.Add(child); RecGet(child, result, allControl); } } }
private void InitializeComponentsTable() { foreach (var key in fakeComponents.Select(x => x.Category).Distinct()) { var batchOperation = new TableBatchOperation(); foreach (var component in fakeComponents.Where(x => x.Category == key)) { var dataObject = new ComponentEntity(component); batchOperation.Insert(dataObject); } table.ExecuteBatch(batchOperation); } }
/// <summary> /// Construye una cadena para escribir el resumen de las estadisticas para un componente. /// </summary> /// <param name="component">Componente sobre el cual se generara el resumen.</param> /// <param name="session">La cadena de sesión para acceder a los datos estadísticos.</param> /// <returns>Una cadena que representa el resumen de estadisticas para el componente.</returns> private string GenerateStatisticSummary(ComponentEntity component, string session) { StringBuilder resultString = new StringBuilder(); // Añade una cadena representando la cantidad de clientes que usaron el formulario. resultString.Append(GetLocalResourceObject("HowManyCustomersUsedForm").ToString() + ": "); resultString.AppendLine(ServicesClients.StatisticsAnalyzer.GetCustomerFormAccessAmount(component, session).ToString(CultureInfo.InvariantCulture)); resultString.AppendLine(); // Añade una cadena representando la cantidad de clics que accedieron al formulario. resultString.Append(GetLocalResourceObject("HowManyTimesUsedForm").ToString() + ": "); resultString.AppendLine(ServicesClients.StatisticsAnalyzer.GetFormAccessAmount(component, session).ToString(CultureInfo.InvariantCulture)); resultString.AppendLine(); switch ((ComponentType)component.ComponentType) { case (ComponentType.MenuForm): // Añade un parrafo representando la cantidad de clics por cada menu,en caso de que el formulario sea un menú. resultString.AppendLine(GetLocalResourceObject("HowManyTimesMenuWasUsed").ToString() + ":"); foreach (ComponentEntity menuEntity in component.MenuItems) { int count = ServicesClients.StatisticsAnalyzer.GetMenuItemAccessAmount(component, session); resultString.AppendLine(menuEntity.Text + " -> " + count); } resultString.AppendLine(); break; case (ComponentType.ListForm): // Añade un párrafo representando la cantidad de clics por cada ítem, en caso que el formulario sea una lista. List <DictionaryEntry> pairWithCount = ServicesClients.StatisticsAnalyzer.GetRegistersClickAmount(component, session); List <DictionaryEntry> pairWithPercentage = ServicesClients.StatisticsAnalyzer.GetRegisterClickPercentageAmount(component, session); if (pairWithCount.Count > 0) { resultString.AppendLine(GetLocalResourceObject("HowManyRegisterSelections") + ":"); for (int i = 0; i < pairWithCount.Count; i++) { string percentage = ((double)pairWithPercentage[i].Value).ToString("P2", CultureInfo.InvariantCulture); resultString.AppendLine(pairWithCount[i].Key + " -> " + pairWithCount[i].Value + " | " + percentage); } resultString.AppendLine(); } break; } return(resultString.ToString()); }
internal Entity CreateNetworkComponentData <T>(Entity entity, int fieldsCount) { var newEntity = NetworkEntityManager.CreateEntity( ComponentType.Create <NetworkComponentData <T> >(), ComponentType.Create <ComponentEntity>(), ComponentType.FixedArray(typeof(int), fieldsCount * 2)); // 2x because of history var component = new ComponentEntity { Index = entity.Index, Version = entity.Version }; NetworkEntityManager.SetComponentData(newEntity, component); return(newEntity); }
/// <summary> /// Obtener un entero indicando la cantidad de accesos al item de menu. /// </summary> /// <param name="component">El formulario para el cual calcular.</param> /// <param name="session">El identificador de sesión del cliente móvil.</param> /// <returns>Un entero indicando la cantidad de accesos al menu item.</returns> public int GetFormAccessAmount(ComponentEntity component, string session) { int count = 0; List <UserActionEntity> userActions = new List <UserActionEntity>(new UserActionDataAccess().LoadWhere(UserActionEntity.DBIdComponent, component.Id, false, OperatorType.Equal)); // Agrupamos por formulario y contamos foreach (UserActionEntity uae in userActions) { if (uae.ActionType == 1) { count++; } } return(count); }
public static bool GetConnection( this ComponentEntity entity, [NotNullWhen(true)] out NetConnection?connection) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (entity.Components.Get <Component <NetConnection> >(out var component)) { connection = component.Entity; return(true); } connection = null; return(false); }
public static bool GetPlayer( this ComponentEntity entity, [NotNullWhen(true)] out Player?player) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (entity.Components.Get <Component <Player> >(out var component)) { player = component.Entity; return(true); } player = null; return(false); }
public static ComponentEntity Transform(TransformModel transformModel) { var properties = TransformHelper.GetPropertiesFromSchema(transformModel.OpenApiSchema, transformModel.ComponentGroupId); var component = new ComponentEntity { Id = transformModel.ComponentId, Name = transformModel.ComponentName, Service = transformModel.ServiceName, GroupName = transformModel.ComponentGroupName, ApiVersion = transformModel.OpenApiDoc.Info.Version, Description = transformModel.OpenApiSchema.Description ?? transformModel.OpenApiSchema.Title, PropertyItems = properties.ToList(), Example = GetComponentExample(transformModel.OpenApiSchema) }; return(component); }
/// <summary> /// Obtener una lista de pares (Item de Menu/Cantidad de accesos). /// </summary> /// <param name="component">El item de menu en el cual calcular.</param> /// <param name="session">El identificador de sesión del cliente móvil.</param> /// <returns>Un lista de pares nombre/valor.</returns> public List <DictionaryEntry> GetMenuItemAccessAmounts(ComponentEntity component, string session) { List <DictionaryEntry> listOfMenuItemsCount = new List <DictionaryEntry>(); foreach (ComponentEntity menuItem in component.MenuItems) { List <UserActionEntity> userActions = new List <UserActionEntity>(new UserActionDataAccess().LoadWhere(UserActionEntity.DBIdComponent, menuItem.Id, false, OperatorType.Equal)); DictionaryEntry nameValue; nameValue = new DictionaryEntry(); nameValue.Key = menuItem.Text; nameValue.Value = userActions.Count; listOfMenuItemsCount.Add(nameValue); } return(listOfMenuItemsCount); }
private static string FieldMenuItem(ComponentEntity component) { string tpl = MenuFieldTemplate; // Reemplaza elementos de plantilla tpl = tpl.Replace("%FIELDNAME%", Utilities.GetValidIdentifier(component.Text, true)); tpl = tpl.Replace("%COMPONENT_ID%", component.Id.ToString(NumberFormatInfo.InvariantInfo)); tpl = tpl.Replace("%MENUTEXT%", Utilities.GetValidStringValue(component.Text)); if (component.OutputDataContext == null) { tpl = tpl.Replace("%OUTPUTMENUITEM%", "null"); } else { tpl = tpl.Replace("%OUTPUTMENUITEM%", Utilities.GetValidIdentifier(component.OutputDataContext.Name, false) + "Entity"); } return(tpl); }
/// <summary> /// /// </summary> /// <param name="component"></param> /// <param name="session"></param> /// <returns></returns> public static string GenerateStatisticSummary(ComponentEntity component, string session) { StringBuilder resultString = new StringBuilder(); resultString.Append(UtnEmall.ServerManager.Properties.Resources.HowManyCustomersUsedForm + ": "); resultString.AppendLine(Services.StatisticsAnalyzer.GetCustomerFormAccessAmount(component, session).ToString(CultureInfo.CurrentCulture)); resultString.AppendLine(); resultString.Append(UtnEmall.ServerManager.Properties.Resources.HowManyTimesUsedForm + ": "); resultString.AppendLine(Services.StatisticsAnalyzer.GetFormAccessAmount(component, session).ToString(CultureInfo.CurrentCulture)); resultString.AppendLine(); switch ((ComponentType)component.ComponentType) { case (ComponentType.MenuForm): resultString.AppendLine(UtnEmall.ServerManager.Properties.Resources.HowManyTimesMenuWasUsed + ":"); foreach (ComponentEntity menuEntity in component.MenuItems) { FormMenuItemWpf menuItem = Utilities.ConvertEntityToFormMenuItem(menuEntity); int count = Services.StatisticsAnalyzer.GetMenuItemAccessAmount(component, session); resultString.AppendLine(menuItem.Text + " -> " + count); } break; case (ComponentType.ListForm): List <DictionaryEntry> pairWithCount = Services.StatisticsAnalyzer.GetRegistersClickAmount(component, session); List <DictionaryEntry> pairWithPercentage = Services.StatisticsAnalyzer.GetRegisterClickPercentageAmount(component, session); resultString.AppendLine(UtnEmall.ServerManager.Properties.Resources.HowManyRegisterSelections + ":"); for (int i = 0; i < pairWithCount.Count; i++) { string percentage = ((double)pairWithPercentage[i].Value).ToString("P2", CultureInfo.CurrentCulture); resultString.AppendLine(pairWithCount[i].Key + " -> " + pairWithCount[i].Value + "|" + percentage); } break; } return(resultString.ToString()); }
/// <summary> /// Obtiene una lista de pares Número de registro/Porcentaje de Clicks. /// </summary> /// <param name="ListFormComponent">El componente ListForm para el cual generar la estadística.</param> /// <param name="session">El identificador de sesión del cliente móvil.</param> /// <returns>Un lista de pares nombre/valor.</returns> public List <DictionaryEntry> GetRegisterClickPercentageAmount(ComponentEntity listFormComponent, string session) { double totalClicks = 0; List <DictionaryEntry> preprocessedCollection = GetRegistersClickAmount(listFormComponent, session); List <DictionaryEntry> processedCollection = new List <DictionaryEntry>(); foreach (DictionaryEntry pair in preprocessedCollection) { totalClicks += (int)pair.Value; } foreach (DictionaryEntry pair in preprocessedCollection) { DictionaryEntry processedItem = new DictionaryEntry(); processedItem.Key = pair.Key; processedItem.Value = ((int)(pair.Value)) / totalClicks; processedCollection.Add(processedItem); } return(processedCollection); }
/// <summary> /// Convierte ComponentEntity guardado en la base de datos que representa un ShowDataForm en un ShowDataFormWpf para ser utilizado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <returns></returns> public static ShowDataFormWpf ConvertEntityToShowDataForm(ComponentEntity componentEntity) { ShowDataFormWpf showDataFrom = new ShowDataFormWpf(); showDataFrom.BackgroundColor = componentEntity.BackgroundColor; showDataFrom.Height = componentEntity.Height; showDataFrom.Width = componentEntity.Width; showDataFrom.InputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, showDataFrom); showDataFrom.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, showDataFrom); showDataFrom.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); showDataFrom.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); // showDataFrom.IsListGiver = componentEntity.IsListGiver; //showDataFrom.IsRegisterGiver = componentEntity.IsRegisterGiver; showDataFrom.StringHelp = componentEntity.StringHelp; showDataFrom.Title = componentEntity.Title; showDataFrom.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; showDataFrom.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; showDataFrom.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; showDataFrom.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; showDataFrom.TemplateListFormDocument = ConvertEntityToTemplateListDocument(componentEntity.TemplateListFormDocument); return(showDataFrom); }
/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un ListForm en un ListFormWpf para ser usado en un proyecto wpf /// </summary> /// <param name="componentEntity"></param> /// <returns></returns> public static ListFormWpf ConvertEntityToListForm(ComponentEntity componentEntity) { ListFormWpf listFormWpf = new ListFormWpf(); listFormWpf.BackgroundColor = componentEntity.BackgroundColor; listFormWpf.Height = componentEntity.Height; listFormWpf.Width = componentEntity.Width; listFormWpf.InputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.InputConnectionPoint, listFormWpf); listFormWpf.OutputConnectionPoint = ConvertEntityToConnectionPoint(componentEntity.OutputConnectionPoint, listFormWpf); listFormWpf.InputDataContext = ConvertEntityToTable(componentEntity.InputDataContext); listFormWpf.OutputDataContext = ConvertEntityToTable(componentEntity.OutputDataContext); // listForm.IsListGiver = componentEntity.IsListGiver; //listForm.IsRegisterGiver = componentEntity.IsRegisterGiver; listFormWpf.StringHelp = componentEntity.StringHelp; listFormWpf.Title = componentEntity.Title; listFormWpf.XCoordinateRelativeToParent = componentEntity.XCoordinateRelativeToParent; listFormWpf.YCoordinateRelativeToParent = componentEntity.YCoordinateRelativeToParent; listFormWpf.XFactorCoordinateRelativeToParent = componentEntity.XFactorCoordinateRelativeToParent; listFormWpf.YFactorCoordinateRelativeToParent = componentEntity.YFactorCoordinateRelativeToParent; listFormWpf.TemplateListFormDocument = ConvertEntityToTemplateListDocument(componentEntity.TemplateListFormDocument); return(listFormWpf); }
/// <summary> /// Convierte un ComponentEntity guardado en la base de datos que representa un TemplateListItem en un TemplateListItemWpf para ser usado en un proyecto wpf /// </summary> /// <param name="templateListItemEntity"></param> /// <returns></returns> public static TemplateListItemWpf ConvertEntityToTemplateListItemWpf(ComponentEntity templateListItemEntity) { Field tempField = ConvertEntityToField(templateListItemEntity.FieldAssociated); TemplateListItemWpf templateListItem = new TemplateListItemWpf(tempField, (FontName)templateListItemEntity.FontName, (FontSize)templateListItemEntity.FontSize, (DataType)templateListItemEntity.DataTypes); templateListItem.MakeCanvas(); templateListItem.BackgroundColor = templateListItemEntity.BackgroundColor; templateListItem.Bold = templateListItemEntity.Bold; templateListItem.DataType = (DataType)templateListItemEntity.DataTypes; templateListItem.FontColor = templateListItemEntity.FontColor; templateListItem.FontName = (FontName)templateListItemEntity.FontName; templateListItem.FontSize = (FontSize)templateListItemEntity.FontSize; templateListItem.Height = templateListItemEntity.Height; templateListItem.Width = templateListItemEntity.Width; templateListItem.Italic = templateListItemEntity.Italic; templateListItem.Underline = templateListItemEntity.Underline; templateListItem.XCoordinateRelativeToParent = templateListItemEntity.XCoordinateRelativeToParent; templateListItem.YCoordinateRelativeToParent = templateListItemEntity.YCoordinateRelativeToParent; templateListItem.XFactorCoordinateRelativeToParent = templateListItemEntity.XFactorCoordinateRelativeToParent; templateListItem.YFactorCoordinateRelativeToParent = templateListItemEntity.YFactorCoordinateRelativeToParent; templateListItem.HeightFactor = templateListItemEntity.HeightFactor; templateListItem.WidthFactor = templateListItemEntity.WidthFactor; return(templateListItem); }
private static string Field(ComponentEntity component) { string tpl = FieldTemplate; // Reemplaza elementos de plantilla tpl = tpl.Replace("%FIELDNAME%", Utilities.GetValidIdentifier(component.FieldAssociated.Name, true, false)); tpl = tpl.Replace("%COMPONENT_ID%", component.Id.ToString(NumberFormatInfo.InvariantInfo)); tpl = tpl.Replace("%MENUTEXT%", Utilities.GetValidStringValue(component.FieldAssociated.Name)); switch (component.FontSize) { case 1: tpl = tpl.Replace("%FONTSIZE%", "9.0"); break; case 2: tpl = tpl.Replace("%FONTSIZE%", "11.0"); break; case 3: tpl = tpl.Replace("%FONTSIZE%", "13.0"); break; default: tpl = tpl.Replace("%FONTSIZE%", "9.0"); break; } switch (component.FontName) { case 1: tpl = tpl.Replace("%FONTNAME%", "Arial"); break; case 2: tpl = tpl.Replace("%FONTNAME%", "Currier"); break; case 3: tpl = tpl.Replace("%FONTNAME%", "Times"); break; default: tpl = tpl.Replace("%FONTNAME%", "Times"); break; } if (component.FontColor != null && component.FontColor.Length > 2) { component.FontColor = component.FontColor.Replace("#", ""); tpl = tpl.Replace("%FONTCOLOR%", "0x" + component.FontColor.Substring(2)); } else { tpl = tpl.Replace("%FONTCOLOR%", "0x000000"); } if (component.BackgroundColor != null) { component.BackgroundColor = component.BackgroundColor.Replace("#", ""); tpl = tpl.Replace("%BACKCOLOR%", "0x" + component.BackgroundColor); } else { tpl = tpl.Replace("%BACKCOLOR%", "0"); } tpl = tpl.Replace("%UNDERLINE%", (component.Underline) ? "true" : "false"); tpl = tpl.Replace("%ITALIC%", (component.Italic) ? "true" : "false"); tpl = tpl.Replace("%BOLD%", (component.Bold) ? "true" : "false"); tpl = tpl.Replace("%X%", "" + Math.Round(component.XFactorCoordinateRelativeToParent, 5).ToString("F5", NumberFormatInfo.InvariantInfo)); tpl = tpl.Replace("%Y%", "" + Math.Round(component.YFactorCoordinateRelativeToParent, 5).ToString("F5", NumberFormatInfo.InvariantInfo)); tpl = tpl.Replace("%Width%", "" + Math.Round(component.WidthFactor, 5).ToString("F5", NumberFormatInfo.InvariantInfo)); tpl = tpl.Replace("%Height%", "" + Math.Round(component.HeightFactor, 5).ToString("F5", NumberFormatInfo.InvariantInfo)); switch (component.DataTypes) { case 1: tpl = tpl.Replace("%FIELDTYPE%", "Text"); break; case 2: tpl = tpl.Replace("%FIELDTYPE%", "Numeric"); break; case 3: tpl = tpl.Replace("%FIELDTYPE%", "DateTime"); break; case 4: tpl = tpl.Replace("%FIELDTYPE%", "Boolean"); break; case 5: tpl = tpl.Replace("%FIELDTYPE%", "Image"); break; default: tpl = tpl.Replace("%FIELDTYPE%", "Text"); break; } return(tpl); }
private static string Form(ComponentEntity component, CustomerServiceDataEntity serviceModel) { string tpl = FormTemplate; // Reemplaza elementos de plantillas tpl = tpl.Replace("%TYPE%", ComponentTypeToString(component.ComponentType)); tpl = tpl.Replace("%NAME%", GetNameForComponent(component, false)); tpl = tpl.Replace("%FORMTITLE%", Utilities.GetValidStringValue(component.Title)); tpl = tpl.Replace("%COMPONENT_ID%", component.Id.ToString(NumberFormatInfo.InvariantInfo)); if (component.Id == serviceModel.IdInitComponent) { tpl = tpl.Replace("%STARTFORM%", "true"); } else { tpl = tpl.Replace("%STARTFORM%", "false"); } tpl = tpl.Replace("%FINALFORM%", (component.FinalizeService) ? "true" : "false"); ComponentType type = (ComponentType)component.ComponentType; if (component.ComponentType != (int)ComponentType.FormMenuItem) { string tplExtra = FormExtraTemplate; string tplExtraEnter = FormExtraEnterTemplate; string fields = ""; if (component.InputDataContext == null) { tplExtra = tplExtra.Replace("%INPUT%", "null"); tplExtra = tplExtra.Replace("%INPUT_TABLE_ID%", "null"); } else { tplExtra = tplExtra.Replace("%INPUT%", Utilities.GetValidIdentifier(component.InputDataContext.Name, false) + "Entity"); tplExtra = tplExtra.Replace("%INPUT_TABLE_ID%", component.InputDataContext.Id.ToString(NumberFormatInfo.InvariantInfo)); } if (component.OutputDataContext == null) { tplExtra = tplExtra.Replace("%OUTPUT%", "null"); } else { tplExtra = tplExtra.Replace("%OUTPUT%", Utilities.GetValidIdentifier(component.OutputDataContext.Name, false) + "Entity"); } switch (type) { case ComponentType.EnterSingleDataFrom: tplExtra = tplExtra.Replace("%ISINPUTAREGISTER%", "true"); tplExtra = tplExtra.Replace("%ISOUTPUTAREGISTER%", "true"); tplExtraEnter = tplExtraEnter.Replace("%ENTERDATAVALUETYPE%", component.DataTypes.ToString(CultureInfo.CurrentCulture.NumberFormat)); tplExtraEnter = tplExtraEnter.Replace("%ENTERDATAFIELDNAME%", Utilities.GetValidIdentifier(component.Title, true, false)); tplExtraEnter = tplExtraEnter.Replace("%ENTERDATADESCRIPTION%", Utilities.GetValidStringValue(component.DescriptiveText)); break; case ComponentType.MenuForm: tplExtra = tplExtra.Replace("%ISINPUTAREGISTER%", "false"); tplExtra = tplExtra.Replace("%ISOUTPUTAREGISTER%", "true"); tplExtraEnter = ""; break; case ComponentType.ListForm: tplExtra = tplExtra.Replace("%ISINPUTAREGISTER%", "false"); tplExtra = tplExtra.Replace("%ISOUTPUTAREGISTER%", "true"); tplExtraEnter = ""; break; case ComponentType.ShowDataForm: tplExtra = tplExtra.Replace("%ISINPUTAREGISTER%", "true"); tplExtra = tplExtra.Replace("%ISOUTPUTAREGISTER%", "true"); tplExtraEnter = ""; break; default: throw new ArgumentException("Componen must be a Form"); } tpl = tpl.Replace("%EXTRAFIELDS%", tplExtra); tpl = tpl.Replace("%EXTRAFIELDSENTER%", tplExtraEnter); if (component.ComponentType == (int)ComponentType.ListForm || component.ComponentType == (int)ComponentType.ShowDataForm) { foreach (ComponentEntity field in component.TemplateListFormDocument.Components) { fields += Field(field); } } if (component.ComponentType == (int)ComponentType.MenuForm) { foreach (ComponentEntity field in component.MenuItems) { fields += FieldMenuItem(field); } } tpl = tpl.Replace("%FIELDS%", fields); } else { tpl = tpl.Replace("%EXTRAFIELDS%", ""); } return(tpl); }