private async void MenuItemDetailSaveAs_Click(object sender, RoutedEventArgs e)
        {
            if (DetailList.Items.Count == 0)
            {
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = AppSettings.Get("Path", "LastSaved", DirectoryHelper.DesktopDirectory);
            sfd.CheckPathExists  = true;
            sfd.AddExtension     = true;
            sfd.DefaultExt       = ".txt";
            sfd.FileName         = AppLanguage.Get("LangPlusFTPLog") + " - " + DateFormatHelper.GetShortDateTimeSafe();
            sfd.Filter           = AppLanguage.Get("LangTextAllextensions");

            if (!(bool)sfd.ShowDialog() || (sfd.FileName.Trim().Length == 0))
            {
                return;
            }

            await Task.Run(() =>
            {
                AppSettings.Set("Path", "LastSaved", DirectoryHelper.GetPath(sfd.FileName));
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < AppMessage.Count; i++)
                {
                    try { sb.Append(((sb.Length > 0) ? Environment.NewLine : string.Empty) + AppMessage.Items[i].MText + " - " + AppMessage.Items[i].MDate); }
                    catch (Exception exp) { ExceptionHelper.Log(exp); }
                }

                FileHelper.WriteAll(sfd.FileName, sb.ToString());
                sb.Clear();
            });
        }
        public void TryParseDateTimeOffset_ValidDate_True(string input, DateTimeOffset expected)
        {
            var success = DateFormatHelper.TryParseDateTimeOffset(input, out var result);

            Assert.True(success);
            Assert.Equal(expected, result);
        }
        protected string replaceDates(string val)
        {
            string input = val;

            this.DateFormat = DateFormatHelper.ConvertInnerFormatToNet(this.DateFormat);
            return(new Regex(string.Format("\\[\"{0}\",(\".*?\"),\"{1}\"\\]", (object)DHXSchedulerDataStore.startMarker, (object)DHXSchedulerDataStore.endMarker)).Replace(input, new MatchEvaluator(this.Callback)));
        }
Exemple #4
0
        public Charge Create(Charge charge)
        {
            var db = DatabaseFactory.CreateDatabase(CONNECTION_NAME);

            using (DbCommand cmd = db.GetStoredProcCommand(SqlQuerys.AddNewCharge))
            {
                db.AddInParameter(cmd, "@EventId", DbType.AnsiString, charge.IdEvent);
                db.AddInParameter(cmd, "@Amount", DbType.Int32, charge.Amount);
                db.AddInParameter(cmd, "@DateIndex", DbType.Int32, DateFormatHelper.DateToIntFormat(DateTime.Now));
                charge.Id = Convert.ToInt32(db.ExecuteScalar(cmd));
            }
            return(charge);
        }
Exemple #5
0
        public virtual void SetUp()
        {
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            var services = new StubMonoRailServices
            {
                UrlBuilder   = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
                UrlTokenizer = new DefaultUrlTokenizer()
            };
            var urlInfo = new UrlInfo(
                "example.org", "test", "/TestBrail", "http", 80,
                "http://test.example.org/test_area/test_controller/test_action.tdd",
                Area, ControllerName, Action, "tdd", "no.idea");

            StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services, urlInfo);
            StubEngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            StubEngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);

            ViewComponentFactory = new DefaultViewComponentFactory();
            ViewComponentFactory.Service(StubEngineContext);
            ViewComponentFactory.Initialize();

            StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            ControllerContext = new ControllerContext
            {
                Helpers     = Helpers,
                PropertyBag = PropertyBag
            };
            StubEngineContext.CurrentControllerContext = ControllerContext;


            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(StubEngineContext);
            Helpers["formhelper"]       = Helpers["form"] = new FormHelper(StubEngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(StubEngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);



            var loader = new FileAssemblyViewSourceLoader("Views");

            _monoRailViewEngine = new NHamlMonoRailViewEngine();
            _monoRailViewEngine.TemplateEngine.Options.TemplateCompiler = new CSharp3TemplateCompiler();
            _monoRailViewEngine.SetViewSourceLoader(loader);
            _templateEngine = _monoRailViewEngine.TemplateEngine;
            _templateEngine.Options.TemplateBaseType = typeof(NHamlMonoRailView);



            ViewComponentFactory.Inspect(GetType().Assembly);
        }
        public BillCharge Create(BillCharge billCharge)
        {
            var db = DatabaseFactory.CreateDatabase(CONNECTION_NAME);

            using (DbCommand cmd = db.GetStoredProcCommand(SqlQuerys.AddNewBillCharge))
            {
                db.AddInParameter(cmd, "@IdBill", DbType.AnsiString, billCharge.IdBill);
                db.AddInParameter(cmd, "@IdCharge", DbType.AnsiString, billCharge.IdCharge);
                db.AddInParameter(cmd, "@DateIndex", DbType.Int32, DateFormatHelper.DateToIntFormat(DateTime.Now));
                Convert.ToInt32(db.ExecuteNonQuery(cmd));
            }

            return(billCharge);
        }
