System.Convert.ToDateTime(string)

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 7

19 Source : NpcCommandHandler.cs
with GNU Lesser General Public License v3.0
from 8720826

private bool CheckField(PlayerEnreplacedy player, string field, string strValue, string strRelation)
        {
            try
            {
                var relations = GetRelations(strRelation);// 1 大于,0 等于 ,-1 小于

                var fieldProp = GetFieldPropertyInfo(player, field);
                if (fieldProp == null)
                {
                    return false;
                }

                var objectValue = fieldProp.GetValue(player);
                var typeCode = Type.GetTypeCode(fieldProp.GetType());
                switch (typeCode)
                {
                    case TypeCode.Int32:
                        return relations.Contains(Convert.ToInt32(strValue).CompareTo(Convert.ToInt32(objectValue)));

                    case TypeCode.Int64:
                        return relations.Contains(Convert.ToInt64(strValue).CompareTo(Convert.ToInt64(objectValue)));

                    case TypeCode.Decimal:
                        return relations.Contains(Convert.ToDecimal(strValue).CompareTo(Convert.ToDecimal(objectValue)));

                    case TypeCode.Double:
                        return relations.Contains(Convert.ToDouble(strValue).CompareTo(Convert.ToDouble(objectValue)));

                    case TypeCode.Boolean:
                        return relations.Contains(Convert.ToBoolean(strValue).CompareTo(Convert.ToBoolean(objectValue)));

                    case TypeCode.DateTime:
                        return relations.Contains(Convert.ToDateTime(strValue).CompareTo(Convert.ToDateTime(objectValue)));

                    case TypeCode.String:
                        return relations.Contains(strValue.CompareTo(objectValue));

                    default:
                        throw new Exception($"不支持的数据类型: {typeCode}");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"CheckField Exception:{ex}");
                return false;
            }
        }

19 Source : MetaWeblogService .cs
with MIT License
from ADefWebserver

public async Task<string> AddPostAsync(string blogid, string username, string preplacedword, Post post, bool publish)
        {
            string BlogPostID = "";

            if (await IsValidMetaWeblogUserAsync(username, preplacedword))
            {
                try
                {
                    Blogs objBlogs = new Blogs();

                    objBlogs.BlogId = 0;
                    objBlogs.BlogUserName = username;

                    if (post.dateCreated > Convert.ToDateTime("1/1/1900"))
                    {
                        objBlogs.BlogDate =
                            post.dateCreated;
                    }
                    else
                    {
                        objBlogs.BlogDate = DateTime.Now;
                    }

                    objBlogs.Blogreplacedle =
                        post.replacedle;

                    objBlogs.BlogContent =
                        post.description;

                    if (post.description != null)
                    {
                        string strSummary = ConvertToText(post.description);
                        int intSummaryLength = strSummary.Length;
                        if (intSummaryLength > 500)
                        {
                            intSummaryLength = 500;
                        }

                        objBlogs.BlogSummary = strSummary.Substring(0, intSummaryLength);
                    }

                    _BlazorBlogsContext.Add(objBlogs);
                    _BlazorBlogsContext.SaveChanges();
                    BlogPostID = objBlogs.BlogId.ToString();

                    if (post.categories != null)
                    {
                        objBlogs.BlogCategory =
                            GetBlogCategories(objBlogs, post.categories);
                    }

                    _BlazorBlogsContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.GetBaseException().Message);
                }
            }
            else
            {
                throw new Exception("Bad user name or preplacedword");
            }

            return BlogPostID;
        }

19 Source : MetaWeblogService .cs
with MIT License
from ADefWebserver

public async Task<bool> EditPostAsync(string postid, string username, string preplacedword, Post post, bool publish)
        {
            if (await IsValidMetaWeblogUserAsync(username, preplacedword))
            {
                var ExistingBlogs = await
                                    _BlazorBlogsContext.Blogs
                                    .Include(x => x.BlogCategory)
                                    .Where(x => x.BlogId == Convert.ToInt32(postid))
                                    .FirstOrDefaultAsync();

                if (ExistingBlogs != null)
                {
                    try
                    {
                        if (post.dateCreated > Convert.ToDateTime("1/1/1900"))
                        {
                            ExistingBlogs.BlogDate =
                                post.dateCreated;
                        }

                        ExistingBlogs.Blogreplacedle =
                            post.replacedle;

                        ExistingBlogs.BlogContent =
                            post.description;

                        if (post.description != null)
                        {
                            string strSummary = ConvertToText(post.description);
                            int intSummaryLength = strSummary.Length;
                            if (intSummaryLength > 500)
                            {
                                intSummaryLength = 500;
                            }

                            ExistingBlogs.BlogSummary = strSummary.Substring(0, intSummaryLength);
                        }

                        if (post.categories == null)
                        {
                            ExistingBlogs.BlogCategory = null;
                        }
                        else
                        {
                            ExistingBlogs.BlogCategory =
                                GetBlogCategories(ExistingBlogs, post.categories);
                        }

                        _BlazorBlogsContext.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.GetBaseException().Message);
                    }
                }
                else
                {
                    throw new Exception("Bad user name or preplacedword");
                }
            }

            return true;
        }

19 Source : AduDateTimePicker.cs
with GNU General Public License v3.0
from aduskin

private void PART_TimePicker_SelectedTimeChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            string datepart = string.Empty;
            string timepart = string.Empty;
            if (!string.IsNullOrEmpty(Convert.ToString(e.NewValue)))
            {
                datepart = this.PART_Calendar.DisplayDate.ToString("yyyy-MM-dd");
                timepart = Convert.ToDateTime(e.NewValue).ToString("HH:mm:ss");
                this.SetDateTime(Convert.ToDateTime(datepart + " " + timepart).ToString(this.DateFormat));
            }
        }

19 Source : AduDateTimePicker.cs
with GNU General Public License v3.0
from aduskin

private void DayButton_MouseLeftButtonUp(object sender, RoutedEventArgs e)
        {
            string date_part = string.Empty;
            string time_part = string.Empty;
            if (sender is Calendar)
            {
                Calendar calendar = sender as Calendar;
                //碰撞检测,此为关键代码
                if (calendar != null && calendar.InputHitTest(Mouse.GetPosition(e.Source as FrameworkElement)) is Rectangle
                    || calendar.InputHitTest(Mouse.GetPosition(e.Source as FrameworkElement)) is TextBlock)
                {
                    if (calendar.SelectedDate == null)
                    {
                        return;
                    }

                    date_part = calendar.SelectedDate.Value.ToString("yyyy-MM-dd");

                    if (this.PART_TimePicker != null)
                    {
                        time_part = this.PART_TimePicker.Value.Value.ToString("HH:mm:ss");
                    }

                    this.SetDateTime(Convert.ToDateTime(date_part + " " + time_part).ToString(this.DateFormat));
                }
            }
        }

19 Source : TimePicker.cs
with GNU General Public License v3.0
from aduskin

private static void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            TimePicker timePicker = (TimePicker)sender;
            DateTime dt1 = DateTime.Now;
            if (e.Property == ValueProperty)
            {
                DateTime dt = Convert.ToDateTime(e.NewValue);

                timePicker.Hour = dt.Hour;
                timePicker.Minute = dt.Minute;
                timePicker.Second = dt.Second;
            }
            else
            {
                string time = string.Format("{0}:{1}:{2}", timePicker.Hour, timePicker.Minute, timePicker.Second);
                dt1 = Convert.ToDateTime(time);
                timePicker.Value = dt1;
            }
            timePicker.OnSelectedTimeChanged(dt1, dt1);
        }

19 Source : Battery.cs
with MIT License
from AL3X1

