コード例 #1
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var surveyId      = TryParseInt32(context, "surveyId");
            var pageId        = TryParseInt16(context, "pageId");
            var textsLanguage = TryParseInt16(context, "textsLanguage", required: false, defValue: 0);

            var surveyManager = VLSurveyManager.GetAnInstance(accessToken);
            var surveyPage    = surveyManager.GetSurveyPageById(surveyId, pageId, textsLanguage);

            if (surveyPage == null)
            {
                throw new VLException(string.Format("There is no SurveyPage with id='{0},{1}'.", surveyId, pageId));
            }

            var _item = new
            {
                surveyPage.Survey,
                surveyPage.PageId,
                surveyPage.DisplayOrder,
                surveyPage.HasSkipLogic,
                surveyPage.CustomId,
                surveyPage.SkipTo,
                surveyPage.SkipToPage,
                surveyPage.SkipToWebUrl,
                surveyPage.TextsLanguage,
                surveyPage.ShowTitle,
                surveyPage.Description,
                CreateDT     = surveyPage.CreateDT.ToShortDateString(),
                LastUpdateDT = surveyPage.LastUpdateDT.ToShortDateString(),
            };

            var response = JsonConvert.SerializeObject(_item, Formatting.None);

            context.Response.Write(response);
        }
コード例 #2
0
        protected override void ProcessPostRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var questionId = TryParseInt32(context, "QuestionId");
            var columnId   = TryParseByte(context, "columnId");
            var columnText = TryParseString(context, "columnText");
            var language   = TryParseInt16(context, "language");

            VLLibraryManager libraryManager = VLLibraryManager.GetAnInstance(accessToken);

            var column = libraryManager.GetLibraryQuestionColumnById(questionId, columnId, language);

            if (column == null)
            {
                throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "LibraryColumn", columnId));
            }

            column.ColumnText = columnText;
            column            = libraryManager.UpdateLibraryQuestionColumn(column);


            var item = new
            {
                column.Question,
                column.ColumnId,
                column.DisplayOrder,
                column.AttributeFlags,
                column.TextsLanguage,
                column.ColumnText
            };

            var response = JsonConvert.SerializeObject(item, Formatting.None);

            context.Response.Write(response);
        }
コード例 #3
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var emailId = TryParseInt32(context, "emailId");


            var systemManager = VLSystemManager.GetAnInstance(accessToken);
            var email         = systemManager.GetKnownEmailById(emailId);

            if (email != null)
            {
                var _item = new
                {
                    email.Client,
                    email.EmailId,
                    email.EmailAddress,
                    email.LocalPart,
                    email.DomainPart,
                    email.RegisterDt,
                    email.IsDomainOK,
                    email.IsVerified,
                    email.IsOptedOut,
                    email.IsBounced,
                    email.VerifiedDt,
                    email.OptedOutDt
                };

                var response = JsonConvert.SerializeObject(_item, Formatting.None);
                context.Response.Write(response);
            }
            else
            {
                throw new VLException(string.Format("There is no KnownEmail with id='{0}'.", emailId));
            }
        }
コード例 #4
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var questionId = TryParseInt32(context, "QuestionId");
            var optionId   = TryParseByte(context, "optionId");
            var language   = TryParseInt16(context, "language");

            VLLibraryManager libraryManager = VLLibraryManager.GetAnInstance(accessToken);

            var option = libraryManager.GetLibraryQuestionOptionById(questionId, optionId, language);

            if (option == null)
            {
                throw new VLException(SR.GetString(SR.There_is_no_item_with_id, "LibraryOption", optionId));
            }


            var item = new
            {
                option.Question,
                option.OptionId,
                option.OptionText,
                option.OptionType,
                option.OptionValue,
                option.TextsLanguage,
                option.DisplayOrder,
                option.AttributeFlags
            };

            var response = JsonConvert.SerializeObject(item, Formatting.None);

            context.Response.Write(response);
        }
コード例 #5
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var surveyId       = TryParseInt32(context, "surveyId");
            var sourceLanguage = TryParseInt16(context, "sourceLanguage");
            var targetLanguage = TryParseInt16(context, "targetLanguage");

            VLSurveyManager surveyManager    = VLSurveyManager.GetAnInstance(accessToken);
            var             translatedSurvey = surveyManager.AddSurveyLanguage(surveyId, sourceLanguage, targetLanguage);

            if (translatedSurvey != null)
            {
                var _survey = new
                {
                    translatedSurvey.Client,
                    translatedSurvey.SurveyId,
                    translatedSurvey.TextsLanguage,
                    translatedSurvey.Title,
                    translatedSurvey.ShowTitle
                };

                var response = JsonConvert.SerializeObject(_survey, Formatting.None);
                context.Response.Write(response);
            }
            else
            {
                throw new VLException("AddSurveyLanguage failure!");
            }
        }
