Esempio n. 1
0
        public xml_API(string intitString)
        {
            this.m_UpdSync = new UpdateSync();
            if (intitString == null || intitString == "")
            {
                throw new Exception("Init string can't be null or \"\" !");
            }
            string[] array = intitString.Replace("\r\n", "\n").Split(new char[]
			{
				'\n'
			});
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                if (text.ToLower().IndexOf("datapath=") > -1)
                {
                    this.m_DataPath = text.Substring(9);
                    this.timer1 = new System.Timers.Timer(15000.0);
                    this.timer1.Elapsed += new ElapsedEventHandler(this.timer1_Elapsed);
                    this.timer1.Enabled = true;
                }
                else
                {
                    if (text.ToLower().IndexOf("mailstorepath=") > -1)
                    {
                        this.m_MailStorePath = text.Substring(14);
                    }
                }
            }
            if (this.m_DataPath.Length > 0 && !this.m_DataPath.EndsWith("\\"))
            {
                this.m_DataPath += "\\";
            }
            if (this.m_MailStorePath.Length > 0 && !this.m_MailStorePath.EndsWith("\\"))
            {
                this.m_MailStorePath += "\\";
            }
            if (!Path.IsPathRooted(this.m_DataPath))
            {
                this.m_DataPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + this.m_DataPath;
            }
            if (!Path.IsPathRooted(this.m_MailStorePath))
            {
                this.m_MailStorePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + this.m_MailStorePath;
            }
            this.m_DataPath = API_Utlis.PathFix(this.m_DataPath);
            this.m_MailStorePath = API_Utlis.PathFix(this.m_MailStorePath);
            if (!Directory.Exists(this.m_DataPath))
            {
                Directory.CreateDirectory(this.m_DataPath);
            }
            RecycleBinManager.RecycleBinPath = this.m_MailStorePath + "RecycleBin/";
            if (!Directory.Exists(this.m_MailStorePath + "RecycleBin/"))
            {
                Directory.CreateDirectory(this.m_MailStorePath + "RecycleBin/");
            }
            this.dsSettings = new DataSet();
            this.dsDomains = new DataSet();
            this.dsUsers = new DataSet();
            this.dsUserAddresses = new DataSet();
            this.dsUserRemoteServers = new DataSet();
            this.dsUserMessageRules = new DataSet();
            this.dsUserMessageRuleActions = new DataSet();
            this.dsUserForwards = new DataSet();
            this.dsGroups = new DataSet();
            this.dsGroupMembers = new DataSet();
            this.dsMailingLists = new DataSet();
            this.dsMailingListAddresses = new DataSet();
            this.dsMailingListACL = new DataSet();
            this.dsRules = new DataSet();
            this.dsRuleActions = new DataSet();
            this.dsRouting = new DataSet();
            this.dsSecurity = new DataSet();
            this.dsFilters = new DataSet();
            this.dsImapACL = new DataSet();
            this.dsSharedFolderRoots = new DataSet();
            this.dsUsersDefaultFolders = new DataSet();
            this.dsRecycleBinSettings = new DataSet();
            this.timer1_Elapsed(this, null);
        }
Esempio n. 2
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="intitString"></param>
		public xml_API(string intitString)
		{
			m_UpdSync = new UpdateSync();

            if(intitString == null || intitString == ""){
                throw new Exception("Init string can't be null or \"\" !");
            }
            
			// datapath=
			// mailstorepath=
			string[] parameters = intitString.Replace("\r\n","\n").Split('\n');
			foreach(string param in parameters){
				if(param.ToLower().IndexOf("datapath=") > -1){
					m_DataPath = param.Substring(9);
                    
					timer1 = new System.Timers.Timer(15000);					
					timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
					timer1.Enabled = true;
				}
				else if(param.ToLower().IndexOf("mailstorepath=") > -1){
					m_MailStorePath = param.Substring(14);
				}
			}
            
			// Fix data path, if isn't ending with \
			if(m_DataPath.Length > 0 && !m_DataPath.EndsWith("\\")){
				m_DataPath += "\\"; 
			}

			// Fix mail store path, if isn't ending with \
			if(m_MailStorePath.Length > 0 && !m_MailStorePath.EndsWith("\\")){
				m_MailStorePath += "\\"; 
			}
                                                
			if(!Path.IsPathRooted(m_DataPath)){
				m_DataPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + System.IO.Path.DirectorySeparatorChar + m_DataPath;
			}

            if(!Path.IsPathRooted(m_MailStorePath)){
				m_MailStorePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + System.IO.Path.DirectorySeparatorChar + m_MailStorePath;
			}

            // Make path directory separator to suit for current platform
            m_DataPath = API_Utlis.PathFix(m_DataPath);
            m_MailStorePath = API_Utlis.PathFix(m_MailStorePath);

            // Settings folder doesn't exist, create it
            if(!Directory.Exists(m_DataPath)){
                Directory.CreateDirectory(m_DataPath);
            }

            // Set Recycle Bin path
            RecycleBinManager.RecycleBinPath = m_MailStorePath + "RecycleBin/";
            // RecycleBin folder doesn't exist, create it
            if(!Directory.Exists(m_MailStorePath + "RecycleBin/")){
                Directory.CreateDirectory(m_MailStorePath + "RecycleBin/");
            }
                        				
			dsSettings               = new DataSet();
			dsDomains                = new DataSet();
			dsUsers                  = new DataSet();
			dsUserAddresses          = new DataSet();
			dsUserRemoteServers      = new DataSet();
			dsUserMessageRules       = new DataSet();
            dsUserMessageRuleActions = new DataSet();
			dsUserForwards           = new DataSet();
            dsGroups                 = new DataSet();
            dsGroupMembers           = new DataSet();
			dsMailingLists           = new DataSet();
			dsMailingListAddresses   = new DataSet();
            dsMailingListACL         = new DataSet();
            dsRules                  = new DataSet();
            dsRuleActions            = new DataSet();
			dsRouting                = new DataSet();
			dsSecurity               = new DataSet();
			dsFilters                = new DataSet();
			dsImapACL                = new DataSet();
            dsSharedFolderRoots      = new DataSet();
            dsUsersDefaultFolders    = new DataSet();
            dsRecycleBinSettings     = new DataSet();

			timer1_Elapsed(this,null);
		}