示例#1
0
        //public static bool TruncateTable()
        //{
        //    connectionString = GetAppPath(@"\Zoiperdb.sdf");
        //    string query = "DELETE from TblPhoneContact";
        //    string dropConstraint = @"ALTER TABLE [TblPhoneContact] DROP CONSTRAINT [PK__TblPhoneContact__0000000000000019]";
        //    string dropIdColumn = "ALTER TABLE[TblPhoneContact] DROP COLUMN[Id]";

        //    string addIdColumn = @"ALTER TABLE [TblPhoneContact] ADD [Id] int IDENTITY (1,1)  NOT NULL";
        //     string addIdConstraint = "ALTER TABLE[TblPhoneContact] ADD CONSTRAINT[PK__TblPhoneContact__0000000000000019] PRIMARY KEY ([Id])";

        //    bool result = false;
        //    try
        //    {
        //        dbContext = new ZoiperdbContext(connectionString);

        //        if (dbContext.DatabaseExists())
        //        {


        //            int idropConstraint = dbContext.ExecuteCommand(dropConstraint);
        //            if (idropConstraint >= 0)
        //                result = true;

        //            int idropIdColumn = dbContext.ExecuteCommand(dropIdColumn);
        //            if (idropIdColumn >= 0)
        //                result = true;

        //            int iQuery = dbContext.ExecuteCommand(query);
        //            if (iQuery >= 0)
        //                result = true;

        //            int iaddIdColumn = dbContext.ExecuteCommand(addIdColumn);
        //            int iaddIdConstraint = dbContext.ExecuteCommand(addIdConstraint);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LibraryLog.WriteErrorLog(ex);
        //    }
        //    return result;
        //}

        /// <summary>
        /// Get User account for calling
        /// </summary>
        /// <returns></returns>
        public static string GetSettings()
        {
            string account = string.Empty;

            try
            {
                //AuthenticateConnectionToDB();
                dbContext = new ZoiperdbContext(AuthenticateConnectionToDB());
                TblZoiperSetting tblSetting = dbContext.TblZoiperSetting.FirstOrDefault();
                account = tblSetting.CallerId + "@" + tblSetting.Domain;
            }
            catch (Exception ex)
            {
                LibraryLog.WriteErrorLog(ex);
            }
            return(account);
        }
示例#2
0
        public static int GetServiceDuration()
        {
            connectionString = GetAppPath(@"\Zoiperdb.sdf"); //GetPath(@"..\..\SqlData\Zoiperdb.sdf");
            dbContext        = new ZoiperdbContext(connectionString);
            int duration = 0;

            try
            {
                TblZoiperSetting setting = dbContext.TblZoiperSetting.FirstOrDefault();
                duration = setting.ServiceDuration;
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex?.Message);
                LibraryLog.WriteErrorLog(ex);
                duration = Convert.ToInt32(false);
            }
            return(duration);
        }