Esempio n. 1
0
        /// <summary>
        /// Inserts a row in the mp_RedirectList table. Returns rows affected count.
        /// </summary>
        /// <param name="rowGuid"> rowGuid </param>
        /// <param name="siteGuid"> siteGuid </param>
        /// <param name="siteID"> siteID </param>
        /// <param name="oldUrl"> oldUrl </param>
        /// <param name="newUrl"> newUrl </param>
        /// <param name="createdUtc"> createdUtc </param>
        /// <param name="expireUtc"> expireUtc </param>
        /// <returns>int</returns>
        public int Create(
            Guid rowGuid,
            Guid siteGuid,
            int siteID,
            string oldUrl,
            string newUrl,
            DateTime createdUtc,
            DateTime expireUtc)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_RedirectList_Insert", 
                7);

            sph.DefineSqlParameter("@RowGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, rowGuid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteID);
            sph.DefineSqlParameter("@OldUrl", SqlDbType.NVarChar, 255, ParameterDirection.Input, oldUrl);
            sph.DefineSqlParameter("@NewUrl", SqlDbType.NVarChar, 255, ParameterDirection.Input, newUrl);
            sph.DefineSqlParameter("@CreatedUtc", SqlDbType.DateTime, ParameterDirection.Input, createdUtc);
            sph.DefineSqlParameter("@ExpireUtc", SqlDbType.DateTime, ParameterDirection.Input, expireUtc);
            int rowsAffected = sph.ExecuteNonQuery();
            return rowsAffected;

        }
Esempio n. 2
0
        /// <summary>
        /// Inserts a row in the mp_SystemLog table. Returns new integer id.
        /// </summary>
        /// <param name="logDate"> logDate </param>
        /// <param name="ipAddress"> ipAddress </param>
        /// <param name="culture"> culture </param>
        /// <param name="url"> url </param>
        /// <param name="shortUrl"> shortUrl </param>
        /// <param name="thread"> thread </param>
        /// <param name="logLevel"> logLevel </param>
        /// <param name="logger"> logger </param>
        /// <param name="message"> message </param>
        /// <returns>int</returns>
        public int Create(
            DateTime logDate,
            string ipAddress,
            string culture,
            string url,
            string shortUrl,
            string thread,
            string logLevel,
            string logger,
            string message)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_SystemLog_Insert", 
                9);

            sph.DefineSqlParameter("@LogDate", SqlDbType.DateTime, ParameterDirection.Input, logDate);
            sph.DefineSqlParameter("@IpAddress", SqlDbType.NVarChar, 50, ParameterDirection.Input, ipAddress);
            sph.DefineSqlParameter("@Culture", SqlDbType.NVarChar, 10, ParameterDirection.Input, culture);
            sph.DefineSqlParameter("@Url", SqlDbType.NVarChar, -1, ParameterDirection.Input, url);
            sph.DefineSqlParameter("@ShortUrl", SqlDbType.NVarChar, 255, ParameterDirection.Input, shortUrl);
            sph.DefineSqlParameter("@Thread", SqlDbType.NVarChar, 255, ParameterDirection.Input, thread);
            sph.DefineSqlParameter("@LogLevel", SqlDbType.NVarChar, 20, ParameterDirection.Input, logLevel);
            sph.DefineSqlParameter("@Logger", SqlDbType.NVarChar, 255, ParameterDirection.Input, logger);
            sph.DefineSqlParameter("@Message", SqlDbType.NVarChar, -1, ParameterDirection.Input, message);
            int newID = Convert.ToInt32(sph.ExecuteScalar());
            return newID;
        }
Esempio n. 3
0
        /// <summary>
        /// Inserts a row in the mp_Currency table. Returns rows affected count.
        /// </summary>
        /// <param name="guid"> guid </param>
        /// <param name="title"> title </param>
        /// <param name="code"> code </param>
        /// <param name="symbolLeft"> symbolLeft </param>
        /// <param name="symbolRight"> symbolRight </param>
        /// <param name="decimalPointChar"> decimalPointChar </param>
        /// <param name="thousandsPointChar"> thousandsPointChar </param>
        /// <param name="decimalPlaces"> decimalPlaces </param>
        /// <param name="value"> value </param>
        /// <param name="lastModified"> lastModified </param>
        /// <param name="created"> created </param>
        /// <returns>bool</returns>
        public async Task<bool> Create(
            Guid guid,
            string title,
            string code,
            string symbolLeft,
            string symbolRight,
            string decimalPointChar,
            string thousandsPointChar,
            string decimalPlaces,
            decimal value,
            DateTime lastModified,
            DateTime created)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_Currency_Insert", 
                11);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@Title", SqlDbType.NVarChar, 50, ParameterDirection.Input, title);
            sph.DefineSqlParameter("@Code", SqlDbType.NChar, 3, ParameterDirection.Input, code);
            sph.DefineSqlParameter("@SymbolLeft", SqlDbType.NVarChar, 15, ParameterDirection.Input, symbolLeft);
            sph.DefineSqlParameter("@SymbolRight", SqlDbType.NVarChar, 15, ParameterDirection.Input, symbolRight);
            sph.DefineSqlParameter("@DecimalPointChar", SqlDbType.NChar, 1, ParameterDirection.Input, decimalPointChar);
            sph.DefineSqlParameter("@ThousandsPointChar", SqlDbType.NChar, 1, ParameterDirection.Input, thousandsPointChar);
            sph.DefineSqlParameter("@DecimalPlaces", SqlDbType.NChar, 1, ParameterDirection.Input, decimalPlaces);
            sph.DefineSqlParameter("@Value", SqlDbType.Decimal, ParameterDirection.Input, value);
            sph.DefineSqlParameter("@LastModified", SqlDbType.DateTime, ParameterDirection.Input, lastModified);
            sph.DefineSqlParameter("@Created", SqlDbType.DateTime, ParameterDirection.Input, created);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return rowsAffected > 0;

        }
Esempio n. 4
0
        public DbDataReader GetUserCountByYearMonth(int siteId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_Users_GetCountByMonthYear", 
                1);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            return sph.ExecuteReader();
        }
Esempio n. 5
0
        public DbDataReader GetSiteSettingsExList(int siteId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_SiteSettingsEx_SelectAll", 
                1);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            return sph.ExecuteReader();
        }
Esempio n. 6
0
        public async Task<bool> Delete(int roleId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_Roles_Delete", 
                1);

            sph.DefineSqlParameter("@RoleID", SqlDbType.Int, ParameterDirection.Input, roleId);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return (rowsAffected > -1);
        }
Esempio n. 7
0
        public async Task<bool> Delete(Guid guid)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_SiteFolders_Delete", 
                1);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return (rowsAffected > -1);
        }
