Example #1
0
        protected void CreateResponsesForSurvey2(VLSurveyManager surveyManager, VLSurvey survey, Int32 responses1 = 200, Int32 responses2 = 120, Int32 responses3 = 500)
        {
            var rnd         = new System.Random(965522113);
            var collector01 = surveyManager.CreateCollector(survey, CollectorType.WebLink, "collector01");
            var collector02 = surveyManager.CreateCollector(survey, CollectorType.WebLink, "collector02");
            var collector03 = surveyManager.CreateCollector(survey, CollectorType.WebLink, "collector03");

            for (int i = 1; i <= responses1; i++)
            {
                var openDate = new DateTime(2013, 8, 4, 12, 0, 0).AddHours(rnd.Next(0, 64));
                var response = surveyManager.CreateResponse(survey.SurveyId, collector01.CollectorId, null, openDate, openDate.AddMinutes(rnd.Next(4, 1441)));

                CreateResponseDetailsForSurvey2(surveyManager, response, rnd);
            }
            for (int i = 1; i <= responses2; i++)
            {
                var openDate = new DateTime(2013, 8, 8, 12, 0, 0).AddHours(rnd.Next(0, 64));
                var response = surveyManager.CreateResponse(survey.SurveyId, collector02.CollectorId, null, openDate, openDate.AddMinutes(rnd.Next(4, 1441)));

                CreateResponseDetailsForSurvey2(surveyManager, response, rnd);
            }
            for (int i = 1; i <= responses3; i++)
            {
                var openDate = new DateTime(2013, 8, 12, 12, 0, 0).AddHours(rnd.Next(0, 120));
                var response = surveyManager.CreateResponse(survey.SurveyId, collector03.CollectorId, null, openDate, openDate.AddMinutes(rnd.Next(4, 1441)));

                CreateResponseDetailsForSurvey2(surveyManager, response, rnd);
            }
        }
        void SendFile(HttpRequest request, HttpResponse response, VLSurvey survey)
        {
            try
            {
                response.ClearHeaders();
                response.Clear();
                response.Cookies.Clear();
                response.Cache.SetCacheability(HttpCacheability.NoCache);
                response.Charset = System.Text.UTF8Encoding.UTF8.WebName;

                String userAgent = HttpContext.Current.Request.Headers.Get("User-Agent");
                if (userAgent.Contains("MSIE"))
                {
                    response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(survey.AllResponsesXlsxExportName.Replace(" ", "_"), System.Text.Encoding.UTF8));
                }
                else
                {
                    response.AppendHeader("Content-Disposition", "attachment; filename=" + survey.AllResponsesXlsxExportName.Replace(" ", "_"));
                }

                response.ContentType = "application/vnd.ms-excel";


                SendFileFromFS(request, response, survey);
            }
            catch (Exception ex)
            {
                Logger.Error(HttpContext.Current.Request.RawUrl, ex);
                throw;
            }
        }
Example #3
0
 public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
 {
     Writer.AddAttribute(HtmlTextWriterAttribute.Class, "soption");
     Writer.RenderBeginTag(HtmlTextWriterTag.Div);
     {
         Writer.RenderBeginTag(HtmlTextWriterTag.Table);
         {
             if (question.UseDateTimeControls)
             {
                 RenderQuestionAsDatePicker(survey, page, question);
             }
             else
             {
                 if (question.ValidationBehavior == ValidationMode.Date1)
                 {
                     RenderQuestionAsInputControls1(survey, page, question);
                 }
                 else if (question.ValidationBehavior == ValidationMode.Date2)
                 {
                     RenderQuestionAsInputControls2(survey, page, question);
                 }
             }
         }
         Writer.RenderEndTag();
     }
     Writer.RenderEndTag();
 }
        void UploadFile(VLSurveyManager surveyManager, VLSurvey survey, StringBuilder sb)
        {
            try
            {
                HttpPostedFile oFile = Request.Files[0];
                if (oFile == null)
                {
                    throw new VLException("Κανένα αρχείο δεν έγινε upload!");
                }

                int fileLength = oFile.ContentLength;
                if (fileLength <= 0)
                {
                    throw new VLException("To αρχείο είχε μηδενικό μέγεθος!");
                }


                string postedFileName = Path.GetFileName(oFile.FileName);
                //Πρέπει να μεταφέρουμε το αρχείο στον EcmsFileManager.
                //Για να το κάνουμε αυτό το μεταφέρουμε στην μνήμη
                System.Byte[] mem          = new byte[fileLength];
                Stream        postedStream = oFile.InputStream;
                postedStream.Read(mem, 0, fileLength);


                VLFile file = surveyManager.AssignFile(survey.SurveyId, mem, postedFileName);
                sb.Append("{\"res\":\"ok\", \"msg\":\"\"}");
            }
            catch (Exception ex)
            {
                sb.AppendFormat("{{\"res\":\"error\", \"msg\":\"{0}\"}}", ex.Message);
                Logger.Error(HttpContext.Current.Request.RawUrl, ex);
            }
        }
