public IHttpActionResult PutPhoneRecord(int id, PhoneRecord phoneRecord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != phoneRecord.Id)
            {
                return(BadRequest());
            }

            db.Entry(phoneRecord).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhoneRecordExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public async Task <IActionResult> PutPhoneRecord([FromRoute] int id, [FromForm] PhoneRecord phoneRecord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != phoneRecord.Id)
            {
                return(BadRequest());
            }

            _context.Entry(phoneRecord).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhoneRecordExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
 public UserRecord(PhoneRecord def, int scores, int coins)
 {
     phones = new List <PhoneRecord>();
     phones.Add(def);
     this.scores = scores;
     this.coins  = coins;
 }
Exemple #4
0
        private async Task <Dictionary <bool, string> > IsEntryValid(PhoneRecord record)
        {
            Dictionary <bool, string> errorMsgs = new Dictionary <bool, string> ();

            List <PhoneRecord> allRecords = await _repo.GetAllPhoneRecords();

            if (EditMode)
            {
                if (allRecords.Select(r => r.PhoneRecordId).ToList().Contains(record.PhoneRecordId))
                {
                    var recordToRemove = allRecords.Where(r => r.PhoneRecordId == record.PhoneRecordId).SingleOrDefault();
                    allRecords.Remove(recordToRemove);
                }
            }

            bool invalidIdNumber = allRecords
                                   .Where(r => r.IdentificationNumber == record.IdentificationNumber).Any();

            bool duplicateName = allRecords
                                 .Where(r => r.Name == record.Name && r.Surname == record.Surname)
                                 .Any();

            if (invalidIdNumber)
            {
                errorMsgs.Add(false, "Record was not saved. Invalid Identification Number.");
            }
            else if (duplicateName)
            {
                errorMsgs.Add(false, "Record was not saved. Duplicate name.");
            }
            return(errorMsgs);
        }
    public void Add(PhoneRecord record)
    {
        if (!this.records.ContainsKey(record.Name))
        {
            this.records[record.Name] = new HashSet<PhoneRecord>();
        }

        this.records[record.Name].Add(record);

        if (!this.names.ContainsKey(record.Name))
        {
            this.names[record.Name] = new HashSet<string>();
        }

        this.names[record.Name].Add(record.Name);

        foreach (var item in record.Name.Split(' '))
        {
            if (!this.names.ContainsKey(item))
            {
                this.names[item] = new HashSet<string>();
            }

            this.names[item].Add(record.Name);
        }
    }
Exemple #6
0
 public void SetPhoneInUse(PhoneRecord phone)
 {
     foreach (PhoneRecord p in phones)
     {
         p.inUse = false;
     }
     phone.inUse = true;
 }
Exemple #7
0
 public void createNewRecord(string firstName, string lastName, string phoneNumber, string address)
 {
     if (IsPhoneNumberCorrect(phoneNumber))
     {
         PhoneRecord record = new PhoneRecord(firstName, lastName, int.Parse(phoneNumber), address);
         Records.Add(record);
     }
 }
        public static async Task AppendAsync(string fileLocation, PhoneRecord record)
        {
            var phonebook = await GetPhonebookAsync(fileLocation);

            phonebook = AppendAlphabetically(phonebook, new PhoneRecordNode {
                record = record
            });
            await UpdatePhoneBookAsync(fileLocation, phonebook);
        }
Exemple #9
0
 // Creating the record which will be validated and passing any record details if any (editing)
 public void SetRecord(PhoneRecord record)
 {
     if (EditablePhoneRecord != null)
     {
         EditablePhoneRecord.ErrorsChanged -= RaiseCanExecuteChanged;
     }
     EditablePhoneRecord = new EditableRecord();
     EditablePhoneRecord.ErrorsChanged += RaiseCanExecuteChanged;
     CopyRecordDetails(record, EditablePhoneRecord);
 }
