コード例 #1
0
        public ActionResult Index(LoginPreferences loginPreferences)
        {
            var preferencesModel = new PreferencesModel();

            var mainDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Content\Skins\Templates");
            int templateCount = mainDir.GetDirectories().Count(dir => (dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden);
            preferencesModel.HdnLayoutCount = templateCount.ToString();

            preferencesModel.QuestionnaireSelectList = new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)), "PxmlName", "PxmlName");

            preferencesModel.QuickPollVisible = true;
            preferencesModel.NewsletterVisible = true;

            //---- Code commented by Optimus : Code was used for the static controls on the web page---
            /*
            preferencesModel.PrimaryTextHexCode = "000000";
            preferencesModel.SecondaryTextHexCode = "333333";
            preferencesModel.PageBackgroundHexCode = "FFFFFF";
            preferencesModel.ContentBackgroundHexCode = "FFFFFF";
            */
            preferencesModel.PanelAdminUrl = loginPreferences.PanelAdminUrl;
            preferencesModel.PanelAdminEmail = loginPreferences.PanelAdminEmail;
            preferencesModel.PanelPassword = loginPreferences.PanelPassword;
            preferencesModel.OfflineMode = loginPreferences.OfflineMode;

            // Clear session variable
            Session[Res.SessionTemplates] = null;

            return View(preferencesModel);
        }
コード例 #2
0
        public ActionResult Index(LoginPreferences loginPreferences)
        {
            var preferencesModel = new PreferencesModel();

            var mainDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Content\Skins\Templates");
            int templateCount = mainDir.GetDirectories().Count(dir => (dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden);
            preferencesModel.HdnLayoutCount = templateCount.ToString();

            var lstOffline = new List<SelectListItem>();
            preferencesModel.AvailableContextSelectList = new SelectList(lstOffline);

            //Added for availablecontext
            if (!loginPreferences.OfflineMode)
            {

                var preferences = new PanelPreferences
                                      {
                                          PanelAdminEmail = loginPreferences.PanelAdminEmail,
                                          PanelAdminUrl = loginPreferences.PanelAdminUrl,
                                          PanelPassword = loginPreferences.PanelPassword
                                      };
                preferences.CookieJar = _automationService.GetCookieJar(preferences);
                preferences.ContextCollection = _automationService.GetContextCollection(preferences.CookieJar);
                var contextItemList = _automationService.GetAllContextItemsList(preferences);
                var lstAdvancedMode = new List<SelectListItem>();
                foreach (var contextItem in contextItemList)
                {
                    string[] contextInfo = { contextItem.ContextInfo.ContextIndex.ToString(), contextItem.ContextInfo.Culture, contextItem.ContextInfo.Environment, contextItem.ContextInfo.OpenPortalLiveBaseUrl, contextItem.ContextInfo.SubDomain, contextItem.ContextInfo.OpenPortalTestBaseUrl };
                    string contextValues = string.Join(Constants.Separator, contextInfo);
                    lstAdvancedMode.Add(new SelectListItem { Text = contextItem.ContextName, Value = contextValues });
                }

                preferencesModel.AvailableContextSelectList = lstAdvancedMode;
                Session["Collection"] = preferences.ContextCollection;
                Session["CookieJar"] = preferences.CookieJar;

            }

            preferencesModel.QuestionnaireSelectList = new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)), "PxmlName", "PxmlName");

            preferencesModel.QuickPollVisible = true;
            preferencesModel.NewsletterVisible = true;

            //---- Code commented by Optimus : Code was used for the static controls on the web page---
            /*
            preferencesModel.PrimaryTextHexCode = "000000";
            preferencesModel.SecondaryTextHexCode = "333333";
            preferencesModel.PageBackgroundHexCode = "FFFFFF";
            preferencesModel.ContentBackgroundHexCode = "FFFFFF";
            */
            preferencesModel.PanelAdminUrl = loginPreferences.PanelAdminUrl;
            preferencesModel.PanelAdminEmail = loginPreferences.PanelAdminEmail;
            preferencesModel.PanelPassword = loginPreferences.PanelPassword;
            preferencesModel.OfflineMode = loginPreferences.OfflineMode;

            // Clear session variable by Optimus
            Session[Res.SessionTemplates] = null;

            return View(preferencesModel);
        }