public async Task<BatteryState> GetCurrentBatteryState()
        {
            BatteryState batteryState = new BatteryState();

            try
            {
                Debug.WriteLine("Getting current battery state");
                GattReadResult gattReadResult = await ReadCurrentCharacteristic();

                if (gattReadResult.Status == GattCommunicationStatus.Success)
                {
                    var batteryData = gattReadResult.Value.ToArray();
                    DateTime lastChargingDate = Convert.ToDateTime($"{batteryData[14]}/{batteryData[13]}/{DateTime.Now.Year} {batteryData[15]}:{batteryData[16]}:{batteryData[17]}");

                    batteryState.ChargeLevel = batteryData[1];
                    batteryState.IsCharging = (batteryData[2] == CHARGING) ? true : false;
                    batteryState.LastCharge = lastChargingDate;
                    batteryState.Cycles = batteryData[18];
                }
            }
            catch (NullReferenceException)
            {
                batteryState.ChargeLevel = 0;
                batteryState.IsCharging = false;
                batteryState.LastCharge = Convert.ToDateTime("0:00");
                batteryState.Cycles = 0;
            }

            return batteryState;
        }

19 Source : Battery.cs
with MIT License
from AL3X1

public async Task<DateTime> GetLastChargingDate()
        {
            GattReadResult gattReadResult = await ReadCurrentCharacteristic();

            var batteryData = gattReadResult.Value.ToArray();
            DateTime lastChargingDate = new DateTime();

            if (gattReadResult.Status == GattCommunicationStatus.Success)
            {
                lastChargingDate = Convert.ToDateTime($"{batteryData[14]}/{batteryData[13]}/{DateTime.Now.Year} {batteryData[15]}:{batteryData[16]}:{batteryData[17]}");
            }

            return lastChargingDate;
        }

19 Source : AlertToChart.cs
with Apache License 2.0
from AlexWan

public void SetFromSaveString(string saveString)
        {
            string[] saveStrings = saveString.Split('@');

            TimeFirstPoint = Convert.ToDateTime(saveStrings[0]);
            ValueFirstPoint = Convert.ToDecimal(saveStrings[1]);

            TimeSecondPoint = Convert.ToDateTime(saveStrings[2]);
            ValueSecondPoint = Convert.ToDecimal(saveStrings[3]);
            LastPoint = Convert.ToDecimal(saveStrings[4]);
        }

19 Source : Order.cs
with Apache License 2.0
from AlexWan

public void SetOrderFromString(string saveString)
        {
            string[] saveArray = saveString.Split('@');
            NumberUser = Convert.ToInt32(saveArray[0]);


            NumberMarket = saveArray[2];
            Enum.TryParse(saveArray[3], true, out Side);
            Price = saveArray[4].ToDecimal();

            Volume = saveArray[6].ToDecimal();
            VolumeExecute = saveArray[7].ToDecimal();

            Enum.TryParse(saveArray[8], true, out _state);
            Enum.TryParse(saveArray[9], true, out TypeOrder);
            TimeCallBack = Convert.ToDateTime(saveArray[10]);

            SecurityNameCode = saveArray[11];
            PortfolioNumber = saveArray[12].Replace('%', '@');


            TimeCreate = Convert.ToDateTime(saveArray[13]);
            TimeCancel = Convert.ToDateTime(saveArray[14]);
            TimeCallBack = Convert.ToDateTime(saveArray[15]);

            TimeSpan.TryParse(saveArray[16], out LifeTime);
            // deals with which the order was opened and the order execution price was calculated
            // сделки, которыми открывался ордер и рассчёт цены исполнения ордера

            if (saveArray[17] == "null")
            {
                _trades = null;
            }
            else
            {
                string[] tradesArray = saveArray[17].Split('*');

                _trades = new List<MyTrade>();

                for (int i = 0; i < tradesArray.Length - 1; i++)
                {
                    _trades.Add(new MyTrade());
                    _trades[i].SetTradeFromString(tradesArray[i]);
                }
            }
            Comment = saveArray[18];
            TimeDone = Convert.ToDateTime(saveArray[19]);
        }

19 Source : MyTrade.cs
with Apache License 2.0
from AlexWan

public void SetTradeFromString(string saveString)
        {
            string[] arraySave = saveString.Split('&');

            Volume = arraySave[0].ToDecimal();
            Price = arraySave[1].ToDecimal();
            NumberOrderParent = arraySave[2];
            Time = Convert.ToDateTime(arraySave[3]);
            NumberTrade = arraySave[4];
            Enum.TryParse(arraySave[5], out Side);
            SecurityNameCode = arraySave[6];
            NumberPosition = arraySave[7];
        }

19 Source : Trade.cs
with Apache License 2.0
from AlexWan

public void SetTradeFromString(string In)
        {
            //20150401,100000,86160.000000000,2
            // либо 20150401,100000,86160.000000000,2, Buy/Sell

            if (string.IsNullOrWhiteSpace(In))
            {
                return;
            }

            string[] sIn = In.Split(',');

            if (sIn.Length >= 6 && (sIn[5] == "C" || sIn[5] == "S"))
            {
                // download data from IqFeed
                // загружаем данные из IqFeed
                Time = Convert.ToDateTime(sIn[0]);
                Price = sIn[1].ToDecimal();
                Volume = sIn[2].ToDecimal();
                Bid = sIn[3].ToDecimal();
                Ask = sIn[4].ToDecimal();
                Side = GetSideIqFeed();

                return;
            }

            int year = Convert.ToInt32(sIn[0].Substring(0, 4));
            int month = Convert.ToInt32(sIn[0].Substring(4, 2));
            int day = Convert.ToInt32(sIn[0].Substring(6, 2));

            int hour = Convert.ToInt32(sIn[1].Substring(0, 2));
            int minute = Convert.ToInt32(sIn[1].Substring(2, 2));
            int second = Convert.ToInt32(sIn[1].Substring(4, 2));

            Time = new DateTime(year, month, day, hour, minute, second);

            Price = sIn[2].ToDecimal();

            Volume = sIn[3].ToDecimal();

            if (sIn.Length > 4)
            {
                Enum.TryParse(sIn[4], true, out Side);
            }

            if (sIn.Length > 5)
            {
                MicroSeconds = Convert.ToInt32(sIn[5]);
            }

            if (sIn.Length > 6)
            {
                Id = sIn[6];
            }

            if (sIn.Length > 7)
            {
                Bid = sIn[7].ToDecimal();
                Ask = sIn[8].ToDecimal();
                BidsVolume = Convert.ToInt32(sIn[9]);
                AsksVolume = Convert.ToInt32(sIn[10]);
            }


        }

19 Source : Order.cs
with Apache License 2.0
from AlexWan

public void SetOrderFromString(string saveString)
        {
            string[] saveArray = saveString.Split('@');
            NumberUser = Convert.ToInt32(saveArray[0]);

            Enum.TryParse(saveArray[1], true, out ServerType);

            NumberMarket = saveArray[2];
            Enum.TryParse(saveArray[3], true, out Side);
            Price = saveArray[4].ToDecimal();

            Volume = saveArray[6].ToDecimal();
            VolumeExecute = saveArray[7].ToDecimal();

            Enum.TryParse(saveArray[8], true, out _state);
            Enum.TryParse(saveArray[9], true, out TypeOrder);
            TimeCallBack = Convert.ToDateTime(saveArray[10]);

            SecurityNameCode = saveArray[11];
            PortfolioNumber = saveArray[12].Replace('%', '@');


            TimeCreate = Convert.ToDateTime(saveArray[13]);
            TimeCancel = Convert.ToDateTime(saveArray[14]);
            TimeCallBack = Convert.ToDateTime(saveArray[15]);

            TimeSpan.TryParse(saveArray[16], out LifeTime);
            // deals with which the order was opened and the order execution price was calculated
            // сделки, которыми открывался ордер и рассчёт цены исполнения ордера

            if (saveArray[17] == "null")
            {
                _trades = null;
            }
            else
            {
                string[] tradesArray = saveArray[17].Split('*');

                _trades = new List<MyTrade>();

                for (int i = 0; i < tradesArray.Length - 1; i++)
                {
                    _trades.Add(new MyTrade());
                    _trades[i].SetTradeFromString(tradesArray[i]);
                }
            }
            Comment = saveArray[18];
            TimeDone = Convert.ToDateTime(saveArray[19]);
        }

