Beispiel #1
0
        private void bwAsync_Worker(object sender, DoWorkEventArgs e)
        {
            ProcessingType type = (ProcessingType)e.Argument;

            e.Result = type;

            switch (type)
            {
            case ProcessingType.LoadData:
            {
                mListIntent = IntentPresenter.GetIntents();

                int index = 1;
                foreach (Intent data in mListIntent)
                {
                    data.STT = index;
                    index++;
                }
            }
            break;

            case ProcessingType.CapNhat:
            {
                foreach (DM_Intent_Type data in DM_Intent_Type.GetDefaultList(0))
                {
                    Intent mIntent = mListIntent.FirstOrDefault(p => p.DM_Intent_TypeID == data.DM_Intent_TypeID);
                    if (mIntent == null)
                    {
                        mIntent = new Intent();
                        mIntent.DM_Intent_TypeID = data.DM_Intent_TypeID;
                        mIntent.IntentName       = data.DM_Intent_TypeName;
                        IntentPresenter.InsertIntent(mIntent);
                    }
                    else
                    {
                        if (mIntent.IntentName != data.DM_Intent_TypeName)
                        {
                            mIntent.IntentName = data.DM_Intent_TypeName;
                            IntentPresenter.UpdateIntent(mIntent);
                        }
                    }
                }
            }
            break;

            default:
                break;
            }
        }
Beispiel #2
0
        private void bwAsync_Worker(object sender, DoWorkEventArgs e)
        {
            ProcessingType type = (ProcessingType)e.Argument;

            e.Result = type;

            switch (type)
            {
            case ProcessingType.LoadData:
            {
                mListData_Flat = IntentPresenter.GetIntents();

                //Update dữ liệu
                mListData = new List <Intent>();
                foreach (DM_Intent_Type nhom in DM_Intent_Type.GetDefaultList(0))
                {
                    if (mListData_Flat.Any(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID))
                    {
                        Intent group_Intent = new Intent();
                        group_Intent.DM_Intent_TypeID = nhom.DM_Intent_TypeID;
                        group_Intent.IntentID         = -1;
                        group_Intent.IntentName       = nhom.DM_Intent_TypeName;
                        group_Intent.mListSubData     = mListData_Flat.Where(p => p.DM_Intent_TypeID == nhom.DM_Intent_TypeID).ToList();
                        mListData.Add(group_Intent);
                    }
                }

                //Update danh sách tất cả các khoa
                {
                    mListThongTinDanhSachIntent      = new List <ThongTinDanhSachIntent>();
                    mListThongTinDanhSachIntent_Flat = new List <ThongTinDanhSachIntent>();
                    ThongTinDanhSachIntent.ThongTinDanhSachIntentID_Index = 1;

                    //Add tất cả khoa
                    ThongTinDanhSachIntent root = new ThongTinDanhSachIntent();
                    root.ThongTinDanhSachIntentType = (int)ThongTinDanhSachIntent.TYPE.ROOT;
                    root.mListData = mListData;
                    root.ThongTinDanhSachIntentName = "Tất Cả Ý Muốn (" + mListData_Flat.Where(p => p.IntentID > 0).Count() + ")";
                    mListThongTinDanhSachIntent.Add(root);
                    mListThongTinDanhSachIntent_Flat.Add(root);
                }

                foreach (DM_Intent_Group nhom_dich_vu in DM_Intent_Group.GetDefaultList(0))
                {
                    ThongTinDanhSachIntent mData = new ThongTinDanhSachIntent();
                    mData.ThongTinDanhSachIntentType = (int)ThongTinDanhSachIntent.TYPE.GROUP;
                    mData.DM_Intent_GroupID          = nhom_dich_vu.DM_Intent_GroupID;
                    mData.mListSubData = new List <ThongTinDanhSachIntent>();
                    mData.mListData    = mListData;
                    mData.ThongTinDanhSachIntentName = DM_Intent_Group.GetDefault(mData.DM_Intent_GroupID).DM_Intent_GroupName;

                    //Add loại khoa
                    {
                        IList <DM_Intent_SubGroup> list_sub = DM_Intent_SubGroup.GetDefaultList_Group(0, mData.DM_Intent_GroupID);
                        foreach (DM_Intent_SubGroup sub_data in list_sub)
                        {
                            ThongTinDanhSachIntent mSubData = new ThongTinDanhSachIntent();
                            mSubData.ThongTinDanhSachIntentType = (int)ThongTinDanhSachIntent.TYPE.SUB_GROUP;
                            mSubData.DM_Intent_GroupID          = mData.DM_Intent_GroupID;
                            mSubData.DM_Intent_SubGroupID       = sub_data.DM_Intent_SubGroupID;
                            mSubData.mListData = new List <Intent>();
                            mSubData.ThongTinDanhSachIntentName = DM_Intent_SubGroup.GetDefault(mSubData.DM_Intent_SubGroupID).DM_Intent_SubGroupName;

                            //Loai
                            if (sub_data.DM_Intent_GroupID == DM_Intent_Group.LOAI)
                            {
                                int loai_khoa = sub_data.DM_Intent_SubGroupID - DM_Intent_SubGroup.LOAI_INIT;
                                mSubData.mListData = mListData_Flat.Where(p => p.DM_Intent_TypeID == loai_khoa).ToList();
                            }

                            //Check
                            if (mSubData.mListData.Count > 0)
                            {
                                mSubData.ThongTinDanhSachIntentName += " (" + mSubData.mListData.Count + ")";
                                mData.mListSubData.Add(mSubData);
                                mListThongTinDanhSachIntent_Flat.Add(mSubData);
                            }
                        }
                    }

                    //Check
                    if (mData.mListData.Count > 0)
                    {
                        mListThongTinDanhSachIntent.Add(mData);
                        mListThongTinDanhSachIntent_Flat.Add(mData);
                    }
                }
            }
            break;

            default:
                break;
            }
        }