Пример #1
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());
        }
    }
Пример #2
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);
    }
Пример #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 = CustomTableItem.New(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);
    }
Пример #4
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);
    }
    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();
    }
        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);
        }
Пример #7
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());
        }
    }
Пример #8
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();
            }
        }
Пример #9
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);
    }
Пример #10
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());
        }
    }
Пример #11
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();
            }
        }
Пример #12
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();
                    }
                }
            }
        }
Пример #13
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();
                }
            }
        }
Пример #14
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();
            }
        }
    /// <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())));
            }
        }
    }
Пример #16
0
    /// <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);
    }
Пример #17
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);
     }
 }
        public void SaveSubmission(Submission submission)
        {
            if (submission == null || submission.SubmissionId == Guid.Empty)
            {
                return;
            }

            var originalSubmissionItem = CustomTableItemProvider.GetItems(SubmissionsTable)
                                         .WhereEquals("SubmissionId", submission.SubmissionId)
                                         .FirstOrDefault();

            var submissionItem = originalSubmissionItem;

            if (submissionItem == null)
            {
                submissionItem = CustomTableItem.New(SubmissionsTable);
                submissionItem.SetValue("SubmissionId", submission.SubmissionId);
            }

            submissionItem.SetValue("SiteId", submission.SiteId);
            submissionItem.SetValue("UserId", submission.UserId);
            submissionItem.SetValue("CustomerId", submission.CustomerId);
            submissionItem.SetValue("AlreadyVerified", submission.AlreadyVerified);
            submissionItem.SetValue("Processed", submission.Processed);
            submissionItem.SetValue("RedirectUrl", submission.RedirectUrl);
            submissionItem.SetValue("OrderJson", submission.OrderJson);

            if (originalSubmissionItem == null)
            {
                submissionItem.Insert();
            }
            else
            {
                submissionItem.Update();
            }
        }
