private void GetDataFromUI()
 {
     if (currenObject == null)
     {
         MessageBox.Show("Data is null, please check again");
         return;
     }
     if (_updataType == UpdataType.Add)
     {
         currenObjectCreate.WK_INT_NO = VnHelper.ConvertToUnSign(txtWK_INT_NO.Text.Trim().ToUpper());
         currenObjectCreate.TTL_ENG   = VnHelper.ConvertToUnSign(txtTTL_ENG.Text.Trim().ToUpper());
         currenObjectCreate.ISWC_NO   = VnHelper.ConvertToUnSign(txtISWC_NO.Text.Trim().ToUpper());
         currenObjectCreate.ISRC      = VnHelper.ConvertToUnSign(txtISRC.Text.Trim().ToUpper());
         currenObjectCreate.WRITER    = VnHelper.ConvertToUnSign(txtWRITER.Text.Trim().ToUpper());
         currenObjectCreate.ARTIST    = VnHelper.ConvertToUnSign(txtARTIST.Text.Trim().ToUpper());
         currenObjectCreate.SOC_NAME  = VnHelper.ConvertToUnSign(txtSOC_NAME.Text.Trim().ToUpper());
     }
     else
     {
         currenObjectUpdate.Id        = currenObject.Id;
         currenObjectUpdate.WK_INT_NO = VnHelper.ConvertToUnSign(txtWK_INT_NO.Text.Trim().ToUpper());
         currenObjectUpdate.TTL_ENG   = VnHelper.ConvertToUnSign(txtTTL_ENG.Text.Trim().ToUpper());
         currenObjectUpdate.ISWC_NO   = VnHelper.ConvertToUnSign(txtISWC_NO.Text.Trim().ToUpper());
         currenObjectUpdate.ISRC      = VnHelper.ConvertToUnSign(txtISRC.Text.Trim().ToUpper());
         currenObjectUpdate.WRITER    = VnHelper.ConvertToUnSign(txtWRITER.Text.Trim().ToUpper());
         currenObjectUpdate.ARTIST    = VnHelper.ConvertToUnSign(txtARTIST.Text.Trim().ToUpper());
         currenObjectUpdate.SOC_NAME  = VnHelper.ConvertToUnSign(txtSOC_NAME.Text.Trim().ToUpper());
     }
 }