19 Source : Security.cs
with Apache License 2.0
from AlexWan

public void LoadFromString(string save)
        {
            string[] array = save.Split('!');

            Name = array[0];
            NameClreplaced = array[1];
            NameFull = array[2];
            NameId = array[3];
            NameFull = array[4];
            Enum.TryParse(array[5],out State);
            PriceStep = array[6].ToDecimal();
            Lot = array[7].ToDecimal();
            PriceStepCost = array[8].ToDecimal();
            Go = array[9].ToDecimal();
            Enum.TryParse(array[10],out SecurityType);
            _decimals = Convert.ToInt32(array[11]);
            PriceLimitLow = array[12].ToDecimal();
            PriceLimitHigh = array[13].ToDecimal();
            Enum.TryParse(array[14], out OptionType);
            Strike = array[15].ToDecimal();
            Expiration = Convert.ToDateTime(array[16]);

        }

19 Source : MyTrade.cs
with Apache License 2.0
from AlexWan

public void SetTradeFromString(string saveString)
        {
            string[] arraySave = saveString.Split('&');

            Volume = arraySave[0].ToDecimal();
            Price = arraySave[1].ToDecimal();
            NumberOrderParent = arraySave[2];
            Time = Convert.ToDateTime(arraySave[3]);
            NumberTrade = arraySave[4];
            Enum.TryParse(arraySave[5], out Side);
            SecurityNameCode = arraySave[6];
            NumberPosition = arraySave[7];

        }

19 Source : Trade.cs
with Apache License 2.0
from AlexWan

public void SetTradeFromString(string In)
        {
            //20150401,100000,86160.000000000,2
            // либо 20150401,100000,86160.000000000,2, Buy/Sell

            if(string.IsNullOrWhiteSpace(In))
            {
                return;
            }

            string[] sIn = In.Split(',');

            if (sIn.Length >= 6 && (sIn[5] == "C" || sIn[5] == "S"))
            {
                // download data from IqFeed
                // загружаем данные из IqFeed
                Time = Convert.ToDateTime(sIn[0]);
                Price = sIn[1].ToDecimal();
                Volume = sIn[2].ToDecimal();
                Bid = sIn[3].ToDecimal();
                Ask = sIn[4].ToDecimal();
                Side = GetSideIqFeed();

                return;
            }

            int year = Convert.ToInt32(sIn[0].Substring(0, 4));
            int month = Convert.ToInt32(sIn[0].Substring(4, 2)); 
            int day = Convert.ToInt32(sIn[0].Substring(6, 2));

            int hour = Convert.ToInt32(sIn[1].Substring(0, 2));
            int minute = Convert.ToInt32(sIn[1].Substring(2, 2));
            int second = Convert.ToInt32(sIn[1].Substring(4, 2));

            Time = new DateTime(year, month, day, hour, minute, second);
            
            Price = sIn[2].ToDecimal();

            Volume = sIn[3].ToDecimal();

            if (sIn.Length > 4)
            {
                Enum.TryParse(sIn[4], true, out Side);
            }

            if (sIn.Length > 5)
            {
                MicroSeconds = Convert.ToInt32(sIn[5]);
            }

            if (sIn.Length > 6)
            {
                Id = sIn[6];
            }

            if (sIn.Length > 7)
            {
                Bid = sIn[7].ToDecimal();
                Ask = sIn[8].ToDecimal();
                BidsVolume = Convert.ToInt32(sIn[9]);
                AsksVolume = Convert.ToInt32(sIn[10]);
            }


        }

19 Source : PatternTime.cs
with Apache License 2.0
from AlexWan

public void Load(string saveString)
        {
            string[] array = saveString.Split('^');

            Weigth = array[1].ToDecimal();
            StartTime = Convert.ToDateTime(array[2]);
            EndTime = Convert.ToDateTime(array[3]);
        }

19 Source : OptimizerMaster.cs
with Apache License 2.0
from AlexWan

public void LoadFromString(string saveStr)
        {
            string[] str = saveStr.Split('%');

            Enum.TryParse(str[0], out TypeFaze);

            _timeStart = Convert.ToDateTime(str[1]);

            _timeEnd = Convert.ToDateTime(str[2]);

            Days = Convert.ToInt32(str[3]);
        }

19 Source : OptimizerMaster.cs
with Apache License 2.0
from AlexWan

private void Load()
        {
            if (!File.Exists(@"Engine\OptimizerSettings.txt"))
            {
                return;
            }
            try
            {
                using (StreamReader reader = new StreamReader(@"Engine\OptimizerSettings.txt"))
                {
                    _threadsCount = Convert.ToInt32(reader.ReadLine());
                    _strategyName = reader.ReadLine();
                    _startDepozit = Convert.ToDecimal(reader.ReadLine());
                    _filterProfitValue = Convert.ToDecimal(reader.ReadLine());
                    _filterProfitIsOn = Convert.ToBoolean(reader.ReadLine());
                    _filterMaxDrowDownValue = Convert.ToDecimal(reader.ReadLine());
                    _filterMaxDrowDownIsOn = Convert.ToBoolean(reader.ReadLine());
                    _filterMiddleProfitValue = Convert.ToDecimal(reader.ReadLine());
                    _filterMiddleProfitIsOn = Convert.ToBoolean(reader.ReadLine());
                    _filterProfitFactorValue = Convert.ToDecimal(reader.ReadLine());
                    _filterProfitFactorIsOn = Convert.ToBoolean(reader.ReadLine());

                    _timeStart = Convert.ToDateTime(reader.ReadLine());
                    _timeEnd = Convert.ToDateTime(reader.ReadLine());
                    _percentOnFilration = Convert.ToDecimal(reader.ReadLine());

                    _filterDealsCountValue = Convert.ToInt32(reader.ReadLine());
                    _filterDealsCountIsOn = Convert.ToBoolean(reader.ReadLine());
                    _isScript = Convert.ToBoolean(reader.ReadLine());
                    _iterationCount = Convert.ToInt32(reader.ReadLine());
                    _commissionType = (ComissionType) Enum.Parse(typeof(ComissionType), 
                        reader.ReadLine() ?? ComissionType.None.ToString());
                    _commissionValue = Convert.ToDecimal(reader.ReadLine());
                    _lastInSample = Convert.ToBoolean(reader.ReadLine());

                    reader.Close();
                }
            }
            catch (Exception error)
            {
                //SendLogMessage(error.ToString(), LogMessageType.Error);
            }
        }

19 Source : QuikDde.cs
with Apache License 2.0
from AlexWan