コード例 #6
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var contactId = TryParseInt32(context, "contactId", true);

            var systemManager = VLSystemManager.GetAnInstance(accessToken);
            var contact       = systemManager.GetContactById(contactId);

            if (contact == null)
            {
                throw new VLException(string.Format("There is no Contact with id='{0}'.", contactId));
            }

            var _item = new
            {
                contact.ClientId,
                contact.ListId,
                contact.ContactId,
                contact.Organization,
                contact.Title,
                contact.Department,
                contact.FirstName,
                contact.LastName,
                contact.Email,
                contact.Comment,
                contact.IsOptedOut,
                contact.IsBouncedEmail,
                CreateDT     = accessToken.ConvertTimeFromUtc(contact.CreateDT).ToString(Utilities.DateTime_Format_General),
                LastUpdateDT = accessToken.ConvertTimeFromUtc(contact.LastUpdateDT).ToString(Utilities.DateTime_Format_General)
            };

            var response = JsonConvert.SerializeObject(_item, Formatting.None);

            context.Response.Write(response);
        }
コード例 #7
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var filterId = TryParseInt32(context, "filterId");

                var manager = VLSurveyManager.GetAnInstance(accessToken);
                var filter  = manager.GetViewFilterById(filterId);
                if (filter != null)
                {
                    manager.DeleteViewFilter(filter);


                    //empty json object
                    context.Response.Write("{}");
                }
                else
                {
                    throw new VLException(string.Format("There is no Filter with id='{0}'.", filterId));
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #8
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var recipientId = TryParseInt32(context, "recipientId");

            var manager   = VLSurveyManager.GetAnInstance(accessToken);
            var recipient = manager.GetRecipientById(recipientId);

            if (recipient != null)
            {
                var _recipient = new
                {
                    recipient.RecipientId,
                    recipient.Collector,
                    recipient.RecipientKey,
                    recipient.Email,
                    recipient.FirstName,
                    recipient.LastName,
                    recipient.Title,
                    recipient.Status,
                    recipient.IsSentEmail,
                    recipient.IsOptedOut,
                    recipient.IsBouncedEmail,
                    recipient.HasPartiallyResponded,
                    recipient.HasResponded,
                    recipient.HasManuallyAdded
                };

                var response = JsonConvert.SerializeObject(_recipient, Formatting.None);
                context.Response.Write(response);
            }
            else
            {
                throw new VLException(string.Format("There is no Recipient with id='{0}'.", recipientId));
            }
        }
コード例 #9
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var messageId = TryParseInt32(context, "messageId");

            var manager = VLSurveyManager.GetAnInstance(accessToken);
            var message = manager.GetMessageById(messageId);

            if (message != null)
            {
                var _message = new
                {
                    message.Collector,
                    message.MessageId,
                    message.Sender,
                    message.Status,
                    message.IsDeliveryMethodOK,
                    message.IsSenderOK,
                    message.IsContentOK,
                    message.IsScheduleOK,
                    message.ScheduledAt,
                    message.SentCounter,
                    message.DeliveryMethod,
                    message.Subject
                };

                var response = JsonConvert.SerializeObject(_message, Formatting.None);
                context.Response.Write(response);
            }
            else
            {
                throw new VLException(string.Format("There is no Message with id='{0}'.", messageId));
            }
        }
コード例 #10
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var viewId             = TryParseGuid(context, "viewId");
                var questionId         = TryParseInt16(context, "questionId");
                var comparisonOperator = (ComparisonOperator)TryParseByte(context, "operator");
                var userinput1         = TryParseString(context, "userinput1");
                var userinput2         = TryParseString(context, "userinput2", false, null);

                //Φτιάχνουμε ένα surveyManager:
                VLSurveyManager surveyManager = VLSurveyManager.GetAnInstance(accessToken);
                //Βρισκουμε την επιλεγμένη όψη:
                var selectedview = surveyManager.GetViewById(viewId);


                //Δημιουργούμε και το φίλτρο:
                var filter = surveyManager.AddFilter(selectedview, questionId, new VLFilterDetail {
                    Operator = comparisonOperator, UserInput1 = userinput1, UserInput2 = userinput2
                });



                //empty json object
                context.Response.Write("{}");
            }
            catch
            {
                throw;
            }
        }