Example #5
0
        public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            Collection <VLQuestionOption> options = SurveyManager.GetQuestionOptions(question);
            Collection <VLQuestionColumn> columns = SurveyManager.GetQuestionColumns(question);

            Writer.AddAttribute(HtmlTextWriterAttribute.Class, "matrixmanyperrow");
            Writer.RenderBeginTag(HtmlTextWriterTag.Table);

            //<thead>
            Writer.RenderBeginTag(HtmlTextWriterTag.Thead);
            Writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            Writer.RenderBeginTag(HtmlTextWriterTag.Td);
            Writer.RenderEndTag();
            foreach (VLQuestionColumn column in columns)
            {
                Writer.AddAttribute(HtmlTextWriterAttribute.Class, "ColumnText");
                Writer.RenderBeginTag(HtmlTextWriterTag.Td);
                HttpUtility.HtmlEncode(column.ColumnText, Writer);
                Writer.RenderEndTag();
            }
            Writer.RenderEndTag();
            Writer.RenderEndTag();


            //<tbody>
            foreach (VLQuestionOption option in options)
            {
                Writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                Writer.AddAttribute(HtmlTextWriterAttribute.Class, "OptionText");
                Writer.RenderBeginTag(HtmlTextWriterTag.Td);
                HttpUtility.HtmlEncode(option.OptionText, Writer);
                Writer.RenderEndTag();

                {
                    foreach (var column in columns)
                    {
                        Writer.RenderBeginTag(HtmlTextWriterTag.Td);

                        Writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");
                        Writer.AddAttribute(HtmlTextWriterAttribute.Value, "1");
                        Writer.AddAttribute(HtmlTextWriterAttribute.Name, option.HtmlOptionId + column.HtmlPartialColumnId);//ID
                        if (this.RuntimeSession != null && this.RuntimeSession[option.HtmlOptionId + column.HtmlPartialColumnId] != null)
                        {
                            Writer.AddAttribute(HtmlTextWriterAttribute.Checked, "Checked");
                        }
                        Writer.RenderBeginTag(HtmlTextWriterTag.Input);
                        Writer.RenderEndTag();


                        Writer.RenderEndTag();
                    }
                }

                Writer.RenderEndTag();
            }

            Writer.RenderEndTag();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="survey"></param>
        /// <returns></returns>
        internal static string GetSurveyPreviewURL(VLSurvey survey)
        {
            var host         = ValisSystem.Settings.Core.RuntimeEngine.Host;
            var absolutePath = GetSurveyPreviewAbsolutePath(survey);

            var url = string.Format(@"{0}{1}", host, absolutePath);

            return(string.Format("http://{0}", url));
        }
        protected void btnAddSrvy_Click(object sender, EventArgs e)
        {
            try
            {
                string surveyCreate = this.Request.Params["SrvyCreate"];
                if (string.Equals(surveyCreate, "rdbtnScratch"))
                {
                    /*
                     * Το survey που θα δημιουργηθεί ανήκει στον τρέχοντα χρήστη που είναι logged-in
                     */
                    if (Globals.UserToken.PrincipalType == PrincipalType.SystemUser)
                    {
                        throw new NotSupportedException("Α systemUser cannot create surveys!");
                    }
                    var clientUser = SystemManager.GetClientUserById(Globals.UserToken.Principal);
                    if (clientUser == null)
                    {
                        throw new VLException(string.Format("Cannot find a clientUser with UserId={0}!", Globals.UserToken.Principal));
                    }

                    var newSurvey = new VLSurvey();
                    newSurvey.Client = clientUser.Client;
                    newSurvey.Title  = this.surveyTitleCreate.Text;
                    newSurvey        = SurveyManager.CreateSurvey(newSurvey, Int16.Parse(this.surveyLanguageCreate.SelectedValue));

                    Response.Redirect(string.Format("~/clay/mysurveys/Design_Survey.aspx?surveyid={0}&language={1}", newSurvey.SurveyId, newSurvey.TextsLanguage), false);
                    this.Context.ApplicationInstance.CompleteRequest();
                }
                else
                {
                    /*
                     * Το survey που θα δημιουργηθεί ανήκει στον τρέχοντα χρήστη που είναι logged-in
                     */
                    if (Globals.UserToken.PrincipalType == PrincipalType.SystemUser)
                    {
                        throw new NotSupportedException("Α systemUser cannot create surveys!");
                    }

                    Int32  sourceSurveyId = Int32.Parse(this.surveyList.SelectedValue);
                    string newTitle       = this.surveyTitleCopy.Text;
                    Int16  languageId     = Int16.Parse(this.Request.Params[this.surveyLanguageCopy.UniqueID]);

                    var newSurvey = SurveyManager.CopySurvey(sourceSurveyId, newTitle, languageId);
                    Response.Redirect(string.Format("~/clay/mysurveys/Design_Survey.aspx?surveyid={0}&language={1}", newSurvey.SurveyId, newSurvey.TextsLanguage), false);
                    this.Context.ApplicationInstance.CompleteRequest();
                }
            }
            catch (ThreadAbortException)
            {
                //
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                this.ErrorMessage = ex.Message;
            }
        }
        /// <summary>
        /// Επιστρέφει ένα URL για την αφαίρεση του συγκεκριμένου recipient απο την address list του συγκεκριμένου πελάτη που τρέχει το survey.
        /// </summary>
        /// <param name="survey"></param>
        /// <param name="collector"></param>
        /// <param name="message"></param>
        /// <param name="recipient"></param>
        /// <returns></returns>
        internal static string GetRemoveRecipientURL(VLSurvey survey, VLCollector collector, VLMessage message, VLRecipient recipient)
        {
            var host = ValisSystem.Settings.Core.SystemPublicHostName;
            var _url = ValisSystem.Settings.Core.RemoveUrl.Url;

            var url = string.Format(@"{0}?rkey={1}&pid={2}&cid={3}&lang={4}", _url, recipient.RecipientKey, survey.PublicId, collector.CollectorId, BuiltinLanguages.PrimaryLanguage.LanguageId);

            url = string.Format("{0}/{1}", host, url).Replace("//", "/");
            return(string.Format("http://{0}", url));
        }
        private static void WriteExcelFile(VLSurveyManager surveyManager, VLSurvey survey, Collection <VLSurveyQuestionEx> questions, Collection <VLResponseEx> responses, SpreadsheetDocument spreadsheet)
        {
            //  Create the Excel file contents.  This function is used when creating an Excel file either writing
            //  to a file, or writing to a MemoryStream.
            spreadsheet.AddWorkbookPart();
            spreadsheet.WorkbookPart.Workbook = new DocumentFormat.OpenXml.Spreadsheet.Workbook();

            //  My thanks to James Miera for the following line of code (which prevents crashes in Excel 2010)
            spreadsheet.WorkbookPart.Workbook.Append(new BookViews(new WorkbookView()));

            //  If we don't add a "WorkbookStylesPart", OLEDB will refuse to connect to this .xlsx file !
            WorkbookStylesPart workbookStylesPart = spreadsheet.WorkbookPart.AddNewPart <WorkbookStylesPart>("rIdStyles");

            //Stylesheet stylesheet = new Stylesheet();
            //workbookStylesPart.Stylesheet = stylesheet;
            workbookStylesPart.Stylesheet = CreateStylesheet();
            workbookStylesPart.Stylesheet.Save();



            uint worksheetNumber = 1;

            {
                // For each worksheet you want to create
                string workSheetID   = "rId" + worksheetNumber.ToString();
                string worksheetName = "Responses";

                WorksheetPart newWorksheetPart = spreadsheet.WorkbookPart.AddNewPart <WorksheetPart>();
                newWorksheetPart.Worksheet = new DocumentFormat.OpenXml.Spreadsheet.Worksheet();

                // create sheet data
                newWorksheetPart.Worksheet.AppendChild(new DocumentFormat.OpenXml.Spreadsheet.SheetData());

                // save worksheet
                WriteDataTableToExcelWorksheet(surveyManager, survey, questions, responses, newWorksheetPart);
                newWorksheetPart.Worksheet.Save();

                // create the worksheet to workbook relation
                if (worksheetNumber == 1)
                {
                    spreadsheet.WorkbookPart.Workbook.AppendChild(new DocumentFormat.OpenXml.Spreadsheet.Sheets());
                }

                spreadsheet.WorkbookPart.Workbook.GetFirstChild <DocumentFormat.OpenXml.Spreadsheet.Sheets>().AppendChild(new DocumentFormat.OpenXml.Spreadsheet.Sheet()
                {
                    Id      = spreadsheet.WorkbookPart.GetIdOfPart(newWorksheetPart),
                    SheetId = (uint)worksheetNumber,
                    Name    = "Responses"
                });

                worksheetNumber++;
            }

            spreadsheet.WorkbookPart.Workbook.Save();
        }
 void RenderDecimal(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question, string content)
 {
     Writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
     Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Decimal");
     if (!string.IsNullOrWhiteSpace(content))
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Value, HttpUtility.HtmlEncode(content));
     }
     Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId + "OptionalInputBox_userinput");
     Writer.RenderBeginTag(HtmlTextWriterTag.Input);
     Writer.RenderEndTag();
 }
        void DeleteFile(VLSurveyManager surveyManager, VLSurvey survey, Guid fileId, StringBuilder sb)
        {
            try
            {
                surveyManager.Removefile(fileId);


                sb.Append("{\"res\":\"ok\", \"msg\":\"\"}");
            }
            catch (Exception ex)
            {
                sb.AppendFormat("{{\"res\":\"error\", \"msg\":\"{0}\"}}", ex.Message);
                Logger.Error(HttpContext.Current.Request.RawUrl, ex);
            }
        }
