public static SPFieldMultiChoiceValue TypeToValue(int value) { var res = new SPFieldMultiChoiceValue(); if (((value & (int)TemplateTypeEnum.AllItemEvents) == (int)TemplateTypeEnum.AllItemEvents)) { res.Add(TemplateCT.TypeChoices.All); } else { if (((value & (int)TemplateTypeEnum.ItemAdded) == (int)TemplateTypeEnum.ItemAdded)) { res.Add(TemplateCT.TypeChoices.ItemAdded); } if (((value & (int)TemplateTypeEnum.ItemRemoved) == (int)TemplateTypeEnum.ItemRemoved)) { res.Add(TemplateCT.TypeChoices.ItemRemoved); } if (((value & (int)TemplateTypeEnum.ItemUpdated) == (int)TemplateTypeEnum.ItemUpdated)) { res.Add(TemplateCT.TypeChoices.ItemUpdated); } } return(res); }
void Refresh() { this.Name = m_Item[TemplateCT.TemplateName] as string; this.State = EnumConverter.ToState(m_Item[TemplateCT.TemplateState] as string); SPFieldUserValueCollection v = new SPFieldUserValueCollection(m_Item.Web, m_Item.GetFieldValue <object>(TemplateCT.SendDraftTo, string.Empty).ToString()); this.SendDraftToAdresses = v.Select(p => p.User.Email).ToList(); this.UseFileForSubject = m_Item.GetFieldValue <bool>(TemplateCT.TemplateSubjectUseFile); this.UseFileForBody = m_Item.GetFieldValue <bool>(TemplateCT.TemplateBodyUseFile); this.UseFileForFrom = m_Item.GetFieldValue <bool>(TemplateCT.TemplateFromUseFile); this.UseFileForReply = m_Item.GetFieldValue <bool>(TemplateCT.TemplateReplayUseFile); this.From = m_Item.GetValueFromTextFieldOrFile(this.UseFileForFrom, TemplateCT.TemplateFrom, TemplateCT.TemplateFromFile, out FromAttached); this.Replay = m_Item.GetValueFromTextFieldOrFile(this.UseFileForReply, TemplateCT.TemplateReplay, TemplateCT.TemplateReplayFile, out ReplyAttached); this.Body = m_Item.GetValueFromTextFieldOrFile(this.UseFileForBody, TemplateCT.TemplateBody, TemplateCT.TemplateBodyFile, out this.BodyAttached); this.Subject = m_Item.GetValueFromTextFieldOrFile(this.UseFileForSubject, TemplateCT.TemplateSubject, TemplateCT.TemplateSubjectFile, out this.SubjectAttached); if (m_Item[TemplateCT.TemplateType] != null) { var val = new SPFieldMultiChoiceValue(m_Item[TemplateCT.TemplateType].ToString()); this.EventTypes = EnumConverter.ToType(val); } else { this.EventTypes = (int)TemplateTypeEnum.Unknown; } this.Associations = AssociationCollection.ParseOrDefault(m_Item[TemplateCT.Associations] as string); }
protected override void MapProperties(object modelHost, Hashtable fileProperties, ContentPageDefinitionBase definition) { base.MapProperties(modelHost, fileProperties, definition); var typedDefinition = definition.WithAssertAndCast<FilterDisplayTemplateDefinition>("model", value => value.RequireNotNull()); fileProperties[BuiltInInternalFieldNames.ContentTypeId] = "0x0101002039C03B61C64EC4A04F5361F38510660400F643FF79F6BD764F8A469B6F153396EE"; if (!string.IsNullOrEmpty(typedDefinition.CrawlerXSLFileURL)) { var crawlerXSLFileValue = new SPFieldUrlValue { Url = typedDefinition.CrawlerXSLFileURL }; if (!string.IsNullOrEmpty(typedDefinition.CrawlerXSLFileDescription)) crawlerXSLFileValue.Description = typedDefinition.CrawlerXSLFileDescription; fileProperties["CrawlerXSLFile"] = crawlerXSLFileValue.ToString(); } if (!string.IsNullOrEmpty(typedDefinition.CompatibleManagedProperties)) fileProperties["CompatibleManagedProperties"] = typedDefinition.CompatibleManagedProperties; if (typedDefinition.CompatibleSearchDataTypes.Count > 0) { var multiChoiceValue = new SPFieldMultiChoiceValue(); foreach (var value in typedDefinition.CompatibleSearchDataTypes) multiChoiceValue.Add(value); fileProperties["CompatibleSearchDataTypes"] = multiChoiceValue.ToString(); } }
protected override void MapProperties(object modelHost, Hashtable fileProperties, ContentPageDefinitionBase definition) { base.MapProperties(modelHost, fileProperties, definition); var typedTemplateModel = definition.WithAssertAndCast <ItemControlTemplateDefinitionBase>("model", value => value.RequireNotNull()); if (typedTemplateModel.TargetControlTypes.Count > 0) { var multiChoiceValue = new SPFieldMultiChoiceValue(); foreach (var value in typedTemplateModel.TargetControlTypes) { multiChoiceValue.Add(value); } fileProperties["TargetControlType"] = multiChoiceValue.ToString(); } if (!string.IsNullOrEmpty(typedTemplateModel.PreviewURL)) { var htmlPreviewValue = new SPFieldUrlValue { Url = typedTemplateModel.PreviewURL }; if (!string.IsNullOrEmpty(typedTemplateModel.PreviewDescription)) { htmlPreviewValue.Description = typedTemplateModel.PreviewDescription; } fileProperties["HtmlDesignPreviewUrl"] = htmlPreviewValue.ToString(); } }
protected override void MapProperties(object modelHost, Hashtable fileProperties, ContentPageDefinitionBase definition) { base.MapProperties(modelHost, fileProperties, definition); var typedTemplateModel = definition.WithAssertAndCast<ItemControlTemplateDefinitionBase>("model", value => value.RequireNotNull()); if (typedTemplateModel.TargetControlTypes.Count > 0) { var multiChoiceValue = new SPFieldMultiChoiceValue(); foreach (var value in typedTemplateModel.TargetControlTypes) multiChoiceValue.Add(value); fileProperties["TargetControlType"] = multiChoiceValue.ToString(); } if (!string.IsNullOrEmpty(typedTemplateModel.PreviewURL)) { var htmlPreviewValue = new SPFieldUrlValue { Url = typedTemplateModel.PreviewURL }; if (!string.IsNullOrEmpty(typedTemplateModel.PreviewDescription)) htmlPreviewValue.Description = typedTemplateModel.PreviewDescription; fileProperties["HtmlDesignPreviewUrl"] = htmlPreviewValue.ToString(); } }
private static SPFieldMultiChoiceValue CreateMultiValue(string input) { SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue(); values.Add(input); return(values); }
public static string GetStringValue(this SPListItem item, string fieldname) { if (item[fieldname] == null || string.IsNullOrEmpty(item[fieldname].ToString().Trim())) { return(string.Empty); } SPField field = item.Fields.GetField(fieldname); string ReturnValue; switch (field.Type) { case SPFieldType.Lookup: if (((SPFieldLookup)field).AllowMultipleValues == false) { SPFieldLookupValue lookup = new SPFieldLookupValue(item[fieldname].ToString()); ReturnValue = lookup.LookupValue; } else { SPFieldLookupValueCollection lookup = new SPFieldLookupValueCollection(item[fieldname].ToString()); ReturnValue = ""; foreach (SPFieldLookupValue v in lookup) { ReturnValue += v.LookupValue + ";"; } ReturnValue.TrimEnd(';'); } break; case SPFieldType.User: if (((SPFieldUser)field).AllowMultipleValues == false) { SPFieldUserValue users = new SPFieldUserValue(item.Web, item[fieldname].ToString()); ReturnValue = users.User.Name; } else { SPFieldUserValueCollection users = new SPFieldUserValueCollection(item.Web, item[fieldname].ToString()); ReturnValue = users[0].User.Name; } break; case SPFieldType.MultiChoice: SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue(item[fieldname].ToString()); ReturnValue = ""; for (int i = 0; i < values.Count; i++) { ReturnValue += values[i].ToString() + ";"; } ReturnValue.TrimEnd(';'); break; default: ReturnValue = item[fieldname].ToString().Trim(); break; } return(ReturnValue); }
/// <summary> /// For the specified object, attempt to create a SharePoint Field Values Hashtable based on the object's contents. /// </summary> /// <param name="properties"></param> /// <returns></returns> public static Hashtable GetFieldValuesHashtableFromPropertyObject(object properties) { Hashtable htProperties = null; if (properties != null && properties != Null.Value && properties is ObjectInstance) { var propertiesInstance = properties as ObjectInstance; htProperties = new Hashtable(); foreach (var property in propertiesInstance.Properties) { var propertyName = property.Name.ToString(CultureInfo.InvariantCulture); //TODO: Convert to appropriate FieldValues object propertyValue; if (property.Value is ObjectInstance && (property.Value as ObjectInstance).HasProperty("type")) { var fieldValue = (property.Value as ObjectInstance); var type = fieldValue.GetPropertyValue("type"); switch (type.ToString()) { case "Lookup": propertyValue = new SPFieldLookupValue(fieldValue.GetPropertyValue("fieldValue").ToString()); break; case "MultiChoice": propertyValue = new SPFieldMultiChoiceValue(fieldValue.GetPropertyValue("fieldValue").ToString()); break; case "MultiChoiceColumn": propertyValue = new SPFieldMultiColumnValue(fieldValue.GetPropertyValue("fieldValue").ToString()); break; case "Url": propertyValue = new SPFieldUrlValue(fieldValue.GetPropertyValue("fieldValue").ToString()); break; case "User": //TODO: Maybe get another web? propertyValue = new SPFieldUserValue(SPBaristaContext.Current.Web, fieldValue.GetPropertyValue("fieldValue").ToString()); break; default: propertyValue = fieldValue.ToString(); break; } } else { propertyValue = property.Value.ToString(); } htProperties.Add(propertyName, propertyValue); } } return(htProperties); }
private IEnumerable<string> GetValues(SPFieldMultiChoiceValue value) { var strings = new string[value.Count]; for (int i = 0; i < value.Count; i++) { strings[i] = value[i]; } return strings; }
/// <summary> /// Formats the value for SpFieldChoice /// </summary> /// <param name="input">List of values to insert</param> /// <returns></returns> public SPFieldMultiChoiceValue FormatValuesForMultiChoice(List <string> input) { var multiChoiceValue = new SPFieldMultiChoiceValue(); foreach (string s in input) { multiChoiceValue.Add(s); } return(multiChoiceValue); }
private void OnMultiChoiceValueChanged(object sender, string fieldName) { SPFieldMultiChoiceValue collection = new SPFieldMultiChoiceValue(); foreach (string item in (IEnumerable)sender) { collection.Add(item); } this[fieldName] = collection.ToString(); }
public static void ReadFrom(this SPFieldMultiChoiceValue choiceValue, string[] values) { if (values != null) { for (int x = 0; x < values.Length; x++) { choiceValue.Add(values[x]); } } }
public static int ToType(SPFieldMultiChoiceValue value) { var list = new List <string>(); for (int i = 0; i < value.Count; i++) { list.Add(value[i]); } return(ToType(list.ToArray())); }
public static List<string> GetUIVersion(this SPListItem item) { var v = new SPFieldMultiChoiceValue(item["UIVersion"] as string); var result = new List<string>(); for (var i = 0; i < v.Count; i++) result.Add(v[i]); return result; }
public SPFieldMultiChoiceValueInstance(ObjectInstance prototype, SPFieldMultiChoiceValue fieldMultiChoiceValue) : this(prototype) { if (fieldMultiChoiceValue == null) { throw new ArgumentNullException("fieldMultiChoiceValue"); } m_fieldMultiChoiceValue = fieldMultiChoiceValue; }
public static List <string> ToValuesFromMultiChoice(this SPListItem item, string fieldName) { var output = new List <string>(); var multiChoiceValue = new SPFieldMultiChoiceValue(item[fieldName].ToString()); for (int i = 0; i < multiChoiceValue.Count; i++) { output.Add(multiChoiceValue[i]); } return(output); }
internal static void Set_SPFieldMultiChoiceValue(SPListItem item, string col, System.Collections.ArrayList komponenty) { SPFieldMultiChoiceValue fmcv = new SPFieldMultiChoiceValue(); foreach (string s in komponenty) { fmcv.Add(s); } item[col] = fmcv; }
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) { item = workflowProperties.Item; Debug.WriteLine("wfGFRWF:{" + workflowProperties.WorkflowId + "} initiated"); startTime = DateTime.Now; selTypyKlientow = new SPFieldMultiChoiceValue(BLL.Tools.Get_Text(item, "enumTypKlienta")); //selSerwisy = BLL.Tools.Get_LookupValueColection(item, "selSewisy"); colMaskaSerwisu = new SPFieldMultiChoiceValue(BLL.Tools.Get_Text(item, "colMaskaSerwisu")); okresId = BLL.Tools.Get_LookupId(item, "selOkres"); }
public static List <string> GetUIVersion(this SPListItem item) { var v = new SPFieldMultiChoiceValue(item["UIVersion"] as string); var result = new List <string>(); for (var i = 0; i < v.Count; i++) { result.Add(v[i]); } return(result); }
public object ToSpValue(object value) { if (value == null) return null; var strings = ((IEnumerable<string>) value).ToList(); var fieldValues = new SPFieldMultiChoiceValue(); strings.ForEach(s => fieldValues.Add(s)); return fieldValues; }
public static bool Has_SelectedOptions(SPListItem item, string col) { SPFieldMultiChoiceValue v = Get_MutichoiceValue(item, col); if (v.Count > 0) { return(true); } else { return(false); } }
public static string[] ToArray(this SPFieldMultiChoiceValue choiceValue) { List <string> list = new List <string>(); if (choiceValue != null) { for (int x = 0; x < choiceValue.Count; x++) { list.Add(choiceValue[x]); } } return(list.ToArray()); }
public static string[] GetValueFromMultiChoice(object oValue) { string[] value = null; if (oValue != null) { SPFieldMultiChoiceValue fieldValue = new SPFieldMultiChoiceValue(oValue.ToString()); value = new string[fieldValue.Count]; for (int i = 0; i < fieldValue.Count; i++) value[i] = fieldValue[i]; } return value; }
protected virtual IList <string> GetMultiChoiceFieldValueInternal(string fieldName) { Collection <string> collection = new Collection <string>(); object value = this[fieldName]; if (value != null) { SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue(value.ToString()); for (int i = 0; i < values.Count; i++) { collection.Add(values[i]); } } return(collection); }
protected override void MapProperties(object modelHost, System.Collections.Hashtable fileProperties, ContentPageDefinitionBase definition) { var typedTemplateModel = definition.WithAssertAndCast<MasterPagePreviewDefinition>("model", value => value.RequireNotNull()); fileProperties[BuiltInInternalFieldNames.ContentTypeId] = BuiltInContentTypeId.MasterPagePreview; if (typedTemplateModel.UIVersion.Count > 0) { var value = new SPFieldMultiChoiceValue(); foreach (var v in typedTemplateModel.UIVersion) value.Add(v); fileProperties["UIVersion"] = value.ToString(); } }
public void BinData() { DataTable dtdata = new DataTable(); dtdata.Columns.Add("ID", typeof(int)); dtdata.Columns.Add("Title", typeof(string)); dtdata.Columns.Add("Description", typeof(string)); dtdata.Columns.Add("Category", typeof(string)); dtdata.Columns.Add("Created", typeof(string)); using (SPSite objSPSite = new SPSite(SPContext.Current.Web.Url)) { using (SPWeb objSPWeb = objSPSite.OpenWeb()) { SPList objSPList = objSPWeb.Lists.TryGetList("Cygnet"); SPListItemCollection listItems = objSPList.GetItems(); foreach (SPItem item in listItems) { DataTable dt1 = new DataTable(); SPFieldMultiChoiceValue choices = new SPFieldMultiChoiceValue(); SPQuery oQuery = new SPQuery(); dt1.Columns.Add("CategoryName", typeof(string)); dt1.Columns.Add("CategoryValue", typeof(string)); choices = new SPFieldMultiChoiceValue(Convert.ToString(item["Category"])); for (int i = 0; i < choices.Count; i++) { dt1.Rows.Add(choices[i], choices[i]); } ddlcategory.Items.Clear(); ddlcategory.DataSource = dt1; ddlcategory.DataTextField = "CategoryName"; ddlcategory.DataValueField = "CategoryValue"; ddlcategory.DataBind(); //grid DataRow dr = dtdata.NewRow(); dr["ID"] = Convert.ToInt16(item["ID"]); dr["Title"] = Convert.ToString(item["Title"]); dr["Description"] = Convert.ToString(item["Description"]); dr["Category"] = Convert.ToString(item["Category"]); dtdata.Rows.Add(dr); } gvListData.DataSource = dtdata; gvListData.DataBind(); } } }
public static string[] GetChoices(this SPListItem listItem, string fieldName) { var value = listItem[fieldName]; if (value == null) { return(new string[0]); } var choices = new SPFieldMultiChoiceValue(value.ToString()); var result = new List <string>(); for (var i = 0; i < choices.Count; i++) { result.Add(choices[i]); } return(result.ToArray()); }
protected override void MapProperties(object modelHost, System.Collections.Hashtable fileProperties, ContentPageDefinitionBase definition) { var typedTemplateModel = definition.WithAssertAndCast <MasterPagePreviewDefinition>("model", value => value.RequireNotNull()); fileProperties[BuiltInInternalFieldNames.ContentTypeId] = BuiltInContentTypeId.MasterPagePreview; if (typedTemplateModel.UIVersion.Count > 0) { var value = new SPFieldMultiChoiceValue(); foreach (var v in typedTemplateModel.UIVersion) { value.Add(v); } fileProperties["UIVersion"] = value.ToString(); } }
protected override void MapProperties(object modelHost, Hashtable fileProperties, ContentPageDefinitionBase definition) { var typedDefinition = definition.WithAssertAndCast<WebPartGalleryFileDefinition>("model", value => value.RequireNotNull()); if (!string.IsNullOrEmpty(typedDefinition.Group)) fileProperties["Group"] = typedDefinition.Group; if (!string.IsNullOrEmpty(typedDefinition.Description)) fileProperties["WebPartDescription"] = typedDefinition.Description; var recSettingsValue = new SPFieldMultiChoiceValue(); foreach (var value in typedDefinition.RecommendationSettings) recSettingsValue.Add(value); fileProperties["QuickAddGroups"] = recSettingsValue.ToString(); }
private static Array Refine_Klienci_MaskaSerwisu(Array klienci, SPFieldMultiChoiceValue maski) { ArrayList results = new ArrayList(); foreach (SPListItem klientItem in klienci) { for (int i = 0; i < maski.Count; i++) { string s = maski[i]; if (BLL.Tools.Has_Service(klientItem, s, "selSewisy")) { results.Add(klientItem); Debug.WriteLine(BLL.Tools.Get_Text(klientItem, "_NazwaPrezentowana") + " - added"); break; } } } return(results.ToArray()); }
public static void Execute(SPListItem item, Microsoft.SharePoint.SPWeb web, out string message) { StringBuilder sb = new StringBuilder(); //sprawdź parametry wywołania SPFieldMultiChoiceValue wt = new SPFieldMultiChoiceValue(item["enumTypKlienta"].ToString()); SPList list = web.Lists.TryGetList(targetList); for (int i = 0; i < wt.Count; i++) { switch (wt[i]) { case "KPiR": Import_KPiR(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; case "KSH": Import_KSH(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; case "Osoba fizyczna": Import_OsobaFizyczna(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; case "Firma": Import_Firma(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; default: break; } } message = String.Format(@"<ul>{0}</ul>", sb.ToString()); }
protected override void MapProperties(object modelHost, Hashtable fileProperties, ContentPageDefinitionBase definition) { base.MapProperties(modelHost, fileProperties, definition); var typedDefinition = definition.WithAssertAndCast <FilterDisplayTemplateDefinition>("model", value => value.RequireNotNull()); fileProperties[BuiltInInternalFieldNames.ContentTypeId] = "0x0101002039C03B61C64EC4A04F5361F38510660400F643FF79F6BD764F8A469B6F153396EE"; if (!string.IsNullOrEmpty(typedDefinition.CrawlerXSLFileURL)) { var crawlerXSLFileValue = new SPFieldUrlValue { Url = typedDefinition.CrawlerXSLFileURL }; if (!string.IsNullOrEmpty(typedDefinition.CrawlerXSLFileDescription)) { crawlerXSLFileValue.Description = typedDefinition.CrawlerXSLFileDescription; } fileProperties["CrawlerXSLFile"] = crawlerXSLFileValue.ToString(); } if (!string.IsNullOrEmpty(typedDefinition.CompatibleManagedProperties)) { fileProperties["CompatibleManagedProperties"] = typedDefinition.CompatibleManagedProperties; } if (typedDefinition.CompatibleSearchDataTypes.Count > 0) { var multiChoiceValue = new SPFieldMultiChoiceValue(); foreach (var value in typedDefinition.CompatibleSearchDataTypes) { multiChoiceValue.Add(value); } fileProperties["CompatibleSearchDataTypes"] = multiChoiceValue.ToString(); } }
public static bool Has_ServiceMask(SPListItem item, string mask) { string col = "colMaskaSerwisu"; if (mask.EndsWith("*")) { mask = mask.Substring(0, mask.Length - 1); } SPFieldMultiChoiceValue choices = item[col] != null ? new SPFieldMultiChoiceValue(item[col].ToString()) : null; for (int i = 0; i < choices.Count; i++) { string s = choices[i]; if (s.StartsWith(mask)) { return(true); } } return(false); }
internal static void Execute(Microsoft.SharePoint.SPItemEventProperties properties, Microsoft.SharePoint.SPWeb web, out string message) { StringBuilder sb = new StringBuilder(); //sprawdź parametry wywołania SPFieldMultiChoiceValue wt = new SPFieldMultiChoiceValue(properties.ListItem["enumTypKlienta"].ToString()); SPList list = web.Lists.TryGetList(targetList); for (int i = 0; i < wt.Count; i++) { switch (wt[i]) { case "KPiR": Import_KPiR(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; case "KSH": Import_KSH(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; case "Osoba fizyczna": Import_OsobaFizyczna(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; case "Firma": Import_Firma(web, list); sb.AppendFormat(@"<li>{1} Import {0} zakończony</li>", wt[i], DateTime.Now.ToString()); break; default: break; } } message = String.Format(@"<ul>{0}</ul>", sb.ToString()); }
protected override void MapProperties(object modelHost, Hashtable fileProperties, ContentPageDefinitionBase definition) { var typedDefinition = definition.WithAssertAndCast <WebPartGalleryFileDefinition>("model", value => value.RequireNotNull()); if (!string.IsNullOrEmpty(typedDefinition.Group)) { fileProperties["Group"] = typedDefinition.Group; } if (!string.IsNullOrEmpty(typedDefinition.Description)) { fileProperties["WebPartDescription"] = typedDefinition.Description; } var recSettingsValue = new SPFieldMultiChoiceValue(); foreach (var value in typedDefinition.RecommendationSettings) { recSettingsValue.Add(value); } fileProperties["QuickAddGroups"] = recSettingsValue.ToString(); }
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) { item = workflowProperties.Item; Debug.WriteLine("wfGFRWF:{" + workflowProperties.WorkflowId + "} initiated"); startTime = DateTime.Now; selTypyKlientow = new SPFieldMultiChoiceValue(BLL.Tools.Get_Text(item, "enumTypKlienta")); //selSerwisy = BLL.Tools.Get_LookupValueColection(item, "selSewisy"); colMaskaSerwisu = new SPFieldMultiChoiceValue(BLL.Tools.Get_Text(item, "colMaskaSerwisu")); okresId = BLL.Tools.Get_LookupId(item, "selOkres"); }
/// <summary> /// Generowanie formatek rozliczeniowych dla wszystkich aktywnych klientów /// </summary> /// <param name="properties"></param> internal static void Execute_GenFormRozl(SPItemEventProperties properties, SPWeb web) { Debug.WriteLine("Execute_GenFromRozl"); StringBuilder msg = new StringBuilder(); StringBuilder sb = new StringBuilder(); //sprawdź parametry wywołania SPFieldMultiChoiceValue wt = new SPFieldMultiChoiceValue(properties.ListItem["enumTypKlienta"].ToString()); int okresId = new SPFieldLookupValue(properties.ListItem["selOkres"].ToString()).LookupId; SPListItem item = properties.ListItem; for (int i = 0; i < wt.Count; i++) { if (okresId > 0) { string typKlienta = wt[i]; Array klienci = tabKlienci.Get_AktywniKlienci_Serwis(web, typKlienta); Debug.WriteLine("Wybrano klientów: " + klienci.Length.ToString()); bool createKK = Get_Flag(item, "colDodajKartyKontrolne"); //sprawdź czy jest ograniczona lista serwisów if (item["selSewisy"] != null && BLL.Tools.Get_LookupValueColection(item, "selSewisy").Count > 0) { SPFieldLookupValueCollection serwisy = BLL.Tools.Get_LookupValueColection(item, "selSewisy"); klienci = Refine_Klienci(klienci, serwisy); Debug.WriteLine("Ograniczono listę do: " + klienci.Length.ToString()); foreach (SPListItem klient in klienci) { Debug.WriteLine("klientId=" + klient.ID.ToString()); foreach (SPFieldLookupValue v in serwisy) { switch (v.LookupValue) { case "ZUS-D": case "ZUS-D+C": case "ZUS-M": case "ZUS-M+C": case "ZUS-ZD": case "ZUS-PRAC": ZUS_Forms.CreateAll(web, klienci, okresId, createKK); break; case "PDS-M": case "PDS-KW": PDS_Forms.CreateAll(web, klienci, okresId, createKK); break; case "PDW-M": case "PDW-KW": //PDW_Forms.Create(web, klienci, okresId, createKK); break; case "PD-M": case "PD-KW": PD_Forms.CreateAll(web, klienci, okresId, createKK); break; case "VAT-M": case "VAT-KW": VAT_Forms.CreateAll(web, klienci, okresId, createKK); break; case "RBR": BR_Forms.CreateAll(web, klienci, okresId, createKK); break; case "POW-Dok": case "POW-WBank": Reminder_Forms.CreateAll(web, klienci, okresId); break; default: break; } } } } else { switch (typKlienta) { case "KPiR": ZUS_Forms.CreateAll(web, klienci, okresId, createKK); PD_Forms.CreateAll(web, klienci, okresId, createKK); //PDW_Forms.Create(web, klienci, okresId, createKK); VAT_Forms.CreateAll(web, klienci, okresId, createKK); BR_Forms.CreateAll(web, klienci, okresId, createKK); Reminder_Forms.CreateAll(web, klienci, okresId); break; case "KSH": ZUS_Forms.CreateAll(web, klienci, okresId, createKK); PDS_Forms.CreateAll(web, klienci, okresId, createKK); VAT_Forms.CreateAll(web, klienci, okresId, createKK); BR_Forms.CreateAll(web, klienci, okresId, createKK); Reminder_Forms.CreateAll(web, klienci, okresId); break; case "Firma": PDS_Forms.CreateAll(web, klienci, okresId, createKK); break; case "Osoba fizyczna": ZUS_Forms.CreateAll(web, klienci, okresId, createKK); PD_Forms.CreateAll(web, klienci, okresId, createKK); //PDW_Forms.Create(web, klienci, okresId, createKK); VAT_Forms.CreateAll(web, klienci, okresId, createKK); break; default: break; } } //informacja dla operatora foreach (SPListItem klient in klienci) { msg.AppendFormat(@"<li>klient# {0} {1}</li>", klient.ID.ToString(), BLL.Tools.Get_Text(klient, "_NazwaPrezentowana")); } } } // info o zakończeniu procesu string bodyHTML = string.Empty; if (msg.Length > 0) { bodyHTML = string.Format(@"<ul>{0}</ul>", msg.ToString()); } string subject = string.Format(@"Generowanie formatek rozliczeniowych dla klientów typu {0}", wt.ToString()); SPEmail.EmailGenerator.SendProcessEndConfirmationMail(subject, bodyHTML, web, item); }
private static SPFieldMultiChoiceValue CreateMultiValue(string input) { SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue(); values.Add(input); return values; }
private static SPFieldMultiChoiceValue GetSPListItemsFromCheckBoxes(CheckBoxList inputCheckBoxList) { SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue(); foreach (ListItem boxItem in inputCheckBoxList.Items) if (boxItem.Selected == true) values.Add(boxItem.Value); return values; }
private static object GetDrivingPaths(string dPaths) { var value = new SPFieldMultiChoiceValue(); if (!String.IsNullOrEmpty(dPaths)) foreach (string dPath in dPaths.Split(',')) value.Add(dPath); return value; }
private void DeployPage(object modelHost, SPList list, SPFolder folder, MasterPageDefinition definition) { var web = list.ParentWeb; var targetPage = GetCurrentObject(folder, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = targetPage == null ? null : targetPage.File, ObjectType = typeof(SPFile), ObjectDefinition = definition, ModelHost = modelHost }); if (targetPage == null) targetPage = CreateObject(modelHost, folder, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = targetPage.File, ObjectType = typeof(SPFile), ObjectDefinition = definition, ModelHost = modelHost }); ModuleFileModelHandler.WithSafeFileOperation(list, folder, targetPage.Url, GetSafePageFileName(definition), definition.Content, definition.NeedOverride, null, afterFile => { var pageItem = afterFile.Properties; //pageItem[BuiltInInternalFieldNames.Title] = definition.Title; pageItem["vti_title"] = definition.Title; pageItem["MasterPageDescription"] = definition.Description; pageItem[BuiltInInternalFieldNames.ContentTypeId] = BuiltInContentTypeId.MasterPage; if (definition.UIVersion.Count > 0) { var value = new SPFieldMultiChoiceValue(); foreach (var v in definition.UIVersion) value.Add(v); pageItem["UIVersion"] = value.ToString(); } pageItem["DefaultCssFile"] = definition.DefaultCSSFile; //pageItem.Update(); //pageItem.SystemUpdate(); }); }
public override void DeployModel(object modelHost, DefinitionBase model) { base.DeployModel(modelHost, model); var listModelHost = modelHost.WithAssertAndCast<FolderModelHost>("modelHost", value => value.RequireNotNull()); var definition = model.WithAssertAndCast<FilterDisplayTemplateDefinition>("model", value => value.RequireNotNull()); var folder = listModelHost.CurrentLibraryFolder; var spObject = GetCurrentObject(folder, definition); var file = spObject.File; var assert = ServiceFactory.AssertService .NewAssert(definition, spObject); #region crawler xslt file if (!string.IsNullOrEmpty(definition.CrawlerXSLFileURL)) { assert.ShouldBeEqual((p, s, d) => { var srcProp = s.GetExpressionValue(m => m.CrawlerXSLFileURL); var isValid = d.GetCrawlerXSLFile().Url == s.CrawlerXSLFileURL; return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, Dst = null, IsValid = isValid }; }); } else { assert.SkipProperty(m => m.CrawlerXSLFileURL, "PreviewURL is NULL. Skipping"); } if (!string.IsNullOrEmpty(definition.CrawlerXSLFileDescription)) { assert.ShouldBeEqual((p, s, d) => { var srcProp = s.GetExpressionValue(m => m.CrawlerXSLFileDescription); var isValid = d.GetCrawlerXSLFile().Description == s.CrawlerXSLFileDescription; return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, Dst = null, IsValid = isValid }; }); } else { assert.SkipProperty(m => m.CrawlerXSLFileDescription, "PreviewDescription is NULL. Skipping"); } #endregion if (!string.IsNullOrEmpty(definition.CompatibleManagedProperties)) assert.ShouldBeEqual(m => m.CompatibleManagedProperties, o => o.GetCompatibleManagedProperties()); else assert.SkipProperty(m => m.CompatibleManagedProperties); if (definition.CompatibleSearchDataTypes.Count > 0) { assert.ShouldBeEqual((p, s, d) => { var srcProp = s.GetExpressionValue(m => m.CompatibleSearchDataTypes); var isValid = true; var targetControlTypeValue = new SPFieldMultiChoiceValue(d["CompatibleSearchDataTypes"].ToString()); var targetControlTypeValues = new List<string>(); for (var i = 0; i < targetControlTypeValue.Count; i++) targetControlTypeValues.Add(targetControlTypeValue[i].ToUpper()); foreach (var v in s.CompatibleSearchDataTypes) { if (!targetControlTypeValues.Contains(v.ToUpper())) isValid = false; } return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, Dst = null, IsValid = isValid }; }); } else { assert.SkipProperty(m => m.CompatibleSearchDataTypes, "CompatibleSearchDataTypes count is 0. Skipping"); } assert.ShouldBeEqual((p, s, d) => { var srcProp = s.GetExpressionValue(m => m.Content); //var dstProp = d.GetExpressionValue(ct => ct.GetId()); var isContentValid = false; var srcStringContent = Encoding.UTF8.GetString(s.Content); var dstStringContent = Encoding.UTF8.GetString(file.GetContent()); isContentValid = dstStringContent.Contains(srcStringContent); return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, // Dst = dstProp, IsValid = isContentValid }; }); }
public override void DeployModel(object modelHost, DefinitionBase model) { base.DeployModel(modelHost, model); var listModelHost = modelHost.WithAssertAndCast<FolderModelHost>("modelHost", value => value.RequireNotNull()); var definition = model.WithAssertAndCast<ItemControlTemplateDefinitionBase>("model", value => value.RequireNotNull()); var folder = listModelHost.CurrentLibraryFolder; var spObject = GetCurrentObject(folder, definition); var assert = ServiceFactory.AssertService .NewAssert(definition, spObject) .ShouldNotBeNull(spObject); #region preview field if (!string.IsNullOrEmpty(definition.PreviewURL)) { assert.ShouldBeEqual((p, s, d) => { var isValid = false; var srcProp = s.GetExpressionValue(m => m.PreviewURL); var previewValue = d.GetPreviewURL(); isValid = (previewValue != null) && (d.GetPreviewURL().Url == s.PreviewURL); return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, Dst = null, IsValid = isValid }; }); } else { assert.SkipProperty(m => m.PreviewURL, "PreviewURL is NULL. Skipping"); } if (!string.IsNullOrEmpty(definition.PreviewDescription)) { assert.ShouldBeEqual((p, s, d) => { var isValid = false; var srcProp = s.GetExpressionValue(m => m.PreviewDescription); var previewValue = d.GetPreviewURL(); isValid = (previewValue != null) && (d.GetPreviewURL().Description == s.PreviewDescription); return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, Dst = null, IsValid = isValid }; }); } else { assert.SkipProperty(m => m.PreviewDescription, "PreviewDescription is NULL. Skipping"); } #endregion #region TargetControlTypes if (definition.TargetControlTypes.Count > 0) { assert.ShouldBeEqual((p, s, d) => { var srcProp = s.GetExpressionValue(m => m.TargetControlTypes); var isValid = true; var targetControlTypeValue = new SPFieldMultiChoiceValue(d["TargetControlType"].ToString()); var targetControlTypeValues = new List<string>(); for (var i = 0; i < targetControlTypeValue.Count; i++) targetControlTypeValues.Add(targetControlTypeValue[i].ToUpper()); foreach (var v in s.TargetControlTypes) { if (!targetControlTypeValues.Contains(v.ToUpper())) isValid = false; } return new PropertyValidationResult { Tag = p.Tag, Src = srcProp, Dst = null, IsValid = isValid }; }); } else { assert.SkipProperty(m => m.TargetControlTypes, "TargetControlTypes count is 0. Skipping"); } #endregion }
private void SetCheckBoxValues(CheckBoxList checkBoxList, object item) { if (null == item) return; SPFieldMultiChoiceValue typedValue = new SPFieldMultiChoiceValue(item.ToString()); for (int i = 0; i < typedValue.Count; i++) { checkBoxList.Items.FindByText(typedValue[i]).Selected = true; } }
private static void SetFieldValue(SPListItem item, SPFieldValue fieldValue) { int num; switch (fieldValue.Type) { case "Text": item[fieldValue.InternalName] = fieldValue.value; break; case "Note": item[fieldValue.InternalName] = fieldValue.value; break; case "Number": item[fieldValue.InternalName] = decimal.Parse(fieldValue.value); break; case "DateTime": item[fieldValue.InternalName] = Convert.ToDateTime(fieldValue.value); break; case "Lookup": item[fieldValue.InternalName] = new SPFieldLookupValue(int.Parse(fieldValue.value), ""); break; case "LookupMulti": { string[] strArray = fieldValue.value.Split(new char[] { ',' }); SPFieldLookupValueCollection values = new SPFieldLookupValueCollection(); num = 0; while (num < strArray.Length) { values.Add(new SPFieldLookupValue(int.Parse(strArray[num]), "")); num++; } item[fieldValue.InternalName] = values; break; } case "RelatedCustomLookupQuery": item[fieldValue.InternalName] = new SPFieldLookupValue(int.Parse(fieldValue.value), ""); break; case "CustomComputedField": item[fieldValue.InternalName] = new SPFieldLookupValue(int.Parse(fieldValue.value), ""); break; case "Choice": item[fieldValue.InternalName] = fieldValue.value; break; case "MultiChoice": { string[] strArray2 = fieldValue.value.Split(new char[] { ',' }); SPFieldMultiChoiceValue value2 = new SPFieldMultiChoiceValue(); for (num = 0; num < strArray2.Length; num++) { value2.Add(strArray2[num]); } item[fieldValue.InternalName] = value2; break; } case "Boolean": item[fieldValue.InternalName] = fieldValue.value; break; } }
/// <summary> /// Generowanie formatek rozliczeniowych dla wszystkich aktywnych klientów /// </summary> /// <param name="properties"></param> internal static void Execute_GenFormRozl(SPItemEventProperties properties, SPWeb web) { StringBuilder msg = new StringBuilder(); StringBuilder sb = new StringBuilder(); //sprawdź parametry wywołania SPFieldMultiChoiceValue wt = new SPFieldMultiChoiceValue(properties.ListItem["enumTypKlienta"].ToString()); int okresId = new SPFieldLookupValue(properties.ListItem["selOkres"].ToString()).LookupId; SPListItem item = properties.ListItem; for (int i = 0; i < wt.Count; i++) { if (okresId > 0) { string typKlienta = wt[i]; Array klienci = tabKlienci.Get_AktywniKlienci_Serwis(web, typKlienta); bool createKK = Get_Flag(item, "colDodajKartyKontrolne"); switch (typKlienta) { case "KPiR": ZUS_Forms.Create(web, klienci, okresId, createKK); PD_Forms.Create(web, klienci, okresId, createKK); VAT_Forms.Create(web, klienci, okresId, createKK); BR_Forms.Create(web, klienci, okresId); Reminder_Forms.Create(web, klienci, okresId); break; case "KSH": ZUS_Forms.Create(web, klienci, okresId, createKK); PDS_Forms.Create(web, klienci, okresId, createKK); VAT_Forms.Create(web, klienci, okresId, createKK); BR_Forms.Create(web, klienci, okresId); Reminder_Forms.Create(web, klienci, okresId); break; case "Firma": PDS_Forms.Create(web, klienci, okresId, false); break; case "Osoba fizyczna": ZUS_Forms.Create(web, klienci, okresId, false); PD_Forms.Create(web, klienci, okresId, false); VAT_Forms.Create(web, klienci, okresId, false); break; default: break; } //informacja dla operatora foreach (SPListItem klient in klienci) { msg.AppendFormat(@"<li>klient# {0} {1}</li>", klient.ID.ToString(), BLL.Tools.Get_Text(klient, "_NazwaPrezentowana")); } } } // info o zakończeniu procesu string bodyHTML = string.Empty; if (msg.Length > 0) { bodyHTML = string.Format(@"<ul>{0}</ul>", msg.ToString()); } string subject = string.Format(@"Generowanie formatek rozliczeniowych dla klientów typu {0}", wt.ToString()); SPEmail.EmailGenerator.SendProcessEndConfirmationMail(subject, bodyHTML, web, item); }
private void Display(string mode) { SPListItem item = GetItem(IDP); try { string workflowStatus = (item["Step"] != null ? item["Step"].ToString() : string.Empty); string approvalStatus = (item["ApprovalStatus"] != null ? item["ApprovalStatus"].ToString() : string.Empty); if (approvalStatus.Equals("Approved")) mode = "display"; ViewState["Status"] = workflowStatus; ltrWorkflow.Text = workflowStatus; ltrRequestCode.Text = item["Title"].ToString(); ltrDate.Text = Convert.ToDateTime(item["Tanggal"].ToString()).ToString("dd-MMM-yyyy HH:mm"); txtAlasanPerubahan.Text = (item["AlasanPerubahan"] != null ? item["AlasanPerubahan"].ToString() : string.Empty); ltrAlasanPerubahan.Text = txtAlasanPerubahan.Text; rdPerubahanModal.SelectedValue = (Convert.ToBoolean(item["PerubahanModal"]) ? "Yes" : "No"); rdPerubahanNama.SelectedValue = (Convert.ToBoolean(item["PerubahanNamaDanTempat"]) ? "Yes" : "No"); rdPerubahanModal.Enabled = false; rdPerubahanNama.Enabled = false; imgbtnNamaCompany.Visible = false; if (item["BNRI"] != null) { bool stsBNRI = Convert.ToBoolean(item["BNRI"]); rbBNRI.SelectedValue = (stsBNRI ? "Yes" : "No"); ltrBNRI.Text = rbBNRI.SelectedItem.Text; } if (item["JenisPerubahan"] != null) { string rawValue = item["JenisPerubahan"].ToString(); SPFieldMultiChoiceValue itemValue = new SPFieldMultiChoiceValue(rawValue); for (int i = 0; i < itemValue.Count; i++) { chkBoxListJenisPerubahan.Items.FindByText(itemValue[i]).Selected = true; } } ddlMataUang.SelectedValue = new SPFieldLookupValue(item["MataUang"].ToString()).LookupId.ToString(); ltrMataUang.Text = ddlMataUang.SelectedItem.Text; txtModalDasarNominalSemula.Text = (item["ModalDasar"] != null ? Convert.ToDouble(item["ModalDasar"]).ToString("#,##0") : "0"); ltrtxtModalDasarNominalSemula.Text = txtModalDasarNominalSemula.Text; txtModalSetorNominalSemula.Text = (item["ModalSetor"] != null ? Convert.ToDouble(item["ModalSetor"]).ToString("#,##0") : "0"); ltrtxtModalSetorNominalSemula.Text = txtModalSetorNominalSemula.Text; txtNominalMataUang.Text = (item["Nominal"] != null ? Convert.ToDouble(item["Nominal"]).ToString("#,##0") : "1"); ltrNominalMataUang.Text = txtNominalMataUang.Text; txtModalDasarNominalMenjadi.Text = (item["NominalModalDasar"] != null ? Convert.ToDouble(item["NominalModalDasar"]).ToString("#,##0") : "0"); ltrtxtModalDasarNominalMenjadi.Text = txtModalDasarNominalMenjadi.Text; txtModalSetorNominalMenjadi.Text = (item["NominalModalSetor"] != null ? Convert.ToDouble(item["NominalModalSetor"]).ToString("#,##0") : "0"); ltrtxtModalSetorNominalMenjadi.Text = txtModalSetorNominalMenjadi.Text; txtRemarks.Text = (item["Keterangan"] != null ? item["Keterangan"].ToString() : string.Empty); ltrRemarks.Text = txtRemarks.Text; hfIDCompany.Value = (item["CompanyCode"] != null ? new SPFieldLookupValue(item["CompanyCode"].ToString()).LookupId.ToString() : string.Empty); hfIDPemohon.Value = new SPFieldLookupValue(item["Requestor"].ToString()).LookupId.ToString(); if (item["JenisPerubahan"] != null) { SPFieldLookupValueCollection lookUpJenisPerubahan = new SPFieldLookupValueCollection(item["JenisPerubahan"].ToString()); for (int i = 0; i < lookUpJenisPerubahan.Count; i++) { SPFieldLookupValue singlevalue = lookUpJenisPerubahan[i]; chkBoxListJenisPerubahan.SelectedValue = singlevalue.LookupId.ToString(); } } if (IDP != 0) { #region UpdatePerusahaanBaru SPList listPerusahaanBaru = web.GetList(Util.CreateSharePointListStrUrl(web.Url, "PerusahaanBaru")); SPListItem itemPerusahaanBaru = listPerusahaanBaru.GetItemById(Convert.ToInt32(hfIDCompany.Value)); txtCompanyCode.Text = (itemPerusahaanBaru["CompanyCodeAPV"] != null ? itemPerusahaanBaru["CompanyCodeAPV"].ToString() : string.Empty); ltrCompanyCode.Text = txtCompanyCode.Text; txtCompanyName.Text = (itemPerusahaanBaru["CompanyCodeAPV"] != null ? itemPerusahaanBaru["NamaPerusahaan"].ToString() : string.Empty); lblPerusahaanName.Text = txtCompanyName.Text; if (string.IsNullOrEmpty(txtAlamatSKDP.Text)) txtAlamatSKDP.Text = (itemPerusahaanBaru["AlamatSKDP"] != null ? itemPerusahaanBaru["AlamatSKDP"].ToString() : string.Empty); if (itemPerusahaanBaru["TempatKedudukan"] != null) { ddlTempatKedudukan.SelectedValue = new SPFieldLookupValue(itemPerusahaanBaru["TempatKedudukan"].ToString()).LookupId.ToString(); ltrddlTempatKedudukan.Text = ddlTempatKedudukan.SelectedItem.Text; } if (itemPerusahaanBaru["MaksudTujuan"] != null) { ddlMaksudDanTujuan.SelectedValue = new SPFieldLookupValue(itemPerusahaanBaru["MaksudTujuan"].ToString()).LookupId.ToString(); ltrddlMaksudDanTujuan.Text = ddlMaksudDanTujuan.SelectedItem.Text; } #endregion #region UpdatePemohon SPList listPemohon = web.GetList(Util.CreateSharePointListStrUrl(web.Url, "Pemohon")); SPListItem itemPemohon = listPemohon.GetItemById(Convert.ToInt32(hfIDPemohon.Value)); txtNamaPemohon.Text = (itemPemohon["Title"] != null ? itemPemohon["Title"].ToString() : string.Empty); ltrNamaPemohon.Text = txtNamaPemohon.Text; txtEmailPemohon.Text = (itemPemohon["EmailPemohon"] != null ? itemPemohon["EmailPemohon"].ToString() : string.Empty); ltrEmailPemohon.Text = txtEmailPemohon.Text; #endregion GetKomisarisDireksiSemula(itemPerusahaanBaru.ID); BindKomisarisDireksiSemula(); GetKomisarisDireksiMenjadi(IDP); BindKomisarisDireksiMenjadi(); GetPemegangSahamSemula(itemPerusahaanBaru.ID); BindPemegangSahamSemula(); GetPemegangSahamMenjadi(IDP); BindPemegangSahamMenjadi(); GetNPWP(IDP); BindNPWP(); if (item["PembuatSK"] != null) { /* SK */ txtSKNo.Text = (item["NoSK"] != null ? item["NoSK"].ToString() : string.Empty); ltrSKNo.Text = txtSKNo.Text; if (item["TanggalMulaiBerlakuSK"] != null) { dtSKMulaiBerlaku.SelectedDate = Convert.ToDateTime(item["TanggalMulaiBerlakuSK"]); ltrSKMulaiBerlaku.Text = Convert.ToDateTime(item["TanggalMulaiBerlakuSK"]).ToString("dd-MMM-yyyy"); } txtSKKeterangan.Text = (item["KeteranganSK"] != null ? item["KeteranganSK"].ToString() : string.Empty); ltrSKKeterangan.Text = txtSKKeterangan.Text; lblSKUserName.Text = (item["PembuatSK"] != null ? new SPFieldUserValue(web, item["PembuatSK"].ToString()).User.Name : string.Empty); } if (item["PembuatBNRI"] != null) { /* BNRI */ txtBNRINo.Text = (item["NoBNRI"] != null ? item["NoBNRI"].ToString() : string.Empty); ltrBNRINo.Text = txtBNRINo.Text; if (item["TanggalMulaiBerlakuBNRI"] != null) { dtBNRIMulaiBerlaku.SelectedDate = Convert.ToDateTime(item["TanggalMulaiBerlakuBNRI"]); ltrBNRIMulaiBerlaku.Text = Convert.ToDateTime(item["TanggalMulaiBerlakuBNRI"]).ToString("dd-MMM-yyyy"); } txtBNRIKeterangan.Text = (item["KeteranganBNRI"] != null ? item["KeteranganBNRI"].ToString() : string.Empty); ltrBNRIKeterangan.Text = txtBNRIKeterangan.Text; lblBNRIUserName.Text = (item["PembuatBNRI"] != null ? new SPFieldUserValue(web, item["PembuatBNRI"].ToString()).User.Name : string.Empty); } if (item["PembuatSKDP"] != null) { /* SKDP */ txtSKDPNo.Text = (item["NoSKDP"] != null ? item["NoSKDP"].ToString() : string.Empty); ltrSKDPNo.Text = txtSKDPNo.Text; if (item["TanggalMulaiBerlakuSKDP"] != null) { dtSKDPTanggalMulai.SelectedDate = Convert.ToDateTime(item["TanggalMulaiBerlakuSKDP"]); ltrSKDPTanggalMulai.Text = Convert.ToDateTime(item["TanggalMulaiBerlakuSKDP"]).ToString("dd-MMM-yyyy"); } if (item["TanggalAkhirBerlakuSKDP"] != null) { dtSKDPTanggalAkhir.SelectedDate = Convert.ToDateTime(item["TanggalAkhirBerlakuSKDP"]); ltrSKDPTanggalAkhir.Text = Convert.ToDateTime(item["TanggalAkhirBerlakuSKDP"]).ToString("dd-MMM-yyyy"); } txtSKDPKeterangan.Text = (item["KeteranganSKDP"] != null ? item["KeteranganSKDP"].ToString() : string.Empty); ltrSKDPKeterangan.Text = txtSKDPKeterangan.Text; lblSKDPUserName.Text = (item["PembuatSKDP"] != null ? new SPFieldUserValue(web, item["PembuatSKDP"].ToString()).User.Name : string.Empty); } if (item["PembuatNPWP"] != null) { /* NPWP */ txtNoNPWP.Text = (item["NoNPWP"] != null ? item["NoNPWP"].ToString() : string.Empty); ltrNoNPWP.Text = txtNoNPWP.Text; txtNamaKPP.Text = (item["NamaKPPNPWP"] != null ? item["NamaKPPNPWP"].ToString() : string.Empty); ltrNamaKPP.Text = txtNamaKPP.Text; if (item["TanggalMulaiBerlakuNPWP"] != null) { dtTanggalTerdaftarNPWP.SelectedDate = Convert.ToDateTime(item["TanggalMulaiBerlakuNPWP"]); ltrTanggalTerdaftarNPWP.Text = Convert.ToDateTime(item["TanggalMulaiBerlakuNPWP"]).ToString("dd-MMM-yyyy"); } txtKeteranganNPWP.Text = (item["KeteranganNPWP"] != null ? item["KeteranganNPWP"].ToString() : string.Empty); ltrKeteranganNPWP.Text = txtKeteranganNPWP.Text; ltrUsernameNPWP.Text = (item["PembuatNPWP"] != null ? new SPFieldUserValue(web, item["PembuatNPWP"].ToString()).User.Name : string.Empty); /* SKT */ txtNOSKTNPWP.Text = (item["NoSKT"] != null ? item["NoSKT"].ToString() : string.Empty); ltrNOSKTNPWP.Text = txtNOSKTNPWP.Text; } /* Akte */ if (item["PembuatAkte"] != null) { txtNoAkte.Text = (item["NoAkte"] != null ? item["NoAkte"].ToString() : string.Empty); ltrNoAkte.Text = txtNoAkte.Text; dtTanggalAkte.SelectedDate = Convert.ToDateTime(item["TanggalAkte"]); ltrTanggalAkte.Text = dtTanggalAkte.SelectedDate.ToString("dd/MM/yyyy"); txtNotarisAkte.Text = item["NotarisAkte"]!=null ? item["NotarisAkte"].ToString().Split(new string[] { ";#" }, StringSplitOptions.RemoveEmptyEntries)[1] : string.Empty; ltrNotarisAkte.Text = txtNotarisAkte.Text; txtKeteranganAkte.Text = item["KeteranganAkte"] == null ? string.Empty : item["KeteranganAkte"].ToString(); ltrKeteranganAkte.Text = txtKeteranganAkte.Text; if (item["PembuatAkte"]!=null) ltrUsernameAkte.Text = item["PembuatAkte"].ToString().Split(new string[] { ";#" }, StringSplitOptions.RemoveEmptyEntries)[1]; } /* APV */ if (item["PembuatAPV"] != null) { txtKodePerusahaanAPV.Text = item["CompanyCodeAPV"] == null ? string.Empty : item["CompanyCodeAPV"].ToString(); ltrKodePerusahaanAPV.Text = txtKodePerusahaanAPV.Text; txtNoAPV.Text = item["NoAPV"] == null ? string.Empty : item["NoAPV"].ToString(); ltrNoAPV.Text = txtNoAPV.Text; if (item["TanggalAPV"] != null) { dtTanggalAPV.SelectedDate = Convert.ToDateTime(item["TanggalAPV"]); ltrTanggalAPV.Text = Convert.ToDateTime(item["TanggalAPV"]).ToString("dd-MMM-yyyy"); } txtKeteranganAPV.Text = item["KeteranganAPV"] == null ? string.Empty : item["KeteranganAPV"].ToString(); ltrKeteranganAPV.Text = txtKeteranganAPV.Text; if (item["PembuatAPV"] != null) ltrUsernameAPV.Text = item["PembuatAPV"].ToString().Split(new string[] { ";#" }, StringSplitOptions.RemoveEmptyEntries)[1]; } /* Setoran Modal */ if (item["PembuatSetoran"] != null) { if (item["TanggalSetoran"] != null) { dtTanggalSetoran.SelectedDate = Convert.ToDateTime(item["TanggalSetoran"]); ltrTanggalSetoran.Text = Convert.ToDateTime(item["TanggalSetoran"]).ToString("dd-MMM-yyyy"); } txtKeteranganSetoran.Text = item["KeteranganSetoran"] == null ? string.Empty : item["KeteranganSetoran"].ToString(); ltrKeteranganSetoran.Text = txtKeteranganSetoran.Text; if (item["StatusSetoran"] != null) { chkStatusSetoran.Checked = Convert.ToBoolean(item["StatusSetoran"]); ltrStatusSetoran.Text = Convert.ToBoolean(item["StatusSetoran"]) == true ? "Yes" : "No"; } if (item["PembuatSetoran"]!=null) ltrUsernameSetoran.Text = item["PembuatSetoran"].ToString().Split(new string[] { ";#" }, StringSplitOptions.RemoveEmptyEntries)[1]; } DisplayDocument(ltrfuSK, Convert.ToInt32(hfIDCompany.Value), "SK"); DisplayDocument(ltrfuAkte, Convert.ToInt32(hfIDCompany.Value), "AKTA"); DisplayDocument(ltrfuSKDP, Convert.ToInt32(hfIDCompany.Value), "SKDP"); DisplayDocument(ltrfuNPWP, Convert.ToInt32(hfIDCompany.Value), "NPWP"); DisplayDocument(ltrfuSKT, Convert.ToInt32(hfIDCompany.Value), "SKT"); DisplayDocument(ltrfuAPV, Convert.ToInt32(hfIDCompany.Value), "APV"); DisplayDocument(ltrfuSetoranModal, Convert.ToInt32(hfIDCompany.Value), "Setoran Modal"); } HiddenControls(mode, workflowStatus, approvalStatus); } catch (Exception ex) { Response.Write(ex.Message + "," + ex.StackTrace); } }
protected SPFieldMultiChoiceValue MapCollectionToMultiChoiceValue(IEnumerable<string> collection) { var values = new SPFieldMultiChoiceValue(); foreach (var item in collection) { values.Add(item); } return values; }
internal static void Set_SPFieldMultiChoiceValue(SPListItem item, string col, System.Collections.ArrayList komponenty) { SPFieldMultiChoiceValue fmcv = new SPFieldMultiChoiceValue(); foreach (string s in komponenty) { fmcv.Add(s); } item[col] = fmcv; }
private static Array Refine_Klienci_MaskaSerwisu(Array klienci, SPFieldMultiChoiceValue maski) { ArrayList results = new ArrayList(); foreach (SPListItem klientItem in klienci) { for (int i = 0; i < maski.Count; i++) { string s = maski[i]; if (BLL.Tools.Has_Service(klientItem, s, "selSewisy")) { results.Add(klientItem); Debug.WriteLine(BLL.Tools.Get_Text(klientItem, "_NazwaPrezentowana") + " - added"); break; } } } return results.ToArray(); }
public void TestInit() { using (SPSite site = new SPSite("http://sp2013test")) { using (SPWeb web = site.OpenWeb(webUrl)) { TestList = web.Lists.TryGetList(this.listName); if (TestList == null) { Guid listId = web.Lists.Add(this.listName, "Test list for SPQueryUtil querystring", SPListTemplateType.GenericList); web.Update(); TestList = web.Lists[listId]; TestList.Fields.Add("TextCol", SPFieldType.Text, false); TestList.Fields.Add("MultiTextCol", SPFieldType.Note, false); TestList.Fields.Add("NumberCol", SPFieldType.Number, false); TestList.Fields.Add("DateTimeCol", SPFieldType.DateTime, false); TestList.Fields.Add("BoolCol", SPFieldType.Boolean, false); TestList.Fields.Add("ChoiceCol", SPFieldType.Choice, false); TestList.Fields.Add("MultiChoiceCol", SPFieldType.MultiChoice, false); TestList.Fields.Add("GuidCol", SPFieldType.Guid, false); TestList.Fields.Add("UrlCol", SPFieldType.URL, false); TestList.Fields.Add("UserCol", SPFieldType.User, false); TestList.Update(); SPListItem textItem = TestList.AddItem(); textItem["TextCol"] = "text1"; textItem.Update(); SPListItem textItemMulti = TestList.AddItem(); textItemMulti["MultiTextCol"] = "Multi text"; textItemMulti.Update(); SPListItem numberItem = TestList.AddItem(); numberItem["NumberCol"] = 100; numberItem.Update(); SPListItem dateTimeCol = TestList.AddItem(); dateTimeCol["DateTimeCol"] = new DateTime(2000, 1, 1, 5, 10, 59); dateTimeCol.Update(); SPListItem boolItem = TestList.AddItem(); boolItem["BoolCol"] = true; boolItem.Update(); SPListItem choiceItem = TestList.AddItem(); choiceItem["ChoiceCol"] = "choice1"; choiceItem.Update(); var choicevalues = new SPFieldMultiChoiceValue(); choicevalues.Add("Green"); choicevalues.Add("Blue"); SPListItem chioceItemMulti = TestList.AddItem(); chioceItemMulti["MultiChoiceCol"] = choicevalues; chioceItemMulti.Update(); SPListItem guidItem = TestList.AddItem(); guidItem["GuidCol"] = new Guid("96D74029-8482-4C52-8C4F-4A4040A77BC5"); guidItem.Update(); SPListItem urlItem = TestList.AddItem(); urlItem["UrlCol"] = "http://www.google.com"; urlItem.Update(); //SPListItem userItem = TestList.AddItem(); //textItemMulti["UserCol"] = ""; //userItem.Update(); } } using (SPWeb web = site.OpenWeb(this.webUrl)) { TestList = web.Lists[this.listName]; } } }
private static object ConvertToMultiChoiceValue(string[] values) { var value = new SPFieldMultiChoiceValue(); if (values != null) foreach (string val in values) value.Add(val); return value; }
// public static void ImportListData(string siteURL, string spListName, string PathToCSV) static void ImportListData(SPWeb spWeb, string spListName, string[] TheData) { //string str = siteURL; //string str2 = spListName; //string str3 = PathToCSV; Console.Write(string.Format("Adding data for list {0} ...", spListName)); //SPSite site = new SPSite(str); //SPList list = site.OpenWeb().Lists[str2]; SPList list = spWeb.Lists[spListName]; Console.WriteLine("Done"); //Console.Write(string.Format("Importing Data from file {0} ...", str3)); //StreamReader reader = new StreamReader(str3); // string str4 = null; List<SPField> list2 = null; // while ((str4 = reader.ReadLine()) != null) foreach (string str4 in TheData) { string[] strArray = str4.Split(new char[] { ',' }); // adding fields first time through if (list2 == null) { list2 = new List<SPField>(); foreach (string str5 in strArray) { SPField field = list.Fields[str5]; list2.Add(field); } } else // adding the data since we already got the fields { SPListItem item = list.Items.Add(); for (int i = 0; i < list2.Count; i++) { string str5 = strArray[i]; string typeAsString = list2[i].TypeAsString; if (typeAsString.StartsWith("Lookup")) { if (!string.IsNullOrEmpty(str5)) { XmlDocument document = new XmlDocument(); document.LoadXml(list2[i].SchemaXml); XmlNode node = document.GetElementsByTagName("Field")[0]; Guid guid = new Guid(node.Attributes["List"].Value); string lookupFieldInternalName = node.Attributes["ShowField"].Value; SPList lookupList = spWeb.Lists[guid]; if (typeAsString == "LookupMulti") { item[list2[i].InternalName] = GetLookupValueCollectionString(lookupList, lookupFieldInternalName, str5); } else { item[list2[i].InternalName] = GetLookupValueID(lookupList, lookupFieldInternalName, str5); } } } else if (typeAsString.StartsWith("MultiChoice")) { if (!string.IsNullOrEmpty(str5)) { string[] strArray2 = str5.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); SPFieldMultiChoiceValue value2 = new SPFieldMultiChoiceValue(); foreach (string str8 in strArray2) { value2.Add(str8); } item[list2[i].InternalName] = value2; } } else if (typeAsString.StartsWith("User")) { if (!string.IsNullOrEmpty(str5)) { int lookupId = int.Parse(str5); SPFieldUserValue value3 = new SPFieldUserValue(item.Web, lookupId, null); item[list2[i].InternalName] = value3; } } else { item[list2[i].InternalName] = str5; } } item.Update(); Console.Write("."); } } Console.WriteLine(" Done"); }
private string SaveUpdate() { using (SPSite site = new SPSite(SPContext.Current.Web.Url, SPContext.Current.Site.SystemAccount.UserToken)) { using (web = site.OpenWeb()) { SPList list = web.GetList(Util.CreateSharePointListStrUrl(web.Url, "PerubahanAnggaranDasarDanDataPerseroan")); SPList listPemegangSaham = web.GetList(Util.CreateSharePointListStrUrl(web.Url, "PerubahanPemegangSaham")); SPList listKomisarisDireksi = web.GetList(Util.CreateSharePointListStrUrl(web.Url, "PerubahanKomisarisDireksi")); SPList listDokumen = web.GetList(Util.CreateSharePointDocLibStrUrl(web.Url, "PerubahanAnggaranDasarDokumen")); SPList listPerusahaanBaru = web.GetList(Util.CreateSharePointListStrUrl(web.Url, "PerusahaanBaru")); SPListItem itemlistPerusahaanBaru = listPerusahaanBaru.GetItemById(Convert.ToInt32(hfIDCompany.Value)); web.AllowUnsafeUpdates = true; SPListItem item = null; try { if (IDP == 0) { item = list.Items.Add(); item["Title"] = Util.GenerateRequestCode(web, this.CodeName, DateTime.Now.Month, DateTime.Now.Year); item["Created By"] = SPContext.Current.Web.CurrentUser.ID.ToString(); item["Step"] = StepWF[0]; if (!string.IsNullOrEmpty(rdPerubahanModal.SelectedValue)) item["PerubahanModal"] = (rdPerubahanModal.SelectedValue.Equals("Yes") ? true : false); if (!string.IsNullOrEmpty(rdPerubahanNama.SelectedValue)) item["PerubahanNamaDanTempat"] = (rdPerubahanNama.SelectedValue.Equals("Yes") ? true : false); } else { item = list.GetItemById(IDP); item["Modified By"] = SPContext.Current.Web.CurrentUser.ID.ToString(); } item["Tanggal"] = Convert.ToDateTime(ltrDate.Text); item["Requestor"] = hfIDPemohon.Value; SPFieldMultiChoiceValue multiValue = new SPFieldMultiChoiceValue(); foreach (ListItem itemCheckBox in chkBoxListJenisPerubahan.Items) { if (itemCheckBox.Selected) multiValue.Add(itemCheckBox.Text); } item["JenisPerubahan"] = multiValue; item["AlasanPerubahan"] = txtAlasanPerubahan.Text.Trim(); item["BNRI"] = (rbBNRI.SelectedValue.Equals("Yes") ? true : false); item["MataUang"] = ddlMataUang.SelectedValue; item["ModalDasar"] = (!string.IsNullOrEmpty(txtModalDasarNominalSemula.Text) ? txtModalDasarNominalSemula.Text.Trim() : "0"); item["ModalSetor"] = (!string.IsNullOrEmpty(txtModalSetorNominalSemula.Text) ? txtModalSetorNominalSemula.Text.Trim() : "0"); item["Nominal"] = (!string.IsNullOrEmpty(txtNominalMataUang.Text) ? txtNominalMataUang.Text.Trim() : "0"); item["NominalModalDasar"] = Convert.ToDouble(item["ModalDasar"]) * Convert.ToDouble(item["Nominal"]); item["NominalModalSetor"] = Convert.ToDouble(item["ModalSetor"]) * Convert.ToDouble(item["Nominal"]); item["Keterangan"] = txtRemarks.Text.Trim(); item["CompanyCode"] = hfIDCompany.Value.Trim(); item.Web.AllowUnsafeUpdates = true; item.Update(); ViewState["ID"] = item.ID; if (item.ID > 0) { #region UpdatePerusahaanBaru itemlistPerusahaanBaru["CompanyCodeAPV"] = txtCompanyCode.Text; itemlistPerusahaanBaru["NamaPerusahaan"] = txtCompanyName.Text; itemlistPerusahaanBaru["TempatKedudukan"] = ddlTempatKedudukan.SelectedValue; itemlistPerusahaanBaru["MaksudTujuan"] = ddlMaksudDanTujuan.SelectedValue; itemlistPerusahaanBaru["MataUang"] = ddlMataUang.SelectedValue; itemlistPerusahaanBaru.Web.AllowUnsafeUpdates = true; itemlistPerusahaanBaru.Update(); #endregion } /* Pemegang Saham */ if (ViewState["PemegangSahamMenjadi"] != null) { List<PemegangSaham> collPemegangSaham = ViewState["PemegangSahamMenjadi"] as List<PemegangSaham>; foreach (PemegangSaham i in collPemegangSaham) { if (!i.IsDeleted) { SPListItem itemPemegangSaham = null; if (i.ID == 0) itemPemegangSaham = listPemegangSaham.Items.Add(); else itemPemegangSaham = listPemegangSaham.Items.GetItemById(i.ID); itemPemegangSaham["PerubahanAnggaranDasar"] = ViewState["ID"].ToString(); itemPemegangSaham["Title"] = i.Nama; itemPemegangSaham["JumlahSaham"] = i.JumlahSaham; itemPemegangSaham["JumlahNominal"] = i.JumlahNominal; itemPemegangSaham["Percentages"] = i.Percentages; itemPemegangSaham["Partner"] = i.Partner; itemPemegangSaham["TanggalMulaiMenjabat"] = i.MulaiMenjabat; itemPemegangSaham["TanggalAkhirMenjabat"] = i.AkhirMenjabat; itemPemegangSaham["Created By"] = SPContext.Current.Web.CurrentUser.ID.ToString(); itemPemegangSaham.Web.AllowUnsafeUpdates = true; itemPemegangSaham.Update(); } else { if (i.ID > 0) listPemegangSaham.GetItemById(i.ID).Recycle(); } } } /* Komisaris */ if (ViewState["KomisarisDireksiMenjadi"] != null) { List<KomisarisDireksi> collKomisarisDireksi = ViewState["KomisarisDireksiMenjadi"] as List<KomisarisDireksi>; foreach (KomisarisDireksi i in collKomisarisDireksi) { if (!i.IsDeleted) { SPListItem itemKomisarisDireksi = null; if (i.ID == 0) itemKomisarisDireksi = listKomisarisDireksi.Items.Add(); else itemKomisarisDireksi = listKomisarisDireksi.Items.GetItemById(i.ID); itemKomisarisDireksi["PerubahanAnggaranDasar"] = ViewState["ID"].ToString(); itemKomisarisDireksi["Title"] = i.Nama; itemKomisarisDireksi["Jabatan"] = i.IDJabatan; itemKomisarisDireksi["NoKTP"] = i.NoKTP; itemKomisarisDireksi["NoNPWP"] = i.NoNPWP; itemKomisarisDireksi["TanggalMulaiMenjabat"] = i.MulaiMenjabat; itemKomisarisDireksi["TanggalAkhirMenjabat"] = i.AkhirMenjabat; itemKomisarisDireksi["Created By"] = SPContext.Current.Web.CurrentUser.ID.ToString(); itemKomisarisDireksi.Web.AllowUnsafeUpdates = true; itemKomisarisDireksi.Update(); } else { if (i.ID > 0) listKomisarisDireksi.GetItemById(i.ID).Recycle(); } } } if (IDP != 0) { if (Convert.ToBoolean(ViewState["Admin"]) == true || ViewState["Status"].ToString() == "PIC Update Akta") { /* Akte */ item["NoAkte"] = txtNoAkte.Text.Trim(); item["TanggalAkte"] = dtTanggalAkte.SelectedDate; if (!string.IsNullOrEmpty(txtNotarisAkte.Text)) item["NotarisAkte"] = GetNotarisID(txtNotarisAkte.Text.Trim()); item["KeteranganAkte"] = txtKeteranganAkte.Text.Trim(); item["PembuatAkte"] = SPContext.Current.Web.CurrentUser.ID.ToString(); } /* SKDP */ if (Convert.ToBoolean(ViewState["Admin"]) == true || ViewState["Status"].ToString() == "PIC Upload SKDP") { /* BNRI */ item["NoBNRI"] = txtBNRINo.Text.Trim(); item["TanggalMulaiBerlakuBNRI"] = dtBNRIMulaiBerlaku.SelectedDate; item["KeteranganBNRI"] = txtBNRIKeterangan.Text.Trim(); item["PembuatBNRI"] = SPContext.Current.Web.CurrentUser.ID.ToString(); item["NoSKDP"] = txtSKDPNo.Text.Trim(); item["TanggalMulaiBerlakuSKDP"] = dtSKDPTanggalMulai.SelectedDate; item["TanggalAkhirBerlakuSKDP"] = dtSKDPTanggalAkhir.SelectedDate; item["KeteranganSKDP"] = txtSKDPKeterangan.Text.Trim(); item["AlamatSKDP"] = txtAlamatSKDP.Text.Trim(); item["PembuatSKDP"] = SPContext.Current.Web.CurrentUser.ID.ToString(); itemlistPerusahaanBaru["AlamatSKDP"] = txtAlamatSKDP.Text.Trim(); itemlistPerusahaanBaru.Update(); } if (Convert.ToBoolean(ViewState["Admin"]) == true || ViewState["Status"].ToString() == "PIC Upload NPWP dan SKT") { /* NPWP */ if (ViewState["NPWP"] != null) { List<NPWP> collNPWP = ViewState["NPWP"] as List<NPWP>; foreach (NPWP i in collNPWP) { SPFolder document = web.Folders["PerubahanNPWP"]; if (!i.IsDeleted) { SPFile file = document.Files.Add(i.NamaFile, i.Attachment, true); SPItem itemDocument = file.Item; itemDocument["Title"] = Path.GetFileNameWithoutExtension(i.NamaFile); itemDocument["PerubahanAnggaranDasar"] = Convert.ToInt32(ViewState["ID"]); itemDocument["NoNPWP"] = i.NoNPWP; itemDocument["Keterangan"] = i.Keterangan; itemDocument["Created By"] = SPContext.Current.Web.CurrentUser.ID.ToString(); itemDocument.Update(); } else { if (i.ID > 0) document.Item.ListItems.DeleteItemById(i.ID); } } } /* NPWP */ item["NoNPWP"] = txtNoNPWP.Text.Trim(); item["TanggalMulaiBerlakuNPWP"] = dtTanggalTerdaftarNPWP.SelectedDate; item["KeteranganNPWP"] = txtKeteranganNPWP.Text.Trim(); item["NamaKPPNPWP"] = txtNamaKPP.Text.Trim(); item["PembuatNPWP"] = SPContext.Current.Web.CurrentUser.ID.ToString(); /* SKT */ item["NoSKT"] = txtNOSKTNPWP.Text.Trim(); item["PembuatSKT"] = SPContext.Current.Web.CurrentUser.ID.ToString(); } if (Convert.ToBoolean(ViewState["Admin"]) == true || ViewState["Status"].ToString() == "PIC Upload APV") { /* APV */ item["CompanyCodeAPV"] = txtKodePerusahaanAPV.Text.Trim(); item["NoAPV"] = txtNoAPV.Text.Trim(); item["TanggalAPV"] = dtTanggalAPV.SelectedDate; item["KeteranganAPV"] = txtKeteranganAPV.Text.Trim(); } if (Convert.ToBoolean(ViewState["Admin"]) == true || ViewState["Status"].ToString() == "PIC Upload Setoran Modal") { /* Setoran */ item["TanggalSetoran"] = dtTanggalSetoran.SelectedDate; item["KeteranganSetoran"] = txtKeteranganSetoran.Text.Trim(); item["StatusSetoran"] = chkStatusSetoran.Checked; item["PembuatSetoran"] = SPContext.Current.Web.CurrentUser.ID.ToString(); item["PembuatAPV"] = SPContext.Current.Web.CurrentUser.ID.ToString(); } if (Convert.ToBoolean(ViewState["Admin"]) == true || ViewState["Status"].ToString() == "PIC Upload SK Persetujuan") { /* SK */ item["NoSK"] = txtSKNo.Text.Trim(); item["TanggalMulaiBerlakuSK"] = dtSKMulaiBerlaku.SelectedDate; item["KeteranganSK"] = txtSKKeterangan.Text.Trim(); item["PembuatSK"] = SPContext.Current.Web.CurrentUser.ID.ToString(); } item.Web.AllowUnsafeUpdates = true; item.Update(); ViewState["ID"] = item.ID; string message = string.Empty; message = SaveDocument(fuSK, Convert.ToInt32(hfIDCompany.Value), "SK"); if (message != string.Empty) return message; message = string.Empty; message = SaveDocument(fuAkte, Convert.ToInt32(hfIDCompany.Value), "AKTA"); if (message != string.Empty) return message; message = SaveDocument(fuSKDP, Convert.ToInt32(hfIDCompany.Value), "SKDP"); if (message != string.Empty) return message; message = SaveDocument(fuNPWP, Convert.ToInt32(hfIDCompany.Value), "NPWP"); if (message != string.Empty) return message; message = SaveDocument(fuSKT, Convert.ToInt32(hfIDCompany.Value), "SKT"); if (message != string.Empty) return message; message = SaveDocument(fuAPV, Convert.ToInt32(hfIDCompany.Value), "APV"); if (message != string.Empty) return message; message = SaveDocument(fuSetoranModal, Convert.ToInt32(hfIDCompany.Value), "Setoran Modal"); if (message != string.Empty) return message; } web.AllowUnsafeUpdates = false; } catch (Exception ex) { string err = ex.Message + "," + ex.StackTrace; if (IDP == 0) return SR.SaveFail + "\n" + err; else return SR.UpdateFail + "\n" + err; } } } return string.Empty; }
/// <summary> /// Generowanie formatek rozliczeniowych dla wszystkich aktywnych klientów /// </summary> /// <param name="properties"></param> internal static void Execute_GenFormRozl(SPItemEventProperties properties, SPWeb web) { StringBuilder msg = new StringBuilder(); StringBuilder sb = new StringBuilder(); //sprawdź parametry wywołania SPFieldMultiChoiceValue wt = new SPFieldMultiChoiceValue(properties.ListItem["enumTypKlienta"].ToString()); int okresId = new SPFieldLookupValue(properties.ListItem["selOkres"].ToString()).LookupId; SPListItem item = properties.ListItem; for (int i = 0; i < wt.Count; i++) { if (okresId > 0) { string typKlienta = wt[i]; Array klienci = tabKlienci.Get_AktywniKlienci_Serwis(web, typKlienta); bool createKK = Get_Flag(item, "colDodajKartyKontrolne"); switch (typKlienta) { case "KPiR": ZUS_Forms.Create(web, klienci, okresId, createKK); PD_Forms.Create(web, klienci, okresId, createKK); VAT_Forms.Create(web, klienci, okresId, createKK); BR_Forms.Create(web, klienci, okresId); Reminder_Forms.Create(web, klienci, okresId); break; case "KSH": ZUS_Forms.Create(web, klienci, okresId, createKK); PDS_Forms.Create(web, klienci, okresId, createKK); VAT_Forms.Create(web, klienci, okresId, createKK); BR_Forms.Create(web, klienci, okresId); Reminder_Forms.Create(web, klienci, okresId); break; case "Firma": PDS_Forms.Create(web, klienci, okresId, false); break; case "Osoba fizyczna": ZUS_Forms.Create(web, klienci, okresId, false); PD_Forms.Create(web, klienci, okresId, false); VAT_Forms.Create(web, klienci, okresId, false); break; default: break; } //informacja dla operatora foreach (SPListItem klient in klienci) { msg.AppendFormat(@"<li>klient# {0} {1}</li>", klient.ID.ToString(), BLL.Tools.Get_Text(klient, "_NazwaPrezentowana")); } } } // info o zakończeniu procesu string bodyHTML = string.Empty; if (msg.Length > 0) { bodyHTML = string.Format(@"<ul>{0}</ul>", msg.ToString()); } string subject = string.Format(@"Generowanie formatek rozliczeniowych dla klientów typu {0}", wt.ToString()); SPEmail.EmailGenerator.SendProcessEndConfirmationMail(subject, bodyHTML, web, item); }
protected IEnumerable<string> MapMultiChoiceValueToCollection(string rawValue) { var values = new SPFieldMultiChoiceValue(rawValue); for (int index = 0; index < values.Count; index++) { yield return values[index]; } }
private static SPListItem setItemFields(List <SPFieldValue> fields, SPListItem item) { foreach (SPFieldValue fieldValue in fields) { string[] strArray; SPFieldLookupValueCollection values; int num; switch (fieldValue.Type) { case "Text": { item[fieldValue.InternalName] = fieldValue.value; continue; } case "Note": { item[fieldValue.InternalName] = fieldValue.value; continue; } case "Number": { item[fieldValue.InternalName] = decimal.Parse(fieldValue.value); continue; } case "DateTime": { item[fieldValue.InternalName] = (fieldValue.value != "") ? new DateTime?(Convert.ToDateTime(fieldValue.value)) : null; continue; } case "Lookup": { item[fieldValue.InternalName] = ((fieldValue.value != "") && (fieldValue.value != "0")) ? new SPFieldLookupValue(int.Parse(fieldValue.value), "") : null; continue; } case "LookupMulti": { strArray = fieldValue.value.Split(new char[] { ',' }); values = new SPFieldLookupValueCollection(); num = 0; if (num < strArray.Length) { values.Add(new SPFieldLookupValue(int.Parse(strArray[num]), "")); num++; } item[fieldValue.InternalName] = values; continue; } case "RelatedCustomLookupQuery": { strArray = fieldValue.value.Split(','); if (strArray.Count() > 0) { values = new SPFieldLookupValueCollection(); num = 0; if (num < strArray.Length && strArray[num].Length > 0) { values.Add(new SPFieldLookupValue(int.Parse(strArray[num]), "")); num++; } item[fieldValue.InternalName] = values; } else { item[fieldValue.InternalName] = ((fieldValue.value != "") && (fieldValue.value != "0")) ? new SPFieldLookupValue(int.Parse(fieldValue.value), "") : null; } continue; } case "CustomComputedField": { item[fieldValue.InternalName] = fieldValue.value; continue; } case "Choice": { item[fieldValue.InternalName] = fieldValue.value; continue; } case "MultiChoice": { string[] strArray2 = fieldValue.value.Split(new char[] { ',' }); SPFieldMultiChoiceValue value3 = new SPFieldMultiChoiceValue(); num = 0; while (num < strArray2.Length) { value3.Add(strArray2[num]); num++; } item[fieldValue.InternalName] = value3; continue; } case "Boolean": { item[fieldValue.InternalName] = fieldValue.value; continue; } case "User": { item[fieldValue.InternalName] = ((fieldValue.value != "") && (fieldValue.value != "0")) ? new SPFieldUserValue(SPContext.Current.Web, int.Parse(fieldValue.value), "") : null; continue; } case "File": { item[fieldValue.InternalName] = ((fieldValue.value != "") && (fieldValue.value != "0")) ? new SPFieldLookupValue(int.Parse(fieldValue.value), "") : null; continue; } default: { continue; } } } return(item); }
/// <summary> /// Update SPListItem with correcsponding data parse from actions. /// </summary> /// <param name="item"></param> /// <param name="updatedField"></param> /// <param name="data"></param> private void DoUpdateItem(SPListItem item, SPField updatedField, string data) { switch (updatedField.Type) { case SPFieldType.Boolean: item[updatedField.Id] = Convert.ToBoolean(data); break; case SPFieldType.File: case SPFieldType.Calculated: case SPFieldType.Computed: case SPFieldType.Currency: case SPFieldType.Integer: case SPFieldType.Note: case SPFieldType.Number: case SPFieldType.Text: item[updatedField.Id] = data; break; case SPFieldType.Choice: SPFieldChoice fieldChoice = (SPFieldChoice)updatedField; item[updatedField.Id] = data; break; case SPFieldType.DateTime: SPFieldDateTime fieldDate = (SPFieldDateTime)updatedField; item[updatedField.Id] = Convert.ToDateTime(data); break; case SPFieldType.Lookup: SPFieldLookup fieldLookup = (SPFieldLookup)updatedField; if (fieldLookup.AllowMultipleValues) { SPFieldLookupValueCollection multiValues = new SPFieldLookupValueCollection(); foreach (var s in data.Split("|".ToCharArray())) { multiValues.Add(new SPFieldLookupValue(s)); } item[updatedField.Id] = multiValues; } else { //int id = fieldLookup.GetLookupIdFromValue(data); SPFieldLookupValue singleLookupValue = new SPFieldLookupValue(data); item[updatedField.Id] = singleLookupValue; } break; case SPFieldType.MultiChoice: SPFieldMultiChoice fieldMultichoice = (SPFieldMultiChoice)updatedField; string [] items = data.Split("|".ToCharArray()); SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue(); foreach (string choice in items) { values.Add(choice); } item[updatedField.Id] = values; break; case SPFieldType.User: SPFieldUser fieldUser = (SPFieldUser)updatedField; SPFieldUserValueCollection fieldValues = new SPFieldUserValueCollection(); string[] entities = data.Split("|".ToCharArray()); foreach (string entity in entities) { SPUser user = item.Web.EnsureUser(entity.Split(";#".ToCharArray())[2]); if(user!= null) fieldValues.Add(new SPFieldUserValue(item.Web, user.ID, user.Name)); } item[updatedField.Id] = fieldValues; break; case SPFieldType.Invalid: if (string.Compare(updatedField.TypeAsString, Constants.LOOKUP_WITH_PICKER_TYPE_NAME, true) == 0) { item[updatedField.Id] = data; } break; } }
private void Update_KK_Zadania_ExecuteCode(object sender, EventArgs e) { int kartaKontrolnaId = (int)BLL.Tools.Get_Value(item, "_KartaKontrolnaId"); SPFieldMultiChoiceValue fmcv = BLL.Tools.Get_MutichoiceValue(item, "_KomponentyKK"); if (fmcv.Count > 0) { SPListItem kkItem = BLL.tabKartyKontrolne.GetItemById(item.Web, kartaKontrolnaId); if (kkItem != null) { for (int i = 0; i < fmcv.Count; i++) { SPListItem zadanie; switch (fmcv[i].ToString()) { case "ZUS": BLL.tabKartyKontrolne.Set_StatusZadania(kkItem, "colZUS_StatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.tabKartyKontrolne.Set_StatusWysylki(kkItem, "colZUS_StatusWysylki", _STATUS_WYSYLKI_WYSLANA); BLL.tabKartyKontrolne.Set_DataWyslania(kkItem, "colZUS_DataWyslaniaInformacji", dataWyslania); zadanie = BLL.tabZadania.GetItemById(item.Web, BLL.Tools.Get_LookupId(kkItem, "selZadanie_ZUS")); if (zadanie != null) { BLL.Tools.Set_Text(zadanie, "enumStatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.Tools.Set_Date(zadanie, "colZUS_DataWyslaniaInformacji", dataWyslania); zadanie.SystemUpdate(); Workflows.Tools.WriteToHistoryLog(workflowProperties, "Zadanie ZUS #" + zadanie.ID.ToString(), "zaktualizowane"); } break; case "ZUSPD": //BLL.tabKartyKontrolne.Set_StatusZadania(kkItem, "colZUS_StatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.tabKartyKontrolne.Set_StatusWysylki(kkItem, "colZUSPD_StatusWysylki", _STATUS_WYSYLKI_WYSLANA); BLL.tabKartyKontrolne.Set_DataWyslania(kkItem, "colZUSPD_DataWyslaniaInformacji", dataWyslania); //zadanie = BLL.tabZadania.GetItemById(item.Web, BLL.Tools.Get_LookupId(kkItem, "selZadanie_ZUS")); //if (zadanie != null) //{ // BLL.Tools.Set_Text(zadanie, "enumStatusZadania", _STATUS_ZADANIE_ZAKONCZONE); // BLL.Tools.Set_Date(zadanie, "colZUSPD_DataWyslaniaInformacji", dataWyslania); // zadanie.SystemUpdate(); //} break; case "PD": BLL.tabKartyKontrolne.Set_StatusZadania(kkItem, "colPD_StatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.tabKartyKontrolne.Set_StatusWysylki(kkItem, "colPD_StatusWysylki", _STATUS_WYSYLKI_WYSLANA); BLL.tabKartyKontrolne.Set_DataWyslania(kkItem, "colPD_DataWylaniaInformacji", dataWyslania); //uwaga błąd w pisowni zadanie = BLL.tabZadania.GetItemById(item.Web, BLL.Tools.Get_LookupId(kkItem, "selZadanie_PD")); if (zadanie != null) { BLL.Tools.Set_Text(zadanie, "enumStatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.Tools.Set_Date(zadanie, "colPD_DataWylaniaInformacji", dataWyslania); zadanie.SystemUpdate(); Workflows.Tools.WriteToHistoryLog(workflowProperties, "Zadanie PD #" + zadanie.ID.ToString(), "zaktualizowane"); } break; case "VAT": BLL.tabKartyKontrolne.Set_StatusZadania(kkItem, "colVAT_StatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.tabKartyKontrolne.Set_StatusWysylki(kkItem, "colVAT_StatusWysylki", _STATUS_WYSYLKI_WYSLANA); BLL.tabKartyKontrolne.Set_DataWyslania(kkItem, "colVAT_DataWyslaniaInformacji", dataWyslania); zadanie = BLL.tabZadania.GetItemById(item.Web, BLL.Tools.Get_LookupId(kkItem, "selZadanie_VAT")); if (zadanie != null) { BLL.Tools.Set_Text(zadanie, "enumStatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.Tools.Set_Date(zadanie, "colVAT_DataWyslaniaInformacji", dataWyslania); zadanie.SystemUpdate(); Workflows.Tools.WriteToHistoryLog(workflowProperties, "Zadanie VAT #" + zadanie.ID.ToString(), "zaktualizowane"); } break; case "RBR": BLL.tabKartyKontrolne.Set_StatusZadania(kkItem, "colRBR_StatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.tabKartyKontrolne.Set_StatusWysylki(kkItem, "colRBR_StatusWysylki", _STATUS_WYSYLKI_WYSLANA); BLL.tabKartyKontrolne.Set_DataWyslania(kkItem, "colBR_DataWyslaniaInformacji", dataWyslania); zadanie = BLL.tabZadania.GetItemById(item.Web, BLL.Tools.Get_LookupId(kkItem, "selZadanie_RBR")); if (zadanie != null) { BLL.Tools.Set_Text(zadanie, "enumStatusZadania", _STATUS_ZADANIE_ZAKONCZONE); BLL.Tools.Set_Date(zadanie, "colBR_DataWyslaniaInformacji", dataWyslania); zadanie.SystemUpdate(); Workflows.Tools.WriteToHistoryLog(workflowProperties, "Zadanie RBR #" + zadanie.ID.ToString(), "zaktualizowane"); } break; default: break; } } } kkItem.SystemUpdate(); Workflows.Tools.WriteToHistoryLog(workflowProperties, "Karta Kontrolna #" + kkItem.ID.ToString(), "zaktualizowana"); } }
/// <summary> /// /// </summary> /// <param name="listConfig"></param> /// <param name="dte"></param> /// <param name="dtagrid"></param> public List<String> getListData(ListConfig listConfig, DateTime dte, DataGridView dtagrid, String EmailMgetFileName, Boolean sendTestEmails) { SP.List oList = _context.Web.Lists.GetByTitle(listConfig._SharePointSListName); List<String> sentRecipients = new List<string>(); CamlQuery camlQuery = new CamlQuery(); Boolean canceled = false; if (dtagrid != null) {// get all all data for testing camlQuery.ViewXml = "<View><Query><Where><Geq>" + "<FieldRef Name='ID'/>" + "<Value Type='Number'>0</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>"; } else { camlQuery.ViewXml = "<View><Query><Where><And>"; foreach (String af in listConfig._ActiveFields) camlQuery.ViewXml += "<Eq><FieldRef Name='" + af + "'/><Value Type='Bool'>True</Value></Eq>"; camlQuery.ViewXml += "</And></Where></Query></View>"; } if (listConfig._CAMLQUery != null && !listConfig._CAMLQUery.Equals(""))// over ride the query if user types it. camlQuery.ViewXml = "<View><Query><Where>" + listConfig._CAMLQUery + "</Where></Query></View>"; ListItemCollection collListItem = oList.GetItems(camlQuery); try { _context.Load(collListItem); } catch (Exception ex) { String Msg = @"[CAML Query " + camlQuery.ViewXml + " Failed:" + ex.Message + "]"; if (dtagrid != null) MessageBox.Show(ex.Message, "Error in CAML"); else throw new Exception(Msg, ex); } int activeFieldsCount = 0; // if (dtagrid != null) // { activeFieldsCount = setUpDataGrid(listConfig, dtagrid); // } List siteAppList = _context.Web.Lists.GetByTitle(listConfig._SharePointSListName); // This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll" // so that it grabs all list items, regardless of the folder they are in. try { _context.ExecuteQuery(); } catch (Exception ex) { String Msg = @"[CAML Query " + camlQuery.ViewXml + " Failed:" + ex.Message + "]"; if (dtagrid != null) MessageBox.Show(ex.Message, "Error in CAML"); else throw new Exception(Msg, ex); } int Frequency = 7; String FrequencyDBValue = ""; String[] activeFlags = new string[activeFieldsCount]; Object[] objRow = new Object[activeFieldsCount]; int emailDiagCount = 0; foreach (ListItem listItem in collListItem) { Dictionary<String, String> secondaryValues = getSecondaryListData(listConfig._secondaryListName, listItem[listConfig._joinFeeld]); // Dictionary<String, String> secondaryValues = getSecondaryListData("Requests", listItem["RequestID"]); String emailAddress = "unknown"; String emailName = "unknown"; Object obj = listItem[listConfig._UserField]; // go thru and figure out if the data is null.. then we have to either default things and run.. // or bail... architecureal decision if (listItem[listConfig._UserField] == null || listItem[listConfig._UserField].ToString().Length < 1) continue;// no data to process int activeCount = 0; foreach (String af in listConfig._ActiveFields) { if (listItem[af] == null) activeFlags[activeCount++] = "False"; else activeFlags[activeCount++] = listItem[af].ToString(); } foreach (String af in listConfig._secondaryFields) { activeFlags[activeCount++] = secondaryValues[af].ToString(); } if (listItem[listConfig._FrequencyField] == null) Frequency = 7; else { try { SPFieldMultiChoiceValue choices = new SPFieldMultiChoiceValue(listItem[listConfig._FrequencyField].ToString()); if (choices.Count >= 1) { Frequency = Int32.Parse(listConfig._FrequecncyItems[choices[0]]); } FrequencyDBValue = choices[0]; } catch (Exception ex) { Frequency = 7; } } String dteField = listConfig._DateField;// "Created"; if (listItem[listConfig._UserField] != null && listItem[listConfig._UserField].ToString().Length > 0) { FieldUserValue UserName = (FieldUserValue)listItem[listConfig._UserField]; emailName = UserName.LookupValue; emailAddress = getUserEmail(UserName); } String send = "Yes"; Int32 interval = -1; if (dteField != null && listItem[dteField] != null) interval = (DateTime.Parse(dte.ToString("d")) - DateTime.Parse(DateTime.Parse(listItem[dteField].ToString()).ToString("d"))).Days;// add one to make it inclusive of the day it ran on. else { String Msg = @"[Date field is NULL]"; if (dtagrid != null) MessageBox.Show(Msg, "Error in Processing interval"); else throw new Exception(Msg); } if (interval <= 0 || (interval % Frequency) != 0) send = "No"; int gridRowCount = 0; for (gridRowCount = 0; gridRowCount < activeCount; gridRowCount++) { if (activeFlags[gridRowCount] == "False") send = "No"; } // We have all the list item data. if (dtagrid != null) { for (gridRowCount = 0; gridRowCount < activeCount; gridRowCount++) { objRow[gridRowCount] = activeFlags[gridRowCount]; } objRow[gridRowCount++] = emailName + "<" + emailAddress + ">"; objRow[gridRowCount++] = FrequencyDBValue; objRow[gridRowCount++] = interval; objRow[gridRowCount++] = Frequency; objRow[gridRowCount++] = String.Format("{0:MM/dd/yyyy}", dte); objRow[gridRowCount++] = String.Format("{0:MM/dd/yyyy}", listItem[dteField]); objRow[gridRowCount++] = send; dtagrid.Rows.Add(objRow); } if (send.Equals("Yes")) { bool tesetSend = true; if( dtagrid != null) tesetSend = false; if (emailDiagCount++ < 50 && sendTestEmails) { try { String msg = String.Format("To:{0}\nFrom:{1}\nSubject:{2}\nBody:{3}\n", emailAddress, listConfig._emailFrom, replaceText(listConfig._emailSubject, listItem, listConfig._SharePointServerName, secondaryValues), replaceText(listConfig._emailBody, listItem, listConfig._SharePointServerName, secondaryValues)); if (!canceled) { DialogResult dialogResult = MessageBox.Show(msg, "Review #" + emailDiagCount + " Ctrl C to copy - press Okay to send", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.No) { tesetSend = false; } if (dialogResult == DialogResult.Cancel) { canceled = true; tesetSend = false; } } else tesetSend = false; } catch (Exception ex) { String Msg = @"[Email for " + emailAddress + " Failed:" + ex.Message + "]"; MessageBox.Show(ex.Message, "Error on " + emailAddress); } } if (!EmailMgetFileName.Equals("") && tesetSend) { ServerManagement sm = getServerSetup(EmailMgetFileName); try { var decryptor = new RijndaelMessageDecryptor(); SmtpClient client = new SmtpClient(sm._SMTPServerName); //MailAddress from = new MailAddress(emailAddress, listConfig._emailFrom); MailAddress from = new MailAddress(listConfig._emailFrom); // Set destinations for the e-mail message. MailAddress to = new MailAddress(emailAddress); // Specify the message content. MailMessage message = new MailMessage(from, to); message.IsBodyHtml = true; message.Body = replaceText(listConfig._emailBody, listItem, listConfig._SharePointServerName, secondaryValues); message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = replaceText(listConfig._emailSubject, listItem, listConfig._SharePointServerName, secondaryValues); message.SubjectEncoding = System.Text.Encoding.UTF8; client.Credentials = new System.Net.NetworkCredential(sm._SMTPUserId, decryptor.Decrypt(sm._SMTPPwd)); client.Port = Int32.Parse(sm._SMTPPort); client.Send(message); sentRecipients.Add(emailAddress); Console.WriteLine("Email sent for " + to); Console.WriteLine("Subject Line " + message.Subject); } catch (Exception ex) { String Msg = @"[Email for " + emailAddress + " Failed:" + ex.Message + "]"; throw new Exception(Msg, ex); } } } } /// return sentRecipients; }