Example #1
0
	public MaterialsBinding (UnityImporter importer)
	{
		m_importer = importer; //the max side of the code is fully asynchronous and reentrant
		m_materialManager = new MaterialManager(importer);
		m_templateManager = new TemplateManager(importer);
		m_textureManager = new TextureManager(importer);
	}
Example #2
0
 public PageBuilder(string sourceDir, string outDir, ApiConfig config, TemplateManager templateManager)
 {
     _sourceDir = EnsureTerminatingDirectorySeparator(sourceDir);
     _outDir = EnsureTerminatingDirectorySeparator(outDir);
     _config = config;
     _templateManager = templateManager;
 }
        public string CreateTemplate(string name, string content, string userId)
        {
            string id = Guid.NewGuid().ToString();
            TOP.Template.Domain.Template template = new TOP.Template.Domain.Template();
            template.Name = name;
            template.Content = content;
            template.CreateUserId = userId;
            template.LastUpdateUserId = userId;

            #region 执行SQL以创建对象

            TemplateManager manager = new TemplateManager();
            string sqlCreate = manager.GetCreateSql(template);
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreate);
                    dbOperator.CommintTran();

                    return id;
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("创建模板发生异常 - ", ex);
                }
            }

            #endregion
        }
Example #4
0
        private static async Task MainAsync(string[] args)
        {
            var configPath = args.Skip(0).Take(1).SingleOrDefault() ?? "../../config.json";
            configPath = Path.GetFullPath(configPath);

            var sourceDir = args.Skip(1).Take(1).SingleOrDefault() ?? "../../pages";
            sourceDir = Path.GetFullPath(sourceDir);

            var outDir = args.Skip(2).Take(1).SingleOrDefault() ?? "../../public";
            outDir = Path.GetFullPath(outDir);

            var templateDir = args.Skip(3).Take(1).SingleOrDefault() ?? "../../res/html";
            templateDir = Path.GetFullPath(templateDir);
            var templateManager = new TemplateManager();
            templateManager.LoadFromDirectory(templateDir);

            var colour = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine($"Config path: {configPath}");
            Console.WriteLine($"Page path: {sourceDir}");
            Console.WriteLine($"Out path: {outDir}");
            Console.WriteLine($"Template path: {templateDir}");
            Console.ForegroundColor = colour;

            var apiConfig = GetConfig(configPath);
            var pageBuilder = new PageBuilder(sourceDir, outDir, apiConfig, templateManager);

            await pageBuilder.Build();

#if DEBUG
            Console.ReadLine();
#endif
        }
 public DocumentManager(Form main)
 {
     this.main = main;
     this.database = new DatabaseManager();
     this.template = new TemplateManager();
     this.error = new ErrorManager();
     this.output = new OutputManager();
     this.desk = new DeskManager();
     this.codebuild = new CodeBuilderManager();
 }
Example #6
0
        public string RenderHtml(TemplateManager templateManager)
        {
            var formatter = new FormatCompiler();

            var rootHtml = templateManager.Templates[TemplateName];
            if (string.IsNullOrEmpty(rootHtml))
            {
                return null;
            }

            var rootTemplate = formatter.Compile(rootHtml);

            var html = rootTemplate.Render(this);

            return html;
        }
Example #7
0
        public void TestTemplateManagerWithMutipleThemesShouldWork()
        {
            // If the same resource name exists in the override folder, use the overriden one
            var themes = new List<string> { "tmpl1", "tmpl/tmpl1" };
            var manager = new TemplateManager(GetType().Assembly, "tmpl", null, themes, null);
            var outputFolder = Path.Combine(_outputFolder, "TestTemplateManager_MutipleThemes");
            manager.ProcessTheme(outputFolder, true);
            // 1. Support tmpl1.zip
            var file1 = Path.Combine(outputFolder, "tmpl1.dot.$");
            Assert.True(File.Exists(file1));
            Assert.Equal("Override: This is file with complex filename characters", File.ReadAllText(file1));

            // backslash is also supported
            var file2 = Path.Combine(outputFolder, "sub/file1");
            Assert.True(File.Exists(file2));
            Assert.Equal("Override: This is file inside a subfolder", File.ReadAllText(file2));
        }
Example #8
0
        public async Task UploadTemplateFile_TemplateNotFound_ThrowException()
        {
            _templateServiceMock.Setup(m => m.GetTemplate(It.IsAny <Guid>())).Returns(() => Task.FromResult((TemplateModel)null));
            _templateServiceMock.Setup(m => m.AddTemplateVersion(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>()));
            _fileStorageMock.Setup(m => m.UploadFile(It.IsAny <string>(), It.IsAny <Stream>()));

            var manager     = new TemplateManager(_templateServiceMock.Object, _fileStorageMock.Object);
            var fileContent = new MemoryStream(Encoding.UTF8.GetBytes("test"));

            try
            {
                await manager.UploadTemplateFile(_templateId, fileContent, "test.pbx", version : "1.2");

                Assert.Fail();
            }
            catch
            {
                _templateServiceMock.Verify(m => m.GetTemplate(_templateId), Times.Once());
                _templateServiceMock.Verify(m => m.AddTemplateVersion(_templateId, It.IsAny <string>(), It.IsAny <string>()), Times.Never());
                _fileStorageMock.Verify(m => m.UploadFile(It.IsAny <string>(), It.IsAny <Stream>()), Times.Never());
            }
        }
Example #9
0
        // This method is called by any waterfall step that throws an exception to ensure consistency
        protected async Task HandleDialogExceptionsAsync(WaterfallStepContext sc, Exception ex, CancellationToken cancellationToken)
        {
            // send trace back to emulator
            var trace = new Activity(type: ActivityTypes.Trace, text: $"DialogException: {ex.Message}, StackTrace: {ex.StackTrace}");
            await sc.Context.SendActivityAsync(trace, cancellationToken);

            // log exception
            TelemetryClient.TrackException(ex, new Dictionary <string, string> {
                { nameof(sc.ActiveDialog), sc.ActiveDialog?.Id }
            });

            // send error message to bot user
            await sc.Context.SendActivityAsync(TemplateManager.GenerateActivity(POISharedResponses.PointOfInterestErrorMessage), cancellationToken);

            // clear state
            var state = await Accessor.GetAsync(sc.Context, () => new PointOfInterestSkillState(), cancellationToken);

            state.Clear();
            await sc.CancelAllDialogsAsync(cancellationToken);

            return;
        }
Example #10
0
        private void _browse_Click(object sender, EventArgs e)
        {
            if (_openFile.ShowDialog(ActiveForm) == DialogResult.OK)
            {
                if (_template != null)
                {
                    ThreatModelManager.Remove(_template.Id);
                }
                _schemas.Items.Clear();

                _fileName.Text = _openFile.FileName;

                _template = TemplateManager.OpenTemplate(_fileName.Text);
                var schemas = _template?.Schemas?.OrderBy(x => x.Name).ToArray();
                if (schemas?.Any() ?? false)
                {
                    _schemas.Items.AddRange(schemas);
                }

                _ok.Enabled = IsValid();
            }
        }
