Example #1
0
 private string getTranslation(DataLookupValue lookupValue)
 {
     if (LanguageCode == "NL")
     {
         return(lookupValue.NL);
     }
     else if (LanguageCode == "EN")
     {
         return(lookupValue.EN);
     }
     else if (LanguageCode == "DE")
     {
         return(lookupValue.DE);
     }
     else if (LanguageCode == "FR")
     {
         return(lookupValue.FR);
     }
     else if (LanguageCode == "SP")
     {
         return(lookupValue.SP);
     }
     else if (LanguageCode == "PL")
     {
         return(lookupValue.PL);
     }
     else if (LanguageCode == "IT")
     {
         return(lookupValue.IT);
     }
     else
     {
         return(lookupValue.Name);
     }
 }
        public void DeleteDataLookupValue(string id)
        {
            BaseService.CheckLoginAndLicense();
            DataLookupValue lookupValue = BaseObject.GetById <DataLookupValue>(new Guid(id));

            lookupValue.Delete();
        }
        private void SetDefaultItemValues(DataItem item)
        {
            PropertyInfo[] properties = typeof(DataItem).GetProperties();
            foreach (DataField fld in item.DataCollection.DataItemFields)
            {
                try
                {
                    PropertyInfo currentProperty = properties.Where(c => c.Name == fld.MappingColumn).FirstOrDefault();
                    if (currentProperty != null)
                    {
                        if (currentProperty.PropertyType == typeof(string))
                        {
                            currentProperty.SetValue(item, fld.DefaultValue, null);
                        }

                        if (currentProperty.PropertyType == typeof(int))
                        {
                            int i = 0;
                            int.TryParse(fld.DefaultValue, out i);
                            currentProperty.SetValue(item, i, null);
                        }

                        if (currentProperty.PropertyType == typeof(DateTime))
                        {
                            DateTime d = DateTime.Now;
                            DateTime.TryParse(fld.DefaultValue, out d);
                            currentProperty.SetValue(item, d, null);
                        }

                        if (currentProperty.PropertyType == typeof(DataLookupValue))
                        {
                            DataLookupValue dlv = DataLookupValue.GetFirst <DataLookupValue>(" Name = '" + fld.DefaultValue + "'");
                            if (dlv != null)
                            {
                                currentProperty.SetValue(item, dlv, null);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #4
0
        //internal string Publish2(out string title, out string metaDescription, out string metaKeywords)
        //{
        //    string html = Publish2();
        //    title = this.ItemTitle;
        //    metaDescription = this.ItemMetaDescription;
        //    metaKeywords = this.ItemMetaKeywords;
        //    return html;
        //}


        public override PostResult HandlePost(CmsPage page, Dictionary <string, string> FormParameters)
        {
            this.dataId = (FormParameters.ContainsKey("dataid")) ? Guid.Parse(FormParameters["dataid"]) : Guid.NewGuid();
            PostResult result       = new PostResult();
            string     messageLabel = "<ul>";
            bool       itemValid    = true;
            DataItem   item;

            if (dataId == Guid.Empty)
            {
                item = new DataItem();
            }
            else
            {
                item = BaseObject.GetById <DataItem>(dataId);
            }
            Type dataFieldType = typeof(DataItem);

            foreach (DataField dataField in this.DataCollection.DataItemFields)
            {
                if (FormParameters.ContainsKey(dataField.Name))
                {
                    string value = FormParameters[dataField.Name];
                    if (value == "")
                    {
                        value = dataField.DefaultValue;
                    }

                    if (dataField.FieldRule == FieldRuleEnum.Required)
                    {
                        if (value == "")
                        {
                            messageLabel += "<li>" + dataField.Name + "</li>";
                            itemValid     = false;
                        }
                    }

                    if (dataField.FieldRule == FieldRuleEnum.ReadOnly)
                    {
                    }

                    switch (dataField.FieldType)
                    {
                    case FieldTypeEnum.DropDown:
                        DataLookupValue lookUpValue = BaseObject.GetById <DataLookupValue>(Guid.Parse(value));
                        dataFieldType.GetProperty(dataField.MappingColumn).SetValue(item, lookUpValue, null);
                        break;

                    case FieldTypeEnum.CheckboxList:
                        string[] selectedLookUpIDs = value.Split(',');
                        foreach (string selectedLookUpID in selectedLookUpIDs)
                        {
                            DataLookupValue lookUpValue1 = BaseObject.GetById <DataLookupValue>(Guid.Parse(selectedLookUpID));
                            item.LookupValues1.Add(lookUpValue1);
                        }
                        break;

                    default:
                        dataFieldType.GetProperty(dataField.MappingColumn).SetValue(item, value, null);
                        break;
                    }
                }
            }

            if (itemValid)
            {
                if (WebSessionHelper.CurrentBitplateUser != null)
                {
                    item.BitplateUser = WebSessionHelper.CurrentBitplateUser;
                }

                if (WebSessionHelper.CurrentSiteUser != null)
                {
                    item.User = WebSessionHelper.CurrentSiteUser;
                }

                item.DataCollection = this.DataCollection;
                Guid parentGroupId;
                Guid.TryParse(this.getSetting <string>("SelectGroupID"), out parentGroupId);
                string strParentGroupID = "";
                if (parentGroupId != Guid.Empty && item.ParentGroup == null)
                {
                    item.ParentGroup = BaseObject.GetById <DataGroup>(parentGroupId);
                    strParentGroupID = parentGroupId.ToString();
                }
                DataItem checkItemNameExist = BaseObject.GetFirst <DataItem>("Name = '" + item.Name + "' AND FK_Parent_Group = '" + strParentGroupID + "'");
                if (checkItemNameExist == null || checkItemNameExist != null && checkItemNameExist.ID == this.dataId)
                {
                    bool isNewItemActive = false;

                    if (item.BitplateUser != null || item.User != null)
                    {
                        isNewItemActive = this.getSetting <bool>("IsNewItemActiveKownUsers");
                    }
                    else
                    {
                        isNewItemActive = this.getSetting <bool>("IsNewItemActiveUnkownUsers");
                    }

                    //this.getSetting<bool>("IsNewItemActive");
                    item.Active = (isNewItemActive) ? ActiveEnum.Active : ActiveEnum.InActive;
                    item.Save();
                }
                else
                {
                    itemValid    = false;
                    messageLabel = "<ul><li>Er bestaat al een item met deze naam in de groep.<li>";
                }
            }
            ModuleNavigationAction navigationActionDrillDown = this.GetNavigationActionByTagName("{SubmitButton}");

            result.ErrorMessage   = messageLabel + "</ul>";
            result.Success        = itemValid;
            result.NavigationType = navigationActionDrillDown.NavigationType;
            if (navigationActionDrillDown.NavigationType == NavigationTypeEnum.NavigateToPage)
            {
                result.NavigationUrl = navigationActionDrillDown.NavigationPage.GetRewriteUrl();
            }
            else
            {
                result.HtmlResult += Regex.Match(this.Content, "{SuccessTemplate}(.*?){/SuccessTemplate}", RegexOptions.Singleline).ToString().Replace("{SuccessTemplate}", "").Replace("{/SuccessTemplate}", "");
            }

            return(result);
        }