Example #1
0
		public static string InsertSpecialView(ViewLocation CtrlKey) {
			string sViewPath = String.Empty;
			CarrotCakeConfig config = CarrotCakeConfig.GetConfig();

			switch (CtrlKey) {
				case ViewLocation.AdminPublicFooter:
					sViewPath = config.AdminFooterControls.ViewPathPublic;
					break;

				case ViewLocation.AdminPopupFooter:
					sViewPath = config.AdminFooterControls.ViewPathPopup;
					break;

				case ViewLocation.AdminMainFooter:
					sViewPath = config.AdminFooterControls.ViewPathMain;
					break;

				case ViewLocation.PublicMainHeader:
					sViewPath = config.PublicSiteControls.ViewPathHeader;
					break;

				case ViewLocation.PublicMainFooter:
					sViewPath = config.PublicSiteControls.ViewPathFooter;
					break;
			}

			return sViewPath;
		}
        private string GetPathFromGeneralName(ControllerContext controllerContext, List <ViewLocation> locations,
                                              string name, string controllerName, string areaName, string cacheKey,
                                              ref string[] searchedLocations)
        {
            string result = String.Empty;

            searchedLocations = new string[locations.Count];

            for (int i = 0; i < locations.Count; i++)
            {
                ViewLocation location    = locations[i];
                string       virtualPath = location.Format(name, controllerName, areaName);

                if (FileExists(controllerContext, virtualPath))
                {
                    searchedLocations = EmptyLocations;
                    result            = virtualPath;
                    ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, result);
                    break;
                }

                searchedLocations[i] = virtualPath;
            }

            return(result);
        }
        public static string InsertSpecialView(ViewLocation CtrlKey)
        {
            string           sViewPath = String.Empty;
            CarrotCakeConfig config    = CarrotCakeConfig.GetConfig();

            switch (CtrlKey)
            {
            case ViewLocation.AdminPublicFooter:
                sViewPath = config.AdminFooterControls.ViewPathPublic;
                break;

            case ViewLocation.AdminPopupFooter:
                sViewPath = config.AdminFooterControls.ViewPathPopup;
                break;

            case ViewLocation.AdminMainFooter:
                sViewPath = config.AdminFooterControls.ViewPathMain;
                break;

            case ViewLocation.PublicMainHeader:
                sViewPath = config.PublicSiteControls.ViewPathHeader;
                break;

            case ViewLocation.PublicMainFooter:
                sViewPath = config.PublicSiteControls.ViewPathFooter;
                break;
            }

            return(sViewPath);
        }