Example #11
0
        protected void GetInheritedFields([NotNull] Template template, [NotNull] out List <Data.Templates.TemplateField> fields, [NotNull] out string baseTemplates)
        {
            fields = new List <Data.Templates.TemplateField>();

            var database         = Factory.GetDatabase(template.Database);
            var baseTemplateList = new List <Data.Items.Item>();

            var templates = template.BaseTemplates.Split(new [] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var templateId in templates)
            {
                // resolve possible item paths
                var baseTemplateItem = database.GetItem(templateId);
                if (baseTemplateItem == null)
                {
                    throw new RetryableEmitException("Template missing", templateId);
                }

                baseTemplateList.Add(baseTemplateItem);

                var t = TemplateManager.GetTemplate(baseTemplateItem.ID, database);
                if (t == null)
                {
                    throw new RetryableEmitException("Template missing", templateId);
                }

                var templateFields = t.GetFields(true);

                foreach (var templateField in templateFields)
                {
                    if (fields.All(f => f.Name != templateField.Name))
                    {
                        fields.Add(templateField);
                    }
                }
            }

            baseTemplates = string.Join("|", baseTemplateList.Select(t => t.ID.ToString()));
        }
        private async Task <DialogTurnResult> GetEventsPromptAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken);

                if (state.ShowMeetingInfo.FocusedEvents.Any())
                {
                    return(await sc.EndDialogAsync(cancellationToken : cancellationToken));
                }
                else if (state.ShowMeetingInfo.ShowingMeetings.Any())
                {
                    return(await sc.NextAsync(cancellationToken : cancellationToken));
                }
                else
                {
                    sc.Context.TurnState.TryGetValue(StateProperties.APITokenKey, out var token);
                    var calendarService = ServiceManager.InitCalendarService(token as string, state.EventSource);
                    return(await sc.PromptAsync(Actions.GetEventPrompt, new GetEventOptions(calendarService, state.GetUserTimeZone())
                    {
                        Prompt = TemplateManager.GenerateActivityForLocale(UpdateEventResponses.NoUpdateStartTime) as Activity,
                        RetryPrompt = TemplateManager.GenerateActivityForLocale(UpdateEventResponses.EventWithStartTimeNotFound) as Activity,
                        MaxReprompt = CalendarCommonUtil.MaxRepromptCount
                    }, cancellationToken));
                }
            }
            catch (SkillException ex)
            {
                await HandleDialogExceptionsAsync(sc, ex, cancellationToken);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
            catch (Exception ex)
            {
                await HandleDialogExceptionsAsync(sc, ex, cancellationToken);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
        }
        private Sitecore.Commerce.XA.Foundation.Common.Constants.ItemTypes GetContextItemType(string UrlItemPath)
        {
            //since this pipeline is being called before ite resolver, Sitecore.Context.Item has not been resolved, so we need to get the item by using item path.
            Item item = Sitecore.Context.Database.GetItem(UrlItemPath);

            if (item == null)
            {
                return(Sitecore.Commerce.XA.Foundation.Common.Constants.ItemTypes.Unknown);
            }
            Template template = TemplateManager.GetTemplate(item);

            Sitecore.Commerce.XA.Foundation.Common.Constants.ItemTypes itemTypes = Sitecore.Commerce.XA.Foundation.Common.Constants.ItemTypes.Unknown;
            if (template.InheritsFrom(Sitecore.Commerce.XA.Foundation.Common.Constants.DataTemplates.CategoryPage.ID))
            {
                itemTypes = Sitecore.Commerce.XA.Foundation.Common.Constants.ItemTypes.Category;
            }
            else if (template.InheritsFrom(Sitecore.Commerce.XA.Foundation.Common.Constants.DataTemplates.ProductPage.ID))
            {
                itemTypes = Sitecore.Commerce.XA.Foundation.Common.Constants.ItemTypes.Product;
            }
            return(itemTypes);
        }
Example #14
0
        public override bool CopyItem(ItemDefinition source, ItemDefinition destination, string copyName, ID copyId, CallContext context)
        {
            Assert.ArgumentNotNull(source, "source");
            Assert.ArgumentNotNull(destination, "destination");
            Assert.ArgumentNotNullOrEmpty(copyName, "copyName");
            Assert.ArgumentNotNull(copyId, "copyId");

            var template = TemplateManager.GetTemplate(source.TemplateID, Database);

            if (template == null)
            {
                return(false);
            }

            if (!ShouldExecuteProvider(destination, copyName, copyId, source.TemplateID, template.Name))
            {
                return(false);
            }

            context.Abort();
            return(base.CopyItem(source, destination, copyName, copyId, context));
        }
Example #15
0
        public void DisableSkin(string skinID)
        {
            if (TemplateManager.GetSkin(skinID, true) == null)
            {
                return;
            }

            if (DefaultSkin == skinID)
            {
                return;
            }

            lock (locker)
            {
                if (DisabledSkins.Contains(skinID) == false)
                {
                    DisabledSkins.Add(skinID);
                }
            }
            TemplateManager.ClearSkinCache();
            SettingManager.SaveSettings(this);
        }
Example #16
0
        public override void Check(ValidationWriter output, Item item)
        {
            Assert.ArgumentNotNull(output, nameof(output));
            Assert.ArgumentNotNull(item, nameof(item));

            var parametersTemplateId = item[ParametersTemplateFieldId];

            if (string.IsNullOrEmpty(parametersTemplateId))
            {
                return;
            }

            var template = TemplateManager.GetTemplate(new ID(parametersTemplateId), item.Database);

            if (template == null)
            {
                return;
            }

            var defaultParameters = new UrlString(item["Default Parameters"]);

            foreach (string key in defaultParameters.Parameters.Keys)
            {
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }

                if (key == "Placeholder")
                {
                    continue;
                }

                if (template.GetField(key) == null)
                {
                    output.Write(SeverityLevel.Warning, "Control has an invalid default parameter", string.Format("The control '{1}' defines the default parameter '{0}', but this parameter does not exist in the controls Parameter Template.", key, item.Name), "Remove the default parameter or add it to the Parameter Template.", item);
                }
            }
        }
Example #17
0
        public void Update(SpecialInfo specialInfo)
        {
            var sqlString = $@"UPDATE {TableName} SET
                {nameof(SpecialInfo.SiteId)} = @{nameof(SpecialInfo.SiteId)},  
                {nameof(SpecialInfo.Title)} = @{nameof(SpecialInfo.Title)}, 
                {nameof(SpecialInfo.Url)} = @{nameof(SpecialInfo.Url)},
                {nameof(SpecialInfo.AddDate)} = @{nameof(SpecialInfo.AddDate)}
            WHERE {nameof(SpecialInfo.Id)} = @{nameof(SpecialInfo.Id)}";

            IDataParameter[] parameters =
            {
                GetParameter(nameof(specialInfo.SiteId),  DataType.Integer,  specialInfo.SiteId),
                GetParameter(nameof(specialInfo.Title),   DataType.VarChar,                   200,specialInfo.Title),
                GetParameter(nameof(specialInfo.Url),     DataType.VarChar,                   200,specialInfo.Url),
                GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate),
                GetParameter(nameof(specialInfo.Id),      DataType.Integer,  specialInfo.Id)
            };

            ExecuteNonQuery(sqlString, parameters);

            TemplateManager.RemoveCache(specialInfo.SiteId);
        }
