public static CookieJar StudyQuestionnairePostToDeployments(CookieJar cookieJar, PanelPreferences preferences)
        {
            var studyQuestionnaireViewUrl = new Uri(preferences.PanelAdminUrl + "StudyQuestionnaireView.aspx");

            string questionnaireViewToDeployFormParams = GetQuestionnaireViewToDeployFormParams(studyQuestionnaireViewUrl, cookieJar.SourceCode);
            var bytes = Encoding.ASCII.GetBytes(questionnaireViewToDeployFormParams);

            var questionnaireViewToDeployRequest = AutomationHelper.CreatePost(studyQuestionnaireViewUrl, cookieJar);
            questionnaireViewToDeployRequest.Referer = preferences.PanelAdminUrl + "HomeView.aspx";
            questionnaireViewToDeployRequest.ContentLength = bytes.Length;

            using (Stream os = questionnaireViewToDeployRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)questionnaireViewToDeployRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            string pageSource = String.Empty;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                pageSource = reader.ReadToEnd();
            }

            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
            return cookieJar;
        }
        public static CookieJar ValidateStudyPost(CookieJar cookieJar, PanelPreferences preferences)
        {
            var studyQuestionnaireViewUrl = new Uri(preferences.PanelAdminUrl + "StudyQuestionnaireView.aspx");
            string questionnaireViewFormParams = GetQuestionnaireViewFormParams(studyQuestionnaireViewUrl, cookieJar.SourceCode);
            var bytes = Encoding.ASCII.GetBytes(questionnaireViewFormParams);

            var questionnaireViewRequest = AutomationHelper.CreatePost(studyQuestionnaireViewUrl, cookieJar);
            questionnaireViewRequest.Referer = preferences.PanelAdminUrl + "HomeView.aspx";
            questionnaireViewRequest.ContentLength = bytes.Length;

            questionnaireViewRequest.Headers.Add("Cookie", "ASP.NET_SessionId=" + cookieJar.AspNetSessionId + "; .VCPanelAuth=" + cookieJar.VcAuthentication + "; " + ".reqid=" + cookieJar.UniqueRequestId + "; " + " .vcmach=" + cookieJar.MachineId);

            using (Stream os = questionnaireViewRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)questionnaireViewRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            string pageSource = String.Empty;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                pageSource = reader.ReadToEnd();
            }

            cookieJar.SourceCode = pageSource;
            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
            return cookieJar;
        }
Example #3
0
        public static CookieJar HomeViewGet(CookieJar cookieJar, PanelPreferences preferences)
        {
            var client = new WebClient();

            client.Headers.Add("Pragma", "no-cache");
            client.Headers.Add("Accept", "text/html, application/xhtml+xml, */*");
            client.Headers.Add("Accept-Encoding", "gzip, deflate");
            client.Headers.Add("Accept-Language", "en-US");
            client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
            client.Headers.Add("Referer", preferences.PanelAdminUrl + "HomeView.aspx");

            client.Headers.Add("Cookie", "ASP.NET_SessionId=" + cookieJar.AspNetSessionId + "; .VCPanelAuth=" + cookieJar.VcAuthentication + ";");

            var source = client.DownloadString(preferences.PanelAdminUrl + "ChangePasswordView.aspx");

            string cookies = client.ResponseHeaders["Set-Cookie"];

            cookieJar.MachineId = AutomationHelper.GetVcMach(cookies);
            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            client.Dispose();

            return cookieJar;
        }
