Пример #1
0
        /// <summary>
        ///  读取部门岗位的Excel文件,并导入数据库,返回导入后的结果
        /// </summary>
        private void ImportOrgInfo()
        {
            string strMsg = string.Empty;

            try
            {
                RefreshUI(RefreshedTypes.ShowProgressBar);
                if (acbCompanyName.SelectedItem == null)
                {
                    tbFileName.Text = string.Empty;//不显示文件
                    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), Utility.GetResourceStr("SELECTCOMPANY"),
                                                   Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                    RefreshUI(RefreshedTypes.HideProgressBar);
                    return;
                }
                if (OpenFileDialog == null || OpenFileDialog.File == null)
                {
                    tbFileName.Text = string.Empty;//不显示文件
                    return;
                }
                Stream Stream = (System.IO.Stream)OpenFileDialog.File.OpenRead();

                byte[] Buffer = new byte[Stream.Length];
                Stream.Read(Buffer, 0, (int)Stream.Length);

                Stream.Dispose();
                Stream.Close();
                UploadFileModel UploadFile = new UploadFileModel();
                UploadFile.FileName = OpenFileDialog.File.Name;
                UploadFile.File     = Buffer;
                string companyID = (acbCompanyName.SelectedItem as T_HR_COMPANY).COMPANYID;
                Dictionary <string, string> empInfo = new Dictionary <string, string>();
                empInfo.Add("ownerID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID);
                empInfo.Add("ownerPostID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID);
                empInfo.Add("ownerDepartmentID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID);
                empInfo.Add("ownerCompanyID", SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
                client.ImportOrgInfoAsync(UploadFile, companyID, empInfo);
            }
            catch (Exception ex)
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), ex.ToString(), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                RefreshUI(RefreshedTypes.HideProgressBar);
            }
        }