public void AddErrorQueueItem(string ID, string Err_Message, string Err_Type, string Note, string Status, string BALNumber = "") { try { if (string.IsNullOrEmpty(ID)) { ID = "BOT0000000"; } SpecificContent content = new SpecificContent(); content.ID = ID; content.Err_Message = Err_Message; content.Err_Type = Err_Type; content.Note = Note; content.Status = Status; content.Data = "[{'CaseNo':'" + BALNumber + "', 'ExtraAsset':'', 'FilePath':'NA'}]"; ItemData itemData = new ItemData(); itemData.Name = appKeys.ResponseQueueName; itemData.Priority = "Normal"; itemData.SpecificContent = content; RootObject queueItemBody = new RootObject(); queueItemBody.itemData = itemData; string token = Authentication(appKeys.isDevelopmentEnvironment); string strQueue = JsonConvert.SerializeObject(queueItemBody); AddQueueItem(token, strQueue); } catch (Exception ex) { throw ex; } }
public IHttpActionResult AddQueueItem([FromBody] PostSaveData bodyModel) { string assetResponse = ""; Response outResponse = new Response(); OrchestratorAPI api = new OrchestratorAPI(); string logMsg = ""; string errorMessage = ""; try { if (string.IsNullOrEmpty(bodyModel.Sysid) && string.IsNullOrEmpty(bodyModel.BalNumber) && 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."; logMsg = "Bal Number : " + bodyModel.BalNumber + ", Process : Add Queue Item, Message : JsonString parameter required"; Log.Info(logMsg); assetResponse = JsonConvert.SerializeObject(outResponse); es.AddErrorESLog(bodyModel.Sysid, "Technical", "QueueItem API Parameter Missing", out errorMessage); api.AddErrorQueueItem(bodyModel.Sysid, "QueueItem API Parameter Missing", "Technical", "QueueItem API Parameter Missing", "In Progress"); return(Json(assetResponse)); } string filter = "?$filter=Name eq '" + bodyModel.BalNumber + "'"; // configuration AppSettingsValues appKeys = GetAppSettings.GetAppSettingsValues(); string token = api.Authentication(appKeys.isDevelopmentEnvironment); AssetModel assetModel = api.GetAsset(token, filter); if (assetModel.value.Count > 0) { SpecificContent content = new SpecificContent(); content.ID = bodyModel.Sysid; content.Err_Message = null; content.Err_Type = null; content.Note = null; content.Status = null; content.Data = "[{'CaseNo':'" + bodyModel.BalNumber + "','Email':'" + bodyModel.Email + "','EsIdNo':'" + bodyModel.EsIdNo + "', 'ExtraAsset':''}]"; if (assetModel.value.Count > 2) { content.Data = "[{'CaseNo':'" + bodyModel.BalNumber + "','Email':'" + bodyModel.Email + "','EsIdNo':'" + bodyModel.EsIdNo + "', 'ExtraAsset':'" + bodyModel.BalNumber + " A" + "'}]"; } ItemData itemData = new ItemData(); itemData.Name = appKeys.QueueName; itemData.Priority = "Normal"; itemData.SpecificContent = content; RootObject queueItemBody = new RootObject(); queueItemBody.itemData = itemData; string strQueue = JsonConvert.SerializeObject(queueItemBody); string message = api.AddQueueItem(token, strQueue); outResponse.success = true; outResponse.message = "Your 9035 will be drafted on FLAG and a copy will be updated to Cobalt. You will receive a notification from ServiceNow when it is complete. if you have any questions, contact #automationinfo"; logMsg = "Bal Number : " + bodyModel.BalNumber + ", Process : Add Queue Item, Message : Queueitem has been added."; Log.Info(logMsg); } } 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.BalNumber); es.AddErrorESLog(bodyModel.Sysid, "Technical", ex.Message, out errorMessage); api.AddErrorQueueItem(bodyModel.Sysid, ex.Message, "Technical", ex.Message, "In Progress"); } assetResponse = JsonConvert.SerializeObject(outResponse); return(Json(assetResponse)); }
public void AddSpecificContent(string name, bool value) { SpecificContent.Add(name, value); }
public void AddSpecificContent(string name, string value) { SpecificContent.Add(name + "@odata.type", "#String"); SpecificContent.Add(name, value); }