Example #4
0
        public static CookieJar HomeViewPostToPanelSettingsManager(CookieJar cookieJar, PanelPreferences preferences)
        {
            //Added for Panel settings will be fecthed from UI not from WebConfig
            var homeViewUrl = new Uri(preferences.PanelAdminUrl + "HomeView.aspx");
            string homeViewFormParams = GetHomeViewFormParams();
            var bytes = Encoding.ASCII.GetBytes(homeViewFormParams);

            var homeViewRequest = AutomationHelper.CreatePost(homeViewUrl, cookieJar);
            homeViewRequest.Referer = preferences.PanelAdminUrl + "HomeView.aspx";
            homeViewRequest.ContentLength = bytes.Length;

            using (Stream os = homeViewRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)homeViewRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            string pageSource = String.Empty;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                pageSource = reader.ReadToEnd();
            }

            cookieJar.SourceCode = pageSource;
            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
            return cookieJar;
        }
        public ContextCollection GetContextCollection(PanelPreferences preferences)
        {
            CookieJar = preferences.CookieJar;
            ContextCollection collection;
            try
            {
                if (CookieJar.SourceCode.IndexOf("Settings are locked by VcAdmin") > 0)
                {
                    throw new Exception("Settings are currently locked, navigate away from settings, recycle or wait");
                }
                collection = new ContextCollection(CookieJar.SourceCode);
            }
            catch (Exception e)
            {
                // attempt to Navigate away to attempt not to lock panel settings
                try
                {
                    PanelSettingsManagement.PanelSettingsPostToAssetManager(CookieJar, preferences);
                }
                catch (Exception) { }
                throw e;
            }

            return collection;
        }
        public LinkInfo SetUpContext(PanelPreferences preferences, string skinFolderPath)
        {
            // Offline and Advanced mode Changes

            var linkInfo = new LinkInfo {FolderName = Res.FolderName};
            if (!preferences.OfflineMode)
            {
                CookieJar = Login(preferences);

                CookieJar = Home.HomeViewPostToPanelSettingsManager(CookieJar, preferences);  //Source code here contains the Panel Settings Form

                var collection = new ContextCollection(CookieJar.SourceCode);

                ContextInfo contextInfo = collection.FindAvailableContext();
                Environment = contextInfo.Environment;

                collection.UpdateFormValue(contextInfo.ContextIndex, -1, "OpenPortalSkinFolder", contextInfo.SubDomain);
                collection.UpdateFormValue(contextInfo.ContextIndex, -1, "PortalSkinPath", Res.PortalSkinPathParent + "/" + contextInfo.SubDomain + "/");
                collection.UpdateFormValue(contextInfo.ContextIndex, -1, "IsHidden", "False");
                collection.UpdateFormValue(contextInfo.ContextIndex, -1, "Name", preferences.CompanyName + " Portal");
                // Added for Language selection
                collection.UpdateFormValue(contextInfo.ContextIndex, -1, "Culture", preferences.Language);

                PanelSettingsManagement.PanelSettingsUpdatePost(CookieJar, collection, preferences);
                linkInfo.FolderName = contextInfo.SubDomain;
                linkInfo.PortalLink = contextInfo.OpenPortalTestBaseUrl; //TODO CHANGE TO LIVE LINK
            }
            return linkInfo;
        }
        public static void CommunicationPostToAssetManager(PanelPreferences preferences)
        {
            var communicationViewUrl = new Uri(preferences.PanelAdminUrl + "CommunicationsManagementView.aspx");
            string panelSettingsViewFormParams = GetCommunicationToAssetManagerFormParams();
            var bytes = Encoding.ASCII.GetBytes(panelSettingsViewFormParams);

            var homeViewRequest = AutomationHelper.CreatePost(communicationViewUrl, preferences.CookieJar);
            homeViewRequest.Referer = preferences.PanelAdminUrl + "CommunicationsManagementView.aspx";
            homeViewRequest.ContentLength = bytes.Length;

            using (Stream os = homeViewRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)homeViewRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            string pageSource = String.Empty;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                pageSource = reader.ReadToEnd();
            }

            preferences.CookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
        }
        public static CookieJar AuthenticationPost(string viewState, CookieJar cookieJar, PanelPreferences preferences)
        {
            var authenticationViewUrl = new Uri(preferences.PanelAdminUrl + "AuthenticationView.aspx");
            string authenticationFormParams = GetAuthFormParams(viewState, preferences);
            byte[] bytes = Encoding.ASCII.GetBytes(authenticationFormParams);

            var authenticationRequest = AutomationHelper.CreatePost(authenticationViewUrl, cookieJar);
            authenticationRequest.Headers.Remove("Cookie");
            authenticationRequest.Referer = preferences.PanelAdminUrl + "AuthenticationView.aspx";
            authenticationRequest.ContentLength = bytes.Length;
            authenticationRequest.AllowAutoRedirect = false;

            using (Stream os = authenticationRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)authenticationRequest.GetResponse();

            string cookies = response.Headers["Set-Cookie"];

            cookieJar.AspNetSessionId = AutomationHelper.GetSessionId(cookies);
            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);

            response.Close();

            return cookieJar;
        }
        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);
        }
