Esempio n. 1
0
        /// <summary>
        /// Save Settings
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        public static bool SaveSettings(Settings settings)
        {
            bool iSuccess = false;

            try
            {
                if (settings != null)
                {
                    //Persist Data into Database
                    //connectionString = GetAppPath(@"\Zoiperdb.sdf"); //GetPath(@"..\..\SqlData\Zoiperdb.sdf");
                    dbContext = new ZoiperdbContext(AuthenticateConnectionToDB());
                    ApplicationLog.WriteEventToLog("Path to ZoiperDB from SaveSettings: " + AuthenticateConnectionToDB());
                    TblZoiperSetting zoiperSetting = new TblZoiperSetting()
                    {
                        Domain          = settings.Domain,
                        Username        = settings.Username,
                        CallerId        = settings.CallerId,
                        ServiceDuration = settings.ServiceDuration,
                        IsRestart       = Convert.ToInt32(settings.Restart),
                        Password        = SharedFunctions.Hash(settings.Password)
                    };
                    ApplicationLog.WriteEventToLog(string.Format("Domain: {0}, Username: {1}, CallerId: {2}, Duration: {3}, Restart: {4}, Password: {5}", zoiperSetting.Domain, zoiperSetting.Username, zoiperSetting.CallerId, zoiperSetting.ServiceDuration, zoiperSetting.IsRestart, zoiperSetting.Password));
                    dbContext.TblZoiperSetting.InsertOnSubmit(zoiperSetting);
                    dbContext.SubmitChanges();
                    iSuccess = true;
                    ApplicationLog.WriteEventToLog("Settings saved into ZoiperDB");
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteErrorToLog(ex.ToString());
            }
            return(iSuccess);
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 private static string AuthenticateConnectionToDB()
 {
     connectionString = GetAppPath(@"\Zoiperdb.sdf");
     ApplicationLog.WriteEventToLog("Path to Zoiper.sdf: " + connectionString);
     return(connectionString);
     // dbContext = new ZoiperdbContext(connectionString);
 }
Esempio n. 3
0
        /// <summary>
        /// Get contact by phone
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns>DbContact</returns>
        public static DbContact GetContactByPhone(string phoneNumber)
        {
            dbContext = new ZoiperdbContext(AuthenticateConnectionToDB());
            ApplicationLog.WriteEventToLog("Path to ZoiperDB from GetContactByPhone: " + AuthenticateConnectionToDB());
            DbContact contact = new DbContact();

            try
            {
                TblPhoneContact tblContact = dbContext.TblPhoneContact.Where(x => x.Telephone == phoneNumber).FirstOrDefault();
                contact = new DbContact(tblContact.ContactName, tblContact.Telephone, tblContact.Organization, tblContact.Url);
                //return contact;
                ApplicationLog.WriteEventToLog(string.Format("Name: {0}, Phone: {1}, Organization: {2}, Url: {3}", contact.FullName, contact.Phone, contact.Company, contact.Url));
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteEventToLog(ex.ToString());
                //LibraryLog.WriteErrorLog(ex.Message);
                //return contact;
            }
            return(contact);
        }