Exemple #7
0
        public Bill Create(Bill bill)
        {
            var db = DatabaseFactory.CreateDatabase(CONNECTION_NAME);

            using (DbCommand cmd = db.GetStoredProcCommand(SqlQuerys.AddNewBill))
            {
                db.AddInParameter(cmd, "@IdUser", DbType.AnsiString, bill.IdUser);
                db.AddInParameter(cmd, "@BillNumber", DbType.AnsiString, bill.BillNumber);
                db.AddInParameter(cmd, "@DateIndex", DbType.Int32, DateFormatHelper.DateToIntFormat(DateTime.Now));
                bill.Id = Convert.ToInt32(db.ExecuteScalar(cmd));
            }

            return(bill);
        }
        private string getUpdatedFieldsString()
        {
            if (this.updateFields == null || this.action.Type == DataActionTypes.Delete)
            {
                return("");
            }
            string net = DateFormatHelper.ConvertInnerFormatToNet(this.DateFormat);
            JavaScriptSerializer scriptSerializer = new JavaScriptSerializer();
            string str1 = "";

            foreach (string key in this.updateFields.GetKeys())
            {
                string str2 = this.updateFields[key].GetType() != Type.GetType("System.DateTime") ? (this.updateFields[key].GetType() != Type.GetType("System.Boolean") ? scriptSerializer.Serialize(this.updateFields[key]).Replace("\"", "") : ((bool)this.updateFields[key] ? "1" : "0")) : string.Format("{0:" + net + "}", (object)(DateTime)this.updateFields[key]);
                str1 += string.Format(" dhx_{0}=\"{1}\"", (object)key, (object)str2);
            }
            return(str1);
        }
        private void SwissTransportGui_Load(object sender, EventArgs e)
        {
            transport        = new Transport();
            dateFormatHelper = new DateFormatHelper();

            //Setting modes for autocomplete on TextBox
            textBoxFrom.AutoCompleteMode   = AutoCompleteMode.Suggest;
            textBoxFrom.AutoCompleteSource = AutoCompleteSource.CustomSource;

            textBoxTo.AutoCompleteMode   = AutoCompleteMode.Suggest;
            textBoxTo.AutoCompleteSource = AutoCompleteSource.CustomSource;

            textBoxStation.AutoCompleteMode   = AutoCompleteMode.Suggest;
            textBoxStation.AutoCompleteSource = AutoCompleteSource.CustomSource;

            textBoxStationSearch.AutoCompleteMode   = AutoCompleteMode.Suggest;
            textBoxStationSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
        }