Example #10
0
        private static string GetUpdateLanguageAndSkinPostForms(string environment, PanelPreferences preferences)
        {
            const string eventTarget = "ApplyButton";
            string eventArgument = String.Empty;
            const string vcViewState = "13";
            string viewState = String.Empty;
            const string ctlCurrentXPos = "0";
            const string ctlCurrentYPos = "0";
            const string loggingOut = "false";
            string oPersistObject_FormElement = String.Empty;
            string nmPick = String.Empty;
            string ctl_NM_ContextData = String.Empty;
            string ctl_onlineHelpMenu = String.Empty;
            const string stabs = "%7B%22State%22%3A%7B%7D%2C%22TabState%22%3A%7B%22sTabs_ctl06%22%3A%7B%22Selected%22%3Atrue%7D%7D%7D";
            string openDateValue = String.Empty;
            string closeDateValue = String.Empty;
            const string languageDropDownInput = "English+%28US%29+%28default%29";

            //Edited  for Language Selection
            //string languageDropDownValue = "en-CA";
            string languageDropDownValue = preferences.Language;
            const string languageDropDownText = "English+%28US%29+%28default%29";
            string languageDropDownClientWidth = String.Empty;
            string languageDropDownClientHeight = String.Empty;
            string environmentDropDownInput = environment;
            string environmentDropDownValue = String.Empty;
            string environmentDropDownText = environment;
            string environmentDropDownClientWidth = String.Empty;
            string environmentDropDownClientHeight = String.Empty;

            var builder = new StringBuilder();
            builder.Append("__EVENTTARGET=" + eventTarget);
            builder.Append("&__EVENTARGUMENT=" + eventArgument);
            builder.Append("&__VisionCriticalVIEWSTATE=" + vcViewState);
            builder.Append("&__VIEWSTATE=" + viewState);
            builder.Append("&ctl08%24CurrentXPos=" + ctlCurrentXPos);
            builder.Append("&ctl08%24CurrentYPos=" + ctlCurrentYPos);
            builder.Append("&LogginOut=" + loggingOut);
            builder.Append("&oPersistObject_FormElement=" + oPersistObject_FormElement);
            builder.Append("&nmPick=" + nmPick);
            builder.Append("&ctl08_NM_ContextData=" + ctl_NM_ContextData);
            builder.Append("&ctl08_OnlineHelpCtxMenu_ContextData=" + ctl_onlineHelpMenu);
            builder.Append("&sTabs=" + stabs);
            builder.Append("&OpenDate%24DateValue=" + openDateValue);
            builder.Append("&CloseDate%24DateValue=" + closeDateValue);
            builder.Append("&CascadingContext%24LanguageDropDown_Input=" + languageDropDownInput);
            builder.Append("&CascadingContext%24LanguageDropDown_value=" + languageDropDownValue);
            builder.Append("&CascadingContext%24LanguageDropDown_text=" + languageDropDownText);
            builder.Append("&CascadingContext%24LanguageDropDown_clientWidth=" + languageDropDownClientWidth);
            builder.Append("&CascadingContext%24LanguageDropDown_clientHeight=" + languageDropDownClientHeight);
            builder.Append("&CascadingContext%24EnvironmentDropDown_Input=" + environmentDropDownInput);
            builder.Append("&CascadingContext%24EnvironmentDropDown_value=" + environmentDropDownValue);
            builder.Append("&CascadingContext%24EnvironmentDropDown_text=" + environmentDropDownText);
            builder.Append("&CascadingContext%24EnvironmentDropDown_clientWidth=" + environmentDropDownClientWidth);
            builder.Append("&CascadingContext%24EnvironmentDropDown_clientHeight=" + environmentDropDownClientHeight);

            return builder.ToString();
        }