Example #18
0
    public void ObtainExp(Role from)
    {
        LevelTplData levelTpl   = TemplateManager.GetLevelTpl(from.GetRoleInfo().Level);
        int          exp        = Mathf.FloorToInt(levelTpl.Expreward * (1 + Random.Range(-0.03f, 0.03f))) + from.GetRoleInfo().Tpl.Extraexp;
        int          levelDelta = _roleInfo.Level - from.GetRoleInfo().Level;

        if (levelDelta > 0)
        {
            if (levelDelta == 1)
            {
                exp = Mathf.FloorToInt(exp * 0.97f);
            }
            else if (levelDelta == 2)
            {
                exp = Mathf.FloorToInt(exp * 0.96f);
            }
            else if (levelDelta == 3)
            {
                exp = Mathf.FloorToInt(exp * 0.95f);
            }
            else if (levelDelta == 4)
            {
                exp = Mathf.FloorToInt(exp * 0.9f);
            }
            else if (levelDelta == 5)
            {
                exp = Mathf.FloorToInt(exp * 0.70f);
            }
            else
            {
                exp = Mathf.FloorToInt(exp * 0.30f);
            }
        }
        if (exp < 1)
        {
            exp = 1;
        }
        _roleInfo.Exp += exp;
    }
        public bool AddCheckPoint(Item item, Checkpoint checkpoint)
        {
            var itemTemplate = TemplateManager.GetTemplate(item);

            if (itemTemplate.GetBaseTemplates().Any(x => x.ID == Constants.LighthouseTemplate))
            {
                var lighthouseItem = new _Lighthouse(item);
                lighthouseItem.Editing.BeginEdit();
                lighthouseItem.Accessibility.RawValue = checkpoint.Accessibility.ToString();
                lighthouseItem.BestPractices.RawValue = checkpoint.BestPractices.ToString();
                lighthouseItem.Perfomance.RawValue    = checkpoint.Performance.ToString();
                lighthouseItem.SEO.RawValue           = checkpoint.SEO.ToString();
                lighthouseItem.Data.RawValue          = AddDataCheckpoint(lighthouseItem.Data.RawValue, checkpoint);
                lighthouseItem.Editing.EndEdit();
            }
            else
            {
                Sitecore.Diagnostics.Log.Error($"Lighthouse: could not save data, item is not inherited from _Lighthouse template {Constants.LighthouseTemplate}", this);
            }

            return(false);
        }
        public void TagEndProcess(TemplateManager manager, Tag tag, string innerContent)
        {
            Expression exp;
            string     _sitedir, _isimg, _img, _imgurl;

            exp = tag.AttributeValue("sitedir");
            if (exp == null)
            {
                throw new Exception("没有sitedir标签");
            }
            _sitedir = manager.EvalExpression(exp).ToString();
            exp      = tag.AttributeValue("isimg");
            if (exp == null)
            {
                _isimg = "0";
            }
            else
            {
                _isimg = manager.EvalExpression(exp).ToString();
            }
            exp = tag.AttributeValue("img");
            if (exp == null)
            {
                _img = "";
            }
            else
            {
                _img = manager.EvalExpression(exp).ToString();
            }
            if (_isimg == "0" || _img.Length == 0)
            {
                _imgurl = "/lib/images/nopic.jpg";
            }
            else
            {
                _imgurl = _img;
            }
            manager.WriteValue(_imgurl);
        }
        protected Activity ToAdaptiveCardForPreviousPageByLG(
            ITurnContext turnContext,
            List <TaskItem> todos,
            int allTasksCount,
            bool isFirstPage,
            string listType)
        {
            bool useFile = Channel.GetChannelId(turnContext) == Channels.Msteams;

            var activity = TemplateManager.GenerateActivityForLocale(ToDoSharedResponses.PreviousPage, new
            {
                Title          = string.Format(ToDoStrings.CardTitle, listType),
                TotalNumber    = allTasksCount > 1 ? string.Format(ToDoStrings.CardMultiNumber, allTasksCount.ToString()) : string.Format(ToDoStrings.CardOneNumber, allTasksCount.ToString()),
                ToDos          = todos,
                UseFile        = useFile,
                CheckIconUrl   = useFile ? GetImageUri(IconImageSource.CheckIconFile) : IconImageSource.CheckIconSource,
                UnCheckIconUrl = useFile ? GetImageUri(IconImageSource.UncheckIconFile) : IconImageSource.UncheckIconSource
            });

            activity.Speak += todos.ToSpeechString(CommonStrings.And, li => li.Topic);
            return(activity);
        }
        protected Activity ToAdaptiveCardForDeletionRefusedFlowByLG(
            ITurnContext turnContext,
            List <TaskItem> todos,
            int allTasksCount,
            string listType)
        {
            bool useFile = Channel.GetChannelId(turnContext) == Channels.Msteams;

            var activity = TemplateManager.GenerateActivityForLocale(ToDoSharedResponses.DeletionAllConfirmationRefused, new
            {
                TaskCount      = allTasksCount,
                ListType       = listType,
                Title          = string.Format(ToDoStrings.CardTitle, listType),
                TotalNumber    = allTasksCount > 1 ? string.Format(ToDoStrings.CardMultiNumber, allTasksCount.ToString()) : string.Format(ToDoStrings.CardOneNumber, allTasksCount.ToString()),
                ToDos          = todos,
                UseFile        = useFile,
                CheckIconUrl   = useFile ? GetImageUri(IconImageSource.CheckIconFile) : IconImageSource.CheckIconSource,
                UnCheckIconUrl = useFile ? GetImageUri(IconImageSource.UncheckIconFile) : IconImageSource.UncheckIconSource
            });

            return(activity);
        }
Example #23
0
        public void TestTemplateManagerWithMutipleThemesShouldWork()
        {
            // If the same resource name exists in the override folder, use the overriden one
            var themes = new List <string> {
                "tmpl1", "tmpl/tmpl1"
            };
            var manager      = new TemplateManager(GetType().Assembly, "tmpl", null, themes, null);
            var outputFolder = Path.Combine(_outputFolder, "TestTemplateManager_MutipleThemes");

            manager.ProcessTheme(outputFolder, true);
            // 1. Support tmpl1.zip
            var file1 = Path.Combine(outputFolder, "tmpl1.dot.$");

            Assert.True(File.Exists(file1));
            Assert.Equal("Override: This is file with complex filename characters", File.ReadAllText(file1));

            // backslash is also supported
            var file2 = Path.Combine(outputFolder, "sub/file1");

            Assert.True(File.Exists(file2));
            Assert.Equal("Override: This is file inside a subfolder", File.ReadAllText(file2));
        }
        public DocumentBuilderWrapper(
            BuildJsonConfig config,
            TemplateManager manager,
            string baseDirectory,
            string outputDirectory,
            string pluginDirectory,
            CrossAppDomainListener listener,
            string templateDirectory)
        {
            _config            = config ?? throw new ArgumentNullException(nameof(config));
            _pluginDirectory   = pluginDirectory;
            _baseDirectory     = baseDirectory;
            _outputDirectory   = outputDirectory;
            _listener          = listener;
            _manager           = manager;
            _logLevel          = Logger.LogLevelThreshold;
            _templateDirectory = templateDirectory;

            // pass EnvironmentContext into another domain
            _disableGitFeatures = EnvironmentContext.GitFeaturesDisabled;
            _version            = EnvironmentContext.Version;
        }
        public override CommandState QueryState(CommandContext context)
        {
            var requiredTemplate = context.Parameters[RequireTemplateParameter];

            if (!string.IsNullOrEmpty(requiredTemplate))
            {
                if (context.Items.Length != 1)
                {
                    return CommandState.Disabled;
                }

                var template = TemplateManager.GetTemplate(context.Items[0]);
                var result = template.InheritsFrom(requiredTemplate)
                    ? base.QueryState(context)
                    : CommandState.Disabled;
                return result;
            }

            return context.Items.Length != 1 || context.Parameters["ScriptRunning"] == "1"
                ? CommandState.Disabled
                : CommandState.Enabled;
        }
        protected async Task <DialogTurnResult> IfCreateTicketAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (sc.Result is EndFlowResult endFlow)
            {
                return(await sc.EndDialogAsync(await CreateActionResultAsync(sc.Context, endFlow.Result, cancellationToken), cancellationToken));
            }

            // Skip create ticket in action mode
            var state = await StateAccessor.GetAsync(sc.Context, () => new SkillState(), cancellationToken);

            if (state.IsAction)
            {
                return(await sc.EndDialogAsync(cancellationToken : cancellationToken));
            }

            var options = new PromptOptions()
            {
                Prompt = TemplateManager.GenerateActivity(KnowledgeResponses.IfCreateTicket)
            };

            return(await sc.PromptAsync(nameof(ConfirmPrompt), options, cancellationToken));
        }
Example #27
0
        public override void DoJob(dynamic data)
        {
            var operationGuid = string.Empty;

            try
            {
                var json = JsonConvert.DeserializeObject(data);
                operationGuid = json.OrderDemandGuid;

                var mail = new MailHelper(TemplateManager.EmailResources(_configuration["FileSystemResourceManagerResourcesPath"]).GetString(json.TemplateName.Value), _configuration["SmtpServer"], _configuration["SubjectPrefix"]);
                mail.ParseBody(json);

                mail.Send(_configuration["Bcc"]);

                _orderDemandRepository.ChangeOrderDemandState(operationGuid, (int)OrderDemandStates.Finished);
            }
            catch (Exception ex)
            {
                _orderDemandRepository.ChangeOrderDemandState(operationGuid, (int)OrderDemandStates.FinishedError);
                _logRepository.InsertLogoRecord(nameof(SendMail), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, data);
            }
        }