private void SecuritiesUpdated(long id, object[,] table)
        {
            int countElem = table.GetLength(0);

            if (countElem == 0)
            {
                return;
            }

            Security [] securities = new Security[countElem];

            decimal bestBid = 0;
            decimal bestAsk = 0;

                for (int i = 0; i < countElem; i++)
                {
                    try
                    {
                        securities[i] = new Security();
                        securities[i].NameFull = table[i, 0].ToString();
                        securities[i].Name = table[i, 1].ToString();
                        securities[i].NameClreplaced = table[i, 2].ToString();

                        if (!string.IsNullOrEmpty(table[i, 3].ToString()))
                        {
                            string state = table[i, 3].ToString().ToLower();

                            if (state == "торгуется")
                            {
                                securities[i].State = SecurityStateType.Activ;
                            }
                            else if (state == "заморожена" || state == "приостановлена")
                            {
                                securities[i].State = SecurityStateType.Close;
                            }
                            else
                            {
                                securities[i].State = securities[i].State = SecurityStateType.UnKnown;
                            }
                        }
                        else
                        {
                            securities[i].State = SecurityStateType.UnKnown;
                        }

                        if (!string.IsNullOrEmpty(table[i, 4].ToString()) &&
                            securities[i].NameClreplaced != "SPBFUT")
                        {
                            securities[i].Lot = ToDecimal(table[i, 4]);
                        }
                        else
                        {
                            securities[i].Lot = 1;
                        }

                        if (!string.IsNullOrEmpty(table[i, 5].ToString()))
                        {
                            securities[i].PriceStep = ToDecimal(table[i, 5]);
                        }

                        bestAsk = ToDecimal(table[i, 6]);
                        bestBid = ToDecimal(table[i, 7]);

                        if (!string.IsNullOrEmpty(table[i, 9].ToString()))
                        {
                            securities[i].PriceStepCost = ToDecimal(table[i, 9]);
                        }
                        else
                        {
                            securities[i].PriceStepCost = securities[i].PriceStep;
                        }

                        try
                        {
                            if (!string.IsNullOrEmpty(table[i, 10].ToString()))
                            {
                                DateTime time = Convert.ToDateTime(table[i, 10].ToString());

                                if (UpdateTimeSecurity != null)
                                {
                                    UpdateTimeSecurity(time);
                                }
                            }
                        }
                        catch (Exception error)
                        {
                            SendLogMessage(error.ToString(), LogMessageType.Error);
                        }

                        try
                        {
                            if (table.GetLength(1) > 11)
                            {
                                if (
                                    !string.IsNullOrEmpty(table[i, 11].ToString()))
                                {
                                    string type = table[i, 11].ToString();

                                    if (type == "Ценные бумаги")
                                    {
                                        securities[i].SecurityType = SecurityType.Stock;
                                    }
                                    else if (type == "Фьючерсы")
                                    {
                                        securities[i].SecurityType = SecurityType.Futures;
                                        securities[i].Lot = 1;
                                    }
                                    else if (type == "Опционы")
                                    {
                                        securities[i].SecurityType = SecurityType.Option;
                                        securities[i].Lot = 1;
                                    }
                                }
                            }
                            else
                            {
                            securities[i].SecurityType = SecurityType.Stock;
                                securities[i].Lot = 1;
                        }

                        }
                        catch (Exception error)
                        {
                            SendLogMessage(error.ToString(), LogMessageType.Error);
                        }
                    }
                    catch (Exception)
                { // here we remove the element by index, and reduce the array / здесь убираем элемент по индексу, и уменьшаем массив, т.к. в строке кака
                    if (securities.Length == 1)
                    { // if the only element of the array is broken / если битым является единственный элемент массива
                        return;
                        }

                        Security[] newArraySecurities = new Security[securities.Length-1];

                        for (int i2 = 0; i2 < i; i++)
                        {
                            newArraySecurities[i2] = securities[i2];
                        }
                        securities = newArraySecurities;
                    }

                    securities[i].PriceLimitHigh = 0;
                    securities[i].PriceLimitLow = 0;

                    if (UpdateSecurity != null)
                    {
                        UpdateSecurity(securities[i], bestBid, bestAsk);
                    }
                }
        }

19 Source : TinkoffClient.cs
with Apache License 2.0
from AlexWan

private DateTime FromIso8601(string str)
        {
            DateTime time = Convert.ToDateTime(str);

            return time;
        }

19 Source : InstanceHelperTest.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

[Fact]
        public void ConvertToMessageBoxSingleInstance_TC03()
        {
            // Arrange
            string lastChangedBy = TestData.UserId_1;
            Instance instance = TestData.Instance_1_1;
            instance.Data = new List<DataElement>()
            {
                new DataElement()
                {
                    LastChanged = Convert.ToDateTime("2019-08-21T19:19:22.2135489Z"),
                    LastChangedBy = lastChangedBy
                }
            };

            // Act
            MessageBoxInstance actual = InstanceHelper.ConvertToMessageBoxInstance(instance);
            string actualLastChangedBy = actual.LastChangedBy;

            // replacedert
            replacedert.Equal(lastChangedBy, actualLastChangedBy);
        }

19 Source : InstanceHelperTest.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

[Fact]
        public void FindLastChangedBy_TC01()
        {
            // Arrange
            Instance instance = TestData.Instance_2_2;
            string expectedlastChangedBy = "20000000";
            DateTime expectedlastChanged = Convert.ToDateTime("2019-08-20T19:19:22.2135489Z");

            // Act
            (string lastChangedBy, DateTime? lastChanged) = InstanceHelper.FindLastChanged(instance);

            // replacedert
            replacedert.Equal(expectedlastChangedBy, lastChangedBy);
            replacedert.Equal(expectedlastChanged, lastChanged);
        }

19 Source : InstanceHelperTest.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

[Fact]
        public void FindLastChangedBy_TC02()
        {
            // Arrange
            Instance instance = TestData.Instance_1_2;
            string expectedlastChangedBy = "20000001";
            DateTime expectedlastChanged = Convert.ToDateTime("2019-09-20T21:19:22.2135489Z");

            // Act
            (string lastChangedBy, DateTime? lastChanged) = InstanceHelper.FindLastChanged(instance);

            // replacedert
            replacedert.Equal(expectedlastChangedBy, lastChangedBy);
            replacedert.Equal(expectedlastChanged, lastChanged);
        }

19 Source : InstanceHelperTest.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

[Fact]
        public void FindLastChangedBy_TC03()
        {
            // Arrange
            Instance instance = TestData.Instance_2_1;
            string expectedlastChangedBy = "20000001";
            DateTime expectedlastChanged = Convert.ToDateTime("2019-10-20T21:19:22.2135489Z");

            // Act
            (string lastChangedBy, DateTime? lastChanged) = InstanceHelper.FindLastChanged(instance);

            // replacedert
            replacedert.Equal(expectedlastChangedBy, lastChangedBy);
            replacedert.Equal(expectedlastChanged, lastChanged);
        }

19 Source : Job_AccessTrendLog_Quartz.cs
with Apache License 2.0
from anjoy8

public async Task Run(IJobExecutionContext context)
        {

            // 可以直接获取 JobDetail 的值
            var jobKey = context.JobDetail.Key;
            var jobId = jobKey.Name;
            // 也可以通过数据库配置,获取传递过来的参数
            JobDataMap data = context.JobDetail.JobDataMap;

            var lastestLogDatetime = (await _accessTrendLogServices.Query(null, d => d.UpdateTime, false)).FirstOrDefault()?.UpdateTime;
            if (lastestLogDatetime == null)
            {
                lastestLogDatetime = Convert.ToDateTime("2021-09-01");
            }

            var accLogs = GetAccessLogs().Where(d => d.User != "" && d.BeginTime.ObjToDate() >= lastestLogDatetime).ToList();
            var logUpdate = DateTime.Now;

            var activeUsers = (from n in accLogs
                               group n by new { n.User } into g
                               select new ActiveUserVM
                               {
                                   user = g.Key.User,
                                   count = g.Count(),
                               }).ToList();

            foreach (var item in activeUsers)
            {
                var user = (await _accessTrendLogServices.Query(d => d.User != "" && d.User == item.user)).FirstOrDefault();
                if (user != null)
                {
                    user.Count += item.count;
                    user.UpdateTime = logUpdate;
                    await _accessTrendLogServices.Update(user);
                }
                else
                {
                    await _accessTrendLogServices.Add(new AccessTrendLog()
                    {
                        Count = item.count,
                        UpdateTime = logUpdate,
                        User = item.user
                    });
                }
            }

            // 重新拉取
            var actUsers = await _accessTrendLogServices.Query(d => d.User != "", d => d.Count, false);
            actUsers = actUsers.Take(15).ToList();

            List<ActiveUserVM> activeUserVMs = new();
            foreach (var item in actUsers)
            {
                activeUserVMs.Add(new ActiveUserVM()
                {
                    user = item.User,
                    count = item.Count
                });
            }

            Parallel.For(0, 1, e =>
            {
                LogLock.OutSql2Log("ACCESSTRENDLOG", new string[] { JsonConvert.SerializeObject(activeUserVMs) }, false, true);
            });
        }

19 Source : Form1.cs
with MIT License
from ap0405140