Example #11
0
 private static string GetAuthFormParams(string viewState,PanelPreferences preferences)
 {
     const string eventTarget = "LoginBtn";
     const string eventArgument = "";
     string emailText = preferences.PanelAdminEmail;
     string passwordText =PasswordUtill.Decrypt(preferences.PanelPassword);
     string formParameters = String.Format("__EVENTTARGET={0}&__EVENTARGUMENT={1}&__VIEWSTATE={2}&eMailText={3}&PasswordText={4}", eventTarget, eventArgument, viewState, emailText, passwordText);
     return formParameters;
 }
 public OfflineLinks CreateSkin(PanelPreferences preferences, string skinFolderPath, string appDataPath, string newFolderName)
 {
     SkinManager.CopyGenericFilesToUploadFolders(preferences.HdnSelectedLayout, skinFolderPath);
     SkinManager.ExtractUploadFolderZipFiles(skinFolderPath);
     SkinManager.DeleteUnusedZipFiles(skinFolderPath);
     SkinManager.UpdateSkin(preferences, skinFolderPath, appDataPath);
     OfflineLinks offlineLinks = SkinManager.CompressSkinFolder(skinFolderPath, newFolderName);
     return offlineLinks;
 }
 public OfflineLinks CreateSkin(PanelPreferences preferences, string skinFolderPath, string dataPath, string newFolderName)
 {
     // TODO the template path shouldn't be under the scratch path where we create
     //      the packages. For session support the scratch folder should be independent
     // remove the old update folder
     SkinManager manager = new SkinManager(skinFolderPath);
     manager.DeleteUploadFolders();
     manager.CreateDirectoriesAndUnzipFiles(preferences.HdnSelectedLayout);
     manager.UpdateSkin(preferences, dataPath);
     OfflineLinks offlineLinks = manager.CompressNewSkins(newFolderName);
     manager.DeleteUploadFolders();
     return offlineLinks;
 }
 public string CreateSurveyTestLink(PanelPreferences preferences, string pqFolderPath)
 {
     CookieJar = AssetManager.AssetManagerPostToHomeView(CookieJar, preferences);
     CookieJar = Home.HomeViewPostToImportNewStudyView(CookieJar, preferences);
     CookieJar = ImportNewStudy.ImportNewPxmlStudy(CookieJar, PxmlManager.GetPxml(pqFolderPath, preferences.QuestionnaireName), preferences);
     CookieJar = StudyStatus.StudyStatusPostToStudyQuestionnaire(CookieJar, preferences);
     CookieJar = StudyQuestionnaire.ValidateStudyPost(CookieJar, preferences);
     CookieJar = StudyQuestionnaire.StudyQuestionnairePostToDeployments(CookieJar, preferences);
     CookieJar = StudyDeployment.DeploymentsPostToAnonymousLinkView(CookieJar, preferences);
     CookieJar = AnonymousLink.UpdateLanguageAndSkinPost(CookieJar, Environment, preferences);
     string testLink = AutomationHelper.ExtractTestLink(CookieJar.SourceCode);
     return testLink;
 }
