fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Umbraco.Forms.Core;
  6. using Umbraco.Forms.Core.Attributes;
  7. using Umbraco.Forms.Data;
  8. using Umbraco.Forms.Data.Storage;
  9. using umbraco.cms.businesslogic.datatype;
  10. using umbraco.cms.businesslogic.member;
  11. using umbraco.cms.businesslogic.property;
  12.  
  13. namespace Contour.Addons.MemberTools.Providers.WorkflowTypes
  14. {
  15. public class MyWorkflow : WorkflowType
  16. {
  17. [Setting("Member Type", description = "Map member type",
  18. control = "Contour.Addons.MemberTools.Providers.FieldSettingTypes.MemberPropertyMapper",
  19. assembly = "Contour.Addons.MemberTools")]
  20. public string Fields { get; set; }
  21.  
  22.  
  23. public MyWorkflow()
  24. {
  25. this.Id = new Guid("081624E0-B318-42CD-929F-208CBB135C4A");
  26. this.Name = "Update umbraco member";
  27. this.Description = "Updates the logged in member";
  28.  
  29. }
  30.  
  31. public override Umbraco.Forms.Core.Enums.WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
  32. {
  33. if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated && System.Web.Security.Membership.GetUser() != null)
  34. {
  35. Dictionary<string, string> mappings = new Dictionary<string, string>();
  36. int mtId = 0;
  37.  
  38. string nameMapping = "NodeName";
  39. string loginMapping = "Login";
  40. string emailMapping = "Email";
  41. string passwordMapping = "Password";
  42.  
  43. string[] array = Fields.Trim().Split('|');
  44.  
  45. foreach (string s in array)
  46. {
  47. string[] a = s.Trim().Split(',');
  48.  
  49. if (a.Count() == 1 && s.Trim().Length >= 4)
  50. {
  51.  
  52. if (mtId == 0)
  53. int.TryParse(s.Trim(), out mtId);
  54.  
  55. }
  56. else if (a.Count() == 3)
  57. {
  58.  
  59. string mapping = "";
  60.  
  61. if (!string.IsNullOrEmpty(a[2]))
  62. mapping = record.RecordFields[new Guid(a[2])].ValuesAsString();
  63. else if (!string.IsNullOrEmpty(a[1]))
  64. mapping = StringHelper.ParsePlaceHolders(e.Context, record, a[1]);
  65. //TODO change _parseAttribute into a helper by itself
  66.  
  67. if ((!string.IsNullOrEmpty(mapping)))
  68. {
  69. if (a[0] == "__defaultname")
  70. nameMapping = mapping;
  71. else if (a[0] == "__defaultlogin")
  72. loginMapping = mapping;
  73. else if (a[0] == "__defaultemail")
  74. emailMapping = mapping;
  75. else if (a[0] == "__defaultpassword")
  76. passwordMapping = mapping;
  77. else
  78. {
  79. mappings.Add(a[0], mapping);
  80. LogHelper.Debug(a[0] + " " + mapping);
  81. }
  82. }
  83. }
  84. }
  85.  
  86.  
  87. int mId = 0;
  88.  
  89.  
  90. if (int.TryParse(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(), out mId))
  91. {
  92. Member m = Member.GetCurrentMember();
  93.  
  94. if (m != null)
  95. {
  96. if (passwordMapping != "Password")
  97. m.Password = passwordMapping;
  98.  
  99. if (emailMapping != "Email")
  100. m.Email = emailMapping;
  101.  
  102. if (loginMapping != "Login")
  103. m.LoginName = loginMapping;
  104.  
  105. foreach (Property p in m.getProperties)
  106. {
  107.  
  108. try
  109. {
  110.  
  111. if (mappings.ContainsKey(p.PropertyType.Alias))
  112. {
  113. switch (((BaseDataType)p.PropertyType.DataTypeDefinition.DataType).DBType)
  114. {
  115. case DBTypes.Date:
  116. m.getProperty(p.PropertyType.Alias).Value = DateTime.Parse(mappings[p.PropertyType.Alias]);
  117. break;
  118. case DBTypes.Integer:
  119. string v = mappings[p.PropertyType.Alias];
  120. if (v.ToLower() == "true" || v.ToLower() == "false")
  121. m.getProperty(p.PropertyType.Alias).Value = bool.Parse(v);
  122. else
  123. m.getProperty(p.PropertyType.Alias).Value = int.Parse(mappings[p.PropertyType.Alias]);
  124. break;
  125. default:
  126. m.getProperty(p.PropertyType.Alias).Value = mappings[p.PropertyType.Alias];;
  127. break;
  128. }
  129. }
  130.  
  131. }
  132. catch (Exception ex)
  133. {
  134. LogHelper.Debug(ex.ToString());
  135. }
  136.  
  137.  
  138. m.XmlGenerate(new System.Xml.XmlDocument());
  139. m.Save();
  140.  
  141. }
  142. }
  143. }
  144. }
  145. return Umbraco.Forms.Core.Enums.WorkflowExecutionStatus.Completed;
  146. }
  147.  
  148. public override List<Exception> ValidateSettings()
  149. {
  150. return new List<Exception>();
  151. }
  152. }
  153. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(5,7): error CS0246: The type or namespace name `Umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(6,7): error CS0246: The type or namespace name `Umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(7,7): error CS0246: The type or namespace name `Umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(8,7): error CS0246: The type or namespace name `Umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(9,7): error CS0246: The type or namespace name `umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(10,7): error CS0246: The type or namespace name `umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(11,7): error CS0246: The type or namespace name `umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(31,25): error CS0246: The type or namespace name `Umbraco' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(148,41): error CS0115: `Contour.Addons.MemberTools.Providers.WorkflowTypes.MyWorkflow.ValidateSettings()' is marked as an override but no suitable method found to override
Compilation failed: 9 error(s), 0 warnings
stdout
Standard output is empty