Ejemplo n.º 1
0
        public async override Task <bool> LoadModelById(IKntService service, Guid id, bool refreshView = true)
        {
            try
            {
                Service = service;

                var res = await Service.Notes.GetMessageAsync(id);

                if (!res.IsValid)
                {
                    return(false);
                }

                Model = res.Entity;
                Model.SetIsDirty(false);
                if (refreshView)
                {
                    View.RefreshView();
                }
                return(true);
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
    public override async Task <bool> NewModel(IKntService service)
    {
        try
        {
            Service = service;

            var response = await Service.Notes.NewExtendedAsync();

            Model = response.Entity;

            // Evaluate whether to put the following default values in the service layer
            // (null values are by default, we need empty strings so that the IsDirty is
            //  not altered after leaving the view when there are no modifications).
            Model.Topic       = "New topic ...";
            Model.Tags        = "";
            Model.Description = "";
            Model.ContentType = "markdown";

            // Context default values
            Model.FolderId  = Store.ActiveFolderWithServiceRef.FolderInfo.FolderId;
            Model.FolderDto = Store.ActiveFolderWithServiceRef.FolderInfo.GetSimpleDto <FolderDto>();

            Model.SetIsDirty(false);

            View.RefreshView();

            return(true);
        }
        catch (Exception ex)
        {
            View.ShowInfo(ex.Message);
        }
        return(false);
    }
Ejemplo n.º 3
0
        public async void AddNote(IKntService service)
        {
            var noteEditorComponent = new NoteEditorComponent(Store);
            await noteEditorComponent.NewModel(service);

            noteEditorComponent.Run();
        }
Ejemplo n.º 4
0
        public async override Task <bool> DeleteModel(IKntService service, Guid id)
        {
            var result = View.ShowInfo("Are you sure you want to delete this folder?", "Delete note", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes || result == DialogResult.Yes)
            {
                try
                {
                    var response = await service.Folders.DeleteAsync(id);

                    if (response.IsValid)
                    {
                        OnDeletedEntity(response.Entity);
                        return(true);
                    }
                    else
                    {
                        View.ShowInfo(response.Message);
                    }
                }
                catch (Exception ex)
                {
                    View.ShowInfo(ex.Message);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        public async override Task <bool> LoadModelById(IKntService service, Guid id, bool refreshView = true)
        {
            try
            {
                Service = service;

                var repositoryForEdit = Store.GetServiceRef(id).RepositoryRef;

                Model.Alias            = repositoryForEdit.Alias;
                Model.ConnectionString = repositoryForEdit.ConnectionString;
                Model.Provider         = repositoryForEdit.Provider;
                Model.Orm = repositoryForEdit.Orm;
                Model.ResourcesContainer              = repositoryForEdit.ResourcesContainer;
                Model.ResourceContentInDB             = repositoryForEdit.ResourceContentInDB;
                Model.ResourcesContainerCacheRootPath = repositoryForEdit.ResourcesContainerCacheRootPath;
                Model.ResourcesContainerCacheRootUrl  = repositoryForEdit.ResourcesContainerCacheRootUrl;
                Model.SetIsDirty(false);

                if (refreshView)
                {
                    View.RefreshView();
                }
                return(await Task.FromResult <bool>(true));
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
                return(await Task.FromResult <bool>(false));
            }
        }
Ejemplo n.º 6
0
    public async override Task <bool> DeleteModel(IKntService service, Guid noteId)
    {
        var result = View.ShowInfo("Are you sure you want to delete this note?", "Delete note", MessageBoxButtons.YesNo);

        if (result == DialogResult.Yes || result == DialogResult.Yes)
        {
            try
            {
                if (noteId == Guid.Empty)
                {
                    return(await Task.FromResult <bool>(true));
                }

                var response = await service.Notes.DeleteExtendedAsync(noteId);

                if (response.IsValid)
                {
                    OnDeletedEntity(response.Entity);
                    return(true);
                }
                else
                {
                    View.ShowInfo(response.Message);
                }
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
            }
        }
        return(false);
    }
Ejemplo n.º 7
0
        public async override Task <bool> DeleteModel(IKntService service, Guid id)
        {
            Service = service;
            var serviceForDelete = Store.GetServiceRef(id);

            var result = View.ShowInfo($"Are you sure you want remove {serviceForDelete?.RepositoryRef.Alias} repository link?", "Delete note", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes || result == DialogResult.Yes)
            {
                try
                {
                    await Store.SaveAndCloseActiveNotes(service.IdServiceRef);

                    Store.RemoveServiceRef(serviceForDelete);
                    Store.SaveConfig();
                    OnDeletedEntity(serviceForDelete.RepositoryRef);
                    return(await Task.FromResult <bool>(true));
                }
                catch (Exception ex)
                {
                    View.ShowInfo(ex.Message);
                }
            }
            return(await Task.FromResult <bool>(false));
        }
Ejemplo n.º 8
0
        public async Task <bool> LoadEntities(IKntService service, FolderInfoDto folder, bool refreshView = true)
        {
            try
            {
                Service     = service;
                Folder      = folder;
                NotesFilter = null;

                Guid f;
                if (Folder == null)
                {
                    f = Guid.Empty;
                }
                else
                {
                    f = Folder.FolderId;
                }

                Result <List <NoteInfoDto> > response;
                if (folder == null)
                {
                    response = await Service.Notes.GetAllAsync();
                }
                else
                {
                    response = await Service.Notes.GetByFolderAsync(f);
                }

                if (response.IsValid)
                {
                    ListEntities = response.Entity;

                    if (refreshView)
                    {
                        View.RefreshView();
                    }

                    if (ListEntities?.Count > 0)
                    {
                        SelectedEntity = ListEntities[0];
                    }
                    else
                    {
                        SelectedEntity = null;
                    }
                }
                else
                {
                    View.ShowInfo(response.Message);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 9
0
        public async Task <bool> LoadFilteredEntities(IKntService service, NotesFilterDto notesFilter, bool refreshView = true)
        {
            bool resLoad = false;

            try
            {
                // TODO: provisional, hay que buscar una solución más generalista a los estados de espera.
                Cursor.Current = Cursors.WaitCursor;

                Service = service;
                Folder  = null;

                Result <List <NoteInfoDto> > response;
                if (string.IsNullOrEmpty(notesFilter?.TextSearch.Trim()) || service == null || notesFilter == null)
                {
                    response        = new Result <List <NoteInfoDto> >();
                    response.Entity = new List <NoteInfoDto>();
                }
                else
                {
                    response = await Service.Notes.GetSearch(notesFilter);
                }

                if (response.IsValid)
                {
                    ListEntities = response.Entity;
                    NotesFilter  = notesFilter;

                    if (refreshView)
                    {
                        View.RefreshView();
                    }

                    if (ListEntities?.Count > 0)
                    {
                        SelectedEntity = ListEntities[0];
                    }
                    else
                    {
                        SelectedEntity = null;
                    }
                }
                else
                {
                    View.ShowInfo(response.Message);
                    resLoad = await Task.FromResult <bool>(false);
                }
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
                resLoad = await Task.FromResult <bool>(false);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }

            return(resLoad);
        }
Ejemplo n.º 10
0
        public override async Task <bool> NewModel(IKntService service)
        {
            Service = service;

            // TODO: call service for new model
            Model = new FolderDto();
            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 11
0
        public async Task <bool> EditNote(IKntService service, Guid noteId)
        {
            var noteEditorComponent = new NoteEditorComponent(Store);
            var res = await noteEditorComponent.LoadModelById(service, noteId, false);

            noteEditorComponent.Run();
            return(res);
        }
Ejemplo n.º 12
0
        public async override Task <bool> NewModel(IKntService service = null)
        {
            Service = service;

            Model = new RepositoryRef();

            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 13
0
        public override async Task<bool> NewModel(IKntService service)
        {
            Service = service;

            // TODO: call service for new model
            Model = new NoteTaskDto();
            Model.NoteTaskId = Guid.NewGuid();
            return await Task.FromResult<bool>(true);
        }
Ejemplo n.º 14
0
        public override async Task <bool> NewModel(IKntService service)
        {
            Service = service;

            // TODO: call service for new model
            Model            = new KMessageDto();
            Model.KMessageId = Guid.NewGuid();
            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 15
0
        public override async Task <bool> NewModel(IKntService service)
        {
            Service = service;

            // TODO: call service for new model
            Model             = new ResourceDto();
            Model.ResourceId  = Guid.NewGuid();
            Model.ContentInDB = false;
            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 16
0
        public async Task <bool> EditNotePostIt(IKntService service, Guid noteId, bool alwaysTop = false)
        {
            var postItEditorComponent = new PostItEditorComponent(Store);
            var res = await postItEditorComponent.LoadModelById(service, noteId, false);

            if (alwaysTop)
            {
                postItEditorComponent.ForceAlwaysTop = true;
            }
            postItEditorComponent.Run();
            return(res);
        }
Ejemplo n.º 17
0
        public async Task <Guid?> GetUserId(IKntService service)
        {
            var userDto = (await service.Users.GetByUserNameAsync(this.AppUserName)).Entity;

            if (userDto != null)
            {
                return(userDto.UserId);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 18
0
        public NotesController(IKntService service, IOptions <AppSettings> appSettings, IFileStore fileStore)
        {
            _service     = service;
            _appSettings = appSettings.Value;
            _fileStore   = fileStore;

            if (string.IsNullOrEmpty(_service.RepositoryRef.ResourcesContainerCacheRootPath))
            {
                _service.RepositoryRef.ResourcesContainerCacheRootPath = _fileStore.GetResourcesContainerRootPath();
            }
            if (string.IsNullOrEmpty(_service.RepositoryRef.ResourcesContainerCacheRootUrl))
            {
                _service.RepositoryRef.ResourcesContainerCacheRootUrl = _fileStore.GetResourcesContainerRootUrl();
            }
        }
Ejemplo n.º 19
0
        public async override Task <bool> DeleteModel(IKntService service, Guid id)
        {
            var result = View.ShowInfo("Are you sure you want to delete this alert/message?", "Delete message", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes || result == DialogResult.Yes)
            {
                try
                {
                    Result <KMessageDto> response;
                    if (AutoDBSave)
                    {
                        response = await service.Notes.DeleteMessageAsync(id);
                    }
                    else
                    {
                        var resGet = await service.Notes.GetMessageAsync(id);

                        if (!resGet.IsValid)
                        {
                            response        = new Result <KMessageDto>();
                            response.Entity = new KMessageDto();
                        }
                        else
                        {
                            response = resGet;
                        }
                    }

                    if (response.IsValid)
                    {
                        response.Entity.SetIsDeleted(true);
                        Model = response.Entity;
                        OnDeletedEntity(Model);
                        return(true);
                    }
                    else
                    {
                        View.ShowInfo(response.Message);
                    }
                }
                catch (Exception ex)
                {
                    View.ShowInfo(ex.Message);
                }
            }
            return(false);
        }
Ejemplo n.º 20
0
 public virtual void LoadModel(IKntService service, TEntity entity, bool refreshView = true)
 {
     try
     {
         Service = service;
         Model   = entity;
         Model.SetIsDirty(false);
         if (refreshView)
         {
             View.RefreshView();
         }
     }
     catch (Exception ex)
     {
         View.ShowInfo(ex.Message);
     }
 }
Ejemplo n.º 21
0
    private async Task <bool> UpdateAttributes(IKntService service, List <EtiquetaExport> etiquetas)
    {
        var allNotes = (await service.Notes.GetAllAsync()).Entity;
        var i        = 0;
        var nRegs    = allNotes.Count;

        foreach (var n in allNotes)
        {
            i++;

            if (!string.IsNullOrEmpty(n.Tags))
            {
                var tags = ProcessTag(n.Tags);
                var note = (await service.Notes.GetAsync(n.NoteId)).Entity;
                foreach (var t in tags)
                {
                    foreach (var atr in note.KAttributesDto)
                    {
                        if (atr.Description.Contains(t.Key))
                        {
                            // TODO: hay que quitar el ! inicial
                            var etiqueta = etiquetas.Find(e => e.CodEtiqueta == t.Value);
                            if (etiqueta != null)
                            {
                                if (!string.IsNullOrEmpty(atr.Value))
                                {
                                    atr.Value += ", ";
                                }
                                atr.Value += etiqueta.DesEtiqueta;
                            }
                            break;
                        }
                    }
                }

                label1.Text = $"{note.NoteId} - {i}/{nRegs}";
                label2.Text = note.Tags.ToString();
                var resSave = await service.Notes.SaveAsync(note);
            }
        }

        return(await Task.FromResult <bool>(true));
    }
Ejemplo n.º 22
0
    public async override Task <bool> NewModel(IKntService service)
    {
        try
        {
            Service = service;

            var response = await Service.Notes.NewAsync();

            Model = response.Entity;

            // Evaluate whether to put the following default values in the service layer
            // (null values are by default, we need empty strings so that the IsDirty is
            //  not altered after leaving the view when there are no modifications).
            Model.Topic       = DateTime.Now.ToString();
            Model.Tags        = "";
            Model.Description = "";
            Model.ContentType = "markdown";

            // Context default values
            if (FolderWithServiceRef == null)
            {
                FolderWithServiceRef = Store.ActiveFolderWithServiceRef;
            }
            Model.FolderId  = FolderWithServiceRef.FolderInfo.FolderId;
            Model.FolderDto = FolderWithServiceRef.FolderInfo.GetSimpleDto <FolderDto>();

            WindowPostIt = await GetNewWindowPostIt();

            Model.SetIsDirty(true);
            WindowPostIt.SetIsDirty(true);

            View.RefreshView();

            return(await Task.FromResult <bool>(true));
        }
        catch (Exception ex)
        {
            View.ShowInfo(ex.Message);
        }

        return(await Task.FromResult <bool>(false));
    }
Ejemplo n.º 23
0
        public async override Task <bool> LoadEntities(IKntService service, bool refreshView = true)
        {
            try
            {
                Service = service;

                var response = await Service.NoteTypes.GetAllAsync();

                if (response.IsValid)
                {
                    ListEntities = response.Entity;

                    if (refreshView)
                    {
                        View.RefreshView();
                    }

                    if (ListEntities?.Count > 0)
                    {
                        SelectedEntity = ListEntities[0];
                    }
                    else
                    {
                        SelectedEntity = null;
                    }

                    NotifySelectedEntity();
                }
                else
                {
                    View.ShowInfo(response.Message);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 24
0
        public override async Task <bool> LoadModelById(IKntService service, Guid id, bool refreshView = true)
        {
            try
            {
                Service = service;

                Model = (await Service.Folders.GetAsync(id)).Entity;
                Model.SetIsDirty(false);
                if (refreshView)
                {
                    View.RefreshView();
                }
                return(true);
            }
            catch (Exception ex)
            {
                View.ShowInfo(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 25
0
    public async override Task <bool> LoadModelById(IKntService service, Guid noteId, bool refreshView = true)
    {
        try
        {
            Service = service;

            Model = (await Service.Notes.GetAsync(noteId)).Entity;
            Model.SetIsDirty(false);

            FolderWithServiceRef = new FolderWithServiceRef {
                ServiceRef = Store.GetServiceRef(service.IdServiceRef), FolderInfo = Model?.FolderDto
            };

            var resGetWindow = await Service.Notes.GetWindowAsync(Model.NoteId, await PostItGetUserId());

            if (resGetWindow.IsValid)
            {
                WindowPostIt = resGetWindow.Entity;
            }
            else
            {
                WindowPostIt = await GetNewWindowPostIt();
            }

            WindowPostIt.Visible = true;
            await Service.Notes.SaveWindowAsync(WindowPostIt);

            WindowPostIt.SetIsDirty(false);

            if (refreshView)
            {
                View.RefreshView();
            }
            return(true);
        }
        catch (Exception ex)
        {
            View.ShowInfo(ex.Message);
            return(false);
        }
    }
Ejemplo n.º 26
0
    private async Task <bool> SaveFolderDto(IKntService service, Guid?userId, CarpetaExport carpetaExport, Guid?parent, List <EtiquetaExport> etiquetas)
    {
        string r11 = "\r\n";
        string r12 = "\n";

        string r21 = "&#x";
        string r22 = "$$$";

        int nErrors = 0;

        #region Import customization

        //// afumfer
        //// .......
        //string r31 = @"D:\KaNote\Resources\ImgsEditorHtml";
        //string r32 = @"D:\Anotas\Docs\__Imgs_!!ANTHtmlEditor!!_";

        //string r41 = @"D:\KaNote\Resources\ImgsEditorHtml";
        //string r42 = @"C:\Anotas\Docs\__Imgs_!!ANTHtmlEditor!!_";

        //string r51 = @"_KNTERRORTRAP";
        //string r52 = @"_ANTERRORTRAP";
        //string r61 = @"_KNTERRORCODE";
        //string r62 = @"_ANTERRORCODE";
        //string r71 = @"_KNTERRORDESCRIPTION";
        //string r72 = @"_ANTERRORDESCRIPTION";
        //string r81 = "";
        //string r82 = "[!ExecuteAnTScriptBGroundThread]";
        //string r91 = "";
        //string r92 = "_ANTForm.Exit();";

        #endregion

        string r31 = @"KntResCon/";
        string r32 = @"\\educacion.org\Almacen\Pincel\TareasTM\Doc\";

        string r41 = @"KntResCon/";
        string r42 = @"\\educacion.org\Almacen\Pincel\tareasTM\Doc\";

        string r51 = @"KntResCon/";
        string r52 = @"\\Educacion.org\Almacen\Pincel\TareasTM\Doc\";

        var newFolderDto = new FolderDto
        {
            FolderNumber = carpetaExport.IdCarpeta,
            //FolderNumber = 0,
            Name       = carpetaExport.NombreCarpeta,
            Order      = carpetaExport.Orden,
            OrderNotes = carpetaExport.OrdenNotas,
            ParentId   = parent
        };

        var resNewFolder = await service.Folders.SaveAsync(newFolderDto);

        label1.Text = $"Added folder: {resNewFolder.Entity?.Name}";
        label1.Refresh();

        var folder = resNewFolder.Entity;

        foreach (var n in carpetaExport.Notas)
        {
            try
            {
                if (n.DescripcionNota.Contains(r12))
                {
                    // Hack multiples CR LF
                    n.DescripcionNota = n.DescripcionNota.Replace(r12, r11);
                    // Hack for problems in deserialization
                    n.DescripcionNota = n.DescripcionNota.Replace(r22, r21);
                }

                #region Import customization

                //// afumfer
                //// .......
                //// Hack inserted resources change
                n.DescripcionNota = n.DescripcionNota.Replace(r32, r31);
                n.DescripcionNota = n.DescripcionNota.Replace(r42, r41);
                n.DescripcionNota = n.DescripcionNota.Replace(r52, r51);
                //n.DescripcionNota = n.DescripcionNota.Replace(r62, r61);
                //n.DescripcionNota = n.DescripcionNota.Replace(r72, r71);
                //n.DescripcionNota = n.DescripcionNota.Replace(r82, r81);
                //n.DescripcionNota = n.DescripcionNota.Replace(r92, r91);

                #endregion

                (string descriptionNew, string scriptCode) = ExtractAnTScriptCode(n.DescripcionNota);

                DateTime fecMod;
                if (n.FechaModificacion > n.FechaHoraCreacion)
                {
                    fecMod = n.FechaModificacion;
                }
                else
                {
                    fecMod = n.FechaHoraCreacion;
                }

                var newNote = new NoteExtendedDto
                {
                    FolderId   = folder.FolderId,
                    NoteNumber = n.IdNota,
                    //NoteNumber = 0,

                    Description = descriptionNew,
                    Script      = scriptCode,

                    Topic                = n.Asunto,
                    CreationDateTime     = n.FechaHoraCreacion,
                    ModificationDateTime = fecMod,
                    Tags         = n.PalabrasClave,
                    InternalTags = n.Vinculo,
                    Priority     = n.Prioridad
                };

                if (!newNote.Tags.Contains("UC="))
                {
                    if ("afumfer fdomher jurivmar sesther sleoare dgoddelw".Contains(n.Usuario))
                    {
                        if (!string.IsNullOrEmpty(newNote.Tags))
                        {
                            newNote.Tags += "; ";
                        }
                        newNote.Tags += "UC=" + n.Usuario;
                    }
                }

                // Add task
                if (n.FechaInicio > new DateTime(1901, 1, 1) ||
                    n.FechaResolucion > new DateTime(1901, 1, 1) ||
                    n.FechaPrevistaInicio > new DateTime(1901, 1, 1) ||
                    n.FechaPrevistaFin > new DateTime(1901, 1, 1) ||
                    n.Resuelto == true)
                {
                    NoteTaskDto task = new NoteTaskDto
                    {
                        NoteId               = Guid.Empty,
                        UserId               = (Guid)userId,
                        CreationDateTime     = n.FechaHoraCreacion,
                        ModificationDateTime = fecMod,
                        Description          = newNote.Topic,
                        Tags              = "(ANotas import)",
                        Priority          = 1,
                        Resolved          = n.Resuelto,
                        EstimatedTime     = n.TiempoEstimado,
                        SpentTime         = n.TiempoInvertido,
                        DifficultyLevel   = n.NivelDificultad,
                        ExpectedEndDate   = n.FechaPrevistaFin,
                        ExpectedStartDate = n.FechaPrevistaInicio,
                        EndDate           = n.FechaResolucion,
                        StartDate         = n.FechaInicio
                    };
                    newNote.Tasks.Add(task);
                }

                // Add alarm
                if (n.Alarma > new DateTime(1901, 1, 1))
                {
                    var message = new KMessageDto
                    {
                        NoteId         = Guid.Empty,
                        UserId         = userId,
                        AlarmActivated = n.ActivarAlarma,
                        ActionType     = EnumActionType.UserAlarm,
                        Comment        = "(import ANotas)",
                        AlarmDateTime  = n.Alarma
                    };

                    // Alarm type
                    switch (n.TipoAlarma)
                    {
                    case 0:      // estandar
                        message.AlarmType = EnumAlarmType.Standard;
                        break;

                    case 1:      // diaria
                        message.AlarmType = EnumAlarmType.Daily;
                        break;

                    case 2:      // semanal
                        message.AlarmType = EnumAlarmType.Weekly;
                        break;

                    case 3:      // mensual
                        message.AlarmType = EnumAlarmType.Monthly;
                        break;

                    case 4:      // anual
                        message.AlarmType = EnumAlarmType.Annual;
                        break;

                    case 5:      // cada hora
                        message.AlarmType    = EnumAlarmType.InMinutes;
                        message.AlarmMinutes = 60;
                        break;

                    case 6:      // 4 horas
                        message.AlarmType    = EnumAlarmType.InMinutes;
                        message.AlarmMinutes = 60 * 4;
                        break;

                    case 7:      // 8 horas
                        message.AlarmType    = EnumAlarmType.InMinutes;
                        message.AlarmMinutes = 60 * 8;
                        break;

                    case 8:      // 12 diaria
                        message.AlarmType    = EnumAlarmType.InMinutes;
                        message.AlarmMinutes = 60 * 12;
                        break;

                    default:
                        message.AlarmType = EnumAlarmType.Standard;
                        break;
                    }

                    newNote.Messages.Add(message);
                }

                // Add resource
                if (!string.IsNullOrEmpty(n.NotaEx))
                {
                    #region Import resources for ContendInDB = true

                    //// TODO: Refactor this line
                    //var root = @"D:\ANotas\Docs";

                    //var fileFullName = $"{root}{n.NotaEx}";

                    //if (File.Exists(fileFullName))
                    //{
                    //    var fileArrayBytes = File.ReadAllBytes(fileFullName);
                    //    var contentBase64 = Convert.ToBase64String(fileArrayBytes);
                    //    ResourceDto resource = new ResourceDto
                    //    {
                    //        NoteId = Guid.Empty,
                    //        ContentInDB = true,
                    //        Order = 1,
                    //        Container = service.RepositoryRef.ResourcesContainer + "\\" + DateTime.Now.Year.ToString(),
                    //        Name = $"{Guid.NewGuid()}_{Path.GetFileName(fileFullName)}",
                    //        Description = $"(ANotas import {n.NotaEx})",
                    //        ContentArrayBytes = fileArrayBytes,
                    //        ContentBase64 = contentBase64,
                    //        FileType = _store.ExtensionFileToFileType(Path.GetExtension(fileFullName))
                    //    };
                    //    newNote.Resources.Add(resource);
                    //}

                    #endregion

                    #region Import resources for ContendInDB = false

                    if (n.NotaEx[0] == '\\')
                    {
                        n.NotaEx = n.NotaEx.Substring(1);
                    }

                    string fileImport = Path.Combine(new[] { service.RepositoryRef.ResourcesContainerCacheRootPath, service.RepositoryRef.ResourcesContainer, n.NotaEx });

                    ResourceDto resource = new ResourceDto
                    {
                        NoteId            = Guid.Empty,
                        ContentInDB       = false,
                        Order             = 1,
                        Container         = service.RepositoryRef.ResourcesContainer,
                        Name              = n.NotaEx,
                        Description       = $"(ANotas import {n.NotaEx})",
                        ContentArrayBytes = null,
                        ContentBase64     = null,
                        FileType          = _store.ExtensionFileToFileType(Path.GetExtension(fileImport))
                    };
                    newNote.Resources.Add(resource);

                    #endregion
                }

                // Save note and PostIt
                Result <NoteExtendedDto> resNewNote = null;
                if (newNote.IsValid())
                {
                    resNewNote = await service.Notes.SaveExtendedAsync(newNote);

                    label2.Text = $"Added note: {resNewNote.Entity?.Topic} - {resNewNote.Entity?.NoteId.ToString()}";

                    // Add Window
                    WindowDto windowPostIt = new WindowDto
                    {
                        NoteId         = resNewNote.Entity.NoteId,
                        UserId         = (Guid)userId,
                        Visible        = false, //n.Visible,
                        AlwaysOnTop    = n.SiempreArriba,
                        PosX           = n.PosX,
                        PosY           = n.PosY,
                        Width          = n.Ancho,
                        Height         = n.Alto,
                        FontName       = n.FontName,
                        FontSize       = n.FontSize,
                        FontBold       = n.FontBold,
                        FontItalic     = n.FontItalic,
                        FontUnderline  = n.FontUnderline,
                        FontStrikethru = n.FontStrikethru,
                        ForeColor      = ColorTranslator.ToHtml(ColorTranslator.FromOle(n.ForeColor)),
                        TitleColor     = ColorTranslator.ToHtml(ColorTranslator.FromOle(n.ColorBanda)),
                        TextTitleColor = ColorTranslator.ToHtml(ColorTranslator.FromOle(n.ForeColor)),
                        NoteColor      = ColorTranslator.ToHtml(ColorTranslator.FromOle(n.ColorNota)),
                        TextNoteColor  = ColorTranslator.ToHtml(ColorTranslator.FromOle(n.ForeColor))
                    };
                    var resNewPostIt = await service.Notes.SaveWindowAsync(windowPostIt);
                }
                else
                {
                    label2.Text = $"Added note: ERROR invalid note.";
                    var msgErr = newNote.GetErrorMessage();
                    MessageBox.Show($"ERROR invalid note: {msgErr}");
                }

                label2.Refresh();
            }
            catch (Exception ex)
            {
                // TODO: hack, hay un registro erróneo en la exportación.
                nErrors++;
                if (nErrors > 1)
                {
                    MessageBox.Show($"Más de error. Error: {ex.Message}");
                }
                //throw;
            }
        }

        // For each folder child all recursively  to this method
        foreach (var c in carpetaExport.CarpetasHijas)
        {
            await SaveFolderDto(service, userId, c, folder.FolderId, etiquetas);
        }

        return(await Task.FromResult <bool>(true));
    }
Ejemplo n.º 27
0
    private async Task <bool> ImportTags(IKntService service, List <EtiquetaExport> etiquetas)
    {
        int orderAtrTab = 0;
        int orderAtr    = 0;

        var filtroEtiquetas = etiquetas
                              .Where(e => (e.CodPadre == "[!EtiquetaRaiz]" || e.CodPadre == "UU") &&
                                     (e.CodEtiqueta != "TB" && e.CodEtiqueta != "ND" && e.CodEtiqueta != "OP" && e.CodEtiqueta != "TR" && e.CodEtiqueta != "TU" && e.CodEtiqueta != "UU"))
                              .Select(e => e).OrderBy(e => e.DesEtiqueta).ToList();

        foreach (var e in filtroEtiquetas)
        {
            listMessages.Items.Add($"{e.DesEtiqueta} - {e.CodEtiqueta} - {e.CodPadre?.ToString()}");
            KAttributeDto attributeDto = new KAttributeDto
            {
                Description        = $"[{e.CodEtiqueta}] - " + e.DesEtiqueta,
                Name               = e.DesEtiqueta,
                KAttributeDataType = EnumKAttributeDataType.TagsValue,
                Disabled           = false,
                Order              = orderAtr++,
                RequiredValue      = false
            };

            var tabulatedValues = etiquetas.Where(ev => ev.CodPadre == e.CodEtiqueta).Select(ev => ev).ToList();
            List <KAttributeTabulatedValueDto> tabulatedValuesAtr = new List <KAttributeTabulatedValueDto>();
            orderAtrTab = 0;
            foreach (var t in tabulatedValues)
            {
                KAttributeTabulatedValueDto atrValue = new KAttributeTabulatedValueDto
                {
                    Value       = t.DesEtiqueta,
                    Description = $"[{t.CodEtiqueta}] - " + t.DesEtiqueta,
                    Order       = orderAtrTab++
                };
                tabulatedValuesAtr.Add(atrValue);
            }

            attributeDto.KAttributeValues = tabulatedValuesAtr;

            // Hack import TareasDesarrolloDB
            if (attributeDto.Name == "Consejería de Educación")
            {
                attributeDto.Name        = "00 - Usuario Consejería de Educación";
                attributeDto.Description = $"[{e.CodEtiqueta}] - " + attributeDto.Name;
                attributeDto.Order       = 0;
            }
            if (attributeDto.Name == "Empresa de Servicios TIC")
            {
                attributeDto.Name        = "00 - Usuarios Empresa de Servicios TIC";
                attributeDto.Description = $"[{e.CodEtiqueta}] - " + attributeDto.Name;
                attributeDto.Order       = 0;
            }
            //if (attributeDto.Name[0] == '!')
            //    attributeDto.Name = attributeDto.Name.Substring(1, attributeDto.Name.Length - 1 );

            // Save Data
            var res = await service.KAttributes.SaveAsync(attributeDto);
        }

        return(await Task.FromResult <bool>(true));
    }
Ejemplo n.º 28
0
 public override Task <bool> DeleteModel(IKntService service, Guid id)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 29
0
 public override Task <bool> NewModel(IKntService service)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 30
0
 public override Task <bool> LoadModelById(IKntService service, Guid id, bool refreshView = true)
 {
     throw new NotImplementedException();
 }