Example #15
0
        public static string GetViewState(PanelPreferences preferences)
        {
            var client = new WebClient();

            client.Headers.Add("Pragma", "no-cache");
            client.Headers.Add("Accept", "text/html, application/xhtml+xml, */*");
            client.Headers.Add("Accept-Encoding", "gzip, deflate");
            client.Headers.Add("Accept-Language", "en-US");
            client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");

            var buffer = client.DownloadData(preferences.PanelAdminUrl + "AuthenticationView.aspx");
            string viewState = ParseViewState(Decompress(buffer));
            client.Dispose();

            return viewState;
        }
        public LinkInfo SetUpContext(PanelPreferences preferences, string skinFolderPath)
        {
            // Offline and Advanced mode Changes by Optimus

            var linkInfo = new LinkInfo {FolderName = Res.FolderName};
            if (!preferences.OfflineMode)
            {
                CookieJar = Login(preferences);

                try
                {
                    CookieJar = Home.HomeViewPostToPanelSettingsManager(CookieJar, preferences);  //Source code here contains the Panel Settings Form

                    if (CookieJar.SourceCode.IndexOf("Settings are locked by VcAdmin") > 0)
                    {
                        throw new Exception("Settings are currently locked, navigate away from settings, recycle or wait");
                    }
                    var collection = new ContextCollection(CookieJar.SourceCode);

                    ContextInfo contextInfo = collection.FindAvailableContext();
                    Environment = contextInfo.Environment;

                    collection.UpdateFormValue(contextInfo.ContextIndex, -1, "OpenPortalSkinFolder", contextInfo.FolderName());
                    collection.UpdateFormValue(contextInfo.ContextIndex, -1, "PortalSkinPath", Res.PortalSkinPathParent + "/" + contextInfo.FolderName() + "/");
                    collection.UpdateFormValue(contextInfo.ContextIndex, -1, "IsHidden", "False");
                    collection.UpdateFormValue(contextInfo.ContextIndex, -1, "Name", preferences.CompanyName + " Portal");

                    // Added for Language selection by Optimus
                    collection.UpdateFormValue(contextInfo.ContextIndex, -1, "Culture", preferences.Language);

                    PanelSettingsManagement.PanelSettingsUpdatePost(CookieJar, collection, preferences);
                    linkInfo.FolderName = contextInfo.FolderName();
                    linkInfo.PortalLink = contextInfo.OpenPortalTestBaseUrl; //TODO CHANGE TO LIVE LINK
                }
                catch (Exception e)
                {
                    // attempt to Navigate away to attempt not to lock panel settings
                    try
                    {
                        PanelSettingsManagement.PanelSettingsPostToAssetManager(CookieJar, preferences);
                    }
                    catch (Exception) { }
                    throw e;
                }
            }
            return linkInfo;
        }
 public ActionResult Index(int[] selectedIndex)
 {
     try
     {
         var preferences = new PanelPreferences();
         List<ManagePanelModel> contextInformationList = new List<ManagePanelModel>();
         preferences.ContextCollection = (ContextCollection)Session["ContextCollection"];
         preferences.CookieJar = (CookieJar)Session["CookieJar"];
         preferences.PanelAdminUrl = Session["PanelAdminUrl"].ToString();
         _automationService.MakeContextAvailable(preferences, selectedIndex);
         contextInformationList = _automationService.GetUnavailableContextItemsList(preferences);
         return View(contextInformationList);
     }
     catch (Exception e)
     {
         var errorModel = new ErrorModel { Exception = e };
         return View("Error", errorModel);
     }
 }
Example #18
0
 public static void EditNewEmailTemplate(PanelPreferences preferences, EmailTemplate emailTemplate, string eid)
 {
     var communicationViewUrl = new Uri(preferences.PanelAdminUrl + "EmailWindow.aspx");
     string communicationViewFormParams = GetEmailEditViewFormParams(emailTemplate, eid);
     var bytes = Encoding.ASCII.GetBytes(communicationViewFormParams);
     var communicationsRequest = AutomationHelper.CreatePost(communicationViewUrl, preferences.CookieJar);
     communicationsRequest.Referer = preferences.PanelAdminUrl + "EmailWindow.aspx";
     communicationsRequest.ContentLength = bytes.Length;
     using (Stream os = communicationsRequest.GetRequestStream())
     {
         os.Write(bytes, 0, bytes.Length);
     }
     var response = (HttpWebResponse)communicationsRequest.GetResponse();
     string pageSource = String.Empty;
     using (var reader = new StreamReader(response.GetResponseStream()))
     {
         pageSource = reader.ReadToEnd();
     }
     response.Close();
 }
        // Modified  by Khushbu for phase 2 task 'Allow the UI to load previously generated zip files in order to pre-populate the form'.
        // Now this function will return created SkinPackage Link.
        public string CreateSkin(PanelPreferences preferences, string skinFolderPath, string dataPath, string newFolderName)
        {
            // TODO the template path shouldn't be under the scratch path where we create
            //      the packages. For session support the scratch folder should be independent
            // remove the old update folder
            SkinManager manager = new SkinManager(skinFolderPath);
            manager.DeleteUploadFolders();
            // manager.CreateDirectoriesAndUnzipFiles(preferences.HdnSelectedLayout);
            manager.CreateDirectoriesAndUnzipFiles(preferences.HdnSelectedLayoutName); // Modified by K.G. for phase 2 task.now operation  will be performed based on Template name rather than index.

            manager.UpdateSkin(preferences, dataPath);

            manager.UpdateEmailTemplates(preferences, dataPath, newFolderName);// Added by K.G(07/12/2011) to update email template files according to user entered values.

            manager.UpdateSubstitutionFile(preferences); // Added by K.G for phase 2 task. update the sbstitution file according to user selected value .

            string SkinPackageLink = manager.CompressNewSkins(newFolderName); // Added by K.G for phase 2 task. Returned only one link for created pacakage.

            return SkinPackageLink;
        }
        public static void PanelSettingsUpdatePost(ContextCollection collection, PanelPreferences preferences)
        {
            var panelSettingsViewUrl = new Uri(preferences.PanelAdminUrl + "PanelSettingsManagementView.aspx");
            string panelSettingsViewFormParams = GetPanelSettingsViewFormParams(collection.GetFormString());
            var bytes = Encoding.ASCII.GetBytes(panelSettingsViewFormParams);

            var panelSettingsRequest = AutomationHelper.CreatePost(panelSettingsViewUrl, preferences.CookieJar);
            panelSettingsRequest.Referer = preferences.PanelAdminUrl + "PanelSettingsManagementView.aspx";
            panelSettingsRequest.ContentLength = bytes.Length;

            using (Stream os = panelSettingsRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)panelSettingsRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            preferences.CookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            preferences.CookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
        }
        public List<ContextList> GetAllContextItemsList(PanelPreferences preferences)
        {
            var items = new List<ContextList>();

            foreach (var context in preferences.ContextCollection.ContextList)
            {

                ContextInfo contextInformation = preferences.ContextCollection.GetContextInformation(context.ContextItems[4].PanelSettings, context.ContextItems[2].PanelSettings, context.ContextIndex);
                string[] portalBaseUrl = contextInformation.PortalBaseUrl.Split('.');
                var contextUrl = String.Format("{0}.{1}", contextInformation.SubDomain, portalBaseUrl[1]);
                if (contextInformation.OpenPortalSkinFolder.Equals(string.Empty))
                {
                    var item = new ContextList(contextUrl + "  Available", contextInformation);
                    items.Insert(0, item);
                }
                else
                {
                    var item = new ContextList(contextUrl + "  " + contextInformation.Name, contextInformation);
                    items.Add(item);
                }
            }
            return items;
        }