コード例 #11
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            HttpRequest     Request       = context.Request;
            HttpResponse    Response      = context.Response;
            VLSurveyManager surveyManager = VLSurveyManager.GetAnInstance(accessToken);

            try
            {
                //Παίρνουμε το FileId απο το Request
                Guid  fileId = TryParseGuid(context, "fileid");
                Int32 width  = TryParseInt32(context, "width", false, 104);
                Int32 height = TryParseInt32(context, "height", false, 80);

                #region Cache Hook
                #endregion


                //τραβάμε τα στοιχεία του αρχείου απο το σύστημα
                var file = surveyManager.GetFileById(fileId);
                if (file == null)
                {
                    return;
                }

                System.Byte[] _thumbnail = surveyManager.GetThumbnail(file, width, height);
                if (_thumbnail != null)
                {
                    #region Cache Hook

                    #endregion

                    Response.ClearHeaders();
                    Response.Clear();
                    Response.Cache.SetExpires(DateTime.Now.AddDays(1));
                    Response.Cache.SetCacheability(HttpCacheability.Public);
                    Response.Cache.SetValidUntilExpires(true);
                    Response.ContentType = GetMimeType(file.OriginalFileName);

                    Response.BinaryWrite(_thumbnail);
                    //Response.End();/*It throws ThreadAbortException */
                    context.ApplicationInstance.CompleteRequest();
                }
                else
                {
                    //Response.Clear();
                    ////Response.CacheControl = "Public";
                    //Response.Cache.SetExpires(DateTime.Now.AddDays(1));
                    //Response.Cache.SetCacheability(HttpCacheability.Public);
                    //Response.Cache.SetValidUntilExpires(true);
                    //string image = Globals.GetImageForMimeType(managedFile.Mime, true);
                    //Response.WriteFile(context.Server.MapPath(string.Format("{0}/ecms/images/", Request.ApplicationPath).Replace("//", "/")) + image);
                    ////Response.End();/*It throws ThreadAbortException */
                    //context.ApplicationInstance.CompleteRequest();
                }
            }
            catch (Exception)
            {
                //System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #12
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var surveyId      = TryParseInt32(context, "surveyId");
            var pageId        = TryParseInt16(context, "pageId");
            var textsLanguage = TryParseInt16(context, "textsLanguage", required: false, defValue: 0);

            var surveyManager = VLSurveyManager.GetAnInstance(accessToken);
            var pages         = surveyManager.GetCandidateSkipPagesForPage(surveyId, pageId, addVirtualPages: true, textsLanguage: textsLanguage);

            var rows = pages.Select(c => new {
                c.Survey,
                c.PageId,
                c.DisplayOrder,
                c.HasSkipLogic,
                c.CustomId,
                c.SkipTo,
                c.SkipToPage,
                c.SkipToWebUrl,
                c.ShowTitle,

                /*
                 * Στις κανονικές σελίδες εμφανίζουμε το πρόθεμα Page: <pageid>
                 * Στις virtual σελίδες εμφναίζουμε μόνο το ShowTitle
                 */
                OptionTitle = c.PageId >= 0 ? (HttpUtility.HtmlEncode(string.Format("Page {0}: {1}", c.DisplayOrder, (c.ShowTitle != null ? c.ShowTitle : "<untitled page>")))) : ((c.ShowTitle != null ? c.ShowTitle : "<untitled page>"))
            }).ToArray();

            var response = JsonConvert.SerializeObject(rows, Formatting.None);

            context.Response.Write(response);
        }
