Example #1
0
        /// <summary>
        /// Verifies the specified code asynchronous.
        /// </summary>
        /// <param name="model">The verify code model.</param>
        /// <returns>A <see cref="Task{TResult}"/> represents the verify operation.</returns>
        public async Task <IResponse> VerifyCodeAsync(VerifyCodeModel model)
        {
            var user = await _userManager.FindByNameAsync(model.PhoneNumber);

            if (user == null)
            {
                if (!ValidateCode(model.Code, model.PhoneNumber))
                {
                    throw new ArgumentException(string.Format(Resources.VerifyCodeFailed, model.Code));
                }

                user = new TUser();

                // set user name
                var result = await _userManager.SetUserNameAsync(user, model.PhoneNumber);

                if (!result.Succeeded)
                {
                    HandleErrors(result, string.Format(Resources.RegisterNewUserFailed, model.PhoneNumber, model.Code));
                }

                // set phone number.
                if (_userManager.SupportsUserPhoneNumber)
                {
                    result = await _userManager.SetPhoneNumberAsync(user, model.PhoneNumber);

                    if (!result.Succeeded)
                    {
                        HandleErrors(result, string.Format(Resources.RegisterNewUserFailed, model.PhoneNumber, model.Code));
                    }
                }

                var password = $"{GenericUtil.UniqueKey()}@520";
                result = await _userManager.CreateAsync(user, password);

                if (!result.Succeeded)
                {
                    HandleErrors(result, string.Format(Resources.RegisterNewUserFailed, model.PhoneNumber, model.Code));
                }

                SendSmsResult smsResult;
                if (string.IsNullOrWhiteSpace(_options.PasswordSmsTemplate))
                {
                    smsResult = await _smsSender.SendSmsAsync(model.PhoneNumber, password);
                }
                else
                {
                    smsResult = await _smsSender.SendSmsAsync(_options.PasswordSmsTemplate, model.PhoneNumber, Tuple.Create("password", password));
                }
                if (!smsResult.IsSuccessSend)
                {
                    _logger.LogError(string.Format(Resources.SendPasswordFailed, model.PhoneNumber, smsResult.ErrorMessage));
                }

                // sign in
                await _signInManager.SignInAsync(user, isPersistent : false);

                return(await RequestTokenAsync(model.PhoneNumber, password));
            }
            else
            {
                if (!await _userManager.VerifyChangePhoneNumberTokenAsync(user, model.Code, model.PhoneNumber))
                {
                    throw new ArgumentException(string.Format(Resources.VerifyCodeFailed, model.Code));
                }

                await _signInManager.SignInAsync(user, isPersistent : false);

                var token = await RequestTokenAsync(model.PhoneNumber, model.Code);

                if (token.IsError)
                {
                    _logger.LogError(token.ToString());

                    throw new ArgumentNullException(string.Format(Resources.LoginFailedWithCodeAndPhone, model.Code, model.PhoneNumber));
                }

                return(token);
            }
        }
Example #2
0
            public static ActivityEntry FromCsvLine(string csvLine, bool recordOnlyValueLength)
            {
                var columnArray = csvLine.Split(new[] { ',' }).ToList();

                if (columnArray.Count != 4)
                {
                    throw new ArgumentException("invalid csv data - check that you do not have commas in data");
                }

                columnArray[3] = columnArray[3].Replace('|', ',');
                try
                {
                    if (columnArray[0] == DebugActionType.CreateTree.ToString())
                    {
                        var activityEntry = new ActivityEntry(
                            GenericUtil.ParseEnum <DebugActionType>(columnArray[0]),
                            Slice.Empty,
                            columnArray[1],
                            null);
                        return(activityEntry);
                    }

                    if (columnArray[0] == DebugActionType.Delete.ToString())
                    {
                        var activityEntry = new ActivityEntry(
                            GenericUtil.ParseEnum <DebugActionType>(columnArray[0]),
                            columnArray[2],
                            columnArray[1],
                            null);

                        return(activityEntry);
                    }

                    var random = new Random();

                    var    type = GenericUtil.ParseEnum <DebugActionType>(columnArray[0]);
                    object value;
                    switch (type)
                    {
                    case DebugActionType.MultiAdd:
                    case DebugActionType.MultiDelete:
                        value = new Slice(Encoding.UTF8.GetBytes(columnArray[3]));
                        break;

                    default:
                        if (recordOnlyValueLength)
                        {
                            var length = long.Parse(columnArray[3]);
                            var bytes  = new byte[length];
                            random.NextBytes(bytes);

                            value = new MemoryStream(bytes);
                        }
                        else
                        {
                            value = new MemoryStream(Encoding.UTF8.GetBytes(columnArray[3]));
                        }
                        break;
                    }

                    var entry = new ActivityEntry(type,
                                                  columnArray[2],
                                                  columnArray[1],
                                                  value);

                    return(entry);
                }
                catch (Exception e)
                {
                    throw new ArgumentException("Unable to parse the argument", e);
                }
            }
