Exemplo n.º 1
0
        public ActionResult ExportFile(string selectedColumns, string className)//
        {
            var removeColumns = selectedColumns.Split(',').ToList();


            switch (className)
            {
            case "Member":
                return(this.File(m_export.Export(removeColumns).ToArray(), "application/vnd.ms-excel", className + ".xlsx"));

            case "Infor":
                return(this.File(i_export.Export(removeColumns).ToArray(), "application/vnd.ms-excel", className + ".xlsx"));

            case "LogRecord":
                return(this.File(l_export.Export(removeColumns).ToArray(), "application/vnd.ms-excel", className + ".xlsx"));

            case "Feature":
                return(this.File(f_export.Export(removeColumns).ToArray(), "application/vnd.ms-excel", className + ".xlsx"));

            default:
                return(Content("<script>history.back()</scrpit>"));
            }
            /**/
        }

        /**/
    }
        public void Exports_With_User_Defined_KeyValues_When_Available()
        {
            var service = new ExportService() as IExportService;
            var product = new Product {
                Id = Guid.NewGuid(), Name = "My Product",
            };
            var license = new License
            {
                LicenseType    = LicenseType.Standard,
                OwnerName      = "License Owner",
                ExpirationDate = null,
            };

            license.Data.Add(new UserData {
                Key = "KeyOne", Value = "ValueOne"
            });
            license.Data.Add(new UserData {
                Key = "KeyTwo", Value = "ValueTwo"
            });

            var path = Path.GetTempFileName();
            var file = new FileInfo(path);

            service.Export(product, license, file);

            var reader  = file.OpenText();
            var content = reader.ReadToEnd();

            Assert.NotNull(content);
            Assert.Contains("KeyOne=\"ValueOne\"", content);
            Assert.Contains("KeyTwo=\"ValueTwo\"", content);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            if (!new CliParser().Parse(args, out var product, out var license))
            {
                return;
            }

            var exportService = new ExportService();

            try
            {
                Console.WriteLine(exportService.Export(product, license));
            }
            catch (Exception e)
            {
                if (e is System.Security.Cryptography.CryptographicException)
                {
                    Console.WriteLine("The key is not complete\n" +
                                      "\tMaybe the public key was provided!");
                }
                else if (e is System.Xml.XmlException)
                {
                    Console.WriteLine("The key is not a valid RSA xml key!");
                }
                else
                {
                    Console.WriteLine($"Unknown error\nError message:\n{e.Message}");
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            AskInformation(ref appId, "Please provide your application id or EXIT:");
            AskInformation(ref appKey, "Please provide your application key or EXIT:");
            AskInformation(ref appVersion, "Please provide your app version or EXIT:");
            AskInformation(ref filePath, "Please provide your csv file path or EXIT:");

            var exportService = new ExportService(appId, appKey, appVersion);

            var data = exportService.Export().Result;

            var sb = new StringBuilder();

            sb.AppendLine("intent;utterance");

            data.ForEach(item =>
            {
                sb.AppendLine($"{item.Item1};{item.Item2}".Replace("\n", ""));
            });

            using (var writer = new StreamWriter(filePath, false, Encoding.UTF8))
            {
                writer.Write(sb.ToString());
            }

            System.Console.WriteLine($"{data.Count} lines wrote in {filePath}");
            System.Console.ReadLine();
        }
Exemplo n.º 5
0
        public ActionResult ExportAllAndReturn <TEntity, TModel, TModelSearch>([DataSourceRequest] DataSourceRequest request, TModelSearch model, string storeName) where TEntity : class
        {
            model.SetPropertyValue("IsExport", true);
            string fullPath = string.Empty, status = string.Empty;
            var    listModel = GetListData <TModel, TEntity, TModelSearch>(request, model, storeName, ref status);

            if (status == NotificationType.Success.ToString())
            {
                status = ExportService.Export(listModel, model.GetPropertyValue("ValueFields").TryGetValue <string>().Split(','));
            }
            return(Json(status));
        }
Exemplo n.º 6
0
        public ActionResult ExportLaudryRecordList([DataSourceRequest] DataSourceRequest request, Lau_LaundryRecordSearchNewModel model)
        {
            var listModel = GetListData <Lau_LaundryRecordModel, LMS_LaundryRecordEntity, Lau_LaundryRecordSearchNewModel>(request, model, ConstantSql.hrm_lau_sp_get_LaundryRecord, ref status);
            Dictionary <string, string> formatFields = new Dictionary <string, string>();

            formatFields.Add(Lau_LaundryRecordModel.FieldNames.TimeLog, ConstantFormat.HRM_Format_DayMonthYear);
            formatFields.Add(Lau_LaundryRecordModel.FieldNames.Hour, ConstantFormat.HRM_Format_Grid_ShortTime);
            formatFields.Add(Lau_LaundryRecordModel.FieldNames.Amount, ConstantFormat.HRM_Format_Money);
            status = ExportService.Export(listModel, model.GetPropertyValue("ValueFields").TryGetValue <string>().Split(','), formatFields);
            return(Json(status));
            //return ExportAllAndReturn<Lau_LaundryRecordEntity, Lau_LaundryRecordModel, Lau_LaundryRecordSearchNewModel>(request, model, ConstantSql.hrm_lau_sp_get_LaundryRecord);
        }
Exemplo n.º 7
0
        /// <summary>
        /// [Tam.Le] - Xuất các dòng dữ liệu được chọn của LaudryRecord ra file Excel
        /// </summary>
        /// <param name="selectedIds"></param>
        /// <param name="valueFields"></param>
        /// <returns></returns>
        public ActionResult ExportLaudryRecordSelected(string selectedIds, string valueFields)
        {
            selectedIds = Common.DotNetToOracle(selectedIds);
            var listModel = GetData <Lau_LaundryRecordModel, LMS_LaundryRecordEntity>(selectedIds, ConstantSql.hrm_lau_sp_get_LaundryRecord_ByIds);
            Dictionary <string, string> formatFields = new Dictionary <string, string>();

            formatFields.Add(Lau_LaundryRecordModel.FieldNames.TimeLog, ConstantFormat.HRM_Format_DayMonthYear);
            formatFields.Add(Lau_LaundryRecordModel.FieldNames.Hour, ConstantFormat.HRM_Format_Grid_ShortTime);
            formatFields.Add(Lau_LaundryRecordModel.FieldNames.Amount, ConstantFormat.HRM_Format_Money);
            status = ExportService.Export(listModel, valueFields.Split(','), formatFields);
            return(Json(status));
            // return ExportSelectedAndReturn<Lau_LaundryRecordEntity, Lau_LaundryRecordModel>(selectedIds, valueFields, ConstantSql.hrm_lau_sp_get_LaundryRecord_ByIds);
        }
Exemplo n.º 8
0
        /// <summary>
        /// [Chuc.Nguyen] - Xuất các dòng dữ liệu được chọn của một đối tượng bất kỳ ra file Excel
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="selectedIds"></param>
        /// <param name="valueFields"></param>
        /// <param name="storeName"></param>
        /// <returns></returns>
        public ActionResult ExportSelectedAndReturn <TEntity, TModel>(Guid templateID, string selectedIds, string valueFields, string storeName) where TEntity : class
        {
            selectedIds = Common.DotNetToOracle(selectedIds);
            var service    = new BaseService();
            var status     = string.Empty;
            var listModel  = new List <TModel>();
            var listEntity = service.GetData <TEntity>(selectedIds, storeName, UserLogin, ref status);

            if (listEntity != null && status == NotificationType.Success.ToString())
            {
                listModel = listEntity.Translate <TModel>();
                status    = ExportService.Export(templateID, listModel, valueFields.Split(','), null);
            }
            return(Json(status));
        }
Exemplo n.º 9
0
 public async Task <IHttpActionResult> Export(int competitionId, int phaseId, [FromBody] string fileName)
 {
     try
     {
         using (var exportService = new ExportService())
         {
             exportService.Export(competitionId, phaseId, fileName);
             return(Ok());
         }
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
 private void SavePDF(object parameter)
 {
     try
     {
         SaveFileDialog openFileDialog = new SaveFileDialog();
         openFileDialog.FileName = "Mystery";
         openFileDialog.Filter   = "Pdf Files|*.pdf";
         if (openFileDialog.ShowDialog() == true)
         {
             ExportService.Export(Mystery, openFileDialog.FileName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Fehler beim Speichern", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 11
0
        public JsonResult MakeCsv()
        {
            try
            {
                if (!Security.CanExport(User.Identity.Name))
                {
                    return(Json(new { error = true, message = "You do not have permission for this action." }));
                }

                using (var export = new ExportService(_data))
                {
                    var success = export.Export();
                    return(Json(new { error = !success, message = success ? "Export Successfull" : "Export Failed" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { error = true, message = ex.Message }));
            }
        }
        public void Exports_With_MaxDate_If_No_Expiration_Date_Is_Set()
        {
            var service = new ExportService() as IExportService;
            var product = new Product {
                Id = Guid.NewGuid(), Name = "My Product",
            };
            var license = new License {
                ID = Guid.NewGuid(), LicenseType = LicenseType.Standard, OwnerName = "License Owner", ExpirationDate = null
            };
            var path = Path.GetTempFileName();
            var file = new FileInfo(path);

            service.Export(product, license, file);

            var reader  = file.OpenText();
            var content = reader.ReadToEnd();

            Assert.NotNull(content);
            Assert.Contains("expiration=\"9999-12-31T23:59:59.9999999\"", content);
        }
        public void Exports_LicenseInfo_To_File()
        {
            var service = new ExportService() as IExportService;
            var product = new Product {
                Id = Guid.NewGuid()
            };
            var license = new License {
                ID = Guid.NewGuid(), LicenseType = LicenseType.Standard, OwnerName = "License Owner", ExpirationDate = new DateTime(2020, 1, 1)
            };
            var path = Path.GetTempFileName();
            var file = new FileInfo(path);

            service.Export(product, license, file);

            var reader  = file.OpenText();
            var content = reader.ReadToEnd();

            Assert.NotNull(content);
            Assert.Contains("<name>License Owner</name>", content);
            Assert.Contains("type=\"Standard\"", content);
            Assert.Contains("expiration=\"2020-01-01T00:00:00.0000000\"", content);
        }
Exemplo n.º 14
0
        public ActionResult ExportHistoryApproveECLAIMByTemplate([DataSourceRequest] DataSourceRequest request, FIN_HistoryApproveECLAIMSearchModel model)
        {
            string         status      = string.Empty;
            var            baseService = new BaseService();
            var            isDataTable = false;
            object         obj         = new FIN_HistoryApproveECLAIMModel();
            ListQueryModel lstModel    = new ListQueryModel
            {
                PageSize       = int.MaxValue - 1,
                PageIndex      = 1,
                Filters        = ExtractFilterAttributes(request),
                Sorts          = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            var result = baseService.GetData <FIN_HistoryApproveECLAIMModel>(lstModel, ConstantSql.hrm_hr_sp_get_HistoryApprovedClaim, UserLogin, ref status);

            if (model != null && model.IsCreateTemplate)
            {
                var           path          = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object       = new FIN_HistoryApproveECLAIMModel(),
                    FileName     = "FIN_HistoryApproveECLAIM",
                    OutPutPath   = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable  = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return(Json(str));
            }
            if (model.ExportId != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                return(Json(fullPath));
            }
            return(Json(result.ToDataSourceResult(request)));
        }
Exemplo n.º 15
0
        public ActionResult GetClaimApprovedList([DataSourceRequest] DataSourceRequest request, FIN_ApprovedClaimSearchModel model)
        {
            var baseService          = new BaseService();
            FIN_ClaimService service = new FIN_ClaimService();

            var result = service.GetClaimApprovedList(model.UserApproveID.Value);


            if (model.IsExport)
            {
                var fullPath = ExportService.Export(result, model.ValueFields.Split(','));
                return(Json(fullPath));
            }

            request.Page = 1;
            var dataSourceResult = result.ToDataSourceResult(request);

            dataSourceResult.Total = result.Count() <= 0 ? 0 : result.FirstOrDefault().TotalRow;
            return(new JsonResult {
                Data = dataSourceResult, MaxJsonLength = Int32.MaxValue
            });
        }
        public void ExportTest()
        {
            string tmpFilename = Path.GetTempFileName();

            MysteryCreator mysteryCreator = new MysteryCreator();

            mysteryCreator.NumberOfColumns = 7;
            mysteryCreator.NumberOfRows    = 7;
            mysteryCreator.NumberOfShips   = 12;
            Mystery mystery = mysteryCreator.Create();

            ExportService.Export(mystery, tmpFilename);

            if (File.Exists(tmpFilename))
            {
                Assert.IsTrue(true);
                File.Delete(tmpFilename);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Exemplo n.º 17
0
 private void DoExport()
 {
     exportService.Export(new List <ResultDicomFile>(MatchedFileList));
 }
Exemplo n.º 18
0
        private void Export(object obj)
        {
            SortedListsOfImagesNames imagesCollectionType = (SortedListsOfImagesNames)obj;
            ExportService            exportService        = ExportServiceFactory.GetExportService(ExportTypes.ExportToZip);

            switch (imagesCollectionType)
            {
            case SortedListsOfImagesNames.BeachesSeaside:
                exportService.Export(BeachesSeaside, imagesCollectionType.ToString());
                BeachesSeaside.Clear();
                break;

            case SortedListsOfImagesNames.CarsVehicles:
                exportService.Export(CarsVehicles, imagesCollectionType.ToString());
                CarsVehicles.Clear();
                break;

            case SortedListsOfImagesNames.EventsParties:
                exportService.Export(EventsParties, imagesCollectionType.ToString());
                EventsParties.Clear();
                break;

            case SortedListsOfImagesNames.FoodDrinks:
                exportService.Export(FoodDrinks, imagesCollectionType.ToString());
                FoodDrinks.Clear();
                break;

            case SortedListsOfImagesNames.InteriorObjects:
                exportService.Export(InteriorObjects, imagesCollectionType.ToString());
                InteriorObjects.Clear();
                break;

            case SortedListsOfImagesNames.MacroFlowers:
                exportService.Export(MacroFlowers, imagesCollectionType.ToString());
                MacroFlowers.Clear();
                break;

            case SortedListsOfImagesNames.NatureLandscape:
                exportService.Export(NatureLandscape, imagesCollectionType.ToString());
                NatureLandscape.Clear();
                break;

            case SortedListsOfImagesNames.PaintingsArt:
                exportService.Export(PaintingsArt, imagesCollectionType.ToString());
                PaintingsArt.Clear();
                break;

            case SortedListsOfImagesNames.PeoplePortraits:
                exportService.Export(PeoplePortraits, imagesCollectionType.ToString());
                PeoplePortraits.Clear();
                break;

            case SortedListsOfImagesNames.PetsAnimals:
                exportService.Export(PetsAnimals, imagesCollectionType.ToString());
                PetsAnimals.Clear();
                break;

            case SortedListsOfImagesNames.StreetviewArchitecture:
                exportService.Export(StreetviewArchitecture, imagesCollectionType.ToString());
                StreetviewArchitecture.Clear();
                break;

            case SortedListsOfImagesNames.SunrisesSunsets:
                exportService.Export(SunrisesSunsets, imagesCollectionType.ToString());
                SunrisesSunsets.Clear();
                break;

            case SortedListsOfImagesNames.TextVisuals:
                exportService.Export(TextVisuals, imagesCollectionType.ToString());
                TextVisuals.Clear();
                break;

            default:
                throw new NoSuchCategoryException("There is no such images category! Contact the application manufacturer!");
            }
        }
Exemplo n.º 19
0
 public void ExportJpg(InkCanvas canvas)
 {
     ExportService.Export(canvas, ImageFormat.Jpeg);
 }
Exemplo n.º 20
0
 public void ExportPng(InkCanvas canvas)
 {
     ExportService.Export(canvas, ImageFormat.Png);
 }
Exemplo n.º 21
0
        /// <summary>
        /// [Hieu.Van] Tồng hợp dữ liệu ăn
        /// </summary>
        /// <param name="request"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        //[HttpPost]
        public ActionResult GetLaundryRecordSummary([DataSourceRequest] DataSourceRequest request, Lau_LaundryRecordSearchModel model)
        {
            Lau_LaundryRecordServices LauService = new Lau_LaundryRecordServices();
            var baseService    = new BaseService();
            var Actionservices = new ActionService(UserLogin);

            #region xử lý dateStart - dateEnd
            DateTime dateStart = DateTime.Now;
            DateTime dateEnd   = DateTime.Now;
            if (model.DateFrom != null)
            {
                dateStart = model.DateFrom.Value;
            }
            if (model.DateTo != null)
            {
                dateEnd = model.DateTo.Value;
            }
            #endregion

            #region xử lý lấy lstProfileIds theo OrgStructureID
            List <Hre_ProfileEntity> lstProfileIDs = new List <Hre_ProfileEntity>();
            string        status = string.Empty;
            List <object> lstObj = new List <object>();
            lstObj.Add(model.OrgStructureID);
            lstObj.Add(null);
            lstObj.Add(null);
            List <Hre_ProfileEntity> _temp       = new List <Hre_ProfileEntity>();
            Hre_ProfileEntity        t           = new Hre_ProfileEntity();
            List <Hre_ProfileEntity> _profileIDs = new List <Hre_ProfileEntity>();
            var baseServices = new ActionService(UserLogin);
            if (model.ProfileIDs != null)
            {
                var lst = model.ProfileIDs.Split(',');
                foreach (var item in lst)
                {
                    t = new Hre_ProfileEntity();
                    Guid _Id = new Guid(item);
                    t.ID = _Id;
                    _temp.Add(t);
                }



                if (model.OrgStructureID != null)
                {
                    lstProfileIDs = Actionservices.GetData <Hre_ProfileEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).ToList();
                    _profileIDs   = lstProfileIDs.Where(m => !_temp.Contains(m)).ToList();
                    lstProfileIDs.AddRange(_profileIDs);
                }
                else
                {
                    lstProfileIDs = _temp;
                }
            }
            else
            {
                lstProfileIDs = Actionservices.GetData <Hre_ProfileEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).ToList();
            }
            #endregion

            // Hàm xử lý tổng hợp
            var result = LauService.GetLaundryRecordSummary(model.LineID, model.LockerID, model.MarkerID, dateStart, dateEnd, lstProfileIDs, UserLogin).ToList().Translate <Lau_LaundryRecordModel>();
            if (result != null)
            {
                var submit = ConstantDisplay.HRM_Enum_Submit.TranslateString();
                var auto   = ConstantDisplay.HRM_Enum_Auto.TranslateString();
                result.Where(s => s.Status == LaundryRecordStatus.E_SUBMIT.ToString()).Select(s => s.Status = submit).ToList();
                result.Where(s => s.Type == LaundryRecordType.E_AUTO.ToString()).Select(s => s.Type         = auto).ToList();
            }
            #region xử lý xuất áo cáo
            if (model.IsExport)
            {
                var fullPath = ExportService.Export(result, model.ValueFields.Split(','));
                return(Json(fullPath));
            }

            if (model.selectedIDs != null)
            {
                var         strSelect = model.selectedIDs.Split(',');
                List <Guid> lstSelect = new List <Guid>();
                foreach (var item in strSelect)
                {
                    lstSelect.Add(new Guid(item));
                }
                var resultSelect = result.Where(m => lstSelect.Contains(m.ID)).ToList();
                var fullPath     = ExportService.Export(resultSelect, model.ValueFields.Split(','));
                return(Json(fullPath));
            }
            #endregion

            request.Page = 1;
            var dataSourceResult = result.ToDataSourceResult(request);
            //dataSourceResult.Total = result.Count() <= 0 ? 0 : result.FirstOrDefault().TotalRow;
            return(Json(result.ToDataSourceResult(request)));
        }
Exemplo n.º 22
0
        /// <summary>
        /// HieuVan
        /// Hàm xử lý tự động send mail hợp đồng đến hạn
        /// </summary>
        public static void SendMailContract()
        {
            BaseService _base    = new BaseService();
            string      status   = string.Empty;
            string      fullPath = string.Empty;
            List <Hre_ContractSendMailEntity> lstProbation = new List <Hre_ContractSendMailEntity>();
            List <Hre_ContractEntity>         lstAttach    = new List <Hre_ContractEntity>();
            Hre_ContractEntity attach = new Hre_ContractEntity();
            DateTime           DS     = DateTime.Now;
            DateTime           DE     = DateTime.Now;

            List <object> lstParam = new List <object>();

            lstParam.AddRange(new object[3]);
            var dataProfile = _base.GetData <Hre_ProfileEntity>(lstParam, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, string.Empty, ref status);

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork               = (IUnitOfWork)(new UnitOfWork(context));
                var repoHre_Contract         = new CustomBaseRepository <Hre_Contract>(unitOfWork);
                var repoCat_ContractType     = new CustomBaseRepository <Cat_ContractType>(unitOfWork);
                var repoCat_Export           = new CustomBaseRepository <Cat_Export>(unitOfWork);
                var repoCat_OrgStructure     = new CustomBaseRepository <Cat_OrgStructure>(unitOfWork);
                var repoCat_OrgStructureType = new CustomBaseRepository <Cat_OrgStructureType>(unitOfWork);
                var repoSys_TemplateSendMail = new CustomBaseRepository <Sys_TemplateSendMail>(unitOfWork);

                string _typeTemplate = EnumDropDown.EmailType.E_WARNINGCONTRACT.ToString();
                var    template      = repoSys_TemplateSendMail.FindBy(s => s.Type == _typeTemplate).FirstOrDefault();
                if (template == null)
                {
                    return;
                }

                var dataContractType     = repoCat_ContractType.FindBy(s => s.ID != null).ToList();
                var dataContract         = repoHre_Contract.FindBy(s => s.IsDelete == null).ToList();
                var dataOrgStructure     = repoCat_OrgStructure.FindBy(s => s.IsDelete == null).ToList();
                var dataOrgStructureType = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList();

                // lọc từng hợp đồng, kiểm tra những hợp đồng nào đến hạn
                Hre_ContractSendMailEntity entity = new Hre_ContractSendMailEntity();
                List <string> lstTemp             = new List <string>();
                foreach (var item in dataContract)
                {
                    lstTemp = new List <string>();
                    entity  = new Hre_ContractSendMailEntity();
                    if (item.DateEnd == null)
                    {
                        continue;
                    }
                    var contractType = dataContractType.Where(s => s.ID == item.ContractTypeID).FirstOrDefault();
                    int loop         = contractType.ExpiryContractLoop != null ? contractType.ExpiryContractLoop.Value : 0;
                    int dbd          = contractType.ExpiryContractDayByDay != null ? contractType.ExpiryContractDayByDay.Value : 0;

                    DateTime loopStart = DateTime.Now.AddDays(loop);
                    DateTime dbdStart  = DateTime.Now.AddDays(dbd);

                    if ((dbdStart >= item.DateEnd.Value || item.DateEnd.Value <= DateTime.Now) && item.ContractResult == null)
                    {
                        attach = item.Copy <Hre_ContractEntity>();
                        var profile = dataProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();
                        entity.ContractID  = item.ID;
                        entity.DayDue      = item.DateEnd;
                        entity.ProfileName = profile.ProfileName;
                        attach.ProfileName = profile.ProfileName;
                        attach.CodeEmp     = profile.CodeEmp;
                        entity.Type        = EnumDropDown.ExpiredContractType.E_DayByDay.ToString();
                        if (contractType.EmailToList != null)
                        {
                            var lstCodeOrg = contractType.EmailToList.Split(',').ToList();
                            foreach (var itemCO in lstCodeOrg)
                            {
                                var temp = LibraryService.GetNearestParent(profile.OrgStructureID, (OrgUnit)Enum.Parse(typeof(OrgUnit), itemCO, true), dataOrgStructure, dataOrgStructureType);
                                if (temp == null || temp.Email == null)
                                {
                                    continue;
                                }
                                var mailOfOrg = temp.Email.Split(',').ToList();
                                lstTemp.AddRange(mailOfOrg);
                            }
                        }
                        if (!string.IsNullOrEmpty(contractType.EmailOther))
                        {
                            var lstEmailOther = contractType.EmailOther.Split(',').ToList();
                            lstTemp.AddRange(lstEmailOther);
                        }
                        if (lstTemp != null)
                        {
                            entity.lstEmail = lstTemp;
                        }
                        lstAttach.Add(attach);
                        lstProbation.Add(entity);
                    }
                    else if ((loopStart >= item.DateEnd.Value || item.DateEnd.Value <= DateTime.Now) && item.ContractResult == null)
                    {
                        attach = item.Copy <Hre_ContractEntity>();
                        if (DateTime.Now.Day != contractType.DayInMonthLoop1 && DateTime.Now.Day != contractType.DayInMonthLoop2 && DateTime.Now.Day != contractType.DayInMonthLoop3)
                        {
                            continue;
                        }
                        var profile = dataProfile.Where(s => s.ID == item.ProfileID).FirstOrDefault();
                        entity.ContractID  = item.ID;
                        entity.DayDue      = item.DateEnd;
                        entity.ProfileName = profile.ProfileName;
                        attach.ProfileName = profile.ProfileName;
                        attach.CodeEmp     = profile.CodeEmp;
                        entity.Type        = EnumDropDown.ExpiredContractType.E_Loop.ToString();
                        if (contractType.EmailToList != null)
                        {
                            var lstCodeOrg = contractType.EmailToList.Split(',').ToList();
                            foreach (var itemCO in lstCodeOrg)
                            {
                                var temp = LibraryService.GetNearestParent(profile.OrgStructureID, (OrgUnit)Enum.Parse(typeof(OrgUnit), itemCO, true), dataOrgStructure, dataOrgStructureType);
                                if (temp == null || temp.Email == null)
                                {
                                    continue;
                                }
                                var mailOfOrg = temp.Email.Split(',').ToList();
                                lstTemp.AddRange(mailOfOrg);
                            }
                        }
                        if (!string.IsNullOrEmpty(contractType.EmailOther))
                        {
                            var lstEmailOther = contractType.EmailOther.Split(',').ToList();
                            lstTemp.AddRange(lstEmailOther);
                        }
                        if (lstTemp != null)
                        {
                            entity.lstEmail = lstTemp;
                        }
                        lstAttach.Add(attach);
                        lstProbation.Add(entity);
                    }
                }

                if (lstAttach.Count > 0)
                {
                    var lstExport = repoCat_Export.FindBy(s => s.IsDelete == null && s.ScreenName == EnumDropDown.EmailType.E_WARNINGCONTRACT.ToString()).ToList();
                    if (lstExport.Count > 0)
                    {
                        var export = lstExport.FirstOrDefault();
                        fullPath = ExportService.Export(export.ID, lstAttach, null, ExportFileType.Excel);
                    }
                }

                List <Hre_ContractBodyEntity> lstSM = new List <Hre_ContractBodyEntity>();
                Hre_ContractBodyEntity        SM    = new Hre_ContractBodyEntity();
                List <Guid> lstGC = new List <Guid>();
                foreach (var item in lstProbation)
                {
                    string _type = "Theo Chu Kỳ";
                    if (item.Type == EnumDropDown.ExpiredContractType.E_DayByDay.ToString())
                    {
                        _type = "Hàng Ngày";
                    }
                    if (item.lstEmail == null)
                    {
                        continue;
                    }
                    string value = "<tr><td> " + item.ProfileName + " </td><td> " + item.DayDue + "</td><td> " + _type + "</td></tr>";

                    foreach (var email in item.lstEmail)
                    {
                        lstGC = new List <Guid>();
                        SM    = new Hre_ContractBodyEntity();
                        var exits = lstSM.Where(m => m.Email == email).FirstOrDefault();
                        if (exits != null && !exits.lstGContract.Contains(item.ContractID))
                        {
                            if (SM.lstGContract != null)
                            {
                                lstGC = SM.lstGContract;
                            }

                            lstGC.Add(item.ContractID);
                            exits.lstGContract = lstGC;
                            exits.Body        += value;
                        }
                        else if (exits == null || !exits.lstGContract.Contains(item.ContractID))
                        {
                            if (SM.lstGContract != null)
                            {
                                lstGC = SM.lstGContract;
                            }

                            lstGC.Add(item.ContractID);
                            SM.lstGContract = lstGC;
                            SM.Email        = email;
                            SM.Body         = value;
                            lstSM.Add(SM);
                        }
                    }
                }

                foreach (var item in lstSM)
                {
                    string title = template.Subject;
                    var    name  = item.Email.Split('@');


                    #region magreData

                    string[] strsParaKey    = null;
                    string[] strsParaValues = null;
                    strsParaKey = new string[]
                    {
                        EnumDropDown.EmailType_WARNINGCONTRACT.E_PROFILENAME.ToString(),
                            EnumDropDown.EmailType_WARNINGCONTRACT.E_TABLECONTENT.ToString(),
                    };
                    strsParaValues = new string[]
                    {
                        name[0].ToString(),
                        item.Body
                    };
                    string body = LibraryService.ReplaceContentFile(template.Content, strsParaKey, strsParaValues);

                    #endregion

                    //string body = "<html><head><title></title></head><body class='scayt-enabled'>Dear " + name[0].ToString() + " ,<br /><br />"
                    //    + "This is email warning about contract probation:<br /> <br /><table border='1' cellpadding='1' cellspacing='1' style='width: 500px;'>"
                    //    + "<tr><td> Nhân Viên </td><td> Ngày Hết Hạn </td><td> Loại Hết Hạn </td></tr>"
                    //    + item.Body
                    //    + "</tbody></table><tbody>"
                    //    + "</body></html>";

                    _base.SendMail(title, item.Email, body, fullPath);
                }
            }
        }
Exemplo n.º 23
0
        public ActionResult GetReportEmpDetail([DataSourceRequest] DataSourceRequest request, Lau_ReportSearchModel model)
        {
            Lau_ReportServices service     = new Lau_ReportServices();
            BaseService        baseService = new BaseService();
            var  Actionservices            = new ActionService(UserLogin);
            bool isIncludeQuitEmp          = model.isIncludeQuitEmp ? true : false;

            #region xử lý dateStart - dateEnd
            DateTime dateStart = DateTime.Now;
            DateTime dateEnd   = DateTime.Now;
            if (model.DateFrom != null)
            {
                dateStart = model.DateFrom.Value;
            }
            if (model.DateTo != null)
            {
                dateEnd = model.DateTo.Value;
            }
            #endregion

            #region xử lý line - locker - marker

            List <Guid?> lstLine   = new List <Guid?>();
            List <Guid?> lstLocker = new List <Guid?>();
            List <Guid?> lstMarker = new List <Guid?>();
            if (model.LineID != null)
            {
                foreach (var line in model.LineID.Split(','))
                {
                    lstLine.Add(new Guid(line));
                }
            }
            if (model.LockerID != null)
            {
                foreach (var locker in model.LockerID.Split(','))
                {
                    lstLocker.Add(new Guid(locker));
                }
            }
            if (model.MarkerID != null)
            {
                foreach (var marker in model.MarkerID.Split(','))
                {
                    lstMarker.Add(new Guid(marker));
                }
            }

            #endregion

            #region xử lý lấy lstProfileIds theo OrgStructureID
            List <Guid>   lstProfileIDs = new List <Guid>();
            string        status        = string.Empty;
            List <object> lstObj        = new List <object>();
            lstObj.Add(model.OrgStructureID);
            lstObj.Add(null);
            lstObj.Add(null);
            List <Guid> _temp       = new List <Guid>();
            List <Guid> _profileIDs = new List <Guid>();

            if (model.ProfileIDs != null)
            {
                var lst = model.ProfileIDs.Split(',');
                foreach (var item in lst)
                {
                    Guid _Id = new Guid(item);
                    _temp.Add(_Id);
                }

                //_temp = lst.Select(int.Parse).ToList();

                if (model.OrgStructureID != null)
                {
                    lstProfileIDs = Actionservices.GetData <Hre_ProfileIdEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).Select(m => m.ID).ToList();
                    _profileIDs   = lstProfileIDs.Where(m => !_temp.Contains(m)).ToList();
                    lstProfileIDs.AddRange(_profileIDs);
                }
                else
                {
                    lstProfileIDs = _temp;
                }
            }
            else
            {
                lstProfileIDs = Actionservices.GetData <Hre_ProfileIdEntity>(lstObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).Select(m => m.ID).ToList();
            }
            #endregion

            var result = service.GetReportEmpDetail(lstLine, lstLocker, lstMarker, lstProfileIDs, dateStart, dateEnd, isIncludeQuitEmp, model.CodeEmp, UserLogin);
            var rs     = result.Translate <Lau_ReportEmpDetailModel>();

            #region xử lý xuất báo cáo

            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, rs);
                return(Json(fullPath));
            }

            #endregion

            var dataSourceResult = result.ToDataSourceResult(request);
            return(Json(rs.ToDataSourceResult(request)));
        }
Exemplo n.º 24
0
        private static int Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture   = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

            var app = new CommandLineApplication();

            app.HelpOption("-h | --help");

            app.Command("template", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Create mapping file template from the Source Tenant model.";

                var tenantOption           = command.Option("-t | --tenant", "Export template tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Export template connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new TemplateService(tenantOption.Value(), connectionStringOption.Value());
                    service.GenerateTemplate().GetAwaiter().GetResult();
                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("export", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export data from source system.";

                var tenantOption           = command.Option("-t | --tenant", "Tenant to export", CommandOptionType.SingleValue);
                var mappingOption          = command.Option("-m | --mapping", "Mapping file", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var tenant       = tenantOption.Value();
                    var jsonSettings = new JsonSerializerSettings {
                        ContractResolver = new CamelCasePropertyNamesContractResolver()
                    };
                    var mappings        = JsonConvert.DeserializeObject <List <EntityMapDefinition> >(File.ReadAllText(mappingOption.Value()), jsonSettings);
                    var seriesProcessor = new SeriesProcessor(mappings, tenant, jsonSettings, _correlationId, _eventMetadata);
                    var service         = new ExportService(tenant, connectionStringOption.Value(), _correlationId, _eventMetadata, mappings, seriesProcessor, jsonSettings);
                    service.Export().GetAwaiter().GetResult();
                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("import", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Import data to destination system.";

                var folderOption           = command.Option("-f | --folder", "Import folder path", CommandOptionType.SingleValue);
                var tenantOption           = command.Option("-t | --tenant", "Import to tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ImportService(folderOption.Value(), tenantOption.Value(), connectionStringOption.Value());
                    service.Import().GetAwaiter().GetResult();
                    Console.WriteLine("Import finished successfully.");
                    Console.ReadKey();
                    return(0);
                });
            });


            app.Command("export-files", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export files from source system.";

                var tenantOption           = command.Option("-t | --tenant", "Tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Blob storage Connection string", CommandOptionType.SingleValue);
                var encryptionKeyOption    = command.Option("-ek | --encryption-key", "Export storage Encryption Key", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ExportBlobsService(tenantOption.Value(), connectionStringOption.Value(), encryptionKeyOption.Value());
                    service.Export().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("export-users", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export users data from source system.";

                var tenantOption           = command.Option("-t | --tenant", "Tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ExportUsersService(tenantOption.Value(), connectionStringOption.Value());
                    service.Export().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("import-users", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Import users data from source system.";

                var folderOption       = command.Option("-f | --folder", "Import folder path", CommandOptionType.SingleValue);
                var tenantOption       = command.Option("-t | --tenant", "Import to tenant", CommandOptionType.SingleValue);
                var apiAddressOption   = command.Option("-e | --endpoint", "Import API endpoint", CommandOptionType.SingleValue);
                var clientIdOption     = command.Option("-ci | --client-id", "API Client's ID", CommandOptionType.SingleValue);
                var clientSecretOption = command.Option("-cs | --client-secret ", "API Client's Secret", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ImportUsersService(folderOption.Value(), tenantOption.Value(), apiAddressOption.Value(), clientIdOption.Value(), clientSecretOption.Value());
                    service.Import().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("import-files", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export files from source system.";

                var mappingsFolderOption   = command.Option("-m | --mappings", "Mappings folder where the file_mapping.csv was stored", CommandOptionType.SingleValue);
                var filesFolderOption      = command.Option("-f | --folder", "Files folder", CommandOptionType.SingleValue);
                var tenantOption           = command.Option("-t | --tenant", "Import to tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Blob storage connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ImportBlobsService(mappingsFolderOption.Value(), filesFolderOption.Value(), tenantOption.Value(), connectionStringOption.Value());
                    service.Import().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });



            return(app.Execute(args));
        }