Пример #19
0
        public UserBudgetItem CreateUserBudgetWithYear(string year, int siteID, int userId)
        {
            DataClassInfo   customTable        = DataClassInfoProvider.GetDataClassInfo(CustomTableClassName);
            CustomTableItem newCustomTableItem = CustomTableItem.New(CustomTableClassName);

            if (customTable != null)
            {
                newCustomTableItem.SetValue("UserID", userId);
                newCustomTableItem.SetValue("Year", year);
                newCustomTableItem.SetValue("Budget", default(decimal));
                newCustomTableItem.SetValue("UserRemainingBudget", default(decimal));
                newCustomTableItem.SetValue("SiteID", siteID);
                newCustomTableItem.Insert();
                return(new UserBudgetItem()
                {
                    ItemID = newCustomTableItem.ItemID,
                    Budget = newCustomTableItem.GetValue("Budget", default(decimal)),
                    UserID = userId,
                    UserRemainingBudget = newCustomTableItem.GetValue("UserRemainingBudget", default(decimal)),
                    Year = year
                });
            }
            return(null);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx";

        // Get form ID from url
        customTableId = QueryHelper.GetInteger("objectid", 0);

        // Running in site manager?
        bool siteManager = QueryHelper.GetInteger("sm", 0) == 1;

        DataClassInfo dci = null;

        // Read data only if user is site manager global admin or table is bound to current site
        if (CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) || (ClassSiteInfoProvider.GetClassSiteInfo(customTableId, SiteContext.CurrentSiteID) != null))
        {
            // Get CustomTable class
            dci = DataClassInfoProvider.GetDataClassInfo(customTableId);
        }

        // Set edited object
        EditedObject = dci;

        if ((dci != null) && dci.ClassIsCustomTable)
        {
            customTableDataList.CustomTableClassInfo         = dci;
            customTableDataList.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            customTableDataList.ViewItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            // Set alternative form and data container
            customTableDataList.UniGrid.FilterFormName = dci.ClassName + ".filter";
            customTableDataList.UniGrid.FilterFormData = CustomTableItem.New(dci.ClassName);

            // Set custom pages
            if (dci.ClassEditingPageURL != String.Empty)
            {
                customTableDataList.EditItemPage = dci.ClassEditingPageURL;
            }
            if (dci.ClassNewPageURL != String.Empty)
            {
                newItemPage = dci.ClassNewPageURL;
            }
            if (dci.ClassViewPageUrl != String.Empty)
            {
                customTableDataList.ViewItemPage = dci.ClassViewPageUrl;
            }

            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" +
                                                                                                                ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectFields.aspx") + "?customtableid=" + customTableId + "'  ,'CustomTableFields', 500, 500); }"));

            if (!siteManager)
            {
                PageTitle.TitleText = GetString("customtable.edit.header");
            }

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            // New item link
            bool canCreate = dci.CheckPermissions(PermissionsEnum.Create, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser);
            HeaderActions.AddAction(new HeaderAction
            {
                Text        = GetString("customtable.data.newitem"),
                RedirectUrl = ResolveUrl(newItemPage + "?new=1&objectid=" + customTableId + (siteManager ? "&sm=1" : "")),
                Enabled     = canCreate,
                Tooltip     = canCreate ? String.Empty : String.Format(GetString("customtable.permissiondenied.create"), dci.ClassName)
            });

            // Select fields link
            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("customtable.data.selectdisplayedfields"),
                OnClientClick = "SelectFields();",
                ButtonStyle   = ButtonStyle.Default,
            });

            if (!siteManager)
            {
                // Initializes page title
                PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
                {
                    Text        = GetString("customtable.list.title"),
                    RedirectUrl = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx"
                });
                PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
                {
                    Text = dci.ClassDisplayName
                });
            }
        }
        else
        {
            customTableDataList.StopProcessing = true;
            customTableDataList.Visible        = false;

            ShowError(GetString("customtable.notcustomtable"));
        }
    }
    /// <summary>
    /// Figure out using the Join Table which categories need to be removed and which added
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void SaveToJoinTable()
    {
        SetPossibleAndSelectedCategories();

        // Do check of min/max here
        if (MinimumCategories > 0 && SelectedCategories.Count() < MinimumCategories)
        {
            AddError("Must select at least " + MinimumCategories + " " + (MinimumCategories == 1 ? "category" : "categories"));
            return;
        }
        if (MaximumCategories > 0 && SelectedCategories.Count() > MaximumCategories)
        {
            AddError("Can select no more than " + MaximumCategories + " " + (MaximumCategories == 1 ? "category" : "categories"));
            return;
        }

        // filter with only the possible categories
        DataClassInfo JoinTableClassInfo = DataClassInfoProvider.GetDataClassInfo(JoinTableName);

        if (JoinTableClassInfo != null)
        {
            List <int> DocumentCategoryIds = new List <int>();

            // Get all the categories the current entity has
            int          totalRecords        = 0;
            var          currentCategoriesDS = ConnectionHelper.ExecuteQuery(JoinTableName + ".selectall", null, string.Format("{0} = '{1}'", JoinTableLeftFieldName, CurrentItemIdentification), null, -1, null, -1, -1, ref totalRecords);
            CategoryInfo catObject           = null;
            string       FieldSaveColumnName = "";
            // Convert to CategoryID
            switch (FieldSaveModeVal)
            {
            case FieldSaveType.ID:
                FieldSaveColumnName = "CategoryID";
                break;

            case FieldSaveType.GUID:
                FieldSaveColumnName = "CategoryGUID";
                break;

            case FieldSaveType.CategoryName:
                FieldSaveColumnName = "CategoryName";
                break;
            }

            foreach (DataRow dr in currentCategoriesDS.Tables[0].Rows)
            {
                // Convert to CategoryID
                switch (FieldSaveModeVal)
                {
                case FieldSaveType.ID:
                    catObject = CategoryInfo.Provider.Get(ValidationHelper.GetInteger(dr[JoinTableRightFieldName], 0));
                    if (catObject != null)
                    {
                        DocumentCategoryIds.Add(catObject.CategoryID);
                    }
                    break;

                case FieldSaveType.GUID:
                    var ClassObject = CategoryInfo.Provider.Get().WhereEquals("CategoryGUID", ValidationHelper.GetGuid(dr[JoinTableRightFieldName], new Guid())).FirstOrDefault();
                    if (ClassObject != null)
                    {
                        DocumentCategoryIds.Add(ValidationHelper.GetInteger(ClassObject["CategoryID"], 0));
                    }
                    break;

                case FieldSaveType.CategoryName:
                    catObject = CategoryInfo.Provider.Get(ValidationHelper.GetString(dr[JoinTableRightFieldName], ""), SiteContext.CurrentSiteID);
                    if (catObject != null)
                    {
                        DocumentCategoryIds.Add(catObject.CategoryID);
                    }
                    break;
                }
            }

            // Find IDs we need to add and remove.
            List <int> NotSelectedIds = PossibleCategoryIDs.Except(SelectedCategoryIDs).ToList();
            List <int> DeselectIds    = DocumentCategoryIds.Intersect(NotSelectedIds).ToList();
            List <int> SelectIds      = SelectedCategoryIDs.Except(DocumentCategoryIds).ToList();

            if (DeselectIds.Count > 0)
            {
                foreach (int DeselectId in DeselectIds)
                {
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItemProvider.GetItems(JoinTableClassInfo.ClassName).WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, CategoryInfo.Provider.Get(DeselectId).GetValue(FieldSaveColumnName))
                        .ToList().ForEach(x => ((CustomTableItem)x).Delete());
                    }
                    else
                    {
                        new ObjectQuery(JoinTableClassInfo.ClassName)
                        .WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, CategoryInfo.Provider.Get(DeselectId).GetValue(FieldSaveColumnName))
                        .ToList().ForEach(x => x.Delete());
                    }
                }
            }
            if (SelectIds.Count > 0)
            {
                foreach (int SelectId in SelectIds)
                {
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItem newCustomTableItem = CustomTableItem.New(JoinTableName);
                        SetBaseInfoItemValues(newCustomTableItem, CategoryInfo.Provider.Get(SelectId).GetValue(FieldSaveColumnName), JoinTableClassInfo.ClassName);
                        InsertObjectHandler(newCustomTableItem);
                    }
                    else
                    {
                        // Create a dynamic BaseInfo object of the right type.
                        var JoinTableClassFactory = new InfoObjectFactory(JoinTableClassInfo.ClassName);
                        if (JoinTableClassFactory.Singleton == null)
                        {
                            AddError("Class does not have TypeInfo and TypeInfoProvider generated.  Must generate " + JoinTableClassInfo.ClassName + " Code before can bind.");
                            return;
                        }
                        BaseInfo newJoinObj = ((BaseInfo)JoinTableClassFactory.Singleton);
                        SetBaseInfoItemValues(newJoinObj, CategoryInfo.Provider.Get(SelectId).GetValue(FieldSaveColumnName), JoinTableClassInfo.ClassName);
                        InsertObjectHandler(newJoinObj);
                    }
                }
            }

            AddConfirmation(string.Format("{0} Categories Added, {1} Categories Removed.", SelectIds.Count, DeselectIds.Count));
        }
    }
