public DataSet GetDeletedData(string ticket, string _tname)
        {
            UserInformation userInfo;

            if (!IsTicketValid(ticket, false, out userInfo))
            {
                return(null);
            }

            DataSet   _ds = new DataSet();
            DataTable _dt = new DataTable();

            using (OracleConnection cn = OracleHelper.OpenConnection())
            {
                try
                {
                    OracleCommand _cmd = new OracleCommand();
                    _cmd.CommandText = "ZHTJ_SJJH.GetDeletedData";
                    _cmd.CommandType = CommandType.StoredProcedure;
                    _cmd.Connection  = cn;

                    _cmd.Parameters.Add("STRYHM", userInfo.UserName);
                    _cmd.Parameters.Add("STRTNAME", _tname);
                    _cmd.Parameters.Add("NMAX", (decimal)1000);
                    _cmd.Parameters.Add("RCRET", OracleDbType.RefCursor, 2000, ParameterDirection.Output);


                    OracleDataAdapter _adapter = new OracleDataAdapter(_cmd);
                    _adapter.Fill(_dt);
                    _dt.TableName = _tname;
                    _ds.Tables.Add(_dt);
                }
                catch (Exception e)
                {
                    Exception exp = e;
                    ServerCommon.WriteLog(string.Format("GetDeletedData({0},{1}) 时发出错误如下:\n{2}", "ticket", _tname, e.Message), EventLogEntryType.Error);
                    return(null);
                }
            }
            return(_ds);
        }
        /// <summary>
        /// 验证用户提供的票据
        /// </summary>
        /// <param name="ticket">标据字串</param>
        /// <param name="IsAdminCall">是否超级用户</param>
        /// <returns>true:通过验证    false:不通过验证</returns>
        private bool IsTicketValid(string ticket, bool IsAdminCall, out UserInformation userInfo)
        {
            userInfo = null;
            if (ticket == null || Context.Cache[ticket] == null)
            {
                // not authenticated
                return(false);
            }
            else
            {
                // check the user authorization
                int userID = int.Parse(FormsAuthentication.Decrypt(ticket).Name);


                //从数据库中取用户信息,待实现
                string  _userSelect = string.Format("select * from jsods.sjjh_yhb where yhid ={0}", userID);
                DataSet ds          = ServerCommon.GetDataBySql(_userSelect);

                userInfo = new UserInformation();
                DataRow dr = ds.Tables[0].Rows[0];

                userInfo.UserName = dr["YHM"].ToString();
                userInfo.UserID   = int.Parse(userID.ToString());

                if (userInfo.IsAccountLocked)
                {
                    return(false);
                }
                else
                {
                    // check admin status (for admin required calls)
                    if (IsAdminCall && !userInfo.IsAdministrator)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
        }
        public IActionResult GetUsers()
        {
            try
            {
                using UserProfileContext userProfileContext = CreateUserProfileContext(out DbSet <RegisteredUser> registeredUsers, out _, out _);
                if (!IsTokenValid(registeredUsers, out RegisteredUser? loginUser) || !loginUser.IsAdmin)
                {
                    return(Unauthorized());
                }

                // キャッシュチェック
                DateTime lastModified = ServerCommon.LastModified(ServerConstants.FILE_NAME_USER_PROFILES);
                if (IsEntityTagValid(YbdCommon.DateTimeToModifiedJulianDate(lastModified)))
                {
                    Debug.WriteLine("GetUsers() キャッシュ有効: ");
                    return(NotModified());
                }

                RegisteredUser[] registeredUsersArray = registeredUsers.Where(x => !x.IsAdmin).OrderBy(x => x.Name).ToArray();
                PublicUserInfo[] results = new PublicUserInfo[registeredUsersArray.Length];
                for (Int32 i = 0; i < registeredUsersArray.Length; i++)
                {
                    PublicUserInfo publicUserInfo = new();
                    registeredUsersArray[i].CopyPublicInfo(publicUserInfo, true);
                    results[i] = publicUserInfo;
                }
                EntityTagHeaderValue eTag = GenerateEntityTag(YbdCommon.DateTimeToModifiedJulianDate(lastModified));
                return(File(JsonSerializer.SerializeToUtf8Bytes(results), ServerConstants.MIME_TYPE_JSON, lastModified, eTag));
            }
            catch (Exception excep)
            {
                Debug.WriteLine("ユーザー一覧取得サーバーエラー:\n" + excep.Message);
                Debug.WriteLine(" スタックトレース:\n" + excep.StackTrace);
                return(InternalServerError());
            }
        }
        public IActionResult GetPublicUserInfo(String?id)
        {
            try
            {
                // キャッシュチェック
                DateTime lastModified = ServerCommon.LastModified(ServerConstants.FILE_NAME_USER_PROFILES);
                if (IsEntityTagValid(YbdCommon.DateTimeToModifiedJulianDate(lastModified)))
                {
                    Debug.WriteLine("GetPublicUserInfo() キャッシュ有効: " + id);
                    return(NotModified());
                }

                if (String.IsNullOrEmpty(id))
                {
                    return(BadRequest());
                }

                using UserProfileContext userProfileContext = CreateUserProfileContext(out DbSet <RegisteredUser> registeredUsers, out _, out _);
                RegisteredUser?registeredUser = registeredUsers.SingleOrDefault(x => x.Id == id);
                if (registeredUser == null)
                {
                    return(NotAcceptable());
                }
                PublicUserInfo userInfo = new PublicUserInfo();
                registeredUser.CopyPublicInfo(userInfo, false);

                EntityTagHeaderValue eTag = GenerateEntityTag(YbdCommon.DateTimeToModifiedJulianDate(lastModified));
                return(File(JsonSerializer.SerializeToUtf8Bytes(userInfo), ServerConstants.MIME_TYPE_JSON, lastModified, eTag));
            }
            catch (Exception excep)
            {
                Debug.WriteLine("公開ユーザー情報取得サーバーエラー:\n" + excep.Message);
                Debug.WriteLine(" スタックトレース:\n" + excep.StackTrace);
                return(InternalServerError());
            }
        }
        /// <summary>
        /// 下注
        /// </summary>
        public feiPanJieGuo StartXiaZhu(xztj xztj, string qiHao)
        {
            feiPanJieGuo fpjgData = new feiPanJieGuo();

            fpjgData.serverUrl = "";
            fpjgData.yuE       = "0";
            lblYuE.Text        = "0";
            lblServer.Text     = "";
            lblName.Text       = "";
            lblState.Text      = "链接中";

            if (cbStart.Checked == true)
            {
                string useServer = "";
                //尝试下注
                if (ServerFeiPan.checkLogin() == false)
                {
                    ServerFeiPan.loginAgain();
                }
                if (ServerFeiPan.checkLogin() == true)
                {
                    if (ServerFeiPan.ServerType.Equals("顺丰"))
                    {
                        fpjgData.isSuccess  = true;
                        fpjgData.serverUrl += ServerFeiPan.FeidanUrl + ";";
                        fpjgData            = ServerFeiPan.xiaZhu_shunfen(xztj, qiHao, fpjgData);
                    }
                    else if (ServerFeiPan.ServerType.Equals("永利"))
                    {
                        fpjgData.isSuccess  = true;
                        fpjgData.serverUrl += ServerFeiPan.FeidanUrl + ";";
                        fpjgData            = ServerFeiPan.xiaZhu_yongli(xztj, qiHao, fpjgData);
                    }
                    useServer = ServerFeiPan.ServerType + ServerFeiPan.LoginName;
                }
                foreach (ListViewItem item in lvSerState.Items)
                {
                    item.SubItems[4].Text = "已停止";
                }
                //重新遍历服务器列表
                if (fpjgData.isSuccess == false)
                {
                    //加载服务器
                    DataTable dtServer = SQLiteHelper.ExecuteDataTable("select * from fuwuqi_" + (String.IsNullOrWhiteSpace(Seq) ? CacheData.Seq : Seq), null);
                    if (dtServer.Rows.Count > 0)
                    {
                        foreach (DataRow row in dtServer.Rows)
                        {
                            string _serverType = row["类型"].ToString();
                            string _serverUrl  = row["服务器地址"].ToString();
                            string _userName   = row["用户名"].ToString();
                            string _userPass   = row["密码"].ToString();
                            if (_serverType.Equals(_serverType + _userName))
                            {
                                function.log("提交失败:" + _serverType + _userName);
                                continue;
                            }
                            if (_serverType.Equals("顺丰"))
                            {
                                ServerFeiPan.login(_serverUrl, _userName, _userPass, _serverType);
                                if (ServerFeiPan.IsLoginSuccess == false && cbIsTryCon.Checked)
                                {
                                    frmMessageTimer frmMessage = new frmMessageTimer("服务器" + _serverUrl + "不能使用");
                                    frmMessage.Show();
                                    Application.DoEvents();
                                }

                                if (ServerFeiPan.IsLoginSuccess == true)
                                {
                                    fpjgData = ServerFeiPan.xiaZhu_shunfen(xztj, qiHao, fpjgData);
                                }
                            }
                            else if (_serverType.Equals("永利"))
                            {
                                ServerFeiPan.login(_serverUrl, _userName, _userPass, _serverType);

                                if (ServerFeiPan.IsLoginSuccess == false && cbIsTryCon.Checked)
                                {
                                    frmMessageTimer frmMessage = new frmMessageTimer("服务器" + _serverUrl + "不能使用");
                                    frmMessage.Show();
                                    Application.DoEvents();
                                }

                                if (ServerFeiPan.IsLoginSuccess == true)
                                {
                                    fpjgData = ServerFeiPan.xiaZhu_yongli(xztj, qiHao, fpjgData);
                                }
                            }

                            //
                            if (ServerFeiPan.IsLoginSuccess)
                            {
                                lblYuE.Text    = ServerFeiPan.KeYongYuE.ToString();
                                lblServer.Text = ServerFeiPan.FeidanUrl;
                                lblName.Text   = ServerFeiPan.LoginName;
                                lblState.Text  = "使用中";
                            }
                            else
                            {
                                lblYuE.Text    = ServerFeiPan.KeYongYuE.ToString();
                                lblServer.Text = ServerFeiPan.FeidanUrl;
                                lblName.Text   = ServerFeiPan.LoginName;
                                lblState.Text  = "已停止";
                            }
                            foreach (ListViewItem item in lvSerState.Items)
                            {
                                if (item.SubItems[2].Text.Equals(_serverUrl))
                                {
                                    item.SubItems[4].Text = ServerFeiPan.IsLoginSuccess ? "使用中" : "已停止";
                                }
                            }
                            //
                            if (fpjgData.isSuccess)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                fpjgData = ServerCommon.SetFeiPanJieGuo(fpjgData, true);
                fpjgData.errorMessage = "未开启";
                //关闭直接返回
                return(fpjgData);
            }

            if (fpjgData.isSuccess == false)
            {
                playFaileSound();

                if (cbStart.Checked && ServerFeiPan.IsLoginSuccess == false)
                {
                    frmMessageTimer frmMessage = new frmMessageTimer("盘口可能坏了,请检查是否可用?");
                    frmMessage.Show();
                    cbStart.Checked = false;
                }
            }


            //for (int i = 0; i < 4; i++)//总和组合
            //{
            //    fpjgData.ZHZHDXDS[i] = true;
            //}

            //
            //lblYuE.Text = fpjgData.yuE;

            //插入
            feiPanJieGuoInsert(xztj, fpjgData, qiHao);

            //查询最新
            chaXunZuiXin();

            return(fpjgData);
            //
            //string result = HttpHelps.Post("", _feidanUrl + "/user/cql_cqsc_lm.aspx?t=all",
            //     _webCookie, Encoding.Default);
        }
Beispiel #6
0
        protected override void ExecuteMethod()
        {
            try
            {
                // string url = "http://localhost:2049/";
                string url = JsonConfig.JsonRead("InsuranceSelfApi", "InsuranceSelfApi");
                this.Parameter.OthOrderCode = ServerCommon.CreateOrderId();
                LoggerFactory.Instance.Logger_Debug("url:" + url.ToString() + "othercode:" + this.Parameter.OthOrderCode, "InSurRequestInfo");
                LoggerFactory.Instance.Logger_Debug(JsonConvert.SerializeObject(this.Parameter), "InSurRequestInfo");
                var data = PostData(string.Format("{0}api/Insure/SaveInsure", url), JsonConvert.SerializeObject(this.Parameter));

                if (!string.IsNullOrEmpty(data))
                {
                    var view = JsonConvert.DeserializeObject <ViewBase>(data);

                    if (view.Status == "100")
                    {
                        var returnResult = JsonConvert.DeserializeObject <ResultView>(view.Result);
                        var list         = this.Parameter.InsuredPersonList.AsParallel().Select(r => new InsurancedPerson()
                        {
                            ApplyNum       = r.applyNum,
                            IdentifyNumber = r.IdentifyNumber,
                            InsuredName    = r.InsuredName,
                            IdentifyType   = r.IdentifyType,
                            Mobile         = r.Mobile,
                            Relation       = r.Relation
                        }).ToList();
                        string msg = "";
                        var    i   = insuranceOrderRep.Insert(new InsuranceOrder()
                        {
                            FlightNo       = this.Parameter.flightNo,
                            FlightDate     = this.Parameter.flightDate,
                            AppliName      = this.Parameter.AppliName,
                            EndDate        = Convert.ToDateTime(this.Parameter.EndDate),
                            IdentifyNumber = this.Parameter.IdentifyNumber,
                            IdentifyType   = this.Parameter.IdentifyType,
                            OthOrderCode   = this.Parameter.OthOrderCode,
                            StartDate      = Convert.ToDateTime(this.Parameter.StartDate),
                            TotalAmount    = decimal.Parse(this.Parameter.TotalAmount),
                            TotalPremium   = decimal.Parse(this.Parameter.TotalPremium),
                            UserId         = long.Parse(this.Parameter.UserId),
                            Mobile         = this.Parameter.Mobile,
                            ProposalNo     = returnResult.ProposalNo,
                            PolicyNo       = returnResult.PolicyNo,
                            UUID           = returnResult.UUID,
                            SendTime       = returnResult.SendTime
                        }, list, out msg);

                        if (i < 1)
                        {
                            this.Result.IsSuccess = false;
                            LoggerFactory.Instance.Logger_Debug(msg, "InSurdboInfo");
                            if (!string.IsNullOrEmpty(msg))
                            {
                                throw new Exception(msg);
                            }
                        }
                    }
                    else
                    {
                        this.Result.IsSuccess = false;
                        LoggerFactory.Instance.Logger_Debug(view.Message, "InSurInfo");
                        throw new Exception(view.Message);
                    }
                }
                else
                {
                    this.Result.IsSuccess = false;
                    this.Result.Message   = "系统超时";
                    LoggerFactory.Instance.Logger_Warn("系统超时", "InSurTimeout");
                }
            }
            catch (Exception ex)
            {
                this.Result.IsSuccess = false;
                this.Result.Message   = ex.Message;
                LoggerFactory.Instance.Logger_Error(ex, "InSurError");
            }
        }
Beispiel #7
0
        public IActionResult SearchByWord(String?query)
        {
            try
            {
                // キャッシュチェック
                DateTime lastModified = ServerCommon.LastModified(ServerConstants.FILE_NAME_AVAILABLE_SONGS);
                if (IsEntityTagValid(YbdCommon.DateTimeToModifiedJulianDate(lastModified)))
                {
                    Debug.WriteLine("SearchByWord() キャッシュ有効: " + query);
                    return(NotModified());
                }

                SearchWord searchWord = new SearchWord(query);
                if (!searchWord.IsValid(out String? errorMessage))
                {
                    return(BadRequest());
                }

                using AvailableSongContext availableSongContext = CreateAvailableSongContext(out DbSet <AvailableSong> availableSongs);
                IQueryable <AvailableSong> searchResults = availableSongs;
                if (searchWord.Type == SearchWordType.AnyWord)
                {
                    // なんでも検索
                    String[] anyWords = SplitKeyword(searchWord.AnyWord);
                    for (Int32 i = 0; i < anyWords.Length; i++)
                    {
                        searchResults = SearchByAnyWord(searchResults, anyWords[i]);
                    }
                }
                else
                {
                    // 曲名
                    // ToDo: SearchBySongName() を関数化すると実行できるが、地の文にすると例外が発生する
                    String[] songNames = SplitKeyword(searchWord.SongName);
                    for (Int32 i = 0; i < songNames.Length; i++)
                    {
                        searchResults = SearchBySongName(searchResults, songNames[i]);
                    }

                    // タイアップ名
                    String[] tieUpNames = SplitKeyword(searchWord.TieUpName);
                    for (Int32 i = 0; i < tieUpNames.Length; i++)
                    {
                        searchResults = SearchByTieUpName(searchResults, tieUpNames[i]);
                    }

                    // 歌手名
                    String[] artistNames = SplitKeyword(searchWord.ArtistName);
                    for (Int32 i = 0; i < artistNames.Length; i++)
                    {
                        searchResults = SearchByArtistName(searchResults, artistNames[i]);
                    }

                    // 制作会社
                    String[] makers = SplitKeyword(searchWord.MakerName);
                    for (Int32 i = 0; i < makers.Length; i++)
                    {
                        searchResults = SearchByMaker(searchResults, makers[i]);
                    }

                    // カラオケ動画制作者
                    String[] workers = SplitKeyword(searchWord.Worker);
                    for (Int32 i = 0; i < workers.Length; i++)
                    {
                        searchResults = SearchByWorker(searchResults, workers[i]);
                    }

                    // ファイル名
                    String[] pathes = SplitKeyword(searchWord.Path);
                    for (Int32 i = 0; i < pathes.Length; i++)
                    {
                        searchResults = SearchByPath(searchResults, pathes[i]);
                    }
                }

                // 追加ヘッダー
                AddTotalCountToHeader(searchResults.Count());

                // 検索結果は AvailableSongContext の寿命と共に尽きるようなので、ToArray() で新しいコンテナに格納する
                AvailableSong[]      results = SortSearchResult(searchResults, searchWord.Sort).Skip(YbdConstants.PAGE_SIZE * searchWord.Page).Take(YbdConstants.PAGE_SIZE).ToArray();
                EntityTagHeaderValue eTag    = GenerateEntityTag(YbdCommon.DateTimeToModifiedJulianDate(lastModified));
                return(File(JsonSerializer.SerializeToUtf8Bytes(results), ServerConstants.MIME_TYPE_JSON, lastModified, eTag));
            }
            catch (Exception excep)
            {
                Debug.WriteLine("キーワード検索サーバーエラー:\n" + excep.Message);
                Debug.WriteLine(" スタックトレース:\n" + excep.StackTrace);
                return(InternalServerError());
            }
        }
Beispiel #8
0
 void Application_Start(object sender, EventArgs e)
 {
     // 在应用程序启动时运行的代码
     ServerCommon.Init();
 }