コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Title.TitleText = GetString("customtable.data.viewitemtitle");
        Page.Title = CurrentMaster.Title.TitleText;

        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_CustomTables/viewitem.png");

        // Get custom table id from url
        int customTableId = QueryHelper.GetInteger("customtableid", 0);
        // Get custom table item id
        int itemId = QueryHelper.GetInteger("itemid", 0);

        DataClassInfo dci = DataClassInfoProvider.GetDataClass(customTableId);

        // Set edited object
        EditedObject = dci;

        if (dci != null)
        {
            // Check 'Read' permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") &&
                !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read"))
            {
                RedirectToAccessDenied("cms.customtables", "Read");
            }

            CustomTableItemProvider ctProvider = new CustomTableItemProvider(CMSContext.CurrentUser);
            CustomTableItem         item       = ctProvider.GetItem(itemId, dci.ClassName);
            customTableViewItem.CustomTableItem = item;
        }
    }
コード例 #2
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "add")
        {
            // Add itemId in customtable_shippingextension.shippingoptionid

            // Creates new Custom table item provider
            CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

            // Prepares the parameters
            string customTableClassName = "customtable.shippingextension";

            // Checks if Custom table exists
            DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
            if (customTable != null)
            {
                // Creates new custom table item
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

                // Sets the ItemText field value
                newCustomTableItem.SetValue("ShippingOptionId", actionArgument.ToString());
                newCustomTableItem.SetValue("LocalContact", string.Empty);
                newCustomTableItem.SetValue("Enabled", true);
                newCustomTableItem.SetValue("ProcessingMode", 0);

                // Inserts the custom table item into database
                newCustomTableItem.Insert();
            }
            //Response.Redirect("ShippingExtension_List.aspx");
            Response.Redirect(Request.Url.ToString());
        }
    }
コード例 #3
0
    /// <summary>
    /// Creates custom table item. Called when the "Create item" button is pressed.
    /// </summary>
    private bool CreateCustomTableItem()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        // Prepare the parameters
        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Create new custom table item
            CustomTableItem newCustomTableItem = new CustomTableItem(customTableClassName, customTableProvider);

            // Set the ItemText field value
            newCustomTableItem.SetValue("ItemText", "New text");

            // Insert the custom table item into database
            newCustomTableItem.Insert();

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Checks create or modify permission.
    /// </summary>
    private void CheckPermissions()
    {
        CustomTableItem ctItem = form.EditedObject;

        // If editing item
        if (ctItem.ItemID > 0)
        {
            // Check 'Modify' permission
            if (!ctItem.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                // Show error message
                form.MessagesPlaceHolder.ClearLabels();
                form.ShowError(String.Format(GetString("customtable.permissiondenied.modify"), ctItem.ClassName));
                form.StopProcessing = true;
            }
        }
        else
        {
            // Check 'Create' permission
            if (!ctItem.CheckPermissions(PermissionsEnum.Create, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                // Show error message
                form.MessagesPlaceHolder.ClearLabels();
                form.ShowError(String.Format(GetString("customtable.permissiondenied.create"), ctItem.ClassName));
                form.StopProcessing = true;
            }
        }
    }
コード例 #5
0
    /// <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);
    }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: KuduApps/Kentico
    /// <summary>
    /// Creates custom table item. Called when the "Create item" button is pressed.
    /// </summary>
    private bool CreateCustomTableItem()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        // Prepare the parameters
        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
        if (customTable != null)
        {
            // Create new custom table item
            CustomTableItem newCustomTableItem = new CustomTableItem(customTableClassName, customTableProvider);

            // Set the ItemText field value
            newCustomTableItem.SetValue("ItemText", "New text");

            // Insert the custom table item into database
            newCustomTableItem.Insert();

            return true;
        }

        return false;
    }
