Example #1
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     Engine.SystemSession.SetSetting("SystemUpdateCancelled", null, PersistenceScope.Application);
     if (WAFContext.Engine.NativeDefinition.Build < 1228) {
         WMQuestion q = new WMQuestion(DialogueIcon.Warning, UIButtons.ConfirmCancel,
             "Upgrade to .NET 4.0", "This update requires that you update the entire site to .NET 4.0. In IIS you will need to change the Application Pool to .NET 4.0, and in Visual Studio you must change the target framework of the website to .NET 4.0"
             + Environment.NewLine + ""
             + Environment.NewLine + "IMPORTANT: Update the .NET version AFTER this update process is complete. The update dialogue will freeze when it is complete, refresh the browser and you will get a compilation error telling you to upgrade the website to .NET 4.0"
             + Environment.NewLine + ""
             + Environment.NewLine + "Click Confirm to continue.");
         return new NextCall(q, afterConfirmation);
     } else {
         return Continue(invoker);
     }
 }
Example #2
0
 NextCall onDirectlyViaHttpAnswer(WorkflowMethod invoker)
 {
     var diag = invoker as WMContentForm;
     string url = diag.Result.Get<ShortStringPropertyValue>("url").Value;
     Session.SetSetting("MergeDef.Url", url, PersistenceScope.Application);
     try {
         var uri = new Uri(url, UriKind.Absolute);
     } catch (Exception err) {
         var n = new WMQuestion(DialogueIcon.Warning, UIButtons.Ok, "Invalid URL", err.Message);
         return new NextCall(n, directlyViaHttp);
     }
     try {
         string username = diag.Result.Get<ShortStringPropertyValue>("username").Value;
         string password = diag.Result.Get<ShortStringPropertyValue>("password").Value;
         if (!url.EndsWith("/")) url = url + "/";
         url = url.ToLower();
         if (url.EndsWith("/edit/")) url = url.Substring(0, url.Length - "edit/".Length);
         Session.SetSetting("MergeDef.Url", url, PersistenceScope.Application);
         var t = Utils.Encrypt(Guid.NewGuid() + username + ":::" + password, "ed3e1a0093398710653ed1e428");
         url = url + "?WAF_Action=GetDefForImport&T=" + HttpUtility.UrlEncode(t);
         WebClient wc = new WebClient();
         var s = Utils.DeSerialize<string>(wc.DownloadData(url));
         if (s.StartsWith("ERROR: ")) {
             throw new Exception(s.Substring(7));
         } else {
             var tempPath = WAFRuntime.Engine.FileTempPath + Guid.NewGuid();
             WAFRuntime.FileSystem.FileWriteAllText(tempPath, s);
             return startMerge(tempPath);
         }
     } catch (Exception error) {
         downloadError = error.Message;
         return directlyViaHttp(null);
     }
 }
Example #3
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     WMQuestion q = new WMQuestion(DialogueIcon.Question, UIButtons.Cancel, new string[] { "By copy", "By reference" }, "By copy or reference?", "A copy will be independent of the file in the library. A referenced file will depend upon and change with the file in the library. ");
     return new NextCall(q, onComplete);
 }
Example #4
0
        public override NextCall Invoke(WorkflowMethod invoker)
        {
            if (Session.Access.IsAdmin() && count() > 1000) {

                WMQuestion q = new WMQuestion(DialogueIcon.Question, UIButtons.YesNoCancel, Local.Text("Web.WAF.Edit.Wastebin.DefaultDeleteFastRunningEvents"), Local.Text("Web.WAF.Edit.Wastebin.DefaultYouShouldRebuild"));
                return new NextCall(q, startDelete);
            } else {
                return startDelete(invoker);
            }
        }
Example #5
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     if (Session.Access.IsAdmin() && count() > 1000) {
         WMQuestion q = new WMQuestion(DialogueIcon.Question, UIButtons.YesNoCancel, "Delete fast without running events?", "You should rebuild all indexes after the delete operation if you choose the fast option.");
         return new NextCall(q, startDelete);
     } else {
         return startDelete(invoker);
     }
 }
Example #6
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     string cap;
     string txt;
     cap = "Delete selected items?";
     txt = _files.Count + " file(s) and " + _folders.Count + " folder(s).";
     WMQuestion q = new WMQuestion(DialogueIcon.Info, UIButtons.ConfirmCancel, null, cap, txt);
     WFContext.InBackgroundMode = false;
     return new NextCall(q, onCompleteConfirm);
 }