Exemple #10
0
    private PhoneRecord[] getPhoneRecord(string CustID, out int Result, out string ErrMsg)
    {
        PhoneRecord[] PhoneRecords = null;
        Result = -19999;
        ErrMsg = "";

        SqlConnection myCon = null;
        SqlCommand    cmd   = new SqlCommand();
        DataSet       ds    = null;

        try
        {
            myCon           = new SqlConnection(DBUtility.BestToneCenterConStr);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "up_Customer_V3_Interface_CustPhoneQuery";

            SqlParameter parCustID = new SqlParameter("@CustID", SqlDbType.VarChar, 16);
            parCustID.Value = CustID;
            cmd.Parameters.Add(parCustID);

            ds = DBUtility.FillData(cmd, DBUtility.BestToneCenterConStr);

            if (ds != null)
            {
                if (ds.Tables.Count != 0)
                {
                    if (ds.Tables[0].Rows.Count != 0)
                    {
                        int RowCount = ds.Tables[0].Rows.Count;
                        PhoneRecords = new PhoneRecord[RowCount];
                        PhoneRecord phoneRecord = new PhoneRecord();
                        for (int i = 0; i < RowCount; i++)
                        {
                            phoneRecord            = new PhoneRecord();
                            phoneRecord.Phone      = ds.Tables[0].Rows[i]["Phone"].ToString().Trim();
                            phoneRecord.PhoneClass = ds.Tables[0].Rows[i]["PhoneClass"].ToString().Trim();
                            if (!"1".Equals(phoneRecord.PhoneClass))
                            {
                                PhoneRecords[i] = phoneRecord;
                            }
                        }
                    }
                    Result = 0;
                }
            }
        }
        catch (Exception e)
        {
            Result = -22500;
            ErrMsg = "获取客户电话号码出错," + e.Message;
        }

        return(PhoneRecords);
    }
        public IHttpActionResult GetPhoneRecord(int id)
        {
            PhoneRecord phoneRecord = db.PhoneRecords.Find(id);

            if (phoneRecord == null)
            {
                return(NotFound());
            }

            return(Ok(phoneRecord));
        }
Exemple #12
0
        private void CopyRecordDetails(PhoneRecord sourceRecord, EditableRecord targetRecord)
        {
            if (EditMode)
            {
                targetRecord.PhoneRecordId = sourceRecord.PhoneRecordId;
            }

            targetRecord.Name                 = sourceRecord.Name;
            targetRecord.Surname              = sourceRecord.Surname;
            targetRecord.PhoneNumber          = sourceRecord.PhoneNumber;
            targetRecord.IdentificationNumber = sourceRecord.IdentificationNumber;
        }
Exemple #13
0
        public async Task <IActionResult> PostPhoneRecord([FromForm] PhoneRecord phoneRecord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PhoneRecord.Add(phoneRecord);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPhoneRecord", new { id = phoneRecord.Id }, phoneRecord));
        }
        public IHttpActionResult DeletePhoneRecord(int id)
        {
            PhoneRecord phoneRecord = db.PhoneRecords.Find(id);

            if (phoneRecord == null)
            {
                return(NotFound());
            }

            db.PhoneRecords.Remove(phoneRecord);
            db.SaveChanges();

            return(Ok(phoneRecord));
        }
Exemple #15
0
        private void ConvertEditableRecord()
        {
            recordForSaving = new PhoneRecord();

            if (EditMode)
            {
                recordForSaving.PhoneRecordId = recordForEditing.PhoneRecordId;
            }

            recordForSaving.Name                 = recordForEditing.Name;
            recordForSaving.Surname              = recordForEditing.Surname;
            recordForSaving.PhoneNumber          = recordForEditing.PhoneNumber;
            recordForSaving.IdentificationNumber = recordForEditing.IdentificationNumber;
        }
    static void Main(string[] args)
    {
        Phonebook phonebook = new Phonebook();

        using (StreamReader inputReader = new StreamReader("phones.txt"))
        {
            String line = inputReader.ReadLine();
            while (line != null)
            {
                string[] lineWords = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                string   names     = lineWords[0].Trim();
                string   town      = lineWords[1].Trim();
                string   phone     = lineWords[2].Trim();

                PhoneRecord record = new PhoneRecord(names, town, phone);
                phonebook.Add(record);
                line = inputReader.ReadLine();
            }
        }

        using (StreamReader inputReader = new StreamReader("commands.txt"))
        {
            String line = inputReader.ReadLine();
            while (line != null)
            {
                string[] comandParameters = line.Split(new string[] { "find(", ")", ",", " " }, StringSplitOptions.RemoveEmptyEntries);

                List <PhoneRecord> results;
                if (comandParameters.Length == 2)
                {
                    string names = comandParameters[0].Trim();
                    string town  = comandParameters[1].Trim();

                    results = phonebook.Find(names, town);
                }
                else
                {
                    string names = comandParameters[0].Trim();
                    results = phonebook.Find(names);
                }

                Console.WriteLine(new String('*', 30));
                Console.WriteLine("Result from command {0}", line);
                PrintPhoneRecordList(results);

                line = inputReader.ReadLine();
            }
        }
    }