コード例 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle.TitleText = GetString("customtable.data.viewitemtitle");
        Page.Title          = PageTitle.TitleText;
        // Get custom table id from url
        int customTableId = QueryHelper.GetInteger("customtableid", 0);
        // Get custom table item id
        int itemId = QueryHelper.GetInteger("itemid", 0);

        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(customTableId);

        // Set edited object
        EditedObject = dci;

        if (dci != null)
        {
            // Check 'Read' permission
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.customtables", "Read") &&
                !MembershipContext.AuthenticatedUser.IsAuthorizedPerClassName(dci.ClassName, "Read"))
            {
                RedirectToAccessDenied("cms.customtables", "Read");
            }

            CustomTableItem item = CustomTableItemProvider.GetItem(itemId, dci.ClassName);
            customTableViewItem.CustomTableItem = item;
        }
    }
コード例 #8
0
    private bool CreateCustomTableItem(string Desc, int Qty)
    {
        // Creates new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

        // Prepares the parameters
        string customTableClassName = "customtable.customBundle";

        // Checks if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Creates new custom table item
            CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

            // Sets the ItemText field value
            newCustomTableItem.SetValue("Quantity", Qty);
            newCustomTableItem.SetValue("Description", Desc);
            newCustomTableItem.SetValue("Enabled", true);
            // Inserts the custom table item into database
            newCustomTableItem.Insert();

            return(true);
        }

        return(false);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSMasterPage currentMaster = Page.Master as CMSMasterPage;

        if (FullscreenMode)
        {
            txtCode.TopOffset = 40;
        }

        // Check master page
        if (currentMaster == null)
        {
            throw new Exception("Page using this control must have CMSMasterPage master page.");
        }

        LabelsInit();

        txtCode.Editor.Width    = new Unit("99%");
        txtCode.Editor.Height   = new Unit("300px");
        txtCode.NamespaceUsings = new List <string> {
            "Transformation"
        };

        // transformation.{classid}.{isascx}
        string resolverName = "transformation." + ClassID + "." + IsAscx;

        txtCode.ResolverName   = resolverName;
        tbWysiwyg.ResolverName = resolverName;

        if (IsAscx)
        {
            DataClassInfo resolverClassInfo = DataClassInfoProvider.GetDataClassInfo(ClassID);
            if (resolverClassInfo != null)
            {
                if (resolverClassInfo.ClassIsCustomTable)
                {
                    txtCode.ASCXRootObject = CustomTableItem.New(resolverClassInfo.ClassName);
                }
                else if (resolverClassInfo.ClassIsDocumentType)
                {
                    txtCode.ASCXRootObject = TreeNode.New(resolverClassInfo.ClassName);
                }
                else
                {
                    txtCode.ASCXRootObject = ModuleManager.GetReadOnlyObjectByClassName(resolverClassInfo.ClassName);
                }
            }

            if (!RequestHelper.IsPostBack() && IsChecked)
            {
                ShowMessage();
            }
        }

        // Hide/Display CSS section
        plcCssLink.Visible = String.IsNullOrEmpty(txtCSS.Text.Trim());

        SetEditor();
    }
コード例 #10
0
        public void DeleteBrand(int brandID)
        {
            CustomTableItem brand = CustomTableItemProvider.GetItem(brandID, CustomTableName);

            if (brand != null)
            {
                brand.Delete();
            }
        }
コード例 #11
0
        public void AdjustUserRemainingBudget(string year, int userID, decimal adjustment)
        {
            CustomTableItem userBudgetDetails = CustomTableItemProvider.GetItems(CustomTableClassName).WhereEquals("UserID", userID).WhereEquals("Year", year).FirstOrDefault();

            if (userBudgetDetails != null)
            {
                userBudgetDetails.SetValue("UserRemainingBudget", userBudgetDetails.GetValue("UserRemainingBudget", default(decimal)) + (adjustment));
                userBudgetDetails.Update();
            }
        }
        public static TItemType ToCustomTableItem <TItemType>(IDocument doc, string className)
            where TItemType : CustomTableItem, new()
        {
            var item = CustomTableItem.New <TItemType>(className, dataRow: null);

            foreach (var prop in item.Properties)
            {
                item.SetValue(prop, doc.Get(prop));
            }

            return(item);
        }
