Пример #1
0
 // Updating Portal and Survey Skin with Dynamic Variable Values by Optimus
 private static void ApplyDynamicVariables(PanelPreferences preferences, string groupName, GuiVariable guiVar, string skinFolderPath,
     string dataPath, ReplacementDirectory.Replacement replacementDirectory)
 {
     switch (guiVar.UiComponent)
     {
         // Modified by K.G for phase2 task 'Support upload/processing of non-image files (e.g. pdf)'.
         case "FileUpload()":
             SkinManagerHelper.UpdateDynamicFile(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, dataPath, guiVar.PropertyName, replacementDirectory, guiVar.PathToUpload);
             break;
         case "ChoiceSelector()":
             var replaceValues = guiVar.PropertyName.Split(',');
             if (replaceValues.Length != 2) throw new Exception("Choice Selections must provide values for selected and unselected in PropertyName (e.g. 'block,none')");
             var replacementValue = preferences.DynamicGuiVariables[guiVar.ComponentName] == "true" ? replaceValues[0] : replaceValues[1];
             SkinManagerHelper.UpdateSkinDynamicVariable(replacementValue, skinFolderPath, guiVar.Substitution, guiVar.PropertyName, replacementDirectory);
             break;
         default:
             SkinManagerHelper.UpdateSkinDynamicVariable(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, guiVar.Substitution, guiVar.PropertyName, replacementDirectory);
             break;
     }
 }
Пример #2
0
 // Updating Portal and Survey Skin with Dynamic Variable Values
 private static void UpdateSkinWithDynamicVariables(PanelPreferences preferences, string groupName, GuiVariable guiVar, string skinFolderPath,
     string dataPath, bool isPortal)
 {
     switch (groupName)
     {
         case "TemplateColors":
             SkinManagerHelper.UpdateSkinDynamicVariableColor(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, guiVar.Substitution, guiVar.PropertyName, isPortal);
             break;
         case "List":
         case "Choices":
         case "Text":
             SkinManagerHelper.UpdateSkinVariableListChoiceText(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, guiVar.Substitution, guiVar.PropertyName, isPortal);
             break;
         case "Images":
             SkinManagerHelper.UpdateDynamicImage(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, dataPath, guiVar.PropertyName, isPortal);
             break;
     }
 }