コード例 #13
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var collectorId   = TryParseInt32(context, "collectorId");
            var textsLanguage = TryParseInt16(context, "textsLanguage");

            var manager   = VLSurveyManager.GetAnInstance(accessToken);
            var collector = manager.GetCollectorById(collectorId, textsLanguage);

            if (collector != null)
            {
                collector.Name = TryParseString(context, "collectorName", true);
                collector      = manager.UpdateCollector(collector);

                var totalScheduledMessages = manager.GetScheduledMessagesCount(collector.CollectorId);

                var _collector = new
                {
                    collector.CollectorId,
                    collector.Survey,
                    collector.CollectorType,
                    collector.Name,
                    collector.AttributeFlags,
                    collector.Status,
                    collector.Responses,
                    collector.SupportedLanguagesIds,
                    collector.PrimaryLanguage,
                    ScheduledMessages = totalScheduledMessages,
                    CreateDT          = collector.CreateDT.ToString(Utilities.DateTime_Format_General),
                    LastUpdateDT      = collector.LastUpdateDT.ToString(Utilities.DateTime_Format_General)
                };

                var response = JsonConvert.SerializeObject(_collector, Formatting.None);
                context.Response.Write(response);
            }
        }
コード例 #14
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var filterId = TryParseInt32(context, "filterId");

            var manager = VLSurveyManager.GetAnInstance(accessToken);
            var filter  = manager.GetViewFilterById(filterId);

            if (filter != null)
            {
                var _filter = new
                {
                    filter.ViewId,
                    filter.FilterId,
                    filter.Survey,
                    filter.Name,
                    filter.ApplyOrder,
                    filter.IsRule,
                    filter.Question,
                    filter.QuestionType,
                    filter.LogicalOperator,
                    filter.IsActive
                };

                var response = JsonConvert.SerializeObject(_filter, Formatting.None);
                context.Response.Write(response);
            }
            else
            {
                throw new VLException(string.Format("There is no Filter with id='{0}'.", filterId));
            }
        }
コード例 #15
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var listId = TryParseInt32(context, "listId", true);

            var systemManager = VLSystemManager.GetAnInstance(accessToken);
            var list          = systemManager.GetClientListById(listId);

            if (list == null)
            {
                throw new VLException(string.Format("There is no List with id='{0}'.", listId));
            }

            var _item = new
            {
                list.Client,
                list.ListId,
                list.Name,
                list.TotalContacts,
                list.CreateDT,
                list.LastUpdateDT
            };

            var response = JsonConvert.SerializeObject(_item, Formatting.None);

            context.Response.Write(response);
        }
コード例 #16
0
        protected override void ProcessPostRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var questionId = TryParseInt32(context, "QuestionId");
            var optionText = TryParseString(context, "optionText");
            var language   = TryParseInt16(context, "language");

            VLLibraryManager libraryManager = VLLibraryManager.GetAnInstance(accessToken);

            var option = libraryManager.CreateLibraryQuestionOption(questionId, optionText, textsLanguage: language);

            var item = new
            {
                option.Question,
                option.OptionId,
                option.OptionText,
                option.OptionType,
                option.OptionValue,
                option.TextsLanguage,
                option.DisplayOrder,
                option.AttributeFlags
            };

            var response = JsonConvert.SerializeObject(item, Formatting.None);

            context.Response.Write(response);
        }
コード例 #17
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var collectorId   = TryParseInt32(context, "collectorId", true);
            var pageIndex     = TryParseInt32(context, "page", false, 1);
            var pageSize      = TryParseInt32(context, "rows", false, 10);
            var sortIndex     = TryParseString(context, "sidx", false, "Name");
            var sortOrder     = TryParseString(context, "sord", false, "asc");
            var orderByClause = string.Format("order by {0} {1}", sortIndex, sortOrder);

            var systemManager = VLSystemManager.GetAnInstance(accessToken);

            int totalRecords = 0;
            var items        = systemManager.GetChargesForCollector(collectorId, pageIndex, pageSize, ref totalRecords, string.Empty, orderByClause);

            int totalpages = totalRecords / pageSize;

            if (totalpages * pageSize < totalRecords)
            {
                totalpages++;
            }


            var rows = items.Select(c => new
            {
                c.CollectorPaymentId,

                c.SurveyId,

                c.CollectorId,
                c.Responses,
                c.CreditType,

                c.PaymentId,
                c.UseOrder,
                c.QuantityReserved,
                c.QuantityUsed,
                FirstChargeDt = c.FirstChargeDt.HasValue ? c.FirstChargeDt.Value.ToShortDateString() : string.Empty,
                LastChargeDt  = c.LastChargeDt.HasValue ? c.LastChargeDt.Value.ToShortDateString() : string.Empty,
                c.IsActive,
                c.IsUsed,

                PaymentDate = c.PaymentDate.ToShortDateString(),
                c.PaymentIsActive,
                PaymentQuantity = GetPaymentQuantity(c),
                c.PaymentQuantityUsed
            }).ToArray();

            var data = new
            {
                total   = totalpages,   //total pages for the query
                page    = pageIndex,    //current page of the query
                records = totalRecords, //total number of records for the query
                rows
            };


            var response = JsonConvert.SerializeObject(data, Formatting.None);

            context.Response.Write(response);
        }