Exemple #17
0
        /// <summary>
        /// 利用字典数组查找 phone.dat数据库中手机号码的信息
        /// </summary>
        /// <param name="pi"></param>
        /// <returns>返回查找到的手机号码信息</returns>
        private PhoneRecord FindPhone(PhoneInfo pi)
        {
            PhoneRecord pr = new PhoneRecord();
            string      s;

            string[] strTemp;
            if (!dicBuf.ContainsKey((int)pi.Phone7))
            {
                pr.Set(pi.PhoneNum, "null", "null", "null", "null", "null");
                return(pr);
            }
            s       = dicBuf[(int)pi.Phone7];
            strTemp = s.Split(new char[] { '|' });
            pr.Set(pi.PhoneNum, strTemp[0], strTemp[1], strTemp[2], strTemp[3], GetCardType(Convert.ToByte(strTemp[4])));
            return(pr);
        }
Exemple #18
0
        private void DataCheng()
        {
            #region 填入資料
            dic1.Clear();
            dic3.Clear();
            foreach (StudentRecord each in Data.StudRecordList)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridViewX1);
                row.Tag = false;

                row.Cells[ColumnIndex["ID"]].Value = each.ID;
                row.Cells[ColumnIndex["班級"]].Value = each.Class.Name;
                row.Cells[ColumnIndex["座號"]].Value = each.SeatNo;
                row.Cells[ColumnIndex["姓名"]].Value = each.Name;

                if (comboBoxEx1.SelectedIndex == 0) //地址資料
                {
                    AddressRecord address = Data.Address[each.ID];

                    AddressRecord beforeAddress = new AddressRecord(); //Log
                    row.Cells[ColumnIndex["郵遞區號"]].Value = beforeAddress.Mailing.ZipCode = address.Mailing.ZipCode;
                    row.Cells[ColumnIndex["縣市"]].Value   = beforeAddress.Mailing.County = address.Mailing.County;
                    row.Cells[ColumnIndex["鄉鎮"]].Value   = beforeAddress.Mailing.Town = address.Mailing.Town;
                    //row.Cells[ColumnIndex["村里"]].Value = beforeAddress.Mailing.District = address.Mailing.District;
                    //row.Cells[ColumnIndex["鄰"]].Value = beforeAddress.Mailing.Area = address.Mailing.Area;
                    row.Cells[ColumnIndex["村里街號"]].Value = beforeAddress.Mailing.Detail = address.Mailing.Detail;
                    dic1.Add(each.ID, beforeAddress);//Log
                }
                else //電話資料
                {
                    PhoneRecord phone = Data.Phone[each.ID];

                    PhoneRecord beforePhone = new PhoneRecord(); //Log
                    row.Cells[ColumnIndex["聯絡電話"]].Value = beforePhone.Contact = phone.Contact;
                    row.Cells[ColumnIndex["其他1"]].Value  = beforePhone.Phone1 = phone.Phone1;
                    row.Cells[ColumnIndex["其他2"]].Value  = beforePhone.Phone2 = phone.Phone2;
                    row.Cells[ColumnIndex["其他3"]].Value  = beforePhone.Phone3 = phone.Phone3;
                    row.Cells[ColumnIndex["手機"]].Value   = beforePhone.Cell = phone.Cell;
                    dic3.Add(each.ID, beforePhone);//Log
                }

                dataGridViewX1.Rows.Add(row);
            }
            #endregion
        }
