Exemplo n.º 1
0
        internal static ExtendedDocument MapProperties(ExtendedDocument selected, dynamic model)
        {
            var notAlloewd = typeof(ModelBase <>).GetProperties().Select(z => z.Name).ToList();

            notAlloewd.Add("Series");

            var propsSelected = selected.GetType().GetProperties().Where(z => z.GetCustomAttribute(typeof(DisplayNameAttribute)) != null);
            var propsModel    = (model.GetType().GetProperties() as PropertyInfo[]).Select(z => z.Name);

            var commun = propsSelected.Where(a => propsModel.Contains(a.Name) &&
                                             !notAlloewd.Contains(a.Name) &&
                                             a.CanWrite);

            if (commun != null)
            {
                foreach (var prop in commun)
                {
                    var  propModel    = (model as ExtendedDocument).GetType().GetProperty(prop.Name);
                    Type typeModel    = propModel?.PropertyType;
                    Type typeSelected = prop.PropertyType;
                    if (typeSelected.Equals(typeModel) == true)
                    {
                        prop.SetValue(selected, propModel.GetValue(model));
                    }
                }
            }

            return(selected);
        }
Exemplo n.º 2
0
        //private static List<IContentItem> setHeader(List<IContentItem> fields)
        // {
        //     //var creche = ElvaSettings.getInstance();
        //     //var logo = creche.PhotoIndice;
        //     //var pathLogo = "";
        //     //if (!string.IsNullOrWhiteSpace(logo))
        //     //{
        //     //    pathLogo = Path.GetFullPath(logo);
        //     //}


        //     //try { fields.Add(new FieldContent("Date", $"{DateTime.Today.ToLongDateString()}")); } catch { }
        //     //    try
        //     //    { fields.Add(new FieldContent("Creche", $"{creche?.Societe}"));
        //     //}
        //     //catch { }
        //     //try
        //     //        { fields.Add(new FieldContent("AdresseCreche", $"{creche?.Adresse}"));
        //     //}
        //     //catch { }
        //     //try
        //     //            { fields.Add(new FieldContent("ContactCreche", $"{creche?.Contact}"));
        //     //}
        //     //catch { }
        //     //try
        //     //                { fields.Add(new ImageContent("Logo", File.ReadAllBytes(pathLogo))); }
        //     //catch { }

        //     //return fields;
        // }


        public static void DefaultSet(ExtendedDocument model)
        {
            //    var doc = $"templates/{model.Name}.docx";
            //    if (File.Exists($"templates/{model.CollectionName}.docx"))
            //    {
            //        File.Copy($"templates/{model.CollectionName}.docx", doc, true);

            //        var type = model.GetType();
            //        var properties = type.GetProperties();

            //        var fields = new List<IContentItem>();
            //        fields = setHeader(fields);

            //        PropertyInfo[] props = type.GetProperties();

            //        foreach (var item in props)
            //        {
            //            fields.Add(new FieldContent(item.Name.ToLower(), item.GetValue(model)?.ToString() ?? "..."));
            //        }

            //        var valuesToFill = new Content(fields.ToArray());
            //        using (var outputDocument = new TemplateProcessor(doc)
            //          .SetRemoveContentControls(true).SetNoticeAboutErrors(false))
            //        {
            //            outputDocument.FillContent(valuesToFill);
            //            outputDocument.SaveChanges();
            //            StartDoc(doc);

            //        }
            //    }
            //    else
            //    {
            //        var resul = MessageBox.Show($"Le document {model.Name} n'a pas un template, créer un template word avec le nom '{model.CollectionName}', Voulez-vous ouvrir les repertoir en question","Aucune template!",MessageBoxButton.YesNo);

            //       if(resul == MessageBoxResult.Yes)
            //        {
            //            Process.Start(@"templates");
            //        }
            //        return;
            //    }


            //}


            //private static void StartDoc(string apth)
            //{
            //    try
            //    {
            //        var p = Path.GetFullPath(apth);
            //        Process.Start(p);
            //    }
            //    catch (Exception s)
            //    {
            //        MessageBox.Show(s.Message);
            //    }
            //}
        }
