Exemplo 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get User account for calling
        /// </summary>
        /// <returns></returns>
        public static string GetAccountID()
        {
            string account = string.Empty;

            try
            {
                dbContext = new ZoiperdbContext(AuthenticateConnectionToDB());
                TblZoiperSetting tblSetting = dbContext.TblZoiperSetting.FirstOrDefault();
                account = tblSetting.CallerId + "@" + tblSetting.Domain;
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteErrorToLog(ex);
                //LibraryLog.WriteErrorLog(ex);
            }
            return(account);
        }
Exemplo n.º 3
0
        public static Settings GetSIPAccount()
        {
            //bool iSuccess = false;
            Settings sipSetting = new Settings();

            try
            {
                dbContext = new ZoiperdbContext(AuthenticateConnectionToDB());
                TblZoiperSetting sipAccount = dbContext.TblZoiperSetting.FirstOrDefault();
                sipSetting = new Settings(sipAccount.Domain, sipAccount.Username, sipAccount.Password, sipAccount.CallerId, sipAccount.RegistrationStatus);
                ApplicationLog.WriteErrorToLog("Success");
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteErrorToLog(ex);
                //iSuccess = false;
            }
            return(sipSetting);
        }
Exemplo n.º 4
0
        public static bool GetSIPRegistrationStatus()
        {
            bool iSuccess = false;

            try
            {
                dbContext = new ZoiperdbContext(AuthenticateConnectionToDB());
                int?registrationStatus = dbContext.TblZoiperSetting.FirstOrDefault().RegistrationStatus;
                if (registrationStatus == 1)
                {
                    iSuccess = true;
                }
                ApplicationLog.WriteErrorToLog("Registration status: " + registrationStatus);
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteErrorToLog(ex);
                iSuccess = false;
            }
            return(iSuccess);
        }