public void Run(dynamic caller)
        {
            var sourceTables = new [] { "ContentItem", "TopicalItem" };
            var csv          = new CsvReader(new StreamReader(HttpContext.Current.Server.MapPath("/Library/Resources/links-for-staging.csv")));
            var spyderUrls   = csv.GetRecords <CsvData>().ToArray();
            var count        = spyderUrls.Length;
            var increment    = 100 / (double)count;
            var progress     = 0d;
            var index        = 0;

            foreach (var spyderUrl in spyderUrls)
            {
                progress += increment;
                ClientLog.Progress(caller, (int)progress, "Replacing invalid https url # " + index++);
                Guid?id = null;
                foreach (var source in sourceTables)
                {
                    id = (Guid?)AutoDal.ExecuteScalar(string.Format("select [OriginalContentId] from [{0}] where [Url] = '{1}'", source, spyderUrl.Url));
                    if (id != null)
                    {
                        break;
                    }
                }
                if (id == null)
                {
                    continue;
                }
                var table          = StormId.Decode(id).Table;
                var replaceInvalid = string.Format("update [{0}] set [Xhtml] = replace(cast(Xhtml as nvarchar(max)),'{1}', '{2}') where [Id] = '{3}'", table, spyderUrl.ReplaceMe, spyderUrl.Valid, id);
                var fixDoubles     = string.Format("update [{0}] set [Xhtml] = replace(cast(Xhtml as nvarchar(max)),'http:http:', 'http:') where [Id] = '{1}'", table, id);
                AutoDal.ExecuteNonQuery(replaceInvalid);
                AutoDal.ExecuteNonQuery(fixDoubles);
            }
        }
Exemplo n.º 2
0
 public static void Progress(dynamic caller, int percent, string message = "", bool isList = false)
 {
     caller.patchProgress(percent + "%");
     if (!string.IsNullOrEmpty(message))
     {
         ClientLog.Write(caller, message, isList);
     }
 }
Exemplo n.º 3
0
 public void Run(dynamic caller)
 {
     for (int i = 0; i < 20; i++)
     {
         Thread.Sleep(500);
         var percent = (i + 1) * 5;
         var message = "Processed # " + i;
         ClientLog.Progress(caller, percent, message, isList: true);
     }
 }
Exemplo n.º 4
0
 public void Run(dynamic caller)
 {
     for (int i = 0; i < 5; i++)
     {
         Thread.Sleep(500);
         var percent = (i + 1) * 20;
         var message = "Processed # " + i;
         ClientLog.Progress(caller, percent, message);
         if (i == 3)
         {
             throw new IndexOutOfRangeException();
         }
     }
 }
Exemplo n.º 5
0
        public void RunPatch(string name)
        {
            var caller = Clients.Caller;

            try
            {
                caller.patchStart(name);
                var watch = Stopwatch.StartNew();
                PatchService.Run(caller, name);
                watch.Stop();
                caller.patchSuccess(name, watch.Elapsed.Hours + " hrs " + watch.Elapsed.Minutes + " mins " + watch.Elapsed.Seconds + " secs");
            }
            catch (Exception ex)
            {
                ClientLog.Error(caller, name, ex);
            }
        }