Esempio n. 8
0
        //public DbDataReader GetSmartDropDownData(int siteId, string query, int rowsToGet)
        //{
        //    SqlParameterHelper sph = new SqlParameterHelper(
        //        logFactory,
        //        readConnectionString, 
        //        "mp_Users_SmartDropDown", 
        //        3);

        //    sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
        //    sph.DefineSqlParameter("@Query", SqlDbType.NVarChar, 50, ParameterDirection.Input, query);
        //    sph.DefineSqlParameter("@RowsToGet", SqlDbType.Int, ParameterDirection.Input, rowsToGet);
        //    return sph.ExecuteReader();
        //}

        public DbDataReader EmailLookup(int siteId, string query, int rowsToGet)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_Users_EmailLookup", 
                3);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@Query", SqlDbType.NVarChar, 50, ParameterDirection.Input, query);
            sph.DefineSqlParameter("@RowsToGet", SqlDbType.Int, ParameterDirection.Input, rowsToGet);
            return sph.ExecuteReader();
        }
Esempio n. 9
0
        public async Task<bool> DeleteByUser(int siteId, string userId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_UserClaims_DeleteByUser", 
                2);

            sph.DefineSqlParameter("@UserId", SqlDbType.NVarChar, 128, ParameterDirection.Input, userId);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return (rowsAffected > 0);

        }
Esempio n. 10
0
        public static bool UpdateState(int newsId, int?stateId, DateTime?approvedUtc, Guid?approvedUserGuid, string approvedBy, string rejectedNotes)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_News_UpdateState", 6);

            sph.DefineSqlParameter("@NewsID", SqlDbType.Int, ParameterDirection.Input, newsId);
            sph.DefineSqlParameter("@StateID", SqlDbType.Int, ParameterDirection.Input, stateId);
            sph.DefineSqlParameter("@ApprovedUtc", SqlDbType.DateTime, ParameterDirection.Input, approvedUtc);
            sph.DefineSqlParameter("@ApprovedUserGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, approvedUserGuid);
            sph.DefineSqlParameter("@ApprovedBy", SqlDbType.NVarChar, 100, ParameterDirection.Input, approvedBy);
            sph.DefineSqlParameter("@RejectedNotes", SqlDbType.NVarChar, ParameterDirection.Input, rejectedNotes);

            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > -1);
        }
Esempio n. 11
0
        public ActionResult DeleteMenus(string[] ids)
        {
            if (ids.Length <= 0)
            {
                return(Json(new { code = 999, msg = "参数有误" }));
            }
            SystemMenuService service = new SystemMenuService();

            object[] obj   = new object[ids.Length];
            string   parms = SqlParameterHelper.GetParameters(ids, ref obj);
            string   sql   = $"delete from SystemMenu where id in({parms})";
            int      n     = service.ExcuteSqlParm(sql, obj);

            return(Json(new { code = 0, msg = "success" }));
        }
Esempio n. 12
0
        public async Task <bool> AddHost(Guid siteGuid, int siteId, string hostName)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString,
                "mp_SiteHosts_Insert",
                3);

            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@HostName", SqlDbType.NVarChar, 255, ParameterDirection.Input, hostName);
            int rowsAffected = await sph.ExecuteNonQueryAsync();

            return(rowsAffected > 0);
        }
Esempio n. 13
0
        public async Task<bool> Delete(
            int id,
            CancellationToken cancellationToken)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_UserClaims_Delete", 
                1);

            sph.DefineSqlParameter("@Id", SqlDbType.Int, ParameterDirection.Input, id);
            int rowsAffected = await sph.ExecuteNonQueryAsync(cancellationToken);
            return (rowsAffected > 0);

        }
Esempio n. 14
0
        public async Task <int> GetCountOfUsersInRole(int siteId, int roleId, string searchInput)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString,
                "mp_UserRoles_CountInRole",
                3);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@RoleID", SqlDbType.Int, ParameterDirection.Input, roleId);
            sph.DefineSqlParameter("@SearchInput", SqlDbType.NVarChar, 50, ParameterDirection.Input, searchInput);
            object result = await sph.ExecuteScalarAsync();

            return(Convert.ToInt32(result));
        }
Esempio n. 15
0
        public async Task <bool> DeleteByUser(int siteId, string userId, string claimType)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString,
                "mp_UserClaims_DeleteByUserByType",
                2);

            sph.DefineSqlParameter("@UserId", SqlDbType.NVarChar, 128, ParameterDirection.Input, userId);
            sph.DefineSqlParameter("@ClaimType", SqlDbType.NVarChar, -1, ParameterDirection.Input, claimType);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);
            int rowsAffected = await sph.ExecuteNonQueryAsync();

            return(rowsAffected > 0);
        }
Esempio n. 16
0
        public static bool Update(
            int paymentMethodID,
            int siteID,
            int paymentProvider,
            string name,
            string description,
            int displayOrder,
            bool isActive,
            decimal additionalFee,
            bool usePercentage,
            bool freeOnOrdersOverXEnabled,
            decimal freeOnOrdersOverXValue,
            bool useSandbox,
            string businessEmail,
            string securePass,
            string hashcode,
            string merchantId,
            string merchantSiteCode,
            string accessCode,
            Guid guid,
            bool isDeleted)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_PaymentMethod_Update", 20);

            sph.DefineSqlParameter("@PaymentMethodID", SqlDbType.Int, ParameterDirection.Input, paymentMethodID);
            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteID);
            sph.DefineSqlParameter("@PaymentProvider", SqlDbType.Int, ParameterDirection.Input, paymentProvider);
            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 255, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@Description", SqlDbType.NVarChar, -1, ParameterDirection.Input, description);
            sph.DefineSqlParameter("@DisplayOrder", SqlDbType.Int, ParameterDirection.Input, displayOrder);
            sph.DefineSqlParameter("@IsActive", SqlDbType.Bit, ParameterDirection.Input, isActive);
            sph.DefineSqlParameter("@AdditionalFee", SqlDbType.Decimal, ParameterDirection.Input, additionalFee);
            sph.DefineSqlParameter("@UsePercentage", SqlDbType.Bit, ParameterDirection.Input, usePercentage);
            sph.DefineSqlParameter("@FreeOnOrdersOverXEnabled", SqlDbType.Bit, ParameterDirection.Input, freeOnOrdersOverXEnabled);
            sph.DefineSqlParameter("@FreeOnOrdersOverXValue", SqlDbType.Decimal, ParameterDirection.Input, freeOnOrdersOverXValue);
            sph.DefineSqlParameter("@UseSandbox", SqlDbType.Bit, ParameterDirection.Input, useSandbox);
            sph.DefineSqlParameter("@BusinessEmail", SqlDbType.NVarChar, 255, ParameterDirection.Input, businessEmail);
            sph.DefineSqlParameter("@SecurePass", SqlDbType.NVarChar, 255, ParameterDirection.Input, securePass);
            sph.DefineSqlParameter("@Hashcode", SqlDbType.NVarChar, 255, ParameterDirection.Input, hashcode);
            sph.DefineSqlParameter("@MerchantId", SqlDbType.NVarChar, 255, ParameterDirection.Input, merchantId);
            sph.DefineSqlParameter("@MerchantSiteCode", SqlDbType.NVarChar, 255, ParameterDirection.Input, merchantSiteCode);
            sph.DefineSqlParameter("@AccessCode", SqlDbType.NVarChar, 255, ParameterDirection.Input, accessCode);
            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@IsDeleted", SqlDbType.Bit, ParameterDirection.Input, isDeleted);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 17