private void Form1_Load(object sender, EventArgs e)
        {
            config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
            
            //Connection String: Please change below connection string for your environment.
            txtConnectionstring.Text = config.AppSettings.Settings["DefaultConnectionString"].Value;

            //Time Range: Default to read at last 10 seconds 's logs, you can change the time range for need.
            dtStarttime.Value = Convert.ToDateTime(DateTime.Now.AddSeconds(-10).ToString("yyyy/MM/dd HH:mm:ss"));
            dtEndtime.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

            //Table Name: Need include schema name(like dbo.Table1), When blank means query all tables 's logs, you can change it for need.
            txtTablename.Text = "";

            timer = new System.Timers.Timer();
            timer.Interval = 1000;
            timer.AutoReset = true;
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_elapsed);
            timer.Enabled = false;

            Init();
        }

19 Source : Issues.cs
with Apache License 2.0
from Appdynamics

private void LoadData(FileInfo MyFile)
        {
            if (MyFile.Exists)
            {
                MyFile.Delete();  // ensures we create a new workbook
            }

            using (ExcelPackage EP = new ExcelPackage(MyFile))
            {
                // add a new worksheet to the empty workbook
                ExcelWorksheet wsData = EP.Workbook.Worksheets.Add("Data");
                //Add the headers
                wsData.Cells[1, 1].Value = "INVOICE_DATE";
                wsData.Cells[1, 2].Value = "TOTAL_INVOICE_PRICE";
                wsData.Cells[1, 3].Value = "EXTENDED_PRICE_VARIANCE";
                wsData.Cells[1, 4].Value = "AUDIT_LINE_STATUS";
                wsData.Cells[1, 5].Value = "RESOLUTION_STATUS";
                wsData.Cells[1, 6].Value = "COUNT";

                //Add some items...
                wsData.Cells["A2"].Value = Convert.ToDateTime("04/2/2012");
                wsData.Cells["B2"].Value = 33.63;
                wsData.Cells["C2"].Value = (-.87);
                wsData.Cells["D2"].Value = "Unfavorable Price Variance";
                wsData.Cells["E2"].Value = "Pending";
                wsData.Cells["F2"].Value = 1;

                wsData.Cells["A3"].Value = Convert.ToDateTime("04/2/2012");
                wsData.Cells["B3"].Value = 43.14;
                wsData.Cells["C3"].Value = (-1.29);
                wsData.Cells["D3"].Value = "Unfavorable Price Variance";
                wsData.Cells["E3"].Value = "Pending";
                wsData.Cells["F3"].Value = 1;

                wsData.Cells["A4"].Value = Convert.ToDateTime("11/8/2011");
                wsData.Cells["B4"].Value = 55;
                wsData.Cells["C4"].Value = (-2.87);
                wsData.Cells["D4"].Value = "Unfavorable Price Variance";
                wsData.Cells["E4"].Value = "Pending";
                wsData.Cells["F4"].Value = 1;

                wsData.Cells["A5"].Value = Convert.ToDateTime("11/8/2011");
                wsData.Cells["B5"].Value = 38.72;
                wsData.Cells["C5"].Value = (-5.00);
                wsData.Cells["D5"].Value = "Unfavorable Price Variance";
                wsData.Cells["E5"].Value = "Pending";
                wsData.Cells["F5"].Value = 1;

                wsData.Cells["A6"].Value = Convert.ToDateTime("3/4/2011");
                wsData.Cells["B6"].Value = 77.44;
                wsData.Cells["C6"].Value = (-1.55);
                wsData.Cells["D6"].Value = "Unfavorable Price Variance";
                wsData.Cells["E6"].Value = "Pending";
                wsData.Cells["F6"].Value = 1;

                wsData.Cells["A7"].Value = Convert.ToDateTime("3/4/2011");
                wsData.Cells["B7"].Value = 127.55;
                wsData.Cells["C7"].Value = (-10.50);
                wsData.Cells["D7"].Value = "Unfavorable Price Variance";
                wsData.Cells["E7"].Value = "Pending";
                wsData.Cells["F7"].Value = 1;

                using (var range = wsData.Cells[2, 1, 7, 1])
                {
                    range.Style.Numberformat.Format = "mm-dd-yy";
                }

                wsData.Cells.AutoFitColumns(0);
                EP.Save();
            }
        }

19 Source : Application.cs
with MIT License
from Autodesk

private object GetPropertyValue(AWS.PropDef definition, string rawValue)
        {
            if (string.IsNullOrEmpty(rawValue) == true)
            {
                return null;
            }
            object propertyValue = null;

            if (definition.Typ == AWS.DataType.Bool)
            {
                if (rawValue.Equals("1"))
                {
                    propertyValue = true;
                }
                else if (rawValue.Equals("0"))
                {
                    propertyValue = false;
                }
                else
                {
                    propertyValue = Convert.ToBoolean(rawValue);
                }
            }
            else if (definition.Typ == AWS.DataType.String)
            {
                propertyValue = rawValue;
            }
            else if (definition.Typ == AWS.DataType.Numeric)
            {
                propertyValue = Convert.ToDouble(rawValue);
            }
            else if (definition.Typ == AWS.DataType.DateTime)
            {
                propertyValue = Convert.ToDateTime(rawValue);
            }
            return propertyValue;
        }

19 Source : Extention.String.cs
with MIT License
from awesomedotnetcore

public static DateTime ToDateTime(this string str)
        {
            return Convert.ToDateTime(str);
        }

19 Source : Extention.String.cs
with MIT License
from awesomedotnetcore

public static T ToEnreplacedy<T>(this string json)
        {
            if (json == null || json == "")
                return default(T);

            Type type = typeof(T);
            object obj = Activator.CreateInstance(type, null);

            foreach (var item in type.GetProperties())
            {
                PropertyInfo info = obj.GetType().GetProperty(item.Name);
                string pattern;
                pattern = "\"" + item.Name + "\":\"(.*?)\"";
                foreach (Match match in Regex.Matches(json, pattern))
                {
                    switch (item.PropertyType.ToString())
                    {
                        case "System.String": info.SetValue(obj, match.Groups[1].ToString(), null); break;
                        case "System.Int32": info.SetValue(obj, match.Groups[1].ToString().ToInt(), null); ; break;
                        case "System.Int64": info.SetValue(obj, Convert.ToInt64(match.Groups[1].ToString()), null); ; break;
                        case "System.DateTime": info.SetValue(obj, Convert.ToDateTime(match.Groups[1].ToString()), null); ; break;
                    }
                }
            }
            return (T)obj;
        }

19 Source : TD_CheckBusiness_Partial.cs
with MIT License
from awesomedotnetcore

public async Task<PageResult<TD_Check>> QueryDataListAsync(string storId,PageInput<TDCheckQueryDTO> input)
        {
            var q = GetIQueryable().Include(i => i.AuditUser);
            var where = LinqHelper.True<TD_Check>();
            var search = input.Search;

            where = where.And(p => p.StorId == storId);
            if (search.IsComplete > -1) where = where.And(p => p.IsComplete == (search.IsComplete == 1));
            if (search.Status > -1) where = where.And(p => p.Status == search.Status);
            if (!search.RefCode.IsNullOrWhiteSpace()) where = where.And(p => p.RefCode.Contains(search.RefCode));
            if (!search.RefCode.IsNullOrWhiteSpace()) where = where.And(p => p.Code.Contains(search.RefCode));
            if (!search.Type.IsNullOrWhiteSpace()) where = where.And(p => p.Type == search.Type);

            DateTime dtStartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01 00:00:00"));
            DateTime dtEndTime= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
            if (search.RangeDate!=null && search.RangeDate.Length==2)
            {
                if(!search.RangeDate[0].IsNullOrWhiteSpace())
                {
                    dtStartTime = Convert.ToDateTime(search.RangeDate[0]);
                }

                if (!search.RangeDate[1].IsNullOrWhiteSpace())
                {
                    dtEndTime = Convert.ToDateTime(search.RangeDate[1]);
                }
            }
            where = where.And(p => p.CheckTime >= dtStartTime && p.CheckTime <= dtEndTime);

            return await q.Where(where).GetPageResultAsync(input);
        }