コード例 #3
0
        public ActionResult Index(LoginPreferences loginPreferences)
        {
            var preferencesModel = new PreferencesModel();

            var mainDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Content\Skins\Templates");
            int templateCount = mainDir.GetDirectories().Count(dir => (dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden);
            preferencesModel.HdnLayoutCount = templateCount.ToString();

            preferencesModel.QuestionnaireSelectList = new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)), "PxmlName", "PxmlName");

            preferencesModel.PanelAdminUrl = loginPreferences.PanelAdminUrl;
            preferencesModel.PanelAdminEmail = loginPreferences.PanelAdminEmail;
            preferencesModel.PanelPassword = loginPreferences.PanelPassword;
            preferencesModel.OfflineMode = loginPreferences.OfflineMode;

            // Clear session variable by Optimus
            Session[Res.SessionTemplates] = null;

            return View(preferencesModel);
        }
コード例 #4
0
        public ActionResult SaveAndContinue(FormCollection formCollection, PreferencesModel model, string returnUrl, HttpPostedFileBase headerFile, HttpPostedFileBase logoFile, IEnumerable<HttpPostedFileBase> postedImages)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var preferences = new PanelPreferences
                                          {
                                              HdnSelectedLayout = model.HdnSelectedLayout,
                                              QuestionnaireName = model.QuestionnaireId,
                                              CompanyName = model.CompanyName,
                                              ContactEmail = model.ContactEmail,
                                              //---- Code commented by Optimus : Code was used for the static controls on the web page---
                                              /*
                                              PageBackgroundHexCode = model.PageBackgroundHexCode,
                                              ContentBackgroundHexCode = model.ContentBackgroundHexCode,
                                              PrimaryTextHexCode = model.PrimaryTextHexCode,
                                              SecondaryTextHexCode = model.SecondaryTextHexCode,
                                               */
                                              NewsletterVisible = model.NewsletterVisible,
                                              QuickPollVisible = model.QuickPollVisible,
                                              PanelAdminEmail = model.PanelAdminEmail,
                                              PanelAdminUrl = model.PanelAdminUrl,
                                              PanelPassword = model.PanelPassword,
                                              OfflineMode = model.OfflineMode,
                                              Language = model.Language
                                          };

                    // Populate PanelPreferences with the dynamic GUI control values
                    if (Session[Res.SessionTemplates] == null)
                    {
                        Session[Res.SessionTemplates] = TemplateManager.Instance.LoadTemplates();
                    }
                    var temps = (DynamicGuiTemplates)Session[Res.SessionTemplates];
                    var currentTemplate = temps.GuiTemplates[model.Counter];

                    // Set the current Template
                    preferences.CurrentGuiTemplate = currentTemplate;
                    preferences.DynamicGuiVariables = new Dictionary<string, string>();
                    foreach (GuiVariableGroup group in currentTemplate.VariableGroups)
                    {
                        foreach (GuiVariable guiVar in group.Variables)
                        {
                            if (group.GroupName.Equals(Res.ImagesGroup))
                            {
                                preferences.DynamicGuiVariables.Add(guiVar.ComponentName, formCollection["Hdn" + guiVar.ComponentName]);
                            }
                            else if (group.GroupName.Equals(Res.ChoiceGroup))
                            {
                                preferences.DynamicGuiVariables.Add(guiVar.ComponentName,Convert.ToBoolean(formCollection[guiVar.ComponentName]).ToString());
                            }
                            else
                            {
                                preferences.DynamicGuiVariables.Add(guiVar.ComponentName, formCollection[guiVar.ComponentName]);
                            }
                        }
                    }

                    // Added for moving all dynamic upload control images to 'Uploads' folder
                    foreach (HttpPostedFileBase imageFile in postedImages)
                    {
                        var path = Path.Combine(Server.MapPath(Res.UploadsDirectoryPath), Path.GetFileName(imageFile.FileName));
                        imageFile.SaveAs(path);
                    }

                    //---- Code commented by Optimus : Code was used for the static controls on the web page---
                    /*
                    if (null != headerFile && headerFile.ContentLength > 0)
                    {
                        preferences.HeaderFileName = Path.GetFileName(headerFile.FileName);
                        var path = Path.Combine(Server.MapPath(Res.UploadsDirectoryPath), preferences.HeaderFileName);
                        headerFile.SaveAs(path);
                    }

                    if (null != logoFile && logoFile.ContentLength > 0)
                    {
                        preferences.LogoFileName = Path.GetFileName(logoFile.FileName);
                        var path = Path.Combine(Server.MapPath(Res.UploadsDirectoryPath), preferences.LogoFileName);
                        logoFile.SaveAs(path);
                    }
                     */
                    LinkInfo linkInfo = _automationService.SetUpContext(preferences,
                                                                          Server.MapPath(Res.SkinsDirectoryPath));
                    OfflineLinks offlineLinks = _automationService.CreateSkin(preferences, Server.MapPath(Res.SkinsDirectoryPath),
                                                                              Server.MapPath(Res.DataDirectoryPath), linkInfo.FolderName);

                    var testLinkModel = new TestLinkModel
                                            {
                                                PortalLink = offlineLinks.portalLink,
                                                SurveyLink = offlineLinks.surveyLink
                                            };

                    // Code to be executed while in Advanced mode
                    if (!preferences.OfflineMode)
                    {
                        _automationService.UploadSkins(preferences, Server.MapPath(Res.SkinsDirectoryPath));
                        linkInfo.Surveylink = _automationService.CreateSurveyTestLink(preferences,
                                                                                      Server.MapPath(Res.PQsDirectoryPath));
                        ViewData["PreferencesModel.QuestionnaireId"] = new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)), "PxmlName", "PxmlName");

                        testLinkModel.PortalLink = HttpUtility.UrlDecode(linkInfo.PortalLink) +
                                                         HttpUtility.UrlDecode(linkInfo.FolderName);
                        testLinkModel.SurveyLink = linkInfo.Surveylink;
                    }
                    return View("Links", testLinkModel);
                }

                ViewData["PreferencesModel.QuestionnaireId"] =
                    new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)),
                                   "PxmlName", "PxmlName");

                return View("Index", model);
            }
            catch (Exception e)
            {
                var errorModel = new ErrorModel { Exception = e };
                return View("Error", errorModel);
            }
        }