0
        public static bool Update(
            int couponID,
            int siteID,
            string couponCode,
            string name,
            decimal discount,
            int discountType,
            decimal orderPurchaseFrom,
            decimal orderPurchaseTo,
            DateTime?fromDate,
            DateTime?expiryDate,
            decimal minPurchase,
            int limitationTimes,
            bool isActive,
            int appliedType,
            string appliedToProducts,
            string appliedToCategories,
            Guid guid,
            DateTime createdOn,
            int discountQtyStep,
            int maximumQtyDiscount)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_Coupon_Update", 20);

            sph.DefineSqlParameter("@CouponID", SqlDbType.Int, ParameterDirection.Input, couponID);
            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteID);
            sph.DefineSqlParameter("@CouponCode", SqlDbType.NVarChar, 50, ParameterDirection.Input, couponCode);
            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 255, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@Discount", SqlDbType.Decimal, ParameterDirection.Input, discount);
            sph.DefineSqlParameter("@DiscountType", SqlDbType.Int, ParameterDirection.Input, discountType);
            sph.DefineSqlParameter("@OrderPurchaseFrom", SqlDbType.Decimal, ParameterDirection.Input, orderPurchaseFrom);
            sph.DefineSqlParameter("@OrderPurchaseTo", SqlDbType.Decimal, ParameterDirection.Input, orderPurchaseTo);
            sph.DefineSqlParameter("@FromDate", SqlDbType.DateTime, ParameterDirection.Input, fromDate);
            sph.DefineSqlParameter("@ExpiryDate", SqlDbType.DateTime, ParameterDirection.Input, expiryDate);
            sph.DefineSqlParameter("@MinPurchase", SqlDbType.Decimal, ParameterDirection.Input, minPurchase);
            sph.DefineSqlParameter("@LimitationTimes", SqlDbType.Int, ParameterDirection.Input, limitationTimes);
            sph.DefineSqlParameter("@IsActive", SqlDbType.Bit, ParameterDirection.Input, isActive);
            sph.DefineSqlParameter("@AppliedType", SqlDbType.Int, ParameterDirection.Input, appliedType);
            sph.DefineSqlParameter("@AppliedToProducts", SqlDbType.NVarChar, -1, ParameterDirection.Input, appliedToProducts);
            sph.DefineSqlParameter("@AppliedToCategories", SqlDbType.NVarChar, -1, ParameterDirection.Input, appliedToCategories);
            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@CreatedOn", SqlDbType.DateTime, ParameterDirection.Input, createdOn);
            sph.DefineSqlParameter("@DiscountQtyStep", SqlDbType.Int, ParameterDirection.Input, discountQtyStep);
            sph.DefineSqlParameter("@MaximumQtyDiscount", SqlDbType.Int, ParameterDirection.Input, maximumQtyDiscount);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 18
0
        /// <summary>
        /// Gets and IDataReader for a page of items for a definition
        /// </summary>
        /// <returns></returns>
        public static IDataReader GetPageForDefinition(
            Guid defGuid,
            Guid siteGuid,
            int pageNumber,
            int pageSize,
            string searchTerm  = "",
            string searchField = "",
            //string sortField = "",
            string sortDirection = "ASC"
            )
        {
            SqlParameterHelper sph = null;

            if (String.IsNullOrWhiteSpace(searchField) && !String.IsNullOrWhiteSpace(searchTerm))
            {
                sph = new SqlParameterHelper(ConnectionString.GetReadConnectionString(), "i7_sflexi_items_SelectPageForDefinitionWithTerm", 6);
                sph.DefineSqlParameter("@DefGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, defGuid);
                sph.DefineSqlParameter("@PageNumber", SqlDbType.Int, ParameterDirection.Input, pageNumber);
                sph.DefineSqlParameter("@PageSize", SqlDbType.Int, ParameterDirection.Input, pageSize);
                sph.DefineSqlParameter("@SearchTerm", SqlDbType.NVarChar, -1, ParameterDirection.Input, searchTerm);
                //sph.DefineSqlParameter("@sortField", SqlDbType.NVarChar, -1, ParameterDirection.Input, sortField);
                sph.DefineSqlParameter("@SortDirection", SqlDbType.VarChar, 4, ParameterDirection.Input, sortDirection);
                sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            }
            else if (!String.IsNullOrWhiteSpace(searchField) && !String.IsNullOrWhiteSpace(searchTerm))
            {
                sph = new SqlParameterHelper(ConnectionString.GetReadConnectionString(), "i7_sflexi_items_SelectPageForDefinitionWithTermAndField", 7);
                sph.DefineSqlParameter("@DefGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, defGuid);
                sph.DefineSqlParameter("@PageNumber", SqlDbType.Int, ParameterDirection.Input, pageNumber);
                sph.DefineSqlParameter("@PageSize", SqlDbType.Int, ParameterDirection.Input, pageSize);
                sph.DefineSqlParameter("@SearchTerm", SqlDbType.NVarChar, -1, ParameterDirection.Input, searchTerm);
                sph.DefineSqlParameter("@SearchField", SqlDbType.NVarChar, -1, ParameterDirection.Input, searchField);
                //sph.DefineSqlParameter("@sortField", SqlDbType.NVarChar, -1, ParameterDirection.Input, sortField);
                sph.DefineSqlParameter("@SortDirection", SqlDbType.VarChar, 4, ParameterDirection.Input, sortDirection);
                sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            }
            else
            {
                sph = new SqlParameterHelper(ConnectionString.GetReadConnectionString(), "i7_sflexi_items_SelectPageForDefinition", 5);
                sph.DefineSqlParameter("@DefGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, defGuid);
                sph.DefineSqlParameter("@PageNumber", SqlDbType.Int, ParameterDirection.Input, pageNumber);
                sph.DefineSqlParameter("@PageSize", SqlDbType.Int, ParameterDirection.Input, pageSize);
                //sph.DefineSqlParameter("@sortField", SqlDbType.NVarChar, -1, ParameterDirection.Input, sortField);
                sph.DefineSqlParameter("@SortDirection", SqlDbType.VarChar, 4, ParameterDirection.Input, sortDirection);
                sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            }
            return(sph.ExecuteReader());
        }
Esempio n. 19
0
        /// <summary>
        /// Inserts a row in the mp_SurveyPages table. Returns rows affected count.
        /// </summary>
        /// <param name="surveySurveyPageGuid"> surveySurveyPageGuid </param>
        /// <param name="surveyGuid"> surveyGuid </param>
        /// <param name="pageTitle"> pageTitle </param>
        /// <param name="pageOrder"> pageOrder </param>
        /// <returns>int</returns>
        public static int Add(
            Guid pageGuid,
            Guid surveyGuid,
            string pageTitle,
            bool pageEnabled)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "mp_SurveyPages_Insert", 4);

            sph.DefineSqlParameter("@PageGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, pageGuid);
            sph.DefineSqlParameter("@SurveyGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, surveyGuid);
            sph.DefineSqlParameter("@PageTitle", SqlDbType.NVarChar, 255, ParameterDirection.Input, pageTitle);
            sph.DefineSqlParameter("@PageEnabled", SqlDbType.Bit, ParameterDirection.Input, pageEnabled);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected);
        }
Esempio n. 20
0
        /// <summary>
        /// Updates the status of a response. Returns true if row updated.
        /// </summary>
        /// <param name="responseGuid"> responseGuid </param>
        /// <param name="submissionDate"> submissionDate </param>
        /// <param name="complete"> complete </param>
        /// <returns>bool</returns>
        public static bool Update(
            Guid responseGuid,
            DateTime submissionDate,
            bool complete
            )
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "mp_SurveyResponses_Update", 3);

            sph.DefineSqlParameter("@ResponseGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, responseGuid);
            sph.DefineSqlParameter("@SubmissionDate", SqlDbType.DateTime, ParameterDirection.Input, submissionDate);
            sph.DefineSqlParameter("@Complete", SqlDbType.Bit, ParameterDirection.Input, complete);

            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 21
0
        public static decimal GetAllTimeRevenueTotal(Guid storeGuid)
        {
            SqlParameterHelper sph = new SqlParameterHelper(WebStoreConnectionString.GetReadConnectionString(), "ws_Order_GetAllTimeRevenue", 1);

            sph.DefineSqlParameter("@StoreGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, storeGuid);

            decimal result = 0;

            try
            {
                result = Convert.ToDecimal(sph.ExecuteScalar());
            }
            catch (InvalidCastException) { }

            return(result);
        }
Esempio n. 22
0
        /// <summary>
        /// Updates a row in the gb_CouponUsageHistory table. Returns true if row updated.
        /// </summary>
        /// <param name="historyID"> historyID </param>
        /// <param name="couponID"> couponID </param>
        /// <param name="orderID"> orderID </param>
        /// <param name="createdOn"> createdOn </param>
        /// <returns>bool</returns>
        public static bool Update(
            int historyID,
            int couponID,
            int orderID,
            DateTime createdOn)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_CouponUsageHistory_Update", 4);

            sph.DefineSqlParameter("@HistoryID", SqlDbType.Int, ParameterDirection.Input, historyID);
            sph.DefineSqlParameter("@CouponID", SqlDbType.Int, ParameterDirection.Input, couponID);
            sph.DefineSqlParameter("@OrderID", SqlDbType.Int, ParameterDirection.Input, orderID);
            sph.DefineSqlParameter("@CreatedOn", SqlDbType.DateTime, ParameterDirection.Input, createdOn);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 23
0
        public DataSet GetAll()
        {
            DataSet ds;
            var     sp = new SqlParameterHelper(StoredProcedure.GetAllUsers, StoredProcedure.GetAllUsersParameters);

            try
            {
                ds = sp.ExecuteDataset();
            }
            catch (SqlException exception)
            {
                _logger.Error("ERROR IN CLASS =>> USERDAO, METHOD =>> GetAll, EXCEPTION MESSAGE =>> " + exception.Message);
                throw new Exception(exception.Message);
            }
            return(ds);
        }
Esempio n. 24
0
        public static IDataReader GetRelatedProducts(
            int siteId,
            Guid productGuid,
            bool showHidden    = false,
            bool twoWayRelated = false,
            int languageId     = -1)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetReadConnectionString(), "gb_Product_SelectRelatedProduct", 5);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@ProductGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, productGuid);
            sph.DefineSqlParameter("@ShowHidden", SqlDbType.Bit, ParameterDirection.Input, showHidden);
            sph.DefineSqlParameter("@TwoWayRelated", SqlDbType.Bit, ParameterDirection.Input, twoWayRelated);
            sph.DefineSqlParameter("@LanguageID", SqlDbType.Int, ParameterDirection.Input, languageId);
            return(sph.ExecuteReader());
        }