Exemple #10
0
        /// <summary>
        /// Add a new user and returns the complete User object
        /// </summary>
        /// <param name="user">User to insert</param>
        /// <returns></returns>
        public User Create(User user)
        {
            var db = DatabaseFactory.CreateDatabase(CONNECTION_NAME);

            using (DbCommand cmd = db.GetSqlStringCommand(SqlQuerys.AddNewUser))
            {
                db.AddInParameter(cmd, "@Document", DbType.AnsiString, user.Document);
                db.AddInParameter(cmd, "@DocumentType", DbType.Int32, user.DocumentType);
                db.AddInParameter(cmd, "@Name", DbType.AnsiString, user.Name);
                db.AddInParameter(cmd, "@Gender", DbType.Int32, (int)user.Gender);
                db.AddInParameter(cmd, "@Address", DbType.AnsiString, user.Address);
                db.AddInParameter(cmd, "@AddressNumber", DbType.Int32, user.AddressNumber);
                db.AddInParameter(cmd, "@Phone", DbType.AnsiString, user.Phone);
                db.AddInParameter(cmd, "@BirthDate", DbType.Int32, user.BirthDate);
                db.AddInParameter(cmd, "@DateIndex", DbType.Int32, DateFormatHelper.DateToIntFormat(DateTime.Now));
                user.Id = Convert.ToInt32(db.ExecuteScalar(cmd));
            }
            return(user);
        }
Exemple #11
0
        /// <summary>
        /// Get the bill for the user in that specific month
        /// </summary>
        /// <param name="user">User to be searched</param>
        /// <param name="date">Date to be searched</param>
        /// <returns></returns>
        public Bill GetBillByUserAndMonth(int idUser, DateTime date)
        {
            Bill charge = null;

            var db = DatabaseFactory.CreateDatabase(CONNECTION_NAME);

            using (DbCommand cmd = db.GetSqlStringCommand(SqlQuerys.GetBillByIdUserAndMonth))
            {
                db.AddInParameter(cmd, "@Id", DbType.Int32, idUser);
                db.AddInParameter(cmd, "@MaxDate", DbType.Int32, DateFormatHelper.FirstDayMonth(date));
                db.AddInParameter(cmd, "@MinDate", DbType.Int32, DateFormatHelper.LastDayMonth(date));
                using (IDataReader dr = db.ExecuteReader(cmd))
                {
                    if (dr.Read())
                    {
                        charge = LoadBill(dr);
                    }
                }
            }
            return(charge);
        }