19 Source : PB_TrayController.cs
with MIT License
from awesomedotnetcore

[HttpPost]
        [NoCheckJWT]
        public async Task<AjaxResult> Import(IFormFile file)// file
        {
            string ReturnValue = string.Empty;
            //定义一个bool类型的变量用来做验证
            bool flag = true;
            try
            {
                #region 检查文件
                string fileExt = Path.GetExtension(file.FileName).ToLower();
                //定义一个集合一会儿将数据存储进来,全部一次丢到数据库中保存
                var Data = new List<PB_Tray>();
                MemoryStream ms = new MemoryStream();
                file.CopyTo(ms);
                ms.Seek(0, SeekOrigin.Begin);
                IWorkbook book;
                if (fileExt == ".xlsx")
                {
                    book = new XSSFWorkbook(ms);
                }
                else if (fileExt == ".xls")
                {
                    book = new HSSFWorkbook(ms);
                }
                else
                {
                    book = null;
                }
                ISheet sheet = book.GetSheetAt(0);

                int CountRow = sheet.LastRowNum + 1;//获取总行数

                if (CountRow - 1 == 0)
                {
                    return Error("Excel列表数据项为空!");

                }
                #endregion
                #region 循环验证
                for (int i = 1; i < CountRow; i++)
                {
                    //获取第i行的数据
                    var row = sheet.GetRow(i);
                    if (row != null)
                    {
                        //循环的验证单元格中的数据
                        for (int j = 0; j < 6; j++)
                        {
                            if ((j == 4 || j == 5) || (row.GetCell(j) == null || row.GetCell(j).ToString().Trim().Length == 0))
                            {
                                //return Error(ReturnValue += $"注意第{i + 1}行,第{j + 1}列数据为空。");
                            }
                            else
                            if (row.GetCell(j) == null || row.GetCell(j).ToString().Trim().Length == 0)
                            {
                                flag = false;
                                return Error(ReturnValue += $"第{i + 1}行,第{j + 1}列数据不能为空。");
                            }
                        }
                    }
                }
                #endregion
                if (flag)
                {
                    for (int i = 1; i < CountRow; i++)//
                    {
                        //实例化实体对象
                        PB_Tray commodity = new PB_Tray();
                        var row = sheet.GetRow(i);
                        if (row.GetCell(0) != null && row.GetCell(0).ToString().Trim().Length > 0)
                        {
                            commodity.Id = IdHelper.GetId();
                            commodity.CreatorId = _Op.UserId; //"Admin";//_Op.UserId;
                            commodity.Status = 1;//导入默认启用
                            commodity.StartTime = Convert.ToDateTime(DateTime.Now.ToString());  //默认当前日期时间

                            commodity.Code = row.GetCell(0).ToString();

                        }
                        if (row.GetCell(1) != null && row.GetCell(1).ToString().Trim().Length > 0)
                        {
                            commodity.Name = row.GetCell(1).ToString();
                        }
                        if (row.GetCell(2) != null && row.GetCell(2).ToString().Trim().Length > 0)
                        {
                            commodity.LocalId = row.GetCell(2).ToString();
                        }
                        if (row.GetCell(3) != null && row.GetCell(3).ToString().Trim().Length > 0)
                        {
                            commodity.TrayTypeId = row.GetCell(3).ToString();
                        }
                        Data.Add(commodity);
                    }
                    var listLocalCodes = Data.Select(s => s.LocalId).Distinct().ToList();
                    //s => .Select(s.Trim())
                    var dicLocal = _pB_TrayBus.GetQueryable<PB_Location>().Where(w => listLocalCodes.Contains(w.Code)).ToDictionary(k => k.Code, v => v.Id);

                    var listTrayTypeCodes = Data.Select(s => s.TrayTypeId).Select(s => s.Trim()).Distinct().ToList();
                    var dicTrayType = _pB_TrayBus.GetQueryable<PB_TrayType>().Where(w => listTrayTypeCodes.Contains(w.Code)).ToDictionary(k => k.Code, v => v.Id);


                    foreach (var item in Data)
                    {
                        if (dicTrayType.ContainsKey(item.TrayTypeId.Trim()))
                            item.TrayTypeId = dicTrayType[item.TrayTypeId.Trim()];
                        else
                            throw new Exception("托盘类型编号不存在!");

                        if (item.LocalId == null)
                        {
                            item.LocalId = null;
                        }
                        else if (dicLocal.ContainsKey(item.LocalId.Trim()))
                        {
                            item.LocalId = dicLocal[item.LocalId.Trim()];
                        }

                    }
                    if (Data.Count > 0)
                    {
                        int j = 1000;

                        for (int i = 0; i < Data.Count; i += 1000)

                        {

                            var cList = new List<PB_Tray>();

                            cList = Data.Take(j).Skip(i).ToList();

                            j += 1000;

                            await _pB_TrayBus.AddDataExlAsync(cList);

                        }
                        ReturnValue = $"数据导入成功,共导入{CountRow - 1}条数据。";
                    }
                }

                if (!flag)
                {
                    return Error(ReturnValue = "数据存在问题!" + ReturnValue);
                }
            }
            catch (Exception)
            {
                return Error("数据异常!");
            }

            return Success(ReturnValue);

        }

19 Source : DTTemp.cs
with GNU Lesser General Public License v3.0
from ccbpm

private bool CompareDate(string today, string writeDate, int n)
        {
            DateTime Today = Convert.ToDateTime(today);
            DateTime WriteDate = Convert.ToDateTime(writeDate);
            WriteDate = WriteDate.AddDays(n);
            if (Today >= WriteDate)
                return false;
            else
                return true;
        }

19 Source : JSON.cs
with GNU Lesser General Public License v3.0
from ccbpm

private static string StringFormat(string str, Type type)
        {
            if (type == typeof(string))
            {
                str = String2Json(str);
                str = "\"" + str + "\"";
            }
            else if (type == typeof(DateTime))
            {
                str = "\"" + Convert.ToDateTime(str).ToShortDateString() + "\"";
            }
            else if (type == typeof(bool))
            {
                str = str.ToLower();
            }

            if (str.Length == 0)
                str = "\"\"";

            return str;
        }

19 Source : DataSet2Json.cs
with GNU Lesser General Public License v3.0
from ccbpm

private static string StringFormat(string str, Type type)
        {
            if (type == typeof(string))
            {
                str = String2Json(str);
                str = "\"" + str + "\"";
            }
            else if (type == typeof(DateTime))
            {
                str = "\"" + Convert.ToDateTime(str).ToShortDateString() + "\"";
            }
            else if (type == typeof(bool))
            {
                str = str.ToLower();
            }
            else if (type == typeof(System.Byte[]))
            {
                //数字字段需转string后进行拼接 
                str = "\"" + str + "\"";
            }
            if (str.Length == 0)
                str = "\"\"";

            return str;
        }

19 Source : unixtime.cs
with MIT License
from ccxt-net

public static DateTime ConvertToUtcTime(string timeWithZone)
        {
            return Convert.ToDateTime(timeWithZone).ToUniversalTime();
        }

19 Source : RentalOperation.cs
with MIT License
from cemozaydin

public void AddToRental()
        {
            string _tempCustomer;
            int _carId, _customerId;
            DateTime _rentDate;
            DateTime? _returnDate;

            Console.Write("Kiralaması yapacak 'Müşteri ID' : ");
            _tempCustomer = Console.ReadLine();
            if (_tempCustomer != null)
            {
                Console.Write("Kiralanacak Araç ID         : ");
                _carId = Convert.ToInt32(Console.ReadLine());
                Console.Write("Kiralama Tarihi[aa/gg/yyyy] : ");
                _rentDate = Convert.ToDateTime(Console.ReadLine());
                _returnDate = null;
                _customerId = Convert.ToInt32(_tempCustomer);

                Rental rental = new Rental
                {
                    CarId = _carId,
                    CustomerId = _customerId,
                    RentDate = _rentDate,
                    ReturnDate = _returnDate
                };

                var result = rentalManager.Add(rental);
                Console.WriteLine(result.Message);

            }
        }