Esempio n. 25
0
        public async Task <DbDataReader> GetPageOfOtherSites(
            int currentSiteId,
            int pageNumber,
            int pageSize)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString,
                "mp_Sites_SelectPageOtherSites",
                3);

            sph.DefineSqlParameter("@CurrentSiteID", SqlDbType.Int, ParameterDirection.Input, currentSiteId);
            sph.DefineSqlParameter("@PageNumber", SqlDbType.Int, ParameterDirection.Input, pageNumber);
            sph.DefineSqlParameter("@PageSize", SqlDbType.Int, ParameterDirection.Input, pageSize);
            return(await sph.ExecuteReaderAsync());
        }
Esempio n. 26
0
 public void UpdateCustomerPassword(UserPassword userPassword)
 {
     try
     {
         //prepare parameters
         var pUserId       = SqlParameterHelper.GetInt32Parameter("@_UserId", userPassword.UserId);
         var pPasswordHash = SqlParameterHelper.GetStringParameter("@_PasswordHash", userPassword.PasswordHash);
         _dataProvider.ExecuteNonQuery("UpdatePasswordUser", pUserId, pPasswordHash);
         var userId = _userRepository.GetById(userPassword.UserId);
         _eventPublisher.EntityUpdated(userId);
     }
     catch (Exception ex)
     {
         _logger.Error("UpdateCustomerPassword error", ex);
     }
 }
Esempio n. 27
0
        /// <summary>
        /// Updates a row in the mp_QuestionOptions table. Returns true if row updated.
        /// </summary>
        /// <param name="questionOptionGuid"> questionOptionGuid </param>
        /// <param name="questionGuid"> questionGuid </param>
        /// <param name="answer"> answer </param>
        /// <param name="order"> order </param>
        /// <returns>bool</returns>
        public static bool Update(
            Guid questionOptionGuid,
            Guid questionGuid,
            string answer,
            int order)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "mp_SurveyQuestionOptions_Update", 4);

            sph.DefineSqlParameter("@QuestionOptionGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, questionOptionGuid);
            sph.DefineSqlParameter("@QuestionGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, questionGuid);
            sph.DefineSqlParameter("@Answer", SqlDbType.NVarChar, 255, ParameterDirection.Input, answer);
            sph.DefineSqlParameter("@Order", SqlDbType.Int, ParameterDirection.Input, order);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 28
0
        /// <summary>
        /// Gets a page of data from the mp_UserLocation table.
        /// </summary>
        /// <param name="siteGuid"> siteGuid </param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="totalPages">total pages</param>
        public DbDataReader GetPageBySite(
            Guid siteGuid,
            int pageNumber,
            int pageSize)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString,
                "mp_UserLocation_SelectPageBySite",
                3);

            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@PageNumber", SqlDbType.Int, ParameterDirection.Input, pageNumber);
            sph.DefineSqlParameter("@PageSize", SqlDbType.Int, ParameterDirection.Input, pageSize);
            return(sph.ExecuteReader());
        }
Esempio n. 29
0
        public async Task <DbDataReader> Find(
            int siteId,
            string loginProvider,
            string providerKey)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString,
                "mp_UserLogins_Find",
                3);

            sph.DefineSqlParameter("@LoginProvider", SqlDbType.NVarChar, 128, ParameterDirection.Input, loginProvider);
            sph.DefineSqlParameter("@ProviderKey", SqlDbType.NVarChar, 128, ParameterDirection.Input, providerKey);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);
            return(await sph.ExecuteReaderAsync());
        }