Пример #3
0
        private GuiTemplate GetGuiTemplate(GuiTemplate guiTemplate, string filePath)
        {
            var xmlDoc = new XmlDocument();
            xmlDoc.Load(filePath + Res.SubstitutionXmlFileName);

            XmlNode groupingsNode = xmlDoc.SelectSingleNode(Res.SubstitutonGroupsPath);
            XmlNode substitutionNode = xmlDoc.SelectSingleNode(Res.SubstitutionPath);

            guiTemplate.TemplateName = (substitutionNode.Attributes[Res.TemplateNameAttribute] != null)
                ? substitutionNode.Attributes[Res.TemplateNameAttribute].Value
                : string.Empty;

            if (groupingsNode != null)
            {
                guiTemplate.VariableGroups = new List<GuiVariableGroup>();
                foreach (XmlNode groupingNode in groupingsNode.ChildNodes)
                {
                    var guiGroup = new GuiVariableGroup
                    {
                        GroupName = (groupingNode.Attributes[Res.NameAttribute] != null)
                                        ? groupingNode.Attributes[Res.NameAttribute].Value
                                        : string.Empty,
                        GroupLabel =
                            (groupingNode.Attributes[Res.GroupLabelAttribute] != null)
                                ? groupingNode.Attributes[Res.GroupLabelAttribute].Value
                                : string.Empty
                    };
                    guiTemplate.VariableGroups.Add(guiGroup);
                }
            }

            XmlNode variablesNode = xmlDoc.SelectSingleNode(Res.SubstitutionVariablesPath);

            if (variablesNode != null)
            {
                foreach (XmlNode variableNode in variablesNode.ChildNodes)
                {
                    var group = (variableNode.Attributes[Res.GroupingAttribute] != null) ?
                        variableNode.Attributes[Res.GroupingAttribute].Value : string.Empty;
                    foreach (GuiVariableGroup guiVarGroup in guiTemplate.VariableGroups)
                    {
                        if (guiVarGroup.GroupName.Equals(group))
                        {
                            if (guiVarGroup.Variables == null)
                            {
                                guiVarGroup.Variables = new List<GuiVariable>();
                            }

                            var guiVariable = new GuiVariable();
                            guiVariable.Substitution = (variableNode.Attributes[Res.SubstituionAttribute] != null) ?
                                variableNode.Attributes[Res.SubstituionAttribute].Value : string.Empty;
                            guiVariable.PropertyName = (variableNode.Attributes[Res.PropertyNameAttribute] != null) ?
                                variableNode.Attributes[Res.PropertyNameAttribute].Value : string.Empty;
                            guiVariable.GuiName = (variableNode.Attributes[Res.UiNameAttribute] != null) ?
                                variableNode.Attributes[Res.UiNameAttribute].Value : string.Empty;
                            guiVariable.AltText = (variableNode.Attributes[Res.AltTextAttribute] != null) ?
                                variableNode.Attributes[Res.AltTextAttribute].Value : string.Empty;
                            guiVariable.UiComponent = (variableNode.Attributes[Res.UIComponentAttribute] != null) ?
                                variableNode.Attributes[Res.UIComponentAttribute].Value : string.Empty;
                            guiVariable.Default = (variableNode.Attributes[Res.DefaultAttribute] != null) ?
                                variableNode.Attributes[Res.DefaultAttribute].Value : string.Empty;
                            guiVariable.ComponentName = (variableNode.Attributes[Res.ComponentNameAttribute] != null) ?
                                variableNode.Attributes[Res.ComponentNameAttribute].Value : string.Empty;
                            guiVariable.ReplacementDirectory = (variableNode.Attributes[Res.ReplacementDirectoryAttribute] != null) ?
                                variableNode.Attributes[Res.ReplacementDirectoryAttribute].Value : string.Empty;
                            guiVariable.PathToUpload = (variableNode.Attributes[Res.PathToUploadAttribute] != null) ?
                                variableNode.Attributes[Res.PathToUploadAttribute].Value : string.Empty;
                            var valueLst = (variableNode.Attributes[Res.ComponentValueListAttribute] != null) ?
                                variableNode.Attributes[Res.ComponentValueListAttribute].Value : string.Empty;
                            if (!String.IsNullOrEmpty(valueLst))
                            {
                                guiVariable.ComponentValueList = new List<string>();
                                string tempString = valueLst.Replace("\',\'", ".").Replace("\'", "");           // TODO needs to be more forgiving
                                guiVariable.ComponentValueList.AddRange(tempString.Split('.'));
                            }
                            else
                            {
                                guiVariable.ComponentValueList = null;
                            }
                            guiVarGroup.Variables.Add(guiVariable);
                        }
                    }
                }
            }
            return guiTemplate;
        }