コード例 #13
0
    public void LoadCommunitiesfromDataservice()
    {
        try
        {
            string del = "delete  Sme_CommiteesMaster";
            execute(del);
            //string customerClassCode = CustomerData.CustomerClassCode.Value;
            Uri ServiceUri = new Uri("http://smemi.personifycloud.com/PersonifyDataServices/PersonifyDatasme.svc");
            personifyDataservicesme.PersonifyEntitiesSME DataAccessLayer =
                new personifyDataservicesme.PersonifyEntitiesSME(ServiceUri);
            DataAccessLayer.Credentials = new NetworkCredential("admin", "admin");

            var CommuniteeList = DataAccessLayer.CustomerInfos.Where(p => p.RecordType == "T").Select(o => o).ToList();
            CommuniteeList = CommuniteeList.Where(p => p.CustomerStatusCode == "ACTIVE").Select(o => o).ToList();


            string MasterCustomerId  = string.Empty;
            string LabelName         = string.Empty;
            string CustomerClassCode = string.Empty;
            string CurrencyCode      = string.Empty;
            string SubCustomerId     = string.Empty;
//
            //var CommuniteeList = DataAccessLayer.CustomerInfos.Where(p => p.RecordType == "T").Select(o => o).ToList();
            //CommuniteeList = CommuniteeList.Where(p => p.CustomerStatusCode  == "ACTIVE").Select(o => o).ToList();

            if (CommuniteeList != null)
            {
                foreach (var community in CommuniteeList)
                {
                    MasterCustomerId  = community.MasterCustomerId;
                    LabelName         = community.LabelName;
                    CustomerClassCode = community.CustomerClassCode;
                    CurrencyCode      = community.CurrencyCode;
                    SubCustomerId     = community.SubCustomerId.ToString();

                    // Create new item for custom table with "Sme.CommiteesMaster" code name
                    var item = CustomTableItem.New("Sme.CommiteesMaster");
                    item.SetValue("MasterCustomerId", MasterCustomerId);
                    item.SetValue("LabelName", LabelName);
                    item.SetValue("CustomerClassCode", CustomerClassCode);
                    item.SetValue("CurrencyCode", CurrencyCode);
                    item.SetValue("SubCustomerId", SubCustomerId);
                    item.Insert();

                    Response.Write("Added Committee : " + LabelName + " in the commitee group : " + CustomerClassCode + "<br/>");
                }
            }
        }
        catch (Exception Ex)
        {
            Response.Write(Ex.ToString());
        }
    }
コード例 #14
0
        public void InsertCampaignOrdersInProgress(int campaignID)
        {
            DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

            if (customTable != null)
            {
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
                newCustomTableItem.SetValue("CampaignID", campaignID);
                newCustomTableItem.SetValue("IsCampaignOrdersInProgress", true);
                newCustomTableItem.SetValue("IsCampaignOrdersFailed", false);
                newCustomTableItem.Insert();
            }
        }
コード例 #15
0
    protected void gridData_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        // Delete item action
        case "delete":
            if (CheckPermissions(PermissionsEnum.Delete))
            {
                if (CustomTableClassInfo != null)
                {
                    CustomTableItem item = CustomTableItemProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                    if (item != null)
                    {
                        item.Delete();
                    }
                }

                URLHelper.RefreshCurrentPage();
            }
            break;

        // Move item up action
        case "moveup":
            if (CheckPermissions(PermissionsEnum.Modify))
            {
                if (CustomTableClassInfo != null)
                {
                    var item = CustomTableItemProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                    item.Generalized.MoveObjectUp();
                }

                URLHelper.RefreshCurrentPage();
            }
            break;

        // Move item down action
        case "movedown":
            if (CheckPermissions(PermissionsEnum.Modify))
            {
                if (CustomTableClassInfo != null)
                {
                    var item = CustomTableItemProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                    item.Generalized.MoveObjectDown();
                }

                URLHelper.RefreshCurrentPage();
            }
            break;
        }
    }
