public bool DeleteSalesOrder() { Config config = ConfigJSON.Read(); NavIntegrationService services = _context.NavIntegrationService.FirstOrDefault(x => x.IntegrationType == "SalesInvoicePost"); string url = config.NavApiBaseUrl + "/" + config.NavPath + $"/companies({config.NavCompanyId})/{services.ServiceName}"; var client = NAV.NAVClient(url, config); var request = new RestRequest(Method.GET); request.AddHeader("Content-Type", "application/json"); IRestResponse <SyncModel <NavSalesInvoice> > response = client.Execute <SyncModel <NavSalesInvoice> >(request); if (response.StatusCode == HttpStatusCode.OK) { foreach (var sOrder in response.Data.value) { //delete first if already exist string urlDelete = url + "(" + sOrder.id + ")"; var clientDelete = NAV.NAVClient(urlDelete, config); var requestDelete = new RestRequest(Method.DELETE); requestDelete.AddHeader("Content-Type", "application/json"); IRestResponse responseDelete = clientDelete.Execute(requestDelete); } return(true); } else { return(false); } }
public List <companies> GetCompaniesList() { List <companies> companiesCardList = new List <companies>(); try { Config mainConfig = ConfigJSON.Read(); config.Default_Config.Username = mainConfig.Default_Config.Username; config.Default_Config.Password = mainConfig.Default_Config.Password; config.Default_Config.Type = mainConfig.Default_Config.Type; config.Default_Config.Company_Name = mainConfig.Default_Config.Company_Name; companies_Filter[] filters = new companies_Filter[0]; companiesCardList = Companies_PortClientService() .ReadMultipleAsync(filters, "", 0) .GetAwaiter() .GetResult() .ReadMultiple_Result1 .ToList(); } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } return(companiesCardList); }
public IActionResult SchedulerSetup() { ViewData["Scheduler"] = ConfigJSON.Read(); IList <CustomerViewModel> customer; _cache.TryGetValue("Customers", out customer); if (customer != null) { ViewData["IsCustomerCache"] = true; ViewData["CustomerCacheCount"] = customer.Count(); } else { ViewData["IsCustomerCache"] = false; } IList <ItemViewModel> item; _cache.TryGetValue("ItemViewModel", out item); if (item != null) { ViewData["IsItemCache"] = true; ViewData["ItemCacheCount"] = item.Count(); } else { ViewData["IsItemCache"] = false; } return(View()); }
public IActionResult Submit() { Config config = ConfigJSON.Read(); ViewBag.IsForRemit = config.Default_Config.IsForRemit; return(View()); }
public IActionResult GetClientComputerName(string ip) { try { Config config = ConfigJSON.Read(); string url = "http://" + ip + ":" + config.ClientPort + "/POSClient/GetComputerName"; var client = new RestSharp.RestClient(url); var request = new RestSharp.RestRequest(RestSharp.Method.GET); request.AddHeader("Access-Control-Allow-Origin", "*"); RestSharp.IRestResponse response = client.Execute(request); string pcName = response.Content.Replace("\"", ""); int terminalId = 0; //check if terminal is assigned TerminalMapping terminalMapping = _context.TerminalMapping.FirstOrDefault(x => x.PCName == pcName); Terminal terminal = new Terminal(); if (terminalMapping != null) { terminal = _context.Terminal.FirstOrDefault(x => x.Id == terminalMapping.TerminalId); } return(Ok(new { pcName = pcName, terminalId = terminalMapping.TerminalId.ToString(), terminalName = terminal?.Name })); } catch (Exception ex) { return(StatusCode(500)); } }
public integrationservice_PortClient Integrationservice_PortClientService() { BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm; basicHttpBinding.MaxReceivedMessageSize = int.MaxValue; Config config = ConfigJSON.Read(); NetworkCredential credential = new NetworkCredential { UserName = config.Default_Config.Username, Password = config.Default_Config.Password, Domain = config.Integration_Setup.Domain }; EndpointAddress endpoint = new EndpointAddress( config.URL + config.Default_Config.Integration_Services.Where(x => x.Integration_Type == "Integration_Service").FirstOrDefault().Service_Name); var client = new integrationservice_PortClient(basicHttpBinding, endpoint); client.ClientCredentials.Windows.ClientCredential = credential; client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; return(client); }
private hrmgt_PortClient Hrmgt_PortClientService() { credential.UserName = User.Identity.GetUserName(); credential.Password = User.Identity.GetPassword(); credential.Domain = config.Integration_Setup.Domain; config.Default_Config.Company_Name = User.Identity.GetCompanyName(); var integrationService = config.Integration_Services .Where(x => x.Integration_Type == "HrMgt" && x.Company_Name == config.Default_Config.Company_Name) .FirstOrDefault(); config.Default_Config.Type = integrationService.Type; string URL = ConfigJSON.GetURL(config, integrationService.Service_Name); EndpointAddress endpoint = new EndpointAddress(URL); var client = new hrmgt_PortClient(basicHttpBinding, endpoint); client.ClientCredentials.Windows.ClientCredential = credential; client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; return(client); }
public IActionResult SchedulerSetup([FromBody] SchedulerDuration data) { Config config = ConfigJSON.Read(); config.SchedulerDuration = data; ConfigJSON.Write(config); return(Ok()); }
public IActionResult BrowserClose() { Config config = ConfigJSON.Read(); config.LoggedInUsers.Remove(User.Identity.Name); ConfigJSON.Write(config); return(Ok()); }
public IActionResult APISetup([FromBody] Config data) { Config config = ConfigJSON.Read(); data.SchedulerDuration = config.SchedulerDuration; data.ClientPort = config.ClientPort; data.Environment = config.Environment; ConfigJSON.Write(data); return(Ok()); }
public IEnumerable <Line> GetLines(ConfigJSON json) { using (DataContext dataContext = new DataContext("systemSettings")) { string assetKey = (json != null ? (json.AssetKey ?? "%") : "%"); int id = (json != null ? (json.ID == null ? -1 : int.Parse(json.ID)) : -1); DataTable table = dataContext.Connection.RetrieveData("Select * FROM Line WHERE AssetKey LIKE {0} " + (id != -1 ? "AND ID LIKE {1}" : ""), assetKey, id); return(table.Select().Select(row => dataContext.Table <Line>().LoadRecord(row)).ToList()); } }
public IActionResult Index([FromBody] Setting setting) { if (ModelState.IsValid) { Config config = ConfigJSON.Read(); config.Environment = setting.Environment; config.NavCompanyId = setting.CompanyId; ConfigJSON.Write(config); } return(RedirectToAction("Index")); }
public IEnumerable<Channel> GetChannelsByMeter(ConfigJSON json) { using (DataContext dataContext = new DataContext("systemSettings")) { string assetKey = (json != null ? (json.AssetKey ?? "%") : "%"); int id = (json != null ? (json.ID == null ? -1 : int.Parse(json.ID)) : -1); string name = (json != null ? (json.Name ?? "%") : "%"); DataTable table = dataContext.Connection.RetrieveData("Select * FROM Channel WHERE MeterID IN (Select ID FROM Meter WHERE AssetKey LIKE {0} AND " + (id != -1 ? "ID LIKE {1} AND " : "") + "NAME LIKE {2})", assetKey, id, name); return table.Select().Select(row => dataContext.Table<Channel>().LoadRecord(row)).ToList(); } }
public IEnumerable <Meter> GetMeters(ConfigJSON json) { using (DataContext dataContext = new DataContext("systemSettings")) { string assetKey = (json != null ? (json.AssetKey ?? "%") : "%"); int id = (json != null ? (json.ID == null ? -1: int.Parse(json.ID)) : -1); string name = (json != null ? (json.Name ?? "%") : "%"); DataTable table = dataContext.Connection.RetrieveData("Select * FROM Meter WHERE AssetKey LIKE {0} AND " + (id != -1? "ID LIKE {1} AND ": "") + "NAME LIKE {2}", assetKey, id, name); return(table.Select().Select(row => dataContext.Table <Meter>().LoadRecord(row)).ToList()); } }
static ConfigWD() { var configWD = @"configWD.json"; if (File.Exists(configWD)) { using (StreamReader r = new StreamReader(configWD)) { string json = r.ReadToEnd(); cfg = JsonConvert.DeserializeObject <ConfigJSON>(json); } } }
/// <summary> /// Конструктор. /// </summary> static ConfigWD() { var configWD = @"wd.config"; if (File.Exists(configWD)) { using (StreamReader r = new StreamReader(configWD)) { var json = r.ReadToEnd(); _cfgJson = JsonConvert.DeserializeObject <ConfigJSON>(json); } } }
public void PostUnSyncInvoie(Store store) { Config config = ConfigJSON.Read(); var unSyncInvoice = _context.SalesInvoice.Where(x => x.IsNavPosted == false); //update isnavsync to false then restart scheduling job bool flag = UpdateIsNavSyncStatus(unSyncInvoice); if (flag == false) { return; } PostSalesInvoice(store); }
void Awake() { if (File.Exists(RConfigPath)) { configData = ConfigJSON.LoadFromJSON <ConfigData>(RConfigPath); } else { // Provide a form of Config recreation either an individual template file or just create an empty when no config is available ConfigJSON.SaveToJSON <ConfigData>(RConfigPath, new ConfigData()); Debug.LogError("No config data available in " + RConfigPath + " a new empty config was created please fill out the empty parameter"); System.Console.WriteLine("No config data available in " + RConfigPath + " a new empty config was created please fill out the empty parameter"); Application.Quit(); } }
public void setContext() { Config config = ConfigJSON.Read(); if (!string.IsNullOrEmpty(config.Environment)) { var con = Configuration.GetConnectionString(config.Environment + "Connection"); if (con != _context.Database.GetDbConnection().ConnectionString) { var options = new DbContextOptionsBuilder <EntityCore>(); options.UseSqlServer(con); _context = new EntityCore(options.Options); } } }
private void SaveConfig() { string mediaFiles = string.Join(", ", MediaPlayList); ConfigJSON["top"] = Top; ConfigJSON["mediaFileList"] = mediaFiles; ConfigJSON["left"] = Left; ConfigJSON["width"] = Width; ConfigJSON["height"] = Height; ConfigJSON["lastMediaFileName"] = (LastMediaFileName == null)?"":LastMediaFileName; ConfigJSON["lastMediaPosition"] = LastMediaPosition; ConfigJSON["volume"] = Volume; ConfigJSON["currentFileIndex"] = CurrentFileIndex; File.WriteAllText(ConfigFileName, ConfigJSON.ToString()); }
public async Task <IActionResult> LogOff() { Config config = ConfigJSON.Read(); config.LoggedInUsers.Remove(User.Identity.Name); ConfigJSON.Write(config); await _signInManager.SignOutAsync(); // _logger.LogInformation(4, "User logged out."); Response.Cookies.Append(User.Identity.Name, "", new CookieOptions() { Expires = DateTime.Now.AddDays(-1) }); return(RedirectToAction("Login", "Account")); }
public IActionResult NAVTestConnection() { Config config = ConfigJSON.Read(); NavSync sync = new NavSync(_context, _mapper, _userManager, _roleManager, _cache, Configuration); var result = sync.TestNavConnection(); if (result is string && result != "Success") { return(StatusCode(500, result)); } if (result.Count() > 0) { return(Ok(result)); } else { return(StatusCode(500, result)); } }
public IActionResult UpdateIntegrationSetup() { try { integrationsetup_Filter[] filter = new integrationsetup_Filter[0]; integrationsetup result = Integrationsetup_PortClientService() .ReadMultipleAsync(filter, "", 0) .GetAwaiter() .GetResult() .ReadMultiple_Result1 .FirstOrDefault(); Config config = ConfigJSON.Read(); config.Integration_Setup = new Integration_Setup { Base_URL = result.Base_URL.Remove(result.Base_URL.Length - 1) + ':' + result.Port, Service_Instance = result.Service_Instance, Domain = result.Domain.Remove(result.Domain.Length - 1), Integration_Name = "WS" }; config.URL = config.Integration_Setup.Base_URL + '/' + config.Integration_Setup.Service_Instance + '/' + config.Integration_Setup.Integration_Name + '/' + config.Default_Config.Company_Name + '/' + config.Default_Config.Type + '/'; ConfigJSON.Write(config); return(StatusCode(Convert.ToInt32(HttpStatusCode.OK), result)); } catch (Exception ex) { return(StatusCode(Convert.ToInt32(HttpStatusCode.InternalServerError), ex.Message)); } }
public IActionResult UpdateIntegrationServices() { try { integrationservice_Filter[] filter = new integrationservice_Filter[0]; var oldResult = Integrationservice_PortClientService() .ReadMultipleAsync(filter, "", 0) .GetAwaiter() .GetResult(); var newResult = oldResult.ReadMultiple_Result1; var result = newResult.ToList(); Config config = ConfigJSON.Read(); List <Integration_Service> integration_Services = new List <Integration_Service>(); foreach (var item in result) { integration_Services.Add( new Integration_Service { Integration_Type = item.Integration_Type.ToString(), Service_Name = item.Service_Name, Type = item.Type.ToString(), Company_Name = item.Company_Name }); } config.Integration_Services = integration_Services.ToArray(); ConfigJSON.Write(config); return(StatusCode(Convert.ToInt32(HttpStatusCode.OK), result)); } catch (Exception ex) { return(StatusCode(Convert.ToInt32(HttpStatusCode.InternalServerError), ex.Message)); } }
private void LoadConfig() { string mediaList = ""; if (File.Exists(ConfigFileName)) { ConfigJSON = JObject.Parse(File.ReadAllText(ConfigFileName)); } else { ConfigJSON = JObject.Parse(CreateConfigFile(ConfigFileName)); } Top = ConfigJSON.GetValue("top").Value <int>(); Left = ConfigJSON.GetValue("left").Value <int>(); Width = ConfigJSON.GetValue("width").Value <int>(); Height = ConfigJSON.GetValue("height").Value <int>(); Volume = ConfigJSON.GetValue("volume").Value <int>(); LastMediaFileName = ConfigJSON.GetValue("lastMediaFileName").Value <string>(); LastMediaPosition = ConfigJSON.GetValue("lastMediaPosition").Value <double>(); CurrentFileIndex = ConfigJSON.GetValue("currentFileIndex").Value <int>(); mediaList = ConfigJSON.GetValue("mediaFileList").Value <string>(); MediaPlayList = mediaList.Split(',').ToList(); }
public companies_PortClient Companies_PortClientService() { credential.UserName = config.Default_Config.Username; credential.Password = config.Default_Config.Password; credential.Domain = config.Integration_Setup.Domain; var integrationService = config.Default_Config.Integration_Services .Where(x => x.Integration_Type == "Company") .FirstOrDefault(); config.Default_Config.Type = integrationService.Type; string URL = ConfigJSON.GetURL(config, integrationService.Service_Name); EndpointAddress endpoint = new EndpointAddress(URL); var client = new companies_PortClient(basicHttpBinding, endpoint); client.ClientCredentials.Windows.ClientCredential = credential; client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; return(client); }
public IActionResult UpdateDefaultSetup(ConfigSetup obj) { try { if (ModelState.IsValid) { Config config = ConfigJSON.Read(); config.Default_Config.Username = obj.Username; config.Default_Config.Password = obj.Password; config.Default_Config.Company_Name = obj.CompanyName; config.Default_Config.Type = obj.Type; config.Integration_Setup.Base_URL = obj.BaseURL; config.Integration_Setup.Service_Instance = obj.ServiceInstance; config.Integration_Setup.Domain = obj.Domain; config.URL = obj.BaseURL + '/' + obj.ServiceInstance + '/' + config.Integration_Setup.Integration_Name + '/' + obj.CompanyName + '/' + obj.Type + '/'; ConfigJSON.Write(config); return(StatusCode(Convert.ToInt32(HttpStatusCode.OK), config)); } return(StatusCode(Convert.ToInt32(HttpStatusCode.BadRequest), ModelState)); } catch (Exception ex) { return(StatusCode(Convert.ToInt32(HttpStatusCode.InternalServerError), ex.Message)); } }
public IActionResult RejectRequest(string travelOrderNo) { PostedTravelOrderViewModel vmObj = new PostedTravelOrderViewModel(); try { postedtravelordercard obj = new postedtravelordercard(); postedtravelordercard_Filter[] filter = { new postedtravelordercard_Filter { Field = postedtravelordercard_Fields.Travel_Order_No, Criteria = travelOrderNo } }; obj = Postedtravelordercard_PortClientService() .ReadMultipleAsync(filter, "", 1) .GetAwaiter() .GetResult() .ReadMultiple_Result1 .FirstOrDefault(); vmObj = _mapper.Map <PostedTravelOrderViewModel>(obj); } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } Config config = ConfigJSON.Read(); ViewBag.IsForRemit = config.Default_Config.IsForRemit; return(View(vmObj)); }
public bool PostBill(BillViewModel model) { try { //Thread.Sleep(100000); Config config = ConfigJSON.Read(); var client = new RestClient(config.IRDBaseUrl); var request = new RestRequest(config.IRDBillUrl, Method.POST); request.AddHeader("Content-Type", "application/json"); //post data //authentication model.username = config.IRDUserName; model.password = config.IRDPassword; request.RequestFormat = DataFormat.Json; var jsonModel = JsonConvert.SerializeObject(model); request.AddJsonBody(model); IRestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public IActionResult Submit(TravelOrderViewModel vmObj) { try { if (ModelState.IsValid) { var obj = _mapper.Map <travelordercard>(vmObj); TravelOrderCard.Create createObj = new TravelOrderCard.Create { travelordercard = obj }; createObj.travelordercard.Employee_Name = null; createObj.travelordercard.Employee_No = User.Identity.GetEmployeeNo(); createObj.travelordercard.Travel_TypeSpecified = true; createObj.travelordercard.Expenses_OnlySpecified = true; Config config = ConfigJSON.Read(); if (config.Default_Config.IsForRemit) { createObj.travelordercard.Fooding_Allowance_OnlySpecified = true; createObj.travelordercard.Lodging_Allowance_OnlySpecified = true; } else { createObj.travelordercard.Travel_Allowance_OnlySpecified = true; } createObj.travelordercard.Daily_Allowance_OnlySpecified = true; createObj.travelordercard.Depature_Date_ADSpecified = true; createObj.travelordercard.Arrival_Date_ADSpecified = true; createObj.travelordercard.Reason_for_TravelSpecified = true; createObj.travelordercard.Mode_Of_TransportationSpecified = true; createObj.travelordercard.Approved_TypeSpecified = true; createObj.travelordercard.Exchange_RateSpecified = true; createObj.travelordercard.Travel_StatusSpecified = true; createObj.travelordercard.Claimed_Local_TransportationSpecified = true; createObj.travelordercard.Claimed_FuelSpecified = true; createObj.travelordercard.Claimed_Other_ExpensesSpecified = true; var result = Travelordercard_PortClientService() .CreateAsync(createObj) .GetAwaiter() .GetResult() .travelordercard; if (result != null) { var postResult = Hrmgt_PortClientService() .PosttravelorderwebAsync(result.Travel_Order_No) .GetAwaiter() .GetResult() .return_value; if (postResult == 200) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Leave Request", text = "Travel order posted successfully.", type = "success" }); return(RedirectToAction(nameof(Index))); } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Error", text = "Travel order created but submitting failed.", type = "error" }); } } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Error", text = "Creating travel order failed. Try again.", type = "error" }); } } else { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Validation Error", text = "Insert proper values for each fields.", type = "error" }); } } catch (Exception ex) { TempData["Notify"] = JsonConvert.SerializeObject(new Notify { title = "Exception Error", text = ex.Message, type = "error" }); } return(View(vmObj)); }
public IEnumerable<Line> GetLines(ConfigJSON json) { using (DataContext dataContext = new DataContext("systemSettings")) { string assetKey = (json != null ? (json.AssetKey ?? "%") : "%"); int id = (json != null ? (json.ID == null ? -1 : int.Parse(json.ID)) : -1); DataTable table = dataContext.Connection.RetrieveData("Select * FROM Line WHERE AssetKey LIKE {0} " + (id != -1 ? "AND ID LIKE {1}" : "") , assetKey, id); return table.Select().Select(row => dataContext.Table<Line>().LoadRecord(row)).ToList(); } }
public void UpdateCacheItemViewModel() { _cache.Set("IsItemCacheInProcess", true); //update cache Config config = ConfigJSON.Read(); //split data to 1lakh and save to cache int count = 100000, skip = 0, errorCount = 0; DateTime startDate = DateTime.Now; //_context.ChangeTracker.AutoDetectChangesEnabled = false; for (; ;) { try { IList <ItemViewModel> itemsTotal = new List <ItemViewModel>(); _context.Database.SetCommandTimeout(TimeSpan.FromHours(1)); //IList<ItemViewModel> itemsTemp = _context.ItemViewModel.FromSql("SPItemViewModel @p0, @p1", count, skip).ToList(); IList <ItemViewModel> itemsTemp = _context.ItemViewModel.Skip(skip).Take(count).ToList(); if (itemsTemp.Count() > 0) { _cache.TryGetValue("ItemViewModel", out itemsTotal); if (itemsTotal == null) { itemsTotal = new List <ItemViewModel>(); } itemsTotal = itemsTotal.Concat(itemsTemp).DistinctBy(x => new { x.Bar_Code, x.Code, x.Discount, x.DiscountEndDate, x.DiscountEndTime, x.DiscountItemType, x.DiscountLocation, x.DiscountMinimumQuantity, x.DiscountSalesGroupCode, x.DiscountStartDate, x.DiscountStartTime, x.DiscountType, x.Name, x.Rate, x.RateEndDate, x.RateMinimumQuantity, x.RateStartDate, x.SalesCode, x.SalesType }).ToList(); _cache.Set("ItemViewModel", itemsTotal); } else { double totalTimeTake = (DateTime.Now - startDate).TotalMinutes; config.Environment = "Total Time take " + totalTimeTake + " Mins"; ConfigJSON.Write(config); _cache.Set("IsItemCacheInProcess", false); break; } config.Environment = itemsTotal.Count() + " item cached"; // itemsTotal = itemsTotal.Concat(itemsTemp).ToList(); skip = skip + count; // config.Environment = itemsTotal.Count() + " item cached"; ConfigJSON.Write(config); } catch (Exception ex) { if (ex.Message == "Invalid object name 'ItemViewModel'.") { _cache.Set("IsItemCacheInProcess", true); break; } if (errorCount > 5) { break; } errorCount += 1; } } }