Exemple #19
0
    private void load()
    {
        userRecord   = ReadUserRecord();
        scoresRecord = ReadScoresRecord();

        if (userRecord == null)
        {
            userRecord = UserRecord.GetDefaultUserRecord();
        }

        phoneInUse = GetPhoneInUse();

        if (scoresRecord == null)
        {
            scoresRecord = new ScoresRecord();
        }
    }
        /// <summary>
        /// 利用字典数组查找 phone.dat数据库中手机号码的信息
        /// </summary>
        /// <param name="pi"></param>
        /// <returns>返回查找到的手机号码信息</returns>
        private PhoneRecord FindPhone(PhoneInfo pi)
        {
            PhoneRecord pr = new PhoneRecord();
            string      s;

            string[] strTemp;
            // Trace.Assert(dicBuf.ContainsKey((int)pi.Phone7), $"{pi.PhoneNum} is not in phonedata");
            if (!dicBuf.ContainsKey((int)pi.Phone7))
            {
                Console.WriteLine($"{pi.PhoneNum} is not in phonedata");
                pr.Set(pi.PhoneNum, "null", "null", "null", "null", "null");
                return(pr);
            }
            s       = dicBuf[(int)pi.Phone7];
            strTemp = s.Split(new char[] { '|' });
            pr.Set(pi.PhoneNum, strTemp[0], strTemp[1], strTemp[2], strTemp[3], GetCardType(Convert.ToByte(strTemp[4])));
            return(pr);
        }
        public IHttpActionResult PostPhoneRecord(PhoneRecord phoneRecord /*, HttpPostedFileBase image*/)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (ModelState.IsValid)
            {
                //if (ImageUploadValidator.IsWebFriendlyImage(image))
                //{
                //    var fileName = Path.GetFileName(image.FileName);
                //    image.SaveAs(Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/"), fileName));
                //    phoneRecord.MediaUrl = "/Uploads/" + fileName;
                //}



                db.PhoneRecords.Add(phoneRecord);
                db.SaveChanges();
            }

            return(CreatedAtRoute("DefaultApi", new { id = phoneRecord.Id }, phoneRecord));
        }
Exemple #22
0
 public void Add(PhoneRecord record)
 {
     this.recordsByName.Add(record.Names, record);
     this.recordsByTown.Add(record.Town, record);
 }
