Пример #1
0
        private void ButtonAddWidgetDataModel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LogicalLibrary.DataModelClasses.Table table = comboBoxDataModels.SelectedItem as LogicalLibrary.DataModelClasses.Table;
                if (table != null)
                {
                    DataSourceWpf dataSourceWPF = new DataSourceWpf(table);
                    dataSourceWPF.MakeCanvas();

                    document.AddWidget(dataSourceWPF);

                    comboBoxDataModels.Items.RemoveAt(comboBoxDataModels.SelectedIndex);
                    comboBoxDataModels.SelectedIndex = 0;
                }
            }
            catch (FileNotFoundException)
            {
                Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.InternalError);
                this.Close();
            }
            catch (ArgumentNullException)
            {
                Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.InternalError);
                this.Close();
            }
            catch (Exception error)
            {
                Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.UnhandledError +
                                     ": " + error.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// Convierte un CustomerServiceDataEntity guardado en la base de datos en un ServiceDocumentWpf para ser usado en un proyecto wpf.
        /// </summary>
        /// <param name="documentEntity"></param>
        /// <param name="serviceDocumentWpf"></param>
        /// <param name="session"></param>
        public static void ConvertEntityToServiceModelWithStatistics(CustomerServiceDataEntity documentEntity, ServiceDocumentWpf serviceDocumentWpf, string session)
        {
            Dictionary <Component, ComponentEntity> connectableComponents = new Dictionary <Component, ComponentEntity>();

            foreach (ComponentEntity componentEntity in documentEntity.Components)
            {
                StatisticsWpf statisticsCanvas;

                switch (componentEntity.ComponentType)
                {
                case (int)ComponentType.DataSource:

                    // Genera e inserta un componente de origen de dato en un documento de servicio.
                    DataSourceWpf dataSource = Utilities.ConvertEntityToDataSource(componentEntity, serviceDocumentWpf.DataModel);
                    dataSource.MakeCanvas();
                    serviceDocumentWpf.Components.Add(dataSource);
                    connectableComponents.Add(dataSource, componentEntity);
                    break;

                case (int)ComponentType.EnterSingleDataFrom:

                    // Genera e inserta el componente de entrada de datos en el documento del servicio.
                    EnterSingleDataFormWpf enterSingleData = Utilities.ConvertEntityToEnterSingleData(componentEntity);
                    enterSingleData.MakeCanvas();
                    serviceDocumentWpf.Components.Add(enterSingleData);
                    connectableComponents.Add(enterSingleData, componentEntity);

                    // Genera el componente de estadistica para el formulario y lo agrega
                    statisticsCanvas = new StatisticsWpf(enterSingleData, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session));
                    serviceDocumentWpf.Components.Add(statisticsCanvas);
                    break;

                case (int)ComponentType.ListForm:

                    // Genera e inserta el componente de origen de datos en el documento del servicio
                    ListFormWpf listFormWpf = Utilities.ConvertEntityToListForm(componentEntity);
                    listFormWpf.MakeCanvas();
                    serviceDocumentWpf.Components.Add(listFormWpf);
                    connectableComponents.Add(listFormWpf, componentEntity);

                    // Asigna el formulario de listas como el componente de inicio si lo es.
                    if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id)
                    {
                        serviceDocumentWpf.StartWidget = listFormWpf;
                    }

                    // Genera el componente de estadistica y lo agrega
                    statisticsCanvas = new StatisticsWpf(listFormWpf, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session));
                    serviceDocumentWpf.Components.Add(statisticsCanvas);
                    break;

                case (int)ComponentType.MenuForm:

                    // Genera e inserta el componetne de origen de datos en el documento del servicio
                    MenuFormWpf menuForm = Utilities.ConvertEntityToMenuForm(componentEntity);
                    menuForm.MakeCanvas();
                    serviceDocumentWpf.Components.Add(menuForm);

                    // Agrega el formulario de menu y todos los items del menu
                    connectableComponents.Add(menuForm, componentEntity);
                    for (int i = 0; i < menuForm.MenuItems.Count; i++)
                    {
                        connectableComponents.Add(menuForm.MenuItems[i], componentEntity.MenuItems[i]);
                    }

                    // Asigna el formulario de menu como componente de inicio
                    if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id)
                    {
                        serviceDocumentWpf.StartWidget = menuForm;
                    }

                    // Genera el componente de estadistica y lo agrega
                    statisticsCanvas = new StatisticsWpf(menuForm, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session));
                    serviceDocumentWpf.Components.Add(statisticsCanvas);
                    break;

                case (int)ComponentType.ShowDataForm:

                    // Genera e inserta el componente de origen de datos en el documento de servicio.
                    ShowDataFormWpf showDataFormWpf = Utilities.ConvertEntityToShowDataForm(componentEntity);
                    showDataFormWpf.MakeCanvas();
                    serviceDocumentWpf.Components.Add(showDataFormWpf);
                    connectableComponents.Add(showDataFormWpf, componentEntity);

                    // Genera el componente de estadistica y lo agrega
                    statisticsCanvas = new StatisticsWpf(showDataFormWpf, serviceDocumentWpf.DrawArea, StatisticsWpf.GenerateStatisticSummary(componentEntity, session));
                    serviceDocumentWpf.Components.Add(statisticsCanvas);
                    break;
                }
            }

            // Convierte cada una de las conexiones
            foreach (ConnectionWidgetEntity connectionWidgetEntity in documentEntity.Connections)
            {
                try
                {
                    ConnectionWpf connectionWpf = ConvertEntityToConnection(connectableComponents, connectionWidgetEntity, serviceDocumentWpf);
                    serviceDocumentWpf.AddConnection(connectionWpf);
                }
                catch (ArgumentNullException)
                {
                    Util.ShowErrorDialog(UtnEmall.ServerManager.Properties.Resources.NonFatalErrorLoadingConnection);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Convierte un CustomerServiceDataEntity almacenado en la base de datos en un ServiceDocumentWpf para ser usado en un proyecto wpf
        /// </summary>
        /// <param name="documentEntity"></param>
        /// <param name="serviceDocumentWpf"></param>
        public static void ConvertEntityToServiceModel(CustomerServiceDataEntity documentEntity, ServiceDocumentWpf serviceDocumentWpf)
        {
            Dictionary <Component, ComponentEntity> connectableComponents = new Dictionary <Component, ComponentEntity>();

            foreach (ComponentEntity componentEntity in documentEntity.Components)
            {
                switch (componentEntity.ComponentType)
                {
                // Convierte un DataSourceEntity en un DataSourceWpf
                case (int)ComponentType.DataSource:
                    DataSourceWpf dataSource = Utilities.ConvertEntityToDataSource(componentEntity, serviceDocumentWpf.DataModel);
                    dataSource.MakeCanvas();
                    serviceDocumentWpf.Components.Add(dataSource);
                    connectableComponents.Add(dataSource, componentEntity);
                    break;

                // Convierte un EnterSingleDataFormEntity en un EnterSingleDataFormWpf
                case (int)ComponentType.EnterSingleDataFrom:
                    EnterSingleDataFormWpf enterSingleData = Utilities.ConvertEntityToEnterSingleData(componentEntity);
                    enterSingleData.MakeCanvas();
                    serviceDocumentWpf.Components.Add(enterSingleData);
                    connectableComponents.Add(enterSingleData, componentEntity);
                    break;

                // Convierte un ListFormEntity en un ListFormWpf
                case (int)ComponentType.ListForm:
                    ListFormWpf listFormWpf = Utilities.ConvertEntityToListForm(componentEntity);
                    listFormWpf.MakeCanvas();
                    serviceDocumentWpf.Components.Add(listFormWpf);
                    connectableComponents.Add(listFormWpf, componentEntity);

                    if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id)
                    {
                        serviceDocumentWpf.StartWidget = listFormWpf;
                    }
                    break;

                // Convierte un MenuFormEntity en un MenuFormWpf
                case (int)ComponentType.MenuForm:
                    MenuFormWpf menuForm = Utilities.ConvertEntityToMenuForm(componentEntity);
                    menuForm.MakeCanvas();
                    serviceDocumentWpf.Components.Add(menuForm);

                    connectableComponents.Add(menuForm, componentEntity);
                    for (int i = 0; i < menuForm.MenuItems.Count; i++)
                    {
                        connectableComponents.Add(menuForm.MenuItems[i], componentEntity.MenuItems[i]);
                    }

                    if (documentEntity.InitComponent != null && documentEntity.InitComponent.Id == componentEntity.Id)
                    {
                        serviceDocumentWpf.StartWidget = menuForm;
                    }
                    break;

                // Convierte un ShowDataFormEntity en un ShowDataFormWpf
                case (int)ComponentType.ShowDataForm:
                    ShowDataFormWpf showDataFormWpf = Utilities.ConvertEntityToShowDataForm(componentEntity);
                    showDataFormWpf.MakeCanvas();
                    serviceDocumentWpf.Components.Add(showDataFormWpf);
                    connectableComponents.Add(showDataFormWpf, componentEntity);
                    break;

                default:
                    break;
                }
            }

            // Convierte cada una de las conexiones
            foreach (ConnectionWidgetEntity connectionWidgetEntity in documentEntity.Connections)
            {
                ConnectionWpf connectionWpf = ConvertEntityToConnection(connectableComponents, connectionWidgetEntity, serviceDocumentWpf);
                serviceDocumentWpf.AddConnection(connectionWpf);
            }
        }