コード例 #16
0
    private bool DeleteCustomTableItem(DataClassInfo customTable)
    {
        try
        {
            if (customTable != null)
            {
                // Prepares the parameters

                string where = "";



                // Gets the data

                DataSet customTableItems = _customTableProvider.GetItems(customTable.ClassName, where, null);

                if (!DataHelper.DataSourceIsEmpty(customTableItems))
                {
                    // Loops through the individual items

                    foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows)
                    {
                        // Creates object from DataRow

                        CustomTableItem deleteCustomTableItem = CustomTableItem.New(customTableItemDr, customTable.ClassName);



                        // Deletes custom table item from database
                        if (RadioButtonAll.Checked)
                        {
                            deleteCustomTableItem.Delete();
                        }
                    }


                    EventLogProvider.LogInformation("CustomTable", "Import delete", "Delete sucess");
                    return(true);
                }
            }
        }
        catch (Exception e)
        {
            EventLogProvider.LogInformation("CustomTable", "Import delete error", e.Message);
        }


        return(false);
    }
コード例 #17
0
    public void LoadCommunitiesfromDataservice()
    {
        try
        {
            string del = "delete dbo.Sme_Membershiplist";
            execute(del);
            //string customerClassCode = CustomerData.CustomerClassCode.Value;
            Uri ServiceUri = new Uri(SUri);
            PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
            DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);
            string ProductId           = string.Empty;
            string ProductCode         = string.Empty;
            string OrganizationUnitId  = string.Empty;
            string ShortName           = string.Empty;
            string WebLongDescription  = string.Empty;
            string WebShortDescription = string.Empty;

            var CommuniteeList = DataAccessLayer.WebMembershipJoinProducts.ToList();//DataAccessLayer.CustomerInfos.Where(p => p.RecordType == "T").Select(o => o).ToList();

            if (CommuniteeList != null)
            {
                foreach (var community in CommuniteeList)
                {
                    ProductId           = community.ProductId.ToString();
                    ProductCode         = community.ProductCode;
                    OrganizationUnitId  = community.OrganizationUnitId;
                    ShortName           = community.ShortName;
                    WebLongDescription  = community.WebLongDescription.ToString();
                    WebShortDescription = community.WebShortDescription.ToString();
                    // Create new item for custom table with "Sme.CommiteesMaster" code name
                    var item = CustomTableItem.New("Sme.Membershiplist");
                    item.SetValue("ProductId", ProductId);
                    item.SetValue("ProductCode", ProductCode);
                    item.SetValue("OrganizationUnitId", OrganizationUnitId);
                    item.SetValue("ShortName", ShortName);
                    item.SetValue("WebLongDescription", WebLongDescription);
                    item.SetValue("WebShortDescription", WebShortDescription);
                    item.Insert();

                    Response.Write(" Committee : " + ProductCode + " in the commitee group : " + ShortName + " Product Id : " + ProductId + "<br/>");
                }
            }
        }
        catch (Exception Ex)
        {
            Response.Write(Ex.ToString());
        }
    }