Exemple #23
0
        private void btnSavePage_Click(object sender, EventArgs e)
        {
            btnSavePage.Enabled = false;

            #region 儲存鈕
            if (comboBoxEx1.SelectedIndex == 0)
            {
                #region 地址資料
                Dictionary <string, AddressRecord> dic2 = new Dictionary <string, AddressRecord>();
                foreach (DataGridViewRow each in dataGridViewX1.Rows)
                {
                    bool CHeng = (bool)each.Tag;
                    if (CHeng)
                    {
                        each.Tag = false;
                        if (Data.Address.ContainsKey("" + each.Cells[0].Value))
                        {
                            AddressRecord address = Data.Address["" + each.Cells[ColumnIndex["ID"]].Value];
                            address.Mailing.ZipCode = "" + each.Cells[ColumnIndex["郵遞區號"]].Value;
                            address.Mailing.County  = "" + each.Cells[ColumnIndex["縣市"]].Value;
                            address.Mailing.Town    = "" + each.Cells[ColumnIndex["鄉鎮"]].Value;
                            //address.Mailing.District = "" + each.Cells[ColumnIndex["村里"]].Value;
                            //address.Mailing.Area = "" + each.Cells[ColumnIndex["鄰"]].Value;
                            address.Mailing.Detail = "" + each.Cells[ColumnIndex["村里街號"]].Value;
                            dic2.Add(address.RefStudentID, address); //修改後
                        }
                    }
                }
                try
                {
                    K12.Data.Address.Update(dic2.Values);
                }
                catch (Exception ex)
                {
                    btnSavePage.Enabled = true;
                    FISCA.Presentation.Controls.MsgBox.Show("儲存地址資料,發生錯誤" + ex.Message);
                    return;
                }

                if (dic2.Values.Count != 0)
                {
                    foreach (AddressRecord each in dic2.Values)
                    {
                        StringBuilder sb   = new StringBuilder();
                        StudentRecord stud = each.Student;
                        AddressRecord bef  = dic1[each.RefStudentID];
                        sb.Append("學生「" + stud.Name + "」");
                        sb.AppendLine("地址資料已被修改。");
                        sb.AppendLine("郵遞區號「" + bef.Mailing.ZipCode + "」改為「" + each.Mailing.ZipCode + "」");
                        sb.AppendLine("縣  市「" + bef.Mailing.County + "」改為「" + each.Mailing.County + "」");
                        sb.AppendLine("鄉鎮市區「" + bef.Mailing.Town + "」改為「" + each.Mailing.Town + "」");
                        //sb.AppendLine("村  里「" + bef.Mailing.District + "」改為「" + each.Mailing.District + "」");
                        //sb.AppendLine("鄰   「" + bef.Mailing.Area + "」改為「" + each.Mailing.Area + "」");
                        sb.AppendLine("村里街號「" + bef.Mailing.Detail + "」改為「" + each.Mailing.Detail + "」");
                        ApplicationLog.Log("學務系統.聯絡資訊管理", "修改學生地址資料", "student", stud.ID, sb.ToString());
                    }
                }

                btnSavePage.Enabled = true;
                FISCA.Presentation.Controls.MsgBox.Show("地址資料,儲存成功");
                #endregion
            }
            else
            {
                #region 電話資料
                Dictionary <string, PhoneRecord> dic2 = new Dictionary <string, PhoneRecord>();
                foreach (DataGridViewRow each in dataGridViewX1.Rows)
                {
                    bool CHeng = (bool)each.Tag;
                    if (CHeng)
                    {
                        each.Tag = false;
                        if (Data.Address.ContainsKey("" + each.Cells[0].Value))
                        {
                            PhoneRecord phone = Data.Phone["" + each.Cells[ColumnIndex["ID"]].Value];
                            phone.Contact = "" + each.Cells[ColumnIndex["聯絡電話"]].Value;
                            phone.Phone1  = "" + each.Cells[ColumnIndex["其他1"]].Value;
                            phone.Phone2  = "" + each.Cells[ColumnIndex["其他2"]].Value;
                            phone.Phone3  = "" + each.Cells[ColumnIndex["其他3"]].Value;
                            phone.Cell    = "" + each.Cells[ColumnIndex["手機"]].Value;
                            dic2.Add(phone.RefStudentID, phone);
                        }
                    }
                }
                try
                {
                    Phone.Update(dic2.Values);
                }
                catch (Exception ex)
                {
                    btnSavePage.Enabled = true;
                    FISCA.Presentation.Controls.MsgBox.Show("儲存電話資料,發生錯誤" + ex.Message);
                    return;
                }

                if (dic2.Values.Count != 0)
                {
                    foreach (PhoneRecord each in dic2.Values)
                    {
                        StringBuilder sb   = new StringBuilder();
                        StudentRecord stud = each.Student;
                        PhoneRecord   bef  = dic3[each.RefStudentID];
                        sb.Append("學生「" + stud.Name + "」");
                        sb.AppendLine("電話資料已被修改。");
                        sb.AppendLine("聯絡電話 「" + bef.Contact + "」改為「" + each.Contact + "」");
                        sb.AppendLine("其他電話一「" + bef.Phone1 + "」改為「" + each.Phone1 + "」");
                        sb.AppendLine("其他電話二「" + bef.Phone2 + "」改為「" + each.Phone2 + "」");
                        sb.AppendLine("其他電話三「" + bef.Phone3 + "」改為「" + each.Phone3 + "」");
                        sb.AppendLine("手  機 「" + bef.Cell + "」改為「" + each.Cell + "」");
                        ApplicationLog.Log("學務系統.聯絡資訊管理", "修改學生電話資料", "student", stud.ID, sb.ToString());
                    }
                }

                btnSavePage.Enabled = true;
                FISCA.Presentation.Controls.MsgBox.Show("電話資料,儲存成功");
                #endregion
            }
            #endregion

            DataGridViewDataInChange = false;
        }
