/
DataHelper.cs
54 lines (43 loc) · 1.26 KB
/
DataHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace PMMP
{
public class DataHelper
{
public static string GetValue(object value)
{
if (value != null)
return value.ToString();
return string.Empty;
}
public static int GetValueAsInteger(object oValue)
{
int value = 0;
if (oValue != null)
value = Convert.ToInt32(oValue.ToString());
return value;
}
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;
}
public static DateTime? GetValueAsDateTime(object oValue)
{
DateTime? value = null;
if (oValue != null)
value = Convert.ToDateTime(oValue);
return value;
}
}
}