Exemple #12
0
 protected virtual List<string> _GetSettings()
 {
     List<string> stringList = new List<string>();
     if (!this.DaySet && !this.FullWeek)
     {
         stringList.Add("start_date:" + DateFormatHelper.DateToJS(this.StartDate, true));
         if (this.EndDate != new DateTime())
             stringList.Add("end_date:" + DateFormatHelper.DateToJS(this.EndDate, true));
     }
     if (!string.IsNullOrEmpty(this.HTML))
         stringList.Add(string.Format("html:\"{0}\"", (object)this.HTML.Replace("\"", "\\\"")));
     if (this.FullWeek)
         stringList.Add("days:\"fullweek\"");
     else if (this.DaySet)
         stringList.Add(string.Format("days:{0}", (object)this.Day));
     if (this.Sections.Count > 0)
         stringList.Add(string.Format("sections:{{{0}}}", (object)string.Join(",", this.Sections.Select<Section, string>((Func<Section, string>)(s => s.ToString())).ToArray<string>())));
     if (this.Zones.Count > 0 && !this.FullDay)
         stringList.Add(string.Format("zones:[{0}]", (object)string.Join(",", this.Zones.Select<Zone, string>((Func<Zone, string>)(z => z.ToString())).ToArray<string>())));
     else if (this.EndDate == new DateTime())
         stringList.Add("zones:\"fullday\"");
     return stringList;
 }
 protected string RenderDefault()
 {
     return(this.replaceDates(DHXSchedulerDataStore.GetSerializer(DateFormatHelper.ConvertInnerFormatToNet(this.DateFormat), this.TimeOffset, this.ToUniversalTime).Serialize((object)this.items)));
 }
		public void SetUp()
		{
			string viewPath = Path.Combine(SiteRoot, "Views");
			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			MockServices services = new MockServices();
			services.UrlBuilder = new DefaultUrlBuilder(new MockServerUtility(), new MockRoutingEngine());
			services.UrlTokenizer = new DefaultUrlTokenizer();
			UrlInfo urlInfo = new UrlInfo(
				"example.org", "test", "/TestBrail", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			MockEngineContext = new MockEngineContext(new MockRequest(), new MockResponse(), services,
													  urlInfo);
			MockEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			MockEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			MockEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			MockEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
			MockEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
			

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(MockEngineContext);
			ViewComponentFactory.Initialize();

			ControllerContext = new ControllerContext();
			ControllerContext.Helpers = Helpers;
			ControllerContext.PropertyBag = PropertyBag;
			MockEngineContext.CurrentControllerContext = ControllerContext;


			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(MockEngineContext);
			Helpers["htmlhelper"] = Helpers["html"] = new HtmlHelper(MockEngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(MockEngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(MockEngineContext);


			//FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
//			loader.AddAssemblySource(
//				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
//									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

			viewEngine = new AspViewEngine();
			viewEngine.Service(MockEngineContext);
			AspViewEngineOptions options = new AspViewEngineOptions();
			options.CompilerOptions.AutoRecompilation = true;
			options.CompilerOptions.KeepTemporarySourceFiles = false;
			string root = AppDomain.CurrentDomain.BaseDirectory;
			root = root.Substring(0, root.LastIndexOf("Bin\\Debug", StringComparison.InvariantCultureIgnoreCase));
			ICompilationContext context = 
				new CompilationContext(
					new DirectoryInfo(root + @"\Bin\Debug"),
					new DirectoryInfo(root),
					new DirectoryInfo(root + @"\RenderingTests\Views"),
					new DirectoryInfo(root));
			viewEngine.Initialize(context, options);
			System.Console.WriteLine("init");

			BeforEachTest();
		}
Exemple #15
0
 /// <summary>
 /// Gets the <see cref="ModifiedDate"/> as a <see cref="DateTimeOffset"/> if it's possible to convert it, or <see langword="null"/>.
 /// </summary>
 public DateTimeOffset?GetModifiedDateTimeOffset()
 {
     return(DateFormatHelper.TryParseDateTimeOffset(ModifiedDate, out var result) ? result : default(DateTimeOffset?));
 }
        public void SetUp()
        {
            var en = CultureInfo.CreateSpecificCulture("en");

            Thread.CurrentThread.CurrentCulture   = en;
            Thread.CurrentThread.CurrentUICulture = en;

            Layout      = null;
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            var services = new StubMonoRailServices
            {
                UrlBuilder    = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
                UrlTokenizer  = new DefaultUrlTokenizer(),
                CacheProvider = new StubCacheProvider()
            };

            services.AddService(typeof(ICacheProvider), services.CacheProvider);

            var urlInfo = new UrlInfo(
                "example.org", "test", "", "http", 80,
                "http://test.example.org/test_area/test_controller/test_action.tdd",
                Area, ControllerName, Action, "tdd", "no.idea");

            Response      = new StubResponse();
            EngineContext = new StubEngineContext(new StubRequest(), Response, services,
                                                  urlInfo);

            services.AddService(typeof(IEngineContext), EngineContext);
            EngineContext.AddService <IEngineContext>(EngineContext);

            EngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            EngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);
            EngineContext.AddService <ICacheProvider>(services.CacheProvider);

            ViewComponentFactory = new DefaultViewComponentFactory();
            ViewComponentFactory.Service(EngineContext);

            EngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            services.AddService(typeof(IViewComponentFactory), ViewComponentFactory);

            EngineContext.AddService <IViewComponentDescriptorProvider>(new DefaultViewComponentDescriptorProvider());
            services.AddService(typeof(IViewComponentDescriptorProvider), EngineContext.GetService <IViewComponentDescriptorProvider>());

            ControllerContext = new ControllerContext {
                Helpers = Helpers, PropertyBag = PropertyBag
            };
            EngineContext.CurrentControllerContext = ControllerContext;

            Helpers["formhelper"]       = Helpers["form"] = new FormHelper(EngineContext);
            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(EngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(EngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(EngineContext);

            var viewPath = Path.Combine(ViewSourcePath, "Views");

            var loader = new FileAssemblyViewSourceLoader(viewPath);

            services.ViewSourceLoader = loader;
            services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader);
            EngineContext.AddService <IViewSourceLoader>(services.ViewSourceLoader);

            Controller = new BaseTestFixtureController();
            Controller.Contextualize(EngineContext, ControllerContext);

            VelocityViewEngine = new NVelocityViewEngine();
            services.AddService(typeof(IViewEngine), VelocityViewEngine);
            EngineContext.AddService <IViewEngine>(VelocityViewEngine);

            VelocityViewEngine.SetViewSourceLoader(loader);
            VelocityViewEngine.Service(services);

            var viewEngineManager = new DefaultViewEngineManager();

            viewEngineManager.RegisterEngineForExtesionLookup(VelocityViewEngine);
            services.EmailTemplateService = new EmailTemplateService(viewEngineManager);

            BeforEachTest();
        }
		public void SetUp()
		{
			var en = CultureInfo.CreateSpecificCulture("en");

			Thread.CurrentThread.CurrentCulture = en;
			Thread.CurrentThread.CurrentUICulture = en;

			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			var services = new StubMonoRailServices
			               	{
			               		UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
			               		UrlTokenizer = new DefaultUrlTokenizer(),
			               		CacheProvider = new StubCacheProvider()
			               	};
			services.AddService(typeof(ICacheProvider), services.CacheProvider);

			var urlInfo = new UrlInfo(
				"example.org", "test", "", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			Response = new StubResponse();
			EngineContext = new StubEngineContext(new StubRequest(), Response, services,
			                                          urlInfo);

			services.AddService(typeof(IEngineContext), EngineContext);
			EngineContext.AddService<IEngineContext>(EngineContext);

			EngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			EngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			EngineContext.AddService<ICacheProvider>(services.CacheProvider);

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(EngineContext);

			EngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			services.AddService(typeof(IViewComponentFactory), ViewComponentFactory);

			EngineContext.AddService<IViewComponentDescriptorProvider>(new DefaultViewComponentDescriptorProvider());
			services.AddService(typeof(IViewComponentDescriptorProvider), EngineContext.GetService<IViewComponentDescriptorProvider>());

			ControllerContext = new ControllerContext { Helpers = Helpers, PropertyBag = PropertyBag };
			EngineContext.CurrentControllerContext = ControllerContext;

			Helpers["formhelper"] = Helpers["form"] = new FormHelper(EngineContext);
			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(EngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(EngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(EngineContext);

			var viewPath = Path.Combine(ViewSourcePath, "Views");

			var loader = new FileAssemblyViewSourceLoader(viewPath);

			services.ViewSourceLoader = loader;
			services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader);
			EngineContext.AddService<IViewSourceLoader>(services.ViewSourceLoader);

			Controller = new BaseTestFixtureController();
			Controller.Contextualize(EngineContext, ControllerContext);

			VelocityViewEngine = new NVelocityViewEngine();
			services.AddService(typeof(IViewEngine), VelocityViewEngine);
			EngineContext.AddService<IViewEngine>(VelocityViewEngine);

			VelocityViewEngine.SetViewSourceLoader(loader);
			VelocityViewEngine.Service(services);

			var viewEngineManager = new DefaultViewEngineManager();
			viewEngineManager.RegisterEngineForExtesionLookup(VelocityViewEngine);
			services.EmailTemplateService = new EmailTemplateService(viewEngineManager);

			BeforEachTest();
		}
Exemple #18
0
 /// <summary>
 /// Gets the <see cref="CreationDate"/> as a <see cref="DateTimeOffset"/> if it's possible to convert it, or <see langword="null"/>.
 /// </summary>
 public DateTimeOffset?GetCreatedDateTimeOffset()
 {
     return(DateFormatHelper.TryParseDateTimeOffset(CreationDate, out var result) ? result : default(DateTimeOffset?));
 }
		public void SetUp()
		{
			var siteRoot = GetSiteRoot();
			var viewPath = Path.Combine(siteRoot, "RenderingTests\\Views");
			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			var services = new StubMonoRailServices
			{
				UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()), 
				UrlTokenizer = new DefaultUrlTokenizer()
			};
			var urlInfo = new UrlInfo(
				"example.org", "test", "/TestBrail", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
													  urlInfo);
			StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			StubEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
			StubEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
			

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(StubEngineContext);

			ControllerContext = new ControllerContext
			{
				Helpers = Helpers, 
				PropertyBag = PropertyBag
			};
			StubEngineContext.CurrentControllerContext = ControllerContext;


			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);


			//FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
//			loader.AddAssemblySource(
//				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
//									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

			viewEngine = new AspViewEngine();
			var options = new AspViewEngineOptions();
			options.CompilerOptions.AutoRecompilation = true;
			options.CompilerOptions.KeepTemporarySourceFiles = false;
			((IAspViewEngineTestAccess)viewEngine).SetOptions(options);
			ICompilationContext context =
				new CompilationContext(
					new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),
					new DirectoryInfo(siteRoot),
					new DirectoryInfo(Path.Combine(siteRoot, "RenderingTests\\Views")),
					new DirectoryInfo(siteRoot));

			var compilationContexts = new List<ICompilationContext> { context };
			((IAspViewEngineTestAccess)viewEngine).SetCompilationContext(compilationContexts);
			viewEngine.Service(StubEngineContext);
		}
Exemple #20
0
        public void SetUp()
        {
            string viewPath = Path.Combine(SiteRoot, "Views");

            Layout      = null;
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            MockServices services = new MockServices();

            services.UrlBuilder   = new DefaultUrlBuilder(new MockServerUtility(), new MockRoutingEngine());
            services.UrlTokenizer = new DefaultUrlTokenizer();
            UrlInfo urlInfo = new UrlInfo(
                "example.org", "test", "/TestBrail", "http", 80,
                "http://test.example.org/test_area/test_controller/test_action.tdd",
                Area, ControllerName, Action, "tdd", "no.idea");

            MockEngineContext = new MockEngineContext(new MockRequest(), new MockResponse(), services,
                                                      urlInfo);
            MockEngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            MockEngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);
            MockEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            MockEngineContext.AddService <ILoggerFactory>(new ConsoleFactory());
            MockEngineContext.AddService <IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));


            ViewComponentFactory = new DefaultViewComponentFactory();
            ViewComponentFactory.Service(MockEngineContext);
            ViewComponentFactory.Initialize();

            ControllerContext             = new ControllerContext();
            ControllerContext.Helpers     = Helpers;
            ControllerContext.PropertyBag = PropertyBag;
            MockEngineContext.CurrentControllerContext = ControllerContext;


            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(MockEngineContext);
            Helpers["htmlhelper"]       = Helpers["html"] = new HtmlHelper(MockEngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(MockEngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(MockEngineContext);


            //FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
//			loader.AddAssemblySource(
//				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
//									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

            viewEngine = new AspViewEngine();
            viewEngine.Service(MockEngineContext);
            AspViewEngineOptions options = new AspViewEngineOptions();

            options.CompilerOptions.AutoRecompilation        = true;
            options.CompilerOptions.KeepTemporarySourceFiles = false;
            string root = AppDomain.CurrentDomain.BaseDirectory;

            root = root.Substring(0, root.LastIndexOf("Bin\\Debug", StringComparison.InvariantCultureIgnoreCase));
            ICompilationContext context =
                new CompilationContext(
                    new DirectoryInfo(root + @"\Bin\Debug"),
                    new DirectoryInfo(root),
                    new DirectoryInfo(root + @"\RenderingTests\Views"),
                    new DirectoryInfo(root));

            viewEngine.Initialize(context, options);
            System.Console.WriteLine("init");

            BeforEachTest();
        }
        public void SetUp()
        {
            var siteRoot = GetSiteRoot();
            var viewPath = Path.Combine(siteRoot, "RenderingTests\\Views");

            Layout      = null;
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            var services = new StubMonoRailServices
            {
                UrlBuilder   = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
                UrlTokenizer = new DefaultUrlTokenizer()
            };
            var urlInfo = new UrlInfo(
                "example.org", "test", "/TestBrail", "http", 80,
                "http://test.example.org/test_area/test_controller/test_action.tdd",
                Area, ControllerName, Action, "tdd", "no.idea");

            StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
                                                      urlInfo);
            StubEngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            StubEngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);
            StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            StubEngineContext.AddService <ILoggerFactory>(new ConsoleFactory());
            StubEngineContext.AddService <IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));


            ViewComponentFactory = new DefaultViewComponentFactory();
            ViewComponentFactory.Service(StubEngineContext);

            ControllerContext = new ControllerContext
            {
                Helpers     = Helpers,
                PropertyBag = PropertyBag
            };
            StubEngineContext.CurrentControllerContext = ControllerContext;


            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(StubEngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(StubEngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);


            //FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
//			loader.AddAssemblySource(
//				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
//									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

            viewEngine = new AspViewEngine();
            var options = new AspViewEngineOptions();

            options.CompilerOptions.AutoRecompilation        = true;
            options.CompilerOptions.KeepTemporarySourceFiles = false;
            ((IAspViewEngineTestAccess)viewEngine).SetOptions(options);
            ICompilationContext context =
                new CompilationContext(
                    new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),
                    new DirectoryInfo(siteRoot),
                    new DirectoryInfo(Path.Combine(siteRoot, "RenderingTests\\Views")),
                    new DirectoryInfo(siteRoot));

            var compilationContexts = new List <ICompilationContext> {
                context
            };

            ((IAspViewEngineTestAccess)viewEngine).SetCompilationContext(compilationContexts);
            viewEngine.Service(StubEngineContext);
        }