Example #7
0
 NextCall nextFile(WorkflowMethod invoker)
 {
     DateTime batchStart = DateTime.Now;
     while (true) {
         if (i == filesTo.Count) return new NextCall(onCompleteAll);
         if (WFContext.BreakExecution) throw new WDCancelException();
         WFContext.Description = i + " of " + filesTo.Count + " files, " + Utils.GetByteSizeString(bytesProgress) + " of " + Utils.GetByteSizeString(bytesTotal) + "...";
         WFContext.SetProgress(bytesProgress, bytesTotal);
         string file = filesFrom[i];
         string destination = filesTo[i];
         if (WAFRuntime.FileSystem.FileExists(destination)) {
             if (_overwriteExistingFiles == null) {
                 WMQuestion q = new WMQuestion(DialogueIcon.Warning, UIButtons.YesNo, null, "Overwrite existing files?", destination);
                 return new NextCall(q, onCompleteOverwriteQuestion);
             } else {
                 if ((bool)_overwriteExistingFiles) {
                     if (_onlyMove) {
                         WAFRuntime.FileSystem.FileDelete(destination);
                         WAFRuntime.FileSystem.FileMove(file, destination);
                     } else {
                         WAFRuntime.FileSystem.FileCopy(file, destination);
                     }
                 }
             }
         } else {
             if (_onlyMove) {
                 WAFRuntime.FileSystem.FileMove(file, destination);
             } else {
                 WAFRuntime.FileSystem.FileCopy(file, destination);
             }
         }
         i++;
         bytesProgress += WAFRuntime.FileSystem.GetFileInfo(destination).Length;
         if (DateTime.Now.Subtract(batchStart).TotalSeconds > 1) break;
     }
     return new NextCall(nextFile);
 }
Example #8
0
 NextCall createFile(bool forceOverwrite)
 {
     if (!forceOverwrite && WAFRuntime.FileSystem.FileExists(_newPath)) {
         WMQuestion q = new WMQuestion(DialogueIcon.Warning, UIButtons.YesNoCancel, null, "File already exists, overwrite?", Path.GetFileName(_newPath));
         return new NextCall(q, onConfirmOverwriteComplete);
     } else {
         File.Create(_newPath);
         SetUnsecureOutput("NewPath", _newPath);
     }
     return null;
 }
Example #9
0
 NextCall createFolder(bool forceOverwrite)
 {
     string path = GetSecureInput<string>();
     string newPath = path + _newFolderName;
     if (!forceOverwrite && WAFRuntime.FileSystem.DirectoryExists(newPath)) {
         WMQuestion q = new WMQuestion(DialogueIcon.Warning, UIButtons.YesNoCancel, null, "Folder already exists, overwrite?", "Path: " + newPath.Substring(WAFContext.PathFromRootToAppFolder.Length));
         return new NextCall(q, onConfirmOverwriteComplete);
     } else {
         WAFRuntime.FileSystem.DirectoryCreate(newPath);
         SetUnsecureOutput("NewPath", newPath + "\\");
     }
     return null;
 }
Example #10
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     WMQuestion q = new WMQuestion(DialogueIcon.Question, UIButtons.Cancel, new string[] { Local.Text("Web.WAF.Dialogues.Main.FileLibraryWMQuestionByCopy"), Local.Text("Web.WAF.Dialogues.Main.FileLibraryWMQuestionByRef") }, Local.Text("Web.WAF.Dialogues.Main.FileLibraryWMQuestionByCopyOrRef"), Local.Text("Web.WAF.Dialogues.Main.FileLibraryWMQuestionInfoText"));
     return new NextCall(q, onComplete);
 }
Example #11
0
        public override NextCall Invoke(WorkflowMethod invoker)
        {
            string cap;
            string txt;

            cap = Local.Text("Web.WAF.Edit.ExplorerDeleteSelectedItems");
            txt = _files.Count + " " + Local.Text("Web.WAF.Edit.ExplorerFilesAnd") + " " + _folders.Count + " " + Local.Text("Web.WAF.Edit.ExplorerFolders");
            WMQuestion q = new WMQuestion(DialogueIcon.Info, UIButtons.ConfirmCancel, null, cap, txt);
            WFContext.InBackgroundMode = false;
            return new NextCall(q, onCompleteConfirm);
        }