Example #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            //valid the textbox input
            string prompt = null;

            if (!Validator.Validate(out prompt))
            {
                MessageBox.Show(prompt);
                return;
            }

            dbserver.ServerName   = this.textBox1.Text.Trim();
            dbserver.LoginName    = this.textBox2.Text.Trim();
            dbserver.Password     = this.textBox3.Text.Trim();
            dbserver.DatabaseName = this.textBox4.Text.Trim();

            if (targetServerAvailable == null || !targetServerAvailable.ConnString.Equals(dbserver.ConnString))
            {
                MessageBox.Show(MessageUtil.GetMessage("LinkMust"));
                return;
            }

            if (dbsm.UpdateSourceDBServer(index, dbserver))
            {
                MessageBox.Show(MessageUtil.GetMessage("SaveSuccess"));
                ViewLocation.SwitchTo(new DBList());
            }
            else
            {
                MessageBox.Show(MessageUtil.GetMessage("SaveFailed"));
            }
        }
        protected virtual string GetPathFromGeneralName(ControllerContext controllerContext,
                                                        List <ViewLocation> locations,
                                                        string name,
                                                        string controllerName,
                                                        string areaName,
                                                        string theme,
                                                        string cacheKey,
                                                        ref string[] searchedLocations)
        {
            string result = String.Empty;

            searchedLocations = new string[locations.Count];

            for (int i = 0; i < locations.Count; i++)
            {
                ViewLocation location               = locations[i];
                string       virtualPath            = location.Format(name, controllerName, areaName, theme);
                DisplayInfo  virtualPathDisplayInfo = DisplayModeProvider.GetDisplayInfoForVirtualPath(virtualPath, controllerContext.HttpContext, path => FileExists(controllerContext, path), controllerContext.DisplayMode);

                if (virtualPathDisplayInfo != null)
                {
                    string resolvedVirtualPath = virtualPathDisplayInfo.FilePath;

                    searchedLocations = _emptyLocations;
                    result            = resolvedVirtualPath;
                    ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, AppendDisplayModeToCacheKey(cacheKey, virtualPathDisplayInfo.DisplayMode.DisplayModeId), result);

                    if (controllerContext.DisplayMode == null)
                    {
                        controllerContext.DisplayMode = virtualPathDisplayInfo.DisplayMode;
                    }

                    // Populate the cache for all other display modes. We want to cache both file system hits and misses so that we can distinguish
                    // in future requests whether a file's status was evicted from the cache (null value) or if the file doesn't exist (empty string).
                    IEnumerable <IDisplayMode> allDisplayModes = DisplayModeProvider.Modes;
                    foreach (IDisplayMode displayMode in allDisplayModes)
                    {
                        if (displayMode.DisplayModeId != virtualPathDisplayInfo.DisplayMode.DisplayModeId)
                        {
                            DisplayInfo displayInfoToCache = displayMode.GetDisplayInfo(controllerContext.HttpContext, virtualPath, virtualPathExists: path => FileExists(controllerContext, path));

                            string cacheValue = String.Empty;
                            if (displayInfoToCache != null && displayInfoToCache.FilePath != null)
                            {
                                cacheValue = displayInfoToCache.FilePath;
                            }
                            ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, AppendDisplayModeToCacheKey(cacheKey, displayMode.DisplayModeId), cacheValue);
                        }
                    }
                    break;
                }

                searchedLocations[i] = virtualPath;
            }

            return(result);
        }
        private string GetPathFromGeneralName(ControllerContext controllerContext, List <ViewLocation> locations, string name, string controllerName, string areaName, string moduleName, string cacheKey, ref string[] searchedLocations)
        {
            string result = String.Empty;

            searchedLocations = new string[locations.Count];

            string       virtualPath            = null;
            ViewLocation location               = null;
            string       resolvedVirtualPath    = null;
            DisplayInfo  virtualPathDisplayInfo = null;

            for (int i = 0; i < locations.Count; i++)
            {
                location               = locations[i];
                virtualPath            = location.Format(name, controllerName, areaName, moduleName);
                virtualPathDisplayInfo = this.DisplayModeProvider.GetDisplayInfoForVirtualPath(virtualPath, controllerContext.HttpContext, path => FileExists(controllerContext, path), controllerContext.DisplayMode);

                if (virtualPathDisplayInfo != null)
                {
                    resolvedVirtualPath = virtualPathDisplayInfo.FilePath;

                    // save to view location cache
                    searchedLocations = g_emptyLocations;
                    result            = resolvedVirtualPath;
                    ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, this.AppendDisplayModeToCacheKey(cacheKey, virtualPathDisplayInfo.DisplayMode.DisplayModeId), result);

                    if (controllerContext.DisplayMode == null)
                    {
                        controllerContext.DisplayMode = virtualPathDisplayInfo.DisplayMode;
                    }

                    // Populate the cache with the existing paths returned by all display modes.
                    // Since we currently don't keep track of cache misses, if we cache view.aspx on a request from a standard browser
                    // we don't want a cache hit for view.aspx from a mobile browser so we populate the cache with view.Mobile.aspx.
                    DisplayInfo displayInfoToCache             = null;
                    IEnumerable <IDisplayMode> allDisplayModes = DisplayModeProvider.Modes;
                    foreach (IDisplayMode displayMode in allDisplayModes)
                    {
                        if (displayMode.DisplayModeId != virtualPathDisplayInfo.DisplayMode.DisplayModeId)
                        {
                            displayInfoToCache = displayMode.GetDisplayInfo(controllerContext.HttpContext, virtualPath, virtualPathExists: path => FileExists(controllerContext, path));

                            if (displayInfoToCache != null && displayInfoToCache.FilePath != null)
                            {
                                ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, this.AppendDisplayModeToCacheKey(cacheKey, displayInfoToCache.DisplayMode.DisplayModeId), displayInfoToCache.FilePath);
                            }
                        }
                    }
                    break;
                }

                searchedLocations[i] = virtualPath;
            }

            return(result);
        }
