示例#1
0
        private IEnumerable <NotesViewEntry> GetNotesViewEntry(NotesView nv)
        {
            NotesViewEntryCollection col = nv.AllEntries;

            if (col.Count > 0)
            {
                UpdateText(lblStatus, "Get Notes Entries...");

                UpdateText(lblNotesEntryTotal, col.Count.ToString());

                for (int index = 1; index <= col.Count; index++)
                {
                    UpdateText(lblNotesEntryCount, index.ToString());

                    NotesViewEntry entry = col.GetNthEntry(index);
                    yield return(entry);

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

                    //Application.DoEvents();
                }

                UpdateText(lblStatus, "Get Notes Entries Completed.");
            }
        }
示例#2
0
        private Dictionary <string, string> ProcessNotesView(NotesView notesView, string searchText)
        {
            Dictionary <string, string> entryOutput = new Dictionary <string, string>();

            foreach (var entry in GetNotesViewEntry(notesView))
            {
                //Application.DoEvents();

                if (entry == null)
                {
                    continue;
                }

                // Skip the entry if already processed
                if (_universalIDList.Contains(entry.UniversalID))
                {
                    continue;
                }
                //if (entryOutput.ContainsKey(entry.UniversalID)) continue;

                var entryContent = ProcessNotesViewEntry(entry, searchText);

                if (string.IsNullOrEmpty(entryContent) == false && entryContent.Trim().Length > 0)
                {
                    _universalIDList.Add(entry.UniversalID);

                    entryOutput.Add(entry.UniversalID, entryContent);
                    //Application.DoEvents();
                }
            }

            return(entryOutput);
        }
示例#3
0
        public static string GetNotesViewItem(RestCommand command, int noteID)
        {
            NotesViewItem notesViewItem = NotesView.GetNotesViewItem(command.LoginUser, noteID);

            if (notesViewItem.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(notesViewItem.GetXml("NotesViewItem", true));
        }
示例#4
0
        override protected void LoadData()
        {
            NotesView notes = new NotesView(_loginUser);

            notes.LoadForIndexing(_organizationID, _maxCount, _isRebuilding);
            foreach (NotesViewItem note in notes)
            {
                _itemIDList.Add(note.NoteID);
            }
        }
示例#5
0
 private void CreateNotesView()
 {
     if (notesView == null)
     {
         notesView            = new NotesView();
         notesView.BeginEdit += notesView_BeginEdit;
         notesView.EndEdit   += notesView_EndEdit;
         panelsGrid.Children.Add(notesView);
         notesView.UpdateLayout();
     }
 }
示例#6
0
        public void RefreshView(bool refreshFilter)
        {
            App.Logger.Trace("NotesViewFlat", $"RefreshView({refreshFilter})");

            if (refreshFilter)
            {
                _filterData.Clear();
            }

            NotesView.Refresh();
        }
示例#7
0
        public static string GetNotesView(RestCommand command)
        {
            NotesView notesView = new NotesView(command.LoginUser);

            notesView.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(notesView.GetXml("NotesView", "NotesViewItem", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
示例#8
0
        /// <summary>
        /// Удаление всей почты если переполнение документами и сжатие БД
        /// Нет доступа на Compact() БД
        /// </summary>
        public void DeleteDataBaseAllMailSizeWarning()
        {
            var sizeWarning = Db.SizeWarning * 0.001; //Мегабайт
            var size        = Db.Size / 1024 / 1024;  //Байты в Мегабайты

            if (size > sizeWarning)
            {
                try
                {
                    Db.AllDocuments.RemoveAll(true);
                    NotesView = GetViewLotus("$SoftDeletions");
                    Document  = NotesView.GetFirstDocument();
                    while (Document != null)
                    {
                        var universalId = Document.UniversalID;
                        var doc         = Document;
                        Document = NotesView.GetNextDocument(Document);
                        doc.RemovePermanently(true);
                        if (doc.IsDeleted)
                        {
                            Loggers.Log4NetLogger.Info(new Exception($"Документ под ID: {universalId} удален!"));
                        }
                    }
                    NotesView.Refresh();
                    Loggers.Log4NetLogger.Error(new Exception($"Срочно требуется сжатие БД {Db.FileName}!!!"));
                }
                catch (Exception ex)
                {
                    Loggers.Log4NetLogger.Error(ex);
                }
                finally
                {
                    if (Document != null)
                    {
                        Marshal.ReleaseComObject(Document);
                    }
                    Document = null;
                    if (NotesView != null)
                    {
                        Marshal.ReleaseComObject(NotesView);
                    }
                    NotesView = null;
                }
            }
        }
示例#9
0
 public void Execute(object parameter)
 {
     if (parameter.ToString() == "Home")
     {
         viewModel.SelectedViewModel = new HomeViewModel();
     }
     else if (parameter.ToString() == "Account")
     {
         viewModel.SelectedViewModel = new AccountViewModel();
     }
     else if (parameter.ToString() != null)
     {
         viewModel2.TempUser.Password = parameter.ToString();
         if (viewModel2.SearchByName())
         {
             NotesView win1 = new NotesView();
             win1.DataContext = new NotesViewModel(viewModel2.TempUser);
             win1.Show();
             System.Windows.Application.Current.MainWindow.Close();
         }
     }
 }
示例#10
0
        override protected void GetNextRecord()
        {
            NotesViewItem note = NotesView.GetNotesViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = note.NoteID;
            UpdatedItems.Add((int)_lastItemID);


            DocText = HtmlToText.ConvertHtml(note.Description);

            _docFields.Clear();
            foreach (DataColumn column in note.Collection.Table.Columns)
            {
                object value = note.Row[column];
                string s     = value == null || value == DBNull.Value ? "" : value.ToString();
                AddDocField(column.ColumnName, s);
            }
            DocFields       = _docFields.ToString();
            DocIsFile       = false;
            DocName         = note.NoteID.ToString();
            DocCreatedDate  = note.DateCreatedUtc;
            DocModifiedDate = DateTime.UtcNow;
        }
示例#11
0
        public MainForm()
        {
            Instance = this;

            InitializeComponent();

            // Set the XML file's build action to "Embedded Resource" and "Never copy" for this to work.
            Tx.LoadFromEmbeddedResource("Unclassified.LogSubmit.LogSubmit.txd");
            TxDictionaryBinding.AddTextBindings(this);

            // Initialise views
            logSelectionView = new LogSelectionView();

            // Read configuration file
            string configFile = Path.Combine(
                Path.GetDirectoryName(Application.ExecutablePath),
                "submit.config");

            try
            {
                ConfigReader config = new ConfigReader(configFile);
                config.Read();
            }
            catch (Exception ex)
            {
                logSelectionView.SetConfigError(ex);
            }

            // Initialise more views
            timeSelectionView     = new TimeSelectionView();
            notesView             = new NotesView();
            compressView          = new CompressView();
            transportView         = new TransportView();
            transportProgressView = new TransportProgressView();

            views.Add(logSelectionView);
            views.Add(timeSelectionView);
            views.Add(notesView);
            views.Add(compressView);
            views.Add(transportView);
            views.Add(transportProgressView);

            // Other initialisation
            Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            UIPreferences.UpdateFormFont(this, Font, SystemFonts.MessageBoxFont);
            USizeGrip.AddToForm(this);

            systemMenu = new SystemMenu(this);
            systemMenu.AddCommand(Tx.T("menu.about"), OnSysMenuAbout, true);

            progressPanel        = new Panel();
            progressPanel.Left   = 0;
            progressPanel.Top    = 0;
            progressPanel.Width  = 0;
            progressPanel.Height = 2;
            //progressPanel.BackColor = SystemColors.Highlight;
            progressPanel.BackColor = Color.Gray;
            Controls.Add(progressPanel);
            progressPanel.BringToFront();

            // Parse command line arguments
            CommandLineReader cmdLine = new CommandLineReader();

            fromErrorDlgOption = cmdLine.RegisterOption("errordlg");
            fromShortcutOption = cmdLine.RegisterOption("shortcut");
            logPathOption      = cmdLine.RegisterOption("logpath", 1);
            endTimeOption      = cmdLine.RegisterOption("endtime", 1);

            try
            {
                cmdLine.Parse();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    Tx.T("msg.command line error", "msg", ex.Message),
                    Tx.T("msg.title.error"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            SharedData.Instance.FromErrorDialog = fromErrorDlgOption.IsSet;
            SharedData.Instance.FromShortcut    = fromShortcutOption.IsSet;

            if (logPathOption.IsSet)
            {
                try
                {
                    logSelectionView.SetLogBasePath(logPathOption.Value);
                }
                catch
                {
                    MessageBox.Show(
                        Tx.T("msg.logpath parameter invalid", "value", logPathOption.Value),
                        Tx.T("msg.title.error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    logSelectionView.ResetLogBasePath();
                    logSelectionView.FindLogBasePath();
                }
            }
            else
            {
                logSelectionView.FindLogBasePath();
            }

            if (endTimeOption.IsSet)
            {
                try
                {
                    appStartTime = DateTime.Parse(endTimeOption.Value);
                    SharedData.Instance.LastLogUpdateTime = appStartTime;
                }
                catch
                {
                    MessageBox.Show(
                        Tx.T("msg.endtime parameter invalid", "value", endTimeOption.Value),
                        Tx.T("msg.title.error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            // Set start view
            SetView(logSelectionView, true);
        }
示例#12
0
 public bool Contains(INote n)
 {
     return(NotesView.Contains(n));
 }
示例#13
0
 public void RefreshView()
 {
     App.Logger.Trace("NotesViewFlat", "RefreshView()");
     NotesView.Refresh();
 }
示例#14
0
        private void cmdOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_LocalNotesSession == null)
                {
                    _LocalNotesSession = new NotesSessionClass();
                    //Initializing Lotus Notes Session
                    try
                    {
                        _LocalNotesSession.Initialize(txtPassword.Password);
                    }
                    catch (COMException cex)
                    {
                        if (cex.ErrorCode != -2147217504)
                        {
                            throw;
                        }
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("pwrd_not_match", "Invalid password"),
                                          PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }
                //Creating Lotus Notes DataBase Object
                var localDatabase = _LocalNotesSession.GetDatabase("", "names.nsf", false);

                if (_ServerNotesSession == null)
                {
                    _ServerNotesSession = new NotesSessionClass();
                    //Initializing Lotus Notes Session
                    try
                    {
                        _ServerNotesSession.Initialize(txtPassword.Password);
                    }
                    catch (COMException cex)
                    {
                        if (cex.ErrorCode != -2147217504)
                        {
                            throw;
                        }
                        PNMessageBox.Show(PNLang.Instance.GetMessageText("pwrd_not_match", "Invalid password"),
                                          PNStrings.PROG_NAME, MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }
                //Creating Lotus Notes DataBase Object
                var serverDatabase = _ServerNotesSession.GetDatabase(txtServer.Text.Trim(), "names.nsf", false);

                //creating Lotus Notes Contact View
                NotesView contactsView = null, peopleView = null;
                if (localDatabase != null)
                {
                    contactsView = localDatabase.GetView("Contacts");
                }
                if (serverDatabase != null)
                {
                    peopleView = serverDatabase.GetView("$People");
                }

                if (LotusCredentialSet != null)
                {
                    LotusCredentialSet(this, new LotusCredentialSetEventArgs(contactsView, peopleView));
                }
                DialogResult = true;
            }
            catch (Exception ex)
            {
                PNStatic.LogException(ex);
            }
        }
示例#15
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);
        }
示例#16
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;
            }
        }
        /// <summary>
        /// 获取新信件
        /// </summary>
        /// <returns></returns>
        public bool GetMailInfo()
        {
            bool          bResult       = false;
            NotesView     pMailView     = null;
            NotesDocument pMailDocument = null;
            int           iCount        = 0;

            try
            {
                if (this._strDataBase == "names.nsf")
                {
                    this.pNotesDatabase = this._pNotesSession.GetDatabase(this._strDomain, this._strDataBase, false);
                }

                if (this.pNotesDatabase == null)
                {
                    throw new Exception("不能打开数据库:" + this._strDataBase);
                }

                pMailView = this.pNotesDatabase.GetView("($inbox)");

                pMailDocument = pMailView.GetFirstDocument();
                Console.WriteLine("共计:" + pMailView.EntryCount.ToString());

                CustomDataCollection pMailStruct = new CustomDataCollection(StructType.CUSTOMDATA);

                while (pMailDocument != null)
                {
                    if (((object[])pMailDocument.GetItemValue("Reader"))[0].ToString() != "YES")
                    {
                        string strPUID        = string.Empty;
                        string strSubject     = (((object[])pMailDocument.ColumnValues)[5] == null) ? "N/A" : ((object[])pMailDocument.ColumnValues)[5].ToString();
                        string strSupervisors = (((object[])pMailDocument.GetItemValue("CopyTo")).Length == 0) ? "N/A" : ((object[])pMailDocument.GetItemValue("CopyTo"))[0].ToString();
                        string strSendTo      = (((object[])pMailDocument.GetItemValue("SendTo")).Length == 0) ? "N/A" : ((object[])pMailDocument.GetItemValue("SendTo"))[0].ToString();

                        if (strSendTo != "N/A")
                        {
                            for (int i = 0; i < ((object[])pMailDocument.GetItemValue("SendTo")).Length; i++)
                            {
                                strSupervisors = strSupervisors + ";" + ((object[])pMailDocument.GetItemValue("SendTo"))[i].ToString();
                            }
                        }

                        if (strSupervisors != "N/A")
                        {
                            for (int i = 1; i < ((object[])pMailDocument.GetItemValue("CopyTo")).Length; i++)
                            {
                                strSupervisors = strSupervisors + ";" + ((object[])pMailDocument.GetItemValue("CopyTo"))[i].ToString();
                            }
                        }

                        string strBody = ((object[])pMailDocument.GetItemValue("Body"))[0].ToString();

                        if (((object[])pMailDocument.GetItemValue("SSM_Agent"))[0].ToString().Length != 0)
                        {
                            strPUID = ((object[])pMailDocument.GetItemValue("SSM_Agent"))[0].ToString();
                        }
                        else if (((object[])pMailDocument.GetItemValue("SSM_Agent"))[0].ToString().Length == 0 && pMailDocument.ParentDocumentUNID == null)
                        {
                            strPUID = "N/A";
                        }
                        else
                        {
                            strPUID = pMailDocument.ParentDocumentUNID;
                        }

                        /*
                         * if (pMailDocument.HasItem("SMS Agent"))
                         * {
                         *  strPUID = ((object[])pMailDocument.GetItemValue("SMS Agent"))[0].ToString();
                         * }
                         * else if (!pMailDocument.HasItem("SMS Agent") && pMailDocument.ParentDocumentUNID == null)
                         * {
                         *  strPUID = "N/A";
                         * }
                         * else
                         * {
                         *  strPUID = pMailDocument.ParentDocumentUNID;
                         * }
                         */

                        //剔除--服务器正常和服务器一切正常
                        if (strSubject.IndexOf("服务器正常", StringComparison.CurrentCulture) > 0 || strSubject.IndexOf("服务器一切正常", StringComparison.CurrentCulture) > 0)
                        {
                            if (pMailDocument.HasItem("Reader"))
                            {
                                pMailDocument.ReplaceItemValue("Reader", "YES");
                            }
                            else
                            {
                                pMailDocument.AppendItemValue("Reader", "YES");
                            }

                            pMailDocument.Save(true, true, true);
                        }
                        else
                        {
                            pMailStruct.Add(DataField.NOTES_UID, DataFormat.STRING, pMailDocument.UniversalID);
                            pMailStruct.Add(DataField.NOTES_UID, DataFormat.STRING, strPUID);
                            pMailStruct.Add(DataField.NOTES_SUBJECT, DataFormat.STRING, strSubject);
                            pMailStruct.Add(DataField.NOTES_FROM, DataFormat.STRING, ((object[])pMailDocument.GetItemValue("Principal"))[0].ToString());
                            pMailStruct.Add(DataField.NOTES_DATE, DataFormat.STRING, ((object[])pMailDocument.ColumnValues)[2].ToString());
                            pMailStruct.Add(DataField.NOTES_SUPERVISORS, DataFormat.STRING, (strSupervisors == "") ? "N/A" : strSupervisors);
                            pMailStruct.Add(DataField.NOTES_CONTENT, DataFormat.STRING, (strBody == "") ? "N/A" : strBody);
                            try
                            {
                                pMailStruct.Add(DataField.NOTES_ATTACHMENTCOUNT, DataFormat.STRING, (((NotesRichTextItem)pMailDocument.GetFirstItem("Body")).EmbeddedObjects == null) ? "0" : ((object[])((NotesRichTextItem)pMailDocument.GetFirstItem("Body")).EmbeddedObjects).Length.ToString());
                            }
                            catch
                            {
                                pMailStruct.Add(DataField.NOTES_ATTACHMENTCOUNT, DataFormat.STRING, "信件内包含多个信件主体,请查阅自己的信箱!");
                            }
                            pMailStruct.AddRows();

                            //GlobalStruct[] pMailStruct = new GlobalStruct[8];

                            //pMailStruct[0].oFieldsName = "Notes_UID";
                            //pMailStruct[0].oFiledsTypes = "String";
                            //pMailStruct[0].oFieldValues = pMailDocument.UniversalID;

                            //pMailStruct[1].oFieldsName = "Notes_PUID";
                            //pMailStruct[1].oFiledsTypes = "String";
                            //pMailStruct[1].oFieldValues = strPUID; // (pMailDocument.ParentDocumentUNID == null) ? "N/A" : pMailDocument.ParentDocumentUNID;

                            //pMailStruct[2].oFieldsName = "Notes_Subject";
                            //pMailStruct[2].oFiledsTypes = "String";
                            //pMailStruct[2].oFieldValues = strSubject;

                            //pMailStruct[3].oFieldsName = "Notes_From";
                            //pMailStruct[3].oFiledsTypes = "String";
                            //pMailStruct[3].oFieldValues = ((object[])pMailDocument.GetItemValue("Principal"))[0].ToString(); //((object[])pMailDocument.ColumnValues)[1].ToString();

                            //pMailStruct[4].oFieldsName = "Notes_Date";
                            //pMailStruct[4].oFiledsTypes = "String";
                            //pMailStruct[4].oFieldValues = ((object[])pMailDocument.ColumnValues)[2].ToString();

                            //pMailStruct[5].oFieldsName = "Notes_Supervisors";
                            //pMailStruct[5].oFiledsTypes = "String";
                            //pMailStruct[5].oFieldValues = (strSupervisors == "") ? "N/A" : strSupervisors;

                            //pMailStruct[6].oFieldsName = "Notes_Content";
                            //pMailStruct[6].oFiledsTypes = "String";
                            //pMailStruct[6].oFieldValues = (strBody == "") ? "N/A" : strBody;

                            //pMailStruct[7].oFieldsName = "Notes_AttachmentCount";
                            //pMailStruct[7].oFiledsTypes = "String";
                            //try
                            //{
                            //    pMailStruct[7].oFieldValues = (((NotesRichTextItem)pMailDocument.GetFirstItem("Body")).EmbeddedObjects == null) ? "0" : ((object[])((NotesRichTextItem)pMailDocument.GetFirstItem("Body")).EmbeddedObjects).Length.ToString();
                            //}
                            //catch
                            //{
                            //    pMailStruct[7].oFieldValues = "信件内包含多个信件主体,请查阅自己的信箱!";
                            //}

                            this.pInfoList.Add(pMailStruct);

                            if (pMailDocument.HasItem("Reader"))
                            {
                                pMailDocument.ReplaceItemValue("Reader", "YES");
                            }
                            else
                            {
                                pMailDocument.AppendItemValue("Reader", "YES");
                            }

                            //pMailStruct = null;

                            pMailDocument.Save(true, true, true);
                            iCount++;
                        }
                    }

                    //pMailDocument.PutInFolder("历史纪录", false);

                    pMailDocument = pMailView.GetNextDocument(pMailDocument);

                    //if (pMailDocument != null)
                    //{
                    //    pMailView.GetPrevDocument(pMailDocument).Remove(false);
                    //}
                }

                this.pRecords = pMailStruct;
                bResult       = true;
            }
            catch (Exception ex)
            {
                this.strMessage = ex.Message;
                Console.WriteLine("丢失Notes个数" + iCount.ToString());
                bResult = false;
                //this.pInfoList.Clear();
            }
            finally
            {
                if (pMailDocument != null)
                {
                    Marshal.ReleaseComObject(pMailDocument);
                }

                if (pMailView != null)
                {
                    Marshal.ReleaseComObject(pMailView);
                }

                pMailDocument = null;
                pMailView     = null;
            }

            return(bResult);
        }
        /// <summary>
        /// 将超过指定时间的邮件移动到指定目录下
        /// </summary>
        /// <returns></returns>
        public bool MoveMailInfo()
        {
            bool          bResult       = false;
            NotesView     pMailView     = null;
            NotesDocument pMailDocument = null;

            try
            {
                if (this._strDataBase == "names.nsf")
                {
                    this.pNotesDatabase = this._pNotesSession.GetDatabase(this._strDomain, this._strDataBase, false);
                }

                if (null == this.pNotesDatabase)
                {
                    throw new Exception("不能打开数据库:" + this._strDataBase);
                }

                pMailView = this.pNotesDatabase.GetView("($inbox)");

                pMailDocument = pMailView.GetFirstDocument();

                DateTime NowTime = DateTime.Now.AddDays(-2);

                int MailCount = 0;

                for (int i = 0; i < pMailView.EntryCount; i++)
                {
                    if (null != pMailDocument)
                    {
                        DateTime MailTime    = Convert.ToDateTime(((object[])pMailDocument.GetItemValue("DeliveredDate"))[0].ToString());
                        string   str_subject = ((object[])pMailDocument.ColumnValues)[5].ToString();

                        if (NowTime > MailTime || 0 < str_subject.IndexOf("服务器正常", 0) || 0 < str_subject.IndexOf("服务器一切正常", 0))
                        {
                            pMailDocument.PutInFolder("超时邮件", false);

                            NotesDocument oldMailDocument = pMailDocument;
                            if (null != oldMailDocument)
                            {
                                oldMailDocument.RemoveFromFolder("($inbox)");
                            }
                            pMailDocument = pMailView.GetFirstDocument();
                            i             = -1;
                            MailCount++;
                        }
                        else
                        {
                            pMailDocument = pMailView.GetNextDocument(pMailDocument);
                        }
                    }
                }

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("共移动了:" + MailCount);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("");

                bResult = true;
            }
            catch (Exception ex)
            {
                this.strMessage = ex.Message;
                Console.WriteLine(ex.Message);

                bResult = false;
            }
            finally
            {
                if (pMailDocument != null)
                {
                    Marshal.ReleaseComObject(pMailDocument);
                }

                if (pMailView != null)
                {
                    Marshal.ReleaseComObject(pMailView);
                }

                pMailDocument = null;
                pMailView     = null;
            }

            return(bResult);
        }
 private ViewModel CreateModelOrNull(NotesView view) => view != null ? new ViewModel(wrapper, view) : null;
        /// <summary>
        /// 获取信件中的附件内容
        /// </summary>
        /// <param name="strNotesUID"></param>
        /// <returns></returns>
        public bool GetMailAttachment(string strNotesUID)
        {
            bool          bResult       = false;
            NotesView     pMailView     = null;
            NotesDocument pMailDocument = null;
            int           iCount        = 0;

            try
            {
                if (this._strDataBase == "names.nsf")
                {
                    this.pNotesDatabase = this._pNotesSession.GetDatabase(this._strDomain, this._strDataBase, false);
                }

                if (this.pNotesDatabase == null)
                {
                    throw new Exception("不能打开数据库:" + this._strDataBase);
                }

                pMailView = this.pNotesDatabase.GetView("($inbox)");

                pMailDocument = pMailView.GetFirstDocument();

                CustomDataCollection pAttachmentStruct = new CustomDataCollection(StructType.CUSTOMDATA);

                while (pMailDocument != null)
                {
                    if (pMailDocument.UniversalID == strNotesUID)
                    {
                        object[] arrItemObject = (object[])((NotesRichTextItem)pMailDocument.GetFirstItem("Body")).EmbeddedObjects;

                        for (int i = 0; i < arrItemObject.Length; i++)
                        {
                            NotesEmbeddedObject pEmbeddedObject = (NotesEmbeddedObject)arrItemObject[i];

                            pEmbeddedObject.ExtractFile(System.AppDomain.CurrentDomain.BaseDirectory + "\\Attachment\\" + pEmbeddedObject.Source);

                            FileStream pAttachmentStream  = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "\\Attachment\\" + pEmbeddedObject.Source, FileMode.Open, FileAccess.Read);
                            byte[]     pAttachmentContent = new byte[pAttachmentStream.Length];
                            pAttachmentStream.Read(pAttachmentContent, 0, pAttachmentContent.Length);
                            pAttachmentStream.Close();
                            pAttachmentStream.Dispose();

                            File.Delete(System.AppDomain.CurrentDomain.BaseDirectory + "\\Attachment\\" + pEmbeddedObject.Source);

                            pAttachmentStruct.Add(DataField.NOTES_ATTACHMENTNAME, DataFormat.STRING, pEmbeddedObject.Source);
                            pAttachmentStruct.Add(DataField.NOTES_ATTACHMENTCOUNT, DataFormat.NONE, pAttachmentContent);
                            pAttachmentStruct.AddRows();

                            //GlobalStruct[] pAttachmentStruct = new GlobalStruct[2];

                            //pAttachmentStruct[0].oFieldsName = "Notes_AttachmentName";
                            //pAttachmentStruct[0].oFiledsTypes = "String";
                            //pAttachmentStruct[0].oFieldValues = pEmbeddedObject.Source;

                            //pAttachmentStruct[1].oFieldsName = "Notes_AttachmentCount";
                            //pAttachmentStruct[1].oFiledsTypes = "Byte[]";
                            //pAttachmentStruct[1].oFieldValues = pAttachmentContent;

                            pAttachmentContent = null;

                            this.pInfoList.Add(pAttachmentStruct);
                        }
                    }

                    pMailDocument = pMailView.GetNextDocument(pMailDocument);
                    iCount++;
                }

                this.pRecords = pAttachmentStruct;
                bResult       = true;
            }
            catch (Exception ex)
            {
                this.strMessage = ex.Message;

                bResult = false;
                //this.pInfoList.Clear();
            }
            finally
            {
                if (pMailDocument != null)
                {
                    Marshal.ReleaseComObject(pMailDocument);
                }

                if (pMailView != null)
                {
                    Marshal.ReleaseComObject(pMailView);
                }

                pMailDocument = null;
                pMailView     = null;
            }

            if (iCount == 0)
            {
                return(false);
            }

            return(bResult);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string domain = SystemSettings.GetAppUrl();

        if (Request["CustomerID"] == null)
        {
            EndResponse("Invalid Customer");
        }

        int          organizationID = int.Parse(Request["CustomerID"]);
        Organization organization   = Organizations.GetOrganization(TSAuthentication.GetLoginUser(), organizationID);

        if (organization == null)
        {
            EndResponse("Invalid Customer");
        }

        if (organization.OrganizationID != TSAuthentication.OrganizationID && organization.ParentID != TSAuthentication.OrganizationID)
        {
            EndResponse("Invalid Customer");
        }

        tipCompany.InnerText = organization.Name;
        tipCompany.Attributes.Add("onclick", "top.Ts.MainPage.openNewCustomer(" + organizationID.ToString() + "); return false;");

        StringBuilder props = new StringBuilder();

        if (!string.IsNullOrEmpty(organization.Website))
        {
            string website;
            website = organization.Website;
            if (organization.Website.IndexOf("http://") < 0 && organization.Website.IndexOf("https://") < 0)
            {
                website = "http://" + organization.Website;
            }
            props.Append(string.Format("<dt>Website</dt><dd><a target=\"_blank\" href=\"{0}\">{0}</a></dd>", website));
        }

        if (organization.SAExpirationDate != null)
        {
            string css = organization.SAExpirationDate <= DateTime.UtcNow ? "tip-customer-expired" : "";
            props.Append(string.Format("<dt>Service Expiration</dt><dd class=\"{0}\">{1:D}</dd>", css, (DateTime)organization.SAExpirationDate));
        }

        PhoneNumbersView numbers = new PhoneNumbersView(organization.Collection.LoginUser);

        numbers.LoadByID(organization.OrganizationID, ReferenceType.Organizations);

        foreach (PhoneNumbersViewItemProxy number in numbers.GetPhoneNumbersViewItemProxies())
        {
            props.Append(string.Format("<dt>{0}</dt><dd><a href=\"tel:{1}\">{1} {2}</a></dd>", number.PhoneType, number.FormattedPhoneNumber, number.Extension));
        }

        tipProps.InnerHtml = props.ToString();

        TicketsView tickets = new TicketsView(TSAuthentication.GetLoginUser());

        tickets.LoadLatest5Tickets(organizationID);
        StringBuilder recent = new StringBuilder();

        foreach (TicketsViewItem t in tickets)
        {
            if (t.TicketNumber != null && t.Name != null && t.Status != null)
            {
                recent.Append(string.Format("<div><a href='{0}?TicketNumber={1}' target='_blank' onclick='top.Ts.MainPage.openTicket({2}); return false;'><span class='ticket-tip-number'>{3}</span><span class='ticket-tip-status'>{4}</span><span class='ticket-tip-name'>{5}</span></a></div>", domain, t.TicketNumber, t.TicketNumber, t.TicketNumber, t.Status.Length > 17 ? t.Status.Substring(0, 15) + "..." : t.Status, t.Name.Length > 35 ? t.Name.Substring(0, 33) + "..." : t.Name));
            }
        }

        if (recent.Length == 0)
        {
            recent.Append("There are no recent tickets for this organization");
        }

        tipRecent.InnerHtml = recent.ToString();

        //Support Hours
        StringBuilder supportHours = new StringBuilder();

        if (organization.SupportHoursMonth > 0)
        {
            tipTimeSpent.Visible = true;
            double timeSpent = organization.GetTimeSpentMonth(TSAuthentication.GetLoginUser(), organization.OrganizationID) / 60;
            supportHours.AppendFormat("<div class='ui-widget-content ts-separator'></div><div id='tipRecent' runat='server'><dt>Monthly Support Hours</dt><dt>Hours Used</dt><dd>{0}</dd><dt>Hours Remaining</dt>", Math.Round(timeSpent, 2));

            if (timeSpent > organization.SupportHoursMonth)
            {
                supportHours.AppendFormat("<dd class='red'>-{0}</dd>", Math.Round(timeSpent - organization.SupportHoursMonth, 2));
            }
            else
            {
                supportHours.AppendFormat("<dd>{0}</dd>", Math.Round(organization.SupportHoursMonth - timeSpent, 2));
            }
        }


        tipTimeSpent.InnerHtml = supportHours.ToString();

        // Customer Notes
        StringBuilder notesString = new StringBuilder();
        NotesView     notes       = new NotesView(TSAuthentication.GetLoginUser());

        notes.LoadbyCustomerID(organizationID);

        foreach (NotesViewItem t in notes)
        {
            notesString.Append(string.Format("<div><a href='#' target='_blank' onclick='top.Ts.MainPage.openNewCustomerNote({0},{1}); return false;'><span class='ticket-tip-name'>{2}</span></a></div>", t.RefID, t.NoteID, t.Title.Length > 65 ? t.Title.Substring(0, 65) + "..." : t.Title));
        }

        if (notesString.Length == 0)
        {
            notesString.Append("");
        }

        tipNotes.InnerHtml = notesString.ToString();
    }
示例#22
0
 internal LotusCredentialSetEventArgs(NotesView peopleView, NotesView contactsView)
 {
     PeopleView   = peopleView;
     ContactsView = contactsView;
 }
        /// <summary>
        /// 转发/回复信件
        /// </summary>
        /// <param name="pSupervisors">抄送人</param>
        /// <param name="pSendSecret">密送人</param>
        /// <param name="strNotesUID">原NotesID</param>
        /// <param name="strMailContent">内容</param>
        /// <returns></returns>
        public bool RelayMailInfo(object pSupervisors, object pSendSecret, string strNotesUID, string strMailContent)
        {
            bool          bResult         = false;
            NotesView     pParentView     = null;
            NotesDocument pParentDocument = null;

            try
            {
                if (this._strDataBase == "names.nsf")
                {
                    this.pNotesDatabase = this._pNotesSession.GetDatabase(this._strDomain, this._strDataBase, false);
                }

                if (this.pNotesDatabase == null)
                {
                    throw new Exception("不能打开数据库:" + this._strDataBase);
                }

                pParentView     = this.pNotesDatabase.GetView("($inbox)");
                pParentDocument = pParentView.GetFirstDocument();

                while (pParentDocument != null)
                {
                    if (pParentDocument.UniversalID == strNotesUID)
                    {
                        NotesDocument pRelayDocument  = pParentDocument.CreateReplyMessage(false);
                        string        strPrincipal    = (((object[])pParentDocument.GetItemValue("Principal"))[0] == null) ? "N/A" : ((object[])pParentDocument.GetItemValue("Principal"))[0].ToString();
                        string        strRelaySubject = (((object[])pParentDocument.GetItemValue("Subject"))[0] == null) ? "N/A" : ((object[])pParentDocument.GetItemValue("Subject"))[0].ToString();

                        pParentDocument.ReplaceItemValue("Form", "Reply");
                        pParentDocument.ReplaceItemValue("CopyTo", pSupervisors);     //抄送
                        pParentDocument.ReplaceItemValue("BlindCopyTo", pSendSecret); //密送
                        pParentDocument.ReplaceItemValue("Subject", "回复:" + strRelaySubject);
                        pParentDocument.ReplaceItemValue("PostedDate", DateTime.Now.ToString());
                        pParentDocument.ReplaceItemValue("Principal", "CN=netadmin/OU=网管部/OU=产品运营中心/O=runstar");
                        pParentDocument.ReplaceItemValue("Body", "");
                        pParentDocument.ReplaceItemValue("SSM_Agent", strNotesUID);

                        if (pParentDocument.HasItem("Reader"))
                        {
                            pParentDocument.ReplaceItemValue("Reader", "NO");
                        }

                        NotesRichTextItem pOldItem = (NotesRichTextItem)pParentDocument.GetFirstItem("Body");
                        pOldItem.AppendText(strMailContent);
                        pOldItem.AddNewLine(5, false);
                        pOldItem.AppendRTItem((NotesRichTextItem)pRelayDocument.GetFirstItem("Body"));

                        object pSendOwner = strPrincipal;//"孙露"
                        pParentDocument.Send(false, ref pSendOwner);

                        bResult = true;

                        Marshal.ReleaseComObject(pOldItem);
                        Marshal.ReleaseComObject(pRelayDocument);

                        pOldItem       = null;
                        pRelayDocument = null;
                        break;
                    }
                    else
                    {
                        bResult = false;

                        this.strMessage = "不能找到原始信件,原信件可能已删除,请新建一封信的信件给接收人!";
                    }

                    pParentDocument = pParentView.GetNextDocument(pParentDocument);
                }
            }
            catch (Exception ex)
            {
                this.strMessage = ex.Message;

                bResult = false;
            }
            finally
            {
                if (pParentDocument != null)
                {
                    Marshal.ReleaseComObject(pParentDocument);
                }

                if (pParentView != null)
                {
                    Marshal.ReleaseComObject(pParentView);
                }

                pParentDocument = null;
                pParentView     = null;
            }

            return(bResult);
        }
示例#24
0
 internal LotusCredentialSetEventArgs(NotesView peopleView, NotesView contactsView)
 {
     PeopleView = peopleView;
     ContactsView = contactsView;
 }
        /// <summary>
        /// 获取联系人
        /// </summary>
        /// <param name="strCategory">联系人分组</param>
        /// <returns></returns>
        public bool GetLinkerInfo(string strCategory)
        {
            bool          bResult         = false;
            NotesView     pLinkerView     = null;
            NotesDocument pLinkerDocument = null;

            try
            {
                if (this._strDataBase != "names.nsf")
                {
                    this.pNotesDatabase = this._pNotesSession.GetDatabase(this._strDomain, "names.nsf", false);
                }

                pLinkerView = this.pNotesDatabase.GetView(strCategory);

                pLinkerDocument = pLinkerView.GetFirstDocument();

                CustomDataCollection pLinkerStruct = new CustomDataCollection(StructType.CUSTOMDATA);

                while (pLinkerDocument != null)
                {
                    pLinkerStruct.Add(DataField.LINKER_NAME, DataFormat.STRING, pLinkerDocument.GetFirstItem("ListName").Text);
                    pLinkerStruct.Add(DataField.LINKER_CONTENT, DataFormat.STRING, (pLinkerDocument.GetFirstItem("Members") == null) ? "N/A" : pLinkerDocument.GetFirstItem("Members").Text);
                    pLinkerStruct.AddRows();

                    //pLinkerStruct[0].oFieldsName = "Linker_Name";
                    //pLinkerStruct[0].oFiledsTypes = "String";
                    //pLinkerStruct[0].oFieldValues = pLinkerDocument.GetFirstItem("ListName").Text;

                    //pLinkerStruct[1].oFieldsName = "Linker_Content";
                    //pLinkerStruct[1].oFiledsTypes = "String";
                    //pLinkerStruct[1].oFieldValues = (pLinkerDocument.GetFirstItem("Members") == null) ? "N/A" : pLinkerDocument.GetFirstItem("Members").Text;

                    //this.pInfoList.Add(pLinkerStruct);

                    pLinkerDocument = pLinkerView.GetNextDocument(pLinkerDocument);
                }
                this.pRecords = pLinkerStruct;
                bResult       = true;
            }
            catch (Exception ex)
            {
                this.strMessage = ex.Message;

                bResult = false;
                //this.pInfoList.Clear();
            }
            finally
            {
                if (pLinkerDocument != null)
                {
                    Marshal.ReleaseComObject(pLinkerDocument);
                }

                if (pLinkerView != null)
                {
                    Marshal.ReleaseComObject(pLinkerView);
                }

                pLinkerDocument = null;
                pLinkerView     = null;
            }

            return(bResult);
        }
示例#26
0
 public App(String filename)
 {
     InitializeComponent();
     NotesViewModel.Inicializador(filename);
     MainPage = new NotesView();
 }
示例#27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["UserID"] == null)
        {
            EndResponse("Invalid User");
        }
        int?ticketID = null;

        if (Request["TicketID"] != null)
        {
            int id;
            if (int.TryParse(Request["TicketID"], out id))
            {
                ticketID = id;
            }
        }

        string domain = SystemSettings.GetAppUrl();
        int    userID = int.Parse(Request["UserID"]);
        User   user   = Users.GetUser(TSAuthentication.GetLoginUser(), userID);

        if (user == null)
        {
            EndResponse("Invalid User");
        }
        Organization organization = Organizations.GetOrganization(user.Collection.LoginUser, user.OrganizationID);

        if (user.OrganizationID != TSAuthentication.OrganizationID && organization.ParentID != TSAuthentication.OrganizationID)
        {
            EndResponse("Invalid User");
        }
        tipName.InnerText = user.FirstLastName;

        if (user.OrganizationID == TSAuthentication.OrganizationID)
        {
            tipName.Attributes.Add("onclick", "top.Ts.MainPage.openNewContact(" + user.UserID.ToString() + "); return false;");
            tipCompany.Visible = false;
        }
        else
        {
            tipName.Attributes.Add("onclick", "top.Ts.MainPage.openContact(" + user.UserID.ToString() + "," + user.OrganizationID.ToString() + "); return false;");
            tipCompany.Visible = true;
        }

        tipCompany.InnerText = organization.Name;
        tipCompany.Attributes.Add("onclick", "top.Ts.MainPage.openNewCustomer(" + user.OrganizationID.ToString() + "); return false;");
        if (!string.IsNullOrEmpty(user.Title))
        {
            tipTitle.InnerHtml = user.Title + ", ";
        }

        StringBuilder props = new StringBuilder();

        if (!string.IsNullOrEmpty(user.Email))
        {
            if (ticketID != null)
            {
                props.Append(string.Format("<dt>Email</dt><dd><a href=\"{0}\" target=\"_blank\">{1}</a></dd>", DataUtils.GetMailLinkHRef(user.Collection.LoginUser, userID, (int)ticketID), user.Email));
            }
            else
            {
                props.Append(string.Format("<dt>Email</dt><dd><a href=\"mailto:{0}\" target=\"_blank\">{0}</a></dd>", user.Email));
            }
        }

        PhoneNumbersView numbers = new PhoneNumbersView(user.Collection.LoginUser);

        numbers.LoadByID(user.UserID, ReferenceType.Users);

        foreach (PhoneNumbersViewItemProxy number in numbers.GetPhoneNumbersViewItemProxies())
        {
            props.Append(string.Format("<dt>{0}</dt><dd><a href=\"tel:{1}\">{1} {2}</a></dd>", number.PhoneType, number.FormattedPhoneNumber, number.Extension));
        }

        tipProps.InnerHtml = props.ToString();

        TicketsView tickets = new TicketsView(TSAuthentication.GetLoginUser());

        tickets.LoadLatest5UserTickets(user.UserID);
        StringBuilder recent = new StringBuilder();

        foreach (TicketsViewItem t in tickets)
        {
            if (t.TicketNumber != null && t.Name != null && t.Status != null)
            {
                recent.Append(string.Format("<div><a href='{0}?TicketNumber={1}' target='_blank' onclick='top.Ts.MainPage.openTicket({2}); return false;'><span class='ticket-tip-number'>{3}</span><span class='ticket-tip-status'>{4}</span><span class='ticket-tip-name'>{5}</span></a></div>", domain, t.TicketNumber, t.TicketNumber, t.TicketNumber, t.Status.Length > 17 ? t.Status.Substring(0, 15) + "..." : t.Status, t.Name.Length > 35 ? t.Name.Substring(0, 33) + "..." : t.Name));
            }
        }

        if (recent.Length == 0)
        {
            recent.Append("There are no recent tickets for this user");
        }

        tipRecent.InnerHtml = recent.ToString();

        // Customer Notes
        StringBuilder notesString = new StringBuilder();
        NotesView     notes       = new NotesView(TSAuthentication.GetLoginUser());

        notes.LoadbyContactID(user.UserID);

        foreach (NotesViewItem t in notes)
        {
            notesString.Append(string.Format("<div><a href='#' target='_blank' onclick='top.Ts.MainPage.openNewContactNote({0},{1}); return false;'><span class='ticket-tip-name'>{2}</span></a></div>", t.RefID, t.NoteID, t.Title.Length > 65 ? t.Title.Substring(0, 65) + "..." : t.Title));
        }

        if (notesString.Length == 0)
        {
            notesString.Append("");
        }

        tipNotes.InnerHtml = notesString.ToString();
    }
示例#28
0
        /// <summary>
        /// Формирование модели для отправки по SMTP протоколу
        /// </summary>
        /// <param name="pathSaveFile">Путь сохранения вложенных в письма файлов на отправку</param>
        public List <MailLotusOutlookOut> SendMailOut(string pathSaveFile)
        {
            var mailLotusOutlookOut = new List <MailLotusOutlookOut>();
            var publicFunction      = new PublicFunctionInfo.PublicFunctionInfo();

            Db.LotusConnectedDataBaseServer(Config.LotusServer, Config.LotusMailSend);
            if (Db.Db == null)
            {
                throw new InvalidOperationException("Фатальная ошибка нет соединения с сервером!");
            }
            var docList = new List <string>();

            try
            {
                NotesView = Db.GetViewLotus("$Inbox");
                Document  = NotesView.GetFirstDocument();
                while (Document != null)
                {
                    var mail = new MailLotusOutlookOut
                    {
                        IdMail        = Document.UniversalID,
                        MailAdressOut = Document.GetItemValue("Subject")[0].ToString(),
                        Body          = Document.GetItemValue("Body")[0].ToString()
                    };
                    NotesRichTextItem bodyFileExtractMail = Document.GetFirstItem("Body") as NotesRichTextItem;
                    var nameFileList = publicFunction.ExtractFile(bodyFileExtractMail, pathSaveFile);
                    mail.FullPathListFile = nameFileList != null && nameFileList.Count > 0 ? string.Join(";", nameFileList) : null;
                    mail.MailAdressIn     = Document.GetItemValue("From")[0].ToString();
                    docList.Add(Document.UniversalID);
                    mailLotusOutlookOut.Add(mail);
                    Document = NotesView.GetNextDocument(Document);
                }
            }
            catch (Exception ex)
            {
                Loggers.Log4NetLogger.Error(ex);
                throw;
            }
            finally
            {
                if (Document != null)
                {
                    Marshal.ReleaseComObject(Document);
                }
                Document = null;
                if (NotesView != null)
                {
                    Marshal.ReleaseComObject(NotesView);
                }
                NotesView = null;
            }
            foreach (var unId in docList)
            {
                Document = Db.Db.GetDocumentByUNID(unId);
                if (Document == null)
                {
                    throw new InvalidOperationException($"No document {unId}");
                }
                Document.Remove(true);
                Marshal.ReleaseComObject(Document);
            }
            return(mailLotusOutlookOut);
        }
        private void OnViewNotes(AppMessages.ViewNotesMessage.MessageData message)
        {
            try
            {
                MainViewModel viewModel = (MainViewModel)DataContext;

                // check to see if the patient is restricted
                bool canProceed = CanUserViewPatientData(message.SiteCode, message.PatientICN);
                if (!canProceed)
                {
                    MessageBox.Show("You cannot view information on this patient.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                bool readOnly = viewModel.WorklistsViewModel.CurrentWorkList.Type == ExamListViewType.Patient ? true : false;
                NotesViewModel dialogViewModel = new NotesViewModel(viewModel.DataSource,
                                                                    message.SiteCode,
                                                                    message.PatientICN,
                                                                    message.PatientID,
                                                                    message.AccessionNr,
                                                                    message.CaseURN,
                                                                    readOnly);
                NotesView dialog = new NotesView(dialogViewModel);
                dialog.Owner = (message.Owner != null) ? message.Owner : this;

                ViewModelLocator.ContextManager.IsBusy = true;
                dialog.ShowDialog();
            }
            catch (Exception ex)
            {
                Log.Error("Failed to show notes.", ex);
                MessageBox.Show("Could not display notes for the case.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                ViewModelLocator.ContextManager.IsBusy = false;
            }
        }