コード例 #5
0
        public ActionResult SaveAndContinue(FormCollection formCollection, PreferencesModel model, IEnumerable<HttpPostedFileBase> postedFiles)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var preferences = new PanelPreferences
                                          {
                                              HdnSelectedLayout = model.HdnSelectedLayout,
                                              HdnSelectedLayoutName = model.HdnSelectedLayoutName, // Added by Khushbu For pahse2 task 'Allow the UI to load previously generated zip files in order to pre-populate the form'.
                                              QuestionnaireName = model.QuestionnaireId,
                                              CompanyName = model.CompanyName,
                                              ContactEmail = model.ContactEmail,
                                              PanelAdminEmail = model.PanelAdminEmail,
                                              PanelAdminUrl = model.PanelAdminUrl,
                                              PanelPassword = model.PanelPassword,
                                              OfflineMode = model.OfflineMode,
                                              Language = model.Language
                                          };

                    // Populate PanelPreferences with the dynamic GUI control values by Optimus
                    if (Session[Res.SessionTemplates] == null)
                    {
                        Session[Res.SessionTemplates] = TemplateManager.Instance.LoadTemplates();
                    }
                    var temps = (DynamicGuiTemplates)Session[Res.SessionTemplates];
                    var currentTemplate = temps.GuiTemplates[model.Counter];

                    // Set the current Template by Optimus
                    preferences.CurrentGuiTemplate = currentTemplate;
                    preferences.DynamicGuiVariables = new Dictionary<string, string>();
                    foreach (GuiVariableGroup group in currentTemplate.VariableGroups)
                    {
                        if (group.Variables == null) continue;
                        foreach (GuiVariable guiVar in group.Variables)
                        {
                            // Modified by K.G(07-12-2011) to support file upload controlS for all the groups.
                            switch (guiVar.UiComponent)
                            {
                                case Constants.FileComponent:
                                    preferences.DynamicGuiVariables.Add(guiVar.ComponentName,
                                                                        formCollection["Hdn" + guiVar.ComponentName]);
                                    break;
                                case Constants.ChoiceComponent:
                                    preferences.DynamicGuiVariables.Add(guiVar.ComponentName,
                                                                        Convert.ToBoolean(
                                                                            formCollection[guiVar.ComponentName]).
                                                                            ToString().ToLower()); // Made changes to resolve the defect as checkboxes didn’t retain  selections in case of load from zip.
                                    break;
                                default:
                                    preferences.DynamicGuiVariables.Add(guiVar.ComponentName,
                                                                        formCollection[guiVar.ComponentName]);
                                    break;
                            }

                        }
                    }

                    // Added for moving all dynamic upload control images to 'Uploads' folder by Optimus
                    foreach (HttpPostedFileBase file in postedFiles)
                    {
                        var path = Path.Combine(Server.MapPath(Res.UploadsDirectoryPath), Path.GetFileName(file.FileName)); // Modified by Khushbu For pahse2 task 'Support upload/processing of non-image files (e.g. pdf)'.
                        file.SaveAs(path);
                    }

                    var linkInfo = _automationService.SetUpContext(preferences, Server.MapPath(Res.SkinsDirectoryPath));

                    //Code modified by Optimus
                    var SkinPackageLink = _automationService.CreateSkin(preferences, Server.MapPath(Res.SkinsDirectoryPath),
                                                                              Server.MapPath(Res.DataDirectoryPath), linkInfo.FolderName);

                    var testLinkModel = new TestLinkModel
                                            {
                                                SkinPackageLink = this.UrlForFile(SkinPackageLink) // Modified by Khushbu For pahse2 task 'Allow the UI to load previously generated zip files in order to pre-populate the form'.

                                            };

                    // Code to be executed while in Advanced mode by Optimus
                    if (!preferences.OfflineMode)
                    {

                        // Added by K.G(07/12/11) to upload email templates on Sparq
                        _automationService.UploadEmailTemplates(preferences, Server.MapPath(Res.SkinsDirectoryPath),
                                                                             Server.MapPath(Res.DataDirectoryPath), linkInfo.FolderName);
                        _automationService.UploadSkins(preferences, Server.MapPath(Res.SkinsDirectoryPath), linkInfo.FolderName);

                        linkInfo.Surveylink = _automationService.CreateSurveyTestLink(preferences,
                                                                                      Server.MapPath(Res.PQsDirectoryPath));
                        ViewData["PreferencesModel.QuestionnaireId"] = new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)), "PxmlName", "PxmlName");

                        testLinkModel.PortalLink = HttpUtility.UrlDecode(linkInfo.PortalLink) +
                                                         HttpUtility.UrlDecode(linkInfo.FolderName);
                        testLinkModel.SurveyLink = linkInfo.Surveylink;
                    }

                    // Added By K.G(25/11/2011) to delete extra zip files.
                    _automationService.DeleteUnusedZipFiles(Server.MapPath(Res.SkinsDirectoryPath));

                    return View("Links", testLinkModel);
                }

                ViewData["PreferencesModel.QuestionnaireId"] =
                    new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)),
                                   "PxmlName", "PxmlName");

                return View("Index", model);
            }
            catch (Exception e)
            {
                var errorModel = new ErrorModel { Exception = e };
                return View("Error", errorModel);
            }
        }