コード例 #18
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var pageIndex     = TryParseInt32(context, "page", false, 1);
            var pageSize      = TryParseInt32(context, "rows", false, 10);
            var sortIndex     = TryParseString(context, "sidx", false, "QuestionText");
            var sortOrder     = TryParseString(context, "sord", false, "asc");
            var orderByClause = string.Format("order by {0} {1}", sortIndex, sortOrder);

            var libraryManager = VLLibraryManager.GetAnInstance(accessToken);

            int totalRecords = 0;
            var items        = libraryManager.GetLibraryQuestions(BuiltinLibraryQuestionCategories.CommonQuestions.CategoryId, pageIndex, pageSize, ref totalRecords, string.Empty, orderByClause);

            int totalpages = totalRecords / pageSize;

            if (totalpages * pageSize < totalRecords)
            {
                totalpages++;
            }


            var rows = items.Select(c => new
            {
                c.QuestionId,
                c.Category,
                c.QuestionType,
                c.IsRequired,
                c.RequiredBehavior,
                c.RequiredMinLimit,
                c.RequiredMaxLimit,
                c.OptionalInputBox,
                c.RandomizeOptionsSequence,
                c.RandomizeColumnSequence,
                c.OneResponsePerColumn,
                c.UseDateTimeControls,
                c.AddResetLink,
                c.ValidationBehavior,
                c.RandomBehavior,
                c.OtherFieldType,
                c.TextsLanguage,
                c.QuestionText,
                c.CreateDT,
                c.LastUpdateDT
            }).ToArray();

            var data = new
            {
                total   = totalpages,   //total pages for the query
                page    = pageIndex,    //current page of the query
                records = totalRecords, //total number of records for the query
                rows
            };


            var response = JsonConvert.SerializeObject(data, Formatting.None);

            context.Response.Write(response);
        }
コード例 #19
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var collectorId = TryParseInt32(context, "collectorId", true);
                var pageIndex   = TryParseInt32(context, "page", false, 1);
                var pageSize    = TryParseInt32(context, "rows", false, 10);
                var sortIndex   = TryParseString(context, "sidx", false, "Name");
                var sortOrder   = TryParseString(context, "sord", false, "asc");

                var manager = VLSurveyManager.GetAnInstance(accessToken);

                int totalRecords = 0;
                var items        = manager.GetNonDraftMessages(collectorId, pageIndex, pageSize, ref totalRecords, string.Empty);

                int totalpages = totalRecords / pageSize;
                if (totalpages * pageSize < totalRecords)
                {
                    totalpages++;
                }



                var rows = items.Select(c => new
                {
                    c.Collector,
                    c.MessageId,
                    c.Sender,
                    c.Status,
                    c.IsDeliveryMethodOK,
                    c.IsSenderOK,
                    c.IsContentOK,
                    c.IsScheduleOK,
                    ScheduledAt = c.ScheduledAt.HasValue ? accessToken.ConvertTimeFromUtc(c.ScheduledAt.Value).ToString(Utilities.DateTime_Format_Human, CultureInfo.InvariantCulture) : null,
                    c.SentCounter,
                    c.FailedCounter,
                    c.SkipCounter,
                    c.DeliveryMethod,
                    c.Subject
                }).ToArray();

                var data = new
                {
                    total   = totalpages,   //total pages for the query
                    page    = pageIndex,    //current page of the query
                    records = totalRecords, //total number of records for the query
                    rows
                };


                var response = JsonConvert.SerializeObject(data, Formatting.None);
                context.Response.Write(response);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #20
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var collectorId = TryParseInt32(context, "collectorId", true);
                var pageIndex   = TryParseInt32(context, "page", false, 1);
                var pageSize    = TryParseInt32(context, "rows", false, 10);
                var sortIndex   = TryParseString(context, "sidx", false, "Name");
                var sortOrder   = TryParseString(context, "sord", false, "asc");

                var manager       = VLSurveyManager.GetAnInstance(accessToken);
                var orderByClause = string.Format("order by {0} {1}", sortIndex, sortOrder);

                int totalRecords = 0;
                var items        = manager.GetRecipients(collectorId, pageIndex, pageSize, ref totalRecords, string.Empty, orderByClause);

                int totalpages = totalRecords / pageSize;
                if (totalpages * pageSize < totalRecords)
                {
                    totalpages++;
                }


                var rows = items.Select(c => new
                {
                    c.RecipientId,
                    c.Collector,
                    c.RecipientKey,
                    c.Email,
                    c.FirstName,
                    c.LastName,
                    c.Title,
                    c.Status,
                    c.IsSentEmail,
                    c.IsOptedOut,
                    c.IsBouncedEmail,
                    c.HasPartiallyResponded,
                    c.HasResponded,
                    c.HasManuallyAdded
                }).ToArray();

                var data = new
                {
                    total   = totalpages,   //total pages for the query
                    page    = pageIndex,    //current page of the query
                    records = totalRecords, //total number of records for the query
                    rows
                };


                var response = JsonConvert.SerializeObject(data, Formatting.None);
                context.Response.Write(response);
            }
            catch
            {
                throw;
            }
        }