Example #22
0
        public static CookieJar UpdateLanguageAndSkinPost(CookieJar cookieJar, string environment, PanelPreferences preferences)
        {
            if (environment.Length == 0 | environment == null)
            {
                throw new Exception("Invalid environment: " + environment);
            }

            var anonymousLinkViewUrl = new Uri(preferences.PanelAdminUrl + "AnonymousLinkView.aspx");

            //Passed new parameter preferences of PanelPreferences type for Language selection
            string anonymousLinkViewFormParams = GetUpdateLanguageAndSkinPostForms(environment, preferences);
            var bytes = Encoding.ASCII.GetBytes(anonymousLinkViewFormParams);

            var homeViewRequest = AutomationHelper.CreatePost(anonymousLinkViewUrl, cookieJar);
            homeViewRequest.Referer = preferences.PanelAdminUrl + "AnonymousLinkView.aspx";
            homeViewRequest.ContentLength = bytes.Length;

            using (Stream os = homeViewRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)homeViewRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            string pageSource;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                pageSource = reader.ReadToEnd();
            }

            cookieJar.SourceCode = pageSource;
            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
            return cookieJar;
        }
Example #23
0
        public static CookieJar AssetManagerDeleteNewPortalSkinZip(CookieJar cookieJar, PanelPreferences preferences)
        {
            var assetManagerUrl = new Uri(preferences.PanelAdminUrl + "AssetManagerView.aspx");
            string assetManagerDeleteFormParams = "Cart_AssetManager_MenuCallBack_Callback_Param=delete&Cart_AssetManager_MenuCallBack_Callback_Param=false|p:" + Res.NewPortalSkinPath.ToLower() + "|" + Res.NewPortalSkinPath;
            var bytes = Encoding.ASCII.GetBytes(assetManagerDeleteFormParams);

            var assetManagerRequest = AutomationHelper.CreatePost(assetManagerUrl, cookieJar);
            assetManagerRequest.Referer = preferences.PanelAdminUrl + "AssetManagerView.aspx";
            assetManagerRequest.ContentLength = bytes.Length;

            using (Stream os = assetManagerRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)assetManagerRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];

            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);

            response.Close();
            return cookieJar;
        }
 public ActionResult Index(LoginPreferences loginPreferences, string a)
 {
     try
     {
         List<ManagePanelModel> contextInformationList = new List<ManagePanelModel>();
         var preferences = new PanelPreferences();
         preferences.PanelAdminEmail = loginPreferences.PanelAdminEmail;
         preferences.PanelAdminUrl = loginPreferences.PanelAdminUrl;
         preferences.PanelPassword = loginPreferences.PanelPassword;
         preferences.CookieJar = _automationService.GetCookieJar(preferences);
         preferences.ContextCollection = _automationService.GetContextCollection(preferences);
         var list = _automationService.GetUnavailableContextItemsList(preferences);
         contextInformationList = list;
         Session["ContextCollection"] = preferences.ContextCollection;
         Session["CookieJar"] = preferences.CookieJar;
         Session["PanelAdminUrl"] = loginPreferences.PanelAdminUrl;
         return View(contextInformationList);
     }
     catch (Exception e)
     {
         var errorModel = new ErrorModel { Exception = e };
         return View("Error", errorModel);
     }
 }