Пример #4
0
        public DynamicGuiTemplates LoadTemplates()
        {
            var guiModel = new DynamicGuiTemplates();
            var mainDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + Res.LocalTemplatePath);
            int templateCount = mainDir.GetDirectories().Count(dir => (dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden);
            guiModel.GuiTemplates = new GuiTemplate[templateCount];
            int count = 0;
            foreach (var subDir in mainDir.EnumerateDirectories())
            {
                if (!subDir.Name.Equals(".svn"))
                {
                    var guiTemplate = new GuiTemplate();

                    var filePath = subDir.FullName;

                    guiTemplate.Image1 = Res.TemplateImagePath + subDir.Name + Res.LoginImageFileName;
                    guiTemplate.Image2 = Res.TemplateImagePath + subDir.Name + Res.PortalImageFileName;
                    guiTemplate.Image3 = Res.TemplateImagePath + subDir.Name + Res.SurveyImageFileName;

                    var xmlDoc = new XmlDocument();
                    xmlDoc.Load(filePath + Res.SubstitutionXmlFileName);

                    XmlNode groupingsNode = xmlDoc.SelectSingleNode(Res.SubstitutonGroupsPath);

                    if (groupingsNode != null)
                    {
                        guiTemplate.VariableGroups = new List<GuiVariableGroup>();
                        foreach (XmlNode groupingNode in groupingsNode.ChildNodes)
                        {
                            var guiGroup = new GuiVariableGroup
                                               {
                                                   GroupName = (groupingNode.Attributes[Res.NameAttribute] != null)
                                                                   ? groupingNode.Attributes[Res.NameAttribute].Value
                                                                   : string.Empty,
                                                   GroupLabel =
                                                       (groupingNode.Attributes[Res.GroupLabelAttribute] != null)
                                                           ? groupingNode.Attributes[Res.GroupLabelAttribute].Value
                                                           : string.Empty
                                               };
                            guiTemplate.VariableGroups.Add(guiGroup);
                        }
                    }

                    XmlNode variablesNode = xmlDoc.SelectSingleNode(Res.SubstitutionVariablesPath);

                    if (variablesNode != null)
                    {
                        foreach (XmlNode variableNode in variablesNode.ChildNodes)
                        {
                            var group = (variableNode.Attributes[Res.GroupingAttribute] != null) ?
                                variableNode.Attributes[Res.GroupingAttribute].Value : string.Empty;
                            foreach (GuiVariableGroup guiVarGroup in guiTemplate.VariableGroups)
                            {
                                if (guiVarGroup.GroupName.Equals(group))
                                {
                                    if (guiVarGroup.Variables == null)
                                    {
                                        guiVarGroup.Variables = new List<GuiVariable>();
                                    }

                                    var guiVariable = new GuiVariable();
                                    guiVariable.Substitution = (variableNode.Attributes[Res.SubstituionAttribute] != null) ?
                                        variableNode.Attributes[Res.SubstituionAttribute].Value : string.Empty;
                                    guiVariable.PropertyName = (variableNode.Attributes[Res.PropertyNameAttribute] != null) ?
                                        variableNode.Attributes[Res.PropertyNameAttribute].Value : string.Empty;
                                    guiVariable.GuiName = (variableNode.Attributes[Res.UiNameAttribute] != null) ?
                                        variableNode.Attributes[Res.UiNameAttribute].Value : string.Empty;
                                    guiVariable.AltText = (variableNode.Attributes[Res.AltTextAttribute] != null) ?
                                        variableNode.Attributes[Res.AltTextAttribute].Value : string.Empty;
                                    guiVariable.UiComponent = (variableNode.Attributes[Res.UIComponentAttribute] != null) ?
                                        variableNode.Attributes[Res.UIComponentAttribute].Value : string.Empty;
                                    guiVariable.Default = (variableNode.Attributes[Res.DefaultAttribute] != null) ?
                                        variableNode.Attributes[Res.DefaultAttribute].Value : string.Empty;
                                    guiVariable.ComponentName = (variableNode.Attributes[Res.ComponentNameAttribute] != null) ?
                                        variableNode.Attributes[Res.ComponentNameAttribute].Value : string.Empty;
                                    guiVariable.ReplacementDirectory = (variableNode.Attributes[Res.ReplacementDirectoryAttribute] != null) ?
                                        variableNode.Attributes[Res.ReplacementDirectoryAttribute].Value : string.Empty;

                                    var valueLst = (variableNode.Attributes[Res.ComponentValueListAttribute] != null) ?
                                        variableNode.Attributes[Res.ComponentValueListAttribute].Value : string.Empty;
                                    if (!String.IsNullOrEmpty(valueLst))
                                    {
                                        guiVariable.ComponentValueList = new List<string>();
                                        guiVariable.ComponentValueList.AddRange(valueLst.Split(','));
                                    }
                                    else
                                    {
                                        guiVariable.ComponentValueList = null;
                                    }
                                    guiVarGroup.Variables.Add(guiVariable);
                                }
                            }
                        }
                    }
                    guiModel.GuiTemplates[count] = guiTemplate;
                    count++;
                }
            }
            return guiModel;
        }
Пример #5
0
 // Updating Portal and Survey Skin with Dynamic Variable Values by Optimus
 private static void ApplyDynamicVariables(PanelPreferences preferences, string groupName, GuiVariable guiVar, string skinFolderPath,
     string dataPath, bool isPortal)
 {
     switch (guiVar.UiComponent)
     {
         case "ImageUpload()":
             SkinManagerHelper.UpdateDynamicImage(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, dataPath, guiVar.PropertyName, isPortal);
             break;
         case "ChoiceSelector()":
             var replaceValues = guiVar.PropertyName.Split(',');
             if (replaceValues.Length != 2) throw new Exception("Choice Selections must provide values for selected and unselected in PropertyName (e.g. 'block,none')");
             var replacementValue = preferences.DynamicGuiVariables[guiVar.ComponentName] == "true" ? replaceValues[0]  : replaceValues[1];
             SkinManagerHelper.UpdateSkinDynamicVariable(replacementValue, skinFolderPath, guiVar.Substitution, guiVar.PropertyName, isPortal);
             break;
         default:
             SkinManagerHelper.UpdateSkinDynamicVariable(preferences.DynamicGuiVariables[guiVar.ComponentName],
                 skinFolderPath, guiVar.Substitution, guiVar.PropertyName, isPortal);
             break;
     }
 }