Example #1
0
 private void bSearchComputer_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             treeView1.Nodes.Clear();
             InputBox input = InputBox.Show("Lotus Notes Password", new InputBoxItem("Password", notesPassword, true), InputBoxButtons.OKCancel);
             if (input.Result == InputBoxResult.OK)
             {
                 notesPassword = input.Items["Password"];
                 NotesSession nSession = initSession(notesPassword);
                 onLocalComputer = true;
                 foreach (string file in openFileDialog1.FileNames)
                 {
                     NotesDatabase db = nSession.GetDatabase("", file, false);
                     treeView1.Nodes.Add(file, db.Title, "database", "database");
                 }
                 treeView1.Sort();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         openFileDialog1.FileName = "";
     }
 }
        /// <summary>
        /// Sends the via notes.
        /// </summary>
        /// <param name="settings">Any settings needed</param>
        /// <param name="month">The month.</param>
        /// <param name="year">The year.</param>
        /// <param name="fullFilename">The full filename.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="password">The password required to submit</param>
        public void Send(Settings settings, string month, string year, string fullFilename, string emailAddress, SecureString password = null)
        {
            // Two digit month and four digit year
            NotesSession session = new NotesSession();

            session.Initialize();
            NotesDatabase database = session.GetDatabase("Pride/Tessella", "mail\\waldm.nsf");

            if (!database.IsOpen)
            {
                database.Open();
            }

            NotesDocument document = database.CreateDocument();

            document.ReplaceItemValue("Form", "Memo");
            document.ReplaceItemValue("Sendto", emailAddress);
            string subject = settings.StaffID + " " + month + "/" + year;

            document.ReplaceItemValue("Subject", subject);

            NotesRichTextItem attachment = document.CreateRichTextItem("Attachment");

            attachment.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, string.Empty, fullFilename, "Attachment");

            document.SaveMessageOnSend = true;
            document.ReplaceItemValue("PostedDate", DateTime.Now);
            document.Send(false, emailAddress);
        }
Example #3
0
        //private IEnumerable<NotesDocument> GetNotesDocument(NotesDatabase db)
        //{
        //    UpdateText(lblStatus, "Get Notes Documents...");

        //    NotesDocumentCollection col = db.AllDocuments;
        //    NotesDocument doc = col.GetFirstDocument();

        //    while (doc != null)
        //    {
        //        yield return doc;

        //        doc = col.GetNextDocument(doc);
        //    }

        //    UpdateText(lblStatus, "Get Notes Documents Completed.");

        //    yield return null;
        //}

        private IEnumerable <NotesView> GetNotesView(NotesDatabase db)
        {
            var  viewList = (object[])db.Views;
            long index    = 1;

            if (viewList.LongLength > 0)
            {
                UpdateText(lblStatus, "Get Notes Views...");

                UpdateText(lblNotesViewTotal, viewList.LongLength.ToString());

                foreach (var view in viewList)
                {
                    UpdateText(lblNotesViewCount, index.ToString());

                    yield return((NotesView)view);

                    index++;

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

                    //Application.DoEvents();
                }

                UpdateText(lblStatus, "Get Notes Views Completed.");
            }
        }
Example #4
0
        private void ListAvailableView()
        {
            UpdateText(lblStatus, "Listing available view(s)...");

            cboView.Items.Clear();
            rtbOutput.Clear();

            NotesSession session = new NotesSession();

            session.Initialize("");

            _db = session.GetDatabase("", txtNsfFilePath.Text, false);

            foreach (NotesView view in GetNotesView(_db))
            {
                if (view != null)
                {
                    if (cboView.Items.Contains(view.Name) == false)
                    {
                        cboView.Items.Add(view.Name);
                    }
                }
            }

            if (cboView.Items.Count > 0)
            {
                cboView.Items.Insert(0, "--All--");
                cboView.SelectedIndex = 0;
            }
        }