Exemple #22
0
        public void SetUp()
        {
            Layout      = null;
            PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            Helpers     = new HelperDictionary();
            var services = new StubMonoRailServices
            {
                UrlBuilder   = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
                UrlTokenizer = new DefaultUrlTokenizer()
            };
            var urlInfo = new UrlInfo(
                "example.org", "test", "/TestBrail", "http", 80,
                "http://test.example.org/test_area/test_controller/test_action.tdd",
                Area, ControllerName, Action, "tdd", "no.idea");

            StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
                                                      urlInfo);
            StubEngineContext.AddService <IUrlBuilder>(services.UrlBuilder);
            StubEngineContext.AddService <IUrlTokenizer>(services.UrlTokenizer);

            ViewComponentFactory = new DefaultViewComponentFactory();
            ViewComponentFactory.Service(StubEngineContext);

            StubEngineContext.AddService <IViewComponentFactory>(ViewComponentFactory);
            ControllerContext = new ControllerContext
            {
                Helpers     = Helpers,
                PropertyBag = PropertyBag
            };
            StubEngineContext.CurrentControllerContext = ControllerContext;


            Helpers["formhelper"]       = Helpers["form"] = new FormHelper(StubEngineContext);
            Helpers["urlhelper"]        = Helpers["url"] = new UrlHelper(StubEngineContext);
            Helpers["dicthelper"]       = Helpers["dict"] = new DictHelper(StubEngineContext);
            Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);

            var viewPath = Path.Combine(viewSourcePath, "Views");

            var loader = new FileAssemblyViewSourceLoader(viewPath);

            loader.AddAssemblySource(
                new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
                                       "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

            BooViewEngine = new BooViewEngine
            {
                Options = new BooViewEngineOptions
                {
                    SaveDirectory = Environment.CurrentDirectory,
                    SaveToDisk    = false,
                    Debug         = true,
                    BatchCompile  = false
                }
            };

            BooViewEngine.SetViewSourceLoader(loader);
            BooViewEngine.Initialize();

            BeforEachTest();
        }
