public static double RandomDouble(ISpecificationProperty specificationProperty) { if (specificationProperty.PropertyType != "double" && specificationProperty.PropertyType != "double?") { throw new ArgumentException("Specification Property " + specificationProperty.Name + " is not an double!"); } double randomDouble; if (specificationProperty.Minimum == null && specificationProperty.Maximum == null) { randomDouble = TemplatesHelper.RandomDouble(-100d, 100d); } else if (specificationProperty.Minimum == null) { randomDouble = TemplatesHelper.RandomDouble(-100d, (double)specificationProperty.Maximum); } else if (specificationProperty.Maximum == null) { randomDouble = TemplatesHelper.RandomDouble((double)specificationProperty.Minimum, 100d); } else { randomDouble = TemplatesHelper.RandomDouble((double)specificationProperty.Minimum, (double)specificationProperty.Maximum); } if (specificationProperty.MantissaSize != null) { randomDouble = Math.Round(randomDouble, specificationProperty.MantissaSize.Value); } return(randomDouble); }
public override void SetSettings(IModelTemplate modelTemplate) { base.SetSettings(modelTemplate); navigation.Model = TemplatesHelper.GetNavBarCustomizationNode(); formStateModelSynchronizerComponent.Model = GetFormStateNode(); modelSynchronizationManager.ModelSynchronizableComponents.Add(navigation); }
public static int RandomInt(ISpecificationProperty specificationProperty) { if (specificationProperty.PropertyType != "int" && specificationProperty.PropertyType != "int?") { throw new ArgumentException("Specification Property " + specificationProperty.Name + " is not an integer!"); } int randomInt; if (specificationProperty.Minimum == null && specificationProperty.Maximum == null) { randomInt = TemplatesHelper.RandomInt(int.MinValue, int.MaxValue); } else if (specificationProperty.Minimum == null) { randomInt = TemplatesHelper.RandomInt(int.MinValue, (int)specificationProperty.Maximum); } else if (specificationProperty.Maximum == null) { randomInt = TemplatesHelper.RandomInt((int)specificationProperty.Minimum, int.MaxValue); } else { randomInt = TemplatesHelper.RandomInt((int)specificationProperty.Minimum, (int)specificationProperty.Maximum); } return(randomInt); }
void ISupportStoreSettings.SetSettings(IModelTemplate settings) { IModelTemplateWin templateModel = (IModelTemplateWin)settings; TemplatesHelper templatesHelper = new TemplatesHelper(templateModel); formStateModelSynchronizer.Model = templatesHelper.GetFormStateNode(); navigation.Model = templatesHelper.GetNavBarCustomizationNode(); }
void ISupportStoreSettings.SetSettings(IModelTemplate settings) { var templateModel = (IModelTemplateWin)settings; var templatesHelper = new TemplatesHelper(templateModel); formStateModelSynchronizer.Model = templatesHelper.GetFormStateNode(); navBarControlModelSynchronizer.Model = templatesHelper.GetNavBarCustomizationNode(); templatesHelper.SetRibbonSettings(ribbonControl); }
public override void SetSettings(IModelTemplate modelTemplate) { base.SetSettings(modelTemplate); //navigation.Model = LoContentControls calizationHelper.GetNavBarCustomizationNode(); navigation.Model = TemplatesHelper.GetNavBarCustomizationNode(); formStateModelSynchronizerComponent.Model = GetFormStateNode(); modelSynchronizationManager.ModelSynchronizableComponents.Add(new NavigationModelSynchronizer(dockPanelNavigation, (IModelTemplateWin)modelTemplate)); modelSynchronizationManager.ModelSynchronizableComponents.Add(navigation); }
private Entity CreateTemplates(string attachmentName) { //Template 1 string title1 = rowEmailSubject1 + DateTime.Now; string body1 = rowEmailBody1 + DateTime.Now; Entity template1 = new Entity("template"); template1["title"] = title1; template1["subject"] = TemplatesHelper.GetSubjectXML(title1); template1["subjectpresentationxml"] = TemplatesHelper.GetSubjectPresentationXML(title1); template1["body"] = TemplatesHelper.GetBodyXML(body1); template1["presentationxml"] = TemplatesHelper.GetBodyPresentationXML(body1); template1["templatetypecode"] = 8;//Global template template1["ispersonal"] = false; template1["languagecode"] = 1033; template1.Id = OrganizationService.Create(template1); //Template 2 string title2 = rowEmailSubject2 + DateTime.Now; string body2 = rowEmailBody2 + DateTime.Now; Entity template2 = new Entity("template"); template2["title"] = title2; template2["subject"] = TemplatesHelper.GetSubjectXML(title2); template2["subjectpresentationxml"] = TemplatesHelper.GetSubjectPresentationXML(title2); template2["body"] = TemplatesHelper.GetBodyXML(body2); template2["presentationxml"] = TemplatesHelper.GetBodyPresentationXML(body2); template2["templatetypecode"] = 8;//Global template template2["ispersonal"] = false; template2["languagecode"] = 1033; template2.Id = OrganizationService.Create(template2); //Add attachment to template 1 Entity activityMimeAttachment1 = new Entity("activitymimeattachment"); activityMimeAttachment1["objectid"] = template1.ToEntityReference(); activityMimeAttachment1["objecttypecode"] = "template"; activityMimeAttachment1["filename"] = attachmentName; activityMimeAttachment1["body"] = Convert.ToBase64String(new UnicodeEncoding().GetBytes("Sample Annotation Text 1")); activityMimeAttachment1["mimetype"] = "text/plain"; OrganizationService.Create(activityMimeAttachment1); //Add attachment to template 2 Entity activityMimeAttachment2 = new Entity("activitymimeattachment"); activityMimeAttachment2["objectid"] = template2.ToEntityReference(); activityMimeAttachment2["objecttypecode"] = "template"; activityMimeAttachment2["filename"] = attachmentName; activityMimeAttachment2["body"] = Convert.ToBase64String(new UnicodeEncoding().GetBytes("Sample Annotation Text 2")); activityMimeAttachment2["mimetype"] = "text/plain"; OrganizationService.Create(activityMimeAttachment2); return(template1); }
protected override IModelFormState GetFormStateNode() { if (View != null) { return(TemplatesHelper.GetFormStateNode(View.Id)); } else { return(base.GetFormStateNode()); } }
private void BaseCall(IModelTemplate settings) { IModelTemplateWin templateModel = (IModelTemplateWin)settings; TemplatesHelper templatesHelper = new TemplatesHelper(templateModel); var viewSiteManager = (ViewSiteManager)this.GetFieldValue("viewSiteManager"); var formState = viewSiteManager.View != null?templatesHelper.GetFormStateNode(viewSiteManager.View.Id) : templatesHelper.GetFormStateNode(); var formStateModelSynchronizer = (FormStateModelSynchronizer)this.GetFieldValue("formStateModelSynchronizer"); formStateModelSynchronizer.Model = formState; templatesHelper.SetRibbonSettings(Ribbon); }
void ISupportStoreSettings.SetSettings(IModelTemplate settings) { IModelTemplateWin templateModel = (IModelTemplateWin)settings; TemplatesHelper templatesHelper = new TemplatesHelper(templateModel); IModelFormState formState; if (viewSiteManager.View != null) { formState = templatesHelper.GetFormStateNode(viewSiteManager.View.Id); } else { formState = templatesHelper.GetFormStateNode(); } formStateModelSynchronizer.Model = formState; }
private Entity CreateTemplate() { Entity template = new Entity("template"); template["title"] = "DXTools - Integration Test - SendCustomEmailTest_WithTypeFormatters - " + DateTime.Now; template["templatetypecode"] = 8;//Global template template["ispersonal"] = false; template["languagecode"] = 1033; rowEmailSubject = "Integration Test " + DateTime.Now; rowEmailBody = "<p><strong> This is an integration test {CurrentVAT} </strong></p>"; template["subject"] = TemplatesHelper.GetSubjectXML(rowEmailSubject); template["subjectpresentationxml"] = TemplatesHelper.GetSubjectPresentationXML(rowEmailSubject); template["body"] = TemplatesHelper.GetBodyXML(rowEmailBody); template["presentationxml"] = TemplatesHelper.GetBodyPresentationXML(rowEmailBody); template.Id = OrganizationService.Create(template); return(template); }
protected override OrganizationRequest SetupTriggerRequest() { Entity template = TemplatesHelper.RetrieveTemplateByName(templateName, this.OrganizationService); if (!template.Contains("title")) { Assert.Fail("Template doesn't contain a title"); } rowEmailSubject = template["title"].ToString(); Entity contact = CreateContact(); payment = CreatePayment(contact); EntityReference paymentReference = payment.ToEntityReference(); WhoAmIResponse whoAmI = OrganizationService.Execute(new WhoAmIRequest()) as WhoAmIResponse; Entity whoAmIUser = new Entity("systemuser"); whoAmIUser.Id = whoAmI.UserId; EntityCollection to = new EntityCollection(); to.Entities.Add(contact); return(new dxtools_SendCustomEmailRequest() { EmailTemplateName = template["title"].ToString() , ToRecipient = to , FromSender = new EntityReference("systemuser", whoAmI.UserId) , Regarding = paymentReference , RecordContext = paymentReference , Attachments = string.Empty , StaticParameters = "{\"currentvat\":\"20%\"}" }); }
public static string RandomString(ISpecificationProperty specificationProperty) { if (specificationProperty.PropertyType != "string") { throw new ArgumentException("Specification Property " + specificationProperty.Name + " is not an string!"); } if (specificationProperty.Name.ToLower().Contains("number")) { int digits = 0; digits = specificationProperty.Minimum == null ? 0 : ((int?)specificationProperty.Minimum).Value > 6 ? 6 : ((int?)specificationProperty.Minimum).Value; int minimum = Convert.ToInt32(Math.Pow(10, digits)) - 1; digits = ((int?)specificationProperty.Maximum).Value > 6 ? 6 : ((int?)specificationProperty.Maximum).Value; int maximum = Convert.ToInt32(Math.Pow(10, digits)) - 1; return(TemplatesHelper.RandomInt(minimum, maximum).ToString()); } return(TemplatesHelper.RandomString((int)specificationProperty.Maximum)); }
private void cbb_template_SelectedIndexChanged(object sender, EventArgs e) { string currentPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string dataDirectory = ConfigurationManager.AppSettings["DataDirectory"]; string completeDataDirectory = Path.Combine(currentPath, dataDirectory); if (Directory.Exists(completeDataDirectory)) { string keysFile = ConfigurationManager.AppSettings["KeysFile"]; string fullpathToKeysFile = Path.Combine(completeDataDirectory, keysFile); if (File.Exists(fullpathToKeysFile)) { KeysHelper.LoadFromFile(fullpathToKeysFile); //string templatesFile = ConfigurationManager.AppSettings["TemplatesFile"]; string templatesFile = cbb_template.Text; string fullpathToTemplatesFile = Path.Combine(completeDataDirectory, templatesFile); if (File.Exists(fullpathToTemplatesFile)) { TemplatesHelper.LoadFromFile(fullpathToTemplatesFile, KeysHelper.Caracteres.Count); } int minChar = Math.Min(KeysHelper.Caracteres.Count, TemplatesHelper.Templates.Count); alphabet.Clear(); for (int idx = 0; idx < minChar; idx++) { CaractereMorphing current = new CaractereMorphing() { Caractere = KeysHelper.Caracteres[idx], Template = TemplatesHelper.Templates[idx] }; alphabet.Add(current); } } } else { } }
private Entity BuildTemplate(string templateTitle, string subject, string body) { Entity newTemplate = new Entity("template"); newTemplate["title"] = templateTitle; newTemplate["templatetypecode"] = 8;//Global template newTemplate["ispersonal"] = false; newTemplate["languagecode"] = 1033; //IMPORTANT NOTE: //Both fields are mandatory to set 'subject' properly newTemplate["subject"] = TemplatesHelper.GetSubjectXML(subject);; newTemplate["subjectpresentationxml"] = TemplatesHelper.GetSubjectPresentationXML(subject); //IMPORTANT NOTE: //Both fields are mandatory to set 'body' properly newTemplate["body"] = TemplatesHelper.GetBodyXML(body);; newTemplate["presentationxml"] = TemplatesHelper.GetBodyPresentationXML(body); newTemplate.Id = this.CrmOrganisationService.Create(newTemplate); return(newTemplate); }
public void RetrieveExistingTemplate() { Entity template = TemplatesHelper.RetrieveTemplateByName(TemplateName, this.CrmOrganisationService); Assert.IsTrue(template.Contains("presentationxml")); InstantiateTemplateRequest instantiateTemplateRequest = new InstantiateTemplateRequest() { ObjectId = Systemuser.GetCallingUserID(this.CrmOrganisationService) , ObjectType = "systemuser" , TemplateId = template.Id }; InstantiateTemplateResponse instantiateTemplateResponse = this.CrmOrganisationService.Execute(instantiateTemplateRequest) as InstantiateTemplateResponse; Assert.IsNotNull(instantiateTemplateResponse.EntityCollection.Entities[0]); Entity email = instantiateTemplateResponse.EntityCollection.Entities[0]; Assert.IsTrue(email.Contains("description")); }
public void TestCreateTemplateProgramatically() { string templateName = "DXTools - Test Create Template Programatically " + DateTime.Now; string subject = "DXTools Template created Programatically " + DateTime.Now; string body = "<p><strong>Amazing</strong></p>"; Entity newTemplate = BuildTemplate(templateName, subject, body); //Validate Template has been created correctly Entity existingTemplateRecord = TemplatesHelper.RetrieveTemplateByName(templateName, this.CrmOrganisationService); Assert.IsNotNull(existingTemplateRecord); Assert.IsTrue(existingTemplateRecord["subject"].ToString().Contains(subject)); Assert.IsTrue(existingTemplateRecord["body"].ToString().Contains(body)); //Validate email based on template is correct Entity emailRecord = GetEmailInstantiateFromTemplate(newTemplate, GetCurrentUser().Id); Assert.IsTrue(emailRecord["subject"].ToString().Contains(subject)); Assert.IsTrue(emailRecord["description"].ToString().Contains(body)); //Email body //Validate email can be created in CRM succesfully this.CrmOrganisationService.Create(emailRecord); }
void ISupportStoreSettings.SetSettings(IModelTemplate settings) { IModelTemplateWin templateModel = (IModelTemplateWin)settings; TemplatesHelper templatesHelper = new TemplatesHelper(templateModel); formStateModelSynchronizer.Model = templatesHelper.GetFormStateNode(); navigation.Model = templatesHelper.GetNavBarCustomizationNode(); templatesHelper.SetRibbonSettings(ribbonControl); }
public virtual void SetSettings(IModelTemplate modelTemplate) { this.modelTemplate = (IModelTemplateWin)modelTemplate; locaizationHelper = new TemplatesHelper(this.modelTemplate); string viewId = String.Empty; if (viewSiteManager.View != null) { viewId = viewSiteManager.View.Id; } formStateModelSynchronizer.Model = locaizationHelper.GetFormStateNode(viewId); ReloadSettings(); }
public virtual void SetSettings(IModelTemplate modelTemplate) { this.modelTemplate = (IModelTemplateWin)modelTemplate; localizationHelper = new TemplatesHelper(this.modelTemplate); SetBarManagerModel(); }
public void RetrieveExistingTemplate() { Entity template = TemplatesHelper.RetrieveTemplateByName(TemplateName, this.CrmOrganisationService); Assert.IsTrue(template.Contains("presentationxml")); }
public static string RandomValue(ISpecification specification, ISpecificationProperty specificationProperty, bool usingMocks, bool useNullForDefault) { if (specificationProperty.Relationship != null && specificationProperty.Relationship.RelatedModel != null) { ISpecificationModel relatedModel = specificationProperty.Relationship.RelatedModel; if (usingMocks) { if (specificationProperty.IsList) { return("this." + relatedModel.Variable.ListInstanceName + ".Select(_mock => _mock.Object).ToList()"); } else { return("this." + relatedModel.Variable.InstanceName + ".Object"); } } else { if (specificationProperty.IsList) { return(TemplatesHelper.NewOf(TemplatesHelper.ListOf(relatedModel.Interface.VariableType))); } else if (useNullForDefault) { return("null"); } else { return("this." + relatedModel.Variable.InstanceName); } } } if (specification.Enumerations.Values.Any(_enumeration => _enumeration.Name == specificationProperty.PropertyType.Replace("?", ""))) { ISpecificationEnumeration specificationEnumeration = specification.Enumerations.Values.First(_enumeration => _enumeration.Name == specificationProperty.PropertyType.Replace("?", "")); IEnumeration enumeration = new TemplateEnumeration(specification.Settings.FrameworkNamespace, specificationEnumeration.Name); foreach (ISpecificationEnumerationItem item in specificationEnumeration.Items) { enumeration.Add(new TemplateEnumerationItem(item.Name)); } return(TemplatesHelper.FormatEnumeration(TemplatesHelper.RandomEnumerationItem(enumeration))); } if (specificationProperty.PropertyType == "bool" || specificationProperty.PropertyType == "bool?") { return(TemplatesHelper.FormatBool(specificationProperty.Default != null ? (bool)specificationProperty.Default : TemplatesHelper.RandomBool())); } if (specificationProperty.PropertyType == "DateTime" || specificationProperty.PropertyType == "DateTime?") { return(TemplatesHelper.FormatDateTime(specificationProperty.Default != null ? (DateTime)specificationProperty.Default : specificationProperty.IsDateOnly?DateTime.Now.Date: DateTime.Now)); } if (specificationProperty.PropertyType == "double" || specificationProperty.PropertyType == "double?") { return(TemplatesHelper.FormatDouble(specificationProperty.Default != null ? (double)specificationProperty.Default : TestingHelper.RandomDouble(specificationProperty))); } if (specificationProperty.PropertyType == "Guid" || specificationProperty.PropertyType == "Guid?") { return("Guid.NewGuid()"); } if (specificationProperty.PropertyType == "int" || specificationProperty.PropertyType == "int?") { return(TemplatesHelper.FormatInt(specificationProperty.Default != null ? (int)specificationProperty.Default : TestingHelper.RandomInt(specificationProperty))); } if (specificationProperty.PropertyType == "string") { return(TemplatesHelper.FormatString(specificationProperty.Default != null ? (string)specificationProperty.Default : TestingHelper.RandomString(specificationProperty))); } if (specificationProperty.PropertyType == "TimeSpan" || specificationProperty.PropertyType == "TimeSpan?") { return(TemplatesHelper.FormatTimeSpan(specificationProperty.Default != null ? (TimeSpan)specificationProperty.Default : TemplatesHelper.RandomTimeSpan())); } return(TemplatesHelper.FormatString("Unsupported type: " + specificationProperty.PropertyType)); }