Example #12
0
    NextCall onCompleteSettingsFromTask(WorkflowMethod invoker)
    {
        var form = invoker as WMContentForm;
        ScheduledTask task = Session.GetContent<ScheduledTask>(_taskNodeId);
        task.TypeName = form.Result.Get<ShortStringPropertyValue>("Typename").Value;
        task.FriendlyName = form.Result.Get<ShortStringPropertyValue>("FriendlyName").Value;

        //task.Enabled = form.Result.Get<CheckBoxPropertyValue>("Enabled").Value;
        task.IntervalUnit = (TaskShedulerIntervalUnit)int.Parse(form.Result.Get<ShortStringPropertyValue>("IntervalUnit").Value);
        task.StartAt = form.Result.Get<IntegerPropertyValue>("StartAt").Value;
        switch (form.Result.Get<ShortStringPropertyValue>("StartAtUnit").Value) {
            case "Seconds": task.StartAt = task.StartAt; break;
            case "Minutes": task.StartAt = task.StartAt * 60; break;
            case "Hours": task.StartAt = task.StartAt * 60 * 60; break;
            case "Days": task.StartAt = task.StartAt * 60 * 60 * 24; break;
            default: break;
        }
        task.UpdateChanges();
        if (_showSettingsButton && form.AnswerCustomIndex == 0) {// show settings
            Type t;
            IWorkflowMethodTaskWithSettings tw = null;
            try {
                t = Utils.GetType(task.TypeName);
            } catch {
                var diag = new WMQuestion(DialogueIcon.Warning, UIButtons.Ok, "Typename check:", "The typename was not found.");
                return new NextCall(diag, Invoke);
            }
            if (typeof(IWorkflowMethodTaskWithSettings).IsAssignableFrom(t)) {
                tw = Activator.CreateInstance(t) as IWorkflowMethodTaskWithSettings;
            } else {
                var diag = new WMQuestion(DialogueIcon.Warning, UIButtons.Ok, "Typename check:", "The typename must implement IWorkflowMethodTaskWithSettings to support settings.");
                return new NextCall(diag, Invoke);
            }
            tw.InitSettings(task);
            var diagSett = tw.CreateSettingsDialogue(task, Invoke);
            return diagSett;
        } else if ((_showSettingsButton && form.AnswerCustomIndex == 1) || (!_showSettingsButton && form.AnswerCustomIndex == 0)) { // test
            WorkflowMethod diag = null;
            if (task.TypeName.Length > 0) {
                Type t = null;
                try {
                    t = Utils.GetType(task.TypeName);
                } catch {
                    diag = new WMQuestion(DialogueIcon.Warning, UIButtons.Ok, "Typename check:", "The typename is unknown.");
                }
        #pragma warning disable 612, 618
                if (diag == null) {
                    if (typeof(WorkflowMethod).IsAssignableFrom(t) || typeof(System.Workflow.ComponentModel.Activity).IsAssignableFrom(t)) {
                        diag = new WMQuestion(DialogueIcon.Info, UIButtons.Ok, "Typename check:", "The typename is valid!");
                    } else {
                        diag = new WMQuestion(DialogueIcon.Warning, UIButtons.Ok, "Typename check:", "The type was found, but is does not inherit from: WorkflowMethod or Activity");
                    }
                }
        #pragma warning restore 612, 618
            } else {
                diag = new WMQuestion(DialogueIcon.Warning, UIButtons.Ok, "Typename check:", "Typename is empty. ");
            }
            return new NextCall(diag, Invoke);
        } else if ((_showSettingsButton && form.AnswerCustomIndex == 2) || (!_showSettingsButton && form.AnswerCustomIndex == 1)) { // internal
            WorkflowMethod diag = new WMEditContent(task.Key, true);
            return new NextCall(diag, Invoke);
        } else { // save & close
            WFContext.RefreshStartupRequest();
            return null;
        }
    }
Example #13
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     var diag = new WMQuestion(DialogueIcon.Question, UIButtons.YesNoCancel, "Include inner contents?", "Including inner content takes longer time.");
     return new NextCall(diag, onCompleteAnswer);
 }
Example #14
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     var sb = new StringBuilder();
     long sizeQueryCache = Engine.GetMemoryUsageQueryCache();
     sb.AppendLine("CONTENT CACHE:");
     sb.AppendLine();
     sb.AppendLine("Count: " + Engine.GetCountContentCache().ToString("### ### ###"));
     sb.AppendLine("Size: " + Utils.GetByteSizeString(Engine.GetMemoryUsageContentCache()));
     sb.AppendLine("Avg size: " + Utils.GetByteSizeString((double)Engine.GetMemoryUsageContentCache() / (double)Engine.GetCountContentCache()));
     sb.AppendLine();
     sb.AppendLine("QUERY CACHE:");
     sb.AppendLine();
     sb.AppendLine("Count: " + Engine.GetCountQueryCache().ToString("### ### ###"));
     sb.AppendLine("Size: " + Utils.GetByteSizeString(Engine.GetMemoryUsageQueryCache()));
     sb.AppendLine("Avg size: " + Utils.GetByteSizeString((double)Engine.GetMemoryUsageQueryCache() / (double)Engine.GetCountQueryCache()));
     var diag = new WMQuestion(DialogueIcon.Info, UIButtons.Ok, new string[] { "Update" }, "Cache statistics", sb.ToString());
     diag.Height = 170;
     diag.Width = 300;
     return new NextCall(diag, onComplete);
 }