protected void Page_InIt(object sender, EventArgs e) { //ErrorMessage CSSClass ProductIdUrlParameter PersonifyControlBase objbase = new PersonifyControlBase(); var ctrl = new Personify.WebControls.Membership.UI.MembershipListingControl(); string customTableClassName = "Sme.personifyPages"; string where = "Parametername ='ProductDetails'"; DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where); if (customTableRecord != null) { ctrl.Step1RegistrationUrl = customTableRecord.Tables[0].Rows[0]["ParameterValue"].ToString(); } ctrl.ProductIdUrlParameter = "productid"; //LoadDropdownList(ddlErrorMessage); //if (!string.IsNullOrEmpty(ErrorMessage)) { ctrl.ErrorMessage = ErrorMessage; } //if (!string.IsNullOrEmpty(ProductIdUrlParameter)) { ctrl.ProductIdUrlParameter = "productId"; } //if (!string.IsNullOrEmpty(RateCodeUrlParameter)) { ctrl.RateCodeUrlParameter = RateCodeUrlParameter; } //LoadDropdownList(ddlStep1RegistrationUrl); //if (!string.IsNullOrEmpty(Step1RegistrationUrl)) { ctrl.Step1RegistrationUrl = Step1RegistrationUrl; } objbase.InitPersonifyWebControl(ctrl); phPersonifyControl.Controls.Add(ctrl); }
protected void Page_InIt(object sender, EventArgs e) { PersonifyControlBase objbase = new PersonifyControlBase(); var ctrl = new Personify.WebControls.Membership.UI.MembershipJoinRegistrationControl(); string customTableClassName = "Sme.personifyPages"; string where = "Parametername ='MbrJoinStep2'"; DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where); //if (!string.IsNullOrEmpty(CancelUrl)) { ctrl.CancelUrl = CancelUrl; } //if (!string.IsNullOrEmpty(CompanySearchEnable)) { ctrl.CompanySearchEnable = System.Boolean.Parse(CompanySearchEnable); } //if (!string.IsNullOrEmpty(CustomCssClass)) { ctrl.CustomCssClass = CustomCssClass; } //LoadDropdownList(ddlErrorMessage); //if (!string.IsNullOrEmpty(ErrorMessage)) { ctrl.ErrorMessage = ErrorMessage; } //LoadDropdownList(ddlImageDirectory); //if (!string.IsNullOrEmpty(ImageDirectory)) { ctrl.ImageDirectory = ImageDirectory; } //if (!string.IsNullOrEmpty(LinkCompanyEnable)) { ctrl.LinkCompanyEnable = System.Boolean.Parse(LinkCompanyEnable); } //if (!string.IsNullOrEmpty(ProductIdUrlParameter)) { ctrl.ProductIdUrlParameter = ProductIdUrlParameter; } //if (!string.IsNullOrEmpty(QueryStringParametersToPreserve)) { ctrl.QueryStringParametersToPreserve = QueryStringParametersToPreserve; } //if (!string.IsNullOrEmpty(RateCodeUrlParameter)) { ctrl.RateCodeUrlParameter = RateCodeUrlParameter; } //LoadDropdownList(ddlStep2Url); if (customTableRecord != null) { ctrl.Step2Url = customTableRecord.Tables[0].Rows[0]["ParameterValue"].ToString(); } //LoadDropdownList(ddlUserExistUrl); //if (!string.IsNullOrEmpty(UserExistUrl)) { ctrl.UserExistUrl = UserExistUrl; } objbase.InitPersonifyWebControl(ctrl); phPersonifyControl.Controls.Add(ctrl); }
/// <summary> /// Get the brand list /// </summary> /// <param name="brandItemID"></param> /// <returns></returns> public string GetBrandName() { string returnValue = string.Empty; try { var brands = CustomTableItemProvider.GetItems(BrandItem.CLASS_NAME) .Columns("ItemId,BrandName") .ToList(); if (!DataHelper.DataSourceIsEmpty(brands)) { ddlBrand.DataSource = brands; ddlBrand.DataTextField = "BrandName"; ddlBrand.DataValueField = "ItemId"; ddlBrand.DataBind(); string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.InvProductForm.BrandWaterMark"), string.Empty); ddlBrand.Items.Insert(0, new ListItem(selectText, "0")); } } catch (Exception ex) { EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "GetBrandName", ex, CurrentSite.SiteID, ex.Message); } return(returnValue); }
public static object GetBusinessUnits(EvaluationContext context, params object[] parameters) { try { int userID = ValidationHelper.GetInteger(parameters[0], 0); var data = CustomTableItemProvider.GetItems <UserBusinessUnitsItem>() .WhereEquals("UserID", userID) .Columns("BusinessUnitID") .ToList(); var buList = new List <string>(); if (!DataHelper.DataSourceIsEmpty(data)) { data.ForEach(x => { var unitName = CustomTableItemProvider.GetItem <BusinessUnitItem>(x.BusinessUnitID); buList.Add(unitName?.GetStringValue("BusinessUnitName", string.Empty) ?? string.Empty); }); } return(String.Join(",", buList)); } catch (Exception ex) { EventLogProvider.LogInformation("Kadena Macro methods", "GetBusinessUnits", ex.Message); return(string.Empty); } }
public void UpdateUserBudgetAllocationRecords(int userId, string year, decimal?totalToBeDeducted) { var userBudgetDetails = CustomTableItemProvider.GetItems(CustomTableClassName).WhereEquals("UserID", userId).WhereEquals("Year", year).FirstOrDefault(); userBudgetDetails.SetValue("UserRemainingBudget", userBudgetDetails.GetValue("UserRemainingBudget", default(decimal)) - totalToBeDeducted); userBudgetDetails.Update(); }
/// <summary> /// This method will get all the allocated user /// </summary> /// <param name="ProductId"></param> private void BindEditProduct(int ProductId) { try { lstUsers = new List <AllocateProduct>(); List <AllocateProduct> lstProduct = new List <AllocateProduct>(); string customTableClassName = "KDA.UserAllocatedProducts"; DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName); if (customTable != null) { var customTableData = CustomTableItemProvider.GetItems(customTableClassName) .WhereStartsWith("ProductID", ProductId.ToString()); foreach (CustomTableItem item in customTableData) { AllocateProduct objProduct = new AllocateProduct(); objProduct.EmailID = ValidationHelper.GetString(item.GetValue("EmailID"), string.Empty); objProduct.UserName = UserInfoProvider.GetUserInfo(ValidationHelper.GetInteger(item.GetValue("UserID"), 0)).FullName; objProduct.Quantity = ValidationHelper.GetInteger(item.GetValue("Quantity"), 0); objProduct.UserID = ValidationHelper.GetInteger(item.GetValue("UserID"), 0); lstProduct.Add(objProduct); } lstUsers.AddRange(lstProduct); } RepSelectedUser.DataSource = lstProduct; RepSelectedUser.DataBind(); } catch (Exception ex) { EventLogProvider.LogException("Product allocation update BindEdit", "EXCEPTION", ex); } }
private void DoStuff() { var products = DocumentHelper.GetDocuments("PbcLinear.Product"); foreach (var product in products) { if (product != null) { var stringSKU = ValidationHelper.GetString(product.DocumentName, String.Empty, CultureInfo.CurrentCulture); // once we find product from step 3 we look up matching category from our list in step 2 var categoryRecord = CustomTableItemProvider.GetItems <ProductAssociationsItem>() .FirstOrDefault(x => x.ProductSKUNumber == stringSKU); // if product detail and product category are not null, add relationship to table mapping product detail node id and product category node id if (categoryRecord != null) { ProcessCategory(product.NodeID, categoryRecord.ProductCategory1); ProcessCategory(product.NodeID, categoryRecord.ProductCategory2); ProcessCategory(product.NodeID, categoryRecord.ProductCategory3); } } } }
public IEnumerable <AirportDto> GetAirportDtos(string searchPhrase = null) { if (AirportsTable != null) { var query = CustomTableItemProvider.GetItems(CustomTableClassName) .OrderBy("AirportName"); if (!string.IsNullOrWhiteSpace(searchPhrase)) { query.WhereContains(NameColumn, searchPhrase); } foreach (var airport in query) { var iataCode = ValidationHelper.GetString(airport.GetValue(IataCodeColumn), ""); var name = ValidationHelper.GetString(airport.GetValue(NameColumn), ""); yield return(new AirportDto { AirportIataCode = iataCode, AirportName = name }); } } }
/// <summary> /// Gets the custom table item and moves it down. Called when the "Get and move item down" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool GetAndMoveCustomTableItemDown() { string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text'"; int topN = 1; string columns = "ItemID"; // Get the data set according to the parameters DataSet dataSet = CustomTableItemProvider.GetItems(customTableClassName, where, null, topN, columns); if (!DataHelper.DataSourceIsEmpty(dataSet)) { // Get the custom table item ID int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0); var item = CustomTableItemProvider.GetItem(itemID, customTableClassName); // Move the item down item.Generalized.MoveObjectDown(); return(true); } } return(false); }
/// <summary> /// Converts an Object's IDs, Guids, or CodeNames to the Objects CodeNames /// </summary> /// <param name="classObjSummary">The Class Object Summary</param> /// <param name="ObjectIdentifications">List of Object IDs, Guids, or CodeNames</param> /// <returns>A list of the Object's Code Names</returns> private static IEnumerable <string> ObjectIdentitiesToCodeNames(ClassObjSummary classObjSummary, IEnumerable <object> ObjectIdentifications) { switch (classObjSummary.ClassName.ToLower()) { case "cms.tree": case "cms.document": return(new DocumentQuery().Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); default: if (classObjSummary.ClassIsDocumentType) { return(new DocumentQuery(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } else if (classObjSummary.ClassIsCustomTable) { return(CustomTableItemProvider.GetItems(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } else if (classObjSummary.ClassIsForm) { return(BizFormItemProvider.GetItems(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } else { return(new ObjectQuery(classObjSummary.ClassName).Where(ObjectIdentitiesWhere(classObjSummary, ObjectIdentifications)).Columns(classObjSummary.CodeNameColumn).Select(x => (string)x.GetValue(classObjSummary.CodeNameColumn)).ToArray()); } } }
public static object GetValueFromCustomTableByItemGUID(EvaluationContext context, params object[] parameters) { if (parameters[0] == null || parameters[1] == null || parameters[2] == null) { return(null); } string CustomTableName = ValidationHelper.GetString(parameters[0], ""); string UniqueID = ValidationHelper.GetString(parameters[1], ""); string ColumnName = ValidationHelper.GetString(parameters[2], ""); DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(CustomTableName); if (customTable != null) { var ds = CustomTableItemProvider.GetItems(CustomTableName) .Column(ColumnName) .WhereEquals("ItemGUID", UniqueID) .TopN(1); if (!DataHelper.DataSourceIsEmpty(ds) && ds.Tables[0].Rows.Count > 0) { return(ds.Tables[0].Rows[0][0]); } } return(null); }
private void PopulateErrors(IEnumerable <MailingAddressDto> badAddresses) { var errorsDictionary = CustomTableItemProvider .GetItems("KDA.AddressErrors") .ToDictionary(i => i["ErrorCode"].ToString(), i => i["ErrorDescription"].ToString()); var missingCodes = new HashSet <string>(); foreach (var address in badAddresses) { string errorDescription; if (errorsDictionary.TryGetValue(address.ErrorMessage, out errorDescription)) { address.ErrorMessage = errorDescription; } else { if (!missingCodes.Contains(address.ErrorMessage)) { missingCodes.Add(address.ErrorMessage); } } } if (missingCodes.Any()) { var exc = new KeyNotFoundException($"The error description is not found for following key(s): {string.Join(", ", missingCodes)}"); EventLogProvider.LogWarning("Mailing Addresses Load", "WARNING", exc, CurrentSite.SiteID, string.Empty); } }
/// <summary> /// Gets the custom table item and moves it up. Called when the "Get and move item up" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool GetAndMoveCustomTableItemUp() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text'"; int topN = 1; string columns = "ItemID"; // Get the data set according to the parameters DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns); if (!DataHelper.DataSourceIsEmpty(dataSet)) { // Get the custom table item ID int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0); // Move the item up customTableProvider.MoveItemUp(itemID, customTableClassName); return(true); } } return(false); }
/// <summary> /// Deletes customTableItem. Called when the "Delete item" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool DeleteCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text%'"; // Get the data DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loop through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Create object from DataRow CustomTableItem deleteCustomTableItem = CustomTableItem.New(customTableItemDr, customTableClassName); // Delete custom table item from database deleteCustomTableItem.Delete(); } return(true); } } return(false); }
private List <CustomTableItem> GetAuthors(string authorsId) { List <int> authorsIdArray = new List <int>(Array.ConvertAll(authorsId.Split('|'), int.Parse)); List <CustomTableItem> ArticleAuthors = new List <CustomTableItem>(); // Get Authors list List <CustomTableItem> Authors = CacheHelper.Cache(cs => { List <CustomTableItem> data = CustomTableItemProvider.GetItems("MedioClinic.Authors").ToList(); if (data != null && cs.Cached) { cs.CacheDependency = CacheHelper.GetCacheDependency("customtableitem|medioclinic.authors|all"); } return(data); }, new CacheSettings(10, string.Format("MedioClinic_GetAuthors()|{0}", SiteContext.CurrentSiteName))); foreach (var item in Authors) { if (authorsIdArray.Contains(item.GetIntegerValue("ItemId", -1))) { ArticleAuthors.Add(item); } } return(ArticleAuthors); }
/// <summary> /// custom validator for checking the uniqueness of the busines unit number /// </summary> protected void cvBUNumber_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { try { BusinessUnitItem objBusinessUnit = new BusinessUnitItem(); var buNumber = ValidationHelper.GetLong(txtBUNumber.Text, default(int)); int itemID = QueryHelper.GetInteger("itemID", 0); if (itemID > 0) { var buData = CustomTableItemProvider.GetItems <BusinessUnitItem>() .WhereEquals("BusinessUnitNumber", buNumber) .And() .WhereNotEquals("ItemID", itemID) .Columns("BusinessUnitNumber") .FirstOrDefault(); args.IsValid = DataHelper.DataSourceIsEmpty(buData); } else { var buData = CustomTableItemProvider.GetItems <BusinessUnitItem>() .WhereEquals("BusinessUnitNumber", buNumber) .Columns("BusinessUnitNumber") .FirstOrDefault(); args.IsValid = DataHelper.DataSourceIsEmpty(buData); } } catch (Exception ex) { EventLogProvider.LogException("BusinessUnit.ascx.cs", "cvBUNumber_ServerValidate()", ex); } }
/// <summary> /// Global event for User object to update FY Budget /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void KDAUser_Update_After(object sender, ObjectEventArgs e) { bool userFYBudgetEnabled = SettingsKeyInfoProvider.GetBoolValue("KDA_UserFYBudgetEnabled", SiteContext.CurrentSiteID); UserInfo user = e.Object as UserInfo; if (user != null && userFYBudgetEnabled) { double budget = user.GetDoubleValue("FYBudget", 0); if (budget > 0) { UserFYBudgetAllocationItem userBudget = CustomTableItemProvider.GetItems <UserFYBudgetAllocationItem>() .Where(x => x.UserID.Equals(user.UserID) && x.Year.Equals(DateTime.Now.Year.ToString()) && x.SiteID.Equals(SiteContext.CurrentSiteID)) .FirstOrDefault(); if (userBudget == null) { userBudget = new UserFYBudgetAllocationItem(); } userBudget.Year = DateTime.Now.Year.ToString(); userBudget.UserID = user.UserID; userBudget.Budget = budget; userBudget.SiteID = SiteContext.CurrentSiteID; if (userBudget.ItemID > 0) { userBudget.Update(); } else { userBudget.Insert(); } } } }
public static void InsertIBFForm(OrderDTO orderDetails) { try { var productItems = orderDetails.Items.ToList(); foreach (var product in productItems) { bool isExist = true; InboundTrackingItem inboundData = CustomTableItemProvider.GetItems <InboundTrackingItem>().WhereEquals("SKUID", product.SKU.KenticoSKUID).FirstOrDefault(); if (inboundData == null) { inboundData = new InboundTrackingItem(); isExist = false; } inboundData.SKUID = product.SKU.KenticoSKUID; inboundData.QtyOrdered = product.UnitCount; if (!isExist) { inboundData.Insert(); } else { inboundData.Update(); } } } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetOrderTotal", ex.Message); } }
private void GetLieu() { CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser); string customTableClassName = "customtable.region"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { string where = "itemID<>'1'"; string orderby = "Libelle"; DataSet data = customTableProvider.GetItems(customTableClassName, where, orderby); if (!DataHelper.DataSourceIsEmpty(data)) { // Bind lieu to the drop-down list this.drpLieu.DataSource = data; this.drpLieu.DataTextField = "Libelle"; this.drpLieu.DataValueField = "ItemID"; this.drpLieu.DataBind(); RemoveDuplicateItems(drpLieu); // Add default '(tous)' value this.drpLieu.Items.Insert(0, new ListItem("FILTRER PAR REGION", "0")); // Add PRES DE CHEZ VOUS value this.drpLieu.Items.Insert(drpLieu.Items.Count, new ListItem("Près de chez vous", "1")); } } }
/// <summary> /// This method will get all the users and bind it to repeater /// </summary> /// <param name="pageIndex"></param> private void BindUsers(int pageIndex) { List <AllocateProduct> lstAllocatedProd = new List <AllocateProduct>(); string customTableClassName = "KDA.UserAllocatedProducts"; var users = UserInfoProvider.GetUsers().Columns("Email", "UserID", "FullName").OnSite(CurrentSite.SiteID).OrderBy("FullName") .Skip(PageSize * (pageIndex - 1)) .Take(PageSize); foreach (UserInfo user in users) { AllocateProduct objProduct = new AllocateProduct(); objProduct.EmailID = user.Email; objProduct.UserID = user.UserID; objProduct.UserName = user.FullName; objProduct.Quantity = CustomTableItemProvider.GetItems(customTableClassName) .WhereEquals("ProductID", productId).WhereEquals("UserID", user.UserID).FirstOrDefault()?.GetValue("Quantity", default(int)) ?? 0; if (lstUsers.FindIndex(item => item.UserID == user.UserID) > -1) { objProduct.Selected = true; } lstAllocatedProd.Add(objProduct); } RepterDetails.DataSource = lstAllocatedProd; RepterDetails.DataBind(); PopulatePager(UserInfoProvider.GetUsers().OnSite(CurrentSite.SiteID).Count(), pageIndex); }
/// <summary> /// Get the State list /// </summary> /// <returns></returns> public string GetStateGroup() { string returnValue = string.Empty; try { var states = CustomTableItemProvider.GetItems(StatesGroupItem.CLASS_NAME) .Columns("ItemID,States,GroupName") .ToList(); if (!DataHelper.DataSourceIsEmpty(states)) { ddlState.DataSource = states; ddlState.DataTextField = "GroupName"; ddlState.DataValueField = "ItemID"; ddlState.DataBind(); string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.InvProductForm.StateWaterMark"), string.Empty); ddlState.Items.Insert(0, new ListItem(selectText, "0")); RepStateInfo.DataSource = states; RepStateInfo.DataBind(); } } catch (Exception ex) { EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_AddCampaignProducts", "GetStateGroup", ex, CurrentSite.SiteID, ex.Message); } return(returnValue); }
protected void ddlPosNo_SelectedIndexChanged(object sender, EventArgs e) { try { string selectedPos = ddlPosNo.SelectedValue; BindData(); SKUInfo skuDetails = SKUInfoProvider.GetSKUs().WhereEquals("SKUNumber", selectedPos).FirstObject; if (skuDetails != null) { string folderName = libraryFolderName; folderName = !string.IsNullOrEmpty(folderName) ? folderName.Replace(" ", "") : "CampaignProducts"; txtLongDes.Text = skuDetails.SKUDescription; txtEstPrice.Text = ValidationHelper.GetString(skuDetails.SKUPrice, string.Empty); ddlPosNo.SelectedValue = ValidationHelper.GetString(skuDetails.SKUNumber, string.Empty); txtShortDes.Text = skuDetails.SKUName; txtActualPrice.Text = ValidationHelper.GetString(skuDetails.SKUPrice, string.Empty); ddlStatus.SelectedValue = skuDetails.SKUEnabled == true ? "1" : "0"; imgProduct.ImageUrl = ValidationHelper.GetString(skuDetails.SKUImagePath, string.Empty); imgProduct.Visible = imgProduct.ImageUrl != string.Empty ? true : false; txtExpDate.Text = ValidationHelper.GetString(skuDetails.SKUValidUntil, string.Empty); txtQuantity.Text = ValidationHelper.GetString(skuDetails.SKUAvailableItems, string.Empty); txtWeight.Text = ValidationHelper.GetString(skuDetails.SKUWeight, string.Empty); CampaignsProduct product = CampaignsProductProvider.GetCampaignsProducts().WhereEquals("NodeSKUID", skuDetails.SKUID).FirstObject; if (product != null) { txtBundleQnt.Text = ValidationHelper.GetString(product.QtyPerPack, string.Empty); ddlBrand.SelectedValue = ValidationHelper.GetString(product.BrandID, string.Empty); ddlState.SelectedValue = ValidationHelper.GetString(product.State, string.Empty); ddlProdCategory.SelectedValue = ValidationHelper.GetString(product.CategoryID, string.Empty); BindEditProduct(ValidationHelper.GetInteger(product.CampaignsProductID, 0)); ViewState["ProductId"] = product.CampaignsProductID; } } else { ViewState["ProductId"] = null; EmptyFields(false); var pos = CustomTableItemProvider.GetItems(POSNumberItem.CLASS_NAME) .WhereEquals("POSNumber", selectedPos) .FirstOrDefault(); if (pos != null && pos.GetValue("BrandID") != null) { var brand = CustomTableItemProvider.GetItems(BrandItem.CLASS_NAME) .WhereEquals("BrandCode", pos.GetValue("BrandID")) .FirstOrDefault(); if (brand != null) { ddlBrand.SelectedValue = brand.GetValue("ItemId").ToString(); } } } ddlPosNo.SelectedValue = selectedPos; } catch (Exception ex) { EventLogProvider.LogException("CMSWebParts_Kadena_Inventory_porduct_POSchanged", "BindCategories", ex, CurrentSite.SiteID, ex.Message); } }
private void BindItemSpecsList(ISheet sheet) { string[] itemSpecsList = CustomTableItemProvider.GetItems <ProductItemSpecsItem>().ToList().Select(x => x.ItemSpec).ToArray(); if (itemSpecsList != null && itemSpecsList.Count() > 0) { AddOneFromManyValidation(16, "ItemSpecsList", itemSpecsList, sheet); } }
private void BindStatesGroupList(ISheet sheet) { string[] statesGroupList = CustomTableItemProvider.GetItems <StatesGroupItem>().ToList().Select(x => x.GroupName).ToArray(); if (statesGroupList != null && statesGroupList.Count() > 0) { AddOneFromManyValidation(5, "StatesGroupList", statesGroupList, sheet); } }
private void BindBrandList(ISheet sheet) { string[] brandList = CustomTableItemProvider.GetItems <BrandItem>().ToList().Select(x => x.BrandName).ToArray(); if (brandList != null && brandList.Count() > 0) { AddOneFromManyValidation(8, "BrandList", brandList, sheet); } }
private CustomTableItem GetFavoriteRecord(int siteId, int userId, int productDocumentId) { return(CustomTableItemProvider.GetItems(CustomTableName) .WhereEquals("ItemSiteID", siteId) .WhereEquals("ItemUserID", userId) .WhereEquals("ItemDocumentID", productDocumentId) .FirstObject); }
public Submission GetSubmission(Guid submissionId) { var submission = CustomTableItemProvider.GetItems(SubmissionsTable) .WhereEquals("SubmissionId", submissionId) .SingleOrDefault(); return(mapper.Map <Submission>(submission)); }
private void BindPOSList(ISheet sheet) { string[] posList = CustomTableItemProvider.GetItems <POSNumberItem>().ToList().Select(x => x.POSNumber.ToString()).ToArray(); if (posList != null && posList.Count() > 0) { AddOneFromManyValidation(2, "POSList", posList, sheet); } }
public List <BusinessUnit> GetBusinessUnits() { ObjectQuery <CustomTableItem> businessUnits = CustomTableItemProvider.GetItems(BusinessUnitsCustomTableName) .WhereEquals("SiteID", SiteContext.CurrentSiteID) .And() .WhereTrue("Status"); return(businessUnits.Select(x => CreateBusinessUnit(x)).ToList()); }
public List <int> CheckFavoriteProductIds(List <int> productIds) { var favorites = CustomTableItemProvider.GetItems(CustomTableName) .WhereEquals("ItemSiteID", SiteContext.CurrentSiteID) .WhereEquals("ItemUserID", MembershipContext.AuthenticatedUser.UserID) .WhereIn("ItemDocumentID", productIds); return(favorites.Select(f => Convert.ToInt32(f["ItemDocumentID"])).ToList()); }
/// <summary> /// GetDocumentResource /// </summary> /// <param name="ui"></param> /// <param name="className"></param> /// <param name="treeProvider"></param> /// <param name="whereClause"></param> /// <param name="orderby"></param> /// <param name="whereTextClause"></param> /// <param name="lookupDataSet"></param> /// <param name="pResourceType"></param> /// <returns>List</returns> protected List<Resource> GetDocumentResource(UserInfo ui, string className, TreeProvider treeProvider, string whereClause, string orderby, string whereTextClause, DataSet lookupDataSet, ResourceTypes pResourceType = ResourceTypes.All) { int lookupval = GetDocTypeValueFromTileMap(className, ui); CustomTableItemProvider tp = new CustomTableItemProvider((UserInfo)Session["KenticoUserInfo"]); string filtercriteria = "LookupValue = " + lookupval + " and (ISNULL(StateLEA,'')='' or StateLEA = '" + DistrictParms.LoadDistrictParms().ClientID + "' or StateLEA = '" + DistrictParms.LoadDistrictParms().State + "')"; DataSet resourcesToShow = tp.GetItems("thinkgate.TileMap_Lookup", filtercriteria, string.Empty); List<Resource> lstResource = new List<Resource>(); foreach (DataRow dr in resourcesToShow.Tables[0].Select().OrderBy(p => p["ItemOrder"].ToString())) { if (isInstructionMaterial == true && dr["KenticoDocumentTypeToShow"].ToString().ToLower() == "thinkgate.competencylist") { continue; } string[] columnNames = { dr["DescriptionColumnName"].ToString(), dr["NameColumnName"].ToString(), dr["AttachmentColumnName"].ToString(), dr["FriendlyName"].ToString() }; List<Resource> resource = (from s in GetDocuments(ui, dr["KenticoDocumentTypeToShow"].ToString(), treeProvider, whereClause, string.Empty, columnNames, whereTextClause, lookupDataSet, pResourceType) select new Resource { Source = s.NodeAliasPath.IndexOf(_districts.ToString(), StringComparison.Ordinal) >= 0 ? District : s.NodeAliasPath.IndexOf(_stateDocuments.ToString(), StringComparison.Ordinal) >= 0 ? State : s.NodeAliasPath.IndexOf(_sharedDocuments.ToString(), StringComparison.Ordinal) >= 0 ? SharedDocument //US15667 : MyDocuments, ID = s.ID, DocumentType = s.DocumentType, ID_Encrypted = "", NodeAliasPath = s.NodeAliasPath, ResourceName = s.ResourceName, Description = s.Description, Type = s.Type, Subtype = s.Subtype, ViewLink = s.ViewLink, DocumentForeignKeyValue = s.DocumentForeignKeyValue, DocumentNodeID = Convert.ToInt32(s.DocumentNodeID), ExpirationDate = s.ExpirationDate, AverageRating = s.AverageRating }).ToList<Resource>(); if (resource.Count == 0) { resource = new List<Resource>(); } lstResource.AddRange(resource); } return lstResource; }
/// <summary> /// GetDocTypeValueFromTileMap /// </summary> /// <param name="resourceToShow"></param> /// <returns>int</returns> private int GetDocTypeValueFromTileMap(string resourceToShow, UserInfo ui) { CustomTableItemProvider tp = new CustomTableItemProvider(ui); DataSet lookupDataSet = tp.GetItems("thinkgate.TileMap", "BaseTileType = '" + resourceToShow + "' ", string.Empty); int lookupval = 0; if (lookupDataSet.Tables[0].Rows.Count > 0) { lookupval = (int)lookupDataSet.Tables[0].Rows[0]["Value"]; } return lookupval; }
void btnGUID_Click(object sender, EventArgs e) { try { // Create GUID field FormFieldInfo ffiGuid = new FormFieldInfo(); // Fill FormInfo object ffiGuid.Name = "ItemGUID"; ffiGuid.Caption = "GUID"; ffiGuid.DataType = FormFieldDataTypeEnum.GUID; ffiGuid.DefaultValue = ""; ffiGuid.Description = ""; ffiGuid.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffiGuid.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLower(); ffiGuid.PrimaryKey = false; ffiGuid.System = true; ffiGuid.Visible = false; ffiGuid.Size = 0; ffiGuid.AllowEmpty = false; FormInfo.AddFormField(ffiGuid); // Update table structure - columns could be added bool old = TableManager.UpdateSystemFields; TableManager.UpdateSystemFields = true; string schema = FormInfo.GetXmlDefinition(); TableManager.UpdateTableBySchema(dci.ClassTableName, schema); TableManager.UpdateSystemFields = old; // Update xml schema and form definition dci.ClassFormDefinition = schema; dci.ClassXmlSchema = TableManager.GetXmlSchema(dci.ClassTableName); dci.Generalized.LogEvents = false; // Save the data DataClassInfoProvider.SetDataClass(dci); dci.Generalized.LogEvents = true; // Generate default queries SqlGenerator.GenerateDefaultQueries(dci, true, false); // Clear cached data CMSObjectHelper.RemoveReadOnlyObjects(CustomTableItemProvider.GetObjectType(className), true); CustomTableItemProvider.Remove(className, true); // Clear the object type hashtable ProviderStringDictionary.ReloadDictionaries(className, true); // Clear the classes hashtable ProviderStringDictionary.ReloadDictionaries("cms.class", true); // Clear class strucures ClassStructureInfo.Remove(className, true); // Ensure GUIDs for all items CustomTableItemProvider tableProvider = new CustomTableItemProvider(); tableProvider.UpdateSystemFields = false; tableProvider.LogSynchronization = false; DataSet dsItems = tableProvider.GetItems(className, null, null); if (!DataHelper.DataSourceIsEmpty(dsItems)) { foreach (DataRow dr in dsItems.Tables[0].Rows) { CustomTableItem item = new CustomTableItem(dr, className, tableProvider); item.ItemGUID = Guid.NewGuid(); item.Update(); } } // Log event UserInfo currentUser = CMSContext.CurrentUser; EventLog.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, "Custom table", "GENERATEGUID", currentUser.UserID, currentUser.UserName, 0, null, null, string.Format(ResHelper.GetAPIString("customtable.GUIDGenerated", "Field 'ItemGUID' for custom table '{0}' was created and GUID values were generated."), dci.ClassName), 0, null); URLHelper.Redirect(URLHelper.AddParameterToUrl(URLRewriter.CurrentURL, "gen", "1")); } catch (Exception ex) { lblError.Visible = true; lblError.Text = GetString("customtable.ErrorGUID") + ex.Message; // Log event EventLog.LogEvent("Custom table", "GENERATEGUID", ex); } }
/// <summary> /// Gets and bulk updates custom table items. Called when the "Get and bulk update items" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool GetAndBulkUpdateCustomTableItems() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text%'"; // Get the data DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loop through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Create object from DataRow CustomTableItem modifyCustomTableItem = CustomTableItem.New(customTableItemDr, customTableClassName); string itemText = ValidationHelper.GetString(modifyCustomTableItem.GetValue("ItemText"), ""); // Set new values modifyCustomTableItem.SetValue("ItemText", itemText.ToUpper()); // Save the changes modifyCustomTableItem.Update(); } return true; } } return false; }
/// <summary> /// Gets the custom table item and moves it up. Called when the "Get and move item up" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool GetAndMoveCustomTableItemUp() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text'"; int topN = 1; string columns = "ItemID"; // Get the data set according to the parameters DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns); if (!DataHelper.DataSourceIsEmpty(dataSet)) { // Get the custom table item ID int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0); // Move the item up customTableProvider.MoveItemUp(itemID, customTableClassName); return true; } } return false; }
/// <summary> /// Gets and updates custom table item. Called when the "Get and update item" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool GetAndUpdateCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text'"; int topN = 1; string columns = "ItemID"; // Get the data set according to the parameters DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns); if (!DataHelper.DataSourceIsEmpty(dataSet)) { // Get the custom table item ID int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0); // Get the custom table item CustomTableItem updateCustomTableItem = customTableProvider.GetItem(itemID, customTableClassName); if (updateCustomTableItem != null) { string itemText = ValidationHelper.GetString(updateCustomTableItem.GetValue("ItemText"), ""); // Set new values updateCustomTableItem.SetValue("ItemText", itemText.ToLowerCSafe()); // Save the changes updateCustomTableItem.Update(); return true; } } } return false; }
/// <summary> /// Deletes customTableItem. Called when the "Delete item" button is pressed. /// Expects the CreateCustomTableItem method to be run first. /// </summary> private bool DeleteCustomTableItem() { // Create new Custom table item provider CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser); string customTableClassName = "customtable.sampletable"; // Check if Custom table 'Sample table' exists DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName); if (customTable != null) { // Prepare the parameters string where = "ItemText LIKE N'New text%'"; // Get the data DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null); if (!DataHelper.DataSourceIsEmpty(customTableItems)) { // Loop through the individual items foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows) { // Create object from DataRow CustomTableItem deleteCustomTableItem = CustomTableItem.New(customTableItemDr, customTableClassName); // Delete custom table item from database deleteCustomTableItem.Delete(); } return true; } } return false; }