Esempio n. 30
0
        /// <summary>
        /// Updates a row in the gb_KLViewHistory table. Returns true if row updated.
        /// </summary>
        /// <param name="id"> id </param>
        /// <param name="newsID"> newsID </param>
        /// <param name="viewDate"> viewDate </param>
        /// <param name="viewCount"> viewCount </param>
        /// <returns>bool</returns>
        public static bool Update(
            int id,
            int newsID,
            DateTime viewDate,
            int viewCount)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_KLViewHistory_Update", 4);

            sph.DefineSqlParameter("@ID", SqlDbType.Int, ParameterDirection.Input, id);
            sph.DefineSqlParameter("@NewsID", SqlDbType.Int, ParameterDirection.Input, newsID);
            sph.DefineSqlParameter("@ViewDate", SqlDbType.DateTime, ParameterDirection.Input, viewDate);
            sph.DefineSqlParameter("@ViewCount", SqlDbType.Int, ParameterDirection.Input, viewCount);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 31
0
        /// <summary>
        /// Updates a row in the gb_KLLevel table. Returns true if row updated.
        /// </summary>
        /// <param name="levelID"> levelID </param>
        /// <param name="name"> name </param>
        /// <param name="from"> from </param>
        /// <param name="to"> to </param>
        /// <returns>bool</returns>
        public static bool Update(
            int levelID,
            string name,
            int from,
            string to)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_KLLevel_Update", 4);

            sph.DefineSqlParameter("@LevelID", SqlDbType.Int, ParameterDirection.Input, levelID);
            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 50, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@From", SqlDbType.Int, ParameterDirection.Input, from);
            sph.DefineSqlParameter("@To", SqlDbType.NChar, 10, ParameterDirection.Input, to);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 32
0
        /// <summary>
        /// Deletes a row from the mp_UserLogins table. Returns true if row deleted.
        /// </summary>
        /// <param name="loginProvider"> loginProvider </param>
        /// <param name="providerKey"> providerKey </param>
        /// <param name="userId"> userId </param>
        /// <returns>bool</returns>
        public async Task<bool> Delete(int siteId, string loginProvider, string providerKey, string userId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_UserLogins_Delete", 
                4);

            sph.DefineSqlParameter("@LoginProvider", SqlDbType.NVarChar, 128, ParameterDirection.Input, loginProvider);
            sph.DefineSqlParameter("@ProviderKey", SqlDbType.NVarChar, 128, ParameterDirection.Input, providerKey);
            sph.DefineSqlParameter("@UserId", SqlDbType.NVarChar, 128, ParameterDirection.Input, userId);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return (rowsAffected > 0);

        }
Esempio n. 33
0
        /// <summary>
        /// Updates a row in the gb_KLLikeHistory table. Returns true if row updated.
        /// </summary>
        /// <param name="likeID"> likeID </param>
        /// <param name="authorID"> authorID </param>
        /// <param name="newsID"> newsID </param>
        /// <param name="createDate"> createDate </param>
        /// <returns>bool</returns>
        public static bool Update(
            int likeID,
            int authorID,
            int newsID,
            DateTime createDate)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_KLLikeHistory_Update", 4);

            sph.DefineSqlParameter("@LikeID", SqlDbType.Int, ParameterDirection.Input, likeID);
            sph.DefineSqlParameter("@AuthorID", SqlDbType.Int, ParameterDirection.Input, authorID);
            sph.DefineSqlParameter("@NewsID", SqlDbType.Int, ParameterDirection.Input, newsID);
            sph.DefineSqlParameter("@CreateDate", SqlDbType.DateTime, ParameterDirection.Input, createDate);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 34
0
        public static int Add(
            Guid optionGuid,
            Guid pollGuid,
            string answer,
            int order)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "mp_PollOptions_Insert", 4);

            sph.DefineSqlParameter("@OptionGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, optionGuid);
            sph.DefineSqlParameter("@PollGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, pollGuid);
            sph.DefineSqlParameter("@Answer", SqlDbType.NVarChar, 255, ParameterDirection.Input, answer);
            sph.DefineSqlParameter("@Order", SqlDbType.Int, ParameterDirection.Input, order);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected);
        }
Esempio n. 35
0
        public async Task<bool> Update(
            int roleId, 
            string roleName,
            CancellationToken cancellationToken)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_Roles_Update", 
                2);

            sph.DefineSqlParameter("@RoleID", SqlDbType.Int, ParameterDirection.Input, roleId);
            sph.DefineSqlParameter("@RoleName", SqlDbType.NVarChar, 50, ParameterDirection.Input, roleName);
            int rowsAffected = await sph.ExecuteNonQueryAsync(cancellationToken);
            return (rowsAffected > -1);
        }
Esempio n. 36
0
        /// <summary>
        /// Inserts a row in the gb_KLNewType table. Returns new integer id.
        /// </summary>
        /// <param name="name"> name </param>
        /// <param name="url"> url </param>
        /// <param name="parentID"> parentID </param>
        /// <param name="isDelected"> isDelected </param>
        /// <returns>int</returns>
        public static int Create(
            string name,
            string url,
            int parentID,
            bool isDelected)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_KLNewType_Insert", 4);

            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 100, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@Url", SqlDbType.NVarChar, 100, ParameterDirection.Input, url);
            sph.DefineSqlParameter("@ParentID", SqlDbType.Int, ParameterDirection.Input, parentID);
            sph.DefineSqlParameter("@IsDelected", SqlDbType.Bit, ParameterDirection.Input, isDelected);
            int newID = Convert.ToInt32(sph.ExecuteScalar());

            return(newID);
        }
Esempio n. 37
0
        public static int AddDownloadHistory(
            Guid guid,
            Guid ticketGuid,
            DateTime uTCTimestamp,
            string iPAddress)
        {
            SqlParameterHelper sph = new SqlParameterHelper(WebStoreConnectionString.GetWriteConnectionString(), "ws_FullfillDownloadHistory_Insert", 4);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@TicketGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, ticketGuid);
            sph.DefineSqlParameter("@UTCTimestamp", SqlDbType.DateTime, ParameterDirection.Input, uTCTimestamp);
            sph.DefineSqlParameter("@IPAddress", SqlDbType.NVarChar, 255, ParameterDirection.Input, iPAddress);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected);
        }
Esempio n. 38
0
        /// <summary>
        /// Updates a row in the gb_KLFowllowAuthor table. Returns true if row updated.
        /// </summary>
        /// <param name="followID"> followID </param>
        /// <param name="userID"> userID </param>
        /// <param name="authorID"> authorID </param>
        /// <param name="dateStartFollow"> dateStartFollow </param>
        /// <returns>bool</returns>
        public static bool Update(
            int followID,
            int userID,
            int authorID,
            DateTime dateStartFollow)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_KLFowllowAuthor_Update", 4);

            sph.DefineSqlParameter("@FollowID", SqlDbType.Int, ParameterDirection.Input, followID);
            sph.DefineSqlParameter("@UserID", SqlDbType.Int, ParameterDirection.Input, userID);
            sph.DefineSqlParameter("@AuthorID", SqlDbType.Int, ParameterDirection.Input, authorID);
            sph.DefineSqlParameter("@DateStartFollow", SqlDbType.DateTime, ParameterDirection.Input, dateStartFollow);
            int rowsAffected = sph.ExecuteNonQuery();

            return(rowsAffected > 0);
        }