Exemplo n.º 3
0
 public static void Generate(ExtendedDocument model)
 {
     switch (model.CollectionName)
     {
     default:
         DefaultSet(model);
         break;
     }
 }
Exemplo n.º 4
0
        public async void OpenScreenAttach(ExtendedDocument screen, string title)
        {
            try
            {
                var c = await DetailViewModel.Create(screen, screen.GetType(), aggre, this);

                c.DisplayName = screen.CollectionName;
                Items.Add(c);
                ActivateItem(c);
            }
            catch (Exception s)
            {
                MessageBox.Show(s.Message);
                return;
            }
        }
Exemplo n.º 5
0
        public PrintWindowViewModel(IEnumerable <dynamic> items)
        {
            Items = items;
            props = new WrapPanel();

            ExtendedDocument one = items.FirstOrDefault();

            if (one != null)
            {
                checkBoxes = new List <CheckBox>();
                var pr = one.GetType().GetProperties();
                foreach (PropertyInfo item in pr)
                {
                    var name    = item.Name;
                    var dispaly = item.GetCustomAttribute(typeof(DisplayNameAttribute)) as DisplayNameAttribute;
                    var column  = item.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;

                    if (column != null && (column.FieldType == ModelFieldType.Separation ||
                                           column.FieldType == ModelFieldType.BaseButton ||
                                           column.FieldType == ModelFieldType.Button ||
                                           column.FieldType == ModelFieldType.LienButton ||
                                           column.FieldType == ModelFieldType.OpsButton ||
                                           column.FieldType == ModelFieldType.Table ||
                                           column.FieldType == ModelFieldType.WeakTable
                                           ))
                    {
                        continue;
                    }

                    if (dispaly != null)
                    {
                        name = dispaly.DisplayName;
                    }

                    CheckBox check = new CheckBox();
                    check.Tag        = item;
                    check.Content    = name;
                    check.Margin     = new Thickness(5);
                    check.Checked   += Check_Checked;
                    check.Unchecked += Check_Unchecked;
                    checkBoxes.Add(check);
                    props.Children.Add(check);
                }
            }

            NotifyOfPropertyChange("props");
        }
Exemplo n.º 6
0
        public async Task OpenScreenDetach(ExtendedDocument screen, string title)
        {
            var ioc = DataHelpers.container;
            var vm  = ioc.Get <ViewManager>();
            var c   = await DetailViewModel.Create(screen, screen.GetType(), aggre, this);

            c.DisplayName = screen.CollectionName;
            var content = vm.CreateAndBindViewForModelIfNecessary(c);

            var cc = new ContentControl();

            cc.HorizontalAlignment = HorizontalAlignment.Stretch;
            cc.VerticalAlignment   = VerticalAlignment.Stretch;
            cc.Content             = content;

            GenericWindowViewModel gw = new GenericWindowViewModel(cc, c.DisplayName, screen.Name);

            windowManager.ShowDialog(gw);
        }
Exemplo n.º 7
0
 public static bool fun(ExtendedDocument t)
 {
     return(true);
 }
Exemplo n.º 8
0
 public static ModuleErp GetModule(ExtendedDocument type)
 {
     return(Modules.FirstOrDefault(a => a.Libelle == type.CollectionName));
 }
Exemplo n.º 9
0
 public async void OpenInstance(ExtendedDocument doc)
 {
     this.OpenScreen(await DetailViewModel.Create(doc, doc.GetType(), aggre, this), $"{doc.CollectionName} - {doc.Name}");
 }
Exemplo n.º 10
0
 public ObjReportViewModel(ExtendedDocument doc)
 {
     this.Doc = doc;
     SetView();
 }