コード例 #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="accessToken"></param>
        public void LogOffUser(VLAccessToken accessToken)
        {
            if (accessToken == null)
            {
                throw new ArgumentNullException("accessToken");
            }

            LogOffUser(accessToken.AccessTokenId);
        }
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var viewId     = TryParseGuid(context, "viewId");
                var questionId = TryParseInt16(context, "questionId");
                var conc_rows  = TryParseString(context, "rows");         //fltrOption_8_1_1,fltrOption_8_2_2,fltrOption_8_3_3
                var conc_cols  = TryParseString(context, "columns");      //fltrColumn_8_9_1,fltrColumn_8_10_1,fltrColumn_8_8_2,fltrColumn_8_9_2,fltrColumn_8_10_2,fltrColumn_8_5_3,fltrColumn_8_6_3,fltrColumn_8_7_3,fltrColumn_8_8_3

                /*σπάμε rows & columns:*/
                var rows    = conc_rows.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var columns = conc_cols.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);


                //Φτιάχνουμε ένα surveyManager:
                VLSurveyManager surveyManager = VLSurveyManager.GetAnInstance(accessToken);
                //Βρισκουμε την επιλεγμένη όψη:
                var selectedview = surveyManager.GetViewById(viewId);


                //Δημιουργούμε τα filterDetails:
                Collection <VLFilterDetail> details = new Collection <VLFilterDetail>();
                foreach (var row in rows)
                {
                    var   tokens   = row.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                    Int32 question = Int32.Parse(tokens[1]);
                    byte  option   = byte.Parse(tokens[2]);
                    byte  section  = byte.Parse(tokens[3]);

                    foreach (var col in columns)
                    {
                        var   tokens2   = col.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                        Int32 question2 = Int32.Parse(tokens2[1]);
                        byte  column    = byte.Parse(tokens2[2]);
                        byte  section2  = byte.Parse(tokens2[3]);

                        if (question == question2 && section == section2)
                        {
                            details.Add(new VLFilterDetail {
                                Operator = ComparisonOperator.IsChecked, SelectedOption = option, SelectedColumn = column
                            });
                        }
                    }
                }
                //Δημιουργούμε και το φίλτρο:
                var filter = surveyManager.AddFilter(selectedview, questionId, details);



                //empty json object
                context.Response.Write("{}");
            }
            catch
            {
                throw;
            }
        }
コード例 #23
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var surveyId  = TryParseInt32(context, "surveyId", true);
                var pageIndex = TryParseInt32(context, "page", false, 1);
                var pageSize  = TryParseInt32(context, "rows", false, 10);
                var sortIndex = TryParseString(context, "sidx", false, "Name");
                var sortOrder = TryParseString(context, "sord", false, "asc");

                var manager = VLSurveyManager.GetAnInstance(accessToken);

                int totalRecords = 0;
                var items        = manager.GetCollectors(surveyId, pageIndex, pageSize, ref totalRecords);

                int totalpages = totalRecords / pageSize;
                if (totalpages * pageSize < totalRecords)
                {
                    totalpages++;
                }


                var rows = items.Select(c => new
                {
                    c.CollectorId,
                    c.Survey,
                    c.CollectorType,
                    c.Name,
                    c.AttributeFlags,
                    c.Status,
                    c.Responses,
                    c.SupportedLanguagesIds,
                    c.PrimaryLanguage,
                    c.TextsLanguage,
                    c.CreditType,
                    CreateDT     = accessToken.ConvertTimeFromUtc(c.CreateDT).ToString(Utilities.DateTime_Format_Human),
                    LastUpdateDT = accessToken.ConvertTimeFromUtc(c.LastUpdateDT).ToString(Utilities.DateTime_Format_Human)
                }).ToArray();

                var data = new
                {
                    total   = totalpages,   //total pages for the query
                    page    = pageIndex,    //current page of the query
                    records = totalRecords, //total number of records for the query
                    rows
                };


                var response = JsonConvert.SerializeObject(data, Formatting.None);
                context.Response.Write(response);
            }
            catch
            {
                throw;
            }
        }