コード例 #6
0
        public ActionResult SaveAndContinue(FormCollection formCollection, PreferencesModel model, string returnUrl, HttpPostedFileBase headerFile, HttpPostedFileBase logoFile, IEnumerable<HttpPostedFileBase> postedImages)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var preferences = new PanelPreferences
                                          {
                                              HdnSelectedLayout = model.HdnSelectedLayout,
                                              QuestionnaireName = model.QuestionnaireId,
                                              CompanyName = model.CompanyName,
                                              ContactEmail = model.ContactEmail,
                                              PanelAdminEmail = model.PanelAdminEmail,
                                              PanelAdminUrl = model.PanelAdminUrl,
                                              PanelPassword = model.PanelPassword,
                                              OfflineMode = model.OfflineMode,
                                              Language = model.Language
                                          };

                    // Populate PanelPreferences with the dynamic GUI control values by Optimus
                    if (Session[Res.SessionTemplates] == null)
                    {
                        Session[Res.SessionTemplates] = TemplateManager.Instance.LoadTemplates();
                    }
                    var temps = (DynamicGuiTemplates)Session[Res.SessionTemplates];
                    var currentTemplate = temps.GuiTemplates[model.Counter];

                    // Set the current Template by Optimus
                    preferences.CurrentGuiTemplate = currentTemplate;
                    preferences.DynamicGuiVariables = new Dictionary<string, string>();
                    foreach (GuiVariableGroup group in currentTemplate.VariableGroups)
                    {
                        if (group.Variables == null) continue;
                        foreach (GuiVariable guiVar in group.Variables)
                        {

                            switch (group.GroupName)
                            {
                                case Constants.ImagesGroup:
                                    preferences.DynamicGuiVariables.Add(guiVar.ComponentName,
                                                                        formCollection["Hdn" + guiVar.ComponentName]);
                                    break;
                                case Constants.ChoiceGroup:
                                    preferences.DynamicGuiVariables.Add(guiVar.ComponentName,
                                                                        Convert.ToBoolean(
                                                                            formCollection[guiVar.ComponentName]).
                                                                            ToString());
                                    break;
                                default:
                                    preferences.DynamicGuiVariables.Add(guiVar.ComponentName,
                                                                        formCollection[guiVar.ComponentName]);
                                    break;
                            }

                        }
                    }

                    // Added for moving all dynamic upload control images to 'Uploads' folder by Optimus
                    foreach (HttpPostedFileBase imageFile in postedImages)
                    {
                        var path = Path.Combine(Server.MapPath(Res.UploadsDirectoryPath), Path.GetFileName(imageFile.FileName));
                        imageFile.SaveAs(path);
                    }

                    var linkInfo = _automationService.SetUpContext(preferences, Server.MapPath(Res.SkinsDirectoryPath));

                    //Code modified by Optimus
                    var offlineLinks = _automationService.CreateSkin(preferences, Server.MapPath(Res.SkinsDirectoryPath),
                                                                              Server.MapPath(Res.DataDirectoryPath), linkInfo.FolderName);

                    var testLinkModel = new TestLinkModel
                                            {
                                                PortalLink = this.UrlForFile(offlineLinks.portalLink),
                                                SurveyLink = this.UrlForFile(offlineLinks.surveyLink)
                                            };

                    // Code to be executed while in Advanced mode by Optimus
                    if (!preferences.OfflineMode)
                    {
                        _automationService.UploadSkins(preferences, Server.MapPath(Res.SkinsDirectoryPath));
                        linkInfo.Surveylink = _automationService.CreateSurveyTestLink(preferences,
                                                                                      Server.MapPath(Res.PQsDirectoryPath));
                        ViewData["PreferencesModel.QuestionnaireId"] = new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)), "PxmlName", "PxmlName");

                        testLinkModel.PortalLink = HttpUtility.UrlDecode(linkInfo.PortalLink) +
                                                         HttpUtility.UrlDecode(linkInfo.FolderName);
                        testLinkModel.SurveyLink = linkInfo.Surveylink;
                    }
                    return View("Links", testLinkModel);
                }

                ViewData["PreferencesModel.QuestionnaireId"] =
                    new SelectList(_automationService.PxmlManager.GetPxmlList(Server.MapPath(Res.PQsDirectoryPath)),
                                   "PxmlName", "PxmlName");

                return View("Index", model);
            }
            catch (Exception e)
            {
                var errorModel = new ErrorModel { Exception = e };
                return View("Error", errorModel);
            }
        }