コード例 #18
0
    protected void gridData_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        // Delete item action
        case "delete":
            if (CheckPermissions("Delete"))
            {
                if (CustomTableClassInfo != null)
                {
                    CustomTableItem item = ctProvider.GetItem(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                    if (item != null)
                    {
                        item.Delete();
                    }
                }

                URLHelper.Redirect(URLHelper.Url.ToString());
            }
            break;

        // Move item up action
        case "moveup":
            if (CheckPermissions("Modify"))
            {
                if (CustomTableClassInfo != null)
                {
                    ctProvider.MoveItemUp(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                }

                URLHelper.Redirect(URLHelper.Url.ToString());
            }
            break;

        // Move item down action
        case "movedown":
            if (CheckPermissions("Modify"))
            {
                if (CustomTableClassInfo != null)
                {
                    ctProvider.MoveItemDown(ValidationHelper.GetInteger(actionArgument, 0), CustomTableClassInfo.ClassName);
                }

                URLHelper.Redirect(URLHelper.Url.ToString());
            }
            break;
        }
    }
コード例 #19
0
        public string GetDistributorBusinessUnit(int distributorID)
        {
            string businessUnit = string.Empty;

            if (distributorID > 0)
            {
                AddressInfo address = AddressInfoProvider.GetAddressInfo(distributorID);
                if (address != null)
                {
                    long            businessUnitNumber = ValidationHelper.GetLong(address.GetValue("BusinessUnit"), default(long));
                    CustomTableItem businessUnitItem   = CustomTableItemProvider.GetItems(BusinessUnitsCustomTableName, "BusinessUnitNumber=" + businessUnitNumber).FirstOrDefault();
                    businessUnit = businessUnitItem != null?businessUnitItem.GetStringValue("BusinessUnitName", string.Empty) : string.Empty;
                }
            }
            return(businessUnit);
        }
コード例 #20
0
 private Brand CreateBrand(CustomTableItem brandItem)
 {
     if (brandItem == null)
     {
         return(null);
     }
     else
     {
         return(new Brand()
         {
             ItemID = brandItem.ItemID,
             BrandName = brandItem.GetStringValue("BrandName", string.Empty),
             BrandCode = brandItem.GetIntegerValue("BrandCode", default(int))
         });
     }
 }
コード例 #21
0
        public bool DeletePOS(int posID)
        {
            bool            isDeleted = false;
            CustomTableItem posItem   = CustomTableItemProvider.GetItem(posID, CustomTableName);

            if (posItem != null)
            {
                var isProductsExist = SKUInfoProvider.GetSKUs().WhereEquals("SKUProductCustomerReferenceNumber", posItem.GetStringValue("POSNumber", string.Empty)).Any();
                if (!isProductsExist)
                {
                    posItem.Delete();
                    isDeleted = true;
                }
            }
            return(isDeleted);
        }
コード例 #22
0
        public void InsertIBTFAdjustmentRecord(IBTFAdjustment inboundAdjustment)
        {
            DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(IBTFAdjustmentCustomTableName);

            if (customTable != null)
            {
                CustomTableItem newCustomTableItem = CustomTableItem.New(IBTFAdjustmentCustomTableName);
                newCustomTableItem.SetValue("SKUID", inboundAdjustment.SKUID);
                newCustomTableItem.SetValue("UserID", inboundAdjustment.UserID);
                newCustomTableItem.SetValue("CampaignID", inboundAdjustment.CampaignID);
                newCustomTableItem.SetValue("OrderedQuantity", inboundAdjustment.OrderedQuantity);
                newCustomTableItem.SetValue("OrderedProductPrice", inboundAdjustment.OrderedProductPrice);
                newCustomTableItem.SetValue("SiteName", SiteContext.CurrentSiteName);
                newCustomTableItem.Insert();
            }
        }
