public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem != null) { Item innerItem = processorItem.InnerItem; string[] langsIDs = this.GetText(innerItem, "Languages", args).Split('|'); foreach (string langID in langsIDs) { Item langItm = Factory.GetDatabase("master").GetItem(langID); if (langItm != null) { Item workFlowItem = args.DataItem; Language language = Language.Parse(langItm.Name); if (language != workFlowItem.Language) { Item langItem = workFlowItem.Database.GetItem(workFlowItem.ID, language); langItem = langItem.Versions.AddVersion(); } } } } }
private IEnumerable <ProcessorItem> GetProcessors() { if (FeatureProcessors.Count == 0) { yield break; } Console.WriteLine("\nThe following processors are loaded:\n"); for (int i = 0; i < FeatureProcessors.Count; i++) { ProcessorItem pi = FeatureProcessors[i]; Console.WriteLine(string.Format("\t{0} {1} {2}", i, pi.Name, pi.Description)); } Console.WriteLine( "\nPlease enter a comma seperated list of processor ids you wish to use,\nin the order you wish to use them."); string[] idstring = Console.ReadLine().Split(new[] { ',', ';', '|' }); foreach (string s in idstring) { int i; if (int.TryParse(s, out i)) { if (i > -1 && i < FeatureProcessors.Count) { yield return(FeatureProcessors[i]); } } } }
public void Process(WorkflowPipelineArgs args) { Item item = args.DataItem; string stateId = item.State.GetWorkflowState().StateID; ProcessorItem workflowItem = args.ProcessorItem; string langs = workflowItem.InnerItem.Fields["LanguagesToWaitFor"].Value; string commandID = workflowItem.InnerItem.Fields["CommandToExecute"].Value; if (commandID == "") { Log.Error("WaitForLanguage action failed. The field 'CommandToExecute' value is not set.", this); return; } Item command = item.Database.Items[commandID]; if (command["Next state"] == "") { Log.Error("WaitForLanguage action failed. The field 'Next State' value of the command is not set.", this); return; } bool result = true; foreach (Language lang in item.Languages) { if (langs != "") { if (langs.IndexOf(lang.GetItem(item.Database).ID.ToString()) == -1) { continue; } } if (lang.Name == item.Language.Name) { continue; } Item langItem = item.Database.Items[item.Paths.FullPath, lang, item.Version]; WorkflowState workflowState = langItem.State.GetWorkflowState(); result = result && (workflowState.StateID == stateId || workflowState.FinalState); } if (result) { foreach (Language lang in item.Languages) { Item langItem = item.Database.Items[item.Paths.FullPath, lang, item.Version]; WorkflowState state = langItem.State.GetWorkflowState(); if (workflowItem.InnerItem.Parent.ID.ToString() == state.StateID) { WorkflowResult execute = CommandExecuter.Execute(commandID, langItem, "", true); if (!execute.Succeeded) { Log.Error("WaitForLanguage action failed: " + execute.Message, this); } } } } }
public void Process(WorkflowPipelineArgs args) { Item item = args.DataItem; ProcessorItem workflowItem = args.ProcessorItem; string commandToExecute = workflowItem.InnerItem["CommandToExecute"]; if (commandToExecute == "" || item.Database.Items[commandToExecute] == null || item.Database.Items[commandToExecute]["Next state"] == "") { Log.Error("Action SetStateByLanguage is failed: 'CommandToExecute' field is not set properly", this); return; } foreach (Language language in item.Languages) { if (language.Name == item.Language.Name) { continue; } Item langItem = item.Database.Items[item.Paths.FullPath, language, item.Version]; if (GetIsAllowToChangeState(langItem, workflowItem)) { using (new EditContext(langItem)) { CommandExecuter.Execute(commandToExecute, langItem, "", true); } } } }
// returns processorItem if WorkflowPipelineArgs input is valid public static ProcessorItem ValidateArgsProcessorItem(WorkflowPipelineArgs args) { // Check the condition before executing Assert.ArgumentNotNull((object)args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem == null) { return(null); } else // item in processor { LayoutItem layoutItem = args.DataItem.Visualization.GetLayout(Sitecore.Context.Device); if (layoutItem == null) // item does not have page layout { string[] acceptablePaths = { "/sitecore/content/Data Components", "/sitecore/system/Modules/Wildcards/Routes" }; if (acceptablePaths.Any(args.DataItem.Paths.Path.Contains)) { return(processorItem); // valid workflow item, although item has no page layout } else { return(null); } // invalid workflow item } // item has page layout return(processorItem); } }
bool GetIsAllowToChangeState(Item langItem, ProcessorItem workflowItem) { if (langItem.State.GetWorkflowState() == null) { return(false); } return(workflowItem.InnerItem.Fields["AllowedToChangeStates"].Value.IndexOf(langItem.State.GetWorkflowState().StateID) != -1); }
// Access workflow process to get info public void Process(WorkflowPipelineArgs args) { ProcessorItem processorItem = args.ProcessorItem; // If item is not in processor and item doesn't have page layout, retrun if (processorItem == null) { return; } Item innerItem = processorItem.InnerItem; // Check the condition before excuting Assert.ArgumentNotNull((object)args, "args"); string fullPath = innerItem.Paths.FullPath; string fromAddress = "*****@*****.**"; string toAddress = User.Current.Profile.Email; if (String.IsNullOrEmpty(toAddress)) { return; } string subject = this.GetText(innerItem, "subject", args); string message = this.GetText(innerItem, "message", args); Error.Assert(toAddress.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath); Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath); Error.Assert(message.Length > 0, "The 'Message' field is not specified in the mail action item: " + fullPath); try { if (!String.IsNullOrEmpty(toAddress.Trim()) && !String.IsNullOrEmpty(fromAddress.Trim())) { // Send email if no issue found if (Util.sendEmail(toAddress, subject, message, fromAddress, "", "", true)) { Sitecore.Diagnostics.Log.Info("Begin Blog info", this); Sitecore.Diagnostics.Log.Info("fromAddress " + fromAddress, this); Sitecore.Diagnostics.Log.Info("toAddress " + toAddress, this); Sitecore.Diagnostics.Log.Info("subject " + subject, this); Sitecore.Diagnostics.Log.Info("message " + message, this); Sitecore.Diagnostics.Log.Info("End info", this); Sitecore.Diagnostics.Log.Info("Email Successfully Sent!!", this); } else { SheerResponse.ShowError("Sending Email Failed. Please try to approve again", ""); args.AbortPipeline(); } } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error("Sending Email Failed - Exception Error", ex, this); } }
public PropertyItem GetProperty(IPropertyProvider propertyProvider, ProcessorItem item, string propertyName) { string filepath = item.Value; switch (propertyName) { case "name": return(new PropertyItem(Path.GetFileNameWithoutExtension(filepath))); case "ext": case "extension": return(new PropertyItem(Path.GetExtension(filepath).SafeSubstring(1))); case "filename": return(new PropertyItem(Path.GetFileName(filepath))); case "dir": case "directory": return(new PropertyItem(Path.GetDirectoryName(filepath))); case "value": return(new PropertyItem(item.Value)); case "ivalue": return(new PropertyItem(item.InitialValue)); case "mime": string mime = MimeTypesMap.GetMimeType(item.Value); return(new PropertyItem(mime)); case "relpath": PropertyItem originItem = item.GetProperty(propertyProvider, "origin"); if (originItem.IsNumeric || originItem == null) { return(null); } string origin = originItem.ValueText; if (!item.Value.StartsWith(origin)) { return(null); } return(new PropertyItem(item.Value.Substring(origin.Length + 1))); case "size": case "filesize": if (!File.Exists(item.Value)) { return(null); } long size = new FileInfo(item.Value).Length; return(new PropertyItem(size, null)); default: return(null); } }
public void GetProperty_Origin_NotCachedProvided() { var mock = new Mock <IPropertyProvider>(); mock.Setup(foo => foo.GetProperty(It.IsAny <IPropertyProvider>(), It.IsAny <ProcessorItem>(), "origin")).Returns(new PropertyItem("fruit")); var item = new ProcessorItem("Testing123", null); var property = item.GetProperty(mock.Object, "origin"); Assert.Equal("fruit", property.Value); }
public void GetProperty_ProvidedProperty_Equals() { var mock = new Mock <IPropertyProvider>(); mock.Setup(foo => foo.GetProperty(It.IsAny <IPropertyProvider>(), It.IsAny <ProcessorItem>(), "filesize")).Returns(new PropertyItem(21.23)); var item = new ProcessorItem("Testing123", null); var property = item.GetProperty(mock.Object, "filesize"); Assert.NotNull(property); // If null, TryCachePropertyValue might not have worked. Assert.Equal(21.23, property.Value); }
public PropertyItem GetProperty(IPropertyProvider _, ProcessorItem item, string propertyName) { foreach (IPropertyProvider propertyProvider in propertyProviders) { PropertyItem property = propertyProvider.GetProperty(this, item, propertyName); if (property != null) { return(property); } } return(fallbackProvider?.GetProperty(this, item, propertyName)); }
public void GetProperty_Origin_IsCached() { var mock = new Mock <IPropertyProvider>(); mock.Setup(foo => foo.GetProperty(It.IsAny <IPropertyProvider>(), It.IsAny <ProcessorItem>(), "origin")).Returns <PropertyItem>(null); var item = new ProcessorItem("Testing123", "apple"); var property = item.GetProperty(mock.Object, "origin"); Assert.NotNull(property); // If null, TryCachePropertyValue might not have worked. Assert.Equal("apple", property.Value); }
public PropertyItem GetProperty(IPropertyProvider propertyProvider, ProcessorItem item, string propertyName) { switch (propertyName) { case "pixels": return(GetPixels(ref propertyProvider, ref item, 1)); case "megapixels": return(GetPixels(ref propertyProvider, ref item, 1000000)); default: return(null); } }
public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem != null) { Item innerItem = processorItem.InnerItem; string fullPath = innerItem.Paths.FullPath; string from = GetText(innerItem, "from", args); string to = GetText(innerItem, "to", args); string host = GetText(innerItem, "mail server", args); string subject = GetText(innerItem, "subject", args); string body = GetText(innerItem, "message", args); Error.Assert(to.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath); Error.Assert(from.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath); Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath); Error.Assert(host.Length > 0, "The 'Mail server' field is not specified in the mail action item: " + fullPath); //var message = new MailMessage(from, to); //message.Subject = subject; //message.Body = body; ////new SmtpClient(host,587).Send(message); //SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); //smtp.EnableSsl = true; //smtp.UseDefaultCredentials = false; //smtp.Credentials = new NetworkCredential("*****@*****.**", "cuntho21010711"); //smtp.Send(message); SmtpClient smtpclient = new SmtpClient { Host = "smtp.gmail.com", Port = 587, Credentials = new NetworkCredential("*****@*****.**", "cuntho21010711"), EnableSsl = true }; MailMessage objmsg = new MailMessage { From = new MailAddress(@from) }; objmsg.To.Add(to); objmsg.Subject = subject; objmsg.Body = body + "vao day"; objmsg.IsBodyHtml = true; smtpclient.Send(objmsg); } }
public void Value_Changed_CacheCleared() { var mock = new Mock <IPropertyProvider>(); mock.Setup(foo => foo.GetProperty(It.IsAny <IPropertyProvider>(), It.IsAny <ProcessorItem>(), "filesize")).Returns <PropertyItem>(null); var item = new ProcessorItem("Testing123", null); item.TryCachePropertyValue("filesize", new PropertyItem(21.23)); item.Value = "Done."; var property = item.GetProperty(mock.Object, "filesize"); Assert.Null(property); }
public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem == null || args.DataItem == null) { return; } Item innerItem = processorItem.InnerItem; MultilistField langs = innerItem.Fields[FieldnameWorkflowLanguages]; Database db = Factory.GetDatabase("master"); if (langs == null || langs.TargetIDs == null || !langs.TargetIDs.Any() || db == null) { return; } ID iD = ID.Null; foreach (var lang in langs.TargetIDs) { Item item = db.GetItem(lang); if (item == null) { continue; } if (item.Name.Equals(args.DataItem.Language.Name, StringComparison.CurrentCultureIgnoreCase)) { iD = MainUtil.GetID(innerItem[FieldnameWorkflowNextState], null); break; } } if (iD.IsNull) { return; } args.NextStateId = iD; }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem == null) { return; } Item innerItem = processorItem.InnerItem; string fromAddress = this.GetText(innerItem, "from", args); string mailServer = this.GetText(innerItem, "mail server", args); string subject = this.GetText(innerItem, "subject", args); string message = this.GetText(innerItem, "message", args); string approversRole = GetText(innerItem, "approvers role", args); string actionPath = innerItem.Paths.FullPath; Error.Assert(fromAddress.Length > 0, "The 'From' field is not specified in the mail action item: " + actionPath); Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + actionPath); Error.Assert(mailServer.Length > 0, "The 'Mail server' field is not specified in the mail action item: " + actionPath); message = ReplaceVariables(message, args); MailMessage mailMessage = new MailMessage { From = new MailAddress(fromAddress), Subject = subject, Body = message, IsBodyHtml = true }; AddRecipientsToMail(mailMessage, approversRole); try { SmtpClient smtpClient = new SmtpClient(mailServer); smtpClient.Send(mailMessage); } catch (Exception ex) { Log.Error($"Failed to send mail: {ex.Message}", ex, typeof(SubmissionNotification)); } }
/// <summary> /// Returns rules of a landing workflow action. /// </summary> /// <param name="processorItem"> /// The processor item. /// </param> /// <returns> /// Returns RuleList of landing workflow. /// </returns> protected RuleList<WorkflowRuleContext> BuildRuleList(ProcessorItem processorItem) { Assert.ArgumentNotNull(processorItem, "processorItem"); Item actionItem = processorItem.InnerItem; RuleList<WorkflowRuleContext> ruleList = new RuleList<WorkflowRuleContext>(); if (!string.IsNullOrEmpty(actionItem["Rule"])) { ruleList.AddRange(RuleFactory.GetRules<WorkflowRuleContext>(actionItem.Fields["Rule"]).Rules); } if (!string.IsNullOrEmpty(actionItem["Rules"])) { Item[] rules = ((MultilistField)actionItem.Fields["Rules"]).GetItems(); ruleList.AddRange(RuleFactory.GetRules<WorkflowRuleContext>(rules, "Rule").Rules); } return ruleList; }
private void OpenResult(CommandData data) { int index = data.Parameters.Get <int>(0); List <ProcessorItem> items = results.ToList(); if (index < 0 || index >= items.Count) { return; } ProcessorItem item = items[index]; if (File.Exists(item.Value)) { Process.Start(item.Value); } }
/// <summary> /// Returns rules of a landing workflow action. /// </summary> /// <param name="processorItem"> /// The processor item. /// </param> /// <returns> /// Returns RuleList of landing workflow. /// </returns> protected RuleList <WorkflowRuleContext> BuildRuleList(ProcessorItem processorItem) { Assert.ArgumentNotNull(processorItem, "processorItem"); Item actionItem = processorItem.InnerItem; RuleList <WorkflowRuleContext> ruleList = new RuleList <WorkflowRuleContext>(); if (!string.IsNullOrEmpty(actionItem["Rule"])) { ruleList.AddRange(RuleFactory.GetRules <WorkflowRuleContext>(actionItem.Fields["Rule"]).Rules); } if (!string.IsNullOrEmpty(actionItem["Rules"])) { Item[] rules = ((MultilistField)actionItem.Fields["Rules"]).GetItems(); ruleList.AddRange(RuleFactory.GetRules <WorkflowRuleContext>(rules, "Rule").Rules); } return(ruleList); }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem == null) { return; } var contentItem = args.DataItem; var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem); var contentHistory = contentWorkflow.GetHistory(contentItem); if (contentHistory.Length > 0) { string username = contentItem[Sitecore.FieldIDs.UpdatedBy]; Assert.IsFalse(string.IsNullOrEmpty(username), "updatedby user cannot be found"); var submittingUser = Sitecore.Security.Accounts.User.FromName(username, false); Assert.ArgumentNotNull(submittingUser, "submittingUser"); string userEmail = submittingUser.Profile.Email; var approvingUser = Sitecore.Context.User; Assert.ArgumentNotNull(approvingUser, "approvingUser"); string subject = String.Format("Item '{0}' has been approved", contentItem.Paths.FullPath); string body = String.Format("Item '{0}' has been approved by '{1}'", contentItem.Paths.FullPath, approvingUser.Profile.FullName); try { System.Net.Mail.MailMessage mailMessage = new MailMessage(approvingUser.Profile.Email, userEmail); mailMessage.Subject = subject; mailMessage.Body = body; SmtpClient smtpClient = new SmtpClient(Sitecore.Configuration.Settings.MailServer); smtpClient.Send(mailMessage); } catch (SmtpException ex) { Log.Error(String.Format("Unable to send approval email to '{0}' error occurred {1}", submittingUser.Profile.FullName, ex.ToString()), this); } } }
public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem != null) { Item innerItem = processorItem.InnerItem; Item dataItem = args.DataItem; if (!string.IsNullOrEmpty(innerItem[Templates.ScriptWorkflowAction.Fields.ScriptBody])) { Item item = innerItem.Database.GetItem(new ID(innerItem[Templates.ScriptWorkflowAction.Fields.ScriptBody])); if (!ItemExtensions.IsPowerShellScript(item)) { Context.ClientPage.ClientResponse.Broadcast(SessionElevationErrors.OperationFailedWrongDataTemplate(), "Shell"); } else if ((!RulesUtils.EvaluateRules(innerItem[Templates.ScriptWorkflowAction.Fields.EnableRule], dataItem, false) ? false : RulesUtils.EvaluateRules(item[Templates.Script.Fields.ShowRule], dataItem, false))) { UrlString urlString = new UrlString(UIUtil.GetUri("control:PowerShellRunner")); urlString.Append("id", dataItem.ID.ToString()); urlString.Append("db", dataItem.Database.Name); urlString.Append("lang", dataItem.Language.Name); int number = dataItem.Version.Number; urlString.Append("ver", number.ToString(CultureInfo.InvariantCulture)); urlString.Append("scriptId", item.ID.ToString()); urlString.Append("scriptDb", item.Database.Name); if (Context.ClientPage.Application == null) { SheerResponse.ShowModalDialog(urlString.ToString(), "400", "220"); } else { Context.ClientPage.ClientResponse.Broadcast(SheerResponse.ShowModalDialog(urlString.ToString(), "400", "220", "PowerShell Script Results", false), "Shell"); } } } } }
public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem != null) { Item innerItem = processorItem.InnerItem; string fullPath = innerItem.Paths.FullPath; string sendFrom = GetText(innerItem, "SendFrom", args); string toUser = GetText(innerItem, "ToUser", args); //string host = GetText(innerItem, "mail server", args); string messageTitle = GetText(innerItem, "MessageTitle", args); string messageBody = GetText(innerItem, "MessageBody", args); Error.Assert(toUser.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath); Error.Assert(sendFrom.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath); Error.Assert(messageTitle.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath); //Error.Assert(host.Length > 0, // "The 'Mail server' field is not specified in the mail action item: " + fullPath); //var message = new MailMessage(from, to); //message.Subject = subject; //message.Body = body; //new SmtpClient(host).Send(message); QYMsgParams qymsgParams = new QYMsgParams(); qymsgParams.touser = toUser; qymsgParams.msgtype = "text"; qymsgParams.agentid = AgentID; qymsgParams.safe = "0"; MsgContent msgContent = new MsgContent(); msgContent.content = messageBody; qymsgParams.text = msgContent; string r1 = MsgService.QYSend(qymsgParams); } }
public void Process(WorkflowPipelineArgs args) { ProcessorItem processorItem = Helper.ValidateArgsProcessorItem(args); if (processorItem == null) { return; } // Add publishable item in Queue ApproveEmail ae = new ApproveEmail(); Database master = Sitecore.Configuration.Factory.GetDatabase("master"); List <Item> getDatasourceChildren = ae.getAllPublishableItems(args); foreach (Item publishItem in getDatasourceChildren) { if (publishItem != null) { Sitecore.Publishing.PublishManager.AddToPublishQueue(publishItem, ItemUpdateType.Created); //Helper.ClearDatabaseCache(master, publishItem); //Sitecore.Diagnostics.Log.Info("WP IS - Cleared Master DB Cache - " + publishItem.Paths.FullPath, this); //Sitecore.Diagnostics.Log.Info("WP IS - Publishing Queue - " + publishItem.Paths.FullPath + " added in Queue", this); //Database targetDb = Sitecore.Configuration.Factory.GetDatabase("web"); //if (targetDb.GetItem(publishItem.ID) != null) //{ // Helper.ClearDatabaseCache(targetDb, publishItem); // Sitecore.Diagnostics.Log.Info("WP IS - Cleared Web DB Cache - " + publishItem.Paths.FullPath, this); //} } } // Publish all items in Queue Database[] targetDBs = new Database[] { Sitecore.Configuration.Factory.GetDatabase("web") }; Language[] languages = new Language[] { Sitecore.Data.Managers.LanguageManager.GetLanguage("en") }; Sitecore.Publishing.PublishManager.PublishIncremental(master, targetDBs, languages); }
public bool Evaluate(IOutput output, IPropertyProvider propertyProvider, IPropertyStore propertyStore, ProcessorItem item) { PropertyItem leftValue = LeftOperand.GetValue(output, propertyProvider, propertyStore, item); if (leftValue == null) { return(Operator.HasFlag(Operator.Ignore)); } PropertyItem rightValue = RightOperand.GetValue(output, propertyProvider, propertyStore, item); if (rightValue == null) { return(Operator.HasFlag(Operator.Ignore)); } if (leftValue.IsNumeric && rightValue.IsNumeric) // If we are comparing two numbers. { double vl = leftValue.ValueNumber; double vr = rightValue.ValueNumber; return(EvaluateNumeric(vl, vr, output)); } else if (!leftValue.IsNumeric && !rightValue.IsNumeric) // If we are comparing two strings. { string vl = leftValue.ValueText; string vr = rightValue.ValueText; return(EvaluateText(vl, vr, output)); } else { output.WriteLine(Level.Warn, $"&-c;Condition type mismatch, unable to compare values, ignoring condition: {leftValue.Value} {Operator} {rightValue.Value}&-^;"); output.WriteLine(Level.Debug, $"&-c; - LV_NUMERIC: {leftValue.IsNumeric}, RV_NUMERIC: {rightValue.IsNumeric}&-^;"); return(true); } }
public PropertyItem GetProperty(IPropertyProvider propertyProvider, IPropertyStore propertyStore, ProcessorItem item) { switch (Type) { case PropertyType.Global: return(propertyStore.GetProperty(Value)); case PropertyType.Item: return(item.GetProperty(propertyProvider, Value)); case PropertyType.Text: default: return(null); } }
public void GetProperty_NullPropertyProvider_ThrowsArgumentNullException() { var item = new ProcessorItem("Testing123", null); Assert.Throws <ArgumentNullException>(() => item.GetProperty(null, "filesize")); }
private static PropertyItem GetPixels(ref IPropertyProvider propertyProvider, ref ProcessorItem item, double divisor) { PropertyItem propWidth = item.GetProperty(propertyProvider, "width"); if (propWidth == null || !propWidth.IsNumeric) { return(null); } PropertyItem propHeight = item.GetProperty(propertyProvider, "height"); if (propHeight == null || !propHeight.IsNumeric) { return(null); } return(new PropertyItem(propWidth.ValueNumber * propHeight.ValueNumber / divisor)); }
public void TryCachePropertyValue_NullPropertyName_ThrowsArgumentNullException() { var item = new ProcessorItem("Testing123", null); Assert.Throws <ArgumentNullException>(() => item.TryCachePropertyValue(null, new PropertyItem(21.23))); }
// Access workflow process to get info public void Process(WorkflowPipelineArgs args) { ProcessorItem processorItem = Helper.ValidateArgsProcessorItem(args); if (processorItem == null) { return; } Item innerItem = processorItem.InnerItem; UpdateWorkflowState update = new UpdateWorkflowState(); User userWhoMadeUpdate = User.FromName(args.DataItem.Statistics.UpdatedBy, true); // Get "To Addresses" for rejection email string toAddress = ""; string listOfAuthorsEmails = Helper.GetToAddressesForApproveRejectEmail(User.Current, args.DataItem.Paths.FullPath); if (!String.IsNullOrEmpty(listOfAuthorsEmails)) { toAddress = userWhoMadeUpdate.Profile.Email + ";" + listOfAuthorsEmails; } // no other author emails found, only send to contributor who made original update else { toAddress = userWhoMadeUpdate.Profile.Email; } string fullPath = innerItem.Paths.FullPath; string fromAddress = User.Current.Profile.Email; string subject = Helper.GetText(innerItem, "subject", args); string message = Helper.GetText(innerItem, "message", args); Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath); Error.Assert(message.Length > 0, "The 'Message' field is not specified in the mail action item: " + fullPath); // Update main page item and its resource folder update.ChangeWorkflowState(args.DataItem, "Working", true); // Find all controls on item foreach (string control in update.GetDatasourceValue(args, args.DataItem)) { if (!String.IsNullOrEmpty(control)) { Item ctrl = args.DataItem.Database.GetItem(control); if (ctrl != null) { update.ChangeWorkflowState(ctrl, "Working", false); } } } try { if (!String.IsNullOrEmpty(toAddress.Trim()) && !String.IsNullOrEmpty(fromAddress.Trim())) { // Send email if no issue found if (Util.sendEmail(toAddress, subject, message, fromAddress, "", "", true)) { if (fromAddress == "*****@*****.**") { fromAddress = "User doesn't have email address"; } Sitecore.Diagnostics.Log.Info("Begin info", this); Sitecore.Diagnostics.Log.Info("fromAddress " + fromAddress, this); Sitecore.Diagnostics.Log.Info("toAddress " + toAddress, this); Sitecore.Diagnostics.Log.Info("subject " + subject, this); Sitecore.Diagnostics.Log.Info("message " + message, this); Sitecore.Diagnostics.Log.Info("End info", this); Sitecore.Diagnostics.Log.Info("Email Successfully Sent!!", this); } else { SheerResponse.ShowError("Sending Email Failed. Please try to reject again", ""); args.AbortPipeline(); } } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error("Sending Email Failed - Exception Error", ex, this); } }
public PropertyItem GetValue(IOutput output, IPropertyProvider propertyProvider, IPropertyStore propertyStore, ProcessorItem item) { switch (Type) { case OperandType.ItemProperty: PropertyItem propertyItem = item.GetProperty(propertyProvider, ValueText); if (propertyItem != null) { return(propertyItem); } output.WriteLine(Level.Fine, $" &-c;Item property named '&-e;{ValueText}&-^;' doesn't exist...&-^;"); return(null); case OperandType.GlobalProperty: PropertyItem property = propertyStore.GetProperty(ValueText); if (property != null) { return(property); } output.WriteLine(Level.Fine, $" &-c;Global property named '&-e;{ValueText}&-^;' doesn't exist...&-^;"); return(null); case OperandType.NumericConstant: return(new PropertyItem(ValueNumeric, Unit)); case OperandType.TextConstant: return(new PropertyItem(ValueText)); default: return(null); } }
bool GetIsAllowToChangeState(Item langItem, ProcessorItem workflowItem) { if(langItem.State.GetWorkflowState() == null) return false; return workflowItem.InnerItem.Fields["AllowedToChangeStates"].Value.IndexOf(langItem.State.GetWorkflowState().StateID) != -1; }