Example #25
0
 public static string AddNewEmailTemplate(PanelPreferences preferences, EmailTemplate emailTemplate)
 {
     var communicationViewUrl = new Uri(preferences.PanelAdminUrl + "CommunicationsManagementView.aspx");
     string communicationViewFormParams = GetCommunicationViewFormParams(emailTemplate);
     var bytes = Encoding.ASCII.GetBytes(communicationViewFormParams);
     var communicationsRequest = AutomationHelper.CreatePost(communicationViewUrl, preferences.CookieJar);
     communicationsRequest.Referer = preferences.PanelAdminUrl + "CommunicationsManagementView.aspx";
     communicationsRequest.ContentLength = bytes.Length;
     using (Stream os = communicationsRequest.GetRequestStream())
     {
         os.Write(bytes, 0, bytes.Length);
     }
     var response = (HttpWebResponse)communicationsRequest.GetResponse();
     string pageSource = String.Empty;
     using (var reader = new StreamReader(response.GetResponseStream()))
     {
         pageSource = reader.ReadToEnd();
     }
     string cookies = response.Headers["Set-Cookie"];
     preferences.CookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
     preferences.CookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);
     response.Close();
     return pageSource;
 }
Example #26
0
        public static CookieJar AssetManagerUploadNewSurveySkin(CookieJar cookieJar, string path, PanelPreferences preferences)
        {
            var fileData = new FileStream(path, FileMode.Open, FileAccess.Read);

            var request = (HttpWebRequest)WebRequest.Create(preferences.PanelAdminUrl + "upload.axd?up=s:portal");

            request.Headers.Add("Pragma", "no-cache");
            request.Accept = "text/*";
            request.UserAgent = "Shockwave Flash";
            request.Headers.Add("Cookie", "ASP.NET_SessionId=" + cookieJar.AspNetSessionId + "; .VCPanelAuth=" + cookieJar.VcAuthentication + "; " + ".reqid=" + cookieJar.UniqueRequestId + "; " + " .vcmach=" + cookieJar.MachineId);
            request.Method = "POST";

            string boundary = "----------" + DateTime.Now.Ticks.ToString("x", CultureInfo.InvariantCulture);
            request.ContentType = "multipart/form-data; boundary=" + boundary;

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "Filename", Res.NewSurveySkinPath);
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\";filename=\"{1}\"\r\n", "Filedata", Res.NewSurveySkinPath);
            stringBuilder.AppendFormat("Content-Type: {0}\r\n\r\n", "application/octet-stream");

            byte[] header = Encoding.UTF8.GetBytes(stringBuilder.ToString());
            byte[] footer = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
            long contentLength = header.Length + fileData.Length + footer.Length;

            request.ContentLength = contentLength;

            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(header, 0, header.Length);

                var buffer = new byte[checked((uint)Math.Min(4096, (int)fileData.Length))];
                int bytesRead;
                while ((bytesRead = fileData.Read(buffer, 0, buffer.Length)) != 0)
                {
                    requestStream.Write(buffer, 0, bytesRead);
                }

                requestStream.Write(footer, 0, footer.Length);
                var response = request.GetResponse();
            }

            return cookieJar;
        }