Пример #22
0
        public void runRoles()
        {
            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();

                        StringBuilder documentsAddedStatus = new StringBuilder();
                        //string eventLocation = string.Empty;
                        string rootFolder = "error";
                        string folderName = "task";
                        string fileName   = "DocumentsStatusLogged.txt";
                        string filePath   = Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            rootFolder,
                            folderName,
                            fileName);
                        documentsAddedStatus.Append(
                            "role Added" + ProductCode + ShortName.Trim()
                            + Environment.NewLine);
                        using (StreamWriter writer = new StreamWriter(filePath, true))
                        {
                            writer.WriteLine(documentsAddedStatus);
                            writer.WriteLine(
                                Environment.NewLine
                                + "-----------------------------------------------------------------------------"
                                + Environment.NewLine);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string folderName = "error";
                string fileName   = "ExceptionLogged.txt";
                string filePath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, folderName, fileName);

                File.Delete(filePath);

                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(
                        "Message :" + ex.Message + Environment.NewLine + "StackTrace :" + ex.StackTrace + ""
                        + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                    writer.WriteLine(
                        Environment.NewLine
                        + "-----------------------------------------------------------------------------"
                        + Environment.NewLine);
                }
            }
        }
Пример #23
0
    /// <summary>
    /// Adds GUID field to form definition.
    /// </summary>
    private void CreateGUID()
    {
        bool success;

        try
        {
            if (FormInfo == null)
            {
                return;
            }

            // Create GUID field
            FormFieldInfo ffiGuid = new FormFieldInfo();

            // Fill FormInfo object
            ffiGuid.Name = "ItemGUID";
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "GUID");
            ffiGuid.DataType = FieldDataType.Guid;
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, String.Empty);
            ffiGuid.PrimaryKey = false;
            ffiGuid.System     = true;
            ffiGuid.Visible    = false;
            ffiGuid.Size       = 0;
            ffiGuid.AllowEmpty = false;

            FormInfo.AddFormItem(ffiGuid);

            // Update definition
            dci.ClassFormDefinition = FormInfo.GetXmlDefinition();

            using (CMSActionContext context = new CMSActionContext())
            {
                // Disable logging into event log
                context.LogEvents = false;

                DataClassInfoProvider.SetDataClassInfo(dci);
            }

            // Clear the default queries
            QueryInfoProvider.ClearDefaultQueries(dci, true);

            // Clear the object type hashtable
            AbstractProviderDictionary.ReloadDictionaries(className, true);

            // Clear the classes hashtable
            AbstractProviderDictionary.ReloadDictionaries("cms.class", true);

            // Clear class strucures
            ClassStructureInfo.Remove(className, true);

            // Ensure GUIDs for all items
            using (CMSActionContext ctx = new CMSActionContext())
            {
                ctx.UpdateSystemFields = false;
                ctx.LogSynchronization = false;
                DataSet dsItems = CustomTableItemProvider.GetItems(className);
                if (!DataHelper.DataSourceIsEmpty(dsItems))
                {
                    foreach (DataRow dr in dsItems.Tables[0].Rows)
                    {
                        CustomTableItem item = CustomTableItem.New(className, dr);
                        item.ItemGUID = Guid.NewGuid();
                        item.Update();
                    }
                }
            }

            // Log event
            UserInfo currentUser = MembershipContext.AuthenticatedUser;

            var logData = new EventLogData(EventTypeEnum.Information, "Custom table", "GENERATEGUID")
            {
                EventDescription = String.Format(ResHelper.GetAPIString("customtable.GUIDGenerated", "Field 'ItemGUID' for custom table '{0}' was created and GUID values were generated."), dci.ClassName),
                UserID           = currentUser.UserID,
                UserName         = currentUser.UserName,
            };

            Service.Resolve <IEventLogService>().LogEvent(logData);

            success = true;
        }
        catch (Exception ex)
        {
            success = false;

            FieldEditor.ShowError(GetString("customtable.ErrorGUID"));

            // Log event
            Service.Resolve <IEventLogService>().LogException("Custom table", "GENERATEGUID", ex);
        }

        if (success)
        {
            URLHelper.Redirect(URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "gen", "1"));
        }
    }
