小编Nom*_*ler的帖子

如何记录和查找最昂贵的查询?

sql2k8中的活动监视器允许我们查看最昂贵的查询.好的,这很酷,但有没有办法可以通过查询分析器记录此信息或获取此信息?我真的不想打开Sql Management控制台,而是查看活动监视器仪表板.

我想弄清楚哪些查询写得不好/架构设计不当等等.

谢谢你的帮助!

sql-server profiling sql-server-2008

64
推荐指数
2
解决办法
5万
查看次数

使用多态方法生成排列

说明 :

请编写一段代码作为输入列表,其中每个元素是另一个包含未知类型的列表,并返回可以通过从每个输入列表中取一个元素获得的所有可能列表的列表.

例如:

[[1,2],[3,4]],应该返回:[[1,3],[1,4],[2,3],[2,4]].

[['1'],['2'],['3','4']]应该返回[['1','2','3'],['1','2', '4'].

我的代码:

public static void Main(string[] args)
{
     //Create a list of lists of objects.
       var collections = new List<List<object>>();
       collections.Add(new List<object> { 1, 5, 3 });
       collections.Add(new List<object> { 7, 9 });
       collections.Add(new List<object> { "a", "b" });

     //Get all the possible permutations
       var combinations = GetPermutations(collections);

     //Loop through the results and display them in console
       foreach (var result in combinations)
       {
           result.ForEach(item => Console.Write(item + " "));
           Console.WriteLine();
       }

        Console.WriteLine("Press any key …
Run Code Online (Sandbox Code Playgroud)

c# polymorphism permutation

8
推荐指数
1
解决办法
185
查看次数

字段值更改未保存

我正在尝试从后端动态更改字段值,但看起来更改没有被保存。

代码

item是从主数据库中获取的。

   using (new EditContext(item))
   {
        item.Editing.BeginEdit();
        try
        {
            //Value is updated here from "" to Test
            item.Fields["Content"].Value = "Test";
        }
        finally
        {
            //item.Fields["Content"].Value is "" again. 
            item.Editing.AcceptChanges();
            item.Editing.EndEdit();
        }                 
    }
Run Code Online (Sandbox Code Playgroud)

更新

正如@sitecore登山者所说,我确实将代码改回使用 -

new Sitecore.SecurityModel.SecurityDisabler()

然而,问题是缓存。仅在我清除缓存并重新启动浏览器后,更新的值才会显示在内容编辑器中。

为了解决这个问题,我在进行编辑之前禁用了缓存,并在编辑完成后将其重新打开。

CacheManager.Enabled = false;

       using (new Sitecore.SecurityModel.SecurityDisabler())
       {
            item.Editing.BeginEdit();
            try
            {
                item.Fields["Content"].Value = "Test";
            }
            finally
            {
                item.Editing.EndEdit();
            }                 
        }
CacheManager.Enabled = true;
Run Code Online (Sandbox Code Playgroud)

c# editing sitecore

5
推荐指数
1
解决办法
4892
查看次数

Sitecore 发布时间太长

智能发布项目(不发布其子项目)大约需要 1 分钟的发布时间。即使它们没有真正发布的更改。而且这个问题并不局限于特定的项目或一组项目 - 这是整个网站的问题。

日志文件片段:

11412 11:54:29 INFO  AUDIT (sitecore\admin): Publish item: master:/sitecore/content/Home/error/404, language: en, version: 1, id: {872E1F05-CCF7-48F5-97EA-65A48FE93DAA}
15368 11:54:34 INFO  AUDIT (sitecore\admin): Publish, languages:en, targets:Internet, databases:web, incremental:false, smart:true, republish:false, children:false
ManagedPoolThread #96 11:54:34 INFO  Job started: Publish
ManagedPoolThread #4 11:54:34 INFO  Job started: Publish to 'web'
ManagedPoolThread #4 11:54:34 INFO  HtmlCacheClearer clearing HTML caches for all sites (1).
ManagedPoolThread #4 11:54:34 INFO  HtmlCacheClearer done.
ManagedPoolThread #4 11:55:32 INFO  Job ended: Publish to 'web' (units processed: 2)
ManagedPoolThread …
Run Code Online (Sandbox Code Playgroud)

publish sitecore sitecore6

5
推荐指数
1
解决办法
2159
查看次数

如何按设备更改控件的占位符?

使用Sitecore 7 - 有没有一种方法可以指定模板控件的占位符将基于设备?

示例: Placeholder A if the device is Mobile else Placeholder B

这更多地与在Mobile中以不同于桌面站点的方式定位内容有关.

UPDATE

Trayek的答案很棒,确实很有效.虽然,我最终采用了不同的方法.

在我的模板的布局细节中,我添加了一个控件C; 将其占位符设置为A并在附加的"参数"部分中添加了HideBydevice Desktop.然后,我再次添加了控件C; 将其占位符设置为B,并在附加的"参数"部分中添加了HideBydevice Mobile.

然后在我的代码中,我检查HideBydevice参数的值并隐藏sublayout/control,如果参数的值与Sitecore.Context.Device.Name相同

这对我有用.

sitecore sitecore7

2
推荐指数
1
解决办法
746
查看次数

Sitecore 重定向错误

我知道我可以扩展Sitecore.Pipelines.HttpRequest.ExecuteRequest和覆盖方法,例如RedirectOnItemNotFound重定向到我的自定义 404 页面等。我想知道是否有办法重定向到自定义页面(位于 sitecore 中)以处理除 404 和 500 之外的所有错误?

RedirectOnNoAccess我猜有一种 403 错误的方法,但我正在寻找重定向所有错误的方法,如 400、401、403、405 等。

Sitecore v7.2

干杯

error-handling sitecore sitecore7 sitecore7.2

2
推荐指数
1
解决办法
8496
查看次数

在C.编译错误中读取文件

下面的代码无法编译.在我的视觉工作室中STDOUT_FILENO下面有一条卷曲的线条,并没有提供任何关于如何纠正它的建议.

#include <stdio.h>
#include <stdlib.h>
#include "read_file.h"

void main()
{
   char ch, file_name[25];
   //FILE *fp;
   FILE *fd;
   int num_read;

   printf("Enter the name of file you wish to see\n");
   gets(file_name);

   fd = fopen(file_name, "O_RDONLY");
   if (fd < 0)
     {
           perror("Error while opening the file.\n");

       exit(EXIT_FAILURE);
     }
   printf("The contents of %s file are :\n", file_name);

   for (;;)
     {
           num_read = fread(fd, ch, sizeof(ch));
           if (num_read < '0')
             {
               perror("Error while reading the file.\n");
               exit(EXIT_FAILURE);
             }
           if (num_read == 0)
             {
               break;
             } …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
255
查看次数