Example #7
0
        public Action <Stream> RenderView(ViewLocation viewLocation, dynamic model)
        {
            if (viewLocation == null)
            {
                return(stream => { });
            }

            return(stream =>
            {
                var writer = new StreamWriter(stream);
                writer.Write(viewLocation.Contents.ReadToEnd());
                writer.Flush();
            });
        }
        private string GetPathFromGeneralName(ControllerContext controllerContext, IList <ViewLocation> locations, string name, string controllerName, string areaName, string theme, string cacheKey, ref string[] searchedLocations)
        {
            string result = string.Empty;

            searchedLocations = new string[locations.Count];

            for (int i = 0; i < locations.Count; i++)
            {
                ViewLocation location    = locations[i];
                string       virtualPath = location.Format(name, controllerName, areaName, theme);

                if (FileExists(controllerContext, virtualPath))
                {
                    searchedLocations = _emptyLocations;
#if LOCALIZE
                    // View was located, not lets look on that same location for localized versions
                    // of the same view
                    string localizedVirtualPath;
                    if (LocalizedFileExists(controllerContext, virtualPath, out localizedVirtualPath))
                    {
                        virtualPath = localizedVirtualPath;
                        if (_onLocalized != null)
                        {
                            _onLocalized(this, new ViewEngines.LocalizedViewEventArgs(controllerContext, virtualPath, localizedVirtualPath));
                        }
                    }
                    else
                    {
                        if (_onLocalized != null)
                        {
                            _onLocalized(this, new ViewEngines.LocalizedViewEventArgs(controllerContext, virtualPath));
                        }
                    }
#endif
                    result = virtualPath;
                    ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, result);
                    break;
                }

                searchedLocations[i] = virtualPath;
            }

            return(result);
        }
Example #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            #region 测试是否可用
            //valid the textbox input
            string prompt = null;
            if (!Validator.Validate(out prompt))
            {
                MessageBox.Show(prompt);
                return;
            }
            DBServer ds = new DBServer()
            {
                ServerName   = this.textBox1.Text.Trim(),
                LoginName    = this.textBox2.Text.Trim(),
                Password     = this.textBox3.Text.Trim(),
                DatabaseName = this.textBox4.Text.Trim()
            };

            if (targetServerAvailable == null || !targetServerAvailable.ConnString.Equals(ds.ConnString))
            {
                MessageBox.Show(MessageUtil.GetMessage("LinkMust"));
                return;
            }
            //判断是否已经存在
            if (dsm.GetAllSourceInfolist().Exists(x => x.ServerName.Equals(ds.ServerName) && x.DatabaseName.Equals(ds.DatabaseName)))
            {
                MessageBox.Show(MessageUtil.GetMessage("dsExisted"));
                return;
            }
            #endregion

            if (dsm.AddSourceDBServer(ds))
            {
                MessageBox.Show(MessageUtil.GetMessage("SaveSuccess"));
                ViewLocation.SwitchTo(new DBList());
            }
            else
            {
                MessageBox.Show(MessageUtil.GetMessage("SaveFailed"));
            }
        }