Exemple #23
0
        public string GenerateJSCode()
        {
            StringBuilder builder = new StringBuilder();

            if (this.Name != this.DefaultName)
            {
                builder.Append(string.Format("\n\twindow.{0} = Scheduler.getSchedulerInstance();", (object)this.Name));
            }
            builder.Append("\n");
            builder.Append(string.Format(DHXScheduler.GetServerList().InitConfigSection, (object)this.Name));
            if (DHXScheduler.GetServerList().Count > 0)
            {
                builder.Append(DHXScheduler.GetServerList().RenderCollections(this.Name));
            }
            foreach (SchedulerControlsBase control in this._Controls)
            {
                control.Render(builder, this.Name);
            }
            foreach (SchedulerSettingsBase setting in this._Settings)
            {
                setting.Render(builder, this.Name);
            }
            if (this.HasBeforeInitCode)
            {
                builder.Append("\n");
                builder.Append(string.Join("\n", this.BeforeInit.ToArray()));
                builder.Append("\n");
            }
            if (this.EventHandlers.Events.Count > 0)
            {
                this.EventHandlers.Render(builder, this.Name);
            }
            if (this.TimeSpans.Items.Count > 0)
            {
                this.TimeSpans.Render(builder, this.Name);
            }
            if (this.Highlighter.Enabled)
            {
                this.Highlighter.Render(builder, this.Name);
            }
            List <string> stringList = new List <string>();

            stringList.Add(string.Format("'{0}_here'", (object)this.Name));
            DateTime initialDate = this.InitialDate;
            string   str         = initialDate == new DateTime() ? "null" : DateFormatHelper.DateToJS(initialDate);
            string   initialView = this.InitialView;

            if (initialDate != new DateTime() || initialView != (string)null)
            {
                if (initialView != (string)null)
                {
                    stringList.Add(str);
                    stringList.Add("'" + initialView + "'");
                }
                else if (initialDate != new DateTime())
                {
                    stringList.Add(str);
                }
            }
            builder.Append(string.Format("\n\t{0}.init({1});", (object)this.Name, (object)string.Join(",", stringList.ToArray())));
            if (this.Extensions != null && this.Extensions.Items != null && this.Extensions.Items.Count != 0)
            {
                foreach (KeyValuePair <SchedulerExtensions.Extension, DHXExtension> keyValuePair in this.Extensions.Items)
                {
                    keyValuePair.Value.Render(builder, this);
                }
            }
            if (this.HasAfterInitCode)
            {
                builder.Append("\n");
                builder.Append(string.Join("\n", this.AfterInit.ToArray()));
                builder.Append("\n");
            }
            if (this.HasDefaultValues)
            {
                this.EventHandlers.Events.Add(new DHXSchedulerEvent(DHXSchedulerEvent.Types.onEventCreated, this._ProcessDefaultValues()));
            }
            this.Data.DateFormat = this.Config.xml_date;
            this.Data.Render(builder, this.Name);
            foreach (SchedulerControlsBase control in this._Controls)
            {
                builder.Append(control.AfterInit());
            }
            return(builder.ToString());
        }
        public void TryParseDateTimeOffset_InvalidInput_False(string input)
        {
            var result = DateFormatHelper.TryParseDateTimeOffset(input, out _);

            Assert.False(result);
        }