Example #5
0
        /// <summary>
        /// Lotus Send E-Mail
        /// </summary>
        /// <param name="sendTo"></param>
        /// <param name="copyTo"></param>
        /// <param name="subject"></param>
        /// <param name="content"></param>
        /// Owner:Andy Gao 2011-08-22 09:32:50
        public static void LotusSendEMail(string[] sendTo, string[] copyTo, string subject, string content)
        {
            NotesSession ns = new NotesSession();

            ns.Initialize(lotusPassword);

            NotesDatabase ndb = ns.GetDatabase(lotusServer, lotusFile, false);

            NotesDocument doc = ndb.CreateDocument();

            doc.ReplaceItemValue(LOTUS_SENDTO, sendTo);
            doc.ReplaceItemValue(LOTUS_COPYTO, copyTo);
            doc.ReplaceItemValue(LOTUS_SUBJECT, subject);

            NotesRichTextItem rti = doc.CreateRichTextItem(LOTUS_BODY);

            rti.AppendText(content);

            object recipients = doc.GetItemValue(LOTUS_SENDTO);

            doc.Send(false, ref recipients);

            Marshal.ReleaseComObject(rti);
            Marshal.ReleaseComObject(doc);
            Marshal.ReleaseComObject(ndb);
            Marshal.ReleaseComObject(ns);

            rti = null;
            doc = null;
            ndb = null;
            ns  = null;
        }