Example #3
0
 public override string ToString()
 {
     return(new string(GenericUtil.RemoveAt(NaturalNumber, ExcludedIndices).ToArray()));
 }
        private void  動品検索()
        {
            //アクティブボタン = 在庫検索ボタンEnum.不動品;


            dg現在庫.Visible = false;
            dg使用量.Visible = false;
            dg不動品.Visible = true;
            dg後発品.Visible = false;


            // 空文字ならば、検索しない。
            if (tb検索キーワード.Text.Replace(" ", "").Replace(" ", "").Equals(""))
            {
                //// カーソルをもとの状態にする
                //this.SetCursorDefault();


                return;
            }


            bool 全期限   = false;
            bool 期限内   = false;
            bool 期限切   = false;
            bool 期限指定  = false;
            bool 以内指定か = false;
            int  期限加算月 = 0;


            if (ddl使用期限日.SelectedIndex == 0)
            {
                全期限 = true;
            }
            else if (ddl使用期限日.SelectedIndex == 1)
            {
                期限内 = true;
            }
            else if (ddl使用期限日.SelectedIndex == 2)
            {
                期限切 = true;
            }
            else if (3 <= ddl使用期限日.SelectedIndex)
            {
                期限指定 = true;
                Tuple <int, bool> tp = Set期限加算月();
                期限加算月 = tp.Value1;
                以内指定か = tp.Value2;
            }

            Service.File.Reader.FileReaderClient client = ReferenceCreater.GetFileReaderClient();


            var rdataset = client.Open不動品CSV(tb検索キーワード.Text, 全期限, 期限内, 期限切, 期限指定, 以内指定か, 期限加算月);


            if (string.IsNullOrEmpty(rdataset.エラーメッセージ))
            {
                var dataList = rdataset.検索結果データlist.ToList();
                var 表示順序dic  = Session["店舗名List"] as Dictionary <int, string>;
                if (表示順序dic == null)
                {
                    return;
                }

                // 表示順序に登録されていない店舗があった場合に使用する臨時dic
                var CopyDic = GenericUtil.Copy(表示順序dic);
                int cnt     = CopyDic.Count + 1;

                dataList.Sort(
                    delegate(動品データ x, 動品データ y)
                {
                    int xValue = 0;
                    int yValue = 0;
                    foreach (var d in CopyDic)
                    {
                        if (d.Value.Equals(x.店名))
                        {
                            xValue = d.Key;
                        }

                        if (d.Value.Equals(y.店名))
                        {
                            yValue = d.Key;
                        }
                    }

                    // 一致するものがなかったら、臨時のcntの番号にする(表示順序が後ろ)
                    bool xy店名が等しい = false;
                    if (xValue == 0)
                    {
                        if (x.店名.Equals(y.店名))
                        {
                            xy店名が等しい = true;
                        }

                        xValue = cnt;
                        CopyDic.Add(cnt, x.店名);
                        cnt++;
                    }

                    if (yValue == 0)
                    {
                        if (xy店名が等しい)
                        {
                            yValue = xValue;
                        }
                        else
                        {
                            yValue = cnt;
                            CopyDic.Add(cnt, y.店名);
                            cnt++;
                        }
                    }

                    // 店名が等しい場合は、医薬品名のアイウエオ順
                    if (xValue == yValue)
                    {
                        return(x.医薬品名.CompareTo(y.医薬品名));
                    }


                    return(xValue - yValue);
                }
                    );


                dg不動品.DataSource = dataList;
                dg不動品.DataBind();

                Set在庫検索結果Result(dataList.Count, rdataset.検索キーワード);
            }
            else
            {
                // メッセージボックスを出すとXPだとIMEが利かなくなるので中止
                //MessageBox.Show(rdataset.エラーメッセージ, "検索結果", MessageBoxButton.OK);
                lbSearchResult.Text = rdataset.エラーメッセージ;
            }
        }
        private void 後発品検索()
        {
            //アクティブボタン = 在庫検索ボタンEnum.後発品;

            dg現在庫.Visible = false;
            dg使用量.Visible = false;
            dg不動品.Visible = false;
            dg後発品.Visible = true;

            // 空文字ならば、検索しない。
            if (tb検索キーワード.Text.Replace(" ", "").Replace(" ", "").Equals(""))
            {
                //// カーソルをもとの状態にする
                //this.SetCursorDefault();

                return;
            }

            int result;

            if (tb検索キーワード.Text.Length != 12)
            {
                return;
            }
            else if (int.TryParse(tb検索キーワード.Text.Substring(0, 7), out result) == false)
            {
                return;
            }
            else if (int.TryParse(tb検索キーワード.Text.Substring(8, 4), out result) == false)
            {
                return;
            }

            bool 全期限         = false;
            bool 期限内         = false;
            bool 期限切         = false;
            bool 期限指定        = false;
            bool 以内指定か       = false;
            int  期限加算月       = 0;
            bool 他規格・剤形も表示する = false;

            if (ddl使用期限日.SelectedIndex == 0)
            {
                全期限 = true;
            }
            else if (ddl使用期限日.SelectedIndex == 1)
            {
                期限内 = true;
            }
            else if (ddl使用期限日.SelectedIndex == 2)
            {
                期限切 = true;
            }
            else if (3 <= ddl使用期限日.SelectedIndex)
            {
                期限指定 = true;
                Tuple <int, bool> tp = Set期限加算月();
                期限加算月 = tp.Value1;
                以内指定か = tp.Value2;
            }


            if (ddl後発品検索.SelectedIndex == 0)
            {
                他規格・剤形も表示する = false;
            }
            else
            {
                他規格・剤形も表示する = true;
            }



            if (tb検索キーワード.Text == "")
            {
                return;
            }

            Service.File.Reader.FileReaderClient client = ReferenceCreater.GetFileReaderClient();


            var rdataset = client.Get後発品検索データ(tb検索キーワード.Text, 全期限, 期限内, 期限切, 期限指定, 以内指定か, 期限加算月, 他規格・剤形も表示する);

            if (rdataset.検索結果データlist != null)
            {
            }

            if (string.IsNullOrEmpty(rdataset.エラーメッセージ))
            {
                var dataList = rdataset.検索結果データlist.ToList();
                var 表示順序dic  = Session["店舗名List"] as Dictionary <int, string>;
                if (表示順序dic == null)
                {
                    return;
                }
                // 表示順序に登録されていない店舗があった場合に使用する臨時dic
                var CopyDic = GenericUtil.Copy(表示順序dic);
                int cnt     = CopyDic.Count + 1;

                dataList.Sort(
                    delegate(現在庫データ x, 現在庫データ y)
                {
                    int xValue = 0;
                    int yValue = 0;
                    foreach (var d in CopyDic)
                    {
                        if (d.Value.Equals(x.店名))
                        {
                            xValue = d.Key;
                        }

                        if (d.Value.Equals(y.店名))
                        {
                            yValue = d.Key;
                        }
                    }

                    // 一致するものがなかったら、臨時のcntの番号にする(表示順序が後ろ)
                    bool xy店名が等しい = false;
                    if (xValue == 0)
                    {
                        if (x.店名.Equals(y.店名))
                        {
                            xy店名が等しい = true;
                        }

                        xValue = cnt;
                        CopyDic.Add(cnt, x.店名);
                        cnt++;
                    }

                    if (yValue == 0)
                    {
                        if (xy店名が等しい)
                        {
                            yValue = xValue;
                        }
                        else
                        {
                            yValue = cnt;
                            CopyDic.Add(cnt, y.店名);
                            cnt++;
                        }
                    }

                    if (xValue != yValue)
                    {
                        return(xValue - yValue);
                    }


                    // 店名が等しい場合は、次は先発か後発で判断する。
                    if (xValue == yValue)
                    {
                        bool x先発か = x.後発区分.Equals("") ? false : true;
                        bool y先発か = y.後発区分.Equals("") ? false : true;

                        if (x先発か == y先発か)
                        {
                        }
                        else if (x先発か == true)
                        {
                            return(-1);
                        }
                        else
                        {
                            return(1);
                        }
                    }

                    // 店名も等しくて、先発かも等しい
                    if (xValue == yValue)
                    {
                        double x薬価;
                        double y薬価;
                        if (double.TryParse(x.薬価, out x薬価) == false)
                        {
                            return(1);
                        }

                        if (double.TryParse(y.薬価, out y薬価) == false)
                        {
                            return(-1);
                        }


                        if (x薬価 > y薬価)
                        {
                            return(-1);
                        }

                        if (y薬価 > x薬価)
                        {
                            return(1);
                        }
                    }

                    // 店名も等しくて、先発かも等しく、薬価も等しい
                    if (xValue == yValue)
                    {
                        return(x.医薬品名.CompareTo(y.医薬品名));
                    }


                    return(xValue - yValue);
                    //return yValue - xValue;
                }
                    );


                dg後発品.DataSource = dataList;
                dg後発品.DataBind();
                Set在庫検索結果Result(dataList.Count, rdataset.検索キーワード);
            }
            else
            {
                lbSearchResult.Text = rdataset.エラーメッセージ;
                // メッセージボックスを出すとXPだとIMEが利かなくなるので中止
                // MessageBox.Show(rdataset.エラーメッセージ, "検索結果", MessageBoxButton.OK);
            }
        }
        public IGcl Analy(string name)
        {
            var array = context.SearchGCL(name);

            if (array.Length == 1)
            {
                IGcl gcl0            = array[0];
                int  genericArgCount = GenericUtil.GetGenericTypeArgCount(gcl0.ForType);
                if (genericArgCount == 0)
                {
                    return(gcl0);
                }
                else if (genericArgCount == 1)
                {
                    Type newType = gcl0.ForType.MakeGenericType(new Type[] { typeof(object) });
                    IGcl result  = gcl0.CreateNewFor(newType);
                    return(result);
                }
                else if (genericArgCount == 2)
                {
                    Type newType = gcl0.ForType.MakeGenericType(new Type[] { typeof(object), typeof(object) });
                    IGcl result  = gcl0.CreateNewFor(newType);
                    return(result);
                }
                else
                {
                    return(null);
                }
            }
            else if (array.Length > 1)
            {
                return(null);
            }

            List <IGcl> glist = FindGenericEndwith(name);

            if (glist.Count == 0)
            {
                return(null);
            }
            foreach (IGcl mpClass in glist)
            {
                int    genericArgCount = GenericUtil.GetGenericTypeArgCount(mpClass.ForType);
                string typeName        = mpClass.ShowName;
                string gtypeName       = name.Substring(0, name.Length - typeName.Length);
                if (genericArgCount == 1)
                {
                    var gcls = context.SearchGCLFromImport(gtypeName);//searchTypeSymbol(gtypeName);
                    if (gcls.Length == 1)
                    {
                        Type newType = mpClass.ForType.MakeGenericType(new Type[] { gcls[0].ForType });
                        IGcl result  = mpClass.CreateNewFor(newType);
                        return(result);
                    }
                }
                else if (genericArgCount == 2)
                {
                    List <IGcl> nlist = FindImportEndwith(gtypeName);
                    if (nlist.Count == 0)
                    {
                        return(null);
                    }
                    foreach (var nClass in nlist)
                    {
                        string ntypeName  = nClass.ShowName;
                        string ngtypeName = gtypeName.Substring(0, gtypeName.Length - ntypeName.Length); //string ngtypeName = gtypeName.Substring(0, name.Length - ntypeName.Length);
                        //ITypeSymbol ntypeSymbol = searchTypeSymbol(ngtypeName);
                        var gcls = context.SearchGCLFromImport(ngtypeName);                              //var gcls = context.SearchGCLFromImport(gtypeName);
                        if (gcls.Length == 1)
                        {
                            var  gcl0    = gcls[0];
                            Type newType = mpClass.ForType.MakeGenericType(new Type[] { gcl0.ForType, nClass.ForType });
                            IGcl result  = mpClass.CreateNewFor(newType); //gcl0.CreateNewFor(newType);
                            return(result);
                        }
                    }
                }
            }
            return(null);
        }
        private void 使用量検索()
        {
            //アクティブボタン = 在庫検索ボタンEnum.使用量;


            dg現在庫.Visible = false;
            dg使用量.Visible = true;
            dg不動品.Visible = false;
            dg後発品.Visible = false;

            // 空文字ならば、検索しない。
            if (tb検索キーワード.Text.Replace(" ", "").Replace(" ", "").Equals(""))
            {
                //// カーソルをもとの状態にする
                //this.SetCursorDefault();

                return;
            }

            bool 全期限   = false;
            int  期限加算月 = 3;

            if (ddl使用量検索.SelectedIndex == 0)
            {
                全期限 = true;
            }
            else
            {
                期限加算月 = Set使用量検索期限加算月();
            }

            Service.File.Reader.FileReaderClient client = ReferenceCreater.GetFileReaderClient();

            //var rdataset = client.Open使用量CSV(tb検索キーワード.Text, 全期限, 期限加算月);
            var rdataset = client.Open使用量2CSV(tb検索キーワード.Text, 全期限, 期限加算月);


            if (string.IsNullOrEmpty(rdataset.エラーメッセージ))
            {
                var dataList = rdataset.検索結果データlist.ToList();
                var 表示順序dic  = Session["店舗名List"] as Dictionary <int, string>;
                if (表示順序dic == null)
                {
                    return;
                }

                // 表示順序に登録されていない店舗があった場合に使用する臨時dic
                var CopyDic = GenericUtil.Copy(表示順序dic);
                int cnt     = CopyDic.Count + 1;

                dataList.Sort(
                    delegate(薬局使用量データ x, 薬局使用量データ y)
                {
                    int xValue = 0;
                    int yValue = 0;
                    foreach (var d in CopyDic)
                    {
                        if (d.Value.Equals(x.店名))
                        {
                            xValue = d.Key;
                        }

                        if (d.Value.Equals(y.店名))
                        {
                            yValue = d.Key;
                        }
                    }

                    // 一致するものがなかったら、臨時のcntの番号にする(表示順序が後ろ)
                    bool xy店名が等しい = false;
                    if (xValue == 0)
                    {
                        if (x.店名.Equals(y.店名))
                        {
                            xy店名が等しい = true;
                        }

                        xValue = cnt;
                        CopyDic.Add(cnt, x.店名);
                        cnt++;
                    }

                    if (yValue == 0)
                    {
                        if (xy店名が等しい)
                        {
                            yValue = xValue;
                        }
                        else
                        {
                            yValue = cnt;
                            CopyDic.Add(cnt, y.店名);
                            cnt++;
                        }
                    }

                    if (xValue != yValue)
                    {
                        return(xValue - yValue);
                    }

                    // 等しい場合は、さらに使用年月日で比較する
                    if (xValue == yValue)
                    {
                        DateTime xの年月日;
                        DateTime yの年月日;

                        // xがDateTimeにキャストできない場合は、後ろに
                        if (DateTime.TryParse(x.使用年月, out xの年月日) == false)
                        {
                            return(1);
                        }


                        // yがDateTimeにキャストできない場合は、前に
                        if (DateTime.TryParse(y.使用年月, out yの年月日) == false)
                        {
                            return(-1);
                        }


                        if (xの年月日 > yの年月日)
                        {
                            return(-1);
                        }
                        else if (yの年月日 > xの年月日)
                        {
                            return(1);
                        }
                    }

                    // 店名が等しく、使用年月も等しい場合は、医薬品名のアイウエオ順
                    if (xValue == yValue)
                    {
                        return(x.医薬品名.CompareTo(y.医薬品名));
                    }


                    return(xValue - yValue);
                }
                    );

                dg使用量.DataSource = dataList;
                dg使用量.DataBind();

                Set在庫検索結果Result(dataList.Count, rdataset.検索キーワード);
            }
            else
            {
                lbSearchResult.Text = rdataset.エラーメッセージ;
            }
        }
