//public static AMSResult<P> Convert<T,P>(this AMSResult<T> source) where P : T //{ // AMSResult<P> result = new AMSResult<P>(); // result.MessageString = source.MessageString; // result.ParameterList = source.ParameterList; // result.PhraseString = source.PhraseString; // result.ResultType = source.ResultType; // result.Result = source.Result as P; //} public static string GetLocalizedMessage <T>(this AMSResult <T> source, int LanguageID) { ResolveDependencies(); // default error message string localizedError = phraseLib.Lookup("term.UnknownError", LanguageID); if (source.ResultType != AMSResultType.Success && !string.IsNullOrEmpty(source.PhraseString)) { // TODO eventually move this into a custom resource manager // See if there is a terminal specific resource string resourceString = phraseLib.Lookup(source.PhraseString, LanguageID); // If the resource key isn't present in the resources then it returns an empty string if (!string.IsNullOrEmpty(resourceString)) { try { if (source.ParameterList == null || source.ParameterList.Count() == 0) { localizedError = resourceString; } else { localizedError = string.Format(resourceString, source.ParameterList.ToArray()); } } catch (FormatException ex) { logger.WriteCritical(string.Format("{0} - {1} - {2}", System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex)); } } else { logger.WriteError(string.Format("Unable to find resource named '{0}' in Phrase Lib", source.PhraseString)); } } string err = LogMessage <T>(source); if (!string.IsNullOrEmpty(err)) { localizedError = err; } return(localizedError); }
public void reloadNotesSrc() { List <Notes> lstNotes = m_Notes.GetNotesBtnInfo(LinkID, NoteType); foreach (Notes note in lstNotes) { if (note.Private == false || (note.Private == true && note.AdminUser.ID == AdminUserID)) { HasVisibleNotes = true; } if ((note.Private == false || (note.Private == true && note.AdminUser.ID == AdminUserID)) && note.Important) { HasImportantNotes = true; } if (note.CreatedDate.Subtract(DateTime.Today).Days == 0) { HasNewNotes = true; } } if (HasVisibleNotes) { if (HasImportantNotes) { notesbutton.Src = (HasNewNotes) ? "/images/notes-newimportant.png" : "/images/notes-someimportant.png"; } else { notesbutton.Src = (HasNewNotes) ? "/images/notes-new.png" : "/images/notes-some.png"; } notesbutton.Alt = (lstNotes.Count == 1) ? lstNotes.Count + " " + PhraseLib.Lookup("term.note", LanguageID).ToLower() : lstNotes.Count + " " + PhraseLib.Lookup("term.notes", LanguageID).ToLower(); notesbutton.Attributes.Add("title", notesbutton.Alt); } else { notesbutton.Src = "/images/notes-none.png"; notesbutton.Alt = PhraseLib.Lookup("term.notes", LanguageID); } }
protected void Page_Load(object sender, EventArgs e) { ResolveDependencies(); AdminUserID = ((AuthenticatedUI)this.Page).CurrentUser.AdminUser.ID; LanguageID = ((AuthenticatedUI)this.Page).LanguageID; PhraseLib = ((AuthenticatedUI)this.Page).PhraseLib; m_ErrorHandler = ((AuthenticatedUI)this.Page).ErrorHandler; notesave.Text = PhraseLib.Lookup("term.save", LanguageID); UserPermissions = ((AuthenticatedUI)this.Page).CurrentUser.UserPermissions; if (UserPermissions.CreateNotes == false) { noteadddiv.Visible = false; } if (UserPermissions.AccessNotes && !IsPostBack) { LoadNotes(); } }
public XmlDocument UpdateBuyerRoleByInternalId(string GUID, int id, string requestXML) { string methodName = "UpdateBuyerRoleByInternalId"; XmlWriter xmlWriter = null; StringWriter strWriter = null; XmlDocument xmlResponse = new XmlDocument(); XmlDocument xmlInput = null; string errMsg = ""; try { Startup(); m_connectorInc.Init_ResponseXML(methodName, ref strWriter, ref xmlWriter); if (!m_authInc.Is_Valid_GUID(GUID)) { m_logger.WriteError(m_phraseLib.Detokenize("term.guidnotvalid", GUID, m_common.Get_AppInfo().AppName)); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_GUID, m_phraseLib.Detokenize("term.guidnotvalid", GUID, m_common.Get_AppInfo().AppName), false); } else if (!m_connectorInc.ConvertStringToXML(requestXML, ref xmlInput)) { m_logger.WriteError(m_phraseLib.Detokenize("term.invalidparameterxmldocument", "requestXML")); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_XML_DOCUMENT, m_phraseLib.Detokenize("term.invalidparameterxmldocument", "requestXML"), false); } else if (!m_connectorInc.IsValidXmlDocument("BuyerRoleData.xsd", xmlInput, out errMsg)) { m_logger.WriteError(m_phraseLib.Detokenize("term.invalidxmlconformxsd", "requestXML", "BuyerRoleData.xsd: " + errMsg)); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_XML_DOCUMENT, m_phraseLib.Detokenize("term.invalidxmlconformxsd", "requestXML", "BuyerRoleData.xsd: " + errMsg), false); } else { var buyerRole = ParseBuyerRoleDetails(xmlInput); var response = m_buyerRole.UpdateBuyerRoleByInternalId(id, buyerRole); CMS.CMSException.StatusCodes statusCode = CMS.CMSException.StatusCodes.GENERAL_ERROR; if (response.ResultType == CMS.AMS.Models.AMSResultType.Success) { statusCode = CMS.CMSException.StatusCodes.SUCCESS; m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, statusCode, m_phraseLib.Lookup("term.success"), true); } else { m_logger.WriteError(response.MessageString); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, statusCode, response.MessageString, false); } } } catch (Exception ex) { m_logger.WriteError("Failed to update buyer role- please see the error log!"); m_errHandler.ProcessError(ex); ProcessException(ex, methodName, ref xmlWriter, ref strWriter); } CloseResponseXml(ref xmlWriter, ref strWriter, ref xmlResponse); Shutdown(); return(xmlResponse); }
protected void notesave_Click(object sender, EventArgs e) { Notes objNote = new Notes(); if (notetext.InnerText.Trim() != String.Empty) { objNote.AdminUser = new CMS.Models.AdminUser(); objNote.AdminUser.FirstName = ((AuthenticatedUI)this.Page).CurrentUser.AdminUser.FirstName; objNote.AdminUser.LastName = ((AuthenticatedUI)this.Page).CurrentUser.AdminUser.LastName; objNote.Note = notetext.InnerText; objNote.NoteTypeID = NoteType; objNote.LinkID = LinkID; objNote.Private = cbPrivate.Checked; objNote.Important = cbImportant.Checked; objNote.AdminUser.ID = AdminUserID; objNote.AdminUser.LanguageID = LanguageID; if (m_Notes.AddNote(objNote) == true) { if (objNote.Private == false) { HistoryString = PhraseLib.Lookup("history.note-add", LanguageID); ActivityTypePhraseID = m_ActivityLog.GetActivityTypePhraseID(ActivityType); if (ActivityTypePhraseID > 0) { HistoryString += " " + PhraseLib.Lookup("term.to", LanguageID).ToLower() + " " + PhraseLib.Lookup(ActivityTypePhraseID, LanguageID).ToLower(); } if (objNote.LinkID == 0) { switch (objNote.NoteTypeID) { case NoteTypes.Offers: case NoteTypes.CustomerGroup: case NoteTypes.ProductGroup: case NoteTypes.PointsProgram: case NoteTypes.StoredValueProgram: case NoteTypes.Promovar: case NoteTypes.Graphic: case NoteTypes.Layout: case NoteTypes.Store: case NoteTypes.StoreGroup: case NoteTypes.Agent: case NoteTypes.Report: case NoteTypes.User: case NoteTypes.Banner: case NoteTypes.Department: case NoteTypes.Terminal: HistoryString += " " + PhraseLib.Lookup("term.list", LanguageID).ToLower(); break; } } m_ActivityLog.Activity_Log(ActivityType, LinkID, AdminUserID, HistoryString); } notetext.InnerText = String.Empty; cbPrivate.Checked = false; cbImportant.Checked = false; if (NotesUpdate != null) { NotesUpdate(sender, e); } LoadNotes(); ScriptManager.RegisterStartupScript(this, this.GetType(), "Script", "toggleNotesDisplay()", true); } } }
/// <summary> /// Processes exception catch for other methods /// </summary> /// <param name="ex">Exception that occurred</param> /// <param name="methodName">Name of the method where the exception occurred</param> /// <param name="xmlWriter">XmlWriter from the method where the exception occurred</param> /// <param name="strWriter">StringWriter from the method where the exception occurred</param> private void ProcessException(Exception ex, string methodName, XmlWriter xmlWriter, StringWriter strWriter) { m_connectorInc.Init_ResponseXML(methodName, ref strWriter, ref xmlWriter); if (ex is CMSException) { var statusCode = CMSException.StatusCodes.GENERAL_ERROR; if (ex.Data != null) { statusCode = (CMSException.StatusCodes)ex.Data["StatusCode"]; } GenerateStatusXml(xmlWriter, methodName, statusCode, ex.Message); } else { m_errHandler.ProcessError(ex); GenerateStatusXml(xmlWriter, methodName, CMSException.StatusCodes.APPLICATION_EXCEPTION, m_phraseLib.Lookup("term.errorprocessingseelog")); m_logger.WriteError("An error occurred while processing - please see the error log!"); } m_connectorInc.Close_ResponseXML(ref xmlWriter); }