Esempio n. 39
0
        public static int GetCount(
            int siteId,
            int zoneId,
            DateTime currentTime,
            int languageId,
            int position)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetReadConnectionString(), "gb_Product_GetCount", 5);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@ZoneID", SqlDbType.Int, ParameterDirection.Input, zoneId);
            sph.DefineSqlParameter("@CurrentTime", SqlDbType.DateTime, ParameterDirection.Input, currentTime);
            sph.DefineSqlParameter("@LanguageID", SqlDbType.Int, ParameterDirection.Input, languageId);
            sph.DefineSqlParameter("@Position", SqlDbType.Int, ParameterDirection.Input, position);
            return(Convert.ToInt32(sph.ExecuteScalar()));
        }
Esempio n. 40
0
        /// <summary>
        /// Inserts a row in the gb_KLViewHistory table. Returns new integer id.
        /// </summary>
        /// <param name="newsID"> newsID </param>
        /// <param name="viewDate"> viewDate </param>
        /// <param name="viewCount"> viewCount </param>
        /// <returns>int</returns>
        public static int Create(
            int newsID,
            DateTime viewDate,
            DateTime fromdate,
            DateTime todate)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "gb_KLViewHistory_Insert", 3);

            sph.DefineSqlParameter("@NewsID", SqlDbType.Int, ParameterDirection.Input, newsID);
            sph.DefineSqlParameter("@ViewDate", SqlDbType.DateTime, ParameterDirection.Input, viewDate);
            sph.DefineSqlParameter("@FromDate", SqlDbType.DateTime, ParameterDirection.Input, fromdate);
            sph.DefineSqlParameter("@ToDate", SqlDbType.DateTime, ParameterDirection.Input, todate);
            int newID = Convert.ToInt32(sph.ExecuteScalar());

            return(newID);
        }
Esempio n. 41
0
        public async Task <bool> Exists(int siteId, string roleName)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString,
                "mp_Roles_RoleExists",
                2);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@RoleName", SqlDbType.NVarChar, 50, ParameterDirection.Input, roleName);
            object result = await sph.ExecuteScalarAsync();

            int count = Convert.ToInt32(result);

            return(count > 0);
        }
Esempio n. 42
0
        /// <summary>
        /// Deletes a row from the mp_UserLogins table. Returns true if row deleted.
        /// </summary>
        /// <param name="loginProvider"> loginProvider </param>
        /// <param name="providerKey"> providerKey </param>
        /// <param name="userId"> userId </param>
        /// <returns>bool</returns>
        public async Task <bool> Delete(int siteId, string loginProvider, string providerKey, string userId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString,
                "mp_UserLogins_Delete",
                4);

            sph.DefineSqlParameter("@LoginProvider", SqlDbType.NVarChar, 128, ParameterDirection.Input, loginProvider);
            sph.DefineSqlParameter("@ProviderKey", SqlDbType.NVarChar, 128, ParameterDirection.Input, providerKey);
            sph.DefineSqlParameter("@UserId", SqlDbType.NVarChar, 128, ParameterDirection.Input, userId);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);
            int rowsAffected = await sph.ExecuteNonQueryAsync();

            return(rowsAffected > 0);
        }
Esempio n. 43
0
        public async Task<bool> Update(
            Guid guid,
            Guid siteGuid,
            string folderName)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_SiteFolders_Update", 
                3);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@FolderName", SqlDbType.NVarChar, 255, ParameterDirection.Input, folderName);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return (rowsAffected > -1);
        }
Esempio n. 44
0
        /// <summary>
        /// Inserts a row in the mp_BannedIPAddresses table. Returns new integer id.
        /// </summary>
        /// <param name="bannedIP"> bannedIP </param>
        /// <param name="bannedUTC"> bannedUTC </param>
        /// <param name="bannedReason"> bannedReason </param>
        /// <returns>int</returns>
        public int Add(
            string bannedIP,
            DateTime bannedUtc,
            string bannedReason)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_BannedIPAddresses_Insert", 
                3);

            sph.DefineSqlParameter("@BannedIP", SqlDbType.NVarChar, 50, ParameterDirection.Input, bannedIP);
            sph.DefineSqlParameter("@BannedUTC", SqlDbType.DateTime, ParameterDirection.Input, bannedUtc);
            sph.DefineSqlParameter("@BannedReason", SqlDbType.NVarChar, 255, ParameterDirection.Input, bannedReason);
            int newID = Convert.ToInt32(sph.ExecuteScalar());
            return newID;
        }
Esempio n. 45
0
        /// <summary>
        /// Inserts a row in the mp_UserLocation table. Returns rows affected count.
        /// </summary>
        /// <param name="rowID"> rowID </param>
        /// <param name="userGuid"> userGuid </param>
        /// <param name="siteGuid"> siteGuid </param>
        /// <param name="iPAddress"> iPAddress </param>
        /// <param name="iPAddressLong"> iPAddressLong </param>
        /// <param name="hostname"> hostname </param>
        /// <param name="longitude"> longitude </param>
        /// <param name="latitude"> latitude </param>
        /// <param name="iSP"> iSP </param>
        /// <param name="continent"> continent </param>
        /// <param name="country"> country </param>
        /// <param name="region"> region </param>
        /// <param name="city"> city </param>
        /// <param name="timeZone"> timeZone </param>
        /// <param name="captureCount"> captureCount </param>
        /// <param name="firstCaptureUTC"> firstCaptureUTC </param>
        /// <param name="lastCaptureUTC"> lastCaptureUTC </param>
        /// <returns>int</returns>
        public int Create(
            Guid rowID,
            Guid userGuid,
            Guid siteGuid,
            string iPAddress,
            long iPAddressLong,
            string hostname,
            double longitude,
            double latitude,
            string iSP,
            string continent,
            string country,
            string region,
            string city,
            string timeZone,
            int captureCount,
            DateTime firstCaptureUTC,
            DateTime lastCaptureUTC)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_UserLocation_Insert", 
                17);

            sph.DefineSqlParameter("@RowID", SqlDbType.UniqueIdentifier, ParameterDirection.Input, rowID);
            sph.DefineSqlParameter("@UserGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, userGuid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@IPAddress", SqlDbType.NVarChar, 50, ParameterDirection.Input, iPAddress);
            sph.DefineSqlParameter("@IPAddressLong", SqlDbType.BigInt, ParameterDirection.Input, iPAddressLong);
            sph.DefineSqlParameter("@Hostname", SqlDbType.NVarChar, 255, ParameterDirection.Input, hostname);
            sph.DefineSqlParameter("@Longitude", SqlDbType.Float, ParameterDirection.Input, longitude);
            sph.DefineSqlParameter("@Latitude", SqlDbType.Float, ParameterDirection.Input, latitude);
            sph.DefineSqlParameter("@ISP", SqlDbType.NVarChar, 255, ParameterDirection.Input, iSP);
            sph.DefineSqlParameter("@Continent", SqlDbType.NVarChar, 255, ParameterDirection.Input, continent);
            sph.DefineSqlParameter("@Country", SqlDbType.NVarChar, 255, ParameterDirection.Input, country);
            sph.DefineSqlParameter("@Region", SqlDbType.NVarChar, 255, ParameterDirection.Input, region);
            sph.DefineSqlParameter("@City", SqlDbType.NVarChar, 255, ParameterDirection.Input, city);
            sph.DefineSqlParameter("@TimeZone", SqlDbType.NVarChar, 255, ParameterDirection.Input, timeZone);
            sph.DefineSqlParameter("@CaptureCount", SqlDbType.Int, ParameterDirection.Input, captureCount);
            sph.DefineSqlParameter("@FirstCaptureUTC", SqlDbType.DateTime, ParameterDirection.Input, firstCaptureUTC);
            sph.DefineSqlParameter("@LastCaptureUTC", SqlDbType.DateTime, ParameterDirection.Input, lastCaptureUTC);
            int rowsAffected = sph.ExecuteNonQuery();
            return rowsAffected;
        }
