public override void Resolve(Q.Query <Displayable> query) { //ClaimsPrincipalDto.AddMarker("kpi.SearchQueryResolver.begin"); //if (!string.IsNullOrEmpty(query.DataQueryToken)) //{ // //NamedQueryFactory.Resolve(query); // return; //} var builder = new SearchQueryBuilder(query); var queryContainer = builder.GetQueryFor <Displayable>(query); var results = ElasticSearch.Search <ElasticTitleIndex>(queryContainer); //ClaimsPrincipalDto.Add("kpi.query", Encoding.UTF8.GetString(results.RequestInformation.Request)); query.Items = new List <Displayable>(); if (results.IsValid && results.Hits.Any()) { foreach (var displayable in results.Documents.Select(item => item.MapToDisplayable())) { query.Items.Add(displayable); } ExtractFilter(query, results); query.ResultSetCount = int.Parse(results.Total.ToString(CultureInfo.InvariantCulture)); } // ClaimsPrincipalDto.AddMarker("kpi.SearchQueryResolver.end"); }
public BulkElasticSuggestiveIndex Post(BulkElasticSuggestiveIndex t) { const int batchCount = 2000; var timerStopwatch = new Stopwatch(); timerStopwatch.Start(); var i = 0; Console.WriteLine(@"Elastic suggestive indexing started - "); CreateMapping(); foreach (var elasticTitle in t.ElasticSuggestive.Batch(batchCount)) { i++; timerStopwatch.Restart(); Console.WriteLine(Environment.NewLine); Console.WriteLine(@"indexed records - " + i * batchCount); ElasticSearch.BulkIndex(elasticTitle.ToList()); Console.WriteLine(@"iteration {0} took - {1} ms", i, timerStopwatch.ElapsedMilliseconds); } Console.WriteLine(@"Elastic suggestive indexing finished at - " + timerStopwatch.ElapsedMilliseconds); timerStopwatch.Stop(); return(t); }
// POST: api/HealthCheck public HealthCheckModel Post([FromBody] DeleteObject deleteme) { string res = ""; HealthCheckModel hcm = new HealthCheckModel(); List <HealthCheckModel> returnval = new List <HealthCheckModel>(); var client = new RestClient(deleteme.AppUrl); var request = new RestRequest("", Method.GET); var queryResult = client.Execute(request); hcm.AppName = deleteme.AppName; hcm.AppUrl = deleteme.AppUrl; hcm.TimeStamp = DateTime.Now; hcm.Status = queryResult.StatusCode.ToString(); if (queryResult.StatusCode == 0) { hcm.Status = HttpStatusCode.ServiceUnavailable.ToString(); } if (JSONHelper.IsValidJson(queryResult.Content)) { hcm.Message = queryResult.Content; } ElasticSearch.LogHealthMetric(hcm); return(hcm); }
private bool disposedValue = false; // Para detectar chamadas redundantes protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: descartar estado gerenciado (objetos gerenciados). if (this.ClientFactory != null) { this.ClientFactory = null; } if (this.ConnectionSettings != null) { this.ConnectionSettings = null; } if (this.ElasticSearchURL != null) { this.ElasticSearchURL = null; } if (this._configuration != null) { this._configuration = null; } } // TODO: liberar recursos não gerenciados (objetos não gerenciados) e substituir um finalizador abaixo. // TODO: definir campos grandes como nulos. disposedValue = true; } }
private SearchResponse GetResponse(ElasticSearch cmdlet) { var enumerator = cmdlet.Invoke().GetEnumerator(); enumerator.MoveNext(); return((SearchResponse)enumerator.Current); }
public IHttpActionResult GetESKey(string username) { string serializeResponse = ""; Response response = new Response(); try { // Validate inputs if (!string.IsNullOrEmpty(username)) { string errorMessage = ""; // Get appsettings AppSettingsValues appKeys = GetAppSettings.GetAppSettingsValues(); ElasticSearch es = new ElasticSearch(); string secretKey = ""; // Gets the key from ElasticSearch string[] esResults = es.GetESKey(username, appKeys.LookupKey, out errorMessage); if (esResults != null) { secretKey = esResults[0]; } response.success = true; response.message = secretKey; Log.Info(username + " username, Process : Get ES key, Message : The Get method for Secret Key from Elastic Search has been successfully executed."); } } catch (Exception ex) { response.success = false; response.message = "Sorry, there seems to be an issue with your request. Please send an email to #automationinfo with your ServiceNow ticket number and we will contact you shortly."; Log.Error(ex, username); } serializeResponse = JsonConvert.SerializeObject(response); return(Json(serializeResponse)); }
public void SearchTest() { var finder = new ElasticSearch(); var results = finder.SearchForQuestion("I would like"); Assert.True(results.Any()); }
public ApiController() : base() { _elastic = new ElasticSearch(); _accent = AccentService.AccentInstance; _bot = BotService.BotInstance; _bot.loadAIMLFromFiles(pathAIML); //string userName = "******" + Guid.NewGuid(); //user = new User(userName, bot); //string pathSetting = HostingEnvironment.MapPath("~/Datasets_BOT/config/Settings.xml"); //bot.loadSettings(pathSetting); //bot.loadAIMLFromFiles(pathAIML); //bot.isAcceptingUserInput = false; //bot.isAcceptingUserInput = true; NOT_MATCH = new Dictionary <string, string>(); NOT_MATCH.Add("NOT_MATCH_01", "Xin lỗi, Tôi không hiểu"); NOT_MATCH.Add("NOT_MATCH_02", "Bạn có thể giải thích thêm được không?"); NOT_MATCH.Add("NOT_MATCH_03", "Tôi không thể tìm thấy, bạn có thể nói rõ hơn?"); NOT_MATCH.Add("NOT_MATCH_04", "Xin lỗi, Bạn có thể giải thích thêm được không?"); NOT_MATCH.Add("NOT_MATCH_05", "Tôi không thể tìm thấy"); NOT_MATCH.Add("NOT_MATCH_06", "Tôi chưa hiểu"); }
public void Save() { UserName.Save(); PassWord.Save(); Title.Save(); ElasticSearch.Save(); About.Save(); }
public UnitOfWork(IOptions <ElasticSearch> configuration) { _configuration = configuration.Value; this.ElasticSearchURL = new Uri(_configuration.URL); this.ConnectionSettings = new ConnectionSettings(ElasticSearchURL); this.ConnectionSettings.BasicAuthentication(_configuration.Account, _configuration.Password); this.ClientFactory = new Dictionary <string, object>(); }
public SearchBasic() { if (string.IsNullOrEmpty(ElasticsearchHost)) { throw new Exception("ElasticSearch appSetting is empty!"); } _search = new ElasticSearch(ElasticsearchHost); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; //LuceneSearch.Test(); ElasticSearch.Test(); Console.WriteLine("Hello World!"); }
public ElasticSearch GetElasticSetting() { var result = new ElasticSearch(); result.Uri = ConfigurationSettings.AppSettings["Uri"]; result.IndexName = ConfigurationSettings.AppSettings["PropertyIndexName"]; result.TypeName = ConfigurationSettings.AppSettings["PropertyTypeName"]; result.UserName = ConfigurationSettings.AppSettings["UserName"]; result.Password = ConfigurationSettings.AppSettings["Password"]; return(result); }
public BulkElasticMagazineIndex Post(BulkElasticMagazineIndex t) { ConsoleProcess.Start(t.GetType()); CreateMapping(); foreach (var elasticMagazine in t.ElasticMagazine.Batch(5000)) { ConsoleProcess.Increment(); ElasticSearch.BulkIndex(elasticMagazine.ToList()); } return(t); }
public BulkElasticOrderHistory Post(BulkElasticOrderHistory t) { ConsoleProcess.Start(t.GetType()); CreateMapping(); foreach (var elasticTitle in t.OrderHistories.Batch(5000)) { ConsoleProcess.Increment(); ElasticSearch.BulkIndex(elasticTitle.ToList()); } return(t); }
public static ElasticClient GetElasticConnection(ElasticSearch elastiSetting) { var node = new Uri(elastiSetting.Uri); var connectionPool = new SniffingConnectionPool(new[] { node }); var elasticConfig = new ConnectionSettings(connectionPool) .SniffOnConnectionFault(false) .SniffOnStartup(false) .DisablePing(); elasticConfig.DefaultIndex(elastiSetting.IndexName); elasticConfig.BasicAuthentication(elastiSetting.UserName, elastiSetting.Password); return(new ElasticClient(elasticConfig)); }
public override int SaveChanges() { try { // Değişen Var mı? Boya Var mı :) var modifiedEntities = ChangeTracker.Entries() .Where(p => p.State == EntityState.Modified).ToList(); var now = System.DateTime.UtcNow; foreach (var change in modifiedEntities) { var entityName = change.Entity.GetType().Name; var PrimaryKey = change.OriginalValues.Properties.FirstOrDefault(prop => prop.IsPrimaryKey() == true).Name; foreach (IProperty prop in change.OriginalValues.Properties) { var originalValue = change.OriginalValues[prop.Name].ToString(); var currentValue = change.CurrentValues[prop.Name].ToString(); if (originalValue != currentValue) //Sadece Değişen kayıt Log'a atılır. { ChangeLog log = new ChangeLog() { EntityName = entityName, PrimaryKeyValue = int.Parse(change.OriginalValues[PrimaryKey].ToString()), PropertyName = prop.Name, OldValue = originalValue, NewValue = currentValue, DateChanged = now, State = EnumState.Update }; //Değişen kayıt Log'u ElasticSearch'e atılır. ElasticSearch.CheckExistsAndInsert(log); } } } return(base.SaveChanges()); } catch (Exception ex) { var error = ex.Message; return(0); } }
public ActionResult RunQuery(RunQueryParameters parameters) { const string indexName = "testindex"; string opResult = string.Empty; opResult = ElasticSearch.DeleteIndex(indexName); opResult = ElasticSearch.CreateIndex(indexName); opResult = ElasticSearch.CreateMapping(indexName, "test", parameters.Mapping); opResult = ElasticSearch.InsertDocument(indexName, "test", parameters.Documents, true); Thread.Sleep(2000); var response = ElasticSearch.RunSearch(indexName, "test", parameters.Query); return(Content(JsonSerialization.Serialize(new { queryResult = response }))); }
public BulkElasticGroupedTitleIndex Post(BulkElasticGroupedTitleIndex t) { const int batchCount = 500; ConsoleProcess.Start(t.GetType()); CreateMapping(); var i = 0; foreach (var elasticTitle in t.ElasticGroupedTitles.Batch(batchCount)) { i++; ConsoleProcess.Restart(); ElasticSearch.BulkIndex(elasticTitle.ToList()); Console.WriteLine(Environment.NewLine); Console.WriteLine(@"iteration for {0} took - {1} ms", i * batchCount, ConsoleProcess.ElapsedMilliseconds()); } ConsoleProcess.End(t.GetType()); return(t); }
public HelperElasticSearchTest() { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); SQLHelperConfig.ConnectionConfig = configuration.GetConnectionString("ContentderAIConnection"); var provider = new ServiceCollection() .AddMemoryCache() .BuildServiceProvider(); var memoryCache = provider.GetService <IMemoryCache>(); var settingHelper = new SettingHelper(memoryCache); settingHelper.CacheAllSettings(); var url = settingHelper.GetCachedSettingValue(SettingKeys.ElasticSearchEndpoint); index = settingHelper.GetCachedSettingValue(SettingKeys.ElasticSearchIndex); _elasticSearch = new ElasticSearch(url, index); }
public JsonResult Delete(long id) { hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>(); HSCV_VANBANDEN entityVanBanDen = hscvVanBanDenBusiness.Find(id); AssignUserInfo(); if (entityVanBanDen == null || currentUser.ID != entityVanBanDen.NGUOITAO) { return(Json(new { Type = "ERROR", Message = "Bạn không có quyền xóa văn bản trình ký này" })); } attachmentBusiness = Get <TAILIEUDINHKEMBusiness>(); FileUltilities file = new FileUltilities(); List <TAILIEUDINHKEM> ListTaiLieu = attachmentBusiness.GetDataByItemID(id, LOAITAILIEU.VANBANDEN); foreach (var item in ListTaiLieu) { attachmentBusiness.repository.Delete(item.TAILIEU_ID); file.RemoveFile(uploadFolder + item.DUONGDAN_FILE); if (!string.IsNullOrEmpty(item.PDF_VERSION)) { file.RemoveFile(uploadFolder + item.PDF_VERSION); } } storeFolderBusiness = Get <THUMUC_LUUTRUBusiness>(); THUMUC_LUUTRU ThuMuc = storeFolderBusiness.GetDataByNam(id.ToString(), ThuMucLuuTruConstant.DefaultVanban); if (ThuMuc != null) { ThuMuc.IS_DELETE = true; storeFolderBusiness.Save(ThuMuc); } attachmentBusiness.Save(); hscvVanBanDenBusiness.repository.Delete(id); #region xóa văn bản đến trong elastic ElasticSearch.deleteDocument(id.ToString(), ElasticType.VanBanDen); #endregion return(Json(new { Type = "SUCCESS", Message = "Xóa văn bản đến thành công" })); }
public JsonResult SaveFlow(long processID, int stepID, long mainUser, List <long> joinUser, string message, bool IsBack = false, long LogID = 0) { var result = new JsonResultBO(true); AssignUserInfo(); var WF_STEPBusiness = Get <WF_STEPBusiness>(); var WF_PROCESSBusiness = Get <WF_PROCESSBusiness>(); var WF_LOGBusiness = Get <WF_LOGBusiness>(); var step = WF_STEPBusiness.GetDaTaByID(stepID); //SMSDAL.SendSMSDAL sms = new SMSDAL.SendSMSDAL(); //var LogSMSBusiness = Get<LogSMSBusiness>(); var lstMainUser = new List <long>(); lstMainUser.Add(mainUser); var process = WF_PROCESSBusiness.Find(processID); string NOIDUNG = currentUser.HOTEN + (process.ITEM_TYPE == MODULE_CONSTANT.VANBANTRINHKY ? " đã gửi bạn một văn bản trình ký" : " đã gửi bạn một văn bản đến"); string URL = process.ITEM_TYPE == MODULE_CONSTANT.VANBANTRINHKY ? "/HSVanBanDiArea/HSVanBanDi/DetailVanBan/" + process.ITEM_ID.ToString() : "/HSCV_VANBANDENArea/HSCV_VANBANDEN/DetailVanBanDen?id=" + process.ITEM_ID.ToString() + "&type=" + VANBANDEN_CONSTANT.CHUA_XULY; string itemName = process.ITEM_TYPE == MODULE_CONSTANT.VANBANTRINHKY ? "VĂN BẢN TRÌNH KÝ" : "VĂN BẢN ĐẾN"; if (IsBack != true) { //Kiểm tra xem đã thực hiện function chưa? var WF_STATE_FUNCTIONBusiness = Get <WF_STATE_FUNCTIONBusiness>(); bool CanNext = false; if (process.ITEM_TYPE == MODULE_CONSTANT.VANBANTRINHKY) { HSCV_VANBANDIBusiness = Get <HSCV_VANBANDIBusiness>(); HSCV_VANBANDI VanBan = HSCV_VANBANDIBusiness.Find(process.ITEM_ID); if (VanBan != null) { CanNext = VanBan.HAS_SIGNED.HasValue ? VanBan.HAS_SIGNED.Value : true; } } var function = WF_STATE_FUNCTIONBusiness.CheckFunctionNextState(process.CURRENT_STATE.GetValueOrDefault(), process.ITEM_ID.GetValueOrDefault(), process.ITEM_TYPE); if (!function && CanNext) { result.MessageFail("Bạn chưa thực hiện hành động của trạng thái"); return(Json(result)); } //Luồng chuyển đi result = WF_PROCESSBusiness.SaveStepAction(processID, stepID, mainUser, joinUser, message, currentUser.ID); #region gửi notification var SYS_TINNHANBusiness = Get <SYS_TINNHANBusiness>(); #region gửi email cho người xử lý chính List <string> lstEmail = new List <string>(); var DM_NGUOIDUNGBusiness = Get <DM_NGUOIDUNGBusiness>(); lstEmail = DM_NGUOIDUNGBusiness.repository.All().Where(x => lstMainUser.Contains(x.ID)).Select(x => x.EMAIL).ToList(); if (lstEmail != null) { var ContentEmail = currentUser.HOTEN + " đã gửi bạn một <a href='" + SERVERADDRESS + URL + "'>" + itemName + "</a>"; EmailProvider.SendMailTemplate(currentUser, ContentEmail, NOIDUNG, lstEmail); } #endregion #region gửi sms cho người xử lý //var LstUserNhan = DM_NGUOIDUNGBusiness.repository.All().Where(x => lstMainUser.Contains(x.ID)).ToList(); //if (LstUserNhan != null) //{ // var ContentSMS = currentUser.HOTEN + " đã gửi bạn một " + itemName; // ContentSMS = sms.locDau(ContentSMS); // var DoDaiSMS = ContentSMS.Length; // string[] noiDung = new string[1]; // noiDung[0] = ContentSMS; // foreach (var user in LstUserNhan) // { // if (!string.IsNullOrEmpty(user.DIENTHOAI)) // { // string resultsend = sms.guiTinNhan(user.DIENTHOAI, "177403", noiDung); // LOGSMS SmsObject = new LOGSMS(); // SmsObject.SODIENTHOAINHAN = user.DIENTHOAI; // SmsObject.NOIDUNG = ContentSMS; // SmsObject.SOKYTU = DoDaiSMS; // SmsObject.KETQUA = resultsend; // SmsObject.CREATED_AT = DateTime.Now; // SmsObject.CREATED_BY = currentUser.ID; // SmsObject.HOTENNGUOIGUI = currentUser.HOTEN; // SmsObject.ITEMTYPE = process.ITEM_TYPE; // SmsObject.ITEMID = process.ITEM_ID; // SmsObject.HOTENNGUOINHAN = user.HOTEN; // LogSMSBusiness.Save(SmsObject); // } // } //} #endregion SYS_TINNHANBusiness.sendMessageMultipleUsers(lstMainUser, currentUser, itemName, NOIDUNG, URL, targetScreen, false, processID, TargetDocType.COORDINATED); if (joinUser != null) { SYS_TINNHANBusiness.sendMessageMultipleUsers(joinUser, currentUser, itemName, NOIDUNG, URL, targetScreen, false, processID, TargetDocType.COORDINATED); } var lstTmpUserId = lstMainUser; if (joinUser != null) { lstTmpUserId.AddRange(joinUser); } if (process.ITEM_TYPE == MODULE_CONSTANT.VANBANTRINHKY) { ElasticSearch.updateListUser(process.ITEM_ID.ToString(), lstTmpUserId, ElasticType.VanBanDi); } else { ElasticSearch.updateListUser(process.ITEM_ID.ToString(), lstTmpUserId, ElasticType.VanBanDen); } #endregion } else { result = WF_PROCESSBusiness.StepDenie(processID, stepID, message, LogID); var log = WF_LOGBusiness.GetDataByID(LogID); lstMainUser.Add(log.NGUOIXULY_ID.GetValueOrDefault()); #region gửi notification var SYS_TINNHANBusiness = Get <SYS_TINNHANBusiness>(); SYS_TINNHANBusiness.sendMessageMultipleUsers(lstMainUser, currentUser, itemName, NOIDUNG, URL, targetScreen, false, processID, TargetDocType.COORDINATED); #endregion } return(Json(result)); }
/// <summary> /// Save Review văn bản /// </summary> /// <param name="processID"></param> /// <param name="stepID"></param> /// <param name="joinUser"></param> /// <param name="message"></param> /// <returns></returns> public JsonResult SaveReview(long processID, int stepID, List <long> joinUser, string message) { AssignUserInfo(); var result = new JsonResultBO(true); if (joinUser.Count > 0 && !joinUser.Contains(currentUser.ID)) { var WF_STEPBusiness = Get <WF_STEPBusiness>(); var WF_PROCESSBusiness = Get <WF_PROCESSBusiness>(); WF_REVIEWBusiness WF_REVIEWBusiness = Get <WF_REVIEWBusiness>(); WF_REVIEW_USERBusiness WF_REVIEW_USERBusiness = Get <WF_REVIEW_USERBusiness>(); var SYS_TINNHANBusiness = Get <SYS_TINNHANBusiness>(); var step = WF_STEPBusiness.GetDaTaByID(stepID); var process = WF_PROCESSBusiness.Find(processID); #region cập nhật trạng thái review process.IS_PENDING = true; WF_PROCESSBusiness.Save(process); #endregion #region lưu yêu cầu review - bảng này sẽ dùng để đếm số lần gửi yêu cầu review WF_REVIEW review = new WF_REVIEW(); review.COMMENT = message; review.CREATED_AT = DateTime.Now; review.ITEMID = process.ITEM_ID; review.ITEMTYPE = process.ITEM_TYPE; review.CREATED_BY = currentUser.ID; WF_REVIEWBusiness.Save(review); #endregion #region lưu yêu cầu review đối với từng người được yêu cầu var WF_LogBusiness = Get <WF_LOGBusiness>(); foreach (var item in joinUser) { WF_USER_REVIEW itemreview = new WF_USER_REVIEW(); itemreview.ITEMID = process.ITEM_ID; itemreview.ITEMTYPE = process.ITEM_TYPE; itemreview.REVIEW_ID = review.ID; itemreview.USER_ID = item; itemreview.CREATED_AT = DateTime.Now; itemreview.CREATED_BY = currentUser.ID; WF_REVIEW_USERBusiness.Save(itemreview); #region luu log WF_LOG log = new WF_LOG(); log.ITEM_ID = process.ITEM_ID; log.WF_ID = process.WF_ID; log.ITEM_TYPE = process.ITEM_TYPE; log.MESSAGE = message; log.NGUOIXULY_ID = currentUser.ID; log.NGUONHAN_ID = item; log.create_at = DateTime.Now; log.create_by = currentUser.ID; WF_LogBusiness.Save(log); #endregion #region gửi notification SYS_TINNHAN noti = new SYS_TINNHAN(); noti.FROM_USERNAME = currentUser.HOTEN; noti.FROM_USER_ID = currentUser.ID; noti.NGAYTAO = DateTime.Now; noti.NOIDUNG = currentUser.HOTEN + " đã gửi bạn review một văn bản trình ký"; if (process.ITEM_TYPE == MODULE_CONSTANT.VANBANTRINHKY) { noti.URL = "/HSVanBanDiArea/VanBanChuaXuLy/DetailVanBan/" + process.ITEM_ID.ToString(); noti.TIEUDE = "REVIEW VĂN BẢN TRÌNH KÝ"; } noti.TO_USER_ID = item; SYS_TINNHANBusiness.Save(noti, targetScreen, false, process.ITEM_ID.HasValue ? process.ITEM_ID.Value : 0, TargetDocType.COORDINATED); #endregion } ElasticSearch.updateListUser(process.ITEM_ID.ToString(), joinUser, ElasticType.VanBanDi); #endregion } else { result.MessageFail("Không thể thực hiện được thao tác này"); } return(Json(result)); }
public ProjectService(eFolioDBContext DBContext, IMapper mapper) { projectRepository = new ProjectRepository(DBContext); elastic = new ElasticSearch(); this.mapper = mapper; }
/// <summary> /// @author:duynn /// @description: gửi cá nhân nhận bên ngoài /// @since: 10/06/2019 /// </summary> /// <param name="entityVanBanDi"></param> /// <param name="sms"></param> /// <returns></returns> public bool SaveVanBanPhatHanhToCaNhan(HSCV_VANBANDI entityVanBanDi, SMSDAL.SendSMSDAL sms) { List <TAILIEUDINHKEM> groupForwardFiles = new List <TAILIEUDINHKEM>(); List <LOGSMS> groupLogSMSs = new List <LOGSMS>(); var idsNguoiNhanDichDanh = entityVanBanDi.USER_RECEIVE_DIRECTLY.ToListLong(','); bool result = true; try { /** * nhóm sổ văn bản */ var dataNhomSoVanBanDen = DM_NHOMDANHMUCBusiness.repository.All() .FirstOrDefault(x => x.GROUP_CODE == DMLOAI_CONSTANT.SOVANBANDEN); /** * gửi từng người nhận đích danh */ foreach (var userId in idsNguoiNhanDichDanh) { var entityNguoiNhan = DM_NGUOIDUNGBusiness.GetNewUserInfo(userId); var dataSoVanBanDen = DM_DANHMUC_DATABusiness.GetSoVanBan(DMLOAI_CONSTANT.SOVANBANDEN, DateTime.Now.Year, entityNguoiNhan.DeptParentID.Value); if (dataSoVanBanDen == null) { dataSoVanBanDen = new DM_DANHMUC_DATA() { DEPTID = entityNguoiNhan.DM_PHONGBAN_ID.GetValueOrDefault(), TEXT = "Sổ văn bản đến " + DateTime.Now.Year, DATA = DateTime.Now.Year, DM_NHOM_ID = dataNhomSoVanBanDen.ID }; DM_DANHMUC_DATABusiness.Save(dataSoVanBanDen); } DM_NGUOIDUNG entityNguoiKy = DM_NGUOIDUNGBusiness.Find(entityVanBanDi.NGUOIKY_ID); HSCV_VANBANDEN entityVanBanDen = this.ConvertToVanBanDen(entityVanBanDi, entityNguoiKy, dataSoVanBanDen); HSCV_VANBANDENBusiness.Save(entityVanBanDen); JsonResultBO workflowResult = WF_PROCESSBusiness.AddFlow(entityVanBanDen.ID, MODULE_CONSTANT.VANBANDEN, entityNguoiNhan); if (!workflowResult.Status) { continue; } /** * Cập nhật số theo sổ */ dataSoVanBanDen.GHICHU = (dataSoVanBanDen.GHICHU.ToIntOrZero() + 1).ToString(); DM_DANHMUC_DATABusiness.Save(dataSoVanBanDen); /** * cập nhật tài liệu đính kèm */ List <TAILIEUDINHKEM> groupFiles = TAILIEUDINHKEMBusiness.GetNewestData(entityVanBanDi.ID, LOAITAILIEU.VANBAN); groupForwardFiles.AddRange(this.GenerateFiles(groupFiles, entityVanBanDen)); /** * cập nhật elastic search */ ElasticSearch.updateListUser(entityVanBanDen.ID.ToString(), new List <long> { entityNguoiNhan.ID }, ElasticType.VanBanDen); /** * gửi email */ if (entityNguoiNhan.EMAIL != null && !string.IsNullOrEmpty(entityNguoiNhan.EMAIL)) { var ContentEmail = currentUser.TenPhongBan + " đã gửi bạn một văn bản đến <a href='" + SERVERADDRESS + "/HSCV_VANBANDENArea/HSCV_VANBANDEN/DetailVanBanDen?id=" + entityVanBanDen.ID.ToString() + "'>" + entityVanBanDen.SOHIEU + "</a>"; EmailProvider.SendMailTemplate(currentUser, ContentEmail, ContentEmail, new List <string> { entityNguoiNhan.EMAIL }); } //gửi sms if (currentUser.CanSendSMS && entityVanBanDi.CAN_SEND_SMS == true) { if (!string.IsNullOrEmpty(entityNguoiNhan.DIENTHOAI)) { var ContentSMS = currentUser.TenPhongBan + " đã gửi bạn một văn bản đến " + entityVanBanDen.SOHIEU; ContentSMS = sms.locDau(ContentSMS); var DoDaiSMS = ContentSMS.Length; string[] noiDung = new string[1]; noiDung[0] = ContentSMS; string resultsend = sms.guiTinNhan(entityNguoiNhan.DIENTHOAI, "177403", noiDung); LOGSMS SmsObject = new LOGSMS(); SmsObject.SODIENTHOAINHAN = entityNguoiNhan.DIENTHOAI; SmsObject.NOIDUNG = ContentSMS; SmsObject.SOKYTU = DoDaiSMS; SmsObject.KETQUA = resultsend; SmsObject.DONVI_GUI = currentUser.DM_PHONGBAN_ID.GetValueOrDefault(); SmsObject.CREATED_AT = DateTime.Now; SmsObject.CREATED_BY = currentUser.ID; SmsObject.HOTENNGUOIGUI = currentUser.HOTEN; SmsObject.ITEMTYPE = "VANBANDEN"; SmsObject.ITEMID = entityVanBanDen.ID; SmsObject.HOTENNGUOINHAN = entityNguoiNhan.HOTEN; SmsObject.DONVI_NHAN = entityNguoiNhan.DM_PHONGBAN_ID.GetValueOrDefault(); groupLogSMSs.Add(SmsObject); } } //gửi tin nhắn SYS_TINNHAN noti = new SYS_TINNHAN(); noti.FROM_USERNAME = currentUser.HOTEN; noti.FROM_USER_ID = currentUser.ID; noti.NGAYTAO = DateTime.Now; noti.NOIDUNG = currentUser.TenPhongBan + " đã gửi đến bạn một văn bản đến"; noti.URL = "/HSCV_VANBANDENArea/HSCV_VANBANDEN/DetailVanBanDen/" + entityVanBanDen.ID.ToString(); noti.TIEUDE = "Xử lý văn bản đến"; noti.TO_USER_ID = entityNguoiNhan.ID; SYS_TINNHANBusiness.Save(noti, "", false, entityVanBanDen.ID, TargetDocType.COORDINATED); } /** * lưu file và log SMS */ TAILIEUDINHKEMBusiness.repository.InsertRange(groupForwardFiles); LogSMSBusiness.repository.InsertRange(groupLogSMSs); TAILIEUDINHKEMBusiness.Save(); } catch (Exception) { result = false; } return(result); }
/// <summary> /// @author:duynn /// @description: gửi đơn vị nhận bên ngoài /// @since: 10/06/2019 /// </summary> /// <param name="entityVanBanDi"></param> /// <param name="sms"></param> /// <returns></returns> public bool SaveVanBanPhatHanhToDonVi(HSCV_VANBANDI entityVanBanDi, SMSDAL.SendSMSDAL sms) { bool result = true; try { DM_NHOMDANHMUC entityNhomDanhMuc = DM_NHOMDANHMUCBusiness.repository.All() .FirstOrDefault(x => x.GROUP_CODE == DMLOAI_CONSTANT.SOVANBANDEN); DM_NGUOIDUNG entityNguoiKy = DM_NGUOIDUNGBusiness.Find(entityVanBanDi.NGUOIKY_ID); List <TAILIEUDINHKEM> groupFiles = TAILIEUDINHKEMBusiness.GetNewestData(entityVanBanDi.ID, LOAITAILIEU.VANBAN); List <int> idsDonViNhan = new List <int>(); if (!string.IsNullOrEmpty(entityVanBanDi.DONVINHAN_INTERNAL_ID)) { var idsDonViDaNhan = entityVanBanDi.DONVINHAN_INTERNAL_ID.ToListInt(','); idsDonViNhan.AddRange(idsDonViDaNhan); entityVanBanDi.DONVINHAN_INTERNAL_ID = string.Join(",", idsDonViNhan.ToArray()); } List <CCTC_THANHPHAN> groupDonViNhan = CCTC_THANHPHANBusiness.repository.AllNoTracking .Where(x => idsDonViNhan.Contains(x.ID)).ToList(); List <LOGSMS> groupLogSMS = new List <LOGSMS>(); List <TAILIEUDINHKEM> groupForwardFiles = new List <TAILIEUDINHKEM>(); List <WF_ITEM_USER_PROCESS> groupItemUserProcess = new List <WF_ITEM_USER_PROCESS>(); foreach (var dept in groupDonViNhan) { WF_STATE firstState = null; //kiểm tra có phải là gửi nội bộ hay không? bool isSendInternal = false; //- trường hợp gửi cho các ban ngành cấp tỉnh và các huyện xa -> thành văn bản đến của các đơnvị nhận được if (dept.TYPE == DEPTTYLELABEL.ToIntOrZero()) { //- trường hợp này là văn bản đến bình thường var workflowModule = WF_MODULEBusiness.repository .All().FirstOrDefault(x => x.MODULE_CODE == MODULE_CONSTANT.VANBANDEN); var workflowStreamIds = workflowModule.WF_STREAM_ID.ToListInt(','); //- lấy luồng xử lý của từng đơn vị var workflowStream = WF_STREAMBusiness.repository.All() .FirstOrDefault(x => x.LEVEL_ID == dept.CATEGORY && workflowStreamIds.Contains(x.ID)); //lấy trạng thái xử lý ban đầu cảu đơn vị firstState = WF_STATEBusiness.repository.All() .FirstOrDefault(x => x.IS_START == true && x.WF_ID == workflowStream.ID); } else if (dept.PARENT_ID == currentUser.DeptParentID) { isSendInternal = true; //- trường hợp gửi các phòng ban thuộc tỉnh ủy => thành văn bản đến nội bộ của tỉnh var workflowModule = WF_MODULEBusiness.repository.All() .FirstOrDefault(x => x.MODULE_CODE == MODULE_CONSTANT.VANBANDENNOIBO); var workflowStreamIds = workflowModule.WF_STREAM_ID.ToListInt(','); //- lấy luồng xử lý của từng đơn vị var workflowStream = WF_STREAMBusiness.repository.All() .FirstOrDefault(x => x.LEVEL_ID == dept.CATEGORY && workflowStreamIds.Contains(x.ID)); firstState = WF_STATEBusiness.repository.All() .FirstOrDefault(x => x.IS_START == true && x.WF_ID == workflowStream.ID); } UserInfoBO processor = null; /** * kiểm tra vai trò nhận của trạng thái đầu tiên */ if (firstState != null) { /** * lấy người thuộc phòng ban có vai trò xử lý */ var receiver = DM_NGUOIDUNGBusiness.GetUserByRoleAndDeptId(firstState.VAITRO_ID.GetValueOrDefault(), dept.ID).FirstOrDefault(); if (receiver != null) { processor = DM_NGUOIDUNGBusiness.GetNewUserInfo(receiver.Value.ToLongOrZero()); } } var dataSoVanBanDen = DM_DANHMUC_DATABusiness.GetSoVanBan(DMLOAI_CONSTANT.SOVANBANDEN, DateTime.Now.Year, dept.ID); if (dataSoVanBanDen == null) { //tạo sổ văn bản đến dataSoVanBanDen = new DM_DANHMUC_DATA() { DEPTID = dept.ID, TEXT = "Sổ văn bản đến " + DateTime.Now.Year, DATA = DateTime.Now.Year, DM_NHOM_ID = entityNhomDanhMuc.ID }; DM_DANHMUC_DATABusiness.Save(dataSoVanBanDen); } HSCV_VANBANDEN entityVanBanDen = this.ConvertToVanBanDen(entityVanBanDi, entityNguoiKy, dataSoVanBanDen); entityVanBanDen.IS_NOIBO = isSendInternal ? true : false; HSCV_VANBANDENBusiness.Save(entityVanBanDen); /** * cập nhật số văn bản đến */ dataSoVanBanDen.GHICHU = (dataSoVanBanDen.GHICHU.ToIntOrZero() + 1).ToString(); DM_DANHMUC_DATABusiness.Save(dataSoVanBanDen); /** * cập nhật tài liệu đính kèm */ var files = this.GenerateFiles(groupFiles, entityVanBanDen); groupForwardFiles.AddRange(files); /** * cập nhật thông tin văn bản đến trong luồng xử lý */ if (processor != null) { WF_PROCESSBusiness.AddFlow(entityVanBanDen.ID, isSendInternal ? MODULE_CONSTANT.VANBANDENNOIBO : MODULE_CONSTANT.VANBANDEN, processor); } /** * nếu không có người phù hợp trong luồng xử lý ==> lấy người có vai trò cao nhất tại phòng */ if (processor == null) { /** * lấy ra người có vai trò cao nhất tại phòng ban */ processor = DM_NGUOIDUNGBusiness.GetUserHighestPriority(dept.ID); /** * lưu thông in người nhận vào bảng WF_ITEM_USER_PROCESS */ var itemUserProcess = new WF_ITEM_USER_PROCESS(); itemUserProcess.ITEM_ID = entityVanBanDen.ID; itemUserProcess.ITEM_TYPE = isSendInternal ? MODULE_CONSTANT.VANBANDENNOIBO : MODULE_CONSTANT.VANBANDEN; itemUserProcess.IS_XULYCHINH = false; itemUserProcess.USER_ID = processor.ID; itemUserProcess.create_at = DateTime.Now; itemUserProcess.create_by = currentUser.ID; groupItemUserProcess.Add(itemUserProcess); } if (processor != null) { ElasticSearch.updateListUser(entityVanBanDen.ID.ToString(), new List <long> { processor.ID }, ElasticType.VanBanDen); //gửi email if (!string.IsNullOrEmpty(processor.EMAIL)) { var ContentEmail = currentUser.TenPhongBan + " đã gửi bạn một văn bản đến <a href='" + SERVERADDRESS + "/HSCV_VANBANDENArea/HSCV_VANBANDEN/DetailVanBanDen?id=" + entityVanBanDen.ID.ToString() + "'>" + entityVanBanDen.SOHIEU + "</a>"; EmailProvider.SendMailTemplate(currentUser, ContentEmail, ContentEmail, new List <string> { processor.EMAIL }); } //gửi tin nhắn if (currentUser.CanSendSMS && entityVanBanDi.CAN_SEND_SMS == true && processor.DIENTHOAI != null) { var ContentSMS = currentUser.TenPhongBan + " đã gửi bạn một văn bản đến " + entityVanBanDen.SOHIEU; ContentSMS = sms.locDau(ContentSMS); var DoDaiSMS = ContentSMS.Length; string[] noiDung = new string[1]; noiDung[0] = ContentSMS; string resultsend = sms.guiTinNhan(processor.DIENTHOAI, "177403", noiDung); LOGSMS SmsObject = new LOGSMS(); SmsObject.SODIENTHOAINHAN = processor.DIENTHOAI; SmsObject.NOIDUNG = ContentSMS; SmsObject.SOKYTU = DoDaiSMS; SmsObject.KETQUA = resultsend; SmsObject.CREATED_AT = DateTime.Now; SmsObject.CREATED_BY = currentUser.ID; SmsObject.HOTENNGUOIGUI = currentUser.HOTEN; SmsObject.DONVI_GUI = currentUser.DM_PHONGBAN_ID.GetValueOrDefault(); SmsObject.ITEMTYPE = "VANBANDEN"; SmsObject.ITEMID = entityVanBanDen.ID; SmsObject.DONVI_NHAN = processor.DM_PHONGBAN_ID.GetValueOrDefault(); SmsObject.HOTENNGUOINHAN = processor.HOTEN; groupLogSMS.Add(SmsObject); } //lưu thông báo SYS_TINNHAN noti = new SYS_TINNHAN(); noti.FROM_USERNAME = currentUser.HOTEN; noti.FROM_USER_ID = currentUser.ID; noti.NGAYTAO = DateTime.Now; noti.NOIDUNG = currentUser.TenPhongBan + " đã gửi đến bạn một văn bản đến"; noti.URL = "/HSCV_VANBANDENArea/HSCV_VANBANDEN/DetailVanBanDen/" + entityVanBanDen.ID.ToString(); noti.TIEUDE = "Xử lý văn bản đến"; noti.TO_USER_ID = processor.ID; SYS_TINNHANBusiness.Save(noti, "", false, entityVanBanDen.ID, TargetDocType.COORDINATED); } } //lưu thông tin tài liệu, sms, luồng xử lý TAILIEUDINHKEMBusiness.repository.InsertRange(groupForwardFiles); LogSMSBusiness.repository.InsertRange(groupLogSMS); WF_ITEM_USER_PROCESSBusiness.repository.InsertRange(groupItemUserProcess); TAILIEUDINHKEMBusiness.repository.Save(); } catch (Exception) { result = false; } return(result); }
public ActionResult SaveVanBanDen(HSCV_VANBANDEN entity, FormCollection fc, IEnumerable <HttpPostedFileBase> filebase, string[] filename, string[] FOLDER_ID) { try { AssignUserInfo(); UploadFileTool uploadFileTool = new UploadFileTool(); hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>(); wfProcessBusiness = Get <WF_PROCESSBusiness>(); dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>(); entity.SOHIEU = fc["SOHIEU"].Trim(); entity.TRICHYEU = fc["TRICHYEU"].Trim(); entity.SOTRANG = fc["SOTRANG"].ToIntOrZero(); entity.LOAIVANBAN_ID = fc["LOAIVANBAN_ID"].ToIntOrZero(); entity.DONVI_ID = fc["DONVI_ID"].ToIntOrZero(); entity.LINHVUCVANBAN_ID = fc["LINHVUCVANBAN_ID"].ToIntOrZero(); entity.DOKHAN_ID = fc["DOKHAN_ID"].ToIntOrZero(); entity.NGAY_HIEULUC = fc["NGAY_HIEULUC"].ToDateTime(); entity.NGAYHET_HIEULUC = fc["NGAYHET_HIEULUC"].ToDateTime(); entity.NGAY_VANBAN = fc["NGAY_VANBAN"].ToDateTime(); entity.NGAY_BANHANH = fc["NGAY_BANHANH"].ToDateTime(); entity.NGUOIKY = !string.IsNullOrEmpty(fc["NGUOIKY"]) ? fc["NGUOIKY"].Trim() : string.Empty; entity.CHUCVU = !string.IsNullOrEmpty(fc["CHUCVU"]) ? fc["CHUCVU"].Trim() : string.Empty; entity.NOIDUNG = !string.IsNullOrEmpty(fc["NOIDUNGVANBAN"]) ? fc["NOIDUNGVANBAN"].Trim() : string.Empty; entity.DOMAT_ID = fc["DOMAT_ID"].ToIntOrZero(); entity.SOVANBANDEN_ID = fc["SOVANBANDEN_ID"].ToIntOrZero(); entity.SODITHEOSO = fc["SODITHEOSO"].Trim(); entity.NGAYCONGTAC = fc["NGAYCONGTAC"].ToDateTime(); entity.GIO_CONGTAC = fc["GIO_CONGTAC"].ToIntOrNULL(); entity.PHUT_CONGTAC = fc["PHUT_CONGTAC"].ToIntOrNULL(); entity.SODITHEOSO_NUMBER = int.Parse(entity.SODITHEOSO); entity.MA_DANGKY = fc["MA_DANGKY"]; entity.LOAI_COQUAN_ID = fc["LOAI_COQUAN_ID"].ToIntOrNULL(); entity.SO_BAN = fc["SO_BAN"].ToIntOrNULL(); entity.THONGTIN_LOAI_ID = fc["THONGTIN_LOAI_ID"].ToIntOrNULL(); entity.TACGIA = fc["TACGIA"]; entity.CONGVAN_DEN_ID = fc["CONGVAN_DEN_ID"].ToIntOrNULL(); entity.THOIHAN_GIAIQUYET = fc["THOIHAN_GIAIQUYET"].ToDateTime(); List <long> ListUser = new List <long>(); ListUser.Add(currentUser.ID); if (entity.ID == 0) { entity.NGAYTAO = DateTime.Now; entity.NGUOITAO = currentUser.ID; entity.NGAYSUA = DateTime.Now; entity.NGUOISUA = currentUser.ID; hscvVanBanDenBusiness.Save(entity); #region insert elastic search ElasticModel model = ElasticModel.ConvertVanBanDen(entity, ListUser); ElasticSearch.insertDocument(model, model.Id.ToString(), ElasticType.VanBanDen); #endregion JsonResultBO processResult = wfProcessBusiness.AddFlow(entity.ID, MODULE_CONSTANT.VANBANDEN, currentUser); if (processResult.Status) { uploadFileTool.UploadFiles(filebase, extensionOfVanBanDen.Split(',').ToList(), uploadFolder, filename, entity.ID, LOAITAILIEU.VANBANDEN, maxSizeOfVanBanDen, currentUser); } //cập nhật số đi theo sổ dmDanhMucDataBusiness.UpdateSoVanBan(entity.SOVANBANDEN_ID.GetValueOrDefault(), entity.SODITHEOSO.ToIntOrZero()); } else { HSCV_VANBANDEN dbEntity = hscvVanBanDenBusiness.Find(entity.ID); dbEntity.SOHIEU = entity.SOHIEU; dbEntity.TRICHYEU = entity.TRICHYEU; dbEntity.SOTRANG = entity.SOTRANG; dbEntity.DONVI_ID = entity.DONVI_ID; dbEntity.LOAIVANBAN_ID = entity.LOAIVANBAN_ID; dbEntity.LINHVUCVANBAN_ID = entity.LINHVUCVANBAN_ID; dbEntity.DOKHAN_ID = entity.DOKHAN_ID; dbEntity.NGAY_HIEULUC = entity.NGAY_HIEULUC; dbEntity.NGAYHET_HIEULUC = entity.NGAYHET_HIEULUC; dbEntity.NGAY_VANBAN = entity.NGAY_VANBAN; dbEntity.NGAY_BANHANH = entity.NGAY_BANHANH; dbEntity.NGUOIKY = entity.NGUOIKY; dbEntity.CHUCVU = entity.CHUCVU; dbEntity.NOIDUNG = entity.NOIDUNG; dbEntity.DOMAT_ID = entity.DOMAT_ID; dbEntity.NGAYCONGTAC = entity.NGAYCONGTAC; dbEntity.SOVANBANDEN_ID = entity.SOVANBANDEN_ID; dbEntity.SODITHEOSO = entity.SODITHEOSO; dbEntity.SODITHEOSO_NUMBER = entity.SODITHEOSO_NUMBER; dbEntity.GIO_CONGTAC = entity.GIO_CONGTAC; dbEntity.PHUT_CONGTAC = entity.PHUT_CONGTAC; dbEntity.MA_DANGKY = entity.MA_DANGKY; dbEntity.LOAI_COQUAN_ID = entity.LOAI_COQUAN_ID; dbEntity.SO_BAN = entity.SO_BAN; dbEntity.THONGTIN_LOAI_ID = entity.THONGTIN_LOAI_ID; dbEntity.TACGIA = entity.TACGIA; dbEntity.CONGVAN_DEN_ID = entity.CONGVAN_DEN_ID; dbEntity.THOIHAN_GIAIQUYET = entity.THOIHAN_GIAIQUYET; dbEntity.NGUOINHAN_TRUCTIEP_IDS = entity.NGUOINHAN_TRUCTIEP_IDS; dbEntity.NGAYSUA = DateTime.Now; dbEntity.NGUOISUA = currentUser.ID; hscvVanBanDenBusiness.Save(dbEntity); uploadFileTool.UploadFiles(filebase, extensionOfVanBanDen.Split(',').ToList(), uploadFolder, filename, dbEntity.ID, LOAITAILIEU.VANBANDEN, maxSizeOfVanBanDen, currentUser); #region update elastic ElasticModel model = ElasticModel.ConvertVanBanDen(dbEntity, ListUser); ElasticSearch.updateDocument(model, model.Id.ToString(), ElasticType.VanBanDen); #endregion } return(RedirectToAction("DetailVanBanDen", new { id = entity.ID })); } catch (Exception ex) { return(RedirectToAction("Index")); } }
// Return a Model Object with index View and fill the data from Assets / Database public ActionResult Index([FromBody] OIDCRequest request) { // Model Object Declerations ParentModel obj = new ParentModel(); Form9035 form = new Form9035(); Lists allLists = new Lists(); OrchestratorAPI api = new OrchestratorAPI(); // Add starting point on ES ElasticSearch es = new ElasticSearch(); string bal_no = ""; ViewBag.id_no = ""; string errorMessage = ""; try { AppSettingsValues appKeys = GetAppSettings.GetAppSettingsValues(); string url = Request.Url.ToString(); // LOCAL USE : Comment this 2 lines whenever you need to publish and push the code these are only for local use // add the case no. and the id no. whenever you're debugging and using this as local if (url.Contains("localhost")) { //for staging localhost request.State = "'+bal_no=1615.54312.7;id_no=BOT0001711;-5791a545d45a92763d8216ffb7004e3ebc32226af366113cf24975ea00014d51+"; //localhost request.State = "'+bal_no=91.147449.2;id_no=43383;-5791a545d45a92763d8216ffb7004e3ebc32226af366113cf24975ea00014d51+"; request.Code = "182635"; } TempData["Error"] = ""; string filter = ""; string encryptedData = ""; string decodeData = ""; string data = ""; string ListencryptedData = ""; if ((request.Code != null && request.Code != "") && (request.State != null && request.State != "")) { // GET The username which try to access this page string sUserName = null; if (url.Contains("localhost")) { sUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; } else { sUserName = User.Identity.Name; } // Extract the username from the identity Log.Info("The User identity Name is : " + sUserName); string[] spliUser = sUserName.Split('\\'); sUserName = spliUser[1]; Log.Info("The User Name is : " + sUserName); // Split the request string and extract BAL Number and ID Number string stateStr = request.State.ToString().Substring(2); string[] stateArray = stateStr.Split('-'); string splitArray = stateArray[0].Replace(";", "&"); NameValueCollection queryString = HttpUtility.ParseQueryString(splitArray); bal_no = queryString["bal_no"].ToString(); // Save into ViewBags for JS Use ViewBag.id_no = queryString["id_no"]; ViewBag.bal_no = bal_no; ViewBag.email_id = sUserName; // Entry point on ES if (es.AddESLog(ViewBag.bal_no, ViewBag.id_no, out errorMessage) == HttpStatusCode.BadRequest) { Log.Info(bal_no + ": Process : Draft9089 - Error Occurred while Calling ES. See ES Log File for further details"); } // Getting UIPATH Token string token = api.Authentication(appKeys.isDevelopmentEnvironment); Log.Info("Bal Number : " + bal_no + " Process : Draft 9035 Page Loading, Message : All variables has been initialized successfully."); // get n check if asset exist filter = "?$filter=Name eq '" + bal_no + "'"; AssetModel assetModel = api.GetAsset(token, filter); // Extracting the Encrypted Data String foreach (var item in assetModel.value) { // 9035 Model Value if (!item.Name.Contains("Lists")) { if (encryptedData == "") { encryptedData = item.Value; } else { encryptedData += item.Value; } } // List Model Value else if (item.Name.Contains("Lists")) { if (ListencryptedData == "") { ListencryptedData = item.Value; } else { ListencryptedData += item.Value; } } } // decode and deserialize data if exists form9035 object if (encryptedData != "") { // 9035 Object Decryption decodeData = SecureData.AesDecryptString(appKeys.SecretKey, encryptedData); if (decodeData != "") { data = CompressString.Unzip(decodeData); form = JsonConvert.DeserializeObject <Form9035>(data); Log.Info("Bal Number : " + bal_no + " Process : Draft 9035 Page Loading, Message : Form9035 Data has been decrypted successfully."); } } // List Object Data Decryption if (!string.IsNullOrEmpty(ListencryptedData)) { decodeData = SecureData.AesDecryptString(appKeys.SecretKey, ListencryptedData); if (decodeData != "") { data = CompressString.Unzip(decodeData); allLists = JsonConvert.DeserializeObject <Lists>(data); Log.Info("Bal Number : " + bal_no + " Process : Draft 9035 Page Loading, Message : Lists Data has been decrypted successfully."); } } // if data not exist check from SQL if (assetModel.value.Count <= 0) { //string query = @"select * from BAL9035"; // string query = @"select * from BAL9035 where BALNumber='20000.50054.51'"; string query = @"select c.CompanyName, c.CompanyNumber, c.IsH1BDependent as 'Company H-1B Dependent', ce.EntityName as 'Sponsoring Entity', ce.IsH1BDependent as 'Entity H-1B Dependent', b.MatterNumber, b.FullName as 'Beneficiary', b.JobPosition as 'Beneficiary Job Title', cc.BALNumber, cst.CaseSubType, --max of 6 lca.SocCode, lca.SocOccupation, lca.BeginOfValidity, lca.EndOfValidity, lca.WageRangeLow, lca.WageRangeHigh, lca.WageLevel, lca.NumberOfPositions, bt1.StaffFirstName as 'Attorney First Name', bt1.StaffMiddleName as 'Attorney Middle Name', bt1.StaffLastName as 'Attorney Last Name', bt1.StaffEmail as 'Attorney Email', bt2.StaffFirstName as 'Assistant First Name', bt2.StaffMiddleName as 'Assistant Middle Name', bt2.StaffLastName as 'Assistant Last Name', bt2.StaffEmail as 'Assistant Email', bt3.ContactFirstName as 'Signer First Name', bt3.ContactMiddleName as 'Signer Middle Name', bt3.ContactLastName as 'Signer Last Name', bt3.JobTitle as 'Signer Job', ca.AddressLine1, ca.AddressLine2, ca.Suite, ca.City, ca.State, ca.ZipCode, l.PrevailingWage, l.PrevailingWageSource, l.PrevailingWagePublishedYear, l.PrevailingWageOther, p.BALNumber as 'Parent Case Number', ps.CaseSubType as 'ParentCaseSubType' from ClientCase cc inner join Beneficiary b on b.beneid = cc.BeneId inner join Company c on c.CompanyId = b.CompanyId inner join LCADetail lca on lca.CaseId = cc.CaseId left join CompanyEntity ce on ce.CompanyEntityId = cc.SponsorEntityId inner join casecontacts cc1 (nolock) on cc.caseid = cc1.caseid and cc1.casecontacttype = 'BAL_MANAGER' and cc1.isprimary = 1 inner join balteam bt1 (nolock) on cc1.userid = bt1.userid inner join casecontacts cc2 (nolock) on cc.caseid = cc2.caseid and cc2.casecontacttype = 'BAL_ASSISTANT' and cc2.isprimary = 1 inner join balteam bt2 (nolock) on cc2.userid = bt2.userid left join casecontacts cc3 (nolock) on cc.caseid = cc3.caseid and cc3.casecontacttype = 'SIGNER' left join CompanyContacts bt3 (nolock) on cc3.userid = bt3.userid --inner join CaseAddress a on a.CaseId = cc.CaseId left join CaseCompanyAddressLink l on l.CaseId = cc.CaseId left join CompanyAddress ca on ca.CompanyAddressId = l.CompanyAddressId inner join CaseSubTypeRel r on r.CaseId = cc.CaseId inner join CaseSubTypes cst on cst.MetaDataId = r.MetaDataId left join ClientCase p on cc.ParentCaseId = p.CaseId left join CaseSubTypeRel pr on pr.CaseId = p.CaseId left join CaseSubTypes ps on ps.MetaDataId = pr.MetaDataId where CC.BALNumber = '" + bal_no + "' order by cc.BALNumber"; //20000.55.52,20000.50054.51 // Calling db object and sending the query and returning the DataTable Database db = new Database(); DataTable dt = db.SqlSelect(query); // If Results found map data else send Error message if (dt.Rows.Count > 0) { // Mapping DataTable to the 9035 and Lists object MapDbData dbData = new MapDbData(); form = dbData.MapdbResult(dt); allLists = dbData.CreateLists(dt, bal_no); dbData.AssignValue(form, allLists.parentCaseSubTypes); Log.Info("Bal Number : " + bal_no + " Process : Draft 9035 Page Loading, Message : Data from SQL Query has been generated successfully."); } else { Log.Info("Bal Number : " + bal_no + ": Process : Draft9035 - No Data Found from the SQL Query."); TempData["Error"] = "You have entered an invalid case matter number. Please submit a new request with the correct matter number"; es.AddErrorESLog(ViewBag.id_no, "Business", "No Data Found from the SQL Query.", out errorMessage); api.AddErrorQueueItem(ViewBag.id_no, TempData["Error"].ToString(), "Business", TempData["Error"].ToString(), "Failed", bal_no); return(RedirectToAction("Error")); } } // Second Asset check n if it is submit case (NOT IN USE) //ViewBag.isSubmit = false; //filter = "?$filter=Name eq '" + ViewBag.id_no + "'"; //AssetModel idModel = api.GetAsset(token, filter); //if (idModel.value.Count > 0 && assetModel.value.Count > 0) //{ // foreach (var item in idModel.value) // { // if (item.Name == ViewBag.id_no) // { // ViewBag.isSubmit = true; // } // } //} //form.isSubmit = false; obj.Form9035 = form; obj.Lists = allLists; Log.Info("Bal Number : " + bal_no + " Process : Draft 9035 Page Loading, Message : Process has been executued successfully returning an object to View."); return(View(obj)); } else { throw new Exception("HTTP Web Request Failed. The data in the URL is not found."); } } catch (Exception ex) { TempData["Error"] = "Sorry, there seems to be an issue with your request. Please send an email to #automationinfo with your ServiceNow ticket number and we will contact you shortly"; Log.Error(ex, bal_no); es.AddErrorESLog(ViewBag.id_no, "Technical", ex.Message, out errorMessage); api.AddErrorQueueItem(ViewBag.id_no, ex.Message, "Technical", ex.Message, "In Progress", bal_no); return(RedirectToAction("Error")); } }
// POST: api/AddCredentials // Create the Credential Asset on UIPATH Orchestrator public IHttpActionResult Post([FromBody] CredentialAsset bodyModel) { string assetResponse = ""; Response outResponse = new Response(); OrchestratorAPI api = new OrchestratorAPI(); ElasticSearch es = new ElasticSearch(); string logMsg = ""; string errorMessage = ""; try { // Check if the Input Parameters has all the values or not if (string.IsNullOrEmpty(bodyModel.Username) && string.IsNullOrEmpty(bodyModel.Password) && string.IsNullOrEmpty(bodyModel.Name) && string.IsNullOrEmpty(bodyModel.Email)) { outResponse.success = false; outResponse.message = "Sorry, there seems to be an issue with your request. Please send an email to #automationinfo with your ServiceNow ticket number and we will contact you shortly."; assetResponse = JsonConvert.SerializeObject(outResponse); logMsg = "Bal Number : " + bodyModel.Name + ", Proecess : Create Credential Asset, Message : Parameter : Username : "******"Password : "******" Name : " + bodyModel.Name + " Email : " + bodyModel.Email + " : Parameter is required."; Log.Info(logMsg); es.AddErrorESLog(bodyModel.Name, "Technical", "Credential Asset Parameter Missing", out errorMessage); api.AddErrorQueueItem(bodyModel.Name, "Credential Asset Parameter Missing", "Technical", "Credential Asset Parameter Missing", "In Progress"); return(Json(assetResponse)); } string filter = ""; // Get the Config from AppSettings AppSettingsValues appKeys = GetAppSettings.GetAppSettingsValues(); // UIPATH TOKEN string token = api.Authentication(appKeys.isDevelopmentEnvironment); // Send error message if the token is null if (string.IsNullOrEmpty(token)) { outResponse.success = false; outResponse.message = "Sorry, there seems to be an issue with your request. Please send an email to #automationinfo with your ServiceNow ticket number and we will contact you shortly."; logMsg = "Bal Number : " + bodyModel.Name + ", Proecess : Create Credential Asset, Message : You are not been able to authenticated. Token : " + token; Log.Info(logMsg); es.AddErrorESLog(bodyModel.Name, "Technical", "UIPATH Token not generated. Authentication Failed.", out errorMessage); api.AddErrorQueueItem(bodyModel.Name, "UIPATH Token not generated. Authentication Failed.", "Technical", "UIPATH Token not generated. Authentication Failed.", "In Progress"); } else { // get n check if asset exist filter = "?$filter=Name eq '" + bodyModel.Name + "'"; AssetModel assetModel = api.GetAsset(token, filter); // create or update asset Dictionary <string, object> assetBody = new Dictionary <string, object>(); assetBody.Add("Name", bodyModel.Name); assetBody.Add("ValueScope", "Global"); assetBody.Add("ValueType", "Credential"); assetBody.Add("StringValue", "no idea"); assetBody.Add("CredentialUsername", bodyModel.Username); assetBody.Add("CredentialPassword", bodyModel.Password); assetResponse = api.CreateAsset(assetModel, token, assetBody); // get n check if asset exist assetModel = api.GetAsset(token, filter); if (assetModel.value.Count > 0) { // Gets user old records and sets the new updated key against it string esKeyID = ""; // gets the KeyID string[] esResults = es.GetESKey(bodyModel.Email, appKeys.LookupKey, out errorMessage); string initalKeyID = ""; if (esResults != null) { initalKeyID = esResults[1]; } // Set the SecretKey against the KeyID es.SetESKey(initalKeyID, bodyModel.Email, bodyModel.SecretKey, appKeys.LookupKey, out errorMessage, out esKeyID); outResponse.success = true; outResponse.message = esKeyID; logMsg = "Bal Number : " + bodyModel.Name + " Process : Create Credential Asset, Message : The method has been successfully exexuted."; Log.Info(logMsg); } else { outResponse.success = false; outResponse.message = "Sorry, there seems to be an issue with your request. Please send an email to #automationinfo with your ServiceNow ticket number and we will contact you shortly."; logMsg = "Bal Number : " + bodyModel.Name + " Process : Create Credential Asset, Message : The asset has not been found"; Log.Info(logMsg); es.AddErrorESLog(bodyModel.Name, "Technical", "The Credential Asset has not been created", out errorMessage); api.AddErrorQueueItem(bodyModel.Name, "The Credential Asset has not been created", "Technical", "The Credential Asset has not been created", "In Progress"); } } } catch (Exception ex) { outResponse.success = false; outResponse.message = "Sorry, there seems to be an issue with your request. Please send an email to #automationinfo with your ServiceNow ticket number and we will contact you shortly."; Log.Error(ex, bodyModel.Name); es.AddErrorESLog(bodyModel.Name, "Technical", ex.Message, out errorMessage); api.AddErrorQueueItem(bodyModel.Name, ex.Message, "Technical", ex.Message, "In Progress"); } assetResponse = JsonConvert.SerializeObject(outResponse); return(Json(assetResponse)); }
public configurationController( IApplicationLifetime applicationLifetime, IWritableOptions <General> general_options, IWritableOptions <Database> database_options, IWritableOptions <Comments> comment_options, IWritableOptions <Smtp> smtp_options, IWritableOptions <Media> media_options, IWritableOptions <Features> features_options, IWritableOptions <Listing> listings_options, IWritableOptions <Authentication> authentication_options, IWritableOptions <Registration> registration_options, IWritableOptions <Aws> aws_options, IWritableOptions <Social> social_options, IWritableOptions <Contact> contact_options, IWritableOptions <Rechapcha> rechapcha_options, IWritableOptions <ElasticSearch> elasticsearch_options, IWritableOptions <ActiveCompaign> activecompany_options, IWritableOptions <Zendesk> zendesk_options, IOptions <General> generalSettings, IOptions <Comments> commentSettings, IOptions <Smtp> smtpSettings, IOptions <Media> mediaSettings, IOptions <Features> featureSettings, IOptions <Listing> listingSettings, IOptions <Authentication> authenticationSettings, IOptions <Registration> registrationSettings, IOptions <Aws> awsSettings, IOptions <Social> socialSettings, IOptions <Contact> contactSettings, IOptions <Rechapcha> rechapchaSettings, IOptions <ElasticSearch> elasticSearchSettings, IOptions <Zendesk> zendeskSettings, IOptions <ActiveCompaign> activeSettings, IOptions <Jugnoon.Blogs.Settings.General> blogs_general_Settings, IOptions <Jugnoon.Blogs.Settings.Aws> blogs_aws_Settings, ApplicationDbContext context ) { _context = context; // writable injectors _database_options = database_options; _general_options = general_options; _comment_options = comment_options; _smtp_options = smtp_options; _media_options = media_options; _features_options = features_options; _listings_options = listings_options; _authentication_options = authentication_options; _registration_options = registration_options; _aws_options = aws_options; _social_options = social_options; _contact_options = contact_options; _rechapcha_options = rechapcha_options; _elasticsearch_options = elasticsearch_options; _activecompaign_options = activecompany_options; _zendesk_options = zendesk_options; ApplicationLifetime = applicationLifetime; // readable injectors _generalSettings = generalSettings.Value; _commentSettings = commentSettings.Value; _smtpSettings = smtpSettings.Value; _mediaSettings = mediaSettings.Value; _featureSettings = featureSettings.Value; _listingSettings = listingSettings.Value; _authenticationSettings = authenticationSettings.Value; _registrationSettings = registrationSettings.Value; _awsSettings = awsSettings.Value; _socialSettings = socialSettings.Value; _contactSettings = contactSettings.Value; _rechapchaSettings = rechapchaSettings.Value; _elasticSearchSettings = elasticSearchSettings.Value; _zendeskSettings = zendeskSettings.Value; _activeSettings = activeSettings.Value; _blogs_general_Settings = blogs_general_Settings.Value; _blogs_aws_Settings = blogs_aws_Settings.Value; }