Example #28
0
        private async Task <DialogTurnResult> EndDialogAsync(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            var userState = await UserStateAccessor.GetAsync(sc.Context, () => new HospitalityUserSkillState(HotelService), cancellationToken);

            if (userState.CheckedOut)
            {
                var tokens = new Dictionary <string, object>
                {
                    { "Email", userState.Email },
                };

                // TODO process request to send email receipt
                // checked out confirmation message
                await sc.Context.SendActivityAsync(TemplateManager.GenerateActivity(CheckOutResponses.SendEmailMessage, tokens), cancellationToken);

                await sc.Context.SendActivityAsync(TemplateManager.GenerateActivity(CheckOutResponses.CheckOutSuccess), cancellationToken);

                return(await sc.EndDialogAsync(await CreateSuccessActionResultAsync(sc.Context, cancellationToken), cancellationToken));
            }

            return(await sc.EndDialogAsync(cancellationToken : cancellationToken));
        }
Example #29
0
        public IHttpActionResult List()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var siteId = request.GetQueryInt("siteId");
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, Utils.PluginId))
                {
                    return(Unauthorized());
                }

                return(Ok(new
                {
                    Value = TemplateManager.GetTemplateInfoList()
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #30
0
        public override void Execute(CommandContext context)
        {
            Assert.IsNotNull(context, "context");
            Assert.IsNotNull(context.Parameters["id"], "id");

            string   contextDbName = Settings.GetSetting(SitecronConstants.SettingsNames.SiteCronContextDB, "master");
            Database contextDb     = Factory.GetDatabase(contextDbName);

            Item scriptItem = contextDb.GetItem(new ID(context.Parameters["id"]));

            if (scriptItem != null && TemplateManager.IsFieldPartOfTemplate(SitecronConstants.SiteCronFieldIds.CronExpression, scriptItem))
            {
                string newItemName = ItemUtil.ProposeValidItemName(string.Concat("Execute Now ", scriptItem.Name, DateTime.Now.ToString(" yyyyMMddHHmmss")));

                Item autoFolderItem = contextDb.GetItem(SitecronConstants.ItemIds.AutoFolderID);
                if (autoFolderItem != null)
                {
                    Item newScriptItem = scriptItem.CopyTo(autoFolderItem, newItemName);

                    double addExecutionSeconds = 20;
                    if (!Double.TryParse(Settings.GetSetting(SitecronConstants.SettingsNames.SiteCronExecuteNowSeconds), out addExecutionSeconds))
                    {
                        addExecutionSeconds = 20;
                    }

                    using (new EditContext(newScriptItem, Sitecore.SecurityModel.SecurityCheck.Disable))
                    {
                        DateTime executeTime = DateTime.Now.AddSeconds(addExecutionSeconds);
                        newScriptItem[SitecronConstants.FieldNames.CronExpression]           = string.Format("{0} {1} {2} 1/1 * ? * ", executeTime.ToString("ss"), executeTime.ToString("mm"), executeTime.ToString("HH"));
                        newScriptItem[SitecronConstants.FieldNames.ArchiveAfterExecution]    = "1";
                        newScriptItem[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime] = "";
                        newScriptItem[SitecronConstants.FieldNames.Disable] = "0";
                    }
                    var newIndexItem = (SitecoreIndexableItem)newScriptItem;
                    ContentSearchManager.GetIndex(Settings.GetSetting(SitecronConstants.SettingsNames.SiteCronGetItemsIndex, "sitecore_master_index").Trim()).Refresh(newIndexItem);
                }
            }
        }
Example #31
0
        private async Task <DialogTurnResult> CollectBuildingPromptAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken);

                if (!string.IsNullOrEmpty(state.MeetingInfo.Building))
                {
                    List <RoomModel> meetingRooms = await searchService.GetMeetingRoomAsync(building : state.MeetingInfo.Building);

                    if (meetingRooms.Any())
                    {
                        return(await sc.NextAsync(result : meetingRooms, cancellationToken : cancellationToken));
                    }
                    else
                    {
                        return(await sc.PromptAsync(Actions.BuildingPromptForCreate, new CalendarPromptOptions
                        {
                            Prompt = TemplateManager.GenerateActivityForLocale(FindMeetingRoomResponses.BuildingNonexistent),
                            MaxReprompt = CalendarCommonUtil.MaxRepromptCount
                        }, cancellationToken));
                    }
                }

                return(await sc.PromptAsync(Actions.BuildingPromptForCreate, new CalendarPromptOptions
                {
                    Prompt = TemplateManager.GenerateActivityForLocale(FindMeetingRoomResponses.NoBuilding),
                    RetryPrompt = TemplateManager.GenerateActivityForLocale(FindMeetingRoomResponses.BuildingNonexistent),
                    MaxReprompt = CalendarCommonUtil.MaxRepromptCount
                }, cancellationToken));
            }
            catch (Exception ex)
            {
                await HandleDialogExceptionsAsync(sc, ex, cancellationToken);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
        }
        private async Task <DialogTurnResult> SendChangeAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken);

            var change = state.Changes[0];
            var settingChangeConfirmed = false;

            // If we skip the ConfirmPrompt due to no confirmation needed then Result will be NULL
            if (sc.Result == null)
            {
                settingChangeConfirmed = true;
            }
            else
            {
                settingChangeConfirmed = (bool)sc.Result;
                change.IsConfirmed     = settingChangeConfirmed;
            }

            if (settingChangeConfirmed)
            {
                string promptTemplate = VehicleSettingsResponses.VehicleSettingsConfirmed;

                await SendActionToDeviceAsync(sc, change, cancellationToken);

                await sc.Context.SendActivityAsync(TemplateManager.GenerateActivityForLocale(promptTemplate), cancellationToken);
            }
            else
            {
                await sc.Context.SendActivityAsync(TemplateManager.GenerateActivityForLocale(VehicleSettingsResponses.VehicleSettingsSettingChangeConfirmationDenied), cancellationToken);
            }

            if (state.IsAction)
            {
                return(await sc.EndDialogAsync(new ActionResult(true), cancellationToken));
            }

            return(await sc.EndDialogAsync(cancellationToken : cancellationToken));
        }
Example #33
0
        public async Task <ActionResult> ScanTemplate(string templateName)
        {
            var scanInfo = new ScanTemplateInfo();
            var listInfo = new List <FormInformation>();

            if (string.IsNullOrEmpty(templateName))
            {
                return(new EmptyResult());
            }

            var spContext = SharePointContextProvider.Current.GetSharePointContext(System.Web.HttpContext.Current);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                var blobInfo = await TemplateManager.GetXsnBlobInfo(templateName, StorageContext);

                if (blobInfo == null)
                {
                    return(new EmptyResult());
                }

                try
                {
                    FormInformation info = InfoPathAnalytics.FormInformation(blobInfo.FileStream);
                    info.XsnUrl = blobInfo.FileName;
                    listInfo.Add(info);
                }
                catch
                {
                    scanInfo.AddMessage(templateName);
                }
            }


            scanInfo.FormInfos = listInfo;

            return(View("ScanTemplates", scanInfo));
        }
        public void OnItemSaving(object sender, EventArgs args)
        {
            Item savingItem = null;
            ItemSavedRemoteEventArgs remoteArgs = args as ItemSavedRemoteEventArgs;

            //Thank you Mike Edwards!
            if (remoteArgs != null)
            {
                savingItem = remoteArgs.Item;
            }
            else
            {
                savingItem = Event.ExtractParameter(args, 0) as Item;
            }

            if (savingItem != null && TemplateManager.IsFieldPartOfTemplate(SitecronConstants.SiteCronFieldIds.CronExpression, savingItem) && !StandardValuesManager.IsStandardValuesHolder(savingItem) && !_inProcess.Contains(savingItem.ID))
            {
                _inProcess.Add(savingItem.ID);

                Item existingItem = savingItem.Database.GetItem(savingItem.ID, savingItem.Language, savingItem.Version);
                if (existingItem.Fields[SitecronConstants.FieldNames.Disable].Value != savingItem.Fields[SitecronConstants.FieldNames.Disable].Value)
                {
                    string appendText = "";
                    string icon = "";
                    if (savingItem.Fields[SitecronConstants.FieldNames.Disable].Value == "1")
                    {
                        appendText = " _DISABLED_";
                        icon = "Applications/32x32/gears_stop.png";
                    }
                    else
                        icon = "Applications/32x32/gears.png";

                    savingItem.Appearance.Icon = icon;
                    savingItem.Appearance.DisplayName = string.Concat(savingItem.Name, appendText);
                }
                _inProcess.Remove(savingItem.ID);
            }
        }