Example #2
0
 private void btnFind_Click(object sender, EventArgs e)
 {
     try
     {
         List <ContractObject> fill = new List <ContractObject>();
         if (cboType.SelectedIndex == 0)
         {
             //fill = contractObjects.Where(x => x.Customer.Contains(txtFind.Text.Trim())).ToList();
             var query = contractObjects.Where(delegate(ContractObject c)
             {
                 if (VnHelper.ConvertToUnSign(c.Customer).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }).AsQueryable();
             fill = query.ToList();
         }
         else if (cboType.SelectedIndex == 1)
         {
             //fill = contractObjects.Where(x => x.License.Contains(txtFind.Text.Trim())).ToList();
             var query = contractObjects.Where(delegate(ContractObject c)
             {
                 if (VnHelper.ConvertToUnSign(c.License).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }).AsQueryable();
             fill = query.ToList();
         }
         else if (cboType.SelectedIndex == 2)
         {
             //fill = contractObjects.Where(x => x.ContractNumber.Contains(txtFind.Text.Trim())).ToList();
             var query = contractObjects.Where(delegate(ContractObject c)
             {
                 if (VnHelper.ConvertToUnSign(c.ContractNumber).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }).AsQueryable();
             fill = query.ToList();
         }
         dgvMain.DataSource = fill;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }
Example #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            inPar = null;
            //int countItem = 0;
            if (inparlist != null && inparlist.Count > 0)
            {
                foreach (var item in inparlist)
                {
                    if (txtIP_INT_NO.Text.Trim() == item.IP_INT_NO)
                    {
                        //countItem++;
                        if (_updataType == UpdataType.Add)
                        {
                            lbInfo.Text = $"IP_INT_NO ({item.IP_INT_NO}) is exist, please input again";
                            return;
                        }
                        else
                        {
                            if (IP_INT_NO_old != txtIP_INT_NO.Text.Trim())
                            {
                                lbInfo.Text = $"IP_INT_NO ({item.IP_INT_NO}) is exist, please input again";
                                return;
                            }
                        }
                    }
                }
            }
            if (txtIP_NAME.Text.Trim() == string.Empty)
            {
                lbInfo.Text = "IP_NAME is empty, please input title";
                return;
            }
            inPar           = new InterestedParty();
            inPar.No        = (maxNo + 1);
            inPar.IP_INT_NO = txtIP_INT_NO.Text.Trim().ToUpper();
            inPar.IP_NAME   = VnHelper.ConvertToUnSign(txtIP_NAME.Text.Trim()).ToUpper();

            inPar.IP_NAMETYPE = cboIP_NAMETYPE.Text.Trim();
            inPar.IP_WK_ROLE  = cboIP_WK_ROLE.Text.Trim();
            //inPar.WK_STATUS = cboWK_STATUS.Text.Trim();

            inPar.PER_OWN_SHR = numPER_OWN_SHR.Value;
            inPar.PER_COL_SHR = numPER_COL_SHR.Value;

            inPar.MEC_OWN_SHR = numMEC_OWN_SHR.Value;
            inPar.MEC_COL_SHR = numMEC_COL_SHR.Value;

            inPar.SP_SHR        = numSP_SHR.Value;
            inPar.TOTAL_MEC_SHR = numTOTAL_MEC_SHR.Value;

            inPar.SYN_OWN_SHR   = numSYN_OWN_SHR.Value;
            inPar.SYN_COL_SHR   = numSYN_COL_SHR.Value;
            inPar.Society       = txtSociety.Text.Trim().ToUpper();
            inPar.IP_NAME_LOCAL = txtIP_NAME_LOCAL.Text.Trim().ToUpper();
            inPar.CountUpdate++;
            inPar.LastUpdateAt = DateTime.Now;
            this.Close();
        }
 private void btnOk_Click(object sender, EventArgs e)
 {
     otherTitle = null;
     if (txtTitle.Text.Trim() == string.Empty)
     {
         lbInfo.Text = "Title is empty, please input title";
         return;
     }
     otherTitle           = new OtherTitle();
     otherTitle.No        = (maxNo + 1);
     otherTitle.Title     = VnHelper.ConvertToUnSign(txtTitle.Text.Trim()).ToUpper();
     otherTitle.TTL_LOCAL = txtTTL_LOCAL.Text.Trim().ToUpper();
     //otherTitle.TitleType = txtTitleType.Text.Trim();
     //otherTitle.Language = txtLanguage.Text.Trim();
     this.Close();
 }
        private void GetDataFromUI()
        {
            if (currenObject == null)
            {
                MessageBox.Show("Data is null, please check again");
                return;
            }
            if (_updataType == UpdataType.Add)
            {
                currenObjectCreate.Asset_ID      = VnHelper.ConvertToUnSign(txtAsset_ID.Text.Trim());
                currenObjectCreate.ISRC          = VnHelper.ConvertToUnSign(txtISRC.Text.Trim().ToUpper());
                currenObjectCreate.Comp_Asset_ID = VnHelper.ConvertToUnSign(txtComp_Asset_ID.Text.Trim().ToUpper());
                currenObjectCreate.C_Title       = VnHelper.ConvertToUnSign(txtC_Title.Text.Trim().ToUpper());
                currenObjectCreate.C_ISWC        = VnHelper.ConvertToUnSign(txtC_ISWC.Text.Trim().ToUpper());
                currenObjectCreate.C_Workcode    = VnHelper.ConvertToUnSign(txtC_Workcode.Text.Trim().ToUpper());
                currenObjectCreate.C_Writers     = VnHelper.ConvertToUnSign(txtC_Writers.Text.Trim().ToUpper());

                currenObjectCreate.Combined_Claim = numCombined_Claim.Text.Trim().ToUpper();
                currenObjectCreate.Mechanical     = numMechanical.Text.Trim().ToUpper();
                currenObjectCreate.Performance    = numPerformance.Text.Trim().ToUpper();

                //currenObjectCreate.MONTH = (int)numMONTH.Value;
                currenObjectCreate.DtCREATED_AT = dtCreate_at.Value;
                currenObjectCreate.DtUPDATED_AT = null;
                //currenObjectCreate.Year = (int)numYear.Value;
            }
            else
            {
                currenObjectUpdate.Id            = currenObject.Id;
                currenObjectUpdate.Asset_ID      = VnHelper.ConvertToUnSign(txtAsset_ID.Text.Trim());
                currenObjectUpdate.ISRC          = VnHelper.ConvertToUnSign(txtISRC.Text.Trim().ToUpper());
                currenObjectUpdate.Comp_Asset_ID = VnHelper.ConvertToUnSign(txtComp_Asset_ID.Text.Trim().ToUpper());
                currenObjectUpdate.C_Title       = VnHelper.ConvertToUnSign(txtC_Title.Text.Trim().ToUpper());
                currenObjectUpdate.C_ISWC        = VnHelper.ConvertToUnSign(txtC_ISWC.Text.Trim().ToUpper());
                currenObjectUpdate.C_Workcode    = VnHelper.ConvertToUnSign(txtC_Workcode.Text.Trim().ToUpper());
                currenObjectUpdate.C_Writers     = VnHelper.ConvertToUnSign(txtC_Writers.Text.Trim().ToUpper());

                currenObjectUpdate.Combined_Claim = numCombined_Claim.Text.Trim().ToUpper();
                currenObjectUpdate.Mechanical     = numMechanical.Text.Trim().ToUpper();
                currenObjectUpdate.Performance    = numPerformance.Text.Trim().ToUpper();

                //currenObjectUpdate.MONTH = (int)numMONTH.Value;
                currenObjectUpdate.DtCREATED_AT = dtCreate_at.Value;
                currenObjectUpdate.DtUPDATED_AT = dtUpdate_at.Value;
                //currenObjectUpdate.Year = (int)numYear.Value;
            }
        }
 private void FilterData()
 {
     try
     {
         isFilter = true;
         List <RoleViewModel> fill = new List <RoleViewModel>();
         if (cboTypeChoise == 0)
         {
             var query = data.ResultObj.Items.Where(delegate(RoleViewModel c)
             {
                 if (VnHelper.ConvertToUnSign(c.Name).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }).AsQueryable();
             fill = query.ToList();
         }
         dgvMain.Invoke(new MethodInvoker(delegate
         {
             dgvMain.DataSource = fill;
         }));
         statusMain.Invoke(new MethodInvoker(delegate
         {
             lbOperation.Text = $"Filter data, total record(s): {fill.Count}";
         }));
         isFilter = false;
     }
     catch (Exception)
     {
         isFilter = false;
         pcloader.Invoke(new MethodInvoker(delegate
         {
             pcloader.Visible = false;
         }));
     }
 }
        private void GetDataFromUI()
        {
            if (currenObject == null)
            {
                MessageBox.Show("Data is null, please check again");
                return;
            }
            if (_updataType == UpdataType.Add)
            {
                currenObjectCreate.Group    = _group;
                currenObjectCreate.CodeOld  = VnHelper.ConvertToUnSign(txtCodeOld.Text.Trim().ToUpper());
                currenObjectCreate.CodeNew  = VnHelper.ConvertToUnSign(txtCodeNew.Text.Trim().ToUpper());
                currenObjectCreate.Name     = txtName.Text.Trim().ToUpper();
                currenObjectCreate.Name2    = VnHelper.ConvertToUnSign(txtName.Text.Trim().ToUpper());
                currenObjectCreate.Own      = txtOwn.Text.Trim().ToUpper();
                currenObjectCreate.Own2     = VnHelper.ConvertToUnSign(txtOwn.Text.Trim().ToUpper());
                currenObjectCreate.NameType = VnHelper.ConvertToUnSign(txtNameType.Text.Trim().ToUpper());

                currenObjectCreate.NoteMono  = txtNoteMono.Text.Trim().ToUpper();
                currenObjectCreate.Note2     = txtNote2.Text.Trim().ToUpper();
                currenObjectCreate.Note3     = txtNote3.Text.Trim().ToUpper();
                currenObjectCreate.IsExpired = cheIsExpired.Checked;

                currenObjectCreate.StartTime   = dtStartTime.Value;
                currenObjectCreate.EndTime     = dtEndTime.Value;
                currenObjectCreate.UpdateTime  = dtUpdateTime.Value;
                currenObjectCreate.ReceiveTime = dtReceiveTime.Value;

                currenObjectCreate.Tone            = cheTone.Checked;
                currenObjectCreate.Web             = cheWeb.Checked;
                currenObjectCreate.Performances    = chePerformances.Checked;
                currenObjectCreate.PerformancesHCM = chePerformancesHCM.Checked;
                currenObjectCreate.Cddvd           = cheCddvd.Checked;
                currenObjectCreate.Kok             = cheKok.Checked;
                currenObjectCreate.Broadcasting    = cheBroadCasting.Checked;

                currenObjectCreate.Entertaiment = cheEntertaiment.Checked;

                currenObjectCreate.Film          = cheFilm.Checked;
                currenObjectCreate.Advertisement = cheAdvertisement.Checked;
                currenObjectCreate.PubMusicBook  = chePubMusicBook.Checked;
                currenObjectCreate.Youtube       = cheYoutube.Checked;
                currenObjectCreate.Other         = cheOther.Checked;
            }
            else
            {
                currenObjectUpdate.Group    = _group;
                currenObjectUpdate.Id       = currenObject.Id;
                currenObjectUpdate.CodeOld  = VnHelper.ConvertToUnSign(txtCodeOld.Text.Trim().ToUpper());
                currenObjectUpdate.CodeNew  = VnHelper.ConvertToUnSign(txtCodeNew.Text.Trim().ToUpper());
                currenObjectUpdate.Name     = txtName.Text.Trim().ToUpper();
                currenObjectUpdate.Name2    = VnHelper.ConvertToUnSign(txtName.Text.Trim().ToUpper());
                currenObjectUpdate.Own      = txtOwn.Text.Trim().ToUpper();
                currenObjectUpdate.Own2     = VnHelper.ConvertToUnSign(txtOwn.Text.Trim().ToUpper());
                currenObjectUpdate.NameType = VnHelper.ConvertToUnSign(txtNameType.Text.Trim().ToUpper());

                currenObjectUpdate.NoteMono  = txtNoteMono.Text.Trim().ToUpper();
                currenObjectUpdate.Note2     = txtNote2.Text.Trim().ToUpper();
                currenObjectUpdate.Note3     = txtNote3.Text.Trim().ToUpper();
                currenObjectUpdate.IsExpired = cheIsExpired.Checked;

                currenObjectUpdate.StartTime   = dtStartTime.Value;
                currenObjectUpdate.EndTime     = dtEndTime.Value;
                currenObjectUpdate.UpdateTime  = dtUpdateTime.Value;
                currenObjectUpdate.ReceiveTime = dtReceiveTime.Value;

                currenObjectUpdate.Tone            = cheTone.Checked;
                currenObjectUpdate.Web             = cheWeb.Checked;
                currenObjectUpdate.Performances    = chePerformances.Checked;
                currenObjectUpdate.PerformancesHCM = chePerformancesHCM.Checked;
                currenObjectUpdate.Cddvd           = cheCddvd.Checked;
                currenObjectUpdate.Kok             = cheKok.Checked;
                currenObjectUpdate.Broadcasting    = cheBroadCasting.Checked;

                currenObjectUpdate.Entertaiment = cheEntertaiment.Checked;

                currenObjectUpdate.Film          = cheFilm.Checked;
                currenObjectUpdate.Advertisement = cheAdvertisement.Checked;
                currenObjectUpdate.PubMusicBook  = chePubMusicBook.Checked;
                currenObjectUpdate.Youtube       = cheYoutube.Checked;
                currenObjectUpdate.Other         = cheOther.Checked;
            }
        }
        private void GetDataFromUI()
        {
            if (currenObject == null)
            {
                MessageBox.Show("Data is null, please check again");
                return;
            }
            if (_updataType == UpdataType.Add)
            {
                currenObjectCreate.WK_INT_NO = VnHelper.ConvertToUnSign(txtWK_INT_NO.Text.Trim().ToUpper());
                currenObjectCreate.TTL_ENG   = VnHelper.ConvertToUnSign(txtTTL_ENG.Text.Trim().ToUpper());
                currenObjectCreate.TTL_LOCAL = txtTTL_ENG.Text.Trim().ToUpper();
                currenObjectCreate.ISWC_NO   = VnHelper.ConvertToUnSign(txtISWC_NO.Text.Trim().ToUpper());
                currenObjectCreate.ISRC      = txtISRC.Text.Trim();

                currenObjectCreate.WRITER       = string.Empty;
                currenObjectCreate.WRITER_LOCAL = string.Empty;
                //bool isCOMPLETE = true;
                for (int i = 0; i < currenObjectCreate.InterestedParties.Count; i++)
                {
                    if (currenObjectCreate.WRITER != string.Empty)
                    {
                        currenObjectCreate.WRITER += ",";
                    }
                    currenObjectCreate.WRITER += currenObjectCreate.InterestedParties[i].IP_NAME;

                    if (currenObjectCreate.InterestedParties[i].IP_NAME_LOCAL != string.Empty)
                    {
                        if (currenObjectCreate.WRITER_LOCAL != string.Empty)
                        {
                            currenObjectCreate.WRITER_LOCAL += ",";
                        }
                        currenObjectCreate.WRITER_LOCAL += currenObjectCreate.InterestedParties[i].IP_NAME_LOCAL;
                        //TODO 2020-10-02
                        //
                        //if(isCOMPLETE && currenObjectCreate.InterestedParties[i].WK_STATUS != "COMPLETE")
                        //{
                        //    isCOMPLETE = false;
                        //}
                    }
                }
                currenObjectCreate.ARTIST     = VnHelper.ConvertToUnSign(txtARTIST.Text.Trim().ToUpper());
                currenObjectCreate.SOC_NAME   = VnHelper.ConvertToUnSign(txtSOC_NAME.Text.Trim().ToUpper());
                currenObjectCreate.WK_STATUS  = cboWK_STATUS.Text;
                currenObjectCreate.StarRating = (int)numStarRating.Value;
            }
            else
            {
                //bool isCOMPLETE = true;
                currenObjectUpdate.Id        = currenObject.Id;
                currenObjectUpdate.WK_INT_NO = VnHelper.ConvertToUnSign(txtWK_INT_NO.Text.Trim().ToUpper());
                currenObjectUpdate.TTL_ENG   = VnHelper.ConvertToUnSign(txtTTL_ENG.Text.Trim().ToUpper());
                currenObjectUpdate.TTL_LOCAL = txtTTL_LOCAL.Text.Trim().ToUpper();
                currenObjectUpdate.ISWC_NO   = VnHelper.ConvertToUnSign(txtISWC_NO.Text.Trim().ToUpper());
                currenObjectUpdate.ISRC      = VnHelper.ConvertToUnSign(txtISRC.Text.Trim().ToUpper());

                currenObjectUpdate.WRITER       = string.Empty;
                currenObjectUpdate.WRITER_LOCAL = string.Empty;

                for (int i = 0; i < currenObjectUpdate.InterestedParties.Count; i++)
                {
                    if (currenObjectUpdate.WRITER != string.Empty)
                    {
                        currenObjectUpdate.WRITER += ",";
                    }
                    currenObjectUpdate.WRITER += currenObjectUpdate.InterestedParties[i].IP_NAME;

                    if (currenObjectUpdate.InterestedParties[i].IP_NAME_LOCAL != string.Empty)
                    {
                        if (currenObjectUpdate.WRITER_LOCAL != string.Empty)
                        {
                            currenObjectUpdate.WRITER_LOCAL += ",";
                        }
                        currenObjectUpdate.WRITER_LOCAL += currenObjectUpdate.InterestedParties[i].IP_NAME_LOCAL;
                        //TODO 2020-10-02
                        //
                        //if (isCOMPLETE && currenObjectUpdate.InterestedParties[i].WK_STATUS != "COMPLETE")
                        //{
                        //    isCOMPLETE = false;
                        //}
                    }
                }
                currenObjectUpdate.ARTIST     = VnHelper.ConvertToUnSign(txtARTIST.Text.Trim().ToUpper());
                currenObjectUpdate.SOC_NAME   = VnHelper.ConvertToUnSign(txtSOC_NAME.Text.Trim().ToUpper());
                currenObjectUpdate.WK_STATUS  = cboWK_STATUS.Text;
                currenObjectUpdate.StarRating = (int)numStarRating.Value;
            }
        }
        /// <summary>
        /// Nạp file json preclaim
        /// </summary>
        /// <param name="path"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public static List <PreclaimViewModel> JsonToPreclaim(string path)
        {
            string        line;
            List <string> subJsonList = new List <string>();
            StreamReader  r           = new StreamReader(path);
            bool          isFirst     = false;
            string        subJson     = "";

            while ((line = r.ReadLine()) != null)
            {
                subJson += line;
                if (line.Trim() == "{")
                {
                    isFirst = true;
                }
                else if (line.Trim() == "}")
                {
                    if (isFirst)
                    {
                        subJsonList.Add(subJson);
                    }
                    isFirst = false;
                    subJson = "";
                }
            }
            List <PreclaimViewModel> objects = new List <PreclaimViewModel>();
            BsonDocument             doctem  = null;
            PreclaimJson             preJson = null;
            PreclaimViewModel        preVM   = null;
            int serial = 1;

            for (int i = 0; i < subJsonList.Count; i++)
            {
                doctem  = BsonSerializer.Deserialize <BsonDocument>(subJsonList[i]);
                preJson = BsonSerializer.Deserialize <PreclaimJson>(doctem);
                preVM   = new PreclaimViewModel
                {
                    SerialNo       = serial,
                    Asset_ID       = preJson.Asset_ID,
                    ISRC           = preJson.ISRC == null ? string.Empty: VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(preJson.ISRC.ToUpper())),
                    Comp_Asset_ID  = preJson.Comp_Asset_ID,
                    C_Title        = preJson.C_Title == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(preJson.C_Title.ToUpper())),
                    C_ISWC         = preJson.C_ISWC == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(preJson.C_ISWC.ToUpper())),
                    C_Workcode     = preJson.C_Workcode == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(preJson.C_Workcode.ToUpper())),
                    C_Writers      = preJson.C_Writers == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(preJson.C_Writers.ToUpper())),
                    Combined_Claim = preJson.Combined_Claim == null ? "0": VnHelper.ConvertToUnSign(preJson.Combined_Claim),
                    Mechanical     = preJson.Mechanical == null ? "0" : VnHelper.ConvertToUnSign(preJson.Mechanical),
                    Performance    = preJson.Performance == null ? "0" : VnHelper.ConvertToUnSign(preJson.Performance),
                    //MONTH = month,// preJson.MONTH,
                    //Year = year
                };
                //if (preJson.CREATED_AT != null)
                //{
                preVM.DtCREATED_AT = TimeTicks.ConvertTicksMongoToC(preJson.CREATED_AT);
                //}
                if (preJson.UPDATED_AT != null)
                {
                    preVM.DtUPDATED_AT = TimeTicks.ConvertTicksMongoToC((long)preJson.UPDATED_AT);
                }
                objects.Add(preVM);
                serial++;
            }
            return(objects);
        }
 static void Main(string[] args)
 {
     string str   = "ù";
     bool   check = VnHelper.Detect(str);
     int    a     = 1;
 }
 private void FilterData()
 {
     try
     {
         isFilter = true;
         List <MemberWorkList> fill = new List <MemberWorkList>();
         if (cboTypeChoise == 0)
         {
             //var query = ediFilesItemsClone.Where(delegate (WorkViewModel c)
             //{
             //    if (VnHelper.ConvertToUnSign(c.WK_INT_NO).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
             //        return true;
             //    else
             //        return false;
             //}).AsQueryable();
             var query = ediFilesItemsClone.Where(c => c.INTERNAL_NO.IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0);
             fill = query.ToList();
         }
         else if (cboTypeChoise == 1)
         {
             var query = ediFilesItemsClone.Where(delegate(MemberWorkList c)
             {
                 if (VnHelper.ConvertToUnSign(c.TITLE).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }).AsQueryable();
             //var query = ediFilesItemsClone.Where(c => c.GroupWriter.IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0);
             fill = query.ToList();
         }
         else if (cboTypeChoise == 2)
         {
             var query = ediFilesItemsClone.Where(delegate(MemberWorkList c)
             {
                 if (VnHelper.ConvertToUnSign(c.NAME).IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0)
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }).AsQueryable();
             //var query = ediFilesItemsClone.Where(c => c.GroupWriter.IndexOf(txtFind.Text.Trim(), StringComparison.CurrentCultureIgnoreCase) >= 0);
             fill = query.ToList();
         }
         dgvEditCalcXXX.Invoke(new MethodInvoker(delegate
         {
             dgvEditCalcXXX.DataSource = fill;
         }));
         statusMain.Invoke(new MethodInvoker(delegate
         {
             lbOperation.Text = $"Filter data, total record(s): {fill.Count}";
         }));
         isFilter = false;
     }
     catch (Exception)
     {
         pcloader.Invoke(new MethodInvoker(delegate
         {
             pcloader.Visible = false;
         }));
         isFilter = false;
     }
 }
        private async void LoadDtaFromExcel()
        {
            try
            {
                #region init
                isLoad = true;
                ExcelHelper excelHelper = new ExcelHelper();
                #endregion

                #region reset
                totalLoad        = 0;
                totalRest        = 0;
                totalRestAffCalc = 0;
                totalDuplicate   = 0;
                lbTotalLoad.Invoke(new MethodInvoker(delegate
                {
                    lbTotalLoad.Text = totalLoad.ToString();
                }));
                lbTotalrest.Invoke(new MethodInvoker(delegate
                {
                    lbTotalrest.Text = totalRest.ToString();
                }));
                lbTotalAftercalc.Invoke(new MethodInvoker(delegate
                {
                    lbTotalAftercalc.Text = totalRestAffCalc.ToString();
                }));
                lbTotalDuplicate.Invoke(new MethodInvoker(delegate
                {
                    lbTotalDuplicate.Text = totalDuplicate.ToString();
                }));
                ediFilesItems      = new List <MemberWorkList>();
                ediFilesItemsClone = new List <MemberWorkList>();
                dgvEditFileImport.Invoke(new MethodInvoker(delegate
                {
                    dgvEditFileImport.DataSource = ediFilesItems;
                }));
                dgvEditCalcXXX.Invoke(new MethodInvoker(delegate
                {
                    dgvEditCalcXXX.DataSource = ediFilesItemsClone;
                }));
                #endregion

                //du lieu doc file
                ediFilesItems = excelHelper.ReadExcelMemberEorkList(tstxtPath.Text);

                #region 1.Loai bo dong trong
                List <MemberWorkList> editFiles = new List <MemberWorkList>();
                if (ediFilesItems != null)
                {
                    ediFilesItemsClone.Clear();
                    string WorkInternalNo = string.Empty;
                    string INTERNAL_NO    = string.Empty;
                    int    pos            = 0;
                    string TITLE2         = string.Empty;
                    string TITLE3         = string.Empty;

                    string   name = string.Empty;
                    string   name3 = string.Empty;
                    string[] arrayname = null;
                    string   text, text2;
                    string[] arrWriterReal;
                    for (int i = 0; i < ediFilesItems.Count; i++)
                    {
                        name      = ediFilesItems[i].NAME;
                        arrayname = name.Split(',');
                        if (arrayname.Length != 2)
                        {
                            continue;
                        }
                        if (arrayname[1].Trim() == string.Empty)
                        {
                            name  = arrayname[0].Trim();
                            name3 = name;
                        }
                        else
                        {
                            if (name == "TRAN THIEN, THANH TRẦN THIỆNTHANH")
                            {
                                int a = 1;
                            }
                            //TRAN THIEN, THANH TRẦN THIỆNTHANH
                            //TRAN THIEN
                            arrayname[0] = arrayname[0].Trim();
                            name         = $"{arrayname[0]} ";
                            //THANH TRẦN THIỆNTHANH
                            arrayname[1] = arrayname[1].Trim();
                            name3        = arrayname[1];
                            //THANH:TRẦN:THIỆNTHANH
                            arrayname    = arrayname[1].Split(' ');
                            arrayname[0] = arrayname[0].Trim();
                            //TRAN THIEN THANH
                            name += arrayname[0];
                            //TRẦN THIỆNTHANH
                            pos = name3.IndexOf(arrayname[0]);
                            if (pos >= 0)
                            {
                                name3 = name3.Substring(pos + arrayname[0].Length, name3.Length - arrayname[0].Length - pos).Trim();
                            }
                            #region nếu là tác giả việt
                            if (name3.Length > 0)
                            {
                                text          = name3.Replace(" ", "");
                                text2         = VnHelper.ConvertToUnSign(text);
                                arrWriterReal = name.Split(' ');
                                name3         = string.Empty;
                                for (int k = 0; k < arrWriterReal.Length; k++)
                                {
                                    pos = text2.IndexOf(arrWriterReal[k]);
                                    if (pos >= 0)
                                    {
                                        int x  = text.Length;
                                        int x1 = text2.Length;
                                        name3 += text.Substring(pos, arrWriterReal[k].Length) + " ";
                                        text   = text.Substring(arrWriterReal[k].Length, text.Length - arrWriterReal[k].Length);
                                        text2  = text2.Substring(arrWriterReal[k].Length, text2.Length - arrWriterReal[k].Length);
                                    }
                                }
                            }
                            #endregion
                        }
                        #region general report: thuong dung
                        if (ediFilesItems[i].INTERNAL_NO != string.Empty)
                        {
                            INTERNAL_NO = ediFilesItems[i].INTERNAL_NO;
                            var x = (MemberWorkList)ediFilesItems[i].Clone();
                            pos    = x.TITLE.Length / 2;
                            TITLE2 = x.TITLE.Substring(0, pos).Trim();
                            TITLE3 = x.TITLE.Substring(pos, x.TITLE.Length - pos).Trim();
                            if (VnHelper.Detect(TITLE3) && TITLE2 == VnHelper.ConvertToUnSign(TITLE3))
                            {
                                x.TITLE2 = TITLE2;
                                x.TITLE3 = TITLE3;
                            }
                            else
                            {
                                x.TITLE2 = x.TITLE;
                                x.TITLE3 = x.TITLE;
                            }
                            x.NAME2 = name;
                            x.NAME3 = name3.Trim();
                            ediFilesItemsClone.Add(x);
                        }
                        else
                        {
                            var x = ediFilesItemsClone.Where(p => p.INTERNAL_NO == INTERNAL_NO).FirstOrDefault();
                            if (x != null)
                            {
                                if (x.NAME_TYPE != string.Empty)
                                {
                                    x.NAME_TYPE += ", ";
                                }
                                x.NAME_TYPE += ediFilesItems[i].NAME_TYPE;

                                if (x.ROLE != string.Empty)
                                {
                                    x.ROLE += ", ";
                                }
                                x.ROLE += ediFilesItems[i].ROLE;

                                if (x.SOCIETY != string.Empty)
                                {
                                    x.SOCIETY += ", ";
                                }
                                x.SOCIETY += ediFilesItems[i].SOCIETY;

                                if (x.NAME2 != string.Empty)
                                {
                                    x.NAME2 += ", ";
                                }
                                x.NAME2 += name;

                                if (x.NAME3 != string.Empty)
                                {
                                    x.NAME3 += ", ";
                                }
                                x.NAME3 += name3.Trim();
                            }
                        }
                        #endregion
                    }
                    totalRest = ediFilesItemsClone.Count;
                    lbTotalrest.Invoke(new MethodInvoker(delegate
                    {
                        lbTotalrest.Text = totalRest.ToString();
                    }));
                }
                else
                {
                    ediFilesItemsClone.Clear();
                }
                #endregion

                #region Hien thi du lieu goc
                //bindingSourceImport.DataSource = ediFilesItems;
                //bindingSourceEdit.DataSource = ediFilesItemsClone;
                if (ediFilesItems != null)
                {
                    totalLoad = ediFilesItems.Count;
                    lbTotalLoad.Invoke(new MethodInvoker(delegate
                    {
                        lbTotalLoad.Text = totalLoad.ToString();
                    }));

                    dgvEditFileImport.Invoke(new MethodInvoker(delegate
                    {
                        dgvEditFileImport.DataSource = ediFilesItems;
                    }));
                    dgvEditCalcXXX.Invoke(new MethodInvoker(delegate
                    {
                        dgvEditCalcXXX.DataSource = ediFilesItemsClone;
                    }));
                    FilterData();
                    totalRestAffCalc = ediFilesItemsClone.Count;
                    totalDuplicate   = totalRest - totalRestAffCalc;

                    lbTotalAftercalc.Invoke(new MethodInvoker(delegate
                    {
                        lbTotalAftercalc.Text = totalRestAffCalc.ToString();
                    }));
                    lbTotalDuplicate.Invoke(new MethodInvoker(delegate
                    {
                        lbTotalDuplicate.Text = totalDuplicate.ToString();
                    }));
                }
                else
                {
                    lbTotalLoad.Text = "0";
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbInfo.Text = "Load data from Excel file be error!";
                    }));
                }
                #endregion
                isLoad = false;
            }
            catch (Exception ex)
            {
                isLoad = false;
                MessageBox.Show(ex.ToString());
            }
        }
        private void LoadDataFreClaimJsonfile()
        {
            try
            {
                currentDataImView = new List <WorkTrackingViewModel>();
                dataImport        = new List <WorkTrackingViewModel>();

                dgvImport.Invoke(new MethodInvoker(delegate
                {
                    dgvImport.DataSource = currentDataImView;
                }));

                countImportFromFile = 0;
                DateTime startTime = DateTime.Now;
                totalPageIm = 0;

                DirectionNarrowDisable();
                #region Read file
                string[] files   = Directory.GetFiles(path);
                int      serical = 0;
                foreach (var item in files)
                {
                    string[] list_name = item.Split('\\');
                    string   name      = "";
                    if (list_name.Length > 0)
                    {
                        name = list_name.Last();
                    }
                    string data = JsonHelper.LoadJson(item);
                    WorkRetrievalViewModel source = JsonHelper.JsonToWorkRetrieval(data);

                    for (int i = 0; i < source._object.retrevalList.Count; i++)
                    {
                        serical++;
                        WorkTrackingViewModel preVM = new WorkTrackingViewModel();
                        preVM.SerialNo  = serical;
                        preVM.WK_INT_NO = source._object.retrevalList[i].wkIntNo == null? string.Empty: VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(source._object.retrevalList[i].wkIntNo.ToUpper()));
                        preVM.TTL_ENG   = source._object.retrevalList[i].engTitle == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(source._object.retrevalList[i].engTitle.ToUpper()));
                        preVM.ISWC_NO   = source._object.retrevalList[i].iswcNo == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(source._object.retrevalList[i].iswcNo.ToUpper()));
                        preVM.ISRC      = source._object.retrevalList[i].isrcNo == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(source._object.retrevalList[i].isrcNo.ToUpper()));
                        preVM.WRITER    = source._object.retrevalList[i].composer == null ? string.Empty : VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(source._object.retrevalList[i].composer.ToUpper()));
                        for (int j = 0; j < source._object.retrevalList[i].artiste.Length; j++)
                        {
                            if (preVM.ARTIST.Length > 0)
                            {
                                preVM.ARTIST += ",";
                            }
                            preVM.ARTIST += source._object.retrevalList[i].artiste[j];
                        }
                        preVM.ARTIST = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(preVM.ARTIST));
                        // preVM.SOC_NAME = dataxxx2._object.retrevalList[i].wkIntNo;
                        preVM.Type  = type;
                        preVM.Year  = year;
                        preVM.MONTH = month;

                        #region bo tac gia tieng viet
                        //VIET HO HUU VIỆTHỒ HỮU
                        //NGUYEN THI SONG NGUYEN = NGUYENXETHISONG NGUYỄN
                        //NGUYEN THI SONG NGUYEN = NGUYENTHISONG NGUYEN
                        if (preVM.WRITER.Length > 0)
                        {
                            //if (preVM.WRITER.Trim() == "VIET HO HUU VIỆTHỒ HỮU")
                            //{
                            //    int a = 1;
                            //}
                            //preVM.WRITER = VnHelper.ConvertToUnSign(preVM.WRITER);
                            string[] ilistWriter  = preVM.WRITER.Trim().Split(',');
                            string[] arrayIwriter = null;
                            string   s1           = "";
                            string   s2           = "";
                            bool     isCorrect    = false;
                            int      pos          = 0;
                            preVM.WRITER = "";
                            string iWriterSub = "";
                            foreach (var iWriter in ilistWriter)
                            {
                                isCorrect    = false;
                                arrayIwriter = iWriter.Trim().Split(' ');
                                if (arrayIwriter.Length > 1)
                                {
                                    string ho = arrayIwriter[arrayIwriter.Length - 1];
                                    pos        = iWriter.LastIndexOf(ho);
                                    iWriterSub = iWriter.Substring(0, pos);
                                    pos        = iWriterSub.LastIndexOf(ho);
                                    if (pos > 0)
                                    {
                                        s1 = iWriter.Substring(0, pos + ho.Length);
                                        s2 = iWriter.Substring(pos + ho.Length, iWriter.Length - (pos + ho.Length));
                                        if (s1.Replace(" ", "") == s2.Replace(" ", ""))
                                        {
                                            isCorrect = true;
                                        }
                                    }
                                }

                                if (isCorrect)
                                {
                                    preVM.WRITER += $",{s1}";
                                }
                                else
                                {
                                    preVM.WRITER += $",{iWriter}";
                                }
                            }
                            if (preVM.WRITER.Length > 1)
                            {
                                preVM.WRITER = preVM.WRITER.Substring(1, preVM.WRITER.Length - 1);
                            }
                        }
                        #endregion

                        dataImport.Add(preVM);
                    }
                }
                #endregion
                if (dataImport != null && dataImport.Count > 0)
                {
                    countImportFromFile = dataImport.Count;
                    if (countImportFromFile % limitIm == 0)
                    {
                        totalPageIm = countImportFromFile / limitIm;
                    }
                    else
                    {
                        totalPageIm = countImportFromFile / limitIm + 1;
                    }
                    lbTotalPage.Invoke(new MethodInvoker(delegate
                    {
                        lbTotalPage.Text = totalPageIm.ToString();
                    }));
                    GotoPage(currentPageIm, totalPageIm);

                    mainStatus.Invoke(new MethodInvoker(delegate
                    {
                        lbInfo.Text = $"Total records load: {countImportFromFile}";
                    }));
                }
                else
                {
                    mainStatus.Invoke(new MethodInvoker(delegate
                    {
                        lbInfo.Text = "Load data from json file be error!";
                    }));
                }
                DateTime endTime = DateTime.Now;
                lbInfoImport.Invoke(new MethodInvoker(delegate
                {
                    lbInfoImport.Text  = $"Time load(second(s)): {(endTime - startTime).TotalSeconds.ToString("##0.##")}, ";
                    lbInfoImport.Text += $"total record(s): {countImportFromFile}, total page(s): {totalPageIm}, ";
                    lbInfoImport.Text += $"total records/page: {limitIm}";
                }));
            }
            catch (Exception)
            {
                pcloader.Invoke(new MethodInvoker(delegate
                {
                    pcloader.Visible = false;
                }));
            }
        }
        private void LoadDtaFromExcel()
        {
            try
            {
                dataLoad = new List <ConvertyToUnsign>();
                dgvEditFileImport.Invoke(new MethodInvoker(delegate
                {
                    dgvEditFileImport.DataSource = new List <ConvertyToUnsign>();
                }));
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbOperation.Text = "Starting load data...";
                }));
                #region init
                ExcelHelper excelHelper = new ExcelHelper();
                #endregion
                //du lieu doc file
                dataLoad = excelHelper.ReadExcelConvertyToUnsign(tstxtPath.Text);
                //var orderByDescendingResult = (from s in ediFilesItems
                //                               //orderby s.seqNo ascending, s.NoOfPerf ascending
                //                               select s).ToList();
                #region 1.Loai bo dong trong
                if (dataLoad != null)
                {
                    for (int i = 0; i < dataLoad.Count; i++)
                    {
                        dataLoad[i].c1  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c1.Trim().ToUpper()));
                        dataLoad[i].c2  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c2.Trim().ToUpper()));
                        dataLoad[i].c3  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c3.Trim().ToUpper()));
                        dataLoad[i].c4  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c4.Trim().ToUpper()));
                        dataLoad[i].c5  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c5.Trim().ToUpper()));
                        dataLoad[i].c6  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c6.Trim().ToUpper()));
                        dataLoad[i].c7  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c7.Trim().ToUpper()));
                        dataLoad[i].c8  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c8.Trim().ToUpper()));
                        dataLoad[i].c9  = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c9.Trim().ToUpper()));
                        dataLoad[i].c10 = VnHelper.ConvertToUnSign(ConvertAllToUnicode.ConvertFromComposite(dataLoad[i].c10.Trim().ToUpper()));
                    }
                }
                #endregion

                #region Hien thi du lieu goc

                if (dataLoad != null)
                {
                    dgvEditFileImport.Invoke(new MethodInvoker(delegate
                    {
                        dgvEditFileImport.DataSource = dataLoad;
                    }));
                }
                else
                {
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbInfo.Text = "Load data from Excel file be error!";
                    }));
                }
                #endregion
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbOperation.Text = "Load data is finish";
                }));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private async void SysnData()
        {
            try
            {
                if (dataMaster == null || dataMaster.Items == null || dataMaster.Items.Count == 0)
                {
                    return;
                }
                isSync = true;
                int totalSuccess = 0;
                int total        = 0;
                for (int i = 0; i < dataMaster.Items.Count; i++)
                {
                    total += dataMaster.Items[i].Items.Count();
                }
                if (total == 0)
                {
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbInfo.Text      = $"Proccessing sync is finish";
                        lbOperation.Text = "Data is empty, so not sync to work";
                    }));
                    isSync = false;
                    return;
                }
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbOperation.Text = "Sync...";
                }));
                DateTime TheFiestTime = DateTime.Now;
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    progressBarImport.Value = 0;
                    lbPercent.Text          = "0%";
                }));

                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbInfo.Text = $"Proccessing sync...";
                }));
                btnSysToWork.Invoke(new MethodInvoker(delegate
                {
                    btnSysToWork.Enabled = false;
                }));
                btnMatch.Invoke(new MethodInvoker(delegate
                {
                    btnMatch.Enabled = false;
                }));
                btnLoadMasterList.Invoke(new MethodInvoker(delegate
                {
                    btnLoadMasterList.Enabled = false;
                }));
                //btnLoadDetails.Invoke(new MethodInvoker(delegate
                //{
                //    btnLoadDetails.Enabled = false;
                //}));
                btnExportExcel.Invoke(new MethodInvoker(delegate
                {
                    btnExportExcel.Enabled = false;
                }));

                DateTime startTime = DateTime.Now;


                for (int i = 0; i < dataMaster.Items.Count; i++)
                {
                    WorkChangeListRequest request = new WorkChangeListRequest();
                    string codeWriter             = VnHelper.ConvertToUnSign(dataMaster.Items[i].IntNo.ToUpper());
                    string nameWriter             = VnHelper.ConvertToUnSign(dataMaster.Items[i].Member.ToUpper());
                    foreach (var item in dataMaster.Items[i].Items)
                    {
                        if (!request.Items.Where(p => p.WK_INT_NO == item.WorkIntNo.ToUpper()).Any())
                        {
                            WorkCreateRequest itmUpdate = new WorkCreateRequest();
                            itmUpdate.WK_INT_NO = VnHelper.ConvertToUnSign(item.WorkIntNo.ToUpper());
                            itmUpdate.TTL_ENG   = VnHelper.ConvertToUnSign(item.Title.Trim().ToUpper());
                            //vi other title giong voi title nen khong can them
                            //itmUpdate.OtherTitles.Add(new Shared.Mis.Works.OtherTitle
                            //{
                            //    No = 1,
                            //    Title = itmUpdate.TTL_ENG
                            //}) ;
                            itmUpdate.InterestedParties.Add(new Shared.Mis.Works.InterestedParty
                            {
                                No         = 1,
                                IP_INT_NO  = codeWriter,
                                IP_NAME    = nameWriter,
                                IP_WK_ROLE = item.Role,
                                //TODO 2020-10-02
                                //WK_STATUS = "COMPLETE",

                                PER_OWN_SHR = item.Share,
                                PER_COL_SHR = item.Share,

                                MEC_OWN_SHR = item.Share,
                                MEC_COL_SHR = item.Share,

                                SP_SHR        = item.Share,
                                TOTAL_MEC_SHR = item.Share,

                                SYN_OWN_SHR   = item.Share,
                                SYN_COL_SHR   = item.Share,
                                Society       = "",//rong se khong cap nhat
                                CountUpdate   = 1,
                                LastUpdateAt  = DateTime.Now,
                                LastChoiseAt  = DateTime.Now,
                                IP_NUMBER     = dataMaster.Items[i].IPINameNo,
                                IP_NAME_LOCAL = "", //rong se khong cap nhat
                                IP_NAMETYPE   = "", //rong se khong cap nhat
                            });
                            itmUpdate.WRITER    = nameWriter;
                            itmUpdate.ARTIST    = string.Empty;
                            itmUpdate.SOC_NAME  = string.Empty;
                            itmUpdate.WK_STATUS = "COMPLETE";
                            request.Items.Add(itmUpdate);
                        }
                    }
                    //request.Items
                    var data = await controller.ChangeList(request);

                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        float values            = (float)(i + 1) / (float)dataMaster.Items.Count * 100;
                        progressBarImport.Value = (int)values;
                        lbPercent.Text          = $"{((int)values).ToString()}%";
                    }));
                    totalSuccess += data.Items.Where(p => p.Status == Utilities.Common.UpdateStatus.Successfull).ToList().Count;
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbOperation.Text = $"Sync..., total sync success/total: {totalSuccess}/{total}";
                    }));
                }
                #region update Ui when finish
                btnSysToWork.Invoke(new MethodInvoker(delegate
                {
                    btnSysToWork.Enabled = true;
                }));
                btnMatch.Invoke(new MethodInvoker(delegate
                {
                    btnMatch.Enabled = true;
                }));
                btnLoadMasterList.Invoke(new MethodInvoker(delegate
                {
                    btnLoadMasterList.Enabled = true;
                }));
                //btnLoadDetails.Invoke(new MethodInvoker(delegate
                //{
                //    btnLoadDetails.Enabled = true;
                //}));

                btnExportExcel.Invoke(new MethodInvoker(delegate
                {
                    btnExportExcel.Enabled = true;
                }));
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbInfo.Text  = $"sync tracking work to work be finish, total time {(DateTime.Now - TheFiestTime).TotalSeconds}(s)";
                    lbInfo.Text += $", total sync success/total: {totalSuccess}/{total}";
                }));

                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbOperation.Text = "Sync is finish";
                }));
                #endregion
                isSync = false;
            }
            catch (Exception)
            {
                isSync = false;
                if (btnMatch != null && !btnMatch.IsDisposed)
                {
                    btnMatch.Invoke(new MethodInvoker(delegate
                    {
                        btnMatch.Enabled = true;
                    }));
                }
                if (btnLoadMasterList != null && !btnLoadMasterList.IsDisposed)
                {
                    btnLoadMasterList.Invoke(new MethodInvoker(delegate
                    {
                        btnLoadMasterList.Enabled = true;
                    }));
                }
                //if (btnLoadDetails != null && !btnLoadDetails.IsDisposed)
                //{
                //    btnLoadDetails.Invoke(new MethodInvoker(delegate
                //    {
                //        btnLoadDetails.Enabled = true;
                //    }));
                //}
                if (btnExportExcel != null && !btnExportExcel.IsDisposed)
                {
                    btnExportExcel.Invoke(new MethodInvoker(delegate
                    {
                        btnExportExcel.Enabled = true;
                    }));
                }
                if (btnSysToWork != null && !btnSysToWork.IsDisposed)
                {
                    btnSysToWork.Invoke(new MethodInvoker(delegate
                    {
                        btnSysToWork.Enabled = true;
                    }));
                }
                if (lbOperation != null && !lbInfo.IsDisposed)
                {
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbOperation.Text = $"Sync tracking work to work be failure";
                    }));
                }
            }
        }
        private async void SysnData()
        {
            try
            {
                if (dataLoad == null || dataLoad.Count == 0)
                {
                    return;
                }
                int totalSuccess = 0;
                int total        = dataLoad.Count;

                if (total == 0)
                {
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbInfo.Text      = $"Proccessing sync is finish";
                        lbOperation.Text = "Data is empty, so not sync to work";
                    }));
                    return;
                }
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbOperation.Text = "Sync...";
                }));
                DateTime TheFiestTime = DateTime.Now;
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    progressBarImport.Value = 0;
                    lbPercent.Text          = "0%";
                }));

                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbInfo.Text = $"Proccessing sync...";
                }));
                btnSysToWork.Invoke(new MethodInvoker(delegate
                {
                    btnSysToWork.Enabled = false;
                }));
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    btnLoad.Enabled = false;
                }));

                DateTime startTime = DateTime.Now;

                WorkChangeListRequest request = new WorkChangeListRequest();
                string   status;
                string[] writer;
                string[] writer1;
                string[] writer2;
                for (int i = 0; i < dataLoad.Count; i++)
                {
                    if (reportType == 2)
                    {
                        #region Add
                        if (!request.Items.Where(p => p.WK_INT_NO == dataLoad[i].WK_INT_NO.ToUpper()).Any())
                        {
                            WorkCreateRequest itmUpdate = new WorkCreateRequest();
                            itmUpdate.WK_INT_NO = VnHelper.ConvertToUnSign(dataLoad[i].WK_INT_NO.ToUpper());
                            itmUpdate.TTL_ENG   = VnHelper.ConvertToUnSign(dataLoad[i].TTL_ENG.Trim().ToUpper());
                            itmUpdate.TTL_LOCAL = dataLoad[i].TTL_LOCAL.Trim().ToUpper();
                            itmUpdate.WK_STATUS = dataLoad[i].STATUS;
                            #region Tac gia
                            itmUpdate.InterestedParties.Add(new Shared.Mis.Works.InterestedParty
                            {
                                No         = itmUpdate.InterestedParties.Count + 1,
                                IP_INT_NO  = dataLoad[i].InternalNo,
                                IP_NAME    = dataLoad[i].WRITER,
                                IP_WK_ROLE = dataLoad[i].WK_ROLE,

                                PER_OWN_SHR = dataLoad[i].PER_OWN_SHR,
                                PER_COL_SHR = dataLoad[i].PER_OWN_SHR,

                                MEC_OWN_SHR = dataLoad[i].MEC_COL_SHR,
                                MEC_COL_SHR = dataLoad[i].MEC_COL_SHR,

                                SP_SHR        = dataLoad[i].PER_OWN_SHR,
                                TOTAL_MEC_SHR = dataLoad[i].MEC_COL_SHR,

                                SYN_OWN_SHR   = 0,
                                SYN_COL_SHR   = 0,
                                Society       = dataLoad[i].Society,
                                CountUpdate   = 1,
                                LastUpdateAt  = DateTime.Now,
                                LastChoiseAt  = DateTime.Now,
                                IP_NUMBER     = dataLoad[i].IpNumber,
                                IP_NAME_LOCAL = dataLoad[i].WRITER_LOCAL,
                                IP_NAMETYPE   = dataLoad[i].IP_NAME_TYPE,
                            });
                            #endregion
                            itmUpdate.WRITER       = dataLoad[i].WRITER;
                            itmUpdate.WRITER_LOCAL = dataLoad[i].WRITER_LOCAL;
                            itmUpdate.ARTIST       = dataLoad[i].ARTIST;
                            itmUpdate.SOC_NAME     = dataLoad[i].SOC_NAME;
                            itmUpdate.ISWC_NO      = dataLoad[i].ISWC_NO;
                            itmUpdate.ISRC         = dataLoad[i].ISRC;
                            request.Items.Add(itmUpdate);
                        }
                        else
                        {
                            var item = request.Items.Where(p => p.WK_INT_NO == dataLoad[i].WK_INT_NO).FirstOrDefault();
                            if (item != null)
                            {
                                #region tac gia
                                if (!item.InterestedParties.Where(p => p.IP_INT_NO == dataLoad[i].WK_INT_NO).Any())
                                {
                                    item.InterestedParties.Add(new Shared.Mis.Works.InterestedParty
                                    {
                                        No         = item.InterestedParties.Count + 1,
                                        IP_INT_NO  = dataLoad[i].InternalNo,
                                        IP_NAME    = dataLoad[i].WRITER,
                                        IP_WK_ROLE = dataLoad[i].WK_ROLE,

                                        //TODO 2020-10-02
                                        //WK_STATUS = dataLoad[i].STATUS,

                                        PER_OWN_SHR = dataLoad[i].PER_OWN_SHR,
                                        PER_COL_SHR = dataLoad[i].PER_OWN_SHR,

                                        MEC_OWN_SHR = dataLoad[i].MEC_COL_SHR,
                                        MEC_COL_SHR = dataLoad[i].MEC_COL_SHR,

                                        SP_SHR        = dataLoad[i].PER_OWN_SHR,
                                        TOTAL_MEC_SHR = dataLoad[i].MEC_COL_SHR,

                                        SYN_OWN_SHR   = 0,
                                        SYN_COL_SHR   = 0,
                                        Society       = dataLoad[i].Society,
                                        CountUpdate   = 1,
                                        LastUpdateAt  = DateTime.Now,
                                        LastChoiseAt  = DateTime.Now,
                                        IP_NUMBER     = dataLoad[i].IpNumber,
                                        IP_NAME_LOCAL = dataLoad[i].WRITER_LOCAL,
                                        IP_NAMETYPE   = dataLoad[i].IP_NAME_TYPE,
                                    });

                                    if (item.WRITER != string.Empty)
                                    {
                                        item.WRITER += ",";
                                    }
                                    item.WRITER += dataLoad[i].WRITER;
                                    if (item.WRITER_LOCAL != string.Empty)
                                    {
                                        item.WRITER_LOCAL += ",";
                                    }
                                    item.WRITER_LOCAL += dataLoad[i].WRITER_LOCAL;
                                }
                                else
                                {
                                    //int a = 1;
                                }
                                #endregion

                                #region Other title
                                if ((item.TTL_ENG != dataLoad[i].TTL_ENG) && (!item.OtherTitles.Where(p => p.Title == dataLoad[i].TTL_ENG).Any()))
                                {
                                    item.OtherTitles.Add(new Shared.Mis.Works.OtherTitle
                                    {
                                        No        = item.OtherTitles.Count + 1,
                                        Title     = dataLoad[i].TTL_ENG,
                                        TTL_LOCAL = dataLoad[i].TTL_LOCAL,
                                    });
                                }
                                else
                                {
                                    //int a = 1;
                                }
                                #endregion
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        #region Add
                        if (!request.Items.Where(p => p.WK_INT_NO == dataLoad[i].WK_INT_NO.ToUpper()).Any())
                        {
                            WorkCreateRequest itmUpdate = new WorkCreateRequest();
                            itmUpdate.WK_INT_NO = VnHelper.ConvertToUnSign(dataLoad[i].WK_INT_NO.ToUpper());
                            itmUpdate.TTL_ENG   = VnHelper.ConvertToUnSign(dataLoad[i].TTL_ENG.Trim().ToUpper());
                            itmUpdate.TTL_LOCAL = dataLoad[i].TTL_LOCAL.Trim().ToUpper();
                            itmUpdate.WK_STATUS = dataLoad[i].STATUS;
                            if (dataLoad[i].WK_INT_NO == "17615461")
                            {
                                //int a = 1;
                            }
                            //HUNSAKER JASON BRADLEY,MARCKS WILLIAM DANIEL,WILCOX JAMES STEVEN,WOOD JEREMY M
                            writer = dataLoad[i].WRITER.Split(',');
                            //nhac
                            writer1 = dataLoad[i].WRITER2.Split(',');
                            //loi
                            writer2 = dataLoad[i].WRITER3.Split(',');

                            string role = string.Empty;
                            for (int k = 0; k < writer.Length; k++)
                            {
                                #region role
                                if (dataLoad[i].WRITER2.Length > 0 || dataLoad[i].WRITER3.Length > 0)
                                {
                                    //loi trong=> CA
                                    if (dataLoad[i].WRITER3.Length == 0)
                                    {
                                        role = "CA";
                                    }
                                    //nam trong loi
                                    else if (writer2.Contains(writer[k].Trim()))
                                    {
                                        role = "A";
                                    }
                                    else
                                    {
                                        //nhac
                                        role = "C";
                                    }
                                }
                                #endregion

                                #region Tac gia
                                if (writer[k] != string.Empty)
                                {
                                    itmUpdate.InterestedParties.Add(new Shared.Mis.Works.InterestedParty
                                    {
                                        No = itmUpdate.InterestedParties.Count + 1,
                                        //CHo nay neu danh sach co ma thi phai xu ly khac
                                        IP_INT_NO  = dataLoad[i].InternalNo,
                                        IP_NAME    = writer[k].Trim(),
                                        IP_WK_ROLE = role,

                                        PER_OWN_SHR = 0,
                                        PER_COL_SHR = 0,

                                        MEC_OWN_SHR = 0,
                                        MEC_COL_SHR = 0,

                                        SP_SHR        = 0,
                                        TOTAL_MEC_SHR = 0,

                                        SYN_OWN_SHR   = 0,
                                        SYN_COL_SHR   = 0,
                                        Society       = dataLoad[i].Society,
                                        CountUpdate   = 1,
                                        LastUpdateAt  = DateTime.Now,
                                        LastChoiseAt  = DateTime.Now,
                                        IP_NUMBER     = dataLoad[i].IpNumber,
                                        IP_NAME_LOCAL = dataLoad[i].WRITER_LOCAL,
                                        IP_NAMETYPE   = dataLoad[i].IP_NAME_TYPE,
                                    });
                                }
                                #endregion
                            }
                            itmUpdate.WRITER       = dataLoad[i].WRITER;
                            itmUpdate.WRITER_LOCAL = dataLoad[i].WRITER_LOCAL;
                            itmUpdate.ARTIST       = dataLoad[i].ARTIST;
                            itmUpdate.SOC_NAME     = dataLoad[i].SOC_NAME;
                            itmUpdate.ISWC_NO      = dataLoad[i].ISWC_NO;
                            itmUpdate.ISRC         = dataLoad[i].ISRC;
                            request.Items.Add(itmUpdate);
                        }
                        else
                        {
                            int a    = 1;
                            var item = request.Items.Where(p => p.WK_INT_NO == dataLoad[i].WK_INT_NO).FirstOrDefault();
                            writer = dataLoad[i].WRITER.Split(',');
                            //nhac
                            writer1 = dataLoad[i].WRITER2.Split(',');
                            //loi
                            writer2 = dataLoad[i].WRITER3.Split(',');

                            string role = string.Empty;
                            for (int k = 0; k < writer.Length; k++)
                            {
                                #region role
                                if (dataLoad[i].WRITER2.Length > 0 || dataLoad[i].WRITER3.Length > 0)
                                {
                                    //loi trong=> CA
                                    if (dataLoad[i].WRITER3.Length == 0)
                                    {
                                        role = "CA";
                                    }
                                    //nam trong loi
                                    else if (writer2.Contains(writer[k].Trim()))
                                    {
                                        role = "A";
                                    }
                                    else
                                    {
                                        //nhac
                                        role = "C";
                                    }
                                }
                                #endregion

                                if (item != null)
                                {
                                    #region tac gia
                                    if (!item.InterestedParties.Where(p => p.IP_INT_NO == dataLoad[i].WK_INT_NO).Any())
                                    {
                                        item.InterestedParties.Add(new Shared.Mis.Works.InterestedParty
                                        {
                                            No = item.InterestedParties.Count + 1,
                                            //cho nay co ma thi phai xu ly khac
                                            IP_INT_NO  = dataLoad[i].InternalNo,
                                            IP_NAME    = writer[k].Trim(),
                                            IP_WK_ROLE = dataLoad[i].WK_ROLE,

                                            //TODO 2020-10-02
                                            //WK_STATUS = dataLoad[i].STATUS,

                                            PER_OWN_SHR = dataLoad[i].PER_OWN_SHR,
                                            PER_COL_SHR = dataLoad[i].PER_OWN_SHR,

                                            MEC_OWN_SHR = dataLoad[i].MEC_COL_SHR,
                                            MEC_COL_SHR = dataLoad[i].MEC_COL_SHR,

                                            SP_SHR        = dataLoad[i].PER_OWN_SHR,
                                            TOTAL_MEC_SHR = dataLoad[i].MEC_COL_SHR,

                                            SYN_OWN_SHR = 0,
                                            SYN_COL_SHR = 0,
                                            //cho nay co ma, chac chan socity se khac
                                            Society       = dataLoad[i].Society,
                                            CountUpdate   = 1,
                                            LastUpdateAt  = DateTime.Now,
                                            LastChoiseAt  = DateTime.Now,
                                            IP_NUMBER     = dataLoad[i].IpNumber,
                                            IP_NAME_LOCAL = dataLoad[i].WRITER_LOCAL,
                                            IP_NAMETYPE   = dataLoad[i].IP_NAME_TYPE,
                                        });

                                        if (item.WRITER != string.Empty)
                                        {
                                            item.WRITER += ",";
                                        }
                                        item.WRITER += dataLoad[i].WRITER;
                                        if (item.WRITER_LOCAL != string.Empty)
                                        {
                                            item.WRITER_LOCAL += ",";
                                        }
                                        item.WRITER_LOCAL += dataLoad[i].WRITER_LOCAL;
                                    }
                                    else
                                    {
                                        //int a = 1;
                                    }
                                    #endregion

                                    #region Other title
                                    if ((item.TTL_ENG != dataLoad[i].TTL_ENG) && (!item.OtherTitles.Where(p => p.Title == dataLoad[i].TTL_ENG).Any()))
                                    {
                                        item.OtherTitles.Add(new Shared.Mis.Works.OtherTitle
                                        {
                                            No        = item.OtherTitles.Count + 1,
                                            Title     = dataLoad[i].TTL_ENG,
                                            TTL_LOCAL = dataLoad[i].TTL_LOCAL,
                                        });
                                    }
                                    else
                                    {
                                        //int a = 1;
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }

                    #region Update
                    if (request.Items.Count >= Core.LimitRequestUpdate || i == dataLoad.Count - 1)
                    {
                        UpdateStatusViewModelList reponse = null;
                        //request.Items
                        reponse = await controller.ChangeList(request);

                        if (reponse == null)
                        {
                            reponse = new UpdateStatusViewModelList
                            {
                                Items = new List <UpdateStatusViewModel>()
                            };
                        }
                        request.Items.Clear();
                        #region UI
                        statusMain.Invoke(new MethodInvoker(delegate
                        {
                            float values            = (float)(i + 1) / (float)dataLoad.Count * 100;
                            progressBarImport.Value = (int)values;
                            lbPercent.Text          = $"{((int)values).ToString()}%";
                        }));
                        totalSuccess += reponse.Items.Where(p => p.Status == Utilities.Common.UpdateStatus.Successfull).ToList().Count;
                        statusMain.Invoke(new MethodInvoker(delegate
                        {
                            lbOperation.Text = $"Sync..., total sync success/total: {totalSuccess}/{total}";
                        }));
                        #endregion
                    }
                    #endregion
                }
                #region update Ui when finish

                if (request.Items.Count > 0)
                {
                    //int a = 1;
                }
                btnSysToWork.Invoke(new MethodInvoker(delegate
                {
                    btnSysToWork.Enabled = true;
                }));
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    btnLoad.Enabled = true;
                }));
                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbInfo.Text  = $"sync tracking work to work be finish, total time {(DateTime.Now - TheFiestTime).TotalSeconds}(s)";
                    lbInfo.Text += $", total sync success/total: {totalSuccess}/{total}";
                }));

                statusMain.Invoke(new MethodInvoker(delegate
                {
                    lbOperation.Text = "Sync is finish";
                }));
                #endregion
            }
            catch (Exception)
            {
                if (statusMain != null && !statusMain.IsDisposed)
                {
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        btnLoad.Enabled = true;
                    }));
                }
                if (btnSysToWork != null && !btnSysToWork.IsDisposed)
                {
                    btnSysToWork.Invoke(new MethodInvoker(delegate
                    {
                        btnSysToWork.Enabled = true;
                    }));
                }
                if (lbOperation != null && !lbInfo.IsDisposed)
                {
                    statusMain.Invoke(new MethodInvoker(delegate
                    {
                        lbOperation.Text = $"Sync tracking work to work be failure";
                    }));
                }
            }
        }