コード例 #23
0
        protected void ProcessCategory(int productNodeId, string categoryPath)
        {
            if (!string.IsNullOrEmpty(categoryPath))
            {
                var categoryItem = FindProductCategory(categoryPath);
                if (categoryItem != null)
                {
                    RelationshipInfoProvider.AddRelationship(productNodeId, categoryItem.NodeID,
                                                             productCategoryProductRelationshipID);
                }
                // if product detail or product category are null log error and add to error tracker (add error tracking custom table)fields, product detail name, product category name and explanation of what's wrong
                else
                {
                    // Prepares the code name (class name) of the custom table to which the data record will be added
                    string customTableClassName = "PbcLinear.ProcessCategoryErrors";

                    // Gets the custom table
                    DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
                    if (customTable != null)
                    {
                        // Creates a new custom table item
                        CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);

                        // Sets the values for the fields of the custom table (ItemText in this case)
                        newCustomTableItem.SetValue("ProductNodeId", productNodeId);
                        newCustomTableItem.SetValue("CategoryPath", categoryPath);
                        newCustomTableItem.SetValue("Error", "categoryItem is null ");

                        if (productNodeId == 0)
                        {
                            var newError = newCustomTableItem.GetValue("Error") + " productNodeId is empty";
                            newCustomTableItem.SetValue("Error", newError);
                        }

                        if (!string.IsNullOrEmpty(categoryPath))
                        {
                            var newError = newCustomTableItem.GetValue("Error") + " categoryPath is empty";
                            newCustomTableItem.SetValue("Error", newError);
                        }

                        // Save the new custom table record into the database
                        newCustomTableItem.Insert();
                    }
                }
            }
        }
コード例 #24
0
    /// <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);
    }
コード例 #25
0
 private BusinessUnit CreateBusinessUnit(CustomTableItem businessUnitItem)
 {
     if (businessUnitItem == null)
     {
         return(null);
     }
     else
     {
         return(new BusinessUnit()
         {
             ItemID = businessUnitItem.ItemID,
             SiteID = businessUnitItem.GetIntegerValue("SiteID", 0),
             BusinessUnitName = businessUnitItem.GetStringValue("BusinessUnitName", string.Empty),
             BusinessUnitNumber = businessUnitItem.GetIntegerValue("BusinessUnitNumber", 0),
             Status = businessUnitItem.GetBooleanValue("Status", false)
         });
     }
 }
コード例 #26
0
    private static bool IsTermInRestrictedList(String term)
    {
        string customTableClassName = "smenet.ignoresearchterms";

        DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

        if (customTable != null)
        {
            CustomTableItem item = CustomTableItemProvider.GetItems(customTableClassName).WhereEquals("LOWER(SearchTerm)", term.ToLower()).FirstObject;

            if (item != null)
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #27
0
        private List <string> getColumnNames(CustomTableItem row)
        {
            List <string> colList = new List <string>();

            foreach (string column in row.ColumnNames)
            {
                if (column.StartsWith("Item"))
                {
                    continue;
                }
                else
                {
                    colList.Add(column);
                }
            }

            return(colList);
        }
コード例 #28
0
        public void SetFavoriteProduct(int productDocumentId)
        {
            var existingRecord = GetFavoriteRecord(SiteContext.CurrentSiteID, MembershipContext.AuthenticatedUser.UserID, productDocumentId);

            if (existingRecord != null)
            {
                existingRecord.Update();
            }
            else
            {
                var newItem = CustomTableItem.New(CustomTableName);
                newItem.SetValue("ItemSiteID", SiteContext.CurrentSiteID);
                newItem.SetValue("ItemUserID", MembershipContext.AuthenticatedUser.UserID);
                newItem.SetValue("ItemDocumentID", productDocumentId);
                newItem.SetValue("ItemOrder", 1);
                newItem.Insert();
            }
        }
コード例 #29
0
        /// <summary>
        /// This method will save the allocated product w.r.t to User in custome tabel
        /// </summary>
        /// <param name="productID">The id of the product which user wants to Allocate</param>
        private void AllocateProductToUsers(int productID)
        {
            string        customTableClassName = "KDA.UserAllocatedProducts";
            DataClassInfo customTable          = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

            if (customTable != null)
            {
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
                foreach (AllocateProduct User in lstUsers)
                {
                    newCustomTableItem.SetValue("UserID", User.UserID);
                    newCustomTableItem.SetValue("ProductID", productID);
                    newCustomTableItem.SetValue("Quantity", User.Quantity);
                    newCustomTableItem.SetValue("EmailID", User.EmailID);
                    newCustomTableItem.Insert();
                }
            }
        }
コード例 #30
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "add")
        {
            CountryInfo country = CountryInfoProvider.GetCountryInfo(Convert.ToInt32(actionArgument));
            // Check if country can be added in the ShippingExtension
            if (CheckCountry(Convert.ToInt32(actionArgument)))
            {
                // Add itemId in customtable_shippingextension.shippingoptionid
                // Creates new Custom table item provider
                CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

                // Prepares the parameters
                string customTableClassName = "customtable.shippingextensioncountry";

                // Checks if Custom table exists
                DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
                if (customTable != null)
                {
                    // Creates new custom table item
                    CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

                    // Sets the ItemText field value
                    newCustomTableItem.SetValue("ShippingOptionId", shippingExtensionID.ToString());
                    newCustomTableItem.SetValue("ShippingCountryId", actionArgument.ToString());
                    newCustomTableItem.SetValue("ShippingBase", 0);
                    newCustomTableItem.SetValue("LocalContact", string.Empty);
                    newCustomTableItem.SetValue("Enabled", true);
                    newCustomTableItem.SetValue("ProcessingMode", 1);
                    newCustomTableItem.SetValue("UnitPrice", 0);
                    // Inserts the custom table item into database
                    newCustomTableItem.Insert();
                }
                //Response.Redirect(Request.Url.ToString());
                ShowInformation(string.Format("<b>{0}</b> added for <b>{1}</b>", country.CountryName, GetShippingOptionName(shippingExtensionID.ToString())));
            }
            else
            {
                ShowError(string.Format("<b>{0}</b> is already defined for <b>{1}</b>", country.CountryName, GetShippingOptionName(shippingExtensionID.ToString())));
            }
        }
    }