Esempio n. 46
0
        /// <summary>
        /// Inserts a row in the mp_TaskQueue table. Returns rows affected count.
        /// </summary>
        /// <param name="guid"> guid </param>
        /// <param name="siteGuid"> siteGuid </param>
        /// <param name="queuedBy"> queuedBy </param>
        /// <param name="taskName"> taskName </param>
        /// <param name="notifyOnCompletion"> notifyOnCompletion </param>
        /// <param name="notificationToEmail"> notificationToEmail </param>
        /// <param name="notificationFromEmail"> notificationFromEmail </param>
        /// <param name="notificationSubject"> notificationSubject </param>
        /// <param name="taskCompleteMessage"> taskCompleteMessage </param>
        /// <param name="canStop"> canStop </param>
        /// <param name="canResume"> canResume </param>
        /// <param name="updateFrequency"> updateFrequency </param>
        /// <param name="queuedUTC"> queuedUTC </param>
        /// <param name="completeRatio"> completeRatio </param>
        /// <param name="status"> status </param>
        /// <param name="serializedTaskObject"> serializedTaskObject </param>
        /// <param name="serializedTaskType"> serializedTaskType </param>
        /// <returns>int</returns>
        public int Create(
            Guid guid,
            Guid siteGuid,
            Guid queuedBy,
            string taskName,
            bool notifyOnCompletion,
            string notificationToEmail,
            string notificationFromEmail,
            string notificationSubject,
            string taskCompleteMessage,
            bool canStop,
            bool canResume,
            int updateFrequency,
            DateTime queuedUTC,
            double completeRatio,
            string status,
            string serializedTaskObject,
            string serializedTaskType)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_TaskQueue_Insert", 
                17);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@QueuedBy", SqlDbType.UniqueIdentifier, ParameterDirection.Input, queuedBy);
            sph.DefineSqlParameter("@TaskName", SqlDbType.NVarChar, 255, ParameterDirection.Input, taskName);
            sph.DefineSqlParameter("@NotifyOnCompletion", SqlDbType.Bit, ParameterDirection.Input, notifyOnCompletion);
            sph.DefineSqlParameter("@NotificationToEmail", SqlDbType.NVarChar, 255, ParameterDirection.Input, notificationToEmail);
            sph.DefineSqlParameter("@NotificationFromEmail", SqlDbType.NVarChar, 255, ParameterDirection.Input, notificationFromEmail);
            sph.DefineSqlParameter("@NotificationSubject", SqlDbType.NVarChar, 255, ParameterDirection.Input, notificationSubject);
            sph.DefineSqlParameter("@TaskCompleteMessage", SqlDbType.NVarChar, -1, ParameterDirection.Input, taskCompleteMessage);
            sph.DefineSqlParameter("@CanStop", SqlDbType.Bit, ParameterDirection.Input, canStop);
            sph.DefineSqlParameter("@CanResume", SqlDbType.Bit, ParameterDirection.Input, canResume);
            sph.DefineSqlParameter("@UpdateFrequency", SqlDbType.Int, ParameterDirection.Input, updateFrequency);
            sph.DefineSqlParameter("@QueuedUTC", SqlDbType.DateTime, ParameterDirection.Input, queuedUTC);
            sph.DefineSqlParameter("@CompleteRatio", SqlDbType.Float, ParameterDirection.Input, completeRatio);
            sph.DefineSqlParameter("@Status", SqlDbType.NVarChar, 255, ParameterDirection.Input, status);
            sph.DefineSqlParameter("@SerializedTaskObject", SqlDbType.NVarChar, -1, ParameterDirection.Input, serializedTaskObject);
            sph.DefineSqlParameter("@SerializedTaskType", SqlDbType.NVarChar, 255, ParameterDirection.Input, serializedTaskType);
            int rowsAffected = sph.ExecuteNonQuery();
            return rowsAffected;
        }
Esempio n. 47
0
        public async Task<bool> Add(
            Guid guid,
            Guid siteGuid,
            string folderName,
            CancellationToken cancellationToken)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_SiteFolders_Insert", 
                3);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@FolderName", SqlDbType.NVarChar, 255, ParameterDirection.Input, folderName);
            int rowsAffected = await sph.ExecuteNonQueryAsync(cancellationToken);
            return rowsAffected > 0;
        }
Esempio n. 48
0
        /// <summary>
        /// Updates a row in the mp_BannedIPAddresses table. Returns true if row updated.
        /// </summary>
        /// <param name="rowID"> rowID </param>
        /// <param name="bannedIP"> bannedIP </param>
        /// <param name="bannedUTC"> bannedUTC </param>
        /// <param name="bannedReason"> bannedReason </param>
        /// <returns>bool</returns>
        public bool Update(
            int rowId,
            string bannedIP,
            DateTime bannedUtc,
            string bannedReason)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_BannedIPAddresses_Update", 
                4);

            sph.DefineSqlParameter("@RowID", SqlDbType.Int, ParameterDirection.Input, rowId);
            sph.DefineSqlParameter("@BannedIP", SqlDbType.NVarChar, 50, ParameterDirection.Input, bannedIP);
            sph.DefineSqlParameter("@BannedUTC", SqlDbType.DateTime, ParameterDirection.Input, bannedUtc);
            sph.DefineSqlParameter("@BannedReason", SqlDbType.NVarChar, 255, ParameterDirection.Input, bannedReason);
            int rowsAffected = sph.ExecuteNonQuery();
            return (rowsAffected > 0);
        }