Exemple #25
0
        public override string Render()
        {
            if (this.Value == null || this.Field == null)
            {
                return(this._Default);
            }
            string str1;

            switch (this.Operator)
            {
            case Operator.Equals:
                str1 = "==";
                break;

            case Operator.NotEquals:
                str1 = "!=";
                break;

            case Operator.Identical:
                str1 = "===";
                break;

            case Operator.NotIdentical:
                str1 = "!==";
                break;

            case Operator.Greater:
                str1 = ">";
                break;

            case Operator.GreaterOrEqual:
                str1 = ">=";
                break;

            case Operator.Lower:
                str1 = "<";
                break;

            case Operator.LowerOrEqual:
                str1 = "<=";
                break;

            case Operator.GreaterOrIdentical:
                str1 = ">==";
                break;

            case Operator.LowerOrIdentical:
                str1 = "<==";
                break;

            default:
                throw new NotImplementedException(this.Operator.ToString() + " operator support has not been implemented yet!");
            }
            string format = "(event.{0} {1} {2})";
            string str2   = this.Value == null || this.Value.GetType() != typeof(DateTime) ? JSONHelper.ToJSON(this.Value) : DateFormatHelper.DateToJS((DateTime)this.Value);

            return(string.Format(format, (object)this.Field, (object)str1, (object)str2));
        }