19 Source : RentalOperation.cs
with MIT License
from cemozaydin

public void UpdateToRentalReturnDate()
        {
            int _updateRentalId;
            DateTime _returnDateUpdate;

            Console.Write("Araç iadesi yapılacak 'KIRALAMA ID' : ");
            _updateRentalId = Convert.ToInt32(Console.ReadLine());
            Console.Write("Aracın İade Tarihi [aa/gg/yyyy]     : ");
            _returnDateUpdate = Convert.ToDateTime(Console.ReadLine());

            Rental rental = new Rental
            {
                Id = _updateRentalId,
                ReturnDate = _returnDateUpdate
            };

            var result = rentalManager.UpdateReturnDate(rental);
            Console.WriteLine(result.Message);
        }

19 Source : BasicDataConversion.cs
with MIT License
from chinabeacon

public static DateTime GetFirstDayOfCurrentYear()
        {
            return Convert.ToDateTime(DateTime.Now.Year + "-01-01");
        }

19 Source : BasicDataConversion.cs
with MIT License
from chinabeacon

public static DateTime StringToDateTime(this string dateTimeString)
        {
            if (string.IsNullOrEmpty(dateTimeString)) throw new ArgumentException($"{dateTimeString}参数不能为空");
            return Convert.ToDateTime(dateTimeString);
        }

19 Source : OdptXmplPackage.cs
with GNU General Public License v3.0
from ClayLipscomb

public IList<TypeITTableBigPartial> GetRowsTypedRet<TypeITTableBigPartial>(Decimal? pInNumber, ref String pInOutVarchar2, ref IList<Int64?> pInOutreplacedocarrayInteger, out DateTime? pOutDate, 
                UInt32? optionalMaxNumberRowsToReadFromAnyCursor = null, OracleConnection optionalPreexistingOpenConnection = null)
                where TypeITTableBigPartial : clreplaced, ITTableBigPartial, new() {
            IList<TypeITTableBigPartial> __ret = new List<TypeITTableBigPartial>(); pOutDate = null; 
            OracleConnection __conn = optionalPreexistingOpenConnection ?? GetConnection();
            try {
                using (OracleCommand __cmd = new OracleCommand("ODPT.XMPL_PKG_EXAMPLE.GET_ROWS_TYPED_RET", __conn)) {
                    __cmd.CommandType = CommandType.StoredProcedure;
                    __cmd.BindByName = true;
                    __cmd.Parameters.Add(new OracleParameter("!RETURN", OracleDbType.RefCursor, null, ParameterDirection.ReturnValue));
                    __cmd.Parameters.Add(new OracleParameter("P_IN_NUMBER", OracleDbType.Decimal, pInNumber, ParameterDirection.Input));
                    __cmd.Parameters.Add(new OracleParameter("P_IN_OUT_VARCHAR2", OracleDbType.Varchar2, 32767, pInOutVarchar2, ParameterDirection.InputOutput));

                    __cmd.Parameters.Add(new OracleParameter("P_IN_OUT_replacedOCARRAY_INTEGER", OracleDbType.Int64, 65535, null, ParameterDirection.InputOutput));
                    __cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value = (pInOutreplacedocarrayInteger == null || pInOutreplacedocarrayInteger.Count == 0 ? new Int64?[]{} : pInOutreplacedocarrayInteger.ToArray());
                    __cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].CollectionType = OracleCollectionType.PLSQLreplacedociativeArray;
                    __cmd.Parameters.Add(new OracleParameter("P_OUT_DATE", OracleDbType.Date, null, ParameterDirection.Output));

                    OracleCommandTrace __cmdTrace = IsTracing(__cmd) ? new OracleCommandTrace(__cmd) : null;
                    int __rowsAffected = __cmd.ExecuteNonQuery();
                    if (!((OracleRefCursor)__cmd.Parameters["!RETURN"].Value).IsNull)
                        using (OracleDataReader __rdr = ((OracleRefCursor)__cmd.Parameters["!RETURN"].Value).GetDataReader()) {
                            __ret = ReadResulreplacedTableBigPartial<TypeITTableBigPartial>(__rdr, optionalMaxNumberRowsToReadFromAnyCursor);
                        } // using OracleDataReader
                    pInOutVarchar2 = __cmd.Parameters["P_IN_OUT_VARCHAR2"].Status == OracleParameterStatus.NullFetched
                        ? (String)null
                        : Convert.ToString(__cmd.Parameters["P_IN_OUT_VARCHAR2"].Value.ToString());

                    pInOutreplacedocarrayInteger = new List<Int64?>();
                    for (int _i = 0; _i < (__cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value as OracleDecimal[]).Length; _i++)
                        pInOutreplacedocarrayInteger.Add((__cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value as OracleDecimal[])[_i].IsNull
                            ? (Int64?)null 
                            : Convert.ToInt64(((__cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value as OracleDecimal[])[_i].ToString())));

                    pOutDate = __cmd.Parameters["P_OUT_DATE"].Status == OracleParameterStatus.NullFetched
                        ? (DateTime?)null
                        : Convert.ToDateTime(__cmd.Parameters["P_OUT_DATE"].Value.ToString());
                    if (__cmdTrace != null) TraceCompletion(__cmdTrace, __ret.Count);
                } // using OracleCommand
            } finally {
                if (optionalPreexistingOpenConnection == null) {
                    __conn.Close();
                    __conn.Dispose();
                }
            }
            return __ret;
        }

19 Source : OdptXmplPackage.cs
with GNU General Public License v3.0
from ClayLipscomb

public IList<TypeITTableBigPartial> GetRowsTypedRet<TypeITTableBigPartial>(Decimal? pInNumber, ref String pInOutVarchar2, ref IList<Int64?> pInOutreplacedocarrayInteger, out DateTime? pOutDate, 
                UInt32? optionalMaxNumberRowsToReadFromAnyCursor = null, OracleConnection optionalPreexistingOpenConnection = null)
                where TypeITTableBigPartial : clreplaced, ITTableBigPartial, new() {
            IList<TypeITTableBigPartial> __ret = new List<TypeITTableBigPartial>(); pOutDate = null; 
            OracleConnection __conn = optionalPreexistingOpenConnection ?? GetConnection();
            try {
                using (OracleCommand __cmd = new OracleCommand("ODPT.XMPL_PKG_EXAMPLE.GET_ROWS_TYPED_RET", __conn)) {
                    __cmd.CommandType = CommandType.StoredProcedure;
                    __cmd.BindByName = true;
                    __cmd.Parameters.Add(new OracleParameter("!RETURN", OracleDbType.RefCursor, null, ParameterDirection.ReturnValue));
                    __cmd.Parameters.Add(new OracleParameter("P_IN_NUMBER", OracleDbType.Decimal, pInNumber, ParameterDirection.Input));
                    __cmd.Parameters.Add(new OracleParameter("P_IN_OUT_VARCHAR2", OracleDbType.Varchar2, 32767, pInOutVarchar2, ParameterDirection.InputOutput));

                    __cmd.Parameters.Add(new OracleParameter("P_IN_OUT_replacedOCARRAY_INTEGER", OracleDbType.Int64, 65535, null, ParameterDirection.InputOutput));
                    __cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value = (pInOutreplacedocarrayInteger == null || pInOutreplacedocarrayInteger.Count == 0 ? new Int64?[]{} : pInOutreplacedocarrayInteger.ToArray());
                    __cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].CollectionType = OracleCollectionType.PLSQLreplacedociativeArray;
                    __cmd.Parameters.Add(new OracleParameter("P_OUT_DATE", OracleDbType.Date, null, ParameterDirection.Output));

                    OracleCommandTrace __cmdTrace = IsTracing(__cmd) ? new OracleCommandTrace(__cmd) : null;
                    int __rowsAffected = __cmd.ExecuteNonQuery();
                    if (!((OracleRefCursor)__cmd.Parameters["!RETURN"].Value).IsNull)
                        using (OracleDataReader __rdr = ((OracleRefCursor)__cmd.Parameters["!RETURN"].Value).GetDataReader()) {
                            __ret = Hydrator.ReadResult<TypeITTableBigPartial>(__rdr, false, false, optionalMaxNumberRowsToReadFromAnyCursor);
                        } // using OracleDataReader
                    pInOutVarchar2 = __cmd.Parameters["P_IN_OUT_VARCHAR2"].Status == OracleParameterStatus.NullFetched
                        ? (String)null
                        : Convert.ToString(__cmd.Parameters["P_IN_OUT_VARCHAR2"].Value.ToString());

                    pInOutreplacedocarrayInteger = new List<Int64?>();
                    for (int _i = 0; _i < (__cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value as OracleDecimal[]).Length; _i++)
                        pInOutreplacedocarrayInteger.Add((__cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value as OracleDecimal[])[_i].IsNull
                            ? (Int64?)null 
                            : Convert.ToInt64(((__cmd.Parameters["P_IN_OUT_replacedOCARRAY_INTEGER"].Value as OracleDecimal[])[_i].ToString())));

                    pOutDate = __cmd.Parameters["P_OUT_DATE"].Status == OracleParameterStatus.NullFetched
                        ? (DateTime?)null
                        : Convert.ToDateTime(__cmd.Parameters["P_OUT_DATE"].Value.ToString());
                    if (__cmdTrace != null) TraceCompletion(__cmdTrace, __ret.Count);
                } // using OracleCommand
            } finally {
                if (optionalPreexistingOpenConnection == null) {
                    __conn.Close();
                    __conn.Dispose();
                }
            }
            return __ret;
        }