Example #12
0
        void AssertSurveysAreCopies(VLSurvey source, VLSurvey copy)
        {
            Assert.IsTrue(copy.Client == source.Client);
            Assert.IsTrue(copy.SurveyId != source.SurveyId);
            Assert.IsTrue(copy.Folder == source.Folder);
            Assert.IsTrue(copy.PublicId != source.PublicId);
            Assert.IsTrue(copy.Title == source.Title);
            Assert.IsTrue(copy.Theme == source.Theme);
            Assert.IsTrue(copy.Logo == source.Logo);
            //AttributeFlags
            //PageSequence
            //QuestionSequence
            //TicketSequence
            //Assert.IsTrue(copy.PrimaryLanguage == source.PrimaryLanguage);
            //Assert.IsTrue(copy.SupportedLanguagesIds == source.SupportedLanguagesIds);
            //SupportedLanguages
            Assert.IsTrue(copy.QuestionNumberingType == source.QuestionNumberingType);
            Assert.IsTrue(copy.ProgressBarPosition == source.ProgressBarPosition);
            Assert.IsTrue(copy.RequiredHighlightType == source.RequiredHighlightType);
            //DesignVersion
            Assert.IsTrue(copy.RecordedResponses == 0);
            Assert.IsNull(copy.CustomId);
            Assert.IsFalse(copy.IsBuiltIn);

            Assert.IsTrue(copy.ShowLanguageSelector == source.ShowLanguageSelector);
            Assert.IsTrue(copy.ShowWelcomePage == source.ShowWelcomePage);
            Assert.IsTrue(copy.ShowGoodbyePage == source.ShowGoodbyePage);
            Assert.IsTrue(copy.ShowCustomFooter == source.ShowCustomFooter);
            Assert.IsTrue(copy.UsePageNumbering == source.UsePageNumbering);
            Assert.IsTrue(copy.UseQuestionNumbering == source.UseQuestionNumbering);
            Assert.IsTrue(copy.UseProgressBar == source.UseProgressBar);
            Assert.IsTrue(copy.ShowSurveyTitle == source.ShowSurveyTitle);
            Assert.IsTrue(copy.ShowPageTitles == source.ShowPageTitles);
            Assert.IsFalse(copy.SaveFilesInDatabase);
            Assert.IsFalse(copy.HasCollectors);
            Assert.IsFalse(copy.HasResponses);

            //Assert.IsTrue(copy.TextsLanguage == copy.PrimaryLanguage);
            Assert.IsTrue(copy.ShowTitle == source.ShowTitle);
            Assert.IsTrue(copy.HeaderHtml == source.HeaderHtml);
            Assert.IsTrue(copy.WelcomeHtml == source.WelcomeHtml);
            Assert.IsTrue(copy.GoodbyeHtml == source.GoodbyeHtml);
            Assert.IsTrue(copy.FooterHtml == source.FooterHtml);
            Assert.IsTrue(copy.StartButton == source.StartButton);
            Assert.IsTrue(copy.PreviousButton == source.PreviousButton);
            Assert.IsTrue(copy.NextButton == source.NextButton);
            Assert.IsTrue(copy.DoneButton == source.DoneButton);
        }
        public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            Writer.AddAttribute(HtmlTextWriterAttribute.Class, "composite");
            Writer.RenderBeginTag(HtmlTextWriterTag.Div);
            {
                //Τραβάμε τις child ερωτήσεις:
                var childQuestions = SurveyManager.GetChildQuestions(question.Survey, question.QuestionId, question.TextsLanguage);

                foreach (var childQuestion in childQuestions)
                {
                    var _renderer = HtmlRenderers.GetQuestionRenderer(this.SurveyManager, this.Writer, this.RuntimeSession, childQuestion.QuestionType);
                    _renderer.RenderQuestion(survey, page, childQuestion);
                }
            }
            Writer.RenderEndTag();
        }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="survey"></param>
        /// <param name="collector"></param>
        /// <param name="recipient"></param>
        /// <param name="manualEntry"></param>
        /// <returns></returns>
        internal static string GetSurveyRuntimeURL(VLSurvey survey, VLCollector collector, VLRecipient recipient, bool manualEntry = false)
        {
            var host         = ValisSystem.Settings.Core.RuntimeEngine.Host;
            var absolutePath = GetSurveyRuntimeAbsolutePath(survey, collector, recipient, manualEntry);

            var url = string.Format(@"{0}{1}", host, absolutePath);

            if (collector.UseSSL)
            {
                return(string.Format("https://{0}", url));
            }
            else
            {
                return(string.Format("http://{0}", url));
            }
        }
 void RenderDefault(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question, string content)
 {
     Writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
     Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Generic");
     if (question.ValidationBehavior == ValidationMode.TextOfSpecificLength)
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, question.ValidationField2);
     }
     if (!string.IsNullOrWhiteSpace(content))
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Value, HttpUtility.HtmlEncode(content));
     }
     Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId + "OptionalInputBox_userinput");
     Writer.RenderBeginTag(HtmlTextWriterTag.Input);
     Writer.RenderEndTag();
 }
        public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            var options = SurveyManager.GetQuestionOptions(question);

            Writer.AddAttribute(HtmlTextWriterAttribute.Class, "DropDown");
            Writer.RenderBeginTag(HtmlTextWriterTag.Div);
            {
                Writer.AddAttribute(HtmlTextWriterAttribute.Class, "mOption");
                Writer.RenderBeginTag(HtmlTextWriterTag.Div);
                {
                    Writer.RenderBeginTag(HtmlTextWriterTag.Label);
                    HttpUtility.HtmlEncode(question.QuestionText, Writer);
                    Writer.RenderEndTag();

                    Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId);
                    Writer.RenderBeginTag(HtmlTextWriterTag.Select);

                    Writer.AddAttribute(HtmlTextWriterAttribute.Value, string.Empty);
                    Writer.RenderBeginTag(HtmlTextWriterTag.Option);
                    HttpUtility.HtmlEncode("[please select]", Writer);
                    Writer.RenderEndTag();

                    string _selectedOptionId = null;
                    if (this.RuntimeSession != null)
                    {
                        _selectedOptionId = this.RuntimeSession[question.HtmlQuestionId] as string;
                    }
                    Int32 selectedOptionId = string.IsNullOrEmpty(_selectedOptionId) == false?Int32.Parse(_selectedOptionId) : 0;

                    foreach (var option in options)
                    {
                        Writer.AddAttribute(HtmlTextWriterAttribute.Value, option.OptionId.ToString(CultureInfo.InvariantCulture));
                        if (option.OptionId == selectedOptionId)
                        {
                            Writer.AddAttribute(HtmlTextWriterAttribute.Selected, "Selected");
                        }
                        Writer.RenderBeginTag(HtmlTextWriterTag.Option);
                        HttpUtility.HtmlEncode(option.OptionText, Writer);
                        Writer.RenderEndTag();
                    }

                    Writer.RenderEndTag();
                }
                Writer.RenderEndTag();
            }
            Writer.RenderEndTag();
        }
        public void RenderQuestion2(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            Writer.AddAttribute(HtmlTextWriterAttribute.Width, "99%");
            Writer.AddAttribute(HtmlTextWriterAttribute.Class, "rangeTable");
            Writer.RenderBeginTag(HtmlTextWriterTag.Table);
            {
                //<thead>

                //<tbody>
                Writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                {
                    //FrontLabelText
                    Writer.AddAttribute(HtmlTextWriterAttribute.Width, "50%");
                    Writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    HttpUtility.HtmlEncode(question.FrontLabelText, Writer);
                    Writer.RenderEndTag();

                    for (int range = question.RangeStart.Value; range <= question.RangeEnd.Value; range++)
                    {
                        Writer.AddAttribute(HtmlTextWriterAttribute.Width, "0%");
                        Writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
                        Writer.RenderBeginTag(HtmlTextWriterTag.Td);


                        Writer.AddAttribute(HtmlTextWriterAttribute.Width, "38px");
                        Writer.RenderBeginTag(HtmlTextWriterTag.Div);
                        {
                            Writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio");
                            Writer.RenderBeginTag(HtmlTextWriterTag.Input);
                            Writer.RenderEndTag();
                        }
                        Writer.RenderEndTag();

                        Writer.RenderEndTag();
                    }

                    //AfterLabelText
                    Writer.AddAttribute(HtmlTextWriterAttribute.Width, "50%");
                    Writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    HttpUtility.HtmlEncode(question.AfterLabelText, Writer);
                    Writer.RenderEndTag();
                }
                Writer.RenderEndTag();
            }

            Writer.RenderEndTag();
        }
        protected void RenderOptionInputBox(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            var content = string.Empty;

            if (this.RuntimeSession != null)
            {
                content = this.RuntimeSession[question.HtmlQuestionId + "OptionalInputBox_userinput"] as string;
            }


            if (question.OtherFieldType == OtherFieldType.MultipleLines)
            {
                Writer.AddAttribute(HtmlTextWriterAttribute.Cols, "50");
                Writer.AddAttribute(HtmlTextWriterAttribute.Rows, "4");
                Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId + "OptionalInputBox_userinput");
                Writer.RenderBeginTag(HtmlTextWriterTag.Textarea);
                if (!string.IsNullOrWhiteSpace(content))
                {
                    Writer.Write(HttpUtility.HtmlEncode(content));
                }
                Writer.RenderEndTag();
            }
            else
            {
                if (question.ValidationBehavior == ValidationMode.WholeNumber)
                {
                    RenderWholeNumber(survey, page, question, content);
                }
                else if (question.ValidationBehavior == ValidationMode.DecimalNumber)
                {
                    RenderDecimal(survey, page, question, content);
                }
                else if (question.ValidationBehavior == ValidationMode.Date1)
                {
                    RenderDate1(survey, page, question, content);
                }
                else if (question.ValidationBehavior == ValidationMode.Date2)
                {
                    RenderDate2(survey, page, question, content);
                }
                else
                {
                    RenderDefault(survey, page, question, content);
                }
            }
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="survey"></param>
        /// <param name="collector"></param>
        /// <param name="recipient"></param>
        /// <param name="manualEntry"></param>
        /// <returns></returns>
        internal static string GetSurveyRuntimeAbsolutePath(VLSurvey survey, VLCollector collector, VLRecipient recipient, bool manualEntry)
        {
            if (collector.CollectorType != CollectorType.Email)
            {
                throw new VLException(string.Format("Collector '{0}', has wrong type!", collector.Name));
            }

            if (manualEntry == false)
            {
                var absolutePath = string.Format(@"/em/{0}/{1}/{2}/{3}/", survey.PublicId, recipient.RecipientKey, collector.CollectorId, BuiltinLanguages.GetTwoLetterISOCode(collector.TextsLanguage));
                return(absolutePath);
            }
            else
            {
                var absolutePath = string.Format(@"/emm/{0}/{1}/{2}/{3}/", survey.PublicId, recipient.RecipientKey, collector.CollectorId, BuiltinLanguages.GetTwoLetterISOCode(collector.TextsLanguage));
                return(absolutePath);
            }
        }
