Here are the examples of the csharp api System.Convert.ToDateTime(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
604 Examples
19
Source : ViewObject.ascx.cs
with MIT License
from Kentico
with MIT License
from Kentico
protected void WriteDataContainer(IDataContainer dc)
{
StringBuilder sb = new StringBuilder();
sb.Append("<table clreplaced=\"table table-hover\" style=\"margin-top: 16px;\">");
// Add header
sb.AppendFormat("<thead><tr clreplaced=\"unigrid-head\"><th>{0}</th><th clreplaced=\"main-column-100\">{1}</th></tr></thead><tbody>", GetString("General.FieldName"), GetString("General.Value"));
// Add values
foreach (string column in dc.ColumnNames)
{
try
{
object value = dc.GetValue(column);
// Binary columns
string content;
if (value is byte[])
{
byte[] data = (byte[])value;
content = "<" + GetString("General.BinaryData") + ", " + DataHelper.GetSizeString(data.Length) + ">";
}
else
{
content = ValidationHelper.GetString(value, String.Empty);
}
if (!String.IsNullOrEmpty(content))
{
sb.AppendFormat("<tr><td><strong>{0}</strong></td><td clreplaced=\"wrap-normal\">", column);
// Possible DataTime columns
if (value is DateTime)
{
DateTime dateTime = Convert.ToDateTime(content);
CultureInfo cultureInfo = CultureHelper.GetCultureInfo(MembershipContext.AuthenticatedUser.PreferredUICultureCode);
content = dateTime.ToString(cultureInfo);
}
// Process content
ProcessContent(sb, dc, column, ref content);
sb.Append("</td></tr>");
}
}
catch
{
}
}
sb.Append("</tbody></table><br />\n");
pnlContent.Controls.Add(new LiteralControl(sb.ToString()));
}
19
Source : QcDataViz.cs
with Apache License 2.0
from kevinkovalchik
with Apache License 2.0
from kevinkovalchik
private void UpdateChart()
{
int y = 0;
int x = 1;
if ((yMinFixed.Checked && yMinFixedValue.BackColor == Color.Red)
|| yMaxFixed.Checked && yMaxFixedValue.BackColor == Color.Red)
{
return;
}
List<string> selected = new List<string>();
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
//if (!(from x in checkBoxComboBox1.CheckBoxItems select x.Text).Contains(data.ColumnName)) return;
if (checkedListBox1.GereplacedemChecked(i))
{
selected.Add(checkedListBox1.Items[i].ToString());
}
}
var myModel = new PlotModel();
myModel.SetDefaultColorsToColorBrewer8ClreplacedSet2();
myModel.LegendPlacement = LegendPlacement.Outside;
myModel.LegendPosition = LegendPosition.BottomCenter;
myModel.LegendOrientation = LegendOrientation.Horizontal;
if (logYScale.Checked)
{
myModel.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Base = Convert.ToDouble(logYScaleBase.Text) });
}
else
{
myModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
}
if (axisTypeComboBox.Text == "Sequential")
{
foreach (string columnName in selected)
{
var scatter = new ScatterSeries();
scatter.replacedle = columnName;
scatter.MarkerType = MarkerType.Circle;
scatter.MarkerSize = 4.0;
for (int currRow = 0; currRow < QcData.Rows.Count; currRow++)
{
if (String.IsNullOrEmpty(RawFileFilter) ||
QcData.Rows[currRow][RawFilereplacedle].ToString().Contains(RawFileFilter) ||
RawFileFilter == "")
{
scatter.Points.Add(new RawFileDataPoint(currRow + 1, Convert.ToDouble(QcData.Rows[currRow][columnName].ToString()), rawFile: QcData.Rows[currRow][RawFilereplacedle].ToString()));
}
}
myModel.Series.Add(scatter);
}
myModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom});
}
else if (axisTypeComboBox.Text == "Date-Time")
{
DateTimeAxis xAxis = new DateTimeAxis
{
Position = AxisPosition.Bottom,
StringFormat = "yyy-MM-dd_HH:mm",
replacedle = "Acquisition date and time",
MinorIntervalType = DateTimeIntervalType.Auto,
IntervalType = DateTimeIntervalType.Auto,
MajorGridlineStyle = LineStyle.Solid,
MinorGridlineStyle = LineStyle.None,
Angle = 45,
};
foreach (string columnName in selected)
{
var scatter = new ScatterSeries();
scatter.replacedle = columnName;
scatter.MarkerType = MarkerType.Circle;
scatter.MarkerSize = 4.0;
for (int currRow = 0; currRow < QcData.Rows.Count; currRow++)
{
if (String.IsNullOrEmpty(RawFileFilter) ||
QcData.Rows[currRow][RawFilereplacedle].ToString().Contains(RawFileFilter) ||
RawFileFilter == "")
{
scatter.Points.Add(new RawFileDataPoint(DateTimeAxis.ToDouble(Convert.ToDateTime(QcData.Rows[currRow]["DateAcquired"].ToString())), Convert.ToDouble(QcData.Rows[currRow][columnName].ToString()), rawFile: QcData.Rows[currRow][RawFilereplacedle].ToString()));
}
}
myModel.Series.Add(scatter);
}
myModel.Axes.Add(xAxis);
}
else
{
foreach (string columnName in selected)
{
var scatter = new ScatterSeries();
scatter.replacedle = columnName;
scatter.MarkerType = MarkerType.Circle;
scatter.MarkerSize = 4.0;
for (int currRow = 0; currRow < QcData.Rows.Count; currRow++)
{
if (String.IsNullOrEmpty(RawFileFilter) ||
QcData.Rows[currRow][RawFilereplacedle].ToString().Contains(RawFileFilter) ||
RawFileFilter == "")
{
scatter.Points.Add(new RawFileDataPoint(Convert.ToDouble(QcData.Rows[currRow][axisTypeComboBox.Text].ToString()), Convert.ToDouble(QcData.Rows[currRow][columnName].ToString()), rawFile: QcData.Rows[currRow][RawFilereplacedle].ToString()));
}
}
myModel.Series.Add(scatter);
}
myModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
}
for (int i = 0; i < myModel.Axes.Count; i++)
{
myModel.Axes[i].MajorGridlineStyle = LineStyle.Solid;
}
for (int i = 0; i < myModel.Series.Count; i++)
{
myModel.Series[i].TrackerFormatString = "{0}\n{1}: {2:0.###}\n{3}: {4}\nFile: {RawFile}";
}
if (yMinFixed.Checked)
{
myModel.Axes[y].Minimum = Convert.ToDouble(yMinFixedValue.Text);
}
if (yMaxFixed.Checked)
{
myModel.Axes[y].Maximum = Convert.ToDouble(yMaxFixedValue.Text);
}
myModel.Axes[y].IsZoomEnabled = false;
myModel.Axes[y].MinimumPadding = 0.05;
myModel.Axes[y].MaximumPadding = 0.05;
if (!String.IsNullOrEmpty(xAxisLabel.Text)) myModel.Axes[x].replacedle = xAxisLabel.Text;
if (!String.IsNullOrEmpty(yAxisLabel.Text)) myModel.Axes[y].replacedle = yAxisLabel.Text;
this.plotView1.Model = myModel;
}
19
Source : JsonSerializerTest_2368a8e.cs
with Creative Commons Zero v1.0 Universal
from kingsimmy
with Creative Commons Zero v1.0 Universal
from kingsimmy
[Test]
public void ConverterAttributeExample()
{
DateTime date = Convert.ToDateTime("1970-01-01T00:00:00Z").ToUniversalTime();
MemberConverterClreplaced c = new MemberConverterClreplaced
{
DefaultConverter = date,
MemberConverter = date
};
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Console.WriteLine(json);
//{
// "DefaultConverter": "\/Date(0)\/",
// "MemberConverter": "1970-01-01T00:00:00Z"
//}
}
19
Source : PluginChartTime.xaml.cs
with MIT License
from Lacro59
with MIT License
from Lacro59
private void GetActivityForGamesTimeGraphics(GameActivities gameActivities, int variateurTime = 0, int limit = 9)
{
Task.Run(() =>
{
try
{
string[] listDate = new string[limit + 1];
ChartValues<CustomerForTime> series1 = new ChartValues<CustomerForTime>();
ChartValues<CustomerForTime> series2 = new ChartValues<CustomerForTime>();
ChartValues<CustomerForTime> series3 = new ChartValues<CustomerForTime>();
ChartValues<CustomerForTime> series4 = new ChartValues<CustomerForTime>();
ChartValues<CustomerForTime> series5 = new ChartValues<CustomerForTime>();
bool HasData2 = false;
bool HasData3 = false;
bool HasData4 = false;
bool HasData5 = false;
List<Activity> Activities = gameActivities.FilterItems;
// Find last activity date
DateTime dateStart = new DateTime(1982, 12, 15, 0, 0, 0);
for (int iActivity = 0; iActivity < Activities.Count; iActivity++)
{
DateTime dateSession = Convert.ToDateTime(Activities[iActivity].DateSession).ToLocalTime();
if (dateSession > dateStart)
{
dateStart = dateSession;
}
}
dateStart = dateStart.AddDays(variateurTime);
// Periode data showned
for (int i = limit; i >= 0; i--)
{
listDate[(limit - i)] = dateStart.AddDays(-i).ToString("yyyy-MM-dd");
CustomerForTime customerForTime = new CustomerForTime
{
Name = dateStart.AddDays(-i).ToString("yyyy-MM-dd"),
Values = 0
};
series1.Add(customerForTime);
series2.Add(customerForTime);
series3.Add(customerForTime);
series4.Add(customerForTime);
series5.Add(customerForTime);
}
LocalDateConverter localDateConverter = new LocalDateConverter();
// Search data in periode
for (int iActivity = 0; iActivity < Activities.Count; iActivity++)
{
ulong elapsedSeconds = Activities[iActivity].ElapsedSeconds;
string dateSession = Convert.ToDateTime(Activities[iActivity].DateSession).ToLocalTime().ToString("yyyy-MM-dd");
//for (int iDay = 0; iDay < 10; iDay++)
for (int iDay = limit; iDay >= 0; iDay--)
{
if (listDate[iDay] == dateSession)
{
string tempName = series1[iDay].Name;
try
{
tempName = (string)localDateConverter.Convert(DateTime.ParseExact(series1[iDay].Name, "yyyy-MM-dd", null), null, null, CultureInfo.CurrentCulture);
}
catch
{
}
if (PluginDatabase.PluginSettings.Settings.replacedulPlaytimeSession)
{
series1[iDay] = new CustomerForTime
{
Name = tempName,
Values = series1[iDay].Values + (long)elapsedSeconds,
};
continue;
}
else
{
if (series1[iDay].Values == 0)
{
series1[iDay] = new CustomerForTime
{
Name = tempName,
Values = (long)elapsedSeconds,
};
continue;
}
if (series2[iDay].Values == 0)
{
HasData2 = true;
series2[iDay] = new CustomerForTime
{
Name = tempName,
Values = (long)elapsedSeconds,
};
continue;
}
if (series3[iDay].Values == 0)
{
HasData3 = true;
series3[iDay] = new CustomerForTime
{
Name = tempName,
Values = (long)elapsedSeconds,
};
continue;
}
if (series4[iDay].Values == 0)
{
HasData4 = true;
series4[iDay] = new CustomerForTime
{
Name = tempName,
Values = (long)elapsedSeconds,
};
continue;
}
if (series5[iDay].Values == 0)
{
HasData5 = true;
series5[iDay] = new CustomerForTime
{
Name = tempName,
Values = (long)elapsedSeconds,
};
continue;
}
}
}
}
}
this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(delegate
{
// Set data in graphic.
SeriesCollection activityForGameSeries = new SeriesCollection();
activityForGameSeries.Add(new ColumnSeries { replacedle = "1", Values = series1 });
if (HasData2)
{
activityForGameSeries.Add(new ColumnSeries { replacedle = "2", Values = series2 });
}
if (HasData3)
{
activityForGameSeries.Add(new ColumnSeries { replacedle = "3", Values = series3 });
}
if (HasData4)
{
activityForGameSeries.Add(new ColumnSeries { replacedle = "4", Values = series4 });
}
if (HasData5)
{
activityForGameSeries.Add(new ColumnSeries { replacedle = "5", Values = series5 });
}
for (int iDay = 0; iDay < listDate.Length; iDay++)
{
listDate[iDay] = Convert.ToDateTime(listDate[iDay]).ToString(Constants.DateUiFormat);
}
string[] activityForGameLabels = listDate;
//let create a mapper so LiveCharts know how to plot our CustomerViewModel clreplaced
var customerVmMapper = Mappers.Xy<CustomerForTime>()
.X((value, index) => index)
.Y(value => value.Values);
//lets save the mapper globally
Charting.For<CustomerForTime>(customerVmMapper);
PlayTimeToStringConverter converter = new PlayTimeToStringConverter();
Func<double, string> activityForGameLogFormatter = value => (string)converter.Convert((ulong)value, null, null, CultureInfo.CurrentCulture);
PART_ChartTimeActivityLabelsY.LabelFormatter = activityForGameLogFormatter;
if (PluginDatabase.PluginSettings.Settings.replacedulPlaytimeSession)
{
PART_ChartTimeActivity.DataTooltip = new CustomerToolTipForTime
{
ShowIcon = PluginDatabase.PluginSettings.Settings.ShowLauncherIcons,
Mode = (PluginDatabase.PluginSettings.Settings.ModeStoreIcon == 1) ? TextBlockWithIconMode.IconTextFirstWithText : TextBlockWithIconMode.IconFirstWithText
};
}
else
{
PART_ChartTimeActivity.DataTooltip = new CustomerToolTipForMultipleTime { Showreplacedle = false };
}
PART_ChartTimeActivityLabelsY.MinValue = 0;
PART_ChartTimeActivity.Series = activityForGameSeries;
PART_ChartTimeActivityLabelsX.Labels = activityForGameLabels;
}));
}
catch (Exception ex)
{
Common.LogError(ex, false, true, "GameActivity");
}
});
}
19
Source : RetroAchievements.cs
with MIT License
from Lacro59
with MIT License
from Lacro59
private List<Achievements> GetGameInfoAndUserProgress(int gameID)
{
List<Achievements> Achievements = new List<Achievements>();
string Target = "API_GetGameInfoAndUserProgress.php";
UrlAchievements = string.Format(BaseUrl + Target + @"?z={0}&y={1}&u={0}&g={2}", User, Key, gameID);
string ResultWeb = string.Empty;
try
{
ResultWeb = Web.DownloadStringData(UrlAchievements).GetAwaiter().GetResult();
}
catch (WebException ex)
{
Common.LogError(ex, false, $"Failed to load from {UrlAchievements}", true, "SuccessStory");
return Achievements;
}
try
{
dynamic resultObj = Serialization.FromJson<dynamic>(ResultWeb);
GameNameAchievements = (string)resultObj["replacedle"];
int NumDistinctPlayersCasual = (int)resultObj["NumDistinctPlayersCasual"];
if (resultObj["Achievements"] != null)
{
foreach (var item in resultObj["Achievements"])
{
foreach (var it in item)
{
Achievements.Add(new Achievements
{
Name = (string)it["replacedle"],
Description = (string)it["Description"],
UrlLocked = string.Format(BaseUrlLocked, (string)it["BadgeName"]),
UrlUnlocked = string.Format(BaseUrlUnlocked, (string)it["BadgeName"]),
DateUnlocked = (it["DateEarned"] == null) ? default(DateTime) : Convert.ToDateTime((string)it["DateEarned"]),
Percent = (int)it["NumAwarded"] * 100 / NumDistinctPlayersCasual
});
}
}
}
}
catch (Exception ex)
{
Common.LogError(ex, false, $"[{gameID}] Failed to parse {ResultWeb}", true, "SuccessStory");
return Achievements;
}
return Achievements;
}
19
Source : TypeParse.cs
with GNU General Public License v2.0
from lfz233002072
with GNU General Public License v2.0
from lfz233002072
public static DateTime StrToDateTime(string strValue, DateTime defValue)
{
if (strValue == null) return defValue;
try
{
return Convert.ToDateTime(strValue);
}
catch
{
return defValue;
}
}
19
Source : ActionAppService.cs
with MIT License
from liuhll
with MIT License
from liuhll
private DateTime? GetDevDate(string dateStr)
{
if (dateStr.IsNullOrEmpty()) return null;
return Convert.ToDateTime(dateStr);
}
19
Source : 02-Like.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task Like_ST()
{
xx = string.Empty;
// like
var res1 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.And(it => it.PathId.Contains("~00-d-3-1-"))
.QueryPagingAsync(1, 10);
replacedert.True(res1.TotalCount == 5680);
/************************************************************************************************************/
xx = string.Empty;
}
19
Source : 07-GreaterThan.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task GreaterThan()
{
xx = string.Empty;
// > --> >
var res1 = await MyDAL_TestDB.QueryListAsync<Agent>(it => it.CreatedOn > Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30));
replacedert.True(res1.Count == 28619);
xx = string.Empty;
}
19
Source : 01-CreateAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task History_01()
{
/********************************************************************************************************************************/
var m2 = new Agent
{
Id = Guid.NewGuid(),
CreatedOn = DateTime.Now,
UserId = Guid.NewGuid(),
PathId = "x-xx-xxx-xxxx",
Name = "张三",
Phone = "18088889999",
IdCardNo = "No.12345",
CrmUserId = "yyyyy",
AgentLevel = AgentLevel.DistiAgent,
ActivedOn = null, // DateTime?
ActiveOrderId = null, // Guid?
DirectorStarCount = 5
};
xx = string.Empty;
var res2 = await MyDAL_TestDB.CreateAsync(m2);
replacedert.True(res2 == 1);
/********************************************************************************************************************************/
xx = string.Empty;
var res5 = await MyDAL_TestDB.CreateAsync(new Agent
{
Id = Guid.NewGuid(),
CreatedOn = Convert.ToDateTime("2018-10-07 17:02:05"),
UserId = Guid.NewGuid(),
PathId = "xx-yy-zz-mm-nn",
Name = "meng-net",
Phone = "17600000000",
IdCardNo = "876987698798",
CrmUserId = Guid.NewGuid().ToString(),
AgentLevel = null,
ActivedOn = null,
ActiveOrderId = null,
DirectorStarCount = 1
});
/********************************************************************************************************************************/
xx = string.Empty;
await ClearData6();
var m6 = new Agent
{
Id = Guid.Parse("ea1ad309-56f7-4e3e-af12-0165c9121e9b"),
CreatedOn = Convert.ToDateTime("2018-10-07 17:02:05"),
UserId = Guid.NewGuid(),
PathId = "xx-yy-zz-mm-nn",
Name = "meng-net",
Phone = "17600000000",
IdCardNo = "876987698798",
CrmUserId = Guid.NewGuid().ToString(),
AgentLevel = AgentLevel.DistiAgent,
ActivedOn = null,
ActiveOrderId = null,
DirectorStarCount = 1
};
var res6 = await MyDAL_TestDB.CreateAsync(m6);
var res61 = await MyDAL_TestDB.QueryOneAsync<Agent>(it => it.Id == Guid.Parse("ea1ad309-56f7-4e3e-af12-0165c9121e9b"));
replacedert.True(res61.AgentLevel == AgentLevel.DistiAgent);
/********************************************************************************************************************************/
xx = string.Empty;
await ClearData7();
var m7 = new Agent
{
Id = Guid.Parse("08d60369-4fc1-e8e0-44dc-435f31635e6d"),
CreatedOn = Convert.ToDateTime("2018-08-16 19:34:25.116759"),
UserId = Guid.NewGuid(),
PathId = "xx-yy-zz-mm-nn",
Name = "meng-net",
Phone = "17600000000",
IdCardNo = "876987698798",
CrmUserId = Guid.NewGuid().ToString(),
AgentLevel = AgentLevel.DistiAgent,
ActivedOn = null,
ActiveOrderId = null,
DirectorStarCount = 1
};
var res7 = await MyDAL_TestDB.CreateAsync(m7);
var res71 = await MyDAL_TestDB.QueryOneAsync<Agent>(it => it.Id == Guid.Parse("08d60369-4fc1-e8e0-44dc-435f31635e6d"));
replacedert.True(res71.CreatedOn == Convert.ToDateTime("2018-08-16 19:34:25.116759"));
/********************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 02-QueryListAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryVM_ST()
{
xx = string.Empty;
var res5 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.QueryListAsync<AgentVM>();
replacedert.True(res5.Count == 28619);
replacedert.NotNull(res5.First().Name);
replacedert.Null(res5.First().XXXX);
/********************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 07-SumAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task Sum_ST()
{
xx = string.Empty;
var res1 = await MyDAL_TestDB
.Queryer<AlipayPaymentRecord>()
.Where(it => it.CreatedOn > Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.SumAsync(it => it.TotalAmount);
replacedert.True(res1 == 1527.2600000000000000000000000M);
xx = string.Empty;
}
19
Source : 01-UpdateAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task History_02()
{
xx = string.Empty;
// set field 2
var res2 = await MyDAL_TestDB
.Updater<AgentInventoryRecord>()
.Set(it => it.LockedCount, 100)
.Where(it => it.AgentId == Guid.Parse("0ce552c0-2f5e-4c22-b26d-01654443b30e"))
.Or(it => it.CreatedOn == Convert.ToDateTime("2018-08-19 11:34:42.577074"))
.UpdateAsync();
replacedert.True(res2 == 2);
/***************************************************************************************************************************/
xx = string.Empty;
var resx6 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Id == Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"))
.QueryOneAsync();
resx6.ActivedOn = null;
// update set null
var res6 = await MyDAL_TestDB
.Updater<Agent>()
.Set(it => it.ActivedOn, resx6.ActivedOn)
.Where(it => it.Id == resx6.Id)
.UpdateAsync();
replacedert.True(res6 == 1);
/***************************************************************************************************************************/
xx = string.Empty;
var guid7 = Guid.Parse("b3866d7c-2b51-46ae-85cb-0165c9121e8f");
var resxxx7 = await MyDAL_TestDB
.Updater<Product>()
.Set(it => it.VipProduct, false)
.Where(it => it.Id == guid7)
.UpdateAsync();
var resx7 = await MyDAL_TestDB
.Queryer<Product>()
.Where(it => it.Id == guid7)
.QueryOneAsync();
replacedert.NotNull(resx7);
replacedert.False(resx7.VipProduct);
resx7.VipProduct = true;
// update set bool bit
var res7 = await MyDAL_TestDB
.Updater<Product>()
.Set(it => it.VipProduct, resx7.VipProduct)
.Where(it => it.Id == resx7.Id)
.UpdateAsync();
replacedert.True(res7 == 1);
var resxx7 = await MyDAL_TestDB
.Queryer<Product>()
.Where(it => it.Id == guid7)
.QueryOneAsync();
replacedert.True(resxx7.VipProduct);
/***************************************************************************************************************************/
xx = string.Empty;
var res8 = await MyDAL_TestDB
.Updater<Agent>()
.Set(it => it.AgentLevel, AgentLevel.NewCustomer)
.Where(it => it.Id == Guid.Parse("0014f62d-2a96-4b5b-b4bd-01654438e3d4"))
.UpdateAsync();
var res81 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Id == Guid.Parse("0014f62d-2a96-4b5b-b4bd-01654438e3d4"))
.QueryOneAsync();
replacedert.True(res81.AgentLevel == AgentLevel.NewCustomer);
/***************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 02-WhereReverse.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task test()
{
/********************************************************************************************************************************/
xx = string.Empty;
// >= obj.DateTime
var res1 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.QueryListAsync();
var resR1 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30) <= it.CreatedOn)
.QueryListAsync();
replacedert.True(res1.Count == resR1.Count);
/********************************************************************************************************************************/
xx = string.Empty;
var start = Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30).AddDays(-10);
// >= variable(DateTime)
var res2 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => it.CreatedOn >= start)
.QueryListAsync();
var resR2 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => start <= it.CreatedOn)
.QueryListAsync();
replacedert.True(res2.Count == resR2.Count);
/********************************************************************************************************************************/
var xx3 = string.Empty;
// <= DateTime
var res3 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => it.CreatedOn <= DateTime.Now)
.QueryListAsync();
var resR3 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => DateTime.Now >= it.CreatedOn)
.QueryListAsync();
replacedert.True(res3.Count == resR3.Count);
/********************************************************************************************************************************/
}
19
Source : 07-MemoryTest.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task Test()
{
xx = string.Empty;
for (var i = 0; i < 100; i++)
{
var name = "张";
var res = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name.Contains($"{name}%") && it.CreatedOn > Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30) || it.AgentLevel == AgentLevel.DistiAgent)
.QueryListAsync();
replacedert.True(res.Count == 2506);
Thread.Sleep(5);
}
xx = string.Empty;
}
19
Source : 08-WhereDollarString.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task test()
{
xx = string.Empty;
var res1 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name == $"{"樊士芹"}")
.QueryOneAsync();
replacedert.NotNull(res1);
/*******************************************************************************************************************/
xx = string.Empty;
var name2 = "樊士芹";
var res2 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name == $"{name2}")
.QueryOneAsync();
replacedert.NotNull(res2);
/*******************************************************************************************************************/
xx = string.Empty;
var res3 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn > DateTime.Parse($"{Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30).AddDays(-10)}"))
.QueryListAsync();
replacedert.NotNull(res3);
replacedert.True(res3.Count == 28619);
/*******************************************************************************************************************/
xx = string.Empty;
var name4 = "张";
var res4 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name.Contains($"{name4}%"))
.QueryListAsync();
replacedert.NotNull(res4);
replacedert.True(res4.Count == 1996);
/*******************************************************************************************************************/
xx = string.Empty;
var res5 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.PathId.Contains($"{WhereTest.ContainStr2}%"))
.QueryListAsync();
replacedert.NotNull(res5);
replacedert.True(res5.Count == 20016);
/*******************************************************************************************************************/
xx = string.Empty;
var like61 = "李";
var like62 = "张";
var res6 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name.Contains($"{like61}%") || it.Name.Contains($"{like62}%"))
.QueryListAsync();
var res61 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name.Contains($"{like61}%"))
.QueryListAsync();
var res62 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.Name.Contains($"{like62}%"))
.QueryListAsync();
replacedert.True(res61.Count != 0);
replacedert.True(res62.Count != 0);
replacedert.True(res6.Count == res61.Count + res62.Count);
/*******************************************************************************************************************/
xx = string.Empty;
}
19
Source : 07-GreaterThan.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task NotGreaterThan()
{
xx = string.Empty;
// !(>) --> <=
var res1 = await MyDAL_TestDB.QueryListAsync<Agent>(it => !(it.CreatedOn > Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30)));
replacedert.True(res1.Count == 1);
/******************************************************************************************************************************************************/
xx = string.Empty;
// <= --> <=
var res2 = await MyDAL_TestDB.QueryListAsync<Agent>(it => it.CreatedOn <= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30));
replacedert.True(res2.Count == 1);
/******************************************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 08-GreaterThanOrEqual.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task GreaterThanOrEqual()
{
xx = string.Empty;
// >= --> >=
var res1 = await MyDAL_TestDB
.Queryer(out Agent agent1, out AgentInventoryRecord record1)
.From(() => agent1)
.InnerJoin(() => record1)
.On(() => agent1.Id == record1.AgentId)
.Where(() => agent1.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-90))
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res1.Count == 574);
xx = string.Empty;
}
19
Source : 08-GreaterThanOrEqual.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task NotGreaterThanOrEqual()
{
xx = string.Empty;
// !(>=) --> <
var res1 = await MyDAL_TestDB
.Queryer(out Agent agent1, out AgentInventoryRecord record1)
.From(() => agent1)
.InnerJoin(() => record1)
.On(() => agent1.Id == record1.AgentId)
.Where(() => !(agent1.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-90)))
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res1.Count == 0);
/******************************************************************************************************************************/
xx = string.Empty;
// < --> <
var res2 = await MyDAL_TestDB
.Queryer(out Agent agent2, out AgentInventoryRecord record2)
.From(() => agent2)
.InnerJoin(() => record2)
.On(() => agent2.Id == record2.AgentId)
.Where(() => agent2.CreatedOn < Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-90))
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res2.Count == 0);
/******************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 01-QueryOneAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryM_ST()
{
xx = string.Empty;
//
var res4 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.And(it => it.Id == Guid.Parse("000c1569-a6f7-4140-89a7-0165443b5a4b"))
.QueryOneAsync();
replacedert.NotNull(res4);
/****************************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 02-QueryListAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task History_06()
{
var m = await PreData01();
var name = "辛文丽";
var level = 128;
/**************************************************************************************************************************/
xx = string.Empty;
//
var res2 = await MyDAL_TestDB
.Queryer(out Agent agent2, out AgentInventoryRecord record2)
.From(() => agent2)
.InnerJoin(() => record2)
.On(() => agent2.Id == record2.AgentId)
.Where(() => agent2.CreatedOn >= Convert.ToDateTime("2018-08-16 19:20:28.118853")) // const method DateTime >=
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res2.Count == 523);
/**************************************************************************************************************************/
xx = string.Empty;
//
var res3 = await MyDAL_TestDB
.Queryer(out Agent agent3, out AgentInventoryRecord record3)
.From(() => agent3)
.InnerJoin(() => record3)
.On(() => agent3.Id == record3.AgentId)
.Where(() => record3.AgentId == Guid.Parse("544b9053-322e-4857-89a0-0165443dcbef")) // const method Guid ==
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res3.Count == 1);
replacedert.Equal(res3.First().Id, Guid.Parse("02dbc81c-5c9a-4cdf-8bf0-016551f756c4"));
/**************************************************************************************************************************/
xx = string.Empty;
//
var res4 = await MyDAL_TestDB
.Queryer(out Agent agent4, out AgentInventoryRecord record4)
.From(() => agent4)
.InnerJoin(() => record4)
.On(() => agent4.Id == record4.AgentId)
.Where(() => agent4.Name == "辛文丽") // const string ==
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res4.Count == 1);
/**************************************************************************************************************************/
xx = string.Empty;
//
var res5 = await MyDAL_TestDB.OpenDebug()
.Queryer(out Agent agent5, out AgentInventoryRecord record5)
.From(() => agent5)
.InnerJoin(() => record5)
.On(() => agent5.Id == record5.AgentId)
.Where(() => agent5.AgentLevel == AgentLevel.DistiAgent) // const enum ==
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res5.Count == 574);
/**************************************************************************************************************************/
xx = string.Empty;
//
var res6 = await MyDAL_TestDB
.Queryer(out Agent agent6, out AgentInventoryRecord record6)
.From(() => agent6)
.InnerJoin(() => record6)
.On(() => agent6.Id == record6.AgentId)
.Where(() => agent6.Id == m.Id) // virable prop Guid ==
.QueryListAsync<Agent>();
replacedert.True(res6.Count == 1);
replacedert.Equal(res6.First().Id, Guid.Parse("0ce552c0-2f5e-4c22-b26d-01654443b30e"));
/**************************************************************************************************************************/
xx = string.Empty;
//
var res7 = await MyDAL_TestDB
.Queryer(out Agent agent7, out AgentInventoryRecord record7)
.From(() => agent7)
.InnerJoin(() => record7)
.On(() => agent7.Id == record7.AgentId)
.Where(() => agent7.Name == name) // virable string ==
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res7.Count == 1);
/**************************************************************************************************************************/
xx = string.Empty;
//
var res8 = await MyDAL_TestDB
.Queryer(out Agent agent8, out AgentInventoryRecord record8)
.From(() => agent8)
.InnerJoin(() => record8)
.On(() => agent8.Id == record8.AgentId)
.Where(() => agent8.AgentLevel == (AgentLevel)level) // virable enum ==
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res8.Count == 574);
/**************************************************************************************************************************/
xx = string.Empty;
//
var res9 = await MyDAL_TestDB
.Queryer(out Agent agent9, out AgentInventoryRecord record9)
.From(() => agent9)
.InnerJoin(() => record9)
.On(() => agent9.Id == record9.AgentId)
.Where(() => agent9.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30)) // prop prop DateTime >=
.QueryListAsync<AgentInventoryRecord>();
replacedert.True(res9.Count == 574);
/**************************************************************************************************************************/
xx = string.Empty;
var res10 = await MyDAL_TestDB
.Queryer(out Agent agent10, out AgentInventoryRecord record10)
.From(() => agent10)
.InnerJoin(() => record10)
.On(() => agent10.Id == record10.AgentId)
.Where(() => agent10.Id == Guid.Parse("544b9053-322e-4857-89a0-0165443dcbef"))
.And(() => record10.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30).AddDays(-60))
.QueryListAsync<Agent>();
replacedert.True(res10.Count == 1);
/**************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 02-Like.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task History()
{
/************************************************************************************************************/
await Pre01();
xx = string.Empty;
// 默认 "%"+"xx"+"%"
var res1 = await MyDAL_TestDB.QueryOneAsync<BodyFitRecord>(it => it.BodyMeasureProperty.Contains("xx"));
replacedert.NotNull(res1);
/************************************************************************************************************/
xx = string.Empty;
// 默认 "%"+"~00-d-3-1-"+"%"
var res3 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.And(it => it.PathId.Contains("~00-d-3-1-"))
.QueryPagingAsync(1, 10);
replacedert.True(res3.TotalCount == 5680);
/************************************************************************************************************/
}
19
Source : 02-QueryListAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryM_ST()
{
xx = string.Empty;
var res4 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.QueryListAsync();
replacedert.True(res4.Count == 28619);
/********************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 02-QueryListAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryVMColumn_MT()
{
xx = string.Empty;
var res1 = await MyDAL_TestDB
.Queryer(out Agent agent, out AgentInventoryRecord record)
.From(() => agent)
.InnerJoin(() => record)
.On(() => agent.Id == record.AgentId)
.Where(() => record.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.QueryListAsync(() => new AgentVM
{
nn = agent.PathId,
yy = record.Id,
xx = agent.Id,
zz = agent.Name,
mm = record.LockedCount
});
replacedert.True(res1.Count == 574);
replacedert.True("~00-d-3-2-1-c-2-1a-1" == res1.First().nn);
/*************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 02-QueryListAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryVM_SQL()
{
xx = string.Empty;
var sql = @"
select agent12.`PathId` as nn,
record12.`Id` as yy,
agent12.`Id` as xx,
agent12.`Name` as zz,
record12.`LockedCount` as mm
from `agent` as agent12
inner join `agentinventoryrecord` as record12
on agent12.`Id`=record12.`AgentId`
where record12.`CreatedOn`>=@CreatedOn;
";
var param = new List<XParam>
{
new XParam{ParamName="@CreatedOn",ParamValue=Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30),ParamType= ParamTypeEnum.DateTime_MySQL_SqlServer}
};
var res1 = await MyDAL_TestDB.QueryListAsync<AgentVM>(sql, param);
replacedert.True(res1.Count == 574);
replacedert.True("~00-d-3-2-1-c-2-1a-1" == res1.First().nn);
xx = string.Empty;
}
19
Source : 03-QueryPagingAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryVM_ST()
{
xx = string.Empty;
var res6 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.QueryPagingAsync<AgentVM>(1, 10);
var resR6 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30) <= it.CreatedOn)
.QueryPagingAsync<AgentVM>(1, 10);
replacedert.True(res6.TotalCount == resR6.TotalCount);
replacedert.True(res6.TotalCount == 28619);
/*************************************************************************************************************************/
xx = string.Empty;
}
19
Source : 03-QueryPagingAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task QueryVmColumn_ST()
{
xx = string.Empty;
var res8 = await MyDAL_TestDB
.Queryer<Agent>()
.Where(it => it.CreatedOn >= Convert.ToDateTime("2018-08-23 13:36:58").AddDays(-30))
.QueryPagingAsync(1, 10, agent => new AgentVM
{
XXXX = agent.Name,
YYYY = agent.PathId
});
replacedert.True(res8.TotalCount == 28619);
/*************************************************************************************************************************/
}
19
Source : StringEx.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
public static DateTime ToDateTime(this string str)
{
try
{
if (str.IsNullStr())
{
throw XConfig.EC.Exception(XConfig.EC._115, $"DateTime ToDateTime(this object obj) -- 参数 str 为 null !!!");
}
return Convert.ToDateTime(str);
}
catch (Exception ex)
{
throw XConfig.EC.Exception(XConfig.EC._114, $"DateTime ToDateTime(this object obj) -- {str?.ToString()},InnerExeception:{ex.Message}");
}
}
19
Source : 01-QueryOneAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
private async Task<BodyFitRecord> PreQuery()
{
var m = new BodyFitRecord
{
Id = Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"),
CreatedOn = Convert.ToDateTime("2018-08-23 13:36:58"),
UserId = Guid.NewGuid(),
BodyMeasureProperty = "xxxx"
};
// 清理数据
var resd = await MyDAL_TestDB.DeleteAsync<BodyFitRecord>(it => it.Id == m.Id);
// 造数据
var resc = await MyDAL_TestDB.CreateAsync(m);
return m;
}
19
Source : 01-QueryOneAsync.cs
with Apache License 2.0
from liumeng0403
with Apache License 2.0
from liumeng0403
[Fact]
public async Task History_01()
{
await PreQuery();
/****************************************************************************************************************************************/
xx = string.Empty;
// == Guid
var res1 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => it.Id == Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"))
.QueryOneAsync();
replacedert.NotNull(res1);
var resR1 = await MyDAL_TestDB.OpenDebug()
.Queryer<BodyFitRecord>()
.Where(it => Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e") == it.Id)
.QueryOneAsync();
replacedert.NotNull(resR1);
replacedert.True(res1.Id == resR1.Id);
/****************************************************************************************************************************************/
xx = string.Empty;
// == DateTime
var res2 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => it.CreatedOn == Convert.ToDateTime("2018-08-23 13:36:58"))
.QueryOneAsync();
replacedert.NotNull(res2);
var resR2 = await MyDAL_TestDB.OpenDebug()
.Queryer<BodyFitRecord>()
.Where(it => Convert.ToDateTime("2018-08-23 13:36:58") == it.CreatedOn)
.QueryOneAsync();
replacedert.NotNull(resR2);
replacedert.True(res2.Id == resR2.Id);
/****************************************************************************************************************************************/
xx = string.Empty;
// == string
var res3 = await MyDAL_TestDB
.Queryer<BodyFitRecord>()
.Where(it => it.BodyMeasureProperty == "xxxx")
.QueryOneAsync();
replacedert.NotNull(res3);
var resR3 = await MyDAL_TestDB.OpenDebug()
.Queryer<BodyFitRecord>()
.Where(it => "xxxx" == it.BodyMeasureProperty)
.QueryOneAsync();
replacedert.NotNull(resR3);
replacedert.True(res3.Id == resR3.Id);
/****************************************************************************************************************************************/
xx = string.Empty;
}
19
Source : LicenseRouter.cs
with GNU General Public License v3.0
from logicpulse
with GNU General Public License v3.0
from logicpulse
public static void GetLicenceInfo()
{
if (GlobalFramework.DtLicenceKeys == null)
{
GlobalFramework.DtLicenceKeys = new DataTable("keysLicence");
GlobalFramework.DtLicenceKeys.Columns.Add("name", typeof(string));
GlobalFramework.DtLicenceKeys.Columns.Add("value", typeof(string));
}
GlobalFramework.DtLicenceKeys.Rows.Clear();
GlobalFramework.LicenceDate = DateTime.Now.ToString("dd/MM/yyyy");
GlobalFramework.LicenceVersion = "LOGICPOS_LICENSED";
GlobalFramework.LicenceName = "Nome DEMO";
GlobalFramework.LicenceCompany = "Empresa DEMO";
GlobalFramework.LicenceNif = "NIF DEMO";
GlobalFramework.LicenceAddress = "Morada DEMO";
GlobalFramework.LicenceEmail = "Email DEMO";
GlobalFramework.LicenceTelephone = "Telefone DEMO";
GlobalFramework.LicenceReseller = "LogicPulse";
GlobalFramework.ServerVersion = "1.0";
GlobalFramework.LicenceUpdateDate = DateTime.Now.AddDays(-1);
#if DEBUG
GlobalFramework.LicenceVersion = "LOGICPOS_CORPORATE";
GlobalFramework.LicenceName = "DEBUG";
GlobalFramework.LicenceCompany = "DEBUG";
GlobalFramework.LicenceAddress = "DEBUG";
GlobalFramework.LicenceEmail = "DEBUG";
GlobalFramework.LicenceTelephone = "DEBUG";
GlobalFramework.LicenceModuleStocks = true;
GlobalFramework.LicenceReseller = "Logicpulse";
#endif
SortedList sortedList = GlobalFramework.PluginLicenceManager.GetLicenseInformation();
GlobalFramework.ServerVersion = GlobalFramework.PluginLicenceManager.GetCurrentVersion();
//GlobalFramework.ServerVersion = "2.0.0.0";
if (showDebug)
{
_log.Debug("licence info count:" + sortedList.Count.ToString());
}
for (int i = 0; i < sortedList.Count; i++)
{
string key = sortedList.GetKey(i).ToString();
string value = sortedList.GetByIndex(i).ToString();
_log.Debug("Licence Key:" + key + "=" + value);
GlobalFramework.DtLicenceKeys.Rows.Add(key, value);
switch (key)
{
case "version":
GlobalFramework.LicenceVersion = value;
break;
case "data":
GlobalFramework.LicenceDate = value;
break;
case "name":
GlobalFramework.LicenceName = value;
break;
case "company":
GlobalFramework.LicenceCompany = value;
break;
case "nif":
GlobalFramework.LicenceNif = value;
break;
case "adress":
GlobalFramework.LicenceAddress = value;
break;
case "email":
GlobalFramework.LicenceEmail = value;
break;
case "telefone":
GlobalFramework.LicenceTelephone = value;
break;
case "reseller":
GlobalFramework.LicenceReseller = value;
SettingsApp.AppCompanyName = value;
break;
case "logicpos_Module_Stocks":
GlobalFramework.LicenceModuleStocks = Convert.ToBoolean(value);
break;
case "all_UpdateExpirationDate":
GlobalFramework.LicenceUpdateDate = Convert.ToDateTime(value);
break;
default:
break;
}
}
}
19
Source : ProcessFinanceDocumentSeries.cs
with GNU General Public License v3.0
from logicpulse
with GNU General Public License v3.0
from logicpulse
private static DateTime AcronymPrefixToDate(int pYear, string pInput)
{
try
{
long baseX = Base36To10(pInput);
string uintString = Convert.ToString(baseX);
//#1 - Always Remove First 1;
uintString = uintString.Substring(1, uintString.Length - 1);
string date = string.Format(
_acronymDateTimeFormat,
uintString.Substring(0 * 2, 2),//hour
uintString.Substring(1 * 2, 2),//minute
uintString.Substring(2 * 2, 2),//second
uintString.Substring(3 * 2, 2),//day
uintString.Substring(4 * 2, 2) //month
);
date = date.Replace("YYYY", pYear.ToString());
return Convert.ToDateTime(date);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message, ex);
return new DateTime();
}
}
19
Source : PublishTaskSqlServerHelper.cs
with Apache License 2.0
from lsamu
with Apache License 2.0
from lsamu
public List<ModelPublireplacedem> GetDataList(string keyword, int topNum) {
List<ModelPublireplacedem> LItem = new List<ModelPublireplacedem>();
string SQLKeyword = string.Empty;
//ƴ��SQL���
SqlParameter[] parameter = {
new SqlParameter("@SQLKeyword",SqlDbType.VarChar,500),
new SqlParameter("@TopNum",SqlDbType.Int,4),
};
parameter[0].Value = SQLKeyword;
parameter[1].Value = topNum;
DataSet ds = DbHelperSQL.RunProcedure("[dbo].[Pro_GetArtileList]", parameter, "ds");
if (ds != null && ds.Tables[0].Rows.Count > 0) {
foreach (DataRow dr in ds.Tables[0].Rows) {
ModelPublireplacedem model = new ModelPublireplacedem();
model.replacedle = dr["replacedle"].ToString();
model.Content = dr["Content"].ToString();
model.Abstract = dr["Abstract"].ToString();
model.Url = dr["Url"].ToString();
model.Time = Convert.ToDateTime(dr["AddDateTime"].ToString());
LItem.Add(model);
}
}
return LItem;
}
19
Source : Html2Article.cs
with Apache License 2.0
from lsamu
with Apache License 2.0
from lsamu
private static DateTime GetPublishDate(string html) {
string text = Regex.Replace(html, "(?is)<.*?>", "");
Match match = Regex.Match(
text,
@"((\d{4}|\d{2})(\-|\/)\d{1,2}\3\d{1,2})(\s?\d{2}:\d{2})?|(\d{4}��\d{1,2}��\d{1,2}��)(\s?\d{2}:\d{2})?",
RegexOptions.IgnoreCase);
DateTime result = new DateTime(1900, 1, 1);
if (match.Success) {
try {
string dateStr = "";
for (int i = 0; i < match.Groups.Count; i++) {
dateStr = match.Groups[i].Value;
if (!String.IsNullOrEmpty(dateStr)) {
break;
}
}
if (dateStr.Contains("��")) {
StringBuilder sb = new StringBuilder();
foreach (var ch in dateStr) {
if (ch == '��' || ch == '��') {
sb.Append("/");
continue;
}
if (ch == '��') {
sb.Append(' ');
continue;
}
sb.Append(ch);
}
dateStr = sb.ToString();
}
result = Convert.ToDateTime(dateStr);
}
catch (Exception) { }
if (result.Year < 1900) {
result = new DateTime(1900, 1, 1);
}
}
return result;
}
19
Source : Extensions.cs
with GNU General Public License v3.0
from luissanches
with GNU General Public License v3.0
from luissanches
public static DateTime ToDateTime(this string value)
{
return Convert.ToDateTime(value);
}
19
Source : DashboardController.cs
with MIT License
from manier13579
with MIT License
from manier13579
[ActionName("chartOld")]
public HttpResponseMessage ChartOld([FromBody] DashboardAjax ajaxData)
{
Db db = new Db();
string sql = @"
SELECT
A.COUNT,
A.DELIVERY_DATE,
ADD_MONTHS(A.DELIVERY_DATE,12*B.SERVICE_YEAR) AS SERVICE_DATE,
ADD_MONTHS(A.DELIVERY_DATE,12*" + ajaxData.oldBenchmark + @") AS OLD_DATE
FROM GDMS_DEV_MAIN A
LEFT JOIN GDMS_STYLE B ON A.STYLE_ID = B.ID
LEFT JOIN GDMS_TYPE C ON B.TYPE_ID = C.ID
LEFT JOIN GDMS_SYSTEM D ON C.SYSTEM_ID = D.ID
WHERE D.ID = '" + ajaxData.systemId + @"'
ORDER BY C.NAME ASC";
var ds = db.QueryT(sql);
Response res = new Response();
//初始化计数
int okCountSum = 0;
int serviceCountSum = 0;
int oldCountSum = 0;
foreach (DataRow col in ds.Rows)
{
var countStr = col["COUNT"].ToString(); //获取数量(字符串格式)
var serviceDate = Convert.ToDateTime(col["SERVICE_DATE"].ToString()); //过保日期
var oldDate = Convert.ToDateTime(col["OLD_DATE"].ToString()); //老旧日期
var nowDate = System.DateTime.Now; //当前日期
if(nowDate <= serviceDate && nowDate <= oldDate) //如果设备未过保,未老旧
{
okCountSum = okCountSum + int.Parse(countStr); //当前类型正常数量
}else if(nowDate > serviceDate && nowDate <= oldDate) //如果设备过保,未老旧
{
serviceCountSum = serviceCountSum + int.Parse(countStr); //当前类型过保数量
}else if (nowDate > oldDate) //如果设备老旧
{
oldCountSum = oldCountSum + int.Parse(countStr); //当前类型老旧数量
}
}
//循环之后加上最后一个类型的信息
Dictionary<string, string> data = new Dictionary<string, string>
{
{ "OK_COUNT", okCountSum.ToString() },
{ "SERVICE_COUNT", serviceCountSum.ToString() },
{ "OLD_COUNT", oldCountSum.ToString() },
};
res.code = 0;
res.msg = "";
res.data = data;
var resJsonStr = JsonConvert.SerializeObject(res);
HttpResponseMessage resJson = new HttpResponseMessage
{
Content = new StringContent(resJsonStr, Encoding.GetEncoding("UTF-8"), "application/json")
};
return resJson;
}
19
Source : oldChartController.cs
with MIT License
from manier13579
with MIT License
from manier13579
[ActionName("type")]
public HttpResponseMessage OrdChart([FromBody] OldChartAjax oldchartajax)
{
Db db = new Db();
string sql = @"
SELECT
A.COUNT,
A.DELIVERY_DATE,
ADD_MONTHS(A.DELIVERY_DATE,12*B.SERVICE_YEAR) AS SERVICE_DATE,
ADD_MONTHS(A.DELIVERY_DATE,12*" + oldchartajax.oldBenchmark + @") AS OLD_DATE,
C.ID AS TYPE_ID,
C.NAME AS TYPE_NAME
FROM GDMS_DEV_MAIN A
LEFT JOIN GDMS_STYLE B ON A.STYLE_ID = B.ID
LEFT JOIN GDMS_TYPE C ON B.TYPE_ID = C.ID
LEFT JOIN GDMS_SYSTEM D ON C.SYSTEM_ID = D.ID
WHERE D.ID = '" + oldchartajax.systemId + @"'
ORDER BY C.ID ASC";
var ds = db.QueryT(sql);
Response res = new Response();
ArrayList data = new ArrayList();
//初始化计数
string typeId = "";
string typeName = "";
int okCountSum = 0;
int serviceCountSum = 0;
int oldCountSum = 0;
foreach (DataRow col in ds.Rows)
{
//第一次循环 或 本次类型与上次相同,数值加和
if (typeId == "" || typeId == col["TYPE_ID"].ToString())
{
typeId = col["TYPE_ID"].ToString(); //当前类型id
typeName = col["TYPE_NAME"].ToString(); //当前类型名称
var countStr = col["COUNT"].ToString(); //获取数量(字符串格式)
var serviceDate = Convert.ToDateTime(col["SERVICE_DATE"].ToString()); //过保日期
var oldDate = Convert.ToDateTime(col["OLD_DATE"].ToString()); //老旧日期
var nowDate = System.DateTime.Now; //当前日期
if(nowDate <= serviceDate && nowDate <= oldDate) //如果设备未过保,未老旧
{
okCountSum = okCountSum + int.Parse(countStr); //当前类型正常数量
}else if(nowDate > serviceDate && nowDate <= oldDate) //如果设备过保,未老旧
{
serviceCountSum = serviceCountSum + int.Parse(countStr); //当前类型过保数量
}else if (nowDate > oldDate) //如果设备老旧
{
oldCountSum = oldCountSum + int.Parse(countStr); //当前类型老旧数量
}
}
//循环到新类型
else {
//将上一类型的数据写入返回数据中data
Dictionary<string, string> dict = new Dictionary<string, string>
{
{ "TYPE_NAME", typeName },
{ "OK_COUNT", okCountSum.ToString() },
{ "SERVICE_COUNT", serviceCountSum.ToString() },
{ "OLD_COUNT", oldCountSum.ToString() },
};
data.Add(dict);
//初始化计数
okCountSum = 0;
serviceCountSum = 0;
oldCountSum = 0;
typeId = col["TYPE_ID"].ToString(); //当前类型id
typeName = col["TYPE_NAME"].ToString(); //当前类型名称
var countStr = col["COUNT"].ToString(); //获取数量(字符串格式)
var serviceDate = Convert.ToDateTime(col["SERVICE_DATE"].ToString()); //过保日期
var oldDate = Convert.ToDateTime(col["OLD_DATE"].ToString()); //老旧日期
var nowDate = System.DateTime.Now; //当前日期
if (nowDate <= serviceDate && nowDate <= oldDate) //如果设备未过保,未老旧
{
okCountSum = okCountSum + int.Parse(countStr); //当前类型正常数量
}
else if (nowDate > serviceDate && nowDate <= oldDate) //如果设备过保,未老旧
{
serviceCountSum = serviceCountSum + int.Parse(countStr); //当前类型过保数量
}
else if (nowDate > oldDate) //如果设备老旧
{
oldCountSum = oldCountSum + int.Parse(countStr); //当前类型老旧数量
}
}
}
//循环之后加上最后一个类型的信息
Dictionary<string, string> dictLast = new Dictionary<string, string>
{
{ "TYPE_NAME", typeName },
{ "OK_COUNT", okCountSum.ToString() },
{ "SERVICE_COUNT", serviceCountSum.ToString() },
{ "OLD_COUNT", oldCountSum.ToString() },
};
data.Add(dictLast);
res.code = 0;
res.msg = "";
res.data = data;
var resJsonStr = JsonConvert.SerializeObject(res);
HttpResponseMessage resJson = new HttpResponseMessage
{
Content = new StringContent(resJsonStr, Encoding.GetEncoding("UTF-8"), "application/json")
};
return resJson;
}
19
Source : Format.cs
with MIT License
from maniero
with MIT License
from maniero
public static void Main() => WriteLine(ToDateTime("03/25/2015").ToString("dd/MM/yyyy"));
19
Source : CsvAdapter.cs
with The Unlicense
from marioguttman
with The Unlicense
from marioguttman
public bool ReadFile() {
try {
int row = 1;
using (CsvFileReader csvFileReader = new CsvFileReader(this.filePath)) {
List<string> columnValues = new List<string>();
while (csvFileReader.ReadRow(columnValues)) {
if (row > 1) { // Skip first row that has column headings.
DataRow dataRow = this.dataTable.NewRow();
for (int i = 0; i < dataTable.Columns.Count; i++) {
if (this.dataTable.Columns[i].DataType == typeof(string)) dataRow[i] = columnValues[i];
else if (this.dataTable.Columns[i].DataType == typeof(int)) dataRow[i] = Convert.ToInt32(columnValues[i]);
else if (this.dataTable.Columns[i].DataType == typeof(double)) dataRow[i] = Convert.ToDouble(columnValues[i]);
else if (this.dataTable.Columns[i].DataType == typeof(DateTime)) dataRow[i] = Convert.ToDateTime(columnValues[i]);
}
this.dataTable.Rows.Add(dataRow);
}
row++;
}
}
return true;
}
catch (Exception exception) {
System.Windows.Forms.MessageBox.Show(
"ReadCsvFile() failed.\n\n"
+ "System error message:\n" + exception.Message, this.programName);
return false;
}
}
19
Source : StringExtensions.cs
with GNU General Public License v3.0
from ME3Tweaks
with GNU General Public License v3.0
from ME3Tweaks
public static DateTime ToDateTime(this string value)
{
return Convert.ToDateTime(value);
}
19
Source : TypeJavaScriptHandler.cs
with MIT License
from michaelschwarz
with MIT License
from michaelschwarz
public void ProcessRequest(HttpContext context)
{
// The request was not a request to invoke a server-side method.
// Now, we will render the Javascript that will be used on the
// client to run as a proxy or wrapper for the methods marked
// with the AjaxMethodAttribute.
if(context.Trace.IsEnabled) context.Trace.Write(Constant.AjaxID, "Render clreplaced proxy Javascript");
// Check wether the javascript is already rendered and cached in the
// current context.
string etag = context.Request.Headers["If-None-Match"];
string modSince = context.Request.Headers["If-Modified-Since"];
string path = type.FullName + "," + type.replacedembly.FullName.Split(',')[0];
if (Utility.Settings.UsereplacedemblyQualifiedName) path = type.replacedemblyQualifiedName;
if(Utility.Settings != null && Utility.Settings.UrlNamespaceMappings.ContainsValue(path))
{
foreach(string key in Utility.Settings.UrlNamespaceMappings.Keys)
{
if(Utility.Settings.UrlNamespaceMappings[key].ToString() == path)
{
path = key;
break;
}
}
}
if(context.Cache[path] != null)
{
CacheInfo ci = (CacheInfo)context.Cache[path];
if(etag != null)
{
if(etag == ci.ETag) // TODO: null check
{
context.Response.StatusCode = 304;
context.Response.SuppressContent = true;
return;
}
}
if(modSince != null)
{
if (modSince.IndexOf(";") > 0)
{
// If-Modified-Since: Tue, 06 Jun 2006 10:13:38 GMT; length=2935
modSince = modSince.Split(';')[0];
}
try
{
DateTime modSinced = Convert.ToDateTime(modSince.ToString()).ToUniversalTime();
if(DateTime.Compare(modSinced, ci.LastModified.ToUniversalTime()) >= 0)
{
context.Response.StatusCode = 304;
context.Response.SuppressContent = true;
return;
}
}
catch(FormatException)
{
if(context.Trace.IsEnabled) context.Trace.Write(Constant.AjaxID, "The header value for If-Modified-Since = " + modSince + " could not be converted to a System.DateTime.");
}
}
}
etag = type.replacedemblyQualifiedName;
etag = MD5Helper.GetHash(System.Text.Encoding.Default.GetBytes(etag));
DateTime now = DateTime.Now;
DateTime lastMod = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); // .ToUniversalTime();
context.Response.AddHeader("Content-Type", "application/x-javascript");
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
context.Response.Cache.SetETag(etag);
context.Response.Cache.SetLastModified(lastMod);
// Ok, we do not have the javascript rendered, yet.
// Build the javascript source and save it to the current
// Application context.
string url = context.Request.ApplicationPath + (context.Request.ApplicationPath.EndsWith("/") ? "" : "/") + Utility.HandlerPath + "/" + AjaxPro.Utility.GetSessionUri() + path + Utility.HandlerExtension;
// find all methods that are able to be used with AjaxPro
MethodInfo[] mi = type.GetMethods();
MethodInfo method;
#if(NET20)
List<MethodInfo> methods = new List<MethodInfo>();
#else
MethodInfo[] methods;
System.Collections.ArrayList methodList = new System.Collections.ArrayList();
int mc = 0;
#endif
for (int y = 0; y < mi.Length; y++)
{
method = mi[y];
if (!method.IsPublic)
continue;
AjaxMethodAttribute[] ma = (AjaxMethodAttribute[])method.GetCustomAttributes(typeof(AjaxMethodAttribute), true);
if (ma.Length == 0)
continue;
PrincipalPermissionAttribute[] ppa = (PrincipalPermissionAttribute[])method.GetCustomAttributes(typeof(PrincipalPermissionAttribute), true);
if (ppa.Length > 0)
{
bool permissionDenied = true;
for (int p = 0; p < ppa.Length && permissionDenied; p++)
{
#if(_____NET20)
if (Roles.Enabled)
{
try
{
if (!String.IsNullOrEmpty(ppa[p].Role) && !Roles.IsUserInRole(ppa[p].Role))
continue;
}
catch (Exception)
{
// Should we disable this AjaxMethod of there is an exception?
continue;
}
}
else
#endif
if (ppa[p].Role != null && ppa[p].Role.Length > 0 && context.User != null && context.User.Idenreplacedy.IsAuthenticated && !context.User.IsInRole(ppa[p].Role))
continue;
permissionDenied = false;
}
if (permissionDenied)
continue;
}
#if(NET20)
methods.Add(method);
#else
//methods[mc++] = method;
methodList.Add(method);
#endif
}
#if(!NET20)
methods = (MethodInfo[])methodList.ToArray(typeof(MethodInfo));
#endif
// render client-side proxy file
System.Text.StringBuilder sb = new System.Text.StringBuilder();
TypeJavaScriptProvider jsp = null;
if (Utility.Settings.TypeJavaScriptProvider != null)
{
try
{
Type jspt = Type.GetType(Utility.Settings.TypeJavaScriptProvider);
if (jspt != null && typeof(TypeJavaScriptProvider).IsreplacedignableFrom(jspt))
{
jsp = (TypeJavaScriptProvider)Activator.CreateInstance(jspt, new object[3] { type, url, sb });
}
}
catch (Exception)
{
}
}
if (jsp == null)
{
jsp = new TypeJavaScriptProvider(type, url, sb);
}
jsp.RenderNamespace();
jsp.RenderClreplacedBegin();
#if(NET20)
jsp.RenderMethods(methods.ToArray());
#else
jsp.RenderMethods(methods);
#endif
jsp.RenderClreplacedEnd();
context.Response.Write(sb.ToString());
context.Response.Write("\r\n");
// save the javascript in current Application context to
// speed up the next requests.
// TODO: was k�nnen wir hier machen??
// System.Web.Caching.CacheDependency fileDepend = new System.Web.Caching.CacheDependency(type.replacedembly.Location);
context.Cache.Add(path, new CacheInfo(etag, lastMod), null,
System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal, null);
if(context.Trace.IsEnabled) context.Trace.Write(Constant.AjaxID, "End ProcessRequest");
}
19
Source : ConverterJavaScriptHandler.cs
with MIT License
from michaelschwarz
with MIT License
from michaelschwarz
public void ProcessRequest(HttpContext context)
{
string etag = context.Request.Headers["If-None-Match"];
string modSince = context.Request.Headers["If-Modified-Since"];
if(context.Cache[Constant.AjaxID + ".converter"] != null)
{
CacheInfo ci = (CacheInfo)context.Cache[Constant.AjaxID + ".converter"];
if(etag != null)
{
if(etag == ci.ETag) // TODO: null check
{
context.Response.StatusCode = 304;
return;
}
}
if(modSince != null)
{
if (modSince.IndexOf(";") > 0)
{
// If-Modified-Since: Tue, 06 Jun 2006 10:13:38 GMT; length=2935
modSince = modSince.Split(';')[0];
}
try
{
DateTime modSinced = Convert.ToDateTime(modSince.ToString()).ToUniversalTime();
if(DateTime.Compare(modSinced, ci.LastModified.ToUniversalTime()) >= 0)
{
context.Response.StatusCode = 304;
return;
}
}
catch(FormatException)
{
if(context.Trace.IsEnabled) context.Trace.Write(Constant.AjaxID, "The header value for If-Modified-Since = " + modSince + " could not be converted to a System.DateTime.");
}
}
}
etag = MD5Helper.GetHash(System.Text.Encoding.Default.GetBytes("converter"));
DateTime now = DateTime.Now;
DateTime lastMod = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); //.ToUniversalTime();
context.Response.AddHeader("Content-Type", "application/x-javascript");
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
context.Response.Cache.SetETag(etag);
context.Response.Cache.SetLastModified(lastMod);
context.Response.Write(@"//--------------------------------------------------------------
// Copyright (C) 2006 Michael Schwarz (http://www.ajaxpro.info).
// All rights reserved.
//--------------------------------------------------------------
// Converter.js
");
if(Utility.Settings != null && Utility.Settings.Security != null)
{
try
{
string secrityScript = Utility.Settings.Security.SecurityProvider.ClientScript;
if (secrityScript != null && secrityScript.Length > 0)
{
context.Response.Write(secrityScript);
context.Response.Write("\r\n");
}
}
catch (Exception)
{
}
}
StringCollection convTypes = new StringCollection();
string convTypeName;
IJavaScriptConverter c;
string script;
IEnumerator s = Utility.Settings.SerializableConverters.Values.GetEnumerator();
while(s.MoveNext())
{
c = (IJavaScriptConverter)s.Current;
convTypeName = c.GetType().FullName;
if (!convTypes.Contains(convTypeName))
{
script = c.GetClientScript();
if (script.Length > 0)
{
#if(NET20)
if(!String.IsNullOrEmpty(c.ConverterName))
#else
if(c.ConverterName != null && c.ConverterName.Length > 0)
#endif
context.Response.Write("// " + c.ConverterName + "\r\n");
context.Response.Write(c.GetClientScript());
context.Response.Write("\r\n");
}
convTypes.Add(convTypeName);
}
}
IEnumerator d = Utility.Settings.DeserializableConverters.Values.GetEnumerator();
while(d.MoveNext())
{
c = (IJavaScriptConverter)d.Current;
convTypeName = c.GetType().FullName;
if (!convTypes.Contains(convTypeName))
{
script = c.GetClientScript();
if (script.Length > 0)
{
#if(NET20)
if (!String.IsNullOrEmpty(c.ConverterName))
#else
if(c.ConverterName != null && c.ConverterName.Length > 0)
#endif
context.Response.Write("// " + c.ConverterName + "\r\n");
context.Response.Write(c.GetClientScript());
context.Response.Write("\r\n");
}
convTypes.Add(convTypeName);
}
}
context.Cache.Add(Constant.AjaxID + ".converter", new CacheInfo(etag, lastMod), null,
System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal, null);
}
19
Source : EmbeddedJavaScriptHandler.cs
with MIT License
from michaelschwarz
with MIT License
from michaelschwarz
public void ProcessRequest(HttpContext context)
{
string etag = context.Request.Headers["If-None-Match"];
string modSince = context.Request.Headers["If-Modified-Since"];
if(context.Cache[Constant.AjaxID + "." + fileName] != null)
{
CacheInfo ci = (CacheInfo)context.Cache[Constant.AjaxID + "." + fileName];
if(etag != null)
{
if(etag == ci.ETag) // TODO: null check
{
context.Response.StatusCode = 304;
return;
}
}
if(modSince != null)
{
if (modSince.IndexOf(";") > 0)
{
// If-Modified-Since: Tue, 06 Jun 2006 10:13:38 GMT; length=2935
modSince = modSince.Split(';')[0];
}
try
{
DateTime modSinced = Convert.ToDateTime(modSince.ToString()).ToUniversalTime();
if(DateTime.Compare(modSinced, ci.LastModified.ToUniversalTime()) >= 0)
{
context.Response.StatusCode = 304;
return;
}
}
catch(FormatException)
{
if(context.Trace.IsEnabled) context.Trace.Write(Constant.AjaxID, "The header value for If-Modified-Since = " + modSince + " could not be converted to a System.DateTime.");
}
}
}
etag = MD5Helper.GetHash(System.Text.Encoding.Default.GetBytes(fileName));
DateTime now = DateTime.Now;
DateTime lastMod = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); //.ToUniversalTime();
context.Response.AddHeader("Content-Type", "application/x-javascript");
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
context.Response.Cache.SetETag(etag);
context.Response.Cache.SetLastModified(lastMod);
context.Response.Write(@"//--------------------------------------------------------------
// Copyright (C) 2006 Michael Schwarz (http://www.ajaxpro.info).
// All rights reserved.
//--------------------------------------------------------------
");
// Now, we want to read the JavaScript embedded source
// from the replacedembly. If the filename includes any comma
// we have to return more than one embedded JavaScript file.
if (fileName != null && fileName.Length > 0)
{
string[] files = fileName.Split(',');
replacedembly replacedembly = replacedembly.GetExecutingreplacedembly();
Stream s;
for (int i = 0; i < files.Length; i++)
{
s = replacedembly.GetManifestResourceStream(Constant.replacedemblyName + "." + files[i] + ".js");
if (s != null)
{
System.IO.StreamReader sr = new System.IO.StreamReader(s);
context.Response.Write("// " + files[i] + ".js\r\n");
context.Response.Write(sr.ReadToEnd());
context.Response.Write("\r\n");
sr.Close();
if (files[i] == "prototype" && AjaxPro.Utility.Settings.OldStyle.Contains("objectExtendPrototype"))
{
context.Response.Write(@"
Object.prototype.extend = function(o, override) {
return Object.extend.apply(this, [this, o, override != false]);
}
");
}
}
}
}
context.Cache.Add(Constant.AjaxID + "." + fileName, new CacheInfo(etag, lastMod), null,
System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration,
System.Web.Caching.CacheItemPriority.Normal, null);
}
19
Source : XmlUtils.cs
with Apache License 2.0
from micro-chen
with Apache License 2.0
from micro-chen
public static DateTime GetNodeValueDate(XmlNode objNode, string nodeName, DateTime defaultValue)
{
DateTime dateValue = defaultValue;
if ((objNode[nodeName] != null))
{
string strValue = objNode[nodeName].InnerText;
if (!string.IsNullOrEmpty(strValue))
{
dateValue = Convert.ToDateTime(strValue);
}
}
return dateValue;
}
19
Source : DataGridTests.cs
with Microsoft Public License
from microsoftarchive
with Microsoft Public License
from microsoftarchive
protected void ValidateGridRow(DataGrid dataGrid, DataGridRow row, TDataClreplaced boundItem, bool onlyWritableColumns)
{
foreach (DataGridBoundColumn boundColumn in dataGrid.Columns)
{
//All columns are autogenerated so the column headers match the property definition.
PropertyInfo pi = properties.Where(p => boundColumn.Header.ToString() == p.Name).First();
if (((onlyWritableColumns && pi.CanWrite) || !onlyWritableColumns) && dataGrid.IsColumnDisplayed(boundColumn.Index))
{
object value = pi.GetValue(boundItem, null);
FrameworkElement cellElement = boundColumn.GetCellContent(row);
if (cellElement is TextBlock || cellElement is TextBox)
{
if (value != null)
{
if (value is DateTime)
{
// For our tests to preplaced on all platforms, we have to compare universal times
DateTime dateTime = Convert.ToDateTime(cellElement is TextBlock ? ((TextBlock)cellElement).Text : ((TextBox)cellElement).Text);
replacedert.AreEqual(((DateTime)value).ToUniversalTime().ToString(), dateTime.ToUniversalTime().ToString());
}
else
{
replacedert.AreEqual(value.ToString(),
cellElement is TextBlock ? ((TextBlock)cellElement).Text : ((TextBox)cellElement).Text,
String.Format(CultureInfo.CurrentCulture, "Column {0} doesn't match", pi.Name));
}
}
else //null's show up as empty strings
{
replacedert.AreEqual("",
cellElement is TextBlock ? ((TextBlock)cellElement).Text : ((TextBox)cellElement).Text,
String.Format(CultureInfo.CurrentCulture, "Column {0} doesn't match", pi.Name));
}
}
else if (cellElement is CheckBox)
{
replacedert.AreEqual(value, ((CheckBox)cellElement).IsChecked, String.Format(CultureInfo.CurrentCulture, "Column {0} doesn't match", pi.Name));
}
}
}
}
19
Source : RegisterHelper.cs
with The Unlicense
from MrBenWang
with The Unlicense
from MrBenWang
internal static DateTime getWebsiteDatetime()
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://www.baidu.com");
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
return Convert.ToDateTime(myResponse.Headers["date"]);
}
19
Source : CommandParser.cs
with MIT License
from mykeels
with MIT License
from mykeels
private void _setPropertyValue<TData>(TData ret, PropertyInfo property, List<string> values, TransformAttribute transform = null)
{
string flagValue = string.Join(null, values);
switch (property.PropertyType.Name)
{
case "String":
try { property.SetValue(ret, flagValue); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to String"); }
break;
case "Int32":
try { property.SetValue(ret, Convert.ToInt32(flagValue)); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to Int32"); }
break;
case "Int64":
try { property.SetValue(ret, Convert.ToInt64(flagValue)); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to Int64"); }
break;
case "DateTime":
try { property.SetValue(ret, Convert.ToDateTime(flagValue)); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to DateTime"); }
break;
case "Double":
try { property.SetValue(ret, Convert.ToDouble(flagValue)); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to Double"); }
break;
case "Boolean":
Console.WriteLine("Boolean Found");
if (string.IsNullOrWhiteSpace(flagValue)) property.SetValue(ret, true); //default to true if no value is specified cos it's a boolean
else try { property.SetValue(ret, Convert.ToBoolean(flagValue)); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to Boolean"); }
break;
case "List`1":
Type listType = property.PropertyType;
if (property.GetValue(ret) == null) property.SetValue(ret, System.Activator.CreateInstance(listType)); //instantiate the List if not instantiated
if (listType.IsGenericType && listType.GetGenericTypeDefinition() == typeof(List<>))
{
Type targetType = listType.GetGenericArguments().First();
values.ForEach((string value) =>
{
_setListValue((IList)property.GetValue(ret), targetType, value);
});
}
property.GetValue(ret).GetType().GetProperties();
break;
default:
if (transform != null)
{
property.SetValue(ret, transform.Execute.DynamicInvoke(flagValue));
}
else
{
if (property.PropertyType.BaseType.Name == "Enum")
{
try { property.SetValue(ret, Enum.Parse(property.PropertyType, flagValue)); } catch { throw new Exception($"Could not convert argument value of \"{flagValue}\" to Enum"); }
}
else throw new Exception($"Type of [{property.Name}] is not recognized");
}
break;
}
}
19
Source : CommandParser.cs
with MIT License
from mykeels
with MIT License
from mykeels
private void _setListValue(IList list, Type listTargetType, string value)
{
if (list != null)
{
switch (listTargetType.Name)
{
case "String":
try { list.Add(Convert.ToString(value)); } catch { throw new Exception($"Could not convert argument value of \"{value}\" to String"); }
break;
case "Int32":
try { list.Add(Convert.ToInt32(value)); } catch { throw new Exception($"Could not convert argument value of \"{value}\" to Int32"); }
break;
case "Int64":
try { list.Add(Convert.ToInt64(value)); } catch { throw new Exception($"Could not convert argument value of \"{value}\" to Int64"); }
break;
case "DateTime":
try { list.Add(Convert.ToDateTime(value)); } catch { throw new Exception($"Could not convert argument value of \"{value}\" to DateTime"); }
break;
case "Boolean":
if (string.IsNullOrWhiteSpace(value)) list.Add(true); //default to true if no value is specified cos it's a boolean
else try { list.Add(Convert.ToBoolean(value)); } catch { throw new Exception($"Could not convert argument value of \"{value}\" to Boolean"); }
break;
default:
if (listTargetType.BaseType.Name == "Enum")
{
try { list.Add(Enum.Parse(listTargetType, value)); } catch { throw new Exception($"Could not convert argument value of \"{value}\" to Enum"); }
}
else throw new Exception($"Type of [{listTargetType.Name}] is not recognized");
break;
}
}
}
19
Source : dm_os_workers.cs
with GNU Lesser General Public License v3.0
from NaverCloudPlatform
with GNU Lesser General Public License v3.0
from NaverCloudPlatform
protected override void GetData()
{
// 데이터를 구한다.
log.Warn(string.Format("{0} GetData started", BaseTableName));
try
{
string probe_time = ProbeTime.ToString("yyyy-MM-dd HH:mm:ss.000");
using (SqlConnection conn = new SqlConnection(config.GetConnectionString(InitialCatalog.Repository)))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = GetDataQuery;
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
buffer.Add(new dm_os_workers_data
{
probe_time = Convert.ToDateTime(probe_time),
session_limit = config.DatabaseValue<int>(reader["session_limit"]),
current_session_cnt = config.DatabaseValue<int>(reader["current_session_cnt"]),
max_worker_thread = config.DatabaseValue<int>(reader["max_worker_thread"]),
current_worker_cnt = config.DatabaseValue<int>(reader["current_worker_cnt"]),
scheduler_id = config.DatabaseValue<int>(reader["scheduler_id"]),
quantum_used = config.DatabaseValue<long>(reader["quantum_used"]),
is_preemptive = config.DatabaseValue<bool>(reader["is_preemptive"]),
context_switch_count = config.DatabaseValue<int>(reader["context_switch_count"]),
state = config.DatabaseValue<string>(reader["state"]),
last_wait_type = config.DatabaseValue<string>(reader["last_wait_type"]),
processor_group = config.DatabaseValue<short>(reader["processor_group"]),
tasks_processed_count = config.DatabaseValue<int>(reader["tasks_processed_count"]),
task_address = config.DatabaseValue<byte[]>(reader["task_address"]),
session_id = config.DatabaseValue<short>(reader["session_id"]),
original_login_name = config.DatabaseValue<string>(reader["original_login_name"]),
host_name = config.DatabaseValue<string>(reader["host_name"]),
program_name = config.DatabaseValue<string>(reader["program_name"]),
command = config.DatabaseValue<string>(reader["command"]),
cpu_time = config.DatabaseValue<int>(reader["cpu_time"]),
total_elapsed_time = config.DatabaseValue<int>(reader["total_elapsed_time"]),
reads = config.DatabaseValue<long>(reader["reads"]),
writes = config.DatabaseValue<long>(reader["writes"]),
logical_reads = config.DatabaseValue<long>(reader["logical_reads"]),
query_hash = config.DatabaseValue<byte[]>(reader["query_hash"]),
sql_handle = config.DatabaseValue<byte[]>(reader["sql_handle"]),
statement_start_offset = config.DatabaseValue<int>(reader["statement_start_offset"]),
statement_end_offset = config.DatabaseValue<int>(reader["statement_end_offset"]),
database_id = config.DatabaseValue<short>(reader["database_id"]),
blocking_session_id = config.DatabaseValue<short>(reader["blocking_session_id"]),
open_transaction_count = config.DatabaseValue<int>(reader["open_transaction_count"]),
percent_complete = config.DatabaseValue<Single>(reader["percent_complete"]),
transaction_isolation_level = config.DatabaseValue<short>(reader["transaction_isolation_level"]),
query_plan_hash = config.DatabaseValue<byte[]>(reader["query_plan_hash"]),
plan_handle = config.DatabaseValue<byte[]>(reader["plan_handle"]),
query_text = config.DatabaseValue<string>(reader["query_text"])
});
}
}
}
conn.Close();
}
}
catch (Exception ex)
{
log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
}
}
19
Source : sp_lock2.cs
with GNU Lesser General Public License v3.0
from NaverCloudPlatform
with GNU Lesser General Public License v3.0
from NaverCloudPlatform
protected override void GetData()
{
// 데이터를 구한다.
log.Warn(string.Format("{0} GetData started", BaseTableName));
try
{
string probe_time = ProbeTime.ToString("yyyy-MM-dd HH:mm:ss.000");
using (SqlConnection conn = new SqlConnection(config.GetConnectionString(InitialCatalog.Repository)))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = GetDataQuery;
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
buffer.Add(new sp_lock2_data
{
//MachineName = config.GetValue(Category.GLOBAL, Key.hostname),
//FullInstanceName = config.DatabaseValue<string>(reader["servicename"]),
//MachinePrivateIp = config.GetValue(Category.GLOBAL, Key.private_ip),
probe_time = Convert.ToDateTime(probe_time),
hh_mm_ss = config.DatabaseValue<string>(reader["hh_mm_ss"]),
wait_sec = config.DatabaseValue<long>(reader["wait_sec"]),
locktree = config.DatabaseValue<string>(reader["locktree"]),
spid = config.DatabaseValue<short>(reader["spid"]),
kpid = config.DatabaseValue<short>(reader["kpid"]),
blocked = config.DatabaseValue<short>(reader["blocked"]),
waittype = config.DatabaseValue<byte[]>(reader["waittype"]),
waittime = config.DatabaseValue<long>(reader["waittime"]),
lastwaittype = config.DatabaseValue<string>(reader["lastwaittype"]),
waitresource = config.DatabaseValue<string>(reader["waitresource"]),
dbid = config.DatabaseValue<short>(reader["dbid"]),
uid = config.DatabaseValue<short>(reader["uid"]),
cpu = config.DatabaseValue<int>(reader["cpu"]),
physical_io = config.DatabaseValue<long>(reader["physical_io"]),
memusage = config.DatabaseValue<int>(reader["memusage"]),
login_time = config.DatabaseValue<DateTime>(reader["login_time"]),
last_batch = config.DatabaseValue<DateTime>(reader["last_batch"]),
ecid = config.DatabaseValue<short>(reader["ecid"]),
open_tran = config.DatabaseValue<short>(reader["open_tran"]),
status = config.DatabaseValue<string>(reader["status"]),
sid = config.DatabaseValue<byte[]>(reader["sid"]),
hostname = config.DatabaseValue<string>(reader["hostname"]),
program_name = config.DatabaseValue<string>(reader["program_name"]),
hostprocess = config.DatabaseValue<string>(reader["hostprocess"]),
cmd = config.DatabaseValue<string>(reader["cmd"]),
nt_domain = config.DatabaseValue<string>(reader["nt_domain"]),
nt_username = config.DatabaseValue<string>(reader["nt_username"]),
net_address = config.DatabaseValue<string>(reader["net_address"]),
net_library = config.DatabaseValue<string>(reader["net_library"]),
loginame = config.DatabaseValue<string>(reader["loginame"]),
context_info = config.DatabaseValue<byte[]>(reader["context_info"]),
sql_handle = config.DatabaseValue<byte[]>(reader["sql_handle"]),
stmt_start = config.DatabaseValue<int>(reader["stmt_start"]),
stmt_end = config.DatabaseValue<int>(reader["stmt_end"]),
request_id = config.DatabaseValue<int>(reader["request_id"]),
objectid = config.DatabaseValue<int>(reader["objectid"]),
number = config.DatabaseValue<short>(reader["number"]),
encrypted = config.DatabaseValue<bool>(reader["encrypted"]),
text = config.DatabaseValue<string>(reader["text"])
//죽 다 넣어준다.
});
}
}
}
conn.Close();
}
}
catch (Exception ex)
{
log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
}
}
See More Examples