コード例 #31
0
 /// <summary>
 /// Update the Product allocation
 /// </summary>
 /// <param name="productID">The id of the product which user wants to Update</param>
 private void UpdateAllocateProduct(int productID)
 {
     try
     {
         string        customTableClassName = "KDA.UserAllocatedProducts";
         DataClassInfo customTable          = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
         if (customTable != null)
         {
             var customTableData = CustomTableItemProvider.GetItems(customTableClassName)
                                   .WhereStartsWith("ProductID", productID.ToString());
             foreach (CustomTableItem customitem in customTableData)
             {
                 int index = lstUsers.FindIndex(item => item.UserID == ValidationHelper.GetInteger(customitem.GetValue("UserID"), 0));
                 if (index > -1)
                 {
                     customitem.SetValue("Quantity", lstUsers[index].Quantity);
                     customitem.Update();
                     lstUsers.RemoveAt(index);
                 }
                 else
                 {
                     customitem.Delete();
                     lstUsers.RemoveAt(index);
                 }
             }
         }
         CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
         foreach (AllocateProduct User in lstUsers)
         {
             newCustomTableItem.SetValue("UserID", User.UserID);
             newCustomTableItem.SetValue("ProductID", productID);
             newCustomTableItem.SetValue("Quantity", User.Quantity);
             newCustomTableItem.SetValue("EmailID", User.EmailID);
             newCustomTableItem.Insert();
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Product allocation update", "EXCEPTION", ex);
     }
 }
コード例 #32
0
ファイル: Default.aspx.cs プロジェクト: KuduApps/Kentico
    /// <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 = new CustomTableItem(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;
    }
コード例 #33
0
ファイル: Default.aspx.cs プロジェクト: KuduApps/Kentico
    /// <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 = new CustomTableItem(customTableItemDr, customTableClassName);

                    // Delete custom table item from database
                    deleteCustomTableItem.Delete();
                }

                return true;
            }
        }

        return false;
    }
コード例 #34
0
    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);
        }
    }