Example #10
0
        public AppConfiguration()
        {
            AssemblyPool.AddThisAssembly();

            Messaging
            .HandleTheseMessagesAsynchronously(mi => mi.Name.EndsWith("TaskMsg"))
            .HandleTheseMessagesOnDispatcher(mi => mi.Name.EndsWith("UiMsg"))
            .TypesSubscribedToMessaging(t => typeof(AbstractViewModel).IsAssignableFrom(t))
            .SpecifyFlexibleSubscriptionRules(a => a.ByMethodName("Handle").PublishMethods("Route"))
            .TypesBeingAMessageHub(t => t.CanBeCastTo <IHub>())
            .TypesBeingAMessageHub(t => t.CanBeCastTo <IController>());

            Converters.ApplyDefaults();

            ViewLocation
            .ModelsMatching <DateTime>(m => m.Use((b, ctx) => b.Start <DatePicker>(ctx.Model).StaticStyle("EditableDate").BindSelectedDate()))
            .ModelsMatching <CustomerNumber>(m => m.FromMatchingDataTemplate())
            .AddLocator <EnumAsGroupBoxViews>();

            StartViewModel <MainViewModel>();
        }
Example #11
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewColumn column = this.dataGridView1.Columns[e.ColumnIndex];
                if (column is DataGridViewButtonColumn)
                {
                    if ("delete".Equals(column.Name))
                    {
                        //delete the dbserver
                        //DataRow dr = (this.dataGridView1.Rows[e.RowIndex].DataBoundItem as DataRowView).Row;
                        dbsm.DeleteSourceDBServerAt(e.RowIndex);
                        this.dataGridView1.Rows.RemoveAt(e.RowIndex);
                    }

                    if ("edit".Equals(column.Name))
                    {
                        //edit the dbserver
                        ViewLocation.SwitchTo(new DBEDIT(e.RowIndex));
                    }
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("ViewLocationId,Name,ViewPointAddress,UserId")] ViewLocation viewLocation)
        {
            if (_userManager.GetUserAsync(User).Result.IsAdmin)
            {
                if (id != viewLocation.ViewLocationId)
                {
                    return(NotFound());
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Update(viewLocation);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!ViewLocationExists(viewLocation.ViewLocationId))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction(nameof(Index)));
                }
                ViewData["UserId"] = new SelectList(_context.ApplicationUser, "Id", "Id", viewLocation.UserId);
                return(View(viewLocation));
            }
            else
            {
                return(NotFound());
            }
        }
Example #13
0
 public Action <System.IO.Stream> RenderView(ViewLocation viewLocation, dynamic model)
 {
     throw new NotImplementedException();
 }
Example #14
0
 /// <summary>
 /// データベース元新規作成
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     //switch to DBADD view
     ViewLocation.SwitchTo(new DBADD());
 }
 protected virtual string GetFormatedVirtualPath(HttpContextBase context, ViewLocation location, string name, string controllerName, string areaName)
 {
     return location.Format(name, controllerName, areaName);
 }
Example #16
0
 protected virtual string GetFormatedVirtualPath(HttpContextBase context, ViewLocation location, string name, string controllerName, string areaName)
 {
     return(location.Format(name, controllerName, areaName));
 }
Example #17
0
 private bool MatchesActionName(ViewLocationContext context, ViewLocation location)
 {
     return context.ActionDescriptor.ActionName.Equals(location.ActionName, StringComparison.OrdinalIgnoreCase);
 }
Example #18
0
        // Filter out if the verb doesnt match.
        private bool MatchsVerbMapping(ViewLocationContext context, ViewLocation location)
        {
            var httpVerb = context.RequestContext.GetHttpMethod();
            var verbs = location.Verbs;

            return verbs != null && !verbs.Any(verb => verb.Equals(httpVerb, StringComparison.OrdinalIgnoreCase));
        }
Example #19
0
 private void button1_Click(object sender, EventArgs e)
 {
     ViewLocation.SwitchTo(new DBList());
 }