Example #20
0
        public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            Writer.AddAttribute(HtmlTextWriterAttribute.Class, "soption");
            Writer.RenderBeginTag(HtmlTextWriterTag.Div);


            Writer.AddAttribute(HtmlTextWriterAttribute.Cols, "50");
            Writer.AddAttribute(HtmlTextWriterAttribute.Rows, "4");
            Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId);
            Writer.RenderBeginTag(HtmlTextWriterTag.Textarea);
            if (this.RuntimeSession != null)
            {
                Writer.Write(HttpUtility.HtmlEncode(this.RuntimeSession[question.HtmlQuestionId]));
            }
            Writer.RenderEndTag();

            Writer.RenderEndTag();
        }
Example #21
0
        /// <summary>
        /// Επιστρέφει το absolutepath του συγκεκριμένου συλλέκτη/survey.
        /// <para>O συλλέκτης πρέπει να είναι τύπου WebLink</para>
        /// </summary>
        /// <param name="survey"></param>
        /// <param name="collector"></param>
        /// <param name="manualEntry"></param>
        /// <returns></returns>
        internal static string GetSurveyRuntimeAbsolutePath(VLSurvey survey, VLCollector collector, bool manualEntry)
        {
            if (collector.CollectorType != CollectorType.WebLink)
            {
                throw new VLException(string.Format("Collector '{0}', has wrong type!", collector.Name));
            }

            if (manualEntry == false)
            {
                var absolutePath = string.Format(@"/w/{0}/{1}/", collector.WebLink, BuiltinLanguages.GetTwoLetterISOCode(collector.TextsLanguage));
                return(absolutePath);
            }
            else
            {
                var absolutePath = string.Format(@"/wm/{0}/{1}/", collector.WebLink, BuiltinLanguages.GetTwoLetterISOCode(collector.TextsLanguage));
                return(absolutePath);
            }
        }
 void RenderWholeNumber(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question, string content)
 {
     Writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
     Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Integer");
     if (question.ValidationBehavior == ValidationMode.WholeNumber)
     {
         if (string.IsNullOrWhiteSpace(question.ValidationField2) == false)
         {
             Writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, (question.ValidationField2.Length + 1).ToString());
         }
     }
     if (!string.IsNullOrWhiteSpace(content))
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Value, HttpUtility.HtmlEncode(content));
     }
     Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId + "OptionalInputBox_userinput");
     Writer.RenderBeginTag(HtmlTextWriterTag.Input);
     Writer.RenderEndTag();
 }
        void SendFileFromFS(HttpRequest request, HttpResponse response, VLSurvey survey)
        {
            string acceptEncoding  = request.Headers["Accept-Encoding"];
            bool   isGzipOutput    = (!string.IsNullOrWhiteSpace(acceptEncoding) && acceptEncoding.Contains("gzip"));
            bool   isDeflateOutput = (!string.IsNullOrWhiteSpace(acceptEncoding) && acceptEncoding.Contains("deflate"));


            Stream outputStream  = null;
            bool   disposeStream = false;

            try
            {
                string filepath = GetFilePath(survey);
                string filename = survey.AllResponsesXlsxExportName;

                FileInfo fileInfo = new FileInfo(filepath);
                if (fileInfo.Exists)
                {
                    int len = (int)fileInfo.Length;

                    if (len <= TransmitFileUpperLimit)
                    {
                        response.TransmitFile(filepath);
                    }
                    else
                    {
                        StreamContent(request, response, len, System.IO.File.OpenRead(filepath));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(HttpContext.Current.Request.RawUrl, ex);
                throw;
            }
            finally
            {
                if (outputStream != null && disposeStream)
                {
                    ((IDisposable)outputStream).Dispose();
                }
            }
        }
Example #24
0
 public void RenderQuestionAsDatePicker(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
 {
     Writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
     Writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, "10");
     if (question.ValidationBehavior == ValidationMode.Date1)
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Date1");
     }
     else if (question.ValidationBehavior == ValidationMode.Date2)
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Date2");
     }
     if (this.RuntimeSession != null)
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Value, this.RuntimeSession[question.HtmlQuestionId] as string);
     }
     Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId);
     Writer.RenderBeginTag(HtmlTextWriterTag.Input);
     Writer.RenderEndTag();
 }
        void GetDirList(VLSurveyManager surveyManager, VLSurvey survey, StringBuilder sb)
        {
            var files = surveyManager.GetFiles(survey);

            sb.Append("[");

            //[
            //{"p":"/fileman/Uploads","f":"6","d":"5"},
            //{"p":"/fileman/Uploads/cccccccccc","f":"0","d":"0"},
            //{"p":"/fileman/Uploads/Documents","f":"2","d":"1"},
            //{"p":"/fileman/Uploads/Documents/Wide","f":"5","d":"0"},
            //{"p":"/fileman/Uploads/FLV","f":"0","d":"0"},
            //{"p":"/fileman/Uploads/Images","f":"5","d":"3"},{"p":"/fileman/Uploads/Images/Horizontal","f":"7","d":"0"},{"p":"/fileman/Uploads/Images/Vertical","f":"8","d":"0"},{"p":"/fileman/Uploads/Images/Wide","f":"5","d":"0"},{"p":"/fileman/Uploads/Manuals","f":"0","d":"2"},{"p":"/fileman/Uploads/Manuals/Mysql","f":"0","d":"0"},{"p":"/fileman/Uploads/Manuals/PHP","f":"0","d":"0"}
            //]
            sb.Append("{");
            //sb.AppendFormat("\"p\":\"{0}\",\"f\":\"{1}\",\"d\":\"0\"", survey.ShowTitle, files.Count);
            sb.AppendFormat("\"p\":\"survey\",\"f\":\"{0}\",\"d\":\"0\"", files.Count);
            sb.Append("}");

            sb.Append("]");
        }