Esempio n. 49
0
        /// <summary>
        /// Updates a row in the mp_GeoZone table. Returns true if row updated.
        /// </summary>
        /// <param name="guid"> guid </param>
        /// <param name="countryGuid"> countryGuid </param>
        /// <param name="name"> name </param>
        /// <param name="code"> code </param>
        /// <returns>bool</returns>
        public async Task<bool> Update(
            Guid guid,
            Guid countryGuid,
            string name,
            string code)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_GeoZone_Update", 
                4);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@CountryGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, countryGuid);
            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 255, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@Code", SqlDbType.NVarChar, 255, ParameterDirection.Input, code);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return (rowsAffected > 0);

        }
Esempio n. 50
0
        /// <summary>
        /// Inserts a row in the mp_GeoCountry table. Returns rows affected count.
        /// </summary>
        /// <param name="guid"> guid </param>
        /// <param name="name"> name </param>
        /// <param name="iSOCode2"> iSOCode2 </param>
        /// <param name="iSOCode3"> iSOCode3 </param>
        /// <returns>int</returns>
        public async Task<bool> Create(
            Guid guid,
            string name,
            string iSOCode2,
            string iSOCode3)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_GeoCountry_Insert", 
                4);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 255, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@ISOCode2", SqlDbType.NChar, 2, ParameterDirection.Input, iSOCode2);
            sph.DefineSqlParameter("@ISOCode3", SqlDbType.NChar, 3, ParameterDirection.Input, iSOCode3);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return rowsAffected > 0;

        }
Esempio n. 51
0
        public async Task<int> RoleCreate(
            Guid roleGuid,
            Guid siteGuid,
            int siteId,
            string roleName)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_Roles_Insert", 
                4);

            sph.DefineSqlParameter("@RoleGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, roleGuid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@RoleName", SqlDbType.NVarChar, 50, ParameterDirection.Input, roleName);
            object result = await sph.ExecuteScalarAsync();
            int newID = Convert.ToInt32(result);
            return newID;
        }
Esempio n. 52
0
        /// <summary>
        /// Inserts a row in the mp_Language table. Returns rows affected count.
        /// </summary>
        /// <param name="guid"> guid </param>
        /// <param name="name"> name </param>
        /// <param name="code"> code </param>
        /// <param name="sort"> sort </param>
        /// <returns>int</returns>
        public async Task<bool> Create(
            Guid guid,
            string name,
            string code,
            int sort)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_Language_Insert", 
                4);

            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@Name", SqlDbType.NVarChar, 255, ParameterDirection.Input, name);
            sph.DefineSqlParameter("@Code", SqlDbType.NChar, 2, ParameterDirection.Input, code);
            sph.DefineSqlParameter("@Sort", SqlDbType.Int, ParameterDirection.Input, sort);
            int rowsAffected = await sph.ExecuteNonQueryAsync();
            return rowsAffected > 0;

        }
Esempio n. 53
0
        public async Task<int> Create(
            int siteId,
            string userId,
            string claimType,
            string claimValue)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_UserClaims_Insert", 
                4);

            sph.DefineSqlParameter("@UserId", SqlDbType.NVarChar, 128, ParameterDirection.Input, userId);
            sph.DefineSqlParameter("@ClaimType", SqlDbType.NVarChar, -1, ParameterDirection.Input, claimType);
            sph.DefineSqlParameter("@ClaimValue", SqlDbType.NVarChar, -1, ParameterDirection.Input, claimValue);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);

            object result = await sph.ExecuteScalarAsync();
            int newID = Convert.ToInt32(result);
            return newID;
        }
Esempio n. 54
0
        public bool SaveExpandoProperty(
            int siteId,
            Guid siteGuid,
            string groupName,
            string keyName,
            string keyValue)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_SiteSettingsEx_Save", 
                5);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@KeyName", SqlDbType.NVarChar, 128, ParameterDirection.Input, keyName);
            sph.DefineSqlParameter("@KeyValue", SqlDbType.NVarChar, -1, ParameterDirection.Input, keyValue);
            sph.DefineSqlParameter("@GroupName", SqlDbType.NVarChar, 255, ParameterDirection.Input, keyName);

            int rowsAffected = sph.ExecuteNonQuery();
            return (rowsAffected > -1);

        }
Esempio n. 55
0
        /// <summary>
        /// Inserts a row in the mp_UserLogins table. Returns new integer id.
        /// </summary>
        /// <returns>int</returns>
        public async Task<bool> Create(
            int siteId,
            string loginProvider, 
            string providerKey,
            string providerDisplayName,
            string userId,
            CancellationToken cancellationToken)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_UserLogins_Insert", 
                5);

            sph.DefineSqlParameter("@LoginProvider", SqlDbType.NVarChar, 128, ParameterDirection.Input, loginProvider);
            sph.DefineSqlParameter("@ProviderKey", SqlDbType.NVarChar, 128, ParameterDirection.Input, providerKey);
            sph.DefineSqlParameter("@UserId", SqlDbType.NVarChar, 128, ParameterDirection.Input, userId);
            sph.DefineSqlParameter("@SiteId", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@ProviderDisplayName", SqlDbType.NVarChar, 100, ParameterDirection.Input, providerDisplayName);

            int rowsAffected = await sph.ExecuteNonQueryAsync(cancellationToken);
            return (rowsAffected > 0);
        }
Esempio n. 56
0
        public async Task<DbDataReader> GetSingleUser(int siteId, string email)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_Users_SelectByEmail", 
                2);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@Email", SqlDbType.NVarChar, 100, ParameterDirection.Input, email);
            return await sph.ExecuteReaderAsync();
        }
Esempio n. 57
0
        public async Task<int> CountUsers(int siteId, String userNameBeginsWith)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_Users_CountByFirstLetter", 
                2);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@UserNameBeginsWith", SqlDbType.NVarChar, 1, ParameterDirection.Input, userNameBeginsWith);
            object result = await sph.ExecuteScalarAsync();
            int count = Convert.ToInt32(result);
            return count;
        }
Esempio n. 58
0
        public async Task<DbDataReader> GetUserByRegistrationGuid(int siteId, Guid registerConfirmGuid)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_Users_SelectByRegisterGuid", 
                2);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@RegisterConfirmGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, registerConfirmGuid);
            return await sph.ExecuteReaderAsync();
        }
Esempio n. 59
0
        public async Task<DbDataReader> GetRolesByUser(int siteId, int userId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                readConnectionString, 
                "mp_Users_GetUserRoles", 
                2);

            sph.DefineSqlParameter("@SiteID", SqlDbType.Int, ParameterDirection.Input, siteId);
            sph.DefineSqlParameter("@UserID", SqlDbType.Int, ParameterDirection.Input, userId);
            return await sph.ExecuteReaderAsync();
        }
Esempio n. 60
0
        public bool DecrementTotalPosts(int userId)
        {
            SqlParameterHelper sph = new SqlParameterHelper(
                logFactory,
                writeConnectionString, 
                "mp_Users_DecrementTotalPosts", 
                1);

            sph.DefineSqlParameter("@UserID", SqlDbType.Int, ParameterDirection.Input, userId);
            int rowsAffected = sph.ExecuteNonQuery();
            return (rowsAffected > -1);
        }