Example #27
0
        public static CookieJar AssetManagerPostToHomeView(CookieJar cookieJar, PanelPreferences preferences)
        {
            var assetManagerViewUrl = new Uri(preferences.PanelAdminUrl + "AssetManagerView.aspx");
            string assetManagerViewFormParams = GetAssetManagerToHomeViewFormParams();
            var bytes = Encoding.ASCII.GetBytes(assetManagerViewFormParams);

            var homeViewRequest = AutomationHelper.CreatePost(assetManagerViewUrl, cookieJar);
            homeViewRequest.Referer = preferences.PanelAdminUrl + "PanelSettingsManagementView.aspx";
            homeViewRequest.ContentLength = bytes.Length;

            using (Stream os = homeViewRequest.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
            }

            var response = (HttpWebResponse)homeViewRequest.GetResponse();
            string cookies = response.Headers["Set-Cookie"];
            string pageSource = String.Empty;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                pageSource = reader.ReadToEnd();
            }

            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);
            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);

            response.Close();
            return cookieJar;
        }
        public static CookieJar ImportNewPxmlStudy(CookieJar cookieJar, string selectedStudyFile, PanelPreferences preferences)
        {
            var fileData = new FileStream(selectedStudyFile, FileMode.Open, FileAccess.Read);

            //Added for Panel settings will be fecthed from UI not from WebConfig
            var request = AutomationHelper.CreatePost(new Uri(preferences.PanelAdminUrl + "ImportNewStudyView.aspx"), cookieJar);
            string contentType = String.Empty;

            request.Referer = preferences.PanelAdminUrl + "ImportNewStudyView.aspx";

            string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x", CultureInfo.InvariantCulture);
            request.ContentType = "multipart/form-data; boundary=" + boundary;

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "__EVENTTARGET", "ImportStudyFromXmlButton");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "__EVENTARGUMENT", "");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "__VisionCriticalVIEWSTATE", "93");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "__VIEWSTATE", "");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "ctl02$CurrentXPos", "0");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "ctl02$CurrentYPos", "0");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "LoggingOut", "false");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "oPersistObject_FormElement", "");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "nmPick", "");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "ctl02_NM_ContextData", "");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "ctl02_OnlineHelpCtxMenu_ContextData", "");
            stringBuilder.AppendFormat("--{0}\r\n", boundary);
            stringBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\";filename=\"{1}\"\r\n", "XmlFileInput", Path.GetFileName(selectedStudyFile));//something.xml/.zip
            stringBuilder.AppendFormat("Content-Type: {0}\r\n\r\n", "text/xml");

            byte[] header = Encoding.UTF8.GetBytes(stringBuilder.ToString());

            var footerBuilder = new StringBuilder();
            footerBuilder.AppendFormat("\r\n--{0}\r\n", boundary);
            footerBuilder.AppendFormat("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}\r\n", "XmlStudyName", Path.GetFileNameWithoutExtension(selectedStudyFile) + "_" + DateTime.Now);//just the name of the study TODO account for multiple studies with the same name
            footerBuilder.AppendFormat("--" + boundary + "--\r\n");
            byte[] footer = Encoding.ASCII.GetBytes(footerBuilder.ToString());

            long contentLength = header.Length + fileData.Length + footer.Length;

            request.ContentLength = contentLength;
            string cookies = String.Empty;
            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(header, 0, header.Length);

                var buffer = new byte[checked((uint)Math.Min(4096, (int)fileData.Length))];
                int bytesRead = 0;
                while ((bytesRead = fileData.Read(buffer, 0, buffer.Length)) != 0)
                {
                    requestStream.Write(buffer, 0, bytesRead);
                }

                requestStream.Write(footer, 0, footer.Length);
                var response = request.GetResponse();
                cookies = response.Headers["Set-Cookie"];
            }

            cookieJar.VcAuthentication = AutomationHelper.GetVcAuthentication(cookies);
            cookieJar.UniqueRequestId = AutomationHelper.GetReqId(cookies);
            return cookieJar;
        }
 public bool UploadSkins(PanelPreferences preferences, string skinFolderPath)
 {
     string newPortalSkinPath = Path.Combine(skinFolderPath, Res.NewPortalSkinPath);
     string newSurveySkinpath = Path.Combine(skinFolderPath, Res.NewSurveySkinPath);
     CookieJar = UploadSkinsToAssetManager(newPortalSkinPath, newSurveySkinpath, preferences);
     return true;
 }
        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);
            }
        }