Example #6
0
        public void SendMail()
        {
            try
            {
                NotesSession ns = new NotesSessionClass();

                ns.Initialize(pwd);
                NotesDatabase ndb = ns.GetDatabase(serverName, nsfFile, false);

                NotesDocument doc = ndb.CreateDocument();
                doc.ReplaceItemValue("Form", "Memo");
                string[] sendtoString = mailTo.ToArray();
                doc.ReplaceItemValue("SendTo", sendtoString);
                doc.ReplaceItemValue("Subject", subject);
                NotesRichTextItem rt = doc.CreateRichTextItem("Body");
                rt.AppendText(body);

                if ((attFileName != null) && (attFileName.Count > 0))
                {
                    NotesRichTextItem item = doc.CreateRichTextItem("attachment");
                    foreach (string att in attFileName)
                    {
                        item.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, "", att, "attachment");
                    }
                }

                object obj = doc.GetItemValue("SendTo");
                doc.Send(false, ref obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        /// <summary>
        /// Данный метод возвращает заполненую колекцию отделов и сотрудников из IMNS
        /// </summary>
        /// <param name="db">Соединение с Базой данных IMNS</param>
        /// <param name="shemeotdel">Схема из библиотеки данных ImnsLotusOtdelValue</param>
        /// <returns></returns>
        public static ModelImnsOtdel ShemeSeathImns(NotesDatabase db, ModelImnsOtdel shemeotdel)
        {
            var colOtdel = db.Search(String.Format("Select(Form= \"" + DbImnsItem.Departament + "\")"), null, 0);
            var docOtdel = colOtdel.GetFirstDocument();

            while (docOtdel != null)
            {
                //ModelImnsOtdel.ModelImnsUsers shemeusers = new ModelImnsOtdel.ModelImnsUsers();
                string repOtd      = docOtdel.GetItemValue(DbImnsItem.Abbreviation)[0];
                var    colectUsers = db.Search(String.Format("Select (" + DbImnsItem.Abbreviation + "= \"" + repOtd + "\"&Form= \"" + DbImnsItem.Departament + "\"| @AllChildren)"), null, 0);
                var    docUsers    = colectUsers.GetFirstDocument();
                while (docUsers != null)
                {
                    string namenull = docUsers.GetItemValue(DbImnsItem.Abbreviation)[0];
                    if (docUsers.GetItemValue(ImnsLotusUsers.Dismissal)[0] != "1" && namenull.Length == 0)
                    {
                        shemeotdel.ShemeUsers.Add(new ModelImnsOtdel.ModelImnsUsers {
                            Username = docUsers.GetItemValue(ImnsLotusUsers.User)[0]
                        });
                    }
                    docUsers = colectUsers.GetNextDocument(docUsers);
                }
                shemeotdel.ShemeOtdel.Add(new ModelImnsOtdel {
                    Otdeldepartament = Regex.Replace(docOtdel.GetItemValue(DbImnsItem.NameOtdel)[0], "[0-9]+[\\s]", String.Empty), _shemeousers = shemeotdel.ShemeUsers
                });
                docOtdel = colOtdel.GetNextDocument(docOtdel);
            }
            return(shemeotdel);
        }
Example #8
0
 /// <summary>
 /// Загрузка файла
 /// </summary>
 /// <param name="fileName">Путь к файлу</param>
 /// <param name="db">БД</param>
 public string ImportDxlFile(string fileName, NotesDatabase db)
 {
     NotesStream      = db.Parent.CreateStream();
     NotesDxlImporter = db.Parent.CreateDXLImporter();
     if (!NotesStream.Open(fileName))
     {
         Loggers.Log4NetLogger.Error(new Exception("Невозможно открыть файл " + fileName));
         return(null);
     }
     //notesDXLImporter.InputValidationOption = VALIDATIONOPTION.VALIDATE_NEVER;
     NotesDxlImporter.ACLImportOption    = DXLIMPORTOPTION.DXLIMPORTOPTION_UPDATE_ELSE_IGNORE;
     NotesDxlImporter.DesignImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_REPLACE_ELSE_CREATE;
     NotesDxlImporter.ReplicaRequiredForReplaceOrUpdate = false;
     NotesDxlImporter.DocumentImportOption  = DXLIMPORTOPTION.DXLIMPORTOPTION_UPDATE_ELSE_CREATE;
     NotesDxlImporter.ExitOnFirstFatalError = true;
     try
     {
         NotesDxlImporter.Import(NotesStream, db);
         string text = NotesDxlImporter.GetFirstImportedNoteId();
         NotesStream.Truncate();
         NotesStream.Close();
         return(text);
     }
     catch (Exception e)
     {
         Loggers.Log4NetLogger.Error(new Exception(NotesDxlImporter.Log));
         Loggers.Log4NetLogger.Error(new Exception(NotesDxlImporter.LogComment));
         Loggers.Log4NetLogger.Error(e);
     }
     finally
     {
         Dispose();
     }
     return(null);
 }
Example #9
0
 public EditNotePage(ref Note note, NotesDatabase db)
 {
     InitializeComponent();
     noteText.Text         = note.NoteText;
     notificationTime.Time = note.NotificationTime;
     notify.IsChecked      = note.IsNotify;
     database = db;
     newNote  = note;
 }
Example #10
0
 public void LoadNotes()
 {
     this.db    = new NotesDatabase();
     this.notes = db.FetchNotes();
     foreach (NoteData x in this.notes)
     {
         this.note_windows.Append(new NoteWindow(x, background_window));
     }
 }
Example #11
0
 /// <summary>
 /// Индексирование БД если индекса нет то делаем
 /// </summary>
 /// <param name="dbDatabase"></param>
 private NotesDatabase IndexDataBaseUseCreate(NotesDatabase dbDatabase)
 {
     if (dbDatabase.IsFTIndexed)
     {
         return(dbDatabase);
     }
     dbDatabase.CreateFTIndex(FTINDEX_OPTIONS.FTINDEX_ALL_BREAKS & FTINDEX_OPTIONS.FTINDEX_CASE_SENSITIVE, false);
     return(dbDatabase);
 }
Example #12
0
    public void save()
    {
        NotesDatabase database = new NotesDatabase();

        database.QueryNoResults("UPDATE notes SET text = '" + this.get_text() + "', " +
                                "color = '" + this.get_color() + "'" +
                                ", pos_x = " + this.get_pos_x() + " " +
                                ", pos_y = " + this.get_pos_y() + " " +
                                "WHERE id = " + this.get_id());
    }
 /// <summary>
 /// Запись всех представлений в лог
 /// </summary>
 public void AllViewToLog(NotesDatabase db)
 {
     using (StreamWriter outputFile = new StreamWriter(Path.Combine(@"C:\Users\7751_svc_admin\Desktop\", "WriteLines.txt")))
     {
         foreach (NotesView dbDatabaseView in db.Views)
         {
             outputFile.WriteLine($"Поля и текст {dbDatabaseView.Name}");
         }
     }
 }
Example #14
0
 /// <summary>
 /// Проверка и востановление индекса Базы Данных
 /// </summary>
 /// <param name="dbDatabase">База данных Lotus</param>
 /// <returns></returns>
 public static NotesDatabase IndexDataBaseUseCreate(NotesDatabase dbDatabase)
 {
     if (dbDatabase.IsFTIndexed)
     {
         //Есть индекс
         return(dbDatabase);
     }
     //Индекса нет востанавливаем
     dbDatabase.CreateFTIndex(FTINDEX_OPTIONS.FTINDEX_ALL_BREAKS & FTINDEX_OPTIONS.FTINDEX_CASE_SENSITIVE, false);
     return(dbDatabase);
 }
Example #15
0
    public void AddNote(object obj, EventArgs args)
    {
        NotesDatabase database = new NotesDatabase();

        database.QueryNoResults("INSERT INTO notes (text, color, pos_x, pos_y) VALUES ('', '#ffffff', 100, 100)");

        NoteData   new_note_data = new NoteData("", RandomNoteColor(), 450, 450, database.get_last_id());
        NoteWindow new_window    = new NoteWindow(new_note_data, this.background_window);

        new_window.ShowAll();
        this.note_windows.Append(new_window);
    }
Example #16
0
        private static void SendUsingLotusNotes(string[] mailingList, IMessage message)
        {
            string serverName = WebConfigurationManager.AppSettings["LotusNotesServerName"];
            string mailFile   = WebConfigurationManager.AppSettings["LotusNotesMailFileName"];
            string password   = WebConfigurationManager.AppSettings["LotusNotesPassword"];

            string[] sendTo      = mailingList;
            string[] copyTo      = { };
            string   replyTo     = message.ReplyTo;
            string   blindCopyTo = "";
            string   subject     = message.Subject;

            //Create new notes session
            NotesSession notesSession = new NotesSession();

            notesSession.Initialize(password);

            //Get and open NotesDataBase
            NotesDatabase notesDataBase = notesSession.GetDatabase(serverName, mailFile, false);

            if (!notesDataBase.IsOpen)
            {
                notesDataBase.Open();
            }

            //Create the notes document
            NotesDocument notesDocument = notesDataBase.CreateDocument();

            //Set document type
            notesDocument.ReplaceItemValue("Form", "Memo");

            //Set notes memo fields (To: CC: Bcc: Subject etc)
            notesDocument.ReplaceItemValue("SendTo", sendTo);
            notesDocument.ReplaceItemValue("CopyTo", copyTo);
            notesDocument.ReplaceItemValue("BlindCopyTo", blindCopyTo);
            notesDocument.ReplaceItemValue("ReplyTo", replyTo);
            notesDocument.ReplaceItemValue("Subject", subject);

            //Set notes Body as HTML
            NotesStream notesStream = notesSession.CreateStream();

            notesStream.WriteText(message.Body);
            notesStream.WriteText("");
            notesStream.WriteText(message.Link);

            NotesMIMEEntity mimeItem = notesDocument.CreateMIMEEntity("Body");

            mimeItem.SetContentFromText(notesStream, "text/html; charset=UTF-8", MIME_ENCODING.ENC_NONE);

            notesDocument.Send(false);
        }
Example #17
0
 public DocumentGenerationAllDxl(NotesDatabase database)
 {
     Document                                     = new note();
     Document.@class                              = noteClass.document;
     Document.version                             = "6.5";
     Document.maintenanceversion                  = "5.0";
     Document.replicaid                           = database.ReplicaID;
     Document.updatedby                           = null;
     Document.revisions                           = null;
     Document.wassignedby                         = null;
     Document.textproperties                      = null;
     Document.noteinfo.noteid                     = "0";
     Document.noteinfo.sequence                   = "0";
     Document.noteinfo.created.datetime.Text      = new List <string>(new[] { DateTime.Now.ToString(CultureInfo.InvariantCulture) });
     Document.noteinfo.modified.datetime.Text     = new List <string>(new string[] {  });
     Document.noteinfo.revised.datetime.Text      = new List <string>(new[] { DateTime.Now.ToString(CultureInfo.InvariantCulture) });
     Document.noteinfo.lastaccessed.datetime.Text = new List <string>(new[] { DateTime.Now.ToString(CultureInfo.InvariantCulture) });
     Document.noteinfo.addedtofile.datetime.Text  = new List <string>(new string[] {  });
 }
 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());
     }
 }
Example #19
0
        public void SendMailIBM(string mailTo, List <string> mailCC, string mailTitle, string IDyc, string date, string username, string mbody)
        {
            try
            {
                NotesSession nSession = new NotesSession();
                nSession.Initialize("12345678");
                NotesDatabase nDatabase  = nSession.GetDatabase("meiko_notes_hanoi2/SOUMU", "mail\\hrsystem.nsf");
                NotesDocument nDocument  = nDatabase.CreateDocument();
                string[]      recipients =
                { "tu.nguyenduy/SOUMU", "*****@*****.**" };

                nDocument.ReplaceItemValue("Form", "Memo");
                nDocument.ReplaceItemValue("SentTo", recipients);                    //To field
                nDocument.ReplaceItemValue("Subject", "Message subject");            //message subject
                nDocument.ReplaceItemValue("Body", "Something in the message body"); //set body text
                nDocument.SaveMessageOnSend = true;                                  //save message after it's sent
                nDocument.Send(false, recipients);                                   //send
            }
            catch
            {
            }
        }
Example #20
0
        /// <summary>
        /// Функция поиска по заданной выборке
        /// </summary>
        /// <param name="db">База данных</param>
        /// <param name="find">Параметры запроса</param>
        /// <returns>Возвращается колекция найденных документов</returns>
        public NotesDocumentCollection Finds(NotesDatabase db, string find)
        {
            var col = db.Search(find, null, 0);

            return(col);
        }
Example #21
0
	public void AddNote(object obj, EventArgs args){

		NotesDatabase database = new NotesDatabase();
		database.QueryNoResults("INSERT INTO notes (text, color, pos_x, pos_y) VALUES ('', '#ffffff', 100, 100)");

		NoteData new_note_data = new NoteData("", RandomNoteColor(), 450, 450, database.get_last_id());
		NoteWindow new_window = new NoteWindow(new_note_data, this.background_window);
		new_window.ShowAll();
		this.note_windows.Append(new_window);

	}
Example #22
0
    public void remove()
    {
        NotesDatabase database = new NotesDatabase();

        database.QueryNoResults("DELETE FROM notes WHERE id = " + this.get_id());
    }
Example #23
0
        //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);
        }
Example #24
0
        /// <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;
            }
        }
 public DatabaseModel(LotusNotesWrapper wrapper, NotesDatabase database)
 {
     this.wrapper  = wrapper ?? throw new ArgumentNullException(nameof(wrapper));
     this.database = database ?? throw new ArgumentNullException(nameof(database));
 }
        public void ExtractGraphicsCafeDocuments()
        {
            var specificCategories = ReadSpecificCategories();

            Console.WriteLine("Initialize the Extract with Cred: Server: " + LotusNotesServer + " Password: "******"Reading file: " + db.FileName);
                    if (db != null && db.FileName.ToLower() == "Graphics Cafe.nsf".ToLower())
                    {
                        Console.WriteLine("Reading file: " + db.FileName);
                        isAlive = false;
                        try
                        {
                            if (!db.IsOpen)
                            {
                                db.Open();
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Unable to open database: " + db.FileName);
                            Console.WriteLine("Exception: " + ex);
                            db = d.GetNextDatabase();
                            continue;
                        }
                        NotesDocumentCollection docs = db.AllDocuments;

                        if (docs != null)
                        {
                            Console.WriteLine("Documents Count: " + db.AllDocuments.Count);
                            string rootFolderName    = Path.GetFileNameWithoutExtension(db.FileName);
                            string baseDirectoryPath = BaseDirectoryPath + rootFolderName + "\\";

                            for (int rowCount = 1; rowCount <= docs.Count; rowCount++)
                            {
                                NotesDocument document = docs.GetNthDocument(rowCount);
                                if (document.HasEmbedded && document.HasItem("$File"))
                                {
                                    object[]      AllDocItems   = (object[])document.Items;
                                    string        category      = string.Empty;
                                    List <string> categories    = new List <string>();
                                    string        subCategory   = string.Empty;
                                    List <string> subCategories = new List <string>();
                                    Console.WriteLine("RowIndex: " + rowCount);
                                    string documentDescription = string.Empty;
                                    string documentDate        = string.Empty;
                                    string documentNotes       = string.Empty;
                                    string documentAuthor      = string.Empty;
                                    var    notesItems          = new List <NotesItem>();
                                    foreach (object CurItem in AllDocItems)
                                    {
                                        notesItems.Add((NotesItem)CurItem);
                                    }

                                    var categoryItem = notesItems.FirstOrDefault(x => x.Name == "Category");
                                    if (categoryItem != null && !string.IsNullOrEmpty(categoryItem.Text))
                                    {
                                        category = categoryItem.Text;
                                    }
                                    var subcategoryItem = notesItems.FirstOrDefault(x => x.Name == "SubCategory");

                                    if (subcategoryItem != null && !string.IsNullOrEmpty(subcategoryItem.Text))
                                    {
                                        subCategory = subcategoryItem.Text;
                                    }

                                    var descriptionItem = notesItems.FirstOrDefault(x => x.Name == "Description");
                                    if (descriptionItem != null && !string.IsNullOrEmpty(descriptionItem.Text))
                                    {
                                        documentDescription = descriptionItem.Text;
                                    }

                                    var notesItem = notesItems.FirstOrDefault(x => x.Name == "Notes");
                                    if (notesItem != null && !string.IsNullOrEmpty(notesItem.Text))
                                    {
                                        documentNotes = notesItem.Text;
                                    }

                                    var dateItem = notesItems.FirstOrDefault(x => x.Name == "tmpDate");
                                    if (dateItem != null && !string.IsNullOrEmpty(dateItem.Text))
                                    {
                                        documentDate = dateItem.Text;
                                    }

                                    var authorItem = notesItems.FirstOrDefault(x => x.Name == "tmpAuthor");
                                    if (authorItem != null && !string.IsNullOrEmpty(authorItem.Text))
                                    {
                                        documentAuthor = authorItem.Text;
                                    }

                                    if (!string.IsNullOrEmpty(category))
                                    {
                                        categories = category.Split(';').ToList();
                                    }
                                    if (!string.IsNullOrEmpty(subCategory))
                                    {
                                        subCategories = subCategory.Split(';').ToList();
                                    }

                                    if (specificCategories.Count == 0 || (specificCategories.Count > 0 && (categories.Any(x => specificCategories.Contains(x)) || subCategories.Any(x => specificCategories.Contains(x)))))
                                    {
                                        List <NotesItem> documentItems = notesItems.Where(x => x.type == IT_TYPE.ATTACHMENT).ToList();
                                        if (documentItems != null && documentItems.Count > 0)
                                        {
                                            foreach (var nItem in documentItems)
                                            {
                                                if (IT_TYPE.ATTACHMENT == nItem.type)
                                                {
                                                    var pAttachment = ((object[])nItem.Values)[0].ToString();
                                                    Console.WriteLine("Description: " + documentDescription);
                                                    Console.WriteLine("Date: " + documentDate);
                                                    Console.WriteLine("Notes: " + documentNotes);
                                                    Console.WriteLine("Author: " + documentAuthor);
                                                    foreach (var cat in categories)
                                                    {
                                                        Console.WriteLine("Category: " + cat);
                                                        string destPath = baseDirectoryPath;
                                                        if (!string.IsNullOrEmpty(cat))
                                                        {
                                                            if (!Directory.Exists(baseDirectoryPath + cat))
                                                            {
                                                                Directory.CreateDirectory(baseDirectoryPath + cat);
                                                            }
                                                            destPath = destPath + cat + "\\";
                                                        }

                                                        foreach (var subcat in subCategories)
                                                        {
                                                            Console.WriteLine("SubCategory: " + subcat);

                                                            if (!string.IsNullOrEmpty(subcat))
                                                            {
                                                                if (!Directory.Exists(baseDirectoryPath + cat + "\\" + subcat))
                                                                {
                                                                    Directory.CreateDirectory(baseDirectoryPath + cat + "\\" + subcat);
                                                                }
                                                                destPath = destPath + subcat + "\\";
                                                            }
                                                        }
                                                        Console.WriteLine("Final Destination Path: " + destPath + pAttachment);
                                                        if (!File.Exists(destPath + pAttachment))
                                                        {
                                                            try
                                                            {
                                                                document.GetAttachment(pAttachment).ExtractFile(destPath + pAttachment);
                                                            }
                                                            catch (Exception exe)
                                                            {
                                                                LogDetails("File not extracted: " + destPath + pAttachment);
                                                                LogExceptionDetails("File not extracted: " + destPath + pAttachment, exe);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("File already exists: " + destPath + pAttachment);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (isAlive)
                    {
                        db = d.GetNextDatabase();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Extract Graphics Cafe Documents Exception:" + ex);
            }
        }
Example #27
0
 // Constructor
 public MindNoteModel(string dbPath)
 {
     _db = new NotesDatabase(dbPath);
 }
Example #28
0
	public void remove () {
		NotesDatabase database = new NotesDatabase();
		database.QueryNoResults("DELETE FROM notes WHERE id = " + this.get_id());		
	}
Example #29
0
        private void bSearchServer_Click(object sender, EventArgs ea)
        {
            treeView1.Nodes.Clear();
            onLocalComputer = false;
            InputBox input = InputBox.Show("Domino Server", new InputBoxItem[] { new InputBoxItem("Server", notesServer), new InputBoxItem("Domain", notesDomain), new InputBoxItem("Password", notesPassword, true) }, InputBoxButtons.OKCancel);

            if (input.Result == InputBoxResult.OK)
            {
                notesServer   = input.Items["Server"];
                notesDomain   = input.Items["Domain"];
                notesPassword = input.Items["Password"];

                ProgressDialog pDialog = new ProgressDialog();
                pDialog.Title   = "Get Databases";
                pDialog.Style   = ProgressBarStyle.Marquee;
                pDialog.DoWork += delegate(object dialog, DoWorkEventArgs e)
                {
                    try
                    {
                        NotesSession nSession = initSession(notesPassword);
                        pDialog.ReportProgress(0);
                        NotesDbDirectory directory = nSession.GetDbDirectory(notesServer + "//" + notesDomain);
                        NotesDatabase    db        = directory.GetFirstDatabase(DB_TYPES.DATABASE);
                        int i = 0;
                        while (db != null)
                        {
                            if (pDialog.IsCancelled)
                            {
                                e.Cancel = true;
                                return;
                            }
                            string[] path = db.FilePath.Split(new char[] { '\\' });
                            treeView1.Invoke((MethodInvoker) delegate()
                            {
                                TreeNodeCollection nodes = treeView1.Nodes;
                                for (int n = 0; n < path.Length - 1; n++)
                                {
                                    string folder = path[n].ToUpper();
                                    if (!nodes.ContainsKey(folder))
                                    {
                                        nodes.Add(folder, folder, "folder", "folder");
                                    }
                                    nodes = nodes[folder].Nodes;
                                }
                                nodes.Add(db.FilePath, db.Title, "database", "database");
                            });
                            db = directory.GetNextDatabase();
                            pDialog.ReportProgress(i);
                            i++;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                pDialog.ProgressChanged += delegate(object dialog, ProgressChangedEventArgs e)
                {
                    pDialog.Message = e.ProgressPercentage + " Databases Found";
                };
                pDialog.Completed += delegate(object dialog, RunWorkerCompletedEventArgs e)
                {
                    //treeView1.Invoke((MethodInvoker)delegate()
                    //{
                    if (e.Cancelled)
                    {
                        treeView1.Nodes.Clear();
                    }
                    else
                    {
                        treeView1.Sort();
                    }
                    //});
                };
                pDialog.Run();
            }
        }
Example #30
0
        public void Pub()
        {
            try
            {
                NotesSession ns = new NotesSessionClass();
                ns.Initialize(pwd);
                NotesDatabase ndb = ns.GetDatabase(serverName, nsfFile, false);

                NotesDocument doc = ndb.CreateDocument();

                doc.ReplaceItemValue("Form", "中央气象台产品记录");

                doc.ReplaceItemValue("dbname_11", "juece.nsf");
                doc.ReplaceItemValue("dbname_12", "juece.nsf");
                doc.ReplaceItemValue("dbname_13", "juece.nsf");
                doc.ReplaceItemValue("dbname_21", "juece.nsf");
                doc.ReplaceItemValue("dbname_22", "juece.nsf");
                doc.ReplaceItemValue("dbname_222", "juece.nsf");
                doc.ReplaceItemValue("dbname_23", "juece.nsf");
                doc.ReplaceItemValue("dbname_24", "juece.nsf");
                doc.ReplaceItemValue("dbname_30", "juece.nsf");
                doc.ReplaceItemValue("doctype", "OCX");
                doc.ReplaceItemValue("Encrypt", "0");

                doc.ReplaceItemValue("img", "");
                doc.ReplaceItemValue("issuetime", this.dateNum);
                doc.ReplaceItemValue("SendTo", "CMA决策");
                doc.ReplaceItemValue("SendTobyHub", "各省气象信息共享数据库");
                doc.ReplaceItemValue("sendOk", "0");
                doc.ReplaceItemValue("role", "周军");
                doc.ReplaceItemValue("role_1", "短期科");

                doc.ReplaceItemValue("标题域", this.Title);
                doc.ReplaceItemValue("标题域_1", this.Title);
                doc.ReplaceItemValue("部委", "0");
                doc.ReplaceItemValue("草稿", "0");
                doc.ReplaceItemValue("产品", "天气预报");
                doc.ReplaceItemValue("产品_1", "天气预报");
                doc.ReplaceItemValue("发布单位", "国家气象中心");
                doc.ReplaceItemValue("发布单位_1", "中央气象台");
                doc.ReplaceItemValue("发布单位_1_1", "中央气象台");
                doc.ReplaceItemValue("发布单位_2", "国家气象中心");
                doc.ReplaceItemValue("发布单位_e", "qxt");
                doc.ReplaceItemValue("发布时间", this.dateNum);
                doc.ReplaceItemValue("发布时间_1", this.datePy);
                doc.ReplaceItemValue("发布时间_2", this.dateNum);
                //doc.ReplaceItemValue("内容", this.Content);
                doc.ReplaceItemValue("日期1", this.dateNum);
                doc.ReplaceItemValue("状态", "1");

                if ((attFileName != null) && (attFileName.Count > 0))
                {
                    NotesRichTextItem item = doc.CreateRichTextItem("attachment");
                    foreach (string att in attFileName)
                    {
                        item.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, "", att, "attachment");
                        doc.ReplaceItemValue("fname", System.IO.Path.GetFileName(att));
                    }
                }

                doc.ComputeWithForm(true, false);
                object obj = doc.GetItemValue("SendTo");
                doc.Send(false, ref obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #31
0
	public void LoadNotes() {

		this.db = new NotesDatabase();
		this.notes = db.FetchNotes();
		foreach(NoteData x in this.notes) {
			this.note_windows.Append(new NoteWindow(x,background_window));
		}

	}
Example #32
0
        public Program()
        {
            ns = new NotesSession();
            ns.Initialize("password");

            string mailServer = ns.GetEnvironmentString("MailServer", true);
            string mailFile   = ns.GetEnvironmentString("MailFile", true);
            string userName   = ns.UserName;

            System.Console.WriteLine($"mailServer: {mailServer}");
            System.Console.WriteLine($"mailFile: {mailFile}");
            System.Console.WriteLine($"userName: {userName}");

            StringBuilder fullpathName = new StringBuilder(512);

            OSPathNetConstruct(null, mailServer, mailFile, fullpathName);
            System.Console.WriteLine($"fullpathName: {fullpathName.ToString()}");

            HANDLE hNotesDB;
            HANDLE hUnreadListTable;

            NSFDbOpen(fullpathName.ToString(), out hNotesDB);
            System.Console.WriteLine($"hNotesDB: {hNotesDB.ToString()}");

            NSFDbGetUnreadNoteTable(hNotesDB, userName, (ushort)userName.Length, true, out hUnreadListTable);
            System.Console.WriteLine($"hUnreadListTable: {hUnreadListTable.ToString()}");
            db = ns.GetDatabase(mailServer, mailFile, false);

            int    numUnreadMail = 0;
            bool   first         = true;
            HANDLE id;

            while (true)
            {
                numUnreadMail = 0; first = true;
                while (IDScan(hUnreadListTable, first, out id))
                {
                    doc = db.GetDocumentByID(id.ToString("X"));
                    string subject = (string)((object[])doc.GetItemValue("Subject"))[0];
                    string sender  = (string)((object[])doc.GetItemValue("From"))[0];
                    if (!sender.Equals(""))
                    {
                        System.Console.WriteLine($"   Doc: {subject} / *{sender}*");
                        if (!sender.Equals(userName))
                        {
                            numUnreadMail++;
                        }
                    }
                    first = false;
                }
                //numUnreadMail -= 3;
                System.Console.WriteLine($"Unread mail: {numUnreadMail.ToString()}");
                System.Threading.Thread.Sleep(3000);
                NSFDbUpdateUnread(hNotesDB, hUnreadListTable);
            }
            IDDestroyTable(hUnreadListTable);
            NSFDbClose(hNotesDB);

            /*
             * db = ns.GetDatabase(mailServer, mailFile, false);
             *
             * NotesView inbox = db.GetView("($Inbox)");
             * doc = inbox.GetFirstDocument();
             * System.Console.WriteLine($"Notes database: /{db.ToString()}");
             *
             * // NotesViewEntryCollection vc = inbox.GetAllUnreadEntries();
             *
             * while (doc != null)
             * {
             *  System.DateTime lastAccessed = doc.LastAccessed;
             *  System.DateTime lastModified = doc.LastModified;
             *  System.DateTime created = doc.Created;
             *
             *  //if ( (lastAccessed.Subtract(lastModified)).TotalSeconds==(double)0.0 && (created.Subtract(lastModified)).TotalSeconds<(double)60.0 )
             *  if (lastAccessed.CompareTo(lastModified) < 0)
             *
             *  {
             *      string subject = (string)((object[])doc.GetItemValue("Subject"))[0];
             *      System.Console.WriteLine($"LastAccessed: {doc.LastAccessed} | LastModified: {doc.LastModified} | Created: {doc.Created} | Subject: {subject}");
             *  }
             *  doc = inbox.GetNextDocument(doc);
             * }
             *
             * db = null;
             * ns = null;
             *
             */

            System.Console.WriteLine("Hello world!");
            System.Console.ReadLine();      // as pause
        }
Example #33
0
	public void save () {
		NotesDatabase database = new NotesDatabase();
		database.QueryNoResults("UPDATE notes SET text = '" + this.get_text() + "', " + 
					    		"color = '" + this.get_color() + "'" +  
								", pos_x = " + this.get_pos_x() + " " + 
								", pos_y = " + this.get_pos_y() + " " + 
							   	"WHERE id = " + this.get_id());
	}