Пример #24
0
    /// <summary>
    /// Adds GUID field to form definition.
    /// </summary>
    private void CreateGUID()
    {
        try
        {
            // Create GUID field
            FormFieldInfo ffiGuid = new FormFieldInfo();

            // Fill FormInfo object
            ffiGuid.Name = "ItemGUID";
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "GUID");
            ffiGuid.DataType = FieldDataType.Guid;
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
            ffiGuid.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, String.Empty);
            ffiGuid.FieldType = FormFieldControlTypeEnum.CustomUserControl;
            ffiGuid.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
            ffiGuid.PrimaryKey = false;
            ffiGuid.System     = true;
            ffiGuid.Visible    = false;
            ffiGuid.Size       = 0;
            ffiGuid.AllowEmpty = false;

            FormInfo.AddFormItem(ffiGuid);

            // Update table structure - columns could be added
            bool old = TableManager.UpdateSystemFields;
            TableManager.UpdateSystemFields = true;
            string schema = FormInfo.GetXmlDefinition();

            TableManager tm = new TableManager(null);
            tm.UpdateTableByDefinition(dci.ClassTableName, schema);

            TableManager.UpdateSystemFields = old;

            // Update xml schema and form definition
            dci.ClassFormDefinition = schema;
            dci.ClassXmlSchema      = tm.GetXmlSchema(dci.ClassTableName);

            dci.Generalized.LogEvents = false;

            // Save the data
            DataClassInfoProvider.SetDataClassInfo(dci);

            dci.Generalized.LogEvents = true;

            // Clear the default queries
            QueryInfoProvider.ClearDefaultQueries(dci, true, false);

            // 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
            using (CMSActionContext ctx = new CMSActionContext())
            {
                ctx.UpdateSystemFields = false;
                ctx.LogSynchronization = false;
                DataSet dsItems = CustomTableItemProvider.GetItems(className);
                if (!DataHelper.DataSourceIsEmpty(dsItems))
                {
                    foreach (DataRow dr in dsItems.Tables[0].Rows)
                    {
                        CustomTableItem item = CustomTableItem.New(className, dr);
                        item.ItemGUID = Guid.NewGuid();
                        item.Update();
                    }
                }
            }

            // Log event
            UserInfo currentUser = MembershipContext.AuthenticatedUser;
            EventLogProvider.LogEvent(EventType.INFORMATION, "Custom table", "GENERATEGUID", string.Format(ResHelper.GetAPIString("customtable.GUIDGenerated", "Field 'ItemGUID' for custom table '{0}' was created and GUID values were generated."), dci.ClassName), null, currentUser.UserID, currentUser.UserName);

            URLHelper.Redirect(URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "gen", "1"));
        }
        catch (Exception ex)
        {
            FieldEditor.ShowError(GetString("customtable.ErrorGUID") + ex.Message);

            // Log event
            EventLogProvider.LogException("Custom table", "GENERATEGUID", ex);
        }
    }