Example #8
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     this.mPresenter = new ReportePlanillaEditor(this);
     Permiso permiso = GenericUtil.ValidarFormulario(AppInfo.CurrentUser, this.Name);
 }
Example #9
0
        private void executeResponseMsg()
        {
            //SetRtbRxConsole(responseMsg.getMessageByte);
            int    id      = getIdFromCA(responseMsg.Guid);
            string command = new string(responseMsg.Command);

            // 1层数据流
            if (command == "PING")
            {
                //在界面上显示心跳
                string _shortAddr = new string(responseMsg.Value, 0, 4);
                rftaglist[id - Offset - 1].heartBeat(8);
                SetRtbStatusConsole("" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 网络地址[" + _shortAddr + "]\n");
                SessionArray[id].ShortAddr = _shortAddr;
                rftaglist[id - Offset - 1].SetLabelTagID(_shortAddr);
            }
            // 2层数据流
            else if (command == "TKME")
            {
                string respResult = new string(responseMsg.Value, 0, responseMsg.Length);
                if (respResult == "OK")
                {
                    rftaglist[id - Offset - 1].darkenLED(2);
                    rftaglist[id - Offset - 1].lightLED(1);
                    SetRtbStatusConsole("" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 取药命令[成功]\n");
                }
                else
                {
                    rftaglist[id - Offset - 1].darkenLED(1);
                    rftaglist[id - Offset - 1].darkenLED(2);
                    string alertValue = "" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 补药命令[错误:" + respResult + "]\n";
                    SetRtbStatusConsole(alertValue);
                    MessageBox.Show(alertValue);
                }
            }
            // 2层数据流
            else if (command == "ADME")
            {
                string respResult = new string(responseMsg.Value, 0, responseMsg.Length);
                if (respResult == "OK")
                {
                    rftaglist[id - Offset - 1].darkenLED(1);
                    rftaglist[id - Offset - 1].lightLED(2);
                    SetRtbStatusConsole("" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 补药命令[成功]\n");
                }
                else
                {
                    rftaglist[id - Offset - 1].darkenLED(1);
                    rftaglist[id - Offset - 1].darkenLED(2);
                    string alertValue = "" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 补药命令[错误:" + respResult + "]\n";
                    SetRtbStatusConsole(alertValue);
                    MessageBox.Show(alertValue);
                }
            }
            // 3层数据流
            else if (command == "AKTK")
            {
                //1 判断是否为Push Button首次确认
                if (responseMsg.Length == 0)
                {
                    executeTakeAck(id);
                }
                // 2
                else
                {
                    string respResult = new string(responseMsg.Value, 0, responseMsg.Length);
                    if (respResult == "OK")
                    {
                        rftaglist[id - Offset - 1].darkenLED(1);
                        SetRtbStatusConsole("" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 取药确认[成功]\n");
                    }
                    else
                    {
                        rftaglist[id - Offset - 1].darkenLED(1);
                        string alertValue = "" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 取药确认[错误:" + respResult + "]\n";
                        SetRtbStatusConsole(alertValue);
                        MessageBox.Show(alertValue);
                    }
                }
            }
            // 3层数据流
            else if (command == "AKAD")
            {
                //1 判断是否为Push Button首次确认
                if (responseMsg.Length == 0)
                {
                    executeAlertAck(id);
                }
                // 2
                else
                {
                    string respResult = new string(responseMsg.Value, 0, responseMsg.Length);
                    if (respResult == "OK")
                    {
                        rftaglist[id - Offset - 1].darkenLED(2);
                        SetRtbStatusConsole("" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 补药确认[成功]\n");
                    }
                    else
                    {
                        rftaglist[id - Offset - 1].darkenLED(2);
                        string alertValue = "" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 补药确认[错误:" + respResult + "]\n";
                        SetRtbStatusConsole(alertValue);
                        MessageBox.Show(alertValue);
                    }
                }
            }
            // 3层数据流
            else if (command == "LTME")
            {
                //1 判断是否为Push Button首次确认
                if (responseMsg.Length == 0)
                {
                    executeQueryAck(id);
                }
                // 2
                else
                {
                    string respResult = new string(responseMsg.Value, 0, responseMsg.Length);
                    if (respResult == "OK")
                    {
                        SetRtbStatusConsole("" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 查询确认[成功]\n");
                    }
                    else
                    {
                        string alertValue = "" + GenericUtil.Generic_ConvertToGuid(id) + " ----> 查询确认[错误:" + respResult + "]\n";
                        SetRtbStatusConsole(alertValue);
                        MessageBox.Show(alertValue);
                    }
                }
            }
        }
        public void Load()
        {
            // for each heightmap component, create Model instance to enable Draw calls when rendering
            foreach (var renderable in Game1.Inst.Scene.GetComponents <C3DRenderable>())
            {
                if (renderable.Value.GetType() != typeof(CHeightmap))
                {
                    continue;
                }
                CHeightmap heightmap = (CHeightmap)renderable.Value;

                /* use each color channel for different data, e.g.
                 * R for height,
                 * G for texture/material/terrain type,
                 * B for fixed spawned models/entities (houses, trees etc.),
                 * A for additional data
                 */


                List <ModelMesh> meshes = new List <ModelMesh>();
                var bones = new List <ModelBone>();

                var indices  = new Dictionary <int, int[]>();
                var vertices = new Dictionary <int, VertexPositionNormalColor[]>();

                CreateIndicesChunk(heightmap, ref indices, 0);
                CalculateHeightData(heightmap);
                CreateVerticesChunks(heightmap, ref vertices, 0, 0);
                basicEffect.Texture = heightmap.Image;
                for (int j = 0; j < vertices.Values.Count; j++)
                {
                    var vert = vertices[j];
                    var ind  = indices[j];
                    CalculateNormals(ref vert, ref ind);
                    vertices[j] = vert;
                    indices[j]  = ind;

                    var modelpart = CreateModelPart(vert, ind);
                    List <ModelMeshPart> meshParts = new List <ModelMeshPart>();
                    meshParts.Add(modelpart);

                    ModelMesh modelMesh = new ModelMesh(mGraphicsDevice, meshParts);
                    modelMesh.BoundingSphere = new BoundingSphere();
                    ModelBone modelBone = new ModelBone();
                    modelBone.AddMesh(modelMesh);
                    modelBone.Transform = Matrix.CreateTranslation(new Vector3(0, 0, 0));                     // changing object world (frame) / origo

                    modelMesh.ParentBone = modelBone;
                    bones.Add(modelBone);
                    meshes.Add(modelMesh);
                    modelMesh.BoundingSphere = BoundingSphere.CreateFromBoundingBox(GenericUtil.BuildBoundingBoxForVertex(vert, Matrix.Identity));
                    modelpart.Effect         = basicEffect;
                }
                ModelMeshPart        ground          = buildGround(heightmap, 20);
                List <ModelMeshPart> groundMeshParts = new List <ModelMeshPart>();
                groundMeshParts.Add(ground);
                ModelMesh groundMesh = new ModelMesh(mGraphicsDevice, groundMeshParts);
                groundMesh.BoundingSphere = new BoundingSphere();
                ModelBone groundBone = new ModelBone();
                groundBone.AddMesh(groundMesh);
                groundBone.Transform  = Matrix.CreateTranslation(new Vector3(0, 0, 0));
                groundMesh.ParentBone = groundBone;
                groundMesh.Name       = "FrontFace";
                bones.Add(groundBone);
                meshes.Add(groundMesh);
                ground.Effect = basicEffect;

                heightmap.model     = new Model(mGraphicsDevice, bones, meshes);
                heightmap.model.Tag = "Map";
            }
        }
Example #11
0
        public List <UserLog> ObtenerTodoUserLogs()
        {
            List <UserLog> UserLogs = GenericUtil.GetUserLog();

            return(UserLogs);
        }
Example #12
0
 private void Insertar(ref bool successful, ref string message)
 {
     message = "Nuevo registro";
     GenericUtil.CreateLog(ModuloLog.Administracion, TipoObjeto.Numeracion, TipoLog.Informacion,
                           string.Format("{0}: {1}", message, this.mCurrent.ToString()));
 }
Example #13
0
        private List <Bet> listBetByIdGame(IResponseService getListGame)
        {
            object elementObject = GenericUtil.GetElementsResultService(getListGame.Result);

            return((List <Bet>)elementObject);
        }
Example #14
0
        internal void DoWork(ChatMessage lastMessage)
        {
            //If Filtering is enabled and timeouted or banned, we don't need to do anything else
            if (ConfigInstance.FilteringEnabled && PerformActionFiltering(lastMessage))
            {
                return;
            }

            //This is a useful optimisation trick, since commands all start with a one and the same prefix, we don't actually have to spend time comparing strings, if we know that prefix was wrong
            if (!lastMessage.Message.StartsWith(CommandPrefix) || CoreConfigInstance.IgnoredUsers.Contains(lastMessage.Username))
            {
                return;
            }

            //Do not perform actions if user is on cooldown
            if (UserCooldowns.ContainsKey(lastMessage.Username) && UserCooldowns[lastMessage.Username] > DateTime.UtcNow)
            {
                return;
            }

            //All of the commands are declared with lower cases
            var messageLazy = lastMessage.Message.ToLower();

            messageLazy = messageLazy.Remove(0, 1);

            //Properties
            if (messageLazy.StartsWithLazy("getproperty"))
            {
                ConfigInstance.GetProperty(this, lastMessage);
                return;
            }

            if (messageLazy.StartsWithLazy("setproperty"))
            {
                ConfigInstance.SetPropety(this, lastMessage);
                return;
            }

            //Quotes
            if (ConfigInstance.QuotesEnabled && (messageLazy.StartsWith("quote") || messageLazy.StartsWith("quotes")))
            {
                QuotesInstance.DoWork(lastMessage);
                return;
            }

            //Chat Filter
            if (ConfigInstance.FilteringEnabled && (messageLazy.StartsWith("chatfilter") || messageLazy.StartsWith("filter")))
            {
                ChatFiltering.DoWork(lastMessage);
                return;
            }

            //Leaderboards
            if (ConfigInstance.LeaderboardsEnabled)
            {
                if (messageLazy == "wr" || messageLazy.StartsWithWordLazy("wr"))
                {
                    Leaderboards.DoWorkWR(lastMessage);
                    return;
                }
                else if (messageLazy == "pb" || messageLazy.StartsWithWordLazy("pb"))
                {
                    Leaderboards.DoWorkPB(lastMessage);
                    return;
                }
                else if (lastMessage.UserRole <= Role.Mod && messageLazy.StartsWithWordLazy(new string[] { "leaderboard", "leaderboards" }))
                {
                    Leaderboards.DoModWork(lastMessage);
                    return;
                }
            }

            //Interval Messages
            if (ConfigInstance.IntervalMessageEnabled)
            {
                if (messageLazy.StartsWithWordLazy(new string[] { "intervalmessage", "intervalmessages" }))
                {
                    if (lastMessage.UserRole <= Role.Mod)
                    {
                        IntervalMessagesInstance.DoWork(lastMessage);
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            //Srl
            if (messageLazy.StartsWith("srl"))
            {
                Components.SRL.GetRaces(this);
                SetUserCooldown(lastMessage, DefaultCooldown);
                return;
            }

            //PCGW
            if (messageLazy.StartsWith("pcgw"))
            {
                PCGW.DoWork(lastMessage);
                return;
            }

            //Twitch update
            if (messageLazy.StartsWith("updatestatus") && lastMessage.UserRole <= Role.VIP)
            {
                UpdateTwitchStatus(true);
                return;
            }

            //Killswitch
            if (messageLazy.StartsWith("killbot") && lastMessage.UserRole == Role.SuperMod)
            {
                ShutdownTask();
                return;
            }

            //GenericUtilComponents
            if (ConfigInstance.GenericUtil.ENABLE)
            {
                if (ConfigInstance.GenericUtil.UptimeEnabled && messageLazy.StartsWith("uptime"))
                {
                    GenericUtil.GetUpTime(lastMessage);
                    return;
                }
            }


            //MemeCompoenents
            if (ConfigInstance.MemeComponents.ENABLE)
            {
                MemeComponents.DoWork(lastMessage);
            }


            //Custom Cvars
            if (ConfigInstance.CustomCvarsEnabled)
            {
                if (messageLazy.StartsWithLazy(new string[] { "cvar", "cvars" }))
                {
                    if (lastMessage.UserRole <= Role.Mod)
                    {
                        Cvars.DoWork(lastMessage);
                        return;
                    }
                    else
                    {
                        return;
                    }
                }

                if (Cvars.PerformCustomCvar(lastMessage))
                {
                    return;
                }
            }
        }
Example #15
0
            public new static WriteActivityEntry FromCsvLine(string csvLine, bool recordOnlyValueLength)
            {
                var columnArray = csvLine.Split(new[] { ',' }).ToList();

                if (columnArray.Count != 5)
                {
                    throw new ArgumentException("invalid csv data - check that you do not have commas in data");
                }

                try
                {
                    var type = GenericUtil.ParseEnum <DebugActionType>(columnArray[0]);

                    if (type == DebugActionType.CreateTree)
                    {
                        var activityEntry = new WriteActivityEntry(
                            type,
                            long.Parse(columnArray[1]),
                            Slice.Empty,
                            columnArray[2],
                            null);
                        return(activityEntry);
                    }

                    if (type == DebugActionType.Delete)
                    {
                        var activityEntry = new WriteActivityEntry(
                            type,
                            long.Parse(columnArray[1]),
                            columnArray[3],
                            columnArray[2],
                            null);

                        return(activityEntry);
                    }

                    var random = new Random();

                    object value;
                    switch (type)
                    {
                    case DebugActionType.Increment:
                        var delta = long.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(columnArray[4])));
                        value = new MemoryStream(EndianBitConverter.Little.GetBytes(delta));
                        break;

                    case DebugActionType.MultiAdd:
                    case DebugActionType.MultiDelete:
                        value = new Slice(Convert.FromBase64String(columnArray[4]));
                        break;

                    default:
                        if (recordOnlyValueLength)
                        {
                            var length = long.Parse(columnArray[4]);
                            var bytes  = new byte[length];
                            random.NextBytes(bytes);

                            value = new MemoryStream(bytes);
                        }
                        else
                        {
                            value = new MemoryStream(Convert.FromBase64String(columnArray[4]));
                        }
                        break;
                    }

                    var entry = new WriteActivityEntry(
                        type,
                        long.Parse(columnArray[1]),
                        columnArray[3],
                        columnArray[2],
                        value);

                    return(entry);
                }
                catch (Exception e)
                {
                    throw new ArgumentException("Unable to parse the argument", e);
                }
            }
        // TBD:
        // The problem with this algo is we have no way to consistently represent null node.
        // For map value and list element, we can just use Java null.
        // But, in general, it may not be possible.....  ????    Is this true????
        // Seems to be working so far (based on the limited unit test cases...)
        private object _BuildJsonStruct(object obj, int depth)
        {
            //        if(depth < 0) {
            //            return null;
            //        }
            object jsonStruct = null;

            if (obj == null || obj is JsonNull)                 // ????
            // return null;
            {
            }
            else
            {
                // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> depth = " + depth);
                // if(depth == 0) {
                if (depth <= 0)
                {
                    if (obj is bool ||
                        obj is char ||
                        Number.IsNumber(obj)
                        )
                    {
                        jsonStruct = obj;
                    }
                    else if (obj is String)
                    {
                        // Note that this string is not a "json string" (e.g., forward slash escaped, etc.)
                        // e.g., if the string is "...\\/...", we will read it as "...\\/..." not as ".../...".
                        jsonStruct = (String)obj;
                    }
                    else
                    {
                        // ????
                        jsonStruct = obj.ToString();
                    }
                }
                else
                {
                    // if (obj is IDictionary<String, Object>) {
                    if (GenericUtil.IsDictionary(obj))
                    {
                        //IDictionary<String, Object> jsonIDictionary = new OrderedMap<String, Object>();
                        IDictionary <String, Object> jsonIDictionary = new Dictionary <String, Object>();
                        // ...

                        // ????
                        // IDictionary<String,Object> map = null;
                        dynamic map = null;
                        try {
                            // map = (IDictionary<String,Object>) obj;
                            map = obj;
                        } catch (Exception e) {
                            System.Diagnostics.Debug.WriteLine("Invalid map type.", e);
                            // What to do???
                            // Use map.ToString???
                        }
                        if (map != null && map.Count > 0)
                        {
                            foreach (string f in map.Keys)
                            {
                                object val     = map[f];
                                object jsonVal = _BuildJsonStruct(val, depth - 1);
                                if (jsonVal != null)
                                {
                                    jsonIDictionary.Add(f, jsonVal);
                                }
                                else
                                {
                                    // ???
                                    jsonIDictionary.Add(f, null);
                                }
                            }
                        }

                        jsonStruct = jsonIDictionary;
                        // } else if (obj is IList<Object>) {
                    }
                    else if (GenericUtil.IsList(obj))
                    {
                        IList <Object> jsonList = new List <Object>();

                        // ????
                        // IList<Object> list = null;
                        dynamic list = null;
                        try {
                            // list = (IList<Object>) obj;
                            list = obj;
                        } catch (Exception e) {
                            System.Diagnostics.Debug.WriteLine("Invalid list type.", e);
                            // What to do???
                            // Use list.ToString???
                        }
                        if (list != null && list.Count > 0)
                        {
                            foreach (object v in list)
                            {
                                object jsonVal = _BuildJsonStruct(v, depth - 1);
                                if (jsonVal != null)
                                {
                                    jsonList.Add(jsonVal);
                                }
                                else
                                {
                                    // ???
                                    jsonList.Add(null);
                                }
                            }
                        }

                        jsonStruct = jsonList;
                    }
                    else if (obj.GetType().IsArray)              // ???
                    {
                        List <Object> jsonList = new List <Object>();

                        // ????
                        // object array = obj;
                        dynamic array = obj;

                        if (array != null && array.Length > 0)
                        {
                            int arrLen = array.Length;
                            // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> arrLen = " + arrLen);
                            for (int i = 0; i < arrLen; i++)
                            {
                                object o = array[i];
                                // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> o = " + o + "; " + o.Type);
                                object jsonVal = _BuildJsonStruct(o, depth - 1);
                                // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> jsonVal = " + jsonVal + "; " + o.Type);
                                if (jsonVal != null)
                                {
                                    jsonList.Add(jsonVal);
                                }
                                else
                                {
                                    // ???
                                    jsonList.Add(null);
                                }
                            }
                        }

                        jsonStruct = jsonList;
                    }
                    else if (obj is Collection <Object> )       // ??????    Not implemented yet.
                    {
                        List <Object> jsonList = new List <Object>();
                        // jsonList.AddAll((Collection<Object>) ((Collection<?>) obj));

                        IEnumerator <Object> it = ((Collection <Object>)obj).GetEnumerator();
                        while (it.MoveNext())
                        {
                            object o       = it.Current;
                            object jsonVal = _BuildJsonStruct(o, depth - 1);
                            if (jsonVal != null)
                            {
                                jsonList.Add(jsonVal);
                            }
                            else
                            {
                                // ???
                                jsonList.Add(null);
                            }
                        }

                        jsonStruct = jsonList;
                    }
                    else
                    {
                        // ???
                        // This can potentially cause infinite recursion.
                        // because maybe JsonCompatible object : toJsonStructure() using JsonBuilder.buidJsonStructure()
                        // which calls the object's toJsonStructure(), which calls JsonBuilder.buidJsonStructure(), etc.
                        // ....
                        // if(obj is JsonCompatible) {
                        //     jsonStruct = ((JsonCompatible) obj).toJsonStructure(depth);
                        // } else {
                        // primitive types... ???
                        if (obj is bool ||
                            obj is char ||
                            Number.IsNumber(obj) ||
                            obj is string
                            )
                        {
                            jsonStruct = obj;
                        }
                        else
                        {
                            // Use inspection....
                            // TBD:
                            // BuilderPolicy ???
                            // ...

                            IDictionary <String, Object> mapEquivalent = null;
                            try {
                                // mapEquivalent = IntrospectionUtil.Introspect(obj, depth);   // depth? or depth - 1 ?
                                // Because we are just converting a bean to a map,
                                // the depth param is not used. (or, depth == 1).
                                mapEquivalent = IntrospectionUtil.Introspect(obj);
                            } catch (Exception ex) {
                                // Ignore.
                                System.Diagnostics.Debug.WriteLine("Faild to Introspect a bean.", ex);
                            }
                            if (mapEquivalent != null)
                            {
                                jsonStruct = _BuildJsonStruct(mapEquivalent, depth);                                           // Note: We do not change the depth.
                            }
                            else
                            {
                                // ????
                                // jsonStruct = null; ???
                                jsonStruct = obj.ToString();
                                // ...
                            }
                            // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> jsonStruct = " + jsonStruct);
                        }
                        // }
                    }
                }
            }

            return(jsonStruct);
        }
Example #17
0
 private static char[] RemoveAt(char[] input, int index)
 {
     return(GenericUtil.RemoveIf(input, (t, i) => i == index).ToArray());
 }
Example #18
0
        private async Task _BuildAsync(TextWriter writer, object obj, int depth)
        {
            if (depth < 0)
            {
                return;
            }

            if (obj == null || obj is JsonNull)
            {
                await writer.WriteAsync(Literals.NULL);
            }
            else
            {
                // if(depth == 0) {
                if (depth <= 0)
                {
                    // TBD:
                    // This section of code is repeated when depth==0 and and when depth>0,
                    //     almost identically... (but not quite exactly the same)
                    // Need to be refactored.
                    // ....
                    string primStr = null;
                    if (obj is bool)
                    {
                        if (((bool)obj) == true)
                        {
                            primStr = Literals.TRUE;
                        }
                        else
                        {
                            primStr = Literals.FALSE;
                        }
                        await writer.WriteAsync(primStr);
                    }
                    else if (obj is char)
                    {
                        // ???
                        char strChar = (char)obj;
                        await writer.WriteAsync("\"");

                        await writer.WriteAsync(strChar);

                        await writer.WriteAsync("\"");
                    }
                    else if (Number.IsNumber(obj))
                    {
                        primStr = obj.ToString();
                        await writer.WriteAsync(primStr);
                    }
                    else if (obj is String)
                    {
                        // ????
                        // Is there a better/faster way to do this?

                        // ???
                        primStr = (String)obj;
                        // await writer.WriteAsync("\"").Append(primStr).Append("\"");

                        // ???
                        await writer.WriteAsync("\"");

                        _AppendEscapedString(writer, primStr);
                        await writer.WriteAsync("\"");

                        // ???
                    }
                    else
                    {
                        // TBD:
                        // java.util.Date ???
                        // and other JDK built-in class support???
                        // ..

                        if (obj is DateTime || obj is DateTimeOffset)
                        {
                            // TBD:
                            // Create a struct ???
                            primStr = obj.ToString();                              // ???
                            // ...
                        }
                        else if (obj is String)
                        {
                            primStr = (String)obj;
                        }
                        else
                        {
                            // TBD:
                            // POJO/Bean support???
                            // ...

                            // ????
                            primStr = obj.ToString();
                        }
                        // await writer.WriteAsync("\"").Append(primStr).Append("\"");
                        await writer.WriteAsync("\"");

                        _AppendEscapedString(writer, primStr);
                        await writer.WriteAsync("\"");
                    }
                }
                else
                {
                    // if(obj is IDictionary<String,Object>) {
                    if (GenericUtil.IsDictionary(obj))
                    {
                        // ????
                        // IDictionary<String, Object> map = null;
                        dynamic map = null;
                        try {
                            // map = (IDictionary<String,Object>) obj;
                            map = obj;
                        } catch (Exception ex) {
                            System.Diagnostics.Debug.WriteLine("Invalid map type.", ex);
                        }
                        await writer.WriteAsync("{");

                        if (map != null && map.Count > 0)
                        {
                            IEnumerator <String> it = map.Keys.GetEnumerator();
                            var next = it.MoveNext();
                            while (next)
                            {
                                string key = it.Current;
                                object val = map[key];
                                await writer.WriteAsync("\"");

                                await writer.WriteAsync(key);

                                await writer.WriteAsync("\":");

                                await writer.WriteAsync(WS);
                                await _BuildAsync(writer, val, depth - 1);

                                //// TBD: how to do this????
                                //// ???
                                next = it.MoveNext();
                                if (next)
                                {
                                    await writer.WriteAsync(",");

                                    await writer.WriteAsync(WS);
                                }
                                //// ....
                            }
                        }
                        await writer.WriteAsync("}");

                        // } else if (obj is IList<Object>) {
                    }
                    else if (GenericUtil.IsList(obj))
                    {
                        // ???
                        // IList<Object> list = null;
                        dynamic list = null;
                        try {
                            // list = (IList<Object>) obj;
                            list = obj;
                        } catch (Exception e) {
                            System.Diagnostics.Debug.WriteLine("Invalid list type.", e);
                        }
                        await writer.WriteAsync("[");

                        if (list != null && list.Count > 0)
                        {
                            IEnumerator <Object> it = list.GetEnumerator();
                            var next = it.MoveNext();
                            while (next)
                            {
                                object o = it.Current;
                                await _BuildAsync(writer, o, depth - 1);

                                //// ????
                                //// How to do this???
                                next = it.MoveNext();
                                if (next)
                                {
                                    await writer.WriteAsync(",");

                                    await writer.WriteAsync(WS);
                                }
                                //// ????
                            }
                        }
                        await writer.WriteAsync("]");
                    }
                    else if (obj.GetType().IsArray)                                  // ???

                    // type safe casting to array????
                    // if obj.GetType().GetElementType() ...
                    // object[] array = (object[]) obj;   // ????

                    // temporary
                    {
                        dynamic array = obj;
                        // ????

                        await writer.WriteAsync("[");

                        if (array != null && array.Length > 0)
                        {
                            int arrLen = array.Length;
                            // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> arrLen = " + arrLen);
                            for (int i = 0; i < arrLen; i++)
                            {
                                object o = array[i];
                                // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> o = " + o + "; " + o.Type);
                                await _BuildAsync(writer, o, depth - 1);

                                // System.Diagnostics.Debug.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>> jsonVal = " + jsonVal + "; " + o.Type);
                                if (i < arrLen - 1)
                                {
                                    await writer.WriteAsync(",");

                                    await writer.WriteAsync(WS);
                                }
                            }
                        }
                        await writer.WriteAsync("]");

                        //                    // ???
                        //                    // This adds weird repeated brackets ([[[[[[[ ...]]]]]]]]).
                        //                    _Build(writer, Arrays.asList(array), depth);
                    }
                    else if (obj is Collection <Object> )                            // ???????   Not implemented yet.
                    {
                        Collection <Object> coll = null;
                        try {
                            coll = (Collection <Object>)obj;
                        } catch (Exception ex) {
                            System.Diagnostics.Debug.WriteLine("Invalid collection type.", ex);
                        }
                        await writer.WriteAsync("[");

                        if (coll != null && coll.Count > 0)
                        {
                            IEnumerator <Object> it = coll.GetEnumerator();
                            var next = it.MoveNext();
                            while (next)
                            {
                                object o = it.Current;
                                await _BuildAsync(writer, o, depth - 1);

                                //// TBD:
                                //// ????
                                next = it.MoveNext();
                                if (next)
                                {
                                    await writer.WriteAsync(",");

                                    await writer.WriteAsync(WS);
                                }
                                //// ????
                            }
                        }
                        await writer.WriteAsync("]");
                    }
                    else
                    {
                        // primitive types... ???
                        // ...
                        string primStr = null;
                        if (obj is bool)
                        {
                            if (((bool)obj) == true)
                            {
                                primStr = Literals.TRUE;
                            }
                            else
                            {
                                primStr = Literals.FALSE;
                            }
                            await writer.WriteAsync(primStr);
                        }
                        else if (obj is char)
                        {
                            // ???
                            char strChar = (char)obj;
                            await writer.WriteAsync("\"");

                            await writer.WriteAsync(strChar);

                            await writer.WriteAsync("\"");
                        }
                        else if (Number.IsNumber(obj))
                        {
                            primStr = obj.ToString();                               // ????
                            await writer.WriteAsync(primStr);
                        }
                        else if (obj is String)
                        {
                            // ????
                            // Is there a better/faster way to do this?

                            // ???
                            primStr = (String)obj;
                            // await writer.WriteAsync("\"").Append(primStr).Append("\"");

                            // ???
                            await writer.WriteAsync("\"");

                            _AppendEscapedString(writer, primStr);
                            await writer.WriteAsync("\"");

                            // ???
                        }
                        else
                        {
                            // TBD:
                            // java.util.Date ???
                            // and other JDK built-in class support???
                            // ..

                            if (obj is DateTime || obj is DateTimeOffset)
                            {
                                // TBD:
                                // Create a struct ???
                                primStr = obj.ToString();
                                // ...
                            }
                            else if (obj is String)
                            {
                                primStr = (String)obj;
                            }
                            else
                            {
                                // ????
                                primStr = obj.ToString();
                            }
                            await writer.WriteAsync("\"");

                            _AppendEscapedString(writer, primStr);
                            await writer.WriteAsync("\"");
                        }
                    }
                }
            }
        }