Example #35
0
        public DocumentBuilderWrapper(
            BuildJsonConfig config,
            TemplateManager manager,
            string baseDirectory,
            string outputDirectory,
            string pluginDirectory,
            CrossAppDomainListener listener,
            string templateDirectory)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _pluginDirectory   = pluginDirectory;
            _baseDirectory     = baseDirectory;
            _outputDirectory   = outputDirectory;
            _config            = config;
            _listener          = listener;
            _manager           = manager;
            _logLevel          = Logger.LogLevelThreshold;
            _templateDirectory = templateDirectory;
        }
Example #36
0
        private async Task <DialogTurnResult> CollectMeetingRoomPromptAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken);

                if (state.MeetingInfo.RecreateState == RecreateEventState.MeetingRoom || string.IsNullOrEmpty(Settings.AzureSearch?.SearchServiceName))
                {
                    return(await sc.NextAsync(cancellationToken : cancellationToken));
                }
                else
                {
                    var prompt = TemplateManager.GenerateActivityForLocale(CreateEventResponses.NoMeetingRoom);
                    return(await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = prompt }, cancellationToken));
                }
            }
            catch (Exception ex)
            {
                await HandleDialogExceptionsAsync(sc, ex, cancellationToken);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
        }
Example #37
0
        private async Task <DialogTurnResult> CreateMeetingAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken);

                if (state.MeetingInfo.MeetingRoom == null)
                {
                    throw new NullReferenceException("CreateMeeting received a null MeetingRoom.");
                }

                var activity = TemplateManager.GenerateActivityForLocale(FindMeetingRoomResponses.ConfirmedMeetingRoom);
                await sc.Context.SendActivityAsync(activity, cancellationToken);

                return(await sc.ReplaceDialogAsync(nameof(CreateEventDialog), sc.Options, cancellationToken));
            }
            catch (Exception ex)
            {
                await HandleDialogExceptionsAsync(sc, ex, cancellationToken);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
        }