Пример #25
0
    public void LoadIndividualData(int pageFrom, int pageTo)
    {
        StringBuilder documentsAddedStatus = new StringBuilder();

        string Query = "select * from (select distinct MasterCustomerId,LabelName,ROW_NUMBER() over (ORDER BY MasterCustomerId) AS Number from dbo.Sme_CommiteesMaster) as com where Number>=" + pageFrom + "AND Number<=" + pageTo;

        var      queryToGetCommittees = new QueryParameters(Query, null, CMS.DataEngine.QueryTypeEnum.SQLQuery, false);
        DataSet  ds = ConnectionHelper.ExecuteQuery(queryToGetCommittees);  //ExecQuery(Query); //("pb.account_types.select_accounts", null, where, null);
        string   CommitteeMemberId            = string.Empty;
        DateTime BeginDate                    = new DateTime();
        string   CommitteeMasterCustomer      = string.Empty;
        string   CommitteeMemberLastFirstName = string.Empty;
        string   CommitteeSubCustomer         = string.Empty;
        DateTime EndDate                        = new DateTime();
        string   MemberAddressId                = string.Empty;
        string   MemberAddressTypeCodeString    = string.Empty;
        string   MemberMasterCustomer           = string.Empty;
        string   ParticipationStatusCodeString  = string.Empty;
        string   PositionCodeDescriptionDisplay = string.Empty;
        string   PositionCodeString             = string.Empty;
        string   VotingStatusCodeString         = string.Empty;
        string   CommitteeLabelName             = string.Empty;

        if (ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Uri ServiceUri =
                    new Uri("http://smemitst.personifycloud.com/PersonifyDataServices/PersonifyDatasme.svc");
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.Credentials = new NetworkCredential("admin", "admin");
                var CommiteeMembers =
                    DataAccessLayer.CommitteeMembers.Where(p => p.CommitteeMasterCustomer == dr["MasterCustomerId"])
                    .Select(o => o)
                    .ToList();
                if (CommiteeMembers != null)
                {
                    foreach (var member in CommiteeMembers)
                    {
                        CommitteeMemberId            = member.CommitteeMemberId.ToString();
                        BeginDate                    = Convert.ToDateTime(member.BeginDate);
                        CommitteeMasterCustomer      = member.CommitteeMasterCustomer;
                        CommitteeMemberLastFirstName = member.CommitteeMemberLastFirstName;
                        CommitteeSubCustomer         = member.CommitteeSubCustomer.ToString();
                        MemberAddressId              = member.MemberAddressId.ToString();

                        MemberAddressTypeCodeString    = member.MemberAddressTypeCodeString;
                        MemberMasterCustomer           = member.MemberMasterCustomer;
                        ParticipationStatusCodeString  = member.ParticipationStatusCodeString;
                        PositionCodeDescriptionDisplay = member.PositionCodeDescriptionDisplay.ToString();


                        PositionCodeString     = member.PositionCodeString;
                        VotingStatusCodeString = member.VotingStatusCodeString.ToString();
                        CommitteeLabelName     = member.CommitteeLabelName;
                        EndDate = Convert.ToDateTime(member.EndDate);

                        string customTableClassName = "Sme.CommiteesMembers";
                        string where = "CommitteeMemberId='" + CommitteeMemberId + "' AND CommitteeMemberLastFirstName='" + CommitteeMemberLastFirstName.Replace("'", "''") + "'";

                        // Check if Custom table 'Sme.CommiteesMembers' exists
                        DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

                        DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where);

                        int memberID = 0;

                        if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                        {
                            // Get the custom table item ID
                            memberID = ValidationHelper.GetInteger(customTableRecord.Tables[0].Rows[0][0], 0);
                        }


                        if (customTable != null)
                        {
                            if (memberID == 0)
                            {
                                if (EndDate >= DateTime.Now ||
                                    PositionCodeDescriptionDisplay.ToLower().Contains("president"))
                                {
                                    // Create new item for custom table with "Sme.CommiteesMembers" code name
                                    CustomTableItem item = CustomTableItem.New("Sme.CommiteesMembers");
                                    item.SetValue("CommitteeMemberId", CommitteeMemberId);
                                    item.SetValue("BeginDate", BeginDate);
                                    item.SetValue("CommitteeMasterCustomer", CommitteeMasterCustomer);
                                    item.SetValue("CommitteeMemberLastFirstName", CommitteeMemberLastFirstName.Replace("'", "''"));
                                    item.SetValue("CommitteeSubCustomer", CommitteeSubCustomer);

                                    item.SetValue("MemberAddressId", MemberAddressId);
                                    item.SetValue("MemberAddressTypeCodeString", MemberAddressTypeCodeString);
                                    item.SetValue("MemberMasterCustomer", MemberMasterCustomer);
                                    item.SetValue("ParticipationStatusCodeString", ParticipationStatusCodeString);
                                    item.SetValue("PositionCodeDescriptionDisplay", PositionCodeDescriptionDisplay);
                                    item.SetValue("PositionCodeString", PositionCodeString);

                                    item.SetValue("VotingStatusCodeString", VotingStatusCodeString);
                                    item.SetValue("CommitteeLabelName", CommitteeLabelName);
                                    item.SetValue("EndDate", EndDate);
                                    item.Insert();
                                }

                                /*documentsAddedStatus.Append(
                                 *  "Added CommitteeLabelName : " + CommitteeLabelName + " in the CommitteeMemberId: "
                                 + CommitteeMemberId + "at" + DateTime.Now + Environment.NewLine);*/
                            }
                            else
                            {
                                if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                                {
                                    // Get the custom table item
                                    CustomTableItem updateItem = CustomTableItemProvider.GetItem(memberID, customTableClassName);

                                    if (updateItem != null)
                                    {
                                        if (EndDate >= DateTime.Now ||
                                            PositionCodeDescriptionDisplay.ToLower().Contains("president"))
                                        {
                                            //updateItem.SetValue("CommitteeMemberId", CommitteeMemberId);
                                            updateItem.SetValue("BeginDate", BeginDate);
                                            updateItem.SetValue("CommitteeMasterCustomer", CommitteeMasterCustomer);
                                            updateItem.SetValue("CommitteeMemberLastFirstName", CommitteeMemberLastFirstName.Replace("'", "''"));
                                            updateItem.SetValue("CommitteeSubCustomer", CommitteeSubCustomer);

                                            updateItem.SetValue("MemberAddressId", MemberAddressId);
                                            updateItem.SetValue(
                                                "MemberAddressTypeCodeString",
                                                MemberAddressTypeCodeString);
                                            updateItem.SetValue("MemberMasterCustomer", MemberMasterCustomer);
                                            updateItem.SetValue(
                                                "ParticipationStatusCodeString",
                                                ParticipationStatusCodeString);
                                            updateItem.SetValue(
                                                "PositionCodeDescriptionDisplay",
                                                PositionCodeDescriptionDisplay);
                                            updateItem.SetValue("PositionCodeString", PositionCodeString);

                                            updateItem.SetValue("VotingStatusCodeString", VotingStatusCodeString);
                                            updateItem.SetValue("CommitteeLabelName", CommitteeLabelName);
                                            updateItem.SetValue("EndDate", EndDate);
                                            updateItem.Update();

                                            /*documentsAddedStatus.Append(
                                             * "Updated CommitteeLabelName : " + CommitteeLabelName + " in the CommitteeMemberId: "
                                             + CommitteeMemberId + "at" + DateTime.Now + Environment.NewLine);*/
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                /*string rootFolder = "CMSWebParts";
                 * string folderName = "SME";
                 * string fileName = "CommitteeMembersStatusLogged.txt";
                 * string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rootFolder, folderName, fileName);
                 *
                 * using (StreamWriter writer = new StreamWriter(filePath, true))
                 * {
                 *  writer.WriteLine(documentsAddedStatus);
                 *  writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                 *  writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                 * }*/
            }
        }
    }
Пример #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Uri ServiceUri = new Uri(SUri);
        PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);

        DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);
        _webControlParameters       = DataAccessLayer.WebControlParameters.ToList();


        if (_webControlParameters.Count > 0)
        {
            foreach (var x  in _webControlParameters)
            {
                //

                string customTableClassName = "Sme.personifyPages";
                string where = "ParameterName='" + x.ParameterName + "'";

                // Check if Custom table 'Sme.CommiteesMembers' exists
                DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);


                CustomTableItem item = CustomTableItem.New("Sme.personifyPages");
                item.SetValue("ParameterValue", x.ParameterValue);
                item.SetValue("ParameterName", x.ParameterName);
                item.Insert();
                //DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where);

                //int ItemID = 0;
                // if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                //    {
                //        // Get the custom table item ID
                //        ItemID = ValidationHelper.GetInteger(customTableRecord.Tables[0].Rows[0][0], 0);
                //    }

                //if (customTable != null)
                //{
                //    if (ItemID == 0)
                //    {
                //        CustomTableItem item = CustomTableItem.New("Sme.CommiteesMembers");
                //        item.SetValue("ParameterValue", x.ParameterValue);
                //        item.SetValue(" ParameterName", x.ParameterName);
                //        item.Insert();
                //    }

                //    else
                //    {

                //        if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                //        {
                //            CustomTableItem updateItem = CustomTableItemProvider.GetItem(ItemID, customTableClassName);
                //            if (updateItem != null)
                //            {
                //                updateItem.SetValue("ParameterValue", x.ParameterValue);
                //                updateItem.SetValue(" ParameterName", x.ParameterName);

                //                updateItem.Update();
                //            }
                //        }
                //    }
                //}

                ///
                Response.Write(x.ParameterValue + "---" + x.ParameterName + "<br/>");
            }
        }
    }
Пример #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx";

        // Get form ID from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);
        //get search value
        searchvalue = QueryHelper.GetString("search", "");
        // Running in site manager?
        bool siteManager = QueryHelper.GetInteger("sm", 0) == 1;

        DataClassInfo dci = null;

        // Read data only if user is site manager global admin or table is bound to current site
        if (CurrentUser.UserSiteManagerAdmin || (ClassSiteInfoProvider.GetClassSiteInfo(customTableId, CMSContext.CurrentSiteID) != null))
        {
            // Get CustomTable class
            dci = DataClassInfoProvider.GetDataClass(customTableId);
        }

        // Set edited object
        EditedObject = dci;

        if (dci != null)
        {
            customTableDataList.CustomTableClassInfo         = dci;
            customTableDataList.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            customTableDataList.ViewItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            // Set alternative form and data container
            customTableDataList.UniGrid.FilterFormName = dci.ClassName + "." + "filter";
            customTableDataList.UniGrid.FilterFormData = CustomTableItem.New(dci.ClassName, new CustomTableItemProvider(CMSContext.CurrentUser));
            string sql = "";
            if (searchvalue != "")
            {
                string[] arr = searchvalue.Trim().Replace("1=1", "").Split(' ');
                for (int i = 0; i < arr.Length; i++)
                {
                    if (i != arr.Length - 1)
                    {
                        sql += string.Format(" Year like '%{0}%' or Make like '%{0}%' or Model like '%{0}%' or BodyText like '%{0}%' or ", arr[i]);
                    }
                    else
                    {
                        sql += string.Format(" Year like '%{0}%' or Make like '%{0}%' or Model like '%{0}%' or BodyText like '%{0}%' ", arr[i]);
                    }
                }
            }
            customTableDataList.UniGrid.WhereCondition = sql;

            // Set custom pages
            if (dci.ClassEditingPageURL != String.Empty)
            {
                customTableDataList.EditItemPage = dci.ClassEditingPageURL;
            }
            if (dci.ClassNewPageURL != String.Empty)
            {
                newItemPage = dci.ClassNewPageURL;
            }
            if (dci.ClassViewPageUrl != String.Empty)
            {
                customTableDataList.ViewItemPage = dci.ClassViewPageUrl;
            }


            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" +
                                                                                                                ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectFields.aspx") + "?customtableid=" + customTableId + "'  ,'CustomTableFields', 500, 500); }"));
            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectSearch", ScriptHelper.GetScript("function SelectSearch() { modalDialog('" +
                                                                                                                ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectSearch.aspx") + "?customtableid=" + customTableId + "'  ,'CustomTableSearch', 500, 500); }"));

            if (!siteManager)
            {
                CurrentMaster.Title.TitleText     = GetString("customtable.edit.header");
                CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_CustomTable/object.png");
                CurrentMaster.Title.HelpTopicName = "custom_tables_data";
                CurrentMaster.Title.HelpName      = "helpTopic";
            }

            // Check 'Read' permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") &&
                !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read"))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            string[,] actions = new string[3, 6];
            // New item link
            actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
            actions[0, 1] = GetString("customtable.data.newitem");
            actions[0, 2] = null;
            actions[0, 3] = ResolveUrl(newItemPage + "?new=1&customtableid=" + customTableId + (siteManager ? "&sm=1" : ""));
            actions[0, 4] = null;
            actions[0, 5] = GetImageUrl("CMSModules/CMS_CustomTables/newitem.png");
            // Select fields link
            actions[1, 0] = HeaderActions.TYPE_HYPERLINK;
            actions[1, 1] = GetString("customtable.data.selectdisplayedfields");
            actions[1, 2] = null;
            actions[1, 3] = "javascript:SelectFields();";
            actions[1, 4] = null;
            actions[1, 5] = GetImageUrl("CMSModules/CMS_CustomTables/selectfields16.png");
            // Select search fields
            actions[2, 0] = HeaderActions.TYPE_LINKBUTTON;
            actions[2, 1] = "Search";
            actions[2, 2] = null;
            actions[2, 3] = "javascript:CloseAndRefresh();";
            actions[2, 4] = null;
            actions[2, 5] = GetImageUrl("CMSModules/CMS_CustomTables/selectfields16.png");
            CurrentMaster.HeaderActions.Actions = actions;
            //
            if (!siteManager)
            {
                // Initializes page title
                string[,] breadcrumbs = new string[2, 3];
                breadcrumbs[0, 0]     = GetString("customtable.list.title");
                breadcrumbs[0, 1]     = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx";
                breadcrumbs[0, 2]     = "";
                breadcrumbs[1, 0]     = dci.ClassDisplayName;
                breadcrumbs[1, 1]     = "";
                breadcrumbs[1, 2]     = "";

                CurrentMaster.Title.Breadcrumbs = breadcrumbs;
            }
        }
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Creates new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

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

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

        if (customTable != null)
        {
            // VALIDATION RULES
            int     shippingUnitTo = -1, shippingUnitFrom = Convert.ToInt32(txtShippingUnitFrom.Text);
            decimal price = 0;



            if (!string.IsNullOrEmpty(txtShippingUnitTo.Text))
            {
                txtShippingUnitTo.Text = txtShippingUnitTo.Text.Trim();

                // Ensures integer value entered in txtShippingUnitTo
                try
                {
                    shippingUnitTo = Convert.ToInt32(txtShippingUnitTo.Text);
                }
                catch
                {
                    ShowError(string.Format("<b>{0}</b> is not valid for <u><b>Shipping unit to</b></u>", txtShippingUnitTo.Text));
                    return;
                }

                // Ensures txtShippingUnitTo > txtShippingUnitFrom
                if (shippingUnitTo <= shippingUnitFrom && shippingUnitTo != -1)
                {
                    ShowError(string.Format("<u><b>Shipping unit to</b></u> must be greater than {0}", txtShippingUnitFrom.Text));
                    return;
                }

                // Ensures price exists
                if (string.IsNullOrEmpty(txtPrice.Text.Trim()))
                {
                    ShowError("Price must be entered");
                    return;
                }
            }

            // Ensures decimal value entered in txtPrice if txtShippingUnitTo is filled
            try
            {
                price = Convert.ToDecimal(txtPrice.Text);
            }
            catch
            {
                if (!string.IsNullOrEmpty(txtShippingUnitTo.Text.Trim()))
                {
                    ShowError(string.Format("<u><b>Price</b></u> {0} is not valid", txtPrice.Text));
                    return;
                }
            }

            // Creates new custom table item
            CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);
            // Sets the ItemText field value
            newCustomTableItem.SetValue("ShippingExtensionCountryId", mShippingExtensionPricingID);
            newCustomTableItem.SetValue("ShippingUnitFrom", int.Parse(txtShippingUnitFrom.Text));
            newCustomTableItem.SetValue("ShippingUnitTo", shippingUnitTo);
            newCustomTableItem.SetValue("ShippingUnitPrice", price);

            // Inserts the custom table item into database
            newCustomTableItem.Insert();
        }
        Response.Redirect(string.Format("ShippingExtension_Edit_Pricing.aspx?ItemID={0}", mShippingExtensionPricingID.ToString()));
    }
Пример #29
0
    private Boolean CreateCustomTableItem(DataClassInfo customTable, DataRow dr)
    {
        if (customTable != null)
        {
            // Creates new custom table item

            CustomTableItem newCustomTableItem = CustomTableItem.New(customTable.ClassName, _customTableProvider);



            // Sets the ItemText field value
            try
            {
                if (_customTable == null)
                {
                    _customTable = (Session["_customTable"] != null ? (DataSet)Session["_customTable"] : null);
                }
                int i = 0;
                if (_customTable != null)
                {
                    foreach (DataColumn column in _customTable.Tables[0].Columns)
                    {
                        if (column.ColumnName.LastIndexOf("Item") == -1)
                        {
                            string temp = "";
                            object aaa  = default_value(column.ColumnName, out temp);
                            aaa = (aaa != null ? aaa : null);
                            if (aaa != null)
                            {
                                object vl = null;

                                /*
                                 * if (default_value_int(column.ColumnName))
                                 * {
                                 *
                                 *   vl = double_parse(dr[aaa.ToString()].ToString().Trim().Replace("$", "").Replace(",", ""));
                                 * }
                                 * else
                                 * {
                                 *   if (column.ColumnName == "Views") vl = int_parse(dr[aaa.ToString()].ToString().Trim());
                                 *   else
                                 *       if (column.ColumnName == "Featured") vl = bool_parse(dr[aaa.ToString()].ToString().Trim());
                                 *   else
                                 *           if (column.ColumnName == "Model") vl = dr[aaa.ToString()].ToString().Trim().Split('"')[0];
                                 *           else
                                 *       vl = dr[aaa.ToString()].ToString().Trim();
                                 *
                                 *
                                 *
                                 * }
                                 */
                                try
                                {
                                    vl = type_field(dr[aaa.ToString()].ToString());
                                    if (vl != null)
                                    {
                                        newCustomTableItem.SetValue(column.ColumnName, vl);
                                    }
                                }
                                catch (Exception exx)
                                {
                                    Literal1.Text += "<p>- Column " + temp + " error:" + exx.Message + "</p>";
                                }
                            }
                        }
                    }

                    newCustomTableItem.Insert();
                    return(true);
                }
            }
            catch (Exception e)
            {
                Literal1.Text += e.Message + "<br>";
                return(false);
            }
        }


        return(false);
    }
    /// <summary>
    /// Figure out using the Join Table which categories need to be removed and which added
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Form_OnAfterSaveJoinTable(object sender, EventArgs e)
    {
        //dont save data for filter forms
        if (sender is CMS.FormEngine.Web.UI.FilterForm)
        {
            return;
        }

        // Add key so it will load the new data even though it is a 'postback' after this.
        DataClassInfo JoinTableClassInfo = DataClassInfoProvider.GetDataClassInfo(JoinTableName);

        if (JoinTableClassInfo != null)
        {
            List <string> SelectedObjectRefIDs = GetSelectedObjects();
            List <string> CurrentObjectRefIDs  = GetCurrentObjects();

            List <string> ObjectsToAdd    = SelectedObjectRefIDs.Where(x => !CurrentObjectRefIDs.Contains(x)).ToList();
            List <string> ObjectsToRemove = CurrentObjectRefIDs.Where(x => !SelectedObjectRefIDs.Contains(x)).ToList();

            if (ObjectsToAdd.Count > 0)
            {
                foreach (string ObjectToAdd in ObjectsToAdd)
                {
                    // Custom Tables
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItem newCustomTableItem = CustomTableItem.New(JoinTableName);
                        SetBaseInfoItemValues(newCustomTableItem, GetProperObjectValue(ObjectToAdd), JoinTableClassInfo.ClassName);
                        newCustomTableItem.Insert();
                    }
                    else
                    {
                        // Create a dynamic BaseInfo object of the right type.
                        var JoinTableClassFactory = new InfoObjectFactory(JoinTableClassInfo.ClassName);
                        if (JoinTableClassFactory.Singleton == null)
                        {
                            AddError("Class does not have TypeInfo and TypeInfoProvider generated.  Must generate " + JoinTableClassInfo.ClassName + " Code before can bind.");
                            return;
                        }
                        BaseInfo newJoinObj = ((BaseInfo)JoinTableClassFactory.Singleton);
                        SetBaseInfoItemValues(newJoinObj, GetProperObjectValue(ObjectToAdd), JoinTableClassInfo.ClassName);
                        InsertObjectHandler(newJoinObj);
                    }
                }
            }
            if (ObjectsToRemove.Count > 0)
            {
                foreach (string ObjectToRemove in ObjectsToRemove)
                {
                    // Custom Table logic
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItemProvider.GetItems(JoinTableClassInfo.ClassName).WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, GetProperObjectValue(ObjectToRemove))
                        .ToList().ForEach(x => ((CustomTableItem)x).Delete());
                    }
                    else
                    {
                        new ObjectQuery(JoinTableClassInfo.ClassName)
                        .WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, GetProperObjectValue(ObjectToRemove))
                        .ToList().ForEach(x => x.Delete());
                    }
                }
            }
        }
    }