/// <summary>要素リストを追加する。</summary>
 /// <param name="collection">要素リスト。</param>
 public void AddRange(IEnumerable <T> collection)
 {
     foreach (var v in collection)
     {
         var manage = new ManageResult();
         this.LocalAdd(v, ref manage);
     }
 }
Ejemplo n.º 2
0
        public static ManageResult manage(LtoManualCV_ManualCV mst)
        {
            var manageResult = new ManageResult();

            try
            {
                var dbUtil = new DatabaseManager();
                using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
                {
                    string result = string.Empty;

                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandText    = "spLtoManualCV_manage";
                        cmd.CommandTimeout = 180;
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@intIDLtoManualCV", mst.intIDLtoManualCV);
                        cmd.Parameters.AddWithValue("@intIDLtoRFBankAccounts", mst.intIDLtoRFBankAccounts);
                        cmd.Parameters.AddWithValue("@DateAsOf", mst.DateAsOf);
                        cmd.Parameters.AddWithValue("@intLeadTime", mst.intLeadTime);
                        cmd.Parameters.AddWithValue("@BalanceLastMonth", mst.BalanceLastMonth);
                        cmd.Parameters.AddWithValue("@CAAmount", mst.CAAmount);
                        cmd.Parameters.AddWithValue("@TotalLiquidation", mst.TotalLiquidation);
                        cmd.Parameters.AddWithValue("@UnliquidatedBalance", mst.UnliquidatedBalance);
                        cmd.Parameters.AddWithValue("@CurrentAmount", mst.CurrentAmount);
                        cmd.Parameters.AddWithValue("@BeyondAmount", mst.BeyondAmount);
                        cmd.Parameters.AddWithValue("@intIDSecUser", mst.intIDSecUser);
                        cmd.Parameters.AddWithValue("@intIDMasLocation", mst.intIDMasLocation);

                        result = (string)cmd.ExecuteScalar();
                    }

                    if (result.Contains("Success121"))
                    {
                        string[] separators = { "," };
                        string[] words      = result.Split(separators, StringSplitOptions.RemoveEmptyEntries);

                        manageResult.Message = "Success";
                        manageResult.ID      = int.Parse(words[1].ToString());
                    }
                    else
                    {
                        manageResult.Message = result;
                        manageResult.ID      = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                manageResult.Message = "Error: " + ex.ToString();
                manageResult.ID      = 0;
            }

            return(manageResult);
        }
Ejemplo n.º 3
0
            /// <summary>葉要素の分割を行う。</summary>
            /// <param name="item">追加する要素。</param>
            /// <param name="idx">追加位置。</param>
            /// <param name="parent">木構造。</param>
            /// <param name="manage">処理状態。</param>
            private void Split(T item, int idx, BPlusTree <T> parent, ref ManageResult manage)
            {
                var tmpNext = new BLeaf(parent.bracketSize);

                if (idx < parent.mSize + 1)
                {
                    // 後半部分はコピー
                    tmpNext.Count = parent.mSize + 1;
                    Array.Copy(this.value, parent.mSize, tmpNext.value, 0, parent.mSize + 1);

                    // 前半部は挿入
#if DEBUG
                    Array.Clear(this.value, parent.mSize, this.value.Length - parent.mSize);
#endif
                    this.Count = parent.mSize + 1;
                    if (parent.mSize + 1 > idx)
                    {
                        Array.Copy(this.value, idx, this.value, idx + 1, (parent.mSize + 1) - idx);
                    }
                    this.value[idx] = item;
                }
                else
                {
                    // 後半部分に挿入
                    int ptr = idx - (parent.mSize + 1);
                    tmpNext.Count = parent.mSize + 1;
                    if (ptr > 0)
                    {
                        Array.Copy(this.value, parent.mSize + 1, tmpNext.value, 0, ptr);
                    }
                    Array.Copy(this.value, idx, tmpNext.value, ptr + 1, parent.bracketSize - idx);
                    tmpNext.value[ptr] = item;

                    // 前半部分は変更なし
#if DEBUG
                    Array.Clear(this.value, parent.mSize + 1, this.value.Length - (parent.mSize + 1));
#endif
                    this.Count = parent.mSize + 1;
                }

                // 前後のリンクを設定
                tmpNext.NextLeaf = this.NextLeaf;
                if (this.NextLeaf != null)
                {
                    this.NextLeaf.PreviewLeaf = tmpNext;
                }
                this.NextLeaf       = tmpNext;
                tmpNext.PreviewLeaf = this;

                // 新しく生成した要素を返す
                manage.newParts = tmpNext;
            }
Ejemplo n.º 4
0
        public void RetrieveRectangles(ManageResult manageresultcb, TContext context)
        {
            if (child[LEFT] != null)
            {
                child[LEFT].RetrieveRectangles(manageresultcb, context);
                child[RIGHT].RetrieveRectangles(manageresultcb, context);
            }

            if (hasData)
            {
                manageresultcb(rect, data, context);
            }
        }
Ejemplo n.º 5
0
        public static ManageResult manage(string xml, string isInsert)
        {
            var manageResult = new ManageResult();

            try
            {
                var dbUtil = new DatabaseManager();
                using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
                {
                    string result = string.Empty;

                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandText    = "spLtoCV_ManageLtoCV_MultiCompany";
                        cmd.CommandTimeout = 180;
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@xmlXML", xml);
                        cmd.Parameters.AddWithValue("@blnInsert", isInsert.Equals("insert"));
                        cmd.Parameters.AddWithValue("@blnUpdate", isInsert.Equals("update"));
                        cmd.Parameters.AddWithValue("@blnDelete", isInsert.Equals("delete"));
                        result = (string)cmd.ExecuteScalar();
                    }

                    if (result.Contains("Success"))
                    {
                        string[] separators = { "," };
                        string[] words      = result.Split(separators, StringSplitOptions.RemoveEmptyEntries);

                        manageResult.Message = words[0].ToString();
                        manageResult.ID      = int.Parse(words[1].ToString());
                    }
                    else
                    {
                        manageResult.Message = result;
                        manageResult.ID      = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                manageResult.Message = "Error: " + ex.ToString();
                manageResult.ID      = 0;
            }

            return(manageResult);
        }
            //---------------------------------------------------------------------
            // 追加
            //---------------------------------------------------------------------
            /// <summary>木要素に要素を追加する。</summary>
            /// <param name="item">追加する項目。</param>
            /// <param name="parent">B+木コレクション。</param>
            /// <param name="manage">処理結果。</param>
            /// <returns>追加したら真。</returns>
            public bool Add(T item, BPlusTree <T> parent, ref ManageResult manage)
            {
                int lf = 0;
                int rt = this.Count - 1;
                int md;

                // 挿入位置の検索
                while (lf < rt)
                {
                    md = lf + (rt - lf) / 2;

                    if (md + 1 < this.Count &&
                        parent.defComp.Compare(this.value[md + 1].HeaderItem, item) <= 0)
                    {
                        lf = md + 1;
                    }
                    else
                    {
                        rt = md;
                    }
                }

                // 要素を挿入する
                if (this.value[lf].Add(item, parent, ref manage))
                {
                    if (this.Count < parent.bracketSize)
                    {
                        // 挿入位置に値を挿入
                        if (this.Count > lf + 1)
                        {
                            Array.Copy(this.value, lf + 1, this.value, lf + 2, this.Count - (lf + 1));
                        }
                        this.value[lf + 1] = manage.newParts;
                        this.Count++;
                        return(false);
                    }
                    else
                    {
                        // 領域サイズを超えたので分割する
                        this.Split(manage.newParts, lf + 1, parent, ref manage);
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
 /// <summary>要素を追加する(内部処理)</summary>
 /// <param name="item">追加する要素。</param>
 /// <param name="manage">処理状態結果。</param>
 private void LocalAdd(T item, ref ManageResult manage)
 {
     if (this.root == null)
     {
         if (this.start.Add(item, this, ref manage))
         {
             this.root = new BBranch(this.bracketSize, this.start, manage.newParts);
         }
     }
     else
     {
         if (this.root.Add(item, this, ref manage))
         {
             this.root = new BBranch(this.bracketSize, this.root, manage.newParts);
         }
     }
 }
            /// <summary>枝要素の分割を行う。</summary>
            /// <param name="element">追加する要素。</param>
            /// <param name="idx">追加位置。</param>
            /// <param name="parent">木構造。</param>
            /// <param name="manage">処理結果。</param>
            private void Split(IBParts element, int idx, BPlusTree <T> parent, ref ManageResult manage)
            {
                var tmpNext = new BBranch(parent.bracketSize);

                if (idx < parent.mSize + 1)
                {
                    // 後半部分はコピー
                    tmpNext.Count = parent.mSize + 1;
                    Array.Copy(this.value, parent.mSize, tmpNext.value, 0, parent.mSize + 1);

                    // 前半部は挿入
#if DEBUG
                    Array.Clear(this.value, parent.mSize, this.value.Length - parent.mSize);
#endif
                    this.Count = parent.mSize + 1;
                    if (parent.mSize + 1 > idx)
                    {
                        Array.Copy(this.value, idx, this.value, idx + 1, (parent.mSize + 1) - idx);
                    }
                    this.value[idx] = element;
                }
                else
                {
                    // 後半部分に挿入
                    int ptr = idx - (parent.mSize + 1);
                    tmpNext.Count = parent.mSize + 1;
                    if (ptr > 0)
                    {
                        Array.Copy(this.value, parent.mSize + 1, tmpNext.value, 0, ptr);
                    }
                    Array.Copy(this.value, idx, tmpNext.value, ptr + 1, parent.bracketSize - idx);
                    tmpNext.value[ptr] = element;

                    // 前半部分は変更なし
#if DEBUG
                    Array.Clear(this.value, parent.mSize + 1, this.value.Length - (parent.mSize + 1));
#endif
                    this.Count = parent.mSize + 1;
                }

                // 検索キー参照変更
                tmpNext.headerLeaf = tmpNext.TraverseLeaf;

                // 新しく生成した要素を返す
                manage.newParts = tmpNext;
            }
        public static ManageResult removeCVRecord(int intIDSecUser, int intIDLtoIncentiveDetails)
        {
            var manageResult = new ManageResult();

            try
            {
                var dbUtil = new DatabaseManager();
                using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
                {
                    string result = string.Empty;

                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandText    = "spLtoIncentive_removeCVRecord";
                        cmd.CommandTimeout = 180;
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@intIDSecUser", intIDSecUser);
                        cmd.Parameters.AddWithValue("@intIDLtoIncentiveDetails", intIDLtoIncentiveDetails);

                        result = (string)cmd.ExecuteScalar();
                    }

                    if (result.Contains("Success121"))
                    {
                        manageResult.Message = "Success";
                        manageResult.ID      = 0;
                    }
                    else
                    {
                        manageResult.Message = result;
                        manageResult.ID      = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                manageResult.Message = "Error: " + ex.ToString();
                manageResult.ID      = 0;
            }

            return(manageResult);
        }
Ejemplo n.º 10
0
        private void AddFaceStage(DetectResult detectResult)
        {
            if (detectResult.face.Count != 1)
            {
                System.Windows.MessageBox.Show("No face detected, or more than one faces detected");
                return;
            }
            //perform add face to person
            ManageResult result = fs.Person_AddFaceByName(userName.Text, detectResult.face[0].face_id);

            if (result == null)
            {
                return;
            }
            if (result.success)
            {
                fs.Train_VerifyByName(userName.Text);
                System.Windows.MessageBox.Show("Face Added");
            }
        }
Ejemplo n.º 11
0
            //---------------------------------------------------------------------
            // 追加
            //---------------------------------------------------------------------
            /// <summary>木要素に要素を追加する。</summary>
            /// <param name="item">追加する項目。</param>
            /// <param name="parent">B+木コレクション。</param>
            /// <param name="manage">処理結果。</param>
            /// <returns>追加できたならば真。</returns>
            public bool Add(T item, BPlusTree <T> parent, ref ManageResult manage)
            {
                if (this.Count <= 0)
                {
                    // 要素が一つもなければ先頭に追加する
                    this.value[0] = item;
                    this.Count++;
                    parent.Count++;
                    manage.changed = true;
                    return(false);
                }
                else
                {
                    // 挿入位置を検索する
                    int idx = BinarySearchOfAdd(item, parent.defComp);

                    if (this.Count < parent.bracketSize)
                    {
                        // 挿入位置に値を挿入
                        if (this.Count > idx)
                        {
                            Array.Copy(this.value, idx, this.value, idx + 1, this.Count - idx);
                        }
                        this.value[idx] = item;

                        this.Count++;
                        parent.Count++;
                        manage.changed = true;
                        return(false);
                    }
                    else
                    {
                        // 領域サイズを超えたので分割する
                        this.Split(item, idx, parent, ref manage);
                        parent.Count++;
                        manage.changed = true;
                        return(true);
                    }
                }
            }
Ejemplo n.º 12
0
        private void buttonReadLib_Click(object sender, EventArgs e)
        {
            textBoxOutput.Clear();
            textBoxOutput.AppendText("请稍等。" + Environment.NewLine);

            fs.Group_DeleteByName(Env.GroupName);
            GroupBasicInfo tempGroupBasicInfo = fs.Group_CreateByIdList(Env.GroupName);
            string         libPath            = System.Environment.CurrentDirectory + Path.DirectorySeparatorChar + Env.libFolder + Path.DirectorySeparatorChar;

            if (!Directory.Exists(libPath))
            {
                MessageBox.Show("没有找到数据库 !", "错误");
                return;
            }
            string[] folders = Directory.GetFileSystemEntries(libPath);
            TrainCount = 0;

            //Every name in folder
            foreach (string singleFolder in folders)
            {
                TrainCount++;
                string[] spiltString = new string[1]
                {
                    Path.DirectorySeparatorChar.ToString()
                };
                string[] items = singleFolder.Split(spiltString, StringSplitOptions.RemoveEmptyEntries);
                string   Name  = items[items.Count() - 1];
                fs.Person_DeleteByName(Name);
                PersonBasicInfo tempPersonBasicInfo = fs.Person_Create(Name);
                long            i         = 0;
                bool            faceExist = false;
                while (File.Exists(libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName))
                {
                    faceExist = true;
                    DetectResult res = fs.Detection_DetectImg(libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName);
                    if (res.face.Count != 1)
                    {
                        MessageBox.Show("路径" + libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName + "中不存在人脸!已经自动删除", "警告");
                        File.Delete(libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName);
                        buttonReadLib_Click(sender, e);
                        return;
                    }
                    ManageResult AddFaceResult = fs.Person_AddFaceById(tempPersonBasicInfo.person_id, res.face[0].face_id);
                    if (!AddFaceResult.success)
                    {
                        MessageBox.Show("为用户添加脸部信息失败!", "错误");
                        return;
                    }
                    i++;
                }
                if (!faceExist)
                {
                    MessageBox.Show(Name + "中没有脸部数据!", "警告");
                    continue;
                }
                ManageResult tempAddPersonResult = fs.Group_AddPerson("", Env.GroupName, "", Name);
                if (!tempAddPersonResult.success)
                {
                    MessageBox.Show("添加用户信息失败!", "错误");
                    return;
                }
                AsyncResult tempAsyncResult            = fs.Train_VerifyByName(Name);
                ParameterizedThreadStart CheckFinished = new ParameterizedThreadStart(ProcessCheckAsyncVerifyByName);
                Thread CheckFinishedProcess            = new Thread(CheckFinished);
                CheckFinishedProcess.IsBackground = true;
                string[] arguementStrings = new string[] { tempAsyncResult.session_id, Name };
                CheckFinishedProcess.Start(arguementStrings);
            }


            MessageBox.Show("数据库建立完成!请等待为每一个人的人脸学习过程完成。", "信息");
        }
        public static ManageResult manage(string xml, LtoIncentive_tblLtoIncentive mst)
        {
            var manageResult = new ManageResult();

            try
            {
                var dbUtil = new DatabaseManager();
                using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
                {
                    string result = string.Empty;

                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandText    = "spLtoIncentive_manageLtoIncentive";
                        cmd.CommandTimeout = 180;
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@intIDLtoIncentive", mst.intIDLtoIncentive);
                        cmd.Parameters.AddWithValue("@datTransaction", mst.datTransaction);
                        cmd.Parameters.AddWithValue("@intIDLtoRFBankAccounts", mst.intIDMasEmployeeLiaison);
                        cmd.Parameters.AddWithValue("@intIDMasEmployeeLtoStaff", mst.intIDMasEmployeeLtoStaff);
                        cmd.Parameters.AddWithValue("@intIDMasEmployeeSS", mst.intIDMasEmployeeSS);
                        cmd.Parameters.AddWithValue("@intIDMasEmployeeCA", mst.intIDMasEmployeeCA);
                        cmd.Parameters.AddWithValue("@intIDMasEmployeeAC", mst.intIDMasEmployeeAC);
                        cmd.Parameters.AddWithValue("@intIDMasEmployeeAC2", mst.intIDMasEmployeeAC2);
                        cmd.Parameters.AddWithValue("@intIDMasEmployeeAC3", mst.intIDMasEmployeeAC3);
                        cmd.Parameters.AddWithValue("@Remarks", mst.Remarks);
                        cmd.Parameters.AddWithValue("@intIDSecUser", mst.intIDSecUser);
                        cmd.Parameters.AddWithValue("@LiaisonAmount", mst.LiaisonAmount);
                        cmd.Parameters.AddWithValue("@LtoStaffAmount", mst.LtoStaffAmount);
                        cmd.Parameters.AddWithValue("@SSAmount", mst.SSAmount);
                        cmd.Parameters.AddWithValue("@CashierAmount", mst.CashierAmount);
                        cmd.Parameters.AddWithValue("@WithholdingTax", mst.WithholdingTax);
                        cmd.Parameters.AddWithValue("@datIncentive", mst.datIncentive);
                        cmd.Parameters.AddWithValue("@xmlXML", xml);

                        result = (string)cmd.ExecuteScalar();
                    }

                    if (result.Contains("Success121"))
                    {
                        string[] separators = { "," };
                        string[] words      = result.Split(separators, StringSplitOptions.RemoveEmptyEntries);

                        manageResult.Message = "Success";
                        manageResult.ID      = int.Parse(words[1].ToString());
                    }
                    else
                    {
                        manageResult.Message = result;
                        manageResult.ID      = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                manageResult.Message = "Error: " + ex.ToString();
                manageResult.ID      = 0;
            }

            return(manageResult);
        }
Ejemplo n.º 14
0
        //---------------------------------------------------------------------
        // 追加
        //---------------------------------------------------------------------
        /// <summary>要素を追加する。</summary>
        /// <param name="item">追加する要素。</param>
        public void Add(T item)
        {
            var manage = new ManageResult();

            this.LocalAdd(item, ref manage);
        }