Exemple #24
0
    private PhoneRecord[] getPhoneRecord(string CustID, out int Result, out string ErrMsg)
    {
        PhoneRecord[] PhoneRecords = null;
        Result = -19999;
        ErrMsg = "";

        SqlConnection myCon = null;
        SqlCommand cmd = new SqlCommand();
        DataSet ds = null;

        try
        {
            myCon = new SqlConnection(DBUtility.BestToneCenterConStr);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "up_Customer_V3_Interface_CustPhoneQuery";

            SqlParameter parCustID = new SqlParameter("@CustID", SqlDbType.VarChar, 16);
            parCustID.Value = CustID;
            cmd.Parameters.Add(parCustID);

            ds = DBUtility.FillData(cmd, DBUtility.BestToneCenterConStr);

            if (ds != null)
            {
                if (ds.Tables.Count != 0)
                {
                    if (ds.Tables[0].Rows.Count != 0)
                    {
                        int RowCount = ds.Tables[0].Rows.Count;
                        PhoneRecords = new PhoneRecord[RowCount];
                        PhoneRecord phoneRecord = new PhoneRecord();
                        for (int i = 0; i < RowCount; i++)
                        {
                            phoneRecord = new PhoneRecord();
                            phoneRecord.Phone = ds.Tables[0].Rows[i]["Phone"].ToString().Trim();
                            phoneRecord.PhoneClass = ds.Tables[0].Rows[i]["PhoneClass"].ToString().Trim();
                            if (!"1".Equals(phoneRecord.PhoneClass))
                            {
                                PhoneRecords[i] = phoneRecord;
                            }

                        }

                    }
                    Result = 0;

                }
            }

        }
        catch (Exception e)
        {
            Result = -22500;
            ErrMsg = "获取客户电话号码出错," + e.Message;
        }

        return PhoneRecords;
    }
Exemple #25
0
 public static UserRecord GetDefaultUserRecord()
 {
     return(new UserRecord(PhoneRecord.GetDefaultPhoneRecord(true), 0, 0));
 }
Exemple #26
0
 public void AddPhone(PhoneRecord p)
 {
     phones.Add(p);
 }
Exemple #27
0
 public void DeletePhone(PhoneRecord phone)
 {
     phones.Remove(phone);
 }
Exemple #28
0
 public void SetPhoneInUse(PhoneRecord p)
 {
     phoneInUse = p;
     userRecord.SetPhoneInUse(p);
 }
Exemple #29
0
 public void DeletePhone(PhoneRecord phone)
 {
     userRecord.DeletePhone(phone);
 }
Exemple #30
0
 private void NavToEditPhoneRecord(PhoneRecord record)
 {
     addPhoneRecordViewModel.EditMode = true;
     addPhoneRecordViewModel.SetRecord(record);
     CurrentViewModel = addPhoneRecordViewModel;
 }
Exemple #31
0
        /// <summary>
        /// 利用二分法查找 phone.dat数据库中手机号码的信息
        /// </summary>
        /// <param name="pi"></param>
        /// <returns>返回查找到的手机号码信息</returns>
        private PhoneRecord FindPhone(PhoneInfo pi)
        {
            PhoneRecord pr = new PhoneRecord {
            };
            Int32  phone_seven_int32;
            int    left = 0;
            int    right = 0;
            int    total_len = Phonedata.total_len;
            int    mid = 0;
            int    offset = 0;
            Int32  cur_phone, record_offset;
            byte   card_type;
            string card_str;
            string data_str;

            string[] data_str_arr;
            Int32    end_offset = 0;

            byte[] Zero_end = System.Text.Encoding.Default.GetBytes("\0");
            byte[] data;

            phone_seven_int32 = (Int32)pi.Phone7; //将uint32 转换为int32, 好用于对比
            right             = (total_len - indexOffset) / PHONE_INDEX_LENGTH;

            for (; ;)
            {
                if (left > right)
                {
                    return(pr);
                }
                //mid = (left + right) / 2;
                mid    = (left + right) >> 1;
                offset = indexOffset + mid * PHONE_INDEX_LENGTH;
                if (offset >= total_len)
                {
                    Console.WriteLine("offset >= total_len");
                    return(pr);
                }
                cur_phone     = Get4(SubByte(Buf, offset, INT_LEN));
                record_offset = Get4(SubByte(Buf, offset + INT_LEN, 4));

                card_type = SubByte(Buf, offset + INT_LEN * 2, 1)[0];

                if (cur_phone > phone_seven_int32)
                {
                    right = mid - 1;
                }
                else if (cur_phone < phone_seven_int32)
                {
                    left = mid + 1;
                }
                else
                {
                    byte[] cbyte = SubByte(Buf, record_offset, total_len - record_offset);
                    end_offset = IndexOf(cbyte, Zero_end);
                    data       = SubByte(Buf, record_offset, end_offset);

                    data_str = System.Text.Encoding.UTF8.GetString(data);

                    data_str_arr = data_str.Split('|');
                    card_str     = GetCardType(card_type);
                    pr.Set(pi.PhoneNum, data_str_arr[0], data_str_arr[1], data_str_arr[2], data_str_arr[3], card_str);

                    return(pr);
                }
            }
            return(pr);
        }