Example #26
0
 public void RenderDefault(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
 {
     Writer.AddAttribute(HtmlTextWriterAttribute.Class, "soption");
     Writer.RenderBeginTag(HtmlTextWriterTag.Div);
     {
         Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Generic");
         Writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
         if (question.ValidationBehavior == ValidationMode.TextOfSpecificLength)
         {
             Writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, question.ValidationField2);
         }
         if (this.RuntimeSession != null)
         {
             Writer.AddAttribute(HtmlTextWriterAttribute.Value, this.RuntimeSession[question.HtmlQuestionId] as string);
         }
         Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId);
         Writer.RenderBeginTag(HtmlTextWriterTag.Input);
         Writer.RenderEndTag();
     }
     Writer.RenderEndTag();
 }
Example #27
0
 public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
 {
     if (question.ValidationBehavior == ValidationMode.WholeNumber)
     {
         IntegerRenderer _renderer = new IntegerRenderer(this.SurveyManager, this.Writer, this.RuntimeSession);
         _renderer.RenderQuestion(survey, page, question);
     }
     else if (question.ValidationBehavior == ValidationMode.DecimalNumber)
     {
         DecimalRenderer _renderer = new DecimalRenderer(this.SurveyManager, this.Writer, this.RuntimeSession);
         _renderer.RenderQuestion(survey, page, question);
     }
     else if (question.ValidationBehavior == ValidationMode.Date1 || question.ValidationBehavior == ValidationMode.Date2)
     {
         DateRenderer _renderer = new DateRenderer(this.SurveyManager, this.Writer, this.RuntimeSession);
         _renderer.RenderQuestion(survey, page, question);
     }
     else
     {
         RenderDefault(survey, page, question);
     }
 }
        public override void RenderQuestion(VLSurvey survey, VLSurveyPage page, VLSurveyQuestion question)
        {
            Writer.AddAttribute(HtmlTextWriterAttribute.Class, "soption");
            Writer.RenderBeginTag(HtmlTextWriterTag.Div);
            {
                //Writer.AddAttribute(HtmlTextWriterAttribute.For, question.HtmlQuestionId);
                //Writer.RenderBeginTag(HtmlTextWriterTag.Label);
                //HttpUtility.HtmlEncode(question.QuestionText, Writer);
                //Writer.RenderEndTag();

                Writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
                Writer.AddAttribute(HtmlTextWriterAttribute.Class, "Decimal");
                if (this.RuntimeSession != null)
                {
                    Writer.AddAttribute(HtmlTextWriterAttribute.Value, this.RuntimeSession[question.HtmlQuestionId] as string);
                }
                Writer.AddAttribute(HtmlTextWriterAttribute.Name, question.HtmlQuestionId);
                Writer.RenderBeginTag(HtmlTextWriterTag.Input);
                Writer.RenderEndTag();
            }
            Writer.RenderEndTag();
        }
 public static void CreateExcelDocument(VLSurveyManager surveyManager, VLSurvey survey, Collection <VLSurveyQuestionEx> questions, Collection <VLResponseEx> responses, string excelFilename)
 {
     try
     {
         using (SpreadsheetDocument document = SpreadsheetDocument.Create(excelFilename, SpreadsheetDocumentType.Workbook))
         {
             WriteExcelFile(surveyManager, survey, questions, responses, document);
         }
     }
     catch (VLException ex)
     {
         var message = string.Format("An exception occured while calling AllResponsesXlsExport.CreateExcelDocument(), AccessTokenId={0}, surveyId={1}, excelFilename={2}", surveyManager.AccessTokenId, survey, excelFilename);
         Logger.Error(string.Format("RefId={0}, {1}", ex.ReferenceId, message), ex);
         throw new VLException(ex.Message, ex.ReferenceId);
     }
     catch (Exception ex)
     {
         var message = string.Format("An exception occured while calling AllResponsesXlsExport.CreateExcelDocument(), AccessTokenId={0}, surveyId={1}, excelFilename={2}", surveyManager.AccessTokenId, survey, excelFilename);
         var nex     = new VLException(message, ex);
         Logger.Error(string.Format("RefId={0}, {1}", nex.ReferenceId, message), ex);
         throw nex;
     }
 }
        void GetFilesList(VLSurveyManager surveyManager, VLSurvey survey, StringBuilder sb)
        {
            var files = surveyManager.GetFiles(survey);


            sb.Append("[");

            //{"p":"/fileman/Uploads/404.jpg","s":"23073","t":"1394898074","w":"564","h":"434"},
            //{"p":"/fileman/Uploads/06316_148.jpg","s":"99318","t":"1394898075","w":"400","h":"216"},
            bool _comma = false;

            foreach (var file in files)
            {
                var url = string.Format("{0}services/api/filebrowser/FetchFileEx?fileid={1}", Request.ApplicationPath, file.FileId);

                if (_comma)
                {
                    sb.Append(",");
                }
                sb.Append("{");
                sb.AppendFormat("\"fileid\":\"{0}\", ", file.FileId);                          //p - path of the file - absolute to the document root
                sb.AppendFormat("\"p\":\"{0}\", ", Server.HtmlEncode(file.ManagedFileName));   //p - path of the file - absolute to the document root
                sb.AppendFormat("\"s\":\"{0}\", ", file.Size);                                 //s - file size in bytes
                sb.AppendFormat("\"t\":\"{0}\", ", Utility.DatetimeToUnixTime(file.CreateDT)); //st - modification time of the file - unix timestamp
                sb.AppendFormat("\"url\":\"{0}\", ", url);                                     //
                if (file.IsImage)
                {
                    sb.AppendFormat("\"w\":\"{0}\", ", file.Width.HasValue ? file.Width.Value : 0);   //w - if the file is image, the width of the image
                    sb.AppendFormat("\"h\":\"{0}\" ", file.Height.HasValue ? file.Height.Value : 0);  //h - if the file is image, the height of the image
                }
                sb.Append("}");
                _comma = true;
            }

            sb.Append("]");
        }