コード例 #24
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var collectorId = TryParseInt32(context, "collectorId");

            var manager = VLSurveyManager.GetAnInstance(accessToken);

            manager.CloseCollector(collectorId);
            //empty json object
            context.Response.Write("{}");
        }
コード例 #25
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            VLSurveyManager surveyManager = VLSurveyManager.GetAnInstance(accessToken);
            var             dashboard     = surveyManager.GetSystemDashboard();


            var response = JsonConvert.SerializeObject(dashboard, Formatting.None);

            context.Response.Write(response);
        }
コード例 #26
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var clientId      = TryParseInt32(context, "ClientId", true);
            var pageIndex     = TryParseInt32(context, "page", false, 1);
            var pageSize      = TryParseInt32(context, "rows", false, 10);
            var sortIndex     = TryParseString(context, "sidx", false, "Name");
            var sortOrder     = TryParseString(context, "sord", false, "asc");
            var orderByClause = string.Format("order by {0} {1}", sortIndex, sortOrder);

            var systemManager = VLSystemManager.GetAnInstance(accessToken);

            int totalRecords = 0;
            var items        = systemManager.GetPayments(clientId, pageIndex, pageSize, ref totalRecords, string.Empty, orderByClause);

            int totalpages = totalRecords / pageSize;

            if (totalpages * pageSize < totalRecords)
            {
                totalpages++;
            }


            var rows = items.Select(c => new
            {
                c.PaymentId,
                c.Client,
                c.Comment,
                c.PaymentType,
                c.PaymentDate,
                c.CustomCode1,
                c.CustomCode2,
                c.IsActive,
                c.IsTimeLimited,
                c.ValidFromDt,
                c.ValidToDt,
                c.CreditType,
                c.Quantity,
                c.QuantityUsed,
                c.CreateDT
            }).ToArray();

            var data = new
            {
                total   = totalpages,   //total pages for the query
                page    = pageIndex,    //current page of the query
                records = totalRecords, //total number of records for the query
                rows
            };


            var response = JsonConvert.SerializeObject(data, Formatting.None);

            context.Response.Write(response);
        }
コード例 #27
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var contactId = TryParseInt32(context, "contactId", true);

            var systemManager = VLSystemManager.GetAnInstance(accessToken);

            systemManager.DeleteContact(contactId);

            //empty json object
            context.Response.Write("{}");
        }
コード例 #28
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var viewId          = TryParseGuid(context, "viewId");
                var conc_collectors = TryParseString(context, "collectors");

                //Φτιάχνουμε ένα surveyManager:
                VLSurveyManager surveyManager = VLSurveyManager.GetAnInstance(accessToken);
                //Βρισκουμε την επιλεγμένη όψη:
                var selectedview = surveyManager.GetViewById(viewId);

                var _collectors = conc_collectors.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                Collection <Int32> collectors = new Collection <int>();
                foreach (var item in _collectors)
                {
                    collectors.Add(Int32.Parse(item.Substring(13)));
                }
                selectedview = surveyManager.AddCollectorFilter(selectedview, collectors);

                var _view = new
                {
                    selectedview.Client,
                    selectedview.UserId,
                    selectedview.Survey,
                    selectedview.ViewId,
                    selectedview.Name,
                    selectedview.IsDefaultView,
                    selectedview.PartialShowInUse,
                    selectedview.EnablePartialShow,
                    selectedview.FilteringByCollectorInUse,
                    selectedview.EnableFilteringByCollector,
                    selectedview.FilteringByTimePeriodInUse,
                    selectedview.EnableFilteringByTimePeriod,
                    selectedview.FilteringByResponseTimeInUse,
                    selectedview.EnableFilteringByResponseTime,
                    selectedview.FilteringByQuestionInUse,
                    selectedview.TimePeriodStart,
                    selectedview.TimePeriodEnd,
                    selectedview.TotalResponseTime,
                    selectedview.TotalResponseTimeUnit,
                    selectedview.TotalResponseTimeOperator,
                    selectedview.NumberOfQuestionFilters
                };


                var response = JsonConvert.SerializeObject(_view, Formatting.None);
                context.Response.Write(response);
            }
            catch
            {
                throw;
            }
        }
