private IEnumerable <NotesItem> GetNoteItem(NotesDocument doc)
        {
            Array itemArray = (Array)doc.Items;

            if (itemArray.Length > 0)
            {
                UpdateText(lblStatus, "Get Notes Items...");

                UpdateText(lblNotesItemTotal, itemArray.Length.ToString());

                for (int index = 0; index < itemArray.Length; index++)
                {
                    UpdateText(lblNotesItemCount, (index + 1).ToString());

                    NotesItem item = (NotesItem)itemArray.GetValue(index);
                    yield return(item);

                    UpdateText(lblStatus, "Get Next Notes Items...");

                    //Application.DoEvents();
                }

                UpdateText(lblStatus, "Get Notes Items Completed.");
            }
        }
        public DocumentItemModel(NotesItem item)
        {
            DateTimeValue = item.DateTimeValue;
            IsAuthors     = item.IsAuthors;
            IsEncrypted   = item.IsEncrypted;
            IsNames       = item.IsNames;
            IsProtected   = item.IsProtected;
            IsReaders     = item.IsReaders;
            IsSigned      = item.IsSigned;
            IsSummary     = item.IsSummary;
            LastModified  = item.LastModified;
            Name          = item.Name;
            //Parent = new DocumentModel(item.Parent);
            SaveToDisk = item.SaveToDisk;
            try { Text = item.Text; } catch { }
            Type        = item.type;
            ValueLength = item.ValueLength;

            if (item.Values is object[] values)
            {
                Values = values;
            }
            else if (item.Values != null)
            {
                Values = new object[] { (object)item.Values }
            }
            ;

            if (Values.Count() == 1)
            {
                Value = Values.FirstOrDefault()?.ToString();
            }
        }