19 Source : DateTimeUtil.cs
with MIT License
from cocosip

public static int ToInt32(string datetime, int defaultValue = 0)
        {
            if (!RegexUtil.IsDataTime(datetime))
            {
                return defaultValue;
            }
            var end = Convert.ToDateTime(datetime);
            return ToInt32(end);
        }

19 Source : DateTimeUtil.cs
with MIT License
from cocosip

public static DateTime ReplaceDay(string day, DateTime datetime)
        {
            var fullTime = $"{datetime:yyyy-MM}-{day}";
            var date = Convert.ToDateTime(fullTime);
            return date;
        }

19 Source : DateTimeUtil.cs
with MIT License
from cocosip

public static DateTime ReplaceTime(string time, DateTime datetime)
        {
            var fullTime = $"{datetime:yyyy-MM-dd} {time}";
            var date = Convert.ToDateTime(fullTime);
            return date;
        }

19 Source : CheckSignBusiness.cs
with Apache License 2.0
from Coldairarrow

private bool CheckSign(Dictionary<string, object> allRequestParames, string appSecret)
        {
            try
            {
                //检验签名是否过期
                DateTime now = DateTime.Now.ToCstTime();
                DateTime requestTime = Convert.ToDateTime(allRequestParames["time"]?.ToString());
                if (requestTime < now.AddMinutes(-5) || requestTime > now.AddMinutes(5))
                    return false;

                //检验签名是否有效
                string oldSign = allRequestParames["sign"]?.ToString();
                Dictionary<string, object> parames = new Dictionary<string, object>();
                foreach (var aParam in allRequestParames)
                {
                    parames.Add(aParam.Key, aParam.Value);
                }

                parames.Remove("sign");
                string newSign = BuildSign(parames, appSecret);

                return oldSign == newSign;
            }
            catch
            {
                return false;
            }
        }

19 Source : CheckSignBusiness.cs
with Apache License 2.0
from Coldairarrow

private AjaxResult CheckSign(Dictionary<string, object> allRequestParames, string appSecret)
        {
            //检验签名是否过期
            DateTime now = DateTime.Now;
            DateTime requestTime = Convert.ToDateTime(allRequestParames["time"]?.ToString());
            if (requestTime < now.AddMinutes(-5) || requestTime > now.AddMinutes(5))
                return new ErrorResult("签名校验失败:time时间参数过期,请校准时间");

            //检验签名是否有效
            string oldSign = allRequestParames["sign"]?.ToString();
            Dictionary<string, object> parames = new Dictionary<string, object>();
            foreach (var aParam in allRequestParames)
            {
                parames.Add(aParam.Key, aParam.Value);
            }

            parames.Remove("sign");
            string newSign = BuildSign(parames, appSecret);
            if (newSign != oldSign)
                return new ErrorResult("签名校验失败:sign签名参数校验失败,请仔细核对签名算法");

            return Success();
        }

19 Source : GenericObjectToTypeConverter.cs
with MIT License
from craigbridges

private T ConvertFromString(string value)
        {
            var convertedValue = default(object);
            var convertType = typeof(T);

            if (String.IsNullOrEmpty(value))
            {
                return default(T);
            }

            if (convertType.IsNullable())
            {
                convertType = Nullable.GetUnderlyingType(convertType);
            }

            if (convertType == typeof(DateTime))
            {
                convertedValue = System.Convert.ToDateTime(value);
            }
            else if (convertType == typeof(bool))
            {
                convertedValue = System.Convert.ToBoolean(value);
            }
            else if (convertType == typeof(double))
            {
                convertedValue = System.Convert.ToDouble(value);
            }
            else if (convertType == typeof(Single))
            {
                convertedValue = System.Convert.ToSingle(value);
            }
            else if (convertType == typeof(decimal))
            {
                convertedValue = System.Convert.ToDecimal(value);
            }
            else if (convertType == typeof(long))
            {
                convertedValue = System.Convert.ToInt64(value);
            }
            else if (convertType == typeof(int))
            {
                convertedValue = System.Convert.ToInt32(value);
            }
            else if (convertType == typeof(short))
            {
                convertedValue = System.Convert.ToInt16(value);
            }
            else if (convertType == typeof(char))
            {
                convertedValue = System.Convert.ToChar(value);
            }
            else if (convertType == typeof(byte))
            {
                convertedValue = System.Convert.ToByte(value);
            }
            else if (convertType.IsEnum)
            {
                convertedValue = Enum.Parse(convertType, value);
            }
            else
            {
                RaiseCannotConvertException(value);
            }

            return (T)convertedValue;
        }

19 Source : GenericObjectConverter.cs
with MIT License
from craigbridges

private T ConvertFromString(string value)
        {
            var convertedValue = default(object);
            var convertType = typeof(T);

            if (String.IsNullOrEmpty(value))
            {
                return default;
            }

            if (convertType.IsNullable())
            {
                convertType = Nullable.GetUnderlyingType(convertType);
            }

            if (convertType == typeof(DateTime))
            {
                convertedValue = System.Convert.ToDateTime(value);
            }
            else if (convertType == typeof(bool))
            {
                convertedValue = System.Convert.ToBoolean(value);
            }
            else if (convertType == typeof(double))
            {
                convertedValue = System.Convert.ToDouble(value);
            }
            else if (convertType == typeof(Single))
            {
                convertedValue = System.Convert.ToSingle(value);
            }
            else if (convertType == typeof(decimal))
            {
                convertedValue = System.Convert.ToDecimal(value);
            }
            else if (convertType == typeof(long))
            {
                convertedValue = System.Convert.ToInt64(value);
            }
            else if (convertType == typeof(int))
            {
                convertedValue = System.Convert.ToInt32(value);
            }
            else if (convertType == typeof(short))
            {
                convertedValue = System.Convert.ToInt16(value);
            }
            else if (convertType == typeof(char))
            {
                convertedValue = System.Convert.ToChar(value);
            }
            else if (convertType == typeof(byte))
            {
                convertedValue = System.Convert.ToByte(value);
            }
            else if (convertType.IsEnum)
            {
                convertedValue = Enum.Parse(convertType, value);
            }
            else
            {
                RaiseCannotConvertException(value);
            }

            return (T)convertedValue;
        }

See More Examples