コード例 #29
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            var pageIndex     = TryParseInt32(context, "page", false, 1);
            var pageSize      = TryParseInt32(context, "rows", false, 10);
            var sortIndex     = TryParseString(context, "sidx", false, "Name");
            var sortOrder     = TryParseString(context, "sord", false, "asc");
            var orderByClause = string.Format("order by {0} {1}", sortIndex, sortOrder);

            var systemManager = VLSystemManager.GetAnInstance(accessToken);

            int totalRecords = 0;
            var items        = systemManager.GetClientExs(pageIndex, pageSize, ref totalRecords, string.Empty, orderByClause);

            int totalpages = totalRecords / pageSize;

            if (totalpages * pageSize < totalRecords)
            {
                totalpages++;
            }


            var rows = items.Select(c => new
            {
                c.ClientId,
                c.Code,
                c.Name,
                c.Profession,
                c.Country,
                c.Prefecture,
                c.Town,
                c.Address,
                c.Zip,
                c.Telephone1,
                c.Telephone2,
                c.WebSite,
                c.IsBuiltIn,
                c.Profile,
                c.ProfileName,
                c.CreateDT
            }).ToArray();
            var data = new
            {
                total   = totalpages,   //total pages for the query
                page    = pageIndex,    //current page of the query
                records = totalRecords, //total number of records for the query
                rows
            };


            var response = JsonConvert.SerializeObject(data, Formatting.None);

            context.Response.Write(response);
        }
コード例 #30
0
        protected override void ProcessGetRequestWrapped(Valis.Core.VLAccessToken accessToken, HttpContext context)
        {
            try
            {
                var viewId           = TryParseGuid(context, "viewId");
                var _timePeriodStart = TryParseString(context, "timePeriodStart");
                var _timePeriodEnd   = TryParseString(context, "timePeriodEnd");

                //Φτιάχνουμε ένα surveyManager:
                VLSurveyManager surveyManager = VLSurveyManager.GetAnInstance(accessToken);
                //Βρισκουμε την επιλεγμένη όψη:
                var selectedview = surveyManager.GetViewById(viewId);

                //ΣΤΑ RESPONSES ΟΙ ΗΜΕΡΟΜΗΝΙΕΣ ΕΙΝΑΙ ΠΑΝΤΑ MM/DD/YYYY:
                var timePeriodStart = DateTime.ParseExact(_timePeriodStart, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                var timePeriodEnd   = DateTime.ParseExact(_timePeriodEnd, "MM/dd/yyyy", CultureInfo.InvariantCulture);

                selectedview = surveyManager.AddTimePeriodFilter(selectedview, timePeriodStart, timePeriodEnd);

                var _view = new
                {
                    selectedview.Client,
                    selectedview.UserId,
                    selectedview.Survey,
                    selectedview.ViewId,
                    selectedview.Name,
                    selectedview.IsDefaultView,
                    selectedview.PartialShowInUse,
                    selectedview.EnablePartialShow,
                    selectedview.FilteringByCollectorInUse,
                    selectedview.EnableFilteringByCollector,
                    selectedview.FilteringByTimePeriodInUse,
                    selectedview.EnableFilteringByTimePeriod,
                    selectedview.FilteringByResponseTimeInUse,
                    selectedview.EnableFilteringByResponseTime,
                    selectedview.FilteringByQuestionInUse,
                    selectedview.TimePeriodStart,
                    selectedview.TimePeriodEnd,
                    selectedview.TotalResponseTime,
                    selectedview.TotalResponseTimeUnit,
                    selectedview.TotalResponseTimeOperator,
                    selectedview.NumberOfQuestionFilters
                };


                var response = JsonConvert.SerializeObject(_view, Formatting.None);
                context.Response.Write(response);
            }
            catch
            {
                throw;
            }
        }