public IActionResult DownloadExcelFromJsonfn(string fields, string data) { try { DataSet DsData = new DataSet(); DataTable DtData = SharedServices.JsonToDT(data); JArray ArryFields = JArray.Parse(fields); for (int i = 0; i < ArryFields.Count; i++) { DtData.Columns[i].ColumnName = ArryFields[i].ToString(); } for (int i = 0; i < ArryFields.Count; i++) { var name = ArryFields[i].ToString(); if (name.IndexOf(",hide") > -1) { DtData.Columns.Remove(name); } } DsData.Tables.Add(table: DtData); DownloadExcelModel excelModel = new DownloadExcelModel { DataSouece = DsData }; return(DownloadExcelFromDBfn(excelModel)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
// GET: Dashboard/Shared public JsonResult UploadImage() { JsonResult result = new JsonResult(); //result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; var PicList = new List <Picture>(); SharedServices sharedServices = new SharedServices(); try { var files = Request.Files; for (int i = 0; i < files.Count; i++) { var pictures = files[i]; var fileName = Guid.NewGuid() + Path.GetExtension(pictures.FileName); var path = Path.Combine(Server.MapPath("/images/site/"), fileName); pictures.SaveAs(path); var dbPicture = new Picture(); dbPicture.Url = fileName; if (sharedServices.SavePictures(dbPicture)) { PicList.Add(dbPicture); } } // result.Data = new {Success = true, ImageUrl = string.Format("/Content/images/{0}", fileName)}; result.Data = new { Success = true, PicList }; } catch (Exception ex) { result.Data = new { Success = false, Message = ex.Message }; } return(result); }
internal SFXPlayer(AudioClipsStorer clipsStorer) { var updater = SharedServices.GetService <IUpdateScheduler>(); if (updater == null) { updater = new UnityUpdateScheduler(); SharedServices.RegisterService(updater); } var dispatcher = SharedServices.GetService <EventDispatcher>(); if (dispatcher == null) { dispatcher = new EventDispatcher(); SharedServices.RegisterService(dispatcher); } updater.ScheduleUpdate(this); dispatcher.AddListener <SceneManagementService.SceneUnloadedEvent>(OnSceneUnloaded); _clipStorer = clipsStorer; for (int i = 0; i < 10; ++i) { CreateHandler(); } }
void Start() { _text = GetComponent <Text>(); _tmpText = GetComponent <TextMeshProUGUI>(); if (_text == null && _tmpText == null) { Debug.LogError("Added a LocalizedText component to a gameobject with no ui text"); return; } if (string.IsNullOrEmpty(_key)) { if (_text != null) { _key = _text.text; } else if (_tmpText != null) { _key = _tmpText.text; } } _service = SharedServices.GetService <ILocalizationService>(); if (_service == null) { _service = new LocalLocalizationService(); _service.Initialize(UpdateText); SharedServices.RegisterService <ILocalizationService>(_service); } _service.OnLocalizationChanged += UpdateText; }
public JsonResult UploadPictures() { JsonResult result = new JsonResult(); var sharedServices = new SharedServices(); var picsList = new List <Picture>(); var files = Request.Files; for (int i = 0; i < files.Count; i++) { var picture = files[i]; var fileName = Guid.NewGuid() + Path.GetExtension(picture.FileName); var filePath = Server.MapPath("~/images/") + fileName; picture.SaveAs(filePath); var dbPicture = new Picture(); dbPicture.Url = fileName; if (sharedServices.SavePicture(dbPicture)) { picsList.Add(dbPicture); } } result.Data = picsList; return(result); }
private void SeperatesParam(SqlCommand cmd, P args, string Connectionstring) { var prefix = "DATA_"; if (args.Key.ToUpper().StartsWith(prefix)) { string key = args.Key.Remove(0, prefix.Length); if (args.Value is string str) { if (str != "[]" && str != "null" && str != "") { return; } if (str.StartsWith("{") && str.EndsWith("}") || str.StartsWith("[") && str.EndsWith("]")) { DataTable dt = SharedServices.JsonToDT(str); MappingDataTableWithUserDefined(conn: Connectionstring, dataTable: dt, userDefinedName: key); cmd.Parameters.AddWithValue(key, SharedServices.JsonToDT(str)); } } else if (args.Value is DataTable dataTable) { cmd.Parameters.AddWithValue( parameterName: key, value: MappingDataTableWithUserDefined(conn: Connectionstring, dataTable: dataTable, userDefinedName: key)); } } else { cmd.Parameters.AddWithValue(args.Key, args.Value); } }
public EventTracker() { if (System.IO.File.Exists(_path)) { string text = System.IO.File.ReadAllText(_path); try { JSONObject jsonfile = JSON.JSON.LoadString(text) as JSONObject; foreach (var kvp in jsonfile) { uint id = 0; if (uint.TryParse(kvp.Key, out id)) { _pending.Add(id, kvp.Value.AsObject()); if (id > _lastId) { _lastId = id; } } else { SharedServices.GetService <ICustomLogger>()?.LogError("Corrupted key in tracks file: {" + kvp.Key + ": " + kvp.Value); } } System.IO.File.WriteAllText(_path, "{}"); } catch (MalformedJSONException e) { SharedServices.GetService <ICustomLogger>()?.LogError("Error parsing saved tracks: " + e.Message); } } }
public IActionResult DownloadExcelFromDBfn(DownloadExcelModel model) { try { DataSet ds = null; if (model.DataSouece != null) { ds = model.DataSouece; } // else ds = SharedServices.CallSP(conn, SharedServices.JsonToSPparams(model.Source_SP)); if (ds.Tables.Count == 0) { ds.Tables.Add(); ds.Tables[0].Columns.Add("-- ไม่พบข้อมูล-- "); } MemoryStream stream = SharedServices.ExcelStreaming( source: ds, SheetName: model.Excelsheetsname, Template: model.Template, LastRowIsSummary: model.LastRowIsSummary); return(File(stream, "application/vnd.ms-excel", model.ExcelName + ".xlsx")); } catch { return(BadRequest()); } }
/// <summary> /// This method gets the list of clients for the relevant listeners. /// </summary> protected override void StartInternal() { mResourceTracker = SharedServices.GetService <IResourceTracker>(); if (mResourceTracker == null) { throw new ArgumentNullException("ResourceTracker cannot be retrieved."); } }
public void Dispose() { SharedServices.GetService <IUpdateScheduler>().UnscheduleUpdate(this); foreach (var handler in _handlers) { UnityEngine.Object.Destroy(handler.gameObject); } SharedServices.GetService <EventDispatcher>().RemoveListener <SceneManagementService.SceneUnloadedEvent>(OnSceneUnloaded); }
/// <summary> /// This method gets the list of clients for the relevant listeners. /// </summary> protected override void StartInternal() { //Get the resource tracker that will be used to reduce message in mResourceTracker = SharedServices.GetService <IResourceTracker>(); if (mResourceTracker == null) { throw new ArgumentNullException("ResourceTracker cannot be retrieved."); } }
IEnumerator CrossFadeCoroutine(string fadeTo, float duration) { float halfDuraion = duration * 0.5f; SharedServices.GetService <CoroutineRunner>().StartCoroutine(this, FadeOutCoroutine(halfDuraion)); yield return(new WaitForSeconds(halfDuraion)); Play(fadeTo); SharedServices.GetService <CoroutineRunner>().StartCoroutine(this, FadeInCoroutine(halfDuraion)); }
public void Dispose() { if (_playingClip != null) { _source.Stop(); _playingClip.ReferencedClip.ReleaseAsset(); } SharedServices.GetService <CoroutineRunner>().StopAllCoroutines(this); UnityEngine.Object.Destroy(_source.gameObject); }
/// <summary> /// This method starts the service and retrieves the services required for connectivity. /// </summary> protected override void StartInternal() { var resourceTracker = SharedServices.GetService <IResourceTracker>(); if (resourceTracker != null && mResourceProfile != null) { mResourceConsumer = resourceTracker.RegisterConsumer("CacheV2" + mResourceProfile.Id, mResourceProfile); } base.StartInternal(); }
protected override void StartInternal() { var resourceTracker = SharedServices.GetService <IResourceTracker>(); if (resourceTracker != null && mPolicy.ResourceProfile != null) { mPolicy.ResourceConsumer = resourceTracker.RegisterConsumer(EntityType, mPolicy.ResourceProfile); } base.StartInternal(); }
public SFXData GetClipByName(string clipName) { foreach (var clip in _clips) { if (string.Equals(clip.ClipName, clipName, System.StringComparison.InvariantCultureIgnoreCase)) { return(clip); } } SharedServices.GetService <ICustomLogger>()?.LogError("Trying to get a nonexistent audio clip: " + clipName); return(null); }
public void TrackPending() { var pending_copy = new Dictionary <uint, JSONObject>(_pending); _pending.Clear(); foreach (var obj in pending_copy.Values) { var id = ++_lastId; SharedServices.GetService <CommandQueue>().AddCommand(new TrackEventCommand(id, obj, OnTrackResponse)); _pending.Add(id, obj.Clone().AsObject()); } }
public JsonResult Action(AccommodationPackageModel model) { var result = false; JsonResult json = new JsonResult(); SharedServices sharedServices = new SharedServices(); List <int> pictureIDs = !string.IsNullOrEmpty(model.PictureIDs)? model.PictureIDs.Split(',').Select(x => int.Parse(x)).ToList():new List <int>(); var pictures = sharedServices.GetPictureByID(pictureIDs); if (model.ID > 0)//for Edit { var accommodationPackage = AccommodationPackagesServices.Instance.GetAccommodationPackageByID(model.ID); accommodationPackage.AccommodationTypeID = model.AccommodationTypeID; accommodationPackage.Name = model.Name; accommodationPackage.FeePerNight = model.FeePerNight; accommodationPackage.NoOfRoom = model.NoOfRoom; accommodationPackage.AccommodationPackagePictures.Clear(); accommodationPackage.AccommodationPackagePictures.AddRange(pictures.Select(x => new AccommodationPackagePicture() { AccommodationPackageID = model.ID, PictureID = x.ID })); result = AccommodationPackagesServices.Instance.UpdateAccommodationPackage(accommodationPackage); } else//for create { AccommodationPackage accommodationPackage = new AccommodationPackage(); accommodationPackage.AccommodationTypeID = model.AccommodationTypeID; accommodationPackage.Name = model.Name; accommodationPackage.FeePerNight = model.FeePerNight; accommodationPackage.NoOfRoom = model.NoOfRoom; accommodationPackage.AccommodationPackagePictures = new List <AccommodationPackagePicture>(); accommodationPackage.AccommodationPackagePictures.AddRange(pictures.Select(x => new AccommodationPackagePicture() { PictureID = x.ID })); result = AccommodationPackagesServices.Instance.SaveAccommodationPackage(accommodationPackage); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { success = false, Message = "Unable to add Accommodationtype" }; } return(json); }
internal MusicPlayer(AudioClipsStorer clipStorer) { if (!SharedServices.HasService <ICoroutineRunner>()) { SharedServices.RegisterService <ICoroutineRunner>(new CoroutineRunner()); } _clipStorer = clipStorer; _source = new GameObject("MusicPlayer").AddComponent <AudioSource>(); UnityEngine.Object.DontDestroyOnLoad(_source.gameObject); _source.playOnAwake = false; _source.spatialBlend = 0f; }
void OnClipLoaded(AudioClip clip) { if (clip == null) { SharedServices.GetService <ICustomLogger>()?.LogError("Cannot load audio clip: " + _playingClip.ClipName); return; } _source.clip = clip; _source.loop = _playingClip.Loop; _source.pitch = _playingClip.Pitch; _source.volume = _playingClip.Volume * _volume; _source.Play(); }
private async Task CallMeAsWell(Schedule schedule) { try { //throw new Exception("Don't care"); var serv = SharedServices.GetService <IRepositoryAsync <Guid, MondayMorningBlues> >(); var result = await serv.Read(new Guid("414f06b5-7c16-403a-acc5-40d2b18f08a1")); } catch (Exception ex) { //throw; } }
private void Edit_Delete_Item(string vid) { try { SharedServices ss = new SharedServices(); var editlist = ss.GetMappinOrderItems(vid); using (Edit_Item eis = new Edit_Item(editlist, vid, user)) { eis.ShowDialog(); }; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal static void InitializeServices() { try { var allGeneralServices = ServicesFactory.CreateAllServices()?.ToList(); allGeneralServices?.ForEach(x => { SharedServices.SetService(x, x.GetType()); }); } catch (Exception e) { } }
public void TrackEvent(string category, string userID, JSONObject data = null) { JSONObject toSend = new JSONObject(); toSend["user_id"] = userID; toSend["ts"] = TimeUtils.Timestamp; toSend["category"] = category; if (data != null) { toSend["data"] = data; } var id = ++_lastId; SharedServices.GetService <CommandQueue>().AddCommand(new TrackEventCommand(id, toSend, OnTrackResponse)); _pending.Add(id, toSend); }
private void ButtonAdv3_Click(object sender, EventArgs e) { using (Search_Products sp = new Search_Products(user)) { sp.ShowDialog(); if (sp.ShowDialog == true) { var pids = sp.ProductItemID_List; for (int i = 0; i < pids.Count; i++) { con.InsertInformation("INSERT INTO [mbo].[PSVendorItemMapping] ([ProductVendorId],[ProductItemId],[Name]) VALUES ('" + Vendorid + "','" + pids[i] + "',(select top 1 Name from [dbo].[ProductVendor] where ProductVendorId='" + Vendorid + "'))"); } SharedServices srv = new SharedServices(); dataGridView1.DataSource = null; dataGridView1.DataSource = srv.GetMappinOrderItems(Vendorid); } } }
static IEnumerator SendCoroutine(Petition petition, Action <Petition> onFinish) { NetworkError error = null; string response = string.Empty; int retries = 0; do { var uploader = new UploadHandlerRaw(petition.GetRawData()); uploader.contentType = "application/json"; var downloadHandler = new DownloadHandlerBuffer(); var request = new UnityWebRequest(petition.Url); request.method = petition.Method == Petition.SendMethod.Post ? UnityWebRequest.kHttpVerbPOST : UnityWebRequest.kHttpVerbGET; request.useHttpContinue = false; request.redirectLimit = 50; request.timeout = 60; if (petition.Method == Petition.SendMethod.Post) { request.SetRequestHeader("Content-Type", "application/json"); } request.uploadHandler = uploader; request.downloadHandler = downloadHandler; yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { error = new NetworkError((int)request.responseCode, request.error); SharedServices.GetService <ICustomLogger>().LogError("Network error error: {" + error.Code + ": " + error.Message + "} for petition: " + petition.GetData()); } else { response = request.downloadHandler.text; error = null; } ++retries; }while(error != null && retries < petition.Retries); petition.SetResponse(response); petition.Error = error; onFinish?.Invoke(petition); }
private void ProcessInputFile() { try { if (_challengeConfiguration != null) { if (SharedServices.HasService(typeof(ChallengeInitializationService))) { _challenge = SharedServices.GetService <ChallengeInitializationService>().InitializeChallenge(_challengeConfiguration); OnReportMessageSet(this, new EventArgs.HandlerEventArgs(this, "Toy Robot Challenge initialized...", false)); if (!String.IsNullOrEmpty(_inputCommandFilePath)) { List <string> stringCommands = null; if (SharedServices.HasService(typeof(CommandParsingService))) { stringCommands = SharedServices.GetService <CommandParsingService>().ParseCommandFile(_inputCommandFilePath); if (stringCommands != null && SharedServices.HasService(typeof(CommandConversionService))) { List <List <IRobotCommand> > robotCommands = SharedServices.GetService <CommandConversionService>().ConvertStringCommands(stringCommands); if (robotCommands != null && robotCommands.Count > 0 && SharedServices.HasService(typeof(CommandExecutionService))) { SharedServices.GetService <CommandExecutionService>().CommandExecuted += CommandExecutionService_CommandExecuted; foreach (List <IRobotCommand> commandlist in robotCommands) { SharedServices.GetService <CommandExecutionService>().ExecuteCommands(_challenge.ActiveRobot, commandlist); } } } } } } } } catch (Exception ex) { _errMsg = String.Format("Unable to process the configuration due to an error. {0}", ex.Message); throw new Exception(_errMsg); } }
void OnLoaded(AudioClip clip) { if (clip == null) { SharedServices.GetService <ICustomLogger>()?.LogError("Cannot load audio clip: " + data.ClipName); return; } gameObject.SetActive(true); gameObject.name = data.ClipName; _source.volume = data.Volume * _volume; _source.pitch = data.Pitch; _source.clip = clip; _source.loop = data.Loop; _source.spatialBlend = 0f; _source.Play(); _toFollow = null; _looping = data.Loop; _duration = clip.length; }
private async Task CallMe(Schedule schedule) { try { var id = Guid.NewGuid(); //throw new Exception("Don't care"); var serv = SharedServices.GetService <IRepositoryAsync <Guid, MondayMorningBlues> >(); var result2 = await serv.Create(new MondayMorningBlues() { Id = id }); var result = await serv.Read(id); } catch (Exception ex) { //throw; } }
public async Task <IActionResult> UploadCommRate([FromForm] FileUpload model) { if (model.File.Length == 0) { return(BadRequest()); } var dataSet = await SharedServices.ExcelToDataSet(model); List <P> parameters = new List <P> { new P { Key = "Data_PB_CommRatesImport", Value = SharedServices.StringAllColumns(dataSet.Tables[0]) }, new P { Key = "AddBy", Value = Current.UserID } }; var ds = dbServices.SpCaller(name: "dbo.PB_CommRatesImport", parameters: parameters); return(Ok(ds.Tables[0])); }