Example #38
0
        public AdminModules(ITokenizer tokenizer)
            : base("/admin")
        {
            WebManager webManager = new WebManager();
            ReportManager reportManager = new ReportManager();
            AdminManager adminManager = new AdminManager();
            EvaluatorManager evaluatorManager = new EvaluatorManager();
            TopicManager topicManager = new TopicManager();
            SponsorManager sponsorManager = new SponsorManager();
            RegistrationManager registration = new RegistrationManager();
            GuestManager guest = new GuestManager();
            TemplateManager templateManager = new TemplateManager();
            AuthTemplateManager authTemplateManager = new AuthTemplateManager();
            SubmissionManager submissionManager = new SubmissionManager();
            BannerManager bannerManager = new BannerManager();

            /*------------------Payment--------------------------*/
            Post["/secureReentry"] = parameters =>
            {
                /*receive the tandem ID  and information store on data base and confirm payment
                /*return in the xml the the receipt link or the error link*/
                return Response.AsXml("");

            };

            /* ----- Template -----*/

            Post["/addTemplate"] = parameters =>
            {
                var temp = this.Bind<TemplateManager.templateQuery>();
                TemplateManager.templateQuery result = templateManager.addTemplate(temp);
                if (result != null)
                {
                    return Response.AsJson(result);
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }

            };

            Get["/getTemplatesAdmin"] = parameters =>
            {

                return Response.AsJson(templateManager.getTemplates());
            };

            Get["/getTemplatesAdminListIndex/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(templateManager.getTemplates(index));
            };

            Put["/deleteTemplate"] = parameters =>
            {
                var id = this.Bind<long>();
                int result = templateManager.deleteTemplate(id);
                if (result == 1 || result == 0)
                    return Response.AsJson(result);

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };
            Put["/updateTemplate"] = parameters =>
            {
                var template = this.Bind<template>();

                if (templateManager.updateTemplate(template))
                {
                    return HttpStatusCode.OK;
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };
            /* ----- Auth Template -----*/

            Post["/addAuthTemplate"] = parameters =>
            {
                var temp = this.Bind<AuthTemplateManager.templateQuery>();
                AuthTemplateManager.templateQuery result = authTemplateManager.addTemplate(temp);
                if (result != null)
                {
                    return Response.AsJson(result);
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }

            };

            Get["/getAuthTemplatesAdmin"] = parameters =>
            {

                return Response.AsJson(authTemplateManager.getTemplates());
            };

            Get["/getAuthTemplatesAdminListIndex/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(authTemplateManager.getTemplates(index));
            };

            Put["/deleteAuthTemplate"] = parameters =>
            {
                var id = this.Bind<int>();
                if (authTemplateManager.deleteTemplate(id))
                {
                    return HttpStatusCode.OK;
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };

            Put["/updateAuthTemplate"] = parameters =>
            {
                var template = this.Bind<authorizationtemplate>();

                if (authTemplateManager.updateTemplate(template))
                {
                    return HttpStatusCode.OK;
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };

            /* ----- Sponsor Complementary-----*/
            Post["/addSponsorComplementaryKeys"] = parameters =>
            {

                var obj = this.Bind<NancyService.Modules.SponsorManager.addComplementary>();
                return Response.AsJson(sponsorManager.addKeysTo(obj));

            };
            Put["/deleteComplementaryKey"] = parameters =>
            {
                var id = this.Bind<long>();
                if (sponsorManager.deleteComplementary(id))
                {
                    return HttpStatusCode.OK;
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };
            Put["/deleteSponsorComplementaryKey"] = parameters =>
            {
                var id = this.Bind<long>();
                return Response.AsJson(sponsorManager.deleteComplementarySponsor(id));
            };
            Get["/getComplementaryKeys"] = parameters =>
            {
                try
                {
                    // this.RequiresAuthentication();
                    // this.RequiresClaims(new[] { "minor" });
                    return Response.AsJson(sponsorManager.getComplementaryList());
                }
                catch { return null; }
            };
            Get["/getSponsorComplementaryKeys/{id:long}"] = parameters =>
            {
                try
                {
                    long id = parameters.id;
                    return Response.AsJson(sponsorManager.getSponsorComplementaryList(id));
                }
                catch { return null; }
            };

            Get["/getSponsorComplementaryKeysFromIndex/{index:int}/{id:long}"] = parameters =>
            {
                try
                {
                    NancyService.Modules.SponsorManager.ComplimentaryPagingQuery info = new NancyService.Modules.SponsorManager.ComplimentaryPagingQuery();
                    info.sponsorID = parameters.id;
                    info.index = parameters.index;
                    return Response.AsJson(sponsorManager.getSponsorComplementaryList(info));
                }
                catch { return null; }
            };

            Get["/searchKeyCodes/{index:int}/{id:long}/{criteria}"] = parameters =>
            {
                try
                {
                    NancyService.Modules.SponsorManager.ComplimentaryPagingQuery info = new NancyService.Modules.SponsorManager.ComplimentaryPagingQuery();
                    info.sponsorID = parameters.id;
                    info.index = parameters.index;
                    string criteria = parameters.criteria;
                    return Response.AsJson(sponsorManager.searchKeyCodes(info, criteria));
                }
                catch { return null; }
            };

            //--------------------------------------------Sponsor----------------------------

            Get["/getSponsorDeadline/"] = parameters =>
            {
                this.RequiresAuthentication();
                this.RequiresAnyClaim(new[] { "sponsor", "admin", "Master", "Admin", "CommitteEvaluator" });
                return Response.AsJson(sponsorManager.getSponsorDeadline());
            };

            Post["/addsponsor"] = parameters =>
            {

                var sponsor = this.Bind<NancyService.Modules.SponsorManager.SponsorQuery>();
                SponsorManager.SponsorQuery added = sponsorManager.addSponsor(sponsor);
                if (added != null)
                {
                    return Response.AsJson(added);
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };

            Get["/getSponsorListIndex/{index:int}"] = parameters =>
            {

                int index = parameters.index;
                return Response.AsJson(sponsorManager.getSponsorList(index));
            };

            Get["/getSponsorbyID/{id:long}"] = parameters =>
            {
                try
                {
                    this.RequiresAuthentication();
                    this.RequiresAnyClaim(new[] { "sponsor", "admin", "Master", "Admin", "CommitteEvaluator" });
                    long id = parameters.id;
                    return Response.AsJson(sponsorManager.getSponsorbyID(id));
                }
                catch { return null; }
            };

            Put["/updateSponsor"] = parameters =>
            {
                var sponsor = this.Bind<NancyService.Modules.SponsorManager.SponsorQuery>();
                SponsorManager.SponsorQuery s = sponsorManager.updateSponsor(sponsor);
                if (s != null)
                {
                    return Response.AsJson(s);
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };

            Get["/getSponsorTypesList"] = parameters =>
            {
                try
                {
                    //this.RequiresAuthentication();
                    //this.RequiresClaims(new[] { "admin" });
                    return Response.AsJson(sponsorManager.getSponsorTypesList());
                }
                catch { return null; }
            };

            Put["/deleteSponsor"] = parameters =>
            {
                var id = this.Bind<long>();
                if (sponsorManager.deleteSponsor(id))
                {
                    return HttpStatusCode.OK;
                }

                else
                {
                    return HttpStatusCode.Conflict;
                }
            };

            Get["/searchSponsors/{index:int}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                return Response.AsJson(sponsorManager.searchSponsors(index, criteria));
                //
            };

            /* ----- Topic -----(Heidi)*/

            //get list of conference topics
            Get["/getTopic"] = parameters =>
            {

                return Response.AsJson(topicManager.getTopicList());
            };

            //add a new topic
            Post["/addTopic"] = parameters =>
            {
                var topic = this.Bind<topiccategory>();
                return Response.AsJson(topicManager.addTopic(topic));
            };

            //update a new topic
            Put["/updateTopic"] = parameters =>
            {
                var topic = this.Bind<topiccategory>();
                return (topicManager.updateTopic(topic));
            };

            //delete topic
            Put["/deleteTopic/{topiccategoryID:int}"] = parameters =>
            {
                return topicManager.deleteTopic(parameters.topiccategoryID);
            };

            /* ----- Administrators -----(Heidi)*/

            //check if there an email has account in ConferenceAdmin when adding a new evaluator
            Get["/getNewAdmin/{email}"] = parameters =>
            {
                return adminManager.checkNewAdmin(parameters.email);
            };

            //get list of administratos
            Get["/getAdministrators/{index:int}"] = parameters =>
            {
                try
                {
                    int index = parameters.index;
                    return Response.AsJson(adminManager.getAdministratorList(index));
                }
                catch { return null; }
            };

            //get list of privileges in the system
            Get["/getPrivilegesList"] = parameters =>
            {
                try
                {
                    //this.RequiresAuthentication();
                    //this.RequiresClaims(new[] { "admin" });
                    return Response.AsJson(adminManager.getPrivilegesList());
                }
                catch { return null; }
            };

            //create a new administrator with a specified privilege
            Post["/addAdmin"] = parameters =>
            {
                var newAdmin = this.Bind<AdministratorQuery>();
                return Response.AsJson(adminManager.addAdmin(newAdmin));
            };

            //update an administrator
            Put["/editAdmin"] = parameters =>
            {
                var editAdmin = this.Bind<AdministratorQuery>();
                return Response.AsJson(adminManager.editAdministrator(editAdmin));
            };

            //remove administrator privileges to a user
            Put["/deleteAdmin"] = parameters =>
            {
                var delAdmin = this.Bind<AdministratorQuery>();
                return adminManager.deleteAdministrator(delAdmin);
            };

            //search administrators that contain the search criteria
            Get["/searchAdmin/{index:int}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                return Response.AsJson(adminManager.searchAdministrators(index, criteria));
            };

            /*------ Evaluators -----(Heidi)*/

            //get list of evaluators past applications
            Get["/getEvaluatorListFromIndex/{index:int}/{id:int}"] = parameters =>
            {
                int index = parameters.index;
                int id = parameters.id;
                return Response.AsJson(evaluatorManager.getEvaluatorList(index, id));
            };

            //get pending list of evaluators
            Get["/getPendingListFromIndex/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(evaluatorManager.getPendingList(index));
            };

            //check evaluator has an account in ConferenceAdmin
            Get["/getNewEvaluator/{email}"] = parameters =>
            {
                return evaluatorManager.checkNewEvaluator(parameters.email);
            };

            //add a new evaluator with status "Accepted"
            Post["/addEvaluator/{email}"] = parameters =>
            {
                return evaluatorManager.addEvaluator(parameters.email);
            };

            //update status of an evaluator application
            Put["/updateEvaluatorAcceptanceStatus"] = parameters =>
            {
                var updateEvaluator = this.Bind<EvaluatorQuery>();
                return (evaluatorManager.updateAcceptanceStatus(updateEvaluator));
            };

            //search evaluators that contain search criteria
            Get["/searchEvaluators/{index:int}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                return Response.AsJson(evaluatorManager.searchEvaluators(index, criteria));
            };

            /* --------------------------------------- Registration ----------------------------------------*/

            Get["/getRegistrations/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                var list = registration.getRegistrationList(index);
                return Response.AsJson(list);
            };

            Get["/getUserTypes"] = parameters =>
            {
                List<UserTypeName> list = registration.getUserTypesList();
                return Response.AsJson(list);
            };

            Put["/updateRegistration"] = parameters =>
            {
                var registeredUser = this.Bind<RegisteredUser>();
                if (registration.updateRegistration(registeredUser))
                    return HttpStatusCode.OK;

                else
                    return HttpStatusCode.Conflict;
            };

            Delete["/deleteRegistration/{registrationID:int}"] = parameters =>
            {
                if (registration.deleteRegistration(parameters.registrationID))
                    return HttpStatusCode.OK;

                else
                    return HttpStatusCode.Conflict;
            };

            Post["/addRegistration"] = parameters =>
            {
                var user = this.Bind<user>();
                var reg = this.Bind<registration>();
                var mem = this.Bind<membership>();
                return Response.AsJson(registration.addRegistration(reg: reg, user: user, mem: mem));
            };

            Get["/getDates"] = parameters =>
            {
                List<string> list = registration.getDates();
                return Response.AsJson(list);
            };

            // [Randy] search within the list with a certain criteria
            Get["/searchRegistration/{index}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                var list = registration.searchRegistration(index, criteria);
                return Response.AsJson(list);
            };

            Get["/getAttendanceReport"] = parameters =>
            {
                return Response.AsJson(reportManager.getAttendanceReport());
            };

            //-------------------------------------GUESTS---------------------------------------------
            //Jaimeiris - Guest list for admins
            Get["/getGuestList/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                GuestsPagingQuery guestList = guest.getListOfGuests(index);

                if (guestList == null)
                {
                    guestList = new GuestsPagingQuery();
                }
                return Response.AsJson(guestList);
            };

            //Jaimeiris - update acceptance status of guest
            Put["/updateAcceptanceStatus"] = parameters =>
            {
                var update = this.Bind<AcceptanceStatusInfo>();
                int guestID = update.id;
                String acceptanceStatus = update.status;

                if (guest.updateAcceptanceStatus(guestID, acceptanceStatus)) return HttpStatusCode.OK;
                else return HttpStatusCode.Conflict;
            };

            //Jaimeiris - set registration status of guest to Rejected.
            Put["/rejectRegisteredGuest/{id}"] = parameters =>
            {
                int id = parameters.id;

                if (guest.rejectRegisteredGuest(id)) return HttpStatusCode.OK;
                else return HttpStatusCode.Conflict;
            };

            //Jaimeiris - get minor's authorizations
            Get["/displayAuthorizations/{id}"] = parameters =>
            {
                int id = parameters.id;
                List<MinorAuthorizations> authorizations = guest.getMinorAuthorizations(id);
                if (authorizations == null)
                {
                    authorizations = new List<MinorAuthorizations>();
                }
                return Response.AsJson(authorizations);
            };

            // [Randy] search within the list with a certain criteria
            Get["/searchGuest/{index}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                var list = guest.searchGuest(index, criteria);
                return Response.AsJson(list);
            };

            //-----------------------------------------WEBSITE CONTENT ----------------------------------[Heidi]

            //get content of the Home section of the website
            Get["/getHome"] = parameters =>
            {
                return Response.AsJson(webManager.getHome());
            };

            //get image found in the Home section of the website
            Get["/getHomeImage"] = parameters =>
            {
                return Response.AsJson(webManager.getHomeImage());
            };

            //get conference logo
            Get["/getWebsiteLogo"] = parameters =>
            {
                return Response.AsJson(webManager.getWebsiteLogo());
            };

            //Update content found in the Home section of the website
            Put["/saveHome"] = parameters =>
            {
                var home = this.Bind<HomeQuery>();
                return webManager.saveHome(home);
            };

            //remove an image from conference content
            Put["/removeFile/{data}"] = parameters =>
            {
                return webManager.removeFile(parameters.data);
            };

            //get content found in the Venue section of the website
            Get["/getVenue"] = parameters =>
            {
                return Response.AsJson(webManager.getVenue());
            };

            //update content found in the Venue section of the website
            Put["/saveVenue"] = parameters =>
            {
                var venue = this.Bind<VenueQuery>();
                return webManager.saveVenue(venue);
            };

            //get content found in the Contact section of the website
            Get["/getContact"] = parameters =>
            {
                return Response.AsJson(webManager.getContact());
            };

            //update content found in the Contact section of the website
            Put["/saveContact"] = parameters =>
            {
                var contact = this.Bind<ContactQuery>();
                return webManager.saveContact(contact);
            };

            //send inquire email
            Post["/sendContactEmail"] = parameters =>
            {
                var emailInfo = this.Bind<ContactEmailQuery>();
                return Response.AsJson(webManager.sendContactEmail(emailInfo));
            };

            //get content found in the Call for Participation section of the website
            Get["/getParticipation"] = parameters =>
            {
                return Response.AsJson(webManager.getParticipation());
            };

            //update content found in the Call for Participation section of the website
            Put["/saveParticipation"] = parameters =>
            {
                var participation = this.Bind<ParticipationQuery>();
                return webManager.saveParticipation(participation);
            };

            //get content found in the Registration section of the website and registration fees
            Get["/getRegistrationInfo"] = parameters =>
            {
                return Response.AsJson(webManager.getRegistrationInfo());
            };

            //update content found in the Registration section of the website and registration fees
            Put["/saveRegistrationInfo"] = parameters =>
            {
                var registrationInfo = this.Bind<RegistrationQuery>();
                return webManager.saveRegistrationInfo(registrationInfo);
            };

            //get conference deadlines
            Get["/getDeadlines"] = parameters =>
            {
                return Response.AsJson(webManager.getDeadlines());
            };

            //get conference deadlines formatted to string: day of the week, day of the month, month and year
            Get["/getInterfaceDeadlines"] = parameters =>
            {
                return Response.AsJson(webManager.getInterfaceDeadlines());
            };

            //update conference deadlines
            Put["/saveDeadlines"] = parameters =>
            {
                var deadlines = this.Bind<DeadlinesQuery>();
                return webManager.saveDeadlines(deadlines);
            };

            //get content found in the Committee section of the website
            Get["/getCommitteeInterface"] = parameters =>
            {
                return Response.AsJson(webManager.getCommittee());
            };

            //update content found in the Committee section of the website
            Put["/saveCommitteeInterface"] = parameters =>
            {
                var info = this.Bind<CommitteeQuery>();
                return webManager.saveCommittee(info);
            };

            //get the benefits of a sponsor category
            Get["/getAdminSponsorBenefits/{data}"] = parameters =>
            {
                return webManager.getAdminSponsorBenefits(parameters.data);
            };

            //update benefits of a sponsor category
            Put["/saveAdminSponsorBenefits"] = parameters =>
            {
                var sponsor = this.Bind<SaveSponsorQuery>();
                return webManager.saveSponsorBenefits(sponsor);
            };

            //update content found in the Sponsor section of the website
            Put["/saveInstructions"] = parameters =>
            {
                var info = this.Bind<SponsorInterfaceBenefits>();
                return webManager.saveInstructions(info);
            };

            //get content found in the Sponsor section of the website
            Get["/getSponsorInstructions"] = parameters =>
            {
                return Response.AsJson(webManager.getInstructions());
            };

            //get all benefits for each category (for website content)
            Get["/getAllSponsorBenefits"] = parameters =>
            {
                return Response.AsJson(webManager.getAllSponsorBenefits());
            };

            //get conference general information: name, days
            Get["/getGeneralInfo"] = parameters =>
            {
                return Response.AsJson(webManager.getGeneralInfo());
            };

            //update conference general information: name, days, logo
            Put["/saveGeneralInfo"] = parameters =>
            {
                var info = this.Bind<GeneralInfoQuery>();
                return webManager.saveGeneralInfo(info);
            };

            //get documents found in the Program section of the website
            Get["/getProgram"] = parameters =>
            {
                return Response.AsJson(webManager.getProgram());
            };

            //get abstract document
            Get["/getAbstractDocument"] = parameters =>
            {
                return Response.AsJson(webManager.getAbstractDocument());
            };

            //get program document
            Get["/getProgramDocument"] = parameters =>
            {
                return Response.AsJson(webManager.getProgramDocument());
            };

            //update documents found in the Program section of the website
            Put["/saveProgram"] = parameters =>
            {
                var info = this.Bind<ProgramQuery>();
                return webManager.saveProgram(info);
            };

            //Get bill report including registrations and sponsor payments
            Get["/getBillReport"] = parameters =>
            {
                return Response.AsJson(reportManager.getBillReportList());
            };

            //search records in the bill report that contain the search criterai
            Get["/searchReport/{index:int}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                return Response.AsJson(reportManager.searchReport(index, criteria));
            };

            //get conference registrations
            Get["/getRegistrationPayments/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(reportManager.getRegistrationPayments(index));
            };

            //get sponsor payments
            Get["/getSponsorPayments/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(reportManager.getSponsorPayments(index));
            };
            //-----------------SUBMISSIONS- JAIMEIRIS------------------------------------
            //Jaimeiris - Gets all submissions in the system that have not been deleted
            Get["/getAllSubmissions/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(submissionManager.getAllSubmissions(index));
            };
            //Jaimeiris - gets the evaluation for a submission
            Get["/getEvaluationsForSubmission/{submissionID}"] = parameters =>
            {
                long submissionID = parameters.submissionID;
                var evaluations = submissionManager.getSubmissionEvaluations(submissionID);

                return Response.AsJson(evaluations);
            };
            //Jaimeiris - gets all approved evaluators so as to assign them submissions to evaluate
            Get["/getAllEvaluators"] = parameters =>
            {
                return Response.AsJson(submissionManager.getAcceptedEvaluators());
            };
            //Jaimeiris - Assigns an evaluator to a submission
            Post["/assignEvaluator/{submissionID:long}/{evaluatorID:long}"] = parameters =>
            {
                long submissionID = parameters.submissionID;
                long evaluatorID = parameters.evaluatorID;

                Evaluation evList = submissionManager.assignEvaluator(submissionID, evaluatorID);

                return Response.AsJson(evList);
            };
            //Jaimeiris - Assigns a template to a submission
            Post["/assignTemplate/{submissionID:long}/{templateID:long}"] = parameters =>
            {
                long submissionID = parameters.submissionID;
                long templateID = parameters.templateID;
                if (submissionManager.assignTemplate(submissionID, templateID)) return HttpStatusCode.OK;
                else return HttpStatusCode.Conflict;
            };
            //Jaimeiris - Get the info of an evaluation
            Get["/getEvaluationDetails/{submissionID:long}/{evaluatorID:long}"] = parameters =>
            {
                long submissionID = parameters.submissionID;
                long evaluatorID = parameters.evaluatorID;
                Evaluation sub = submissionManager.getEvaluationDetails(submissionID, evaluatorID);
                if (sub == null)
                {
                    sub = new Evaluation();
                }
                return Response.AsJson(sub);
            };
            //Jaimeiris - Remove evaluator submission relation
            Put["/removeEvaluatorSubmission/{evaluatorSubmissionID}"] = parameters =>
            {
                long evaluatorSubmissionID = parameters.evaluatorSubmissionID;
                long es = submissionManager.removeEvaluatorSubmission(evaluatorSubmissionID);
                return Response.AsJson(es);
            };
            //Jaimeiris - Change submission status
            Put["/changeSubmissionStatus/{status}/{submissionID}"] = parameters =>
            {
                String newStatus = parameters.status;
                long submissionID = parameters.submissionID;
                Submission sub = submissionManager.changeSubmissionStatus(submissionID, newStatus);

                return Response.AsJson(sub);
            };
            //Jaimeiris - admin adds a submission
            Post["/postAdminSubmission"] = parameters =>
            {
                panel pannelToAdd = null;
                workshop workshopToAdd = null;
                submission submissionToAdd = this.Bind<submission>();
                usersubmission usersubTA = this.Bind<usersubmission>();

                int submissionTypeID = submissionToAdd.submissionTypeID;
                if (submissionTypeID == 3)
                {
                    pannelToAdd = this.Bind<panel>();
                }
                else if (submissionTypeID == 5)
                {
                    workshopToAdd = this.Bind<workshop>();
                }
                Submission newSubmission =
                    submissionManager.addSubmissionByAdmin(usersubTA, submissionToAdd, pannelToAdd, workshopToAdd);
                return Response.AsJson(newSubmission);
            };
            //Jaimeiris - post final version of evaluation submitted by admin
            Post["/postAdminFinalSubmission"] = parameters =>
            {
                panel pannelToAdd = null;
                workshop workshopToAdd = null;
                submission submissionToAdd = this.Bind<submission>();
                documentssubmitted submissionDocuments = this.Bind<documentssubmitted>();
                usersubmission usersubTA = this.Bind<usersubmission>();

                int submissionTypeID = submissionToAdd.submissionTypeID;
                if (submissionDocuments.document == null && submissionDocuments.documentName == null)
                {
                    submissionDocuments = null;
                }
                if (submissionTypeID == 3)
                {
                    pannelToAdd = this.Bind<panel>();
                }
                else if (submissionTypeID == 5)
                {
                    workshopToAdd = this.Bind<workshop>();
                }
                Submission newSubmission =
                    submissionManager.postAdminFinalSubmission(usersubTA, submissionToAdd, submissionDocuments, pannelToAdd, workshopToAdd);
                return Response.AsJson(newSubmission);
            };
            //Jaimeiris - gets all deleted submissions
            Get["/getDeletedSubmissions/{index:int}"] = parameters =>
            {
                int index = parameters.index;
                return Response.AsJson(submissionManager.getDeletedSubmissions(index));
            };
            //Jaimeiris - gets the details of a deleted submission
            Get["/getADeletedSubmission/{submissionID:long}"] = parameters =>
            {
                long submissionID = parameters.submissionID;
                return Response.AsJson(submissionManager.getADeletedSubmission(submissionID));
            };
            //Jaimeiris - gets the list of all users
            Get["/getListOfUsers"] = parameters =>
            {
                return Response.AsJson(submissionManager.getListOfUsers());
            };
            //Jaimeiris - returns true is the currently logged in user is the master
            Get["/isMaster/{userID:long}"] = parameters =>
            {
                long userID = parameters.userID;
                bool isMaster = submissionManager.isMaster(userID);
                return isMaster;
            };
            // [Randy] search within the list with a certain criteria
            Get["/searchSubmission/{index}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                var list = submissionManager.searchSubmission(index, criteria);
                return Response.AsJson(list);
            };
            // [Randy] search within the list with a certain criteria
            Get["/searchDeletedSubmission/{index}/{criteria}"] = parameters =>
            {
                int index = parameters.index;
                string criteria = parameters.criteria;
                var list = submissionManager.searchDeletedSubmission(index, criteria);
                return Response.AsJson(list);
            };
            //Jaimeiris - Gets the file for the submission with submissionID
            Get["/getSubmissionFile/{fileID}"] = parameters =>
            {
                int fileID = parameters.fileID;
                return Response.AsJson(submissionManager.getSubmissionFile(fileID));
            };
            //Jaimeiris - get submission report
            Get["/getSubmissionsReport"] = parameters =>
            {
                return Response.AsJson(reportManager.getSubmissionsReport());
            };
            //Jaimeiris-get templates list
            Get["/getTemplates"] = parameters =>
                {
                    return Response.AsJson(submissionManager.getTemplates());
                };

            //------------------------------------Banner---------------------------------------------
            Get["/getBanners/{index:int}/{sponsor}"] = parameters =>
            {
                int index = parameters.index;
                String sponsor = parameters.sponsor;
                return Response.AsJson(bannerManager.getBannerList(sponsor, index));
            };
        }
        public List<ContentComparison> PreviewTemplates(Type typeBaseTemplate)
        {
            List<ContentComparison> templateComparison = new List<ContentComparison>();
            TemplateManager templateManager = new TemplateManager();

            foreach (Type typeTemplate in Util.GetFirstLevelSubTypes(typeBaseTemplate))
            {
                if (typeTemplate.IsGenericType)
                {
                    templateComparison.AddRange(PreviewTemplates(typeTemplate));
                    continue;
                }

                string alias = TemplateManager.GetTemplateAlias(typeTemplate);
                Template template = Template.GetByAlias(alias);
                if (template == null)
                {
                    string path =
                        IOHelper.MapPath(SystemDirectories.Masterpages + "/" + alias.Replace(" ", "") + ".master");

                    if (File.Exists(path))
                    {
                        string parentAlias = templateManager.GetParentMasterPageName(File.ReadAllText(path));

                        templateComparison.Add(new ContentComparison
                        {
                            Alias = alias,
                            DocumentTypeStatus = Status.New,
                            ParentAlias = parentAlias ?? ""
                        });
                    }
                }
                else
                {
                    int parentTemplateId = 0;
                    string parentMasterPageName = templateManager.GetParentMasterPageName(template);
                    if (!string.IsNullOrEmpty(parentMasterPageName) && parentMasterPageName != "default")
                    {
                        Template parentTemplate = Template.GetByAlias(parentMasterPageName);
                        if (parentTemplate == null)
                        {
                            throw new Exception(
                                string.Format(
                                    "Template '{0}' is using '{1}' as a parent template (defined in MasterPageFile in {0}.master) but '{1}' template cannot be found",
                                    template.Alias, parentMasterPageName));
                        }
                        parentTemplateId = parentTemplate.Id;
                    }
                    if (template.MasterTemplate != parentTemplateId)
                    {
                        templateComparison.Add(new ContentComparison { Alias = alias, DocumentTypeStatus = Status.Changed, ParentAlias = parentMasterPageName ?? "default" });

                    }
                    else
                    {
                        templateComparison.Add(new ContentComparison { Alias = alias, DocumentTypeStatus = Status.Same, ParentAlias = parentMasterPageName ?? "default" });
                    }

                }

                templateComparison.AddRange(PreviewTemplates(typeTemplate));
            }

            return templateComparison;
        }