Exemple #3
0
        public AttachmentModel(NotesDocument document, NotesItem item)
        {
            if (!IsAttachmentItem(item))
            {
                throw new ArgumentException("Item is not an attachment", nameof(item));
            }

            var name = ((IEnumerable)item.Values).Cast <string>().First();

            embeddedObject = document.GetAttachment(name);

            FileSize  = embeddedObject.FileSize;
            Name      = embeddedObject.Name;
            Source    = embeddedObject.Source;
            EmbedType = embeddedObject.type;
        }
 public KeyValuePair <string, NotesViewResultSet[]>[] PullNotesView(string[] ViewNames, string server, string database, string password)
 {
     if (ViewNames == null || ViewNames.Length == 0 || ViewNames.ToList().Distinct().Count() != ViewNames.Length)
     {
         throw new ArgumentException();
     }
     else
     {
         List <KeyValuePair <string, NotesViewResultSet[]> > results = new List <KeyValuePair <string, NotesViewResultSet[]> >();
         NotesSession notesSession = new Domino.NotesSession();
         notesSession.Initialize(password);
         NotesDatabase notesDatabase = notesSession.GetDatabase(server, database, false);
         for (int i = 0; i < ViewNames.Length; i++)
         {
             List <NotesViewResultSet> result = new List <NotesViewResultSet>();
             Domino.NotesView          notesView;
             string view = ViewNames[i];
             notesView = notesDatabase.GetView(view);
             NotesViewEntryCollection notesViewCollection = notesView.AllEntries;
             for (int rowCount = 1; rowCount <= notesViewCollection.Count; rowCount++)
             {
                 NotesViewEntry viewEntry   = notesViewCollection.GetNthEntry(rowCount);
                 NotesDocument  document    = viewEntry.Document;
                 Array          notesThings = document.Items as Array;
                 for (int j = 0; j < notesThings.Length; j++)
                 {
                     NotesItem notesItem = (notesThings.GetValue(j) as Domino.NotesItem);
                     result.Add(new NotesViewResultSet()
                     {
                         RecordID = rowCount,
                         Name     = notesItem.Name,
                         Value    = notesItem.Text
                     });
                 }
             }
             results.Add(new KeyValuePair <string, NotesViewResultSet[]>(view, result.ToArray()));
         }
         return(results.ToArray());
     }
 }
        //private NotesDatabase _serverDatabase = null;
        //private NotesView _peopleView = null;
        //private string _lotusCientPassword = null;
        //private string _lotusnotesserverName = null;
        //private bool _IsfetchServerData = false;

        #region Methods

        /// <summary>
        /// Overrides virtual read method for full list of elements
        /// </summary>
        /// <param name="clientFolderName">
        /// the information from where inside the source the elements should be read -
        ///   This does not need to be a real "path", but need to be something that can be expressed as a string
        /// </param>
        /// <param name="result">
        /// The list of elements that should get the elements. The elements should be added to
        ///   the list instead of replacing it.
        /// </param>
        /// <returns>
        /// The list with the newly added elements
        /// </returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            string currentElementName = string.Empty;

            try
            {
                this.LogProcessingEvent(Resources.uiLogginIn);
                //Lotus Notes Object Creation
                _lotesNotesSession = new Domino.NotesSessionClass();
                //Initializing Lotus Notes Session
                _lotesNotesSession.Initialize(this.LogOnPassword);                       //Passwort
                _localDatabase = _lotesNotesSession.GetDatabase("", "names.nsf", false); //Database for Contacts default names.nsf

                this.LogProcessingEvent(Resources.uiPreparingList);

                string viewname = "$People";
                _contactsView = _localDatabase.GetView(viewname);
                // TODO: implement reading from the Lotus Notes server and map the entities to StdContact instances
                if (_contactsView == null)
                {
                    this.LogProcessingEvent(Resources.uiNoViewFound, viewname);
                }
                else
                {
                    NotesViewEntryCollection notesViewCollection = _contactsView.AllEntries;
                    //ArrayList notesUIDSList = new ArrayList();
                    for (int rowCount = 1; rowCount <= notesViewCollection.Count; rowCount++)
                    {
                        //Get the nth entry of the selected view according to the iteration.
                        NotesViewEntry viewEntry = notesViewCollection.GetNthEntry(rowCount);
                        //Get the first document of particular entry.
                        NotesDocument document = viewEntry.Document;

                        object documentItems = document.Items;
                        Array  itemArray     = (System.Array)documentItems;

                        StdContact elem = new StdContact();
                        PersonName name = new PersonName();
                        elem.Name = name;
                        AddressDetail businessAddress = new AddressDetail();
                        elem.BusinessAddressPrimary = businessAddress;
                        AddressDetail address = new AddressDetail();
                        elem.PersonalAddressPrimary = address;

                        elem.ExternalIdentifier.SetProfileId(ProfileIdentifierType.LotusNotesId, document.NoteID);

                        for (int itemCount = 0; itemCount < itemArray.Length; itemCount++)
                        {
                            NotesItem notesItem = (Domino.NotesItem)itemArray.GetValue(itemCount);
                            string    itemname  = notesItem.Name;
                            string    text      = notesItem.Text;
                            switch (notesItem.Name)
                            {
                            //Name
                            case "FirstName":
                                name.FirstName = notesItem.Text;
                                break;

                            case "LastName":
                                name.LastName = notesItem.Text;
                                break;

                            case "Titel":
                            {
                                if (notesItem.Text != "0")
                                {
                                    name.AcademicTitle = notesItem.Text;
                                }
                            }
                            break;

                            //Geburtstag
                            case "Birthday":
                                DateTime dt;
                                if (DateTime.TryParse(notesItem.Text, out dt))
                                {
                                    elem.DateOfBirth = dt;
                                }
                                break;

                            case "Comment":
                                elem.AdditionalTextData = notesItem.Text;
                                break;

                            //Business adress
                            case "InternetAddress":
                                elem.BusinessEmailPrimary = notesItem.Text;
                                break;

                            case "OfficePhoneNumber":
                                businessAddress.Phone = new PhoneNumber();
                                businessAddress.Phone.DenormalizedPhoneNumber = notesItem.Text;
                                break;

                            case "OfficeStreetAddress":
                                businessAddress.StreetName = notesItem.Text;
                                break;

                            case "OfficeState":
                                businessAddress.StateName = notesItem.Text;
                                break;

                            case "OfficeCity":
                                businessAddress.CityName = notesItem.Text;
                                break;

                            case "OfficeZIP":
                                businessAddress.PostalCode = notesItem.Text;
                                break;

                            case "OfficeCountry":
                                businessAddress.CountryName = notesItem.Text;
                                break;

                            //Business
                            case "Department":
                                elem.BusinessDepartment = notesItem.Text;
                                break;

                            case "CompanyName":
                                elem.BusinessCompanyName = notesItem.Text;
                                break;

                            case "JobTitle":
                                elem.BusinessPosition = notesItem.Text;
                                break;

                            case "WebSite":
                                elem.PersonalHomepage = notesItem.Text;
                                break;

                            //Address
                            case "PhoneNumber":
                                address.Phone = new PhoneNumber();
                                address.Phone.DenormalizedPhoneNumber = notesItem.Text;
                                break;

                            case "StreetAddress":
                                address.StreetName = notesItem.Text;
                                break;

                            case "State":
                                address.StateName = notesItem.Text;
                                break;

                            case "City":
                                address.CityName = notesItem.Text;
                                break;

                            case "Zip":
                                address.PostalCode = notesItem.Text;
                                break;

                            case "country":
                                address.CountryName = notesItem.Text;
                                break;

                            //Mobile
                            case "CellPhoneNumber":
                                elem.PersonalPhoneMobile = new PhoneNumber();
                                elem.PersonalPhoneMobile.DenormalizedPhoneNumber = notesItem.Text;
                                break;

                            //Categories
                            case "Categories":
                                elem.Categories = new List <string>(notesItem.Text.Split(';'));
                                break;
                            }
                        }
                        this.LogProcessingEvent("mapping contact {0} ...", elem.Name.ToString());
                        result.Add(elem);
                    }

                    this.ThinkTime(1000);
                    result.Sort();
                }
            }
            catch (Exception ex)
            {
                this.LogProcessingEvent(
                    string.Format(CultureInfo.CurrentCulture, Resources.uiErrorAtName, currentElementName, ex.Message));
            }
            finally
            {
                //outlookNamespace.Logoff();
                _lotesNotesSession = null;
            }
            return(result);
        }
        /// <summary>
        /// Overrides virtual write method for full list of elements
        /// </summary>
        /// <param name="elements">
        /// the list of elements that should be written to the target system.
        /// </param>
        /// <param name="clientFolderName">
        /// the information to where inside the source the elements should be written -
        ///   This does not need to be a real "path", but need to be something that can be expressed as a string
        /// </param>
        /// <param name="skipIfExisting">
        /// specifies whether existing elements should be updated or simply left as they are
        /// </param>
        protected override void WriteFullList(List <StdElement> elements, string clientFolderName, bool skipIfExisting)
        {
            string currentElementName = string.Empty;

            try
            {
                this.LogProcessingEvent(Resources.uiLogginIn);
                //Lotus Notes Object Creation
                _lotesNotesSession = new Domino.NotesSessionClass();
                //Initializing Lotus Notes Session
                _lotesNotesSession.Initialize(this.LogOnPassword);                       //Passwort
                _localDatabase = _lotesNotesSession.GetDatabase("", "names.nsf", false); //Database for Contacts default names.nsf

                this.LogProcessingEvent(Resources.uiPreparingList);

                string viewname = "$People";
                _contactsView = _localDatabase.GetView(viewname);
                // TODO: implement reading from the Lotus Notes server and map the entities to StdContact instances
                if (_contactsView == null)
                {
                    this.LogProcessingEvent(Resources.uiNoViewFound, viewname);
                }
                else
                {
                    foreach (StdContact item in elements)
                    {
                        NotesViewEntryCollection notesViewCollection = _contactsView.AllEntries;
                        //ArrayList notesUIDSList = new ArrayList();
                        bool gefunden = false;
                        for (int rowCount = 1; rowCount <= notesViewCollection.Count; rowCount++)
                        {
                            //Get the nth entry of the selected view according to the iteration.
                            NotesViewEntry viewEntry = notesViewCollection.GetNthEntry(rowCount);

                            //Get the first document of particular entry.
                            NotesDocument document = viewEntry.Document;
                            string        noteId   = document.NoteID;;
                            //
                            string id = string.Empty;
                            if (item.ExternalIdentifier != null)
                            {
                                ProfileIdInformation info = item.ExternalIdentifier.GetProfileId(ProfileIdentifierType.LotusNotesId);
                                if (info != null)
                                {
                                    id = document.NoteID;
                                }
                            }
                            if (id == noteId)
                            {
                                gefunden = true;
                                //
                                object documentItems = document.Items;
                                Array  itemArray     = (System.Array)documentItems;
                                //Daten übernehmen
                                for (int itemCount = 0; itemCount < itemArray.Length; itemCount++)
                                {
                                    NotesItem notesItem = (Domino.NotesItem)itemArray.GetValue(itemCount);
                                    //string itemname = notesItem.Name;
                                    string text = notesItem.Text;
                                    switch (notesItem.Name)
                                    {
                                    //Name
                                    case "FirstName":
                                        //  notesItem.Text = item.Name.FirstName;
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.LogProcessingEvent(
                    string.Format(CultureInfo.CurrentCulture, Resources.uiErrorAtName, currentElementName, ex.Message));
            }
            finally
            {
                //outlookNamespace.Logoff();
                _lotesNotesSession = null;
            }
        }
Exemple #7
0
 public static bool IsAttachmentItem(NotesItem item) => item.type == IT_TYPE.ATTACHMENT;
Exemple #8
0
        public static void parseFile(string path, string searchQuery, string type)
        {
            Domino.NotesSession session = null;
            session = new Domino.NotesSession();
            session.Initialize("");
            List <ContentDetail> lstContent  = new List <ContentDetail>();
            List <Resources>     lstResource = new List <Resources>();

            Domino.NotesDatabase db = session.GetDatabase("", path, false);

            Domino.NotesDocumentCollection col = db.Search(searchQuery, null, 0);
            for (int i = 0; i < col.Count; i++)
            {
                NotesDocument nd   = col.GetNthDocument(i);
                Note          note = new Note();
                note.nodeId = nd.NoteID;
                note.fields = new Dictionary <string, object>();
                List <string> ebpath = null;
                foreach (NotesItem item in nd.Items)
                {
                    if (item.Name == "$FILE")
                    {
                        NotesItem           file       = nd.GetFirstItem("$File");
                        string              fileName   = ((object[])item.Values)[0].ToString();
                        NotesEmbeddedObject attachfile = (NotesEmbeddedObject)nd.GetAttachment(fileName);
                        if (attachfile != null)
                        {
                            string p = Settings.Default.saveDirectory + nd.NoteID + "\\" + fileName;
                            System.IO.Directory.CreateDirectory(Settings.Default.saveDirectory + nd.NoteID);
                            if (ebpath == null)
                            {
                                ebpath = new List <string>();
                            }
                            ebpath.Add(p);
                            try
                            {
                                attachfile.ExtractFile(p);
                            } catch (Exception en)
                            {
                                Console.WriteLine(en.Message);
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            if (item.type == IT_TYPE.RICHTEXT)
                            {
                                note.fields.Add(item.Name, item.Values);
                            }
                            else
                            {
                                note.fields.Add(item.Name, item.Values[0]);
                            }
                        } catch (Exception en)
                        {
                            Console.WriteLine(en.Message);
                        }
                    }
                }

                if (type == "resource")
                {
                    Resources rs = new Resources(note);
                    if (ebpath != null && ebpath.Count > 0)
                    {
                        foreach (string p in ebpath)
                        {
                            rs.path = rs.path + p + ";";
                        }
                    }
                    lstResource.Add(rs);
                }
                else
                {
                    ContentDetail ct = new ContentDetail(note);
                    lstContent.Add(ct);
                }
            }
            if (lstContent != null && lstContent.Count > 0)
            {
                string json = JsonConvert.SerializeObject(lstContent);
                //write string to file
                System.IO.File.WriteAllText(@Settings.Default.saveDirectory + "cms.txt", json);
            }

            if (lstResource != null && lstResource.Count > 0)
            {
                string json = JsonConvert.SerializeObject(lstResource);
                //write string to file
                System.IO.File.WriteAllText(@Settings.Default.saveDirectory + "resource.txt", json);
            }
        }