예제 #1
0
        private EmailHelper()
        {
      #if !DEBUG
            emailService = Service.ConnectToService(UserData.CreateUserData(
                                                        Configuration.ConfigHandler.InstanceOf.MailUser
                                                        ));
      #elif DEBUG
            emailService = Service.ConnectToService(UserData.CreateUserData(
                                                        Configuration.ConfigHandler.InstanceOf.MailUser), new LogTraceListener());
      #endif

            rfiMailBox = new Mailbox(Configuration.ConfigHandler.InstanceOf.MailBoxes.ToList().Find(x => x.Address == "*****@*****.**").Address);

            rfiInboxFolder = new FolderId(WellKnownFolderName.Inbox, rfiMailBox);

            rfiDraftsFolder = new FolderId(WellKnownFolderName.Drafts, rfiMailBox);

            rfiDeletedItemsFolder = new FolderId(WellKnownFolderName.DeletedItems, rfiMailBox);

            //      newStoresMailbox = new Mailbox(Configuration.InstanceOf.MailBoxes.Find( x => x.Address == "*****@*****.**" ).Address);
//
            //      newStoresInboxFolder = new FolderId(WellKnownFolderName.Inbox, newStoresMailbox);
//
            //      newStoresDraftsFolder = new FolderId(WellKnownFolderName.Drafts, newStoresMailbox);
//
            //      existingStoresMailBox = new Mailbox(Configuration.InstanceOf.MailBoxes.Find( x => x.Address == "*****@*****.**" ).Address);
//
            //      existingStoresInboxFolder = new FolderId(WellKnownFolderName.Inbox, existingStoresMailBox);
//
            //      existingStoresDraftsFolder = new FolderId(WellKnownFolderName.Drafts, existingStoresMailBox);

            connector = new Data.DatabaseConnector();

            this.ConfigureSubFolders();
        }
예제 #2
0
        public static ISPDatabase CreateSPDatabase(Data.DatabaseConnector db)
        {
            string      sSQL       = "SELECT table_type FROM information_schema.tables WHERE table_name = 'Docs'";
            object      oTableType = db.ExecuteScalar(sSQL);
            ISPDatabase oDB        = null;

            if (oTableType == null || oTableType == DBNull.Value)
            {
                throw new ApplicationException("This database structure is not recognized as a Sharepoint 2003 or Sharepoint 2007 database.");
            }

            string sTableType = (string)oTableType;

            // in Sharepoint 2003, the Docs table is a BASE TABLE
            // in Sharepoint 2007, the Docs table is a VIEW
            if (sTableType == "BASE TABLE")
            {
                oDB = new SPDatabase2003(db);
            }
            else if (sTableType == "VIEW")
            {
                oDB = new SPDatabase2007(db);
            }
            else
            {
                throw new ApplicationException("This database structure is not recognized as a Sharepoint 2003 or Sharepoint 2007 database.");
            }

            return(oDB);
        }
예제 #3
0
        /// <summary>
        /// Attempts to discover a walmart project based on content and contacts in the email
        /// </summary>
        /// <param name="message">Microsoft.Exchange.WebServices.Data.EmailMessage</param>
        /// <param name="category">Contains the category string if function returns true.
        /// <para>If function returns false this value will be String.Empty</para></param>
        /// <param name="store">System.Collections.Generic.List&lt; Entity.Store &gt;</param>
        /// <returns>RfiCoder.Enum.QuestionTypes</returns>
        public Enum.QuestionTypes DiscoverProject(Microsoft.Exchange.WebServices.Data.EmailMessage message, out string category, out System.Collections.Generic.List <Entity.Store> store)
        {
            // step one try to get the city, state combination from the email.
            var parser = new Parser();

            var search = String.Format("{0} {1}", message.Subject, message.Body);

            System.Collections.Generic.List <System.Collections.Generic.Dictionary <string, string> > matches;

            var isMatch = parser.TryCityState(search, out matches);

            if (isMatch)
            {
                // let's try to find some stores
                var connector = new Data.DatabaseConnector();

                var stores = new System.Collections.Generic.List <Entity.Store>();

                foreach (var match in matches)
                {
                    var storeList = connector.GetAllStoresByCityState(match["city"], match["state"]);

                    if (storeList.Count != 0)
                    {
                        stores.AddRange(storeList);
                    }
                }
            }

            // get email contacts
            var contacts = message.CcRecipients;

            contacts.Add(message.Sender);

            // some (actually alot) email are automatically forwarded from Amy.  These email
            // don't have any CC recipients.  They are listed in the body of the email.
            // what we'll do is check the message to see if it was sent from Amy but only
            // to the RFI inbox.

            if (message.Sender.Address == "*****@*****.**" &&
                message.ToRecipients[0].Address == "*****@*****.**")
            {
                // becuase this message is an autoforward we need to clear the email addresses we've stored
                contacts.Clear();
            }

            store = new System.Collections.Generic.List <Entity.Store>();

            category = "";

            return(Enum.QuestionTypes.RequestForInformation);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <param name="evaluateRecordCount"></param>
        /// <param name="includeDocumentContent">
        ///		For document libraries, when this parameter is true, returns an additionnal field containing the file content.
        ///		Ignored if the list is not a document library.</param>
        /// <returns></returns>
        public IDataReader GetListItemsAsReader(SPListDefinition list, bool evaluateRecordCount, bool includeDocumentContent)
        {
            // when returning a datareader, we do it on a separate connection so we do not
            // exclusively lock the main connection.  (Data Readers monopolize the connection until they are closed).
            //
            // In order to prevent the connection pool to grow too much, we set the autoCloseConnection option to true
            // on the ExecuteReader method.
            Data.DatabaseConnector oDB = _DB.Clone();

            if (evaluateRecordCount)
            {
                return(oDB.ExecuteReader(this.GetListItemsQuery(list, includeDocumentContent, true) + ";" + this.GetListItemsQuery(list, includeDocumentContent, false), true));
            }
            else
            {
                return(oDB.ExecuteReader(this.GetListItemsQuery(list, includeDocumentContent, false), true));
            }
        }
예제 #5
0
 public SPDatabase2007(Data.DatabaseConnector db)
 {
     _DB = db;
 }
예제 #6
0
		public SPDatabase2007(Data.DatabaseConnector db)
		{
			_DB = db;
		}