private static string GetMacAddress() { try { string macAddress = string.Empty; const int MIN_MAC_ADDR_LENGTH = 12; long maxSpeed = -1; foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { Dbg.Debug( " MAC Address: " + nic.GetPhysicalAddress() + " Type: " + nic.NetworkInterfaceType); string tempMac = nic.GetPhysicalAddress().ToString(); if (macAddress == string.Empty && nic.Speed > maxSpeed && !string.IsNullOrEmpty(tempMac) && tempMac.Length >= MIN_MAC_ADDR_LENGTH) { Dbg.Debug("MAC address is found : MAC: {0} , Max Speed = {1}", tempMac, nic.Speed); maxSpeed = nic.Speed; macAddress = tempMac; } } return(macAddress); } catch (Exception ex) { Dbg.Debug("can't got MAC Address: {0}", ex); return(null); } }
public static Dictionary <string, object> ReadResxDictionary(string fileName) { try { var dict = new Dictionary <string, object>(); if (File.Exists(fileName)) { lock (m_LockObject) { using (var reader = new ResXResourceReader(fileName)) { var enumerator = reader.GetEnumerator(); while (enumerator.MoveNext()) { var keystr = enumerator.Key.ToString(); var val = enumerator.Value.ToString(); dict.Add(keystr, enumerator.Value); } } } } return(dict); } catch (Exception e) { Dbg.Debug("error during resource reading. Resource {0}, error: {1}", fileName, e); return(null); } }
public MainForm() { InitializeComponent(); BaseFormManager.Init(this); BaseFormManager.MainBarManager = barManager1; MenuActionManager.Instance = new MenuActionManager(this, barManager1, tbToolbar, EidssUserContext.User) { ItemsStorage = EidssMenu.Instance }; WindowState = FormWindowState.Maximized; Text = WinClientContext.ApplicationCaption; ToolTipController.InitTooltipController(); DefaultBarAndDockingController1.InitBarAppearance(); tbToolbar.Appearance.InitAppearance(); Dbg.Debug("Application thread ID: {0}", Thread.CurrentThread.ManagedThreadId); DefaultLookAndFeel1.LookAndFeel.SkinName = BaseSettings.SkinName; // "SkinsTest_Money Twins"; SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); //AUM UpdateMessenger = new UpdateMessenger(new ConnectionCredentials()); TimerUpdateListener = UpdateMessenger.CreateTimerListener(); TimerUpdateListener.SynchronizingObject = this; TimerUpdateListener.Elapsed += TimerUpdateListener_Elapsed; TimerExit = UpdateMessenger.CreateTimerExit(); TimerExit.SynchronizingObject = this; TimerExit.Elapsed += TimerExit_Elapsed; }
public static bool CloseNonListForms(bool needSave) { var openedFoms = new IApplicationForm[m_FormList.Count]; m_FormList.CopyTo(openedFoms); try { foreach (IApplicationForm frm in openedFoms) { //if (!(frm is IBaseListPanel || frm is IListFormsContainer)) if (((Control)frm).FindForm() != MainForm) { if (!Close(frm, DialogResult.Cancel, needSave ? FormClosingMode.SaveWithConfirmation : FormClosingMode.NoSave)) { return(false); } } } } catch (Exception ex) { Dbg.Trace(); Dbg.Debug(ex.ToString()); } m_CurrentForm = null; return(true); }
public void Arrange(int left, int top, int captionWidth, int controlWidth) { m_Label.Left = left; Dbg.Debug("y offset = " + m_YLabelShift.ToString()); m_Label.Top = top + m_YLabelShift; m_Label.Width = captionWidth; int singleControlWidth = Convert.ToInt32((controlWidth - (m_Controls.Length - 1) * m_Distance) / m_Controls.Length); int x = left + m_Label.Width; int ctlLeft = x; for (int i = 0; i < m_Controls.Length; i++) { Control ctl = m_Controls[i]; ctl.Left = x; ctl.Top = top; if (i == m_Controls.Length - 1) { ctl.Width = ctlLeft + controlWidth - ctl.Left; } else { ctl.Width = singleControlWidth; } x += singleControlWidth + m_Distance; } }
public static void DeleteSubkey(string section, string keyName) { try { string fullKeyName = GetSectionName(section) + "\\" + keyName; RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, GetRegistryView()).OpenSubKey(GetSectionName(section), true); if (key != null) { RegistryKey subKey = key.OpenSubKey(keyName, true); if (subKey != null) { key.DeleteSubKey(keyName); key.Close(); } else { Dbg.Debug("can\'t open key {0} in registry", fullKeyName); } } } catch (Exception ex) { Dbg.Debug("can\'t delete registry key {0}:{1}, error - {2}", keyName, ex); } }
public bool ValidatePassword(string password) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { DataSet ds = manager.SetSpCommand("dbo.spSecurityPolicy_List", manager.Parameter("@LangID", ModelUserContext.CurrentLanguage) ).ExecuteDataSet(); if (ds == null || ds.Tables.Count < 2 || ds.Tables[0].Rows.Count == 0) { return(false); } DataTable dt = ds.Tables[0]; if ((int)dt.Rows[0]["intForcePasswordComplexity"] == 0) { return(true); } dt = ds.Tables[1]; if (dt.Rows.Count == 0) { return(true); } string passwordExpression = Utils.Str(dt.Rows[0]["strAlphabet"], ""); MatchCollection matches = Regex.Matches(password, passwordExpression); return(matches.Count > 0); } catch (Exception e) { Dbg.Debug("error during password validation: {0}", e.ToString()); return(false); } } }
/// <summary> /// Encrypts specified plaintext using Rijndael symmetric key algorithm /// and returns a base64-encoded result. /// </summary> /// <param name="plainText"> /// Plaintext value to be encrypted. /// </param> /// <param name="passPhrase"> /// Passphrase from which a pseudo-random password will be derived. The /// derived password will be used to generate the encryption key. /// Passphrase can be any string. In this example we assume that this /// passphrase is an ASCII string. /// </param> /// <param name="saltValue"> /// Salt value used along with passphrase to generate password. Salt can /// be any string. In this example we assume that salt is an ASCII string. /// </param> /// <param name="passwordIterations"> /// Number of iterations used to generate password. One or two iterations /// should be enough. /// </param> /// <param name="initVector"> /// Initialization vector (or IV). This value is required to encrypt the /// first block of plaintext data. For RijndaelManaged class IV must be /// exactly 16 ASCII characters long. /// </param> /// <param name="keySize"> /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. /// Longer keys are more secure than shorter keys. /// </param> /// <returns> /// Encrypted value formatted as a base64-encoded string. /// </returns> public static string Encrypt(string plainText, string passPhrase, string saltValue, int passwordIterations, string initVector, int keySize) { try { byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); //Dim password As New PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations) var password = new Rfc2898DeriveBytes(passPhrase, saltValueBytes, passwordIterations); byte[] keyBytes = password.GetBytes(keySize / 8); var symmetricKey = new RijndaelManaged { Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7 }; ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes); var memoryStream = new MemoryStream(); var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write); cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); cryptoStream.FlushFinalBlock(); byte[] cipherTextBytes = memoryStream.ToArray(); memoryStream.Close(); cryptoStream.Close(); string cipherText = Convert.ToBase64String(cipherTextBytes); return(cipherText); } catch (Exception e) { Dbg.Debug("Encryption error: {0}", e); } return(""); }
public int GetIntPolicyValue(string name, int defaultValue) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { DataTable dt = manager.SetSpCommand("dbo.spSecurityPolicy_List", manager.Parameter("@LangID", ModelUserContext.CurrentLanguage) ).ExecuteDataTable(); if (dt == null || dt.Rows.Count == 0) { return(defaultValue); } return((int)dt.Rows[0][name]); } catch (Exception e) { Dbg.Debug( "error during retrieving security policy value {0}, default value {1} is returned. \r\n{2}", name, defaultValue, e.ToString()); return(defaultValue); } } }
public void LogOut() { if (!(Utils.IsEmpty(EidssUserContext.User.ID))) { SecurityLog.WriteToEventLogDB(EidssUserContext.User.ID, SecurityAuditEvent.Logoff, true, "EIDSS user log off", null, null, SecurityAuditProcessType.Eidss); //EIDSS user log off } try { lock (LockObject) { if (EidssUserContext.User.IsAuthenticated) { using (DbManager manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { manager.SetSpCommand("spLogoffUser", manager.Parameter("@ClientID", ModelUserContext.ClientID), manager.Parameter("@idfUserID", EidssUserContext.User.ID)).ExecuteNonQuery(); } EidssUserContext.User.Clear(); } } } catch (Exception ex) { Dbg.Debug("error during logoff: {0}", ex); } }
private static bool CheckAumMutex() { Mutex mutexUpdateNow; bool alone; const string mutexText = "aumupdatenow"; Dbg.Debug("aum mutex checking..."); try { mutexUpdateNow = Mutex.OpenExisting(mutexText, MutexRights.FullControl); alone = false; } catch (WaitHandleCannotBeOpenedException) { //не найден, можно продолжать работу alone = true; } catch (UnauthorizedAccessException) { alone = false; } Dbg.Debug("aum mutex alone={0}", alone); if (!alone) { Dbg.Debug("EIDSS now exit because aum (bvupdater) is running"); } return(alone); }
private static IntPtr GetMainWindowHandle() { string processName = GetProcessName(); if (processName == null) { return(IntPtr.Zero); } processName = Path.GetFileNameWithoutExtension(processName); Process[] processes = Process.GetProcessesByName(processName); Dbg.Debug("retrieving window handle for process:" + processName); //Loop through the running processes in with the same name Process current = Process.GetCurrentProcess(); foreach (Process p in processes) { //Ignore the current process if (p.MainModule != null && current.MainModule != null) { if (p.MainModule.FileName != current.MainModule.FileName) { Dbg.Debug("process " + processName + " is found"); return(p.MainWindowHandle); } } } Dbg.Debug("process " + processName + " is not found"); return(IntPtr.Zero); } //RunningInstance
public override bool SaveChanges(Dictionary <object, DesignElement> changes, string cultureCode) { try { var captionChange = changes.First(c => c.Key == this.CaptionLabel); if (!captionChange.Equals(null)) { ParentBasePanel.Caption = CaptionLabel.Text; var tmpChanges = new Dictionary <object, DesignElement> { { ParentBasePanel, DesignElement.Caption } }; TranslationToolHelperWinClient.SaveViewChanges(ParentBasePanel as ITranslationView, tmpChanges, cultureCode); changes.Remove(captionChange.Key); } ((ITranslationView)panelMain.Controls[0]).SaveChanges(changes, cultureCode); ((ITranslationView)panelBottom.Controls[0]).SaveChanges(changes, cultureCode); return(true); } catch (Exception ex) { Dbg.Debug("error during translation saving", ex); return(false); } }
public static string FindFileRecursive(DirectoryInfo dir, string fileName) { if (m_RecursiveLevel >= MaxRecursiveLevel || dir == null) { return(null); } m_RecursiveLevel += 1; try { var foundFile = FindConfigFileInFolder(dir.FullName, fileName); if (!string.IsNullOrEmpty(foundFile)) { return(foundFile); } if (dir.Parent == null) { return(null); } return(FindFileRecursive(dir.Parent, fileName)); } catch (Exception ex) { Dbg.Debug("error during cofig reading: {0}", ex); return(null); } finally { m_RecursiveLevel -= 1; } }
// Creates the error message and displays it. private DialogResult ShowThreadExceptionDialog(Exception e) { try { if (e is DbModelTimeoutException) { ErrorForm.ShowWarning("msgTimeoutList", "Cannot retrieve records from database because of the timeout. Please change search criteria and try again"); } else if (!SqlExceptionHandler.Handle(e)) { ErrorForm.ShowError(StandardError.UnprocessedError, e); } } catch (Exception e1) { Dbg.Debug("application error: {0} ", e.ToString()); if (e.InnerException != null) { Dbg.Debug("Inner exception: {0} ", e.InnerException.ToString()); } Dbg.Debug("error during displaying application error: {0} ", e1.ToString()); return(MessageForm.Show(e.Message, "Application Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop)); } if (BaseFormManager.MainForm == null || !((MainForm)BaseFormManager.MainForm).m_Loaded) { return(DialogResult.Abort); } return(DialogResult.Ignore); }
public override void CreateContextData() { if (DbManagerFactory.Factory == null) { return; } using (DbManagerProxy manager = DbManagerFactory.Factory.Create(this)) { try { manager.SetSpCommand("dbo.spSetContextData", manager.Parameter("@idfEventID", DBNull.Value), manager.Parameter("@idfDataAuditEvent", DBNull.Value) ).ExecuteNonQuery(); } catch (Exception e) { Dbg.Debug("error during context creating: {0}", e.ToString()); //Exception throwing is commented because this method can be called before creating valid DbManagerFactory with correct connection. //if (e is DataException) //{ // throw DbModelException.Create(e as DataException); //} //throw; } } }
public static bool DefaultLogin() { //#if !DEBUG // return Login(LoginType.Simple); //#else if (BaseSettings.UseDefaultLogin) { try { var manager = new EidssSecurityManager(); int errorCode; if (DoLogin(manager, BaseSettings.DefaultOrganization, BaseSettings.DefaultUser, BaseSettings.DefaultPassword, out errorCode)) { return(true); } } catch (Exception ex) { Dbg.Debug("auto login error: {0}", ex.ToString()); } return(Login(LoginType.Simple)); } return(Login(LoginType.Simple)); //#endif }
public static void Init() { m_Channel = new TcpChannel(RemoteEventManager.TcpPort); ChannelServices.RegisterChannel(m_Channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteEventManager), RemoteEventManager.Uri, WellKnownObjectMode.Singleton); Dbg.Debug("Remote server is initialized with port {0} and uri {1}", RemoteEventManager.TcpPort, RemoteEventManager.Uri); var pi = new Process(); try { if (BaseSettings.DontStartClient != true) { var path = Path.GetDirectoryName(Application.ExecutablePath); if (path != null) { pi.StartInfo.FileName = path + "\\eidss_clientagent.exe"; pi.StartInfo.WorkingDirectory = path; pi.Start(); } } } catch (Exception ex) { Dbg.Debug("can\'t start EIDSS_ClientAgent: {0}", ex); } }
private void CreateClientEvent(EventType eventType, object objectId) { Dbg.ConditionalDebug(DebugDetalizationLevel.Low, "replication client raise replication event for object at {0}", DateTime.Now); using (DbManagerProxy manager = GetDbManager()) { try { manager.SetSpCommand("dbo.spEventLog_CreateNewEvent", manager.Parameter("@idfsEventTypeID", Convert.ToInt64(eventType)), manager.Parameter("@idfObjectID", objectId), manager.Parameter("@strInformationString", DBNull.Value), manager.Parameter("@strNote", DBNull.Value), manager.Parameter("@ClientID", m_ClientID), manager.Parameter("@datEventDatatime", DateTime.Now), manager.Parameter("@intProcessed", 0), manager.Parameter("@idfUserID", m_UserID), manager.Parameter(ParameterDirection.InputOutput, "@EventID", DBNull.Value, DbType.Int64), manager.Parameter("@idfsSite", m_SiteID), manager.Parameter("@idfsDiagnosis", DBNull.Value) ).ExecuteNonQuery(); } catch (Exception ex) { Dbg.Debug("event creation fail: {0}", ex); } } }
//private static string m_DefaultLayout; //public static string DefaultLayout //{ // get // { // return m_DefaultLayout; // } // set // { // m_DefaultLayout = value; // } //} public static void ResetLanguage() { LayoutCorrector.Init(); var openedFoms = new IApplicationForm[m_FormList.Count]; m_FormList.CopyTo(openedFoms); try { foreach (IApplicationForm frm in openedFoms) { //if (!(frm is IBaseListPanel || frm is IListFormsContainer)) if (((Control)frm).FindForm() != MainForm) { Close(frm); } else { ResetLanguage(frm); } } } catch (Exception ex) { Dbg.Trace(); Dbg.Debug(ex.ToString()); } }
private void MainForm_VisibleChanged(object sender, EventArgs e) { if (Visible) { Splash.HideSplash(); Dbg.Debug("Main form is shown at {0:F}", DateTime.Now); } }
public static void ShowClient(Type typeForm, Control parentControl, IObject bo, Dictionary <string, object> @params = null) { if (typeForm == null) { return; } IApplicationForm appForm = null; try { using (new WaitDialog()) { var o = ClassLoader.LoadClass(typeForm); appForm = o as IApplicationForm; if (appForm == null) { return; } if (!Register(appForm, bo.Key)) { return; } if (bo.Key == null || (bo.Key is long && ((long)bo.Key) <= 0)) { object id = null; if (!LoadData(appForm, ref id)) { UnRegister(appForm); return; } } var basePanel = appForm as IBasePanel; if (basePanel != null) { basePanel.BusinessObject = bo; if (ReadOnly) { basePanel.ReadOnly = true; } } DisplayClientForm(appForm, parentControl); //if (!CanViewObject(frm)) //{ // return; //} } } catch (Exception ex) { UnRegister(appForm); Dbg.Debug("error during form showing", ex.ToString()); throw; } }
public static void WriteToResx(string fileName, Dictionary <string, ResourceValue> resourceValues, SizeF autoScaleFactor) { if (resourceValues == null || resourceValues.Count == 0) { return; } try { lock (m_LockObject) { if (File.Exists(fileName)) { var fi = new FileInfo(fileName) { IsReadOnly = false }; fi.Refresh(); } using (var writer = new ResXResourceWriter(fileName)) { foreach (var res in resourceValues) { //skip resources with empty values if (res.Value == null || string.IsNullOrWhiteSpace(res.Value.ToString())) { continue; } object value = res.Value.Value; string key = string.IsNullOrEmpty(res.Value.SourceKey) ? res.Key : res.Value.SourceKey; if (res.Value.Modified) { if (key.EndsWith(".Size")) { value = GetScaledSize((Size)value, autoScaleFactor); } else if (key.EndsWith(".Location")) { value = GetScaledPoint((Point)value, autoScaleFactor); } } writer.AddResource(key, value); } writer.Generate(); writer.Close(); } } } catch (Exception e) { Dbg.Debug("error during resource writing. Resource {0}, error: {1}", fileName, e); throw; } }
public void CheckAllUILocalizers() { Dbg.Debug(GridLocalizer.Active.GetLocalizedString(GridStringId.MenuGroupPanelShow)); Dbg.Debug(ChartLocalizer.Active.GetLocalizedString(ChartStringId.DefaultMaxValue)); Dbg.Debug(Localizer.Active.GetLocalizedString(StringId.Cancel)); Dbg.Debug(BarLocalizer.Active.GetLocalizedString(BarString.RenameToolbarCaption)); Dbg.Debug(NavBarLocalizer.Active.GetLocalizedString(NavBarStringId.NavPaneMenuAddRemoveButtons)); Dbg.Debug(TreeListLocalizer.Active.GetLocalizedString(TreeListStringId.PrintDesignerDescription)); //TODO разобраться Dbg.Debug(PivotGridLocalizer.Active.GetLocalizedString(PivotGridStringId.PopupMenuClearSorting)); Dbg.Debug(ReportLocalizer.Active.GetLocalizedString(ReportStringId.Cmd_ViewCode)); Dbg.Debug(PreviewLocalizer.Active.GetLocalizedString(PreviewStringId.ExportOption_HtmlExportMode)); }
/// ----------------------------------------------------------------------------- /// <summary> /// Searches the class in the registered assemblies, and returns the full assembly name containing the class /// </summary> /// <param name="className"> /// the class name that should be contained by assembly. /// </param> /// <param name="hdl"> /// returns the <b>ObjectHandle</b> to the class instance if the class is requested first time. In other case this parameter returns <b>Nothing</b> /// </param> /// <returns> /// Returns the full qualified assembly name that contains the requested class /// </returns> /// <remarks> /// If method is called first time for this specific class, it tries to load the class from all registered assemblies /// and after successful attempt cash the assembly name for this class and returns the handler to the class instance in the <i>hdl</i> parameter. /// If class was already loaded before, it just returns the cashed class assembly name. /// If assembly for requested files was not found, SystemException with message 'Class not found' is thrown. /// </remarks> /// <history> /// [Mike] 22.03.2006 Created /// </history> /// ----------------------------------------------------------------------------- private static string FindModuleAssembly(ref string className, ref ObjectHandle hdl) { moduleInfo mi; if (m_Modules.ContainsKey(className)) { mi = m_Modules[className]; className = mi.FullName; return(mi.AssemblyName); } string cName = className; bool wasError = false; foreach (var assemblyName in m_AssemblyList.Keys) { Assembly a; try { a = Assembly.LoadFrom(m_AssemblyList[assemblyName]); var type = a.GetTypes().FirstOrDefault(t => t.FullName == cName || t.Name == cName); if (type != null) { hdl = LoadClassByName(a.FullName, type.FullName); if (hdl != null) { mi.AssemblyName = a.FullName; mi.FullName = type.FullName; m_Modules[className] = mi; return(a.FullName); } } } catch (Exception e) { Dbg.Debug(string.Format("EIDSS_LoadClass:Can\'t create class {0}, Assembly {1}{2}:{3}{4}", className, AppDomain.CurrentDomain.BaseDirectory, assemblyName, "\r\n", e.Message), (System.Exception)null); Dbg.Debug(string.Format("Stack trace:{0}", e.StackTrace), (System.Exception)null); if (e.InnerException != null) { Dbg.Debug(string.Format("InerException:Can\'t create class {0}, Assembly {1}{2}:{3}{4}", className, AppDomain.CurrentDomain.BaseDirectory, assemblyName, "\r\n", e.InnerException.Message), (System.Exception)null); Dbg.Debug(string.Format("Stack trace:{0}", e.InnerException.StackTrace), (System.Exception)null); } wasError = true; } } if (!wasError) { throw (new Exception(string.Format("Class {0} is not found in registerd assemblies", className))); } return(String.Empty); }
/// <summary> /// /// </summary> /// <param name="cbFont"></param> public static void InitFontItems(ImageComboBoxEdit cbFont) { const int width = 20; const int height = 16; const int offset = 1; var il = new ImageList { ImageSize = new Size(width, height) }; var r = new Rectangle(offset, offset, width - offset * 2, height - offset * 2); cbFont.Properties.BeginUpdate(); try { cbFont.Properties.Items.Clear(); cbFont.Properties.SmallImages = il; int i; int j = 0; for (i = 0; i <= FontFamily.Families.Length - 1; i++) { try { var f = new Font(FontFamily.Families[i].Name, 8); string s = (FontFamily.Families[i].Name); var im = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(im)) { g.FillRectangle(Brushes.White, r); g.DrawString("abc", f, Brushes.Black, offset, offset); g.DrawRectangle(Pens.Black, r); } il.Images.Add(im); cbFont.Properties.Items.Add(new ImageComboBoxItem(s, f, j)); j++; } catch (Exception ex) { Dbg.Debug("font items creation error:{0}", ex.ToString()); } } } finally { cbFont.Properties.CancelUpdate(); } }
private void CheckNotificationService() { using (DbManagerProxy manager = GetDbManager()) { try { var dt = manager.SetSpCommand("dbo.spEventLog_IsNtfyServiceRunning", manager.Parameter("@idfsClient", m_ClientID) ).ExecuteNonQuery(); } catch (Exception ex) { Dbg.Debug("event subscription is fail: {0}", ex); } } }
public static bool WriteToEventLogDB(object userID, SecurityAuditEvent action, bool success, string alternativeMessage, string errString, string description, SecurityAuditProcessType processType) { if (EidssUserContext.User.IsAuthenticated) { if (!Utils.IsEmpty(userID)) { userID = EidssUserContext.User.ID; } if (Utils.IsEmpty(alternativeMessage)) { alternativeMessage = string.Format("EIDSS log: action=\'{0}\', process = {1}, success=\'{2}\', user=\'{3}\', error = \'{4}\', description =\'{5}\'", action, processType, success, Utils.Str(EidssUserContext.User.Name), Utils.Str(errString), Utils.Str(description)); } using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { manager.SetSpCommand("dbo.spLogSecurityEvent", manager.Parameter("@idfUserID", userID), manager.Parameter("@idfsAction", action), manager.Parameter("@success", success), manager.Parameter("@strErrorText", errString), manager.Parameter("@strDescription", description), manager.Parameter("@idfsProcessType", processType) ); manager.CommandTimeout = 2; manager.ExecuteNonQuery(); } catch (Exception e) { WriteToEventLogWindows(alternativeMessage, AppName, success ? EventLogEntryType.Information : EventLogEntryType.Error, "Application"); WriteToEventLogWindows(string.Format("Error during writing security log to database: {0}", e), AppName, EventLogEntryType.Error, "Application"); Dbg.Debug("security error writing error: {0}", e.ToString()); } } } else { if (Utils.IsEmpty(alternativeMessage)) { alternativeMessage = string.Format("{6} log: action=\'{0}\', process = {1}, success=\'{2}\', user=\'{3}\', error = \'{4}\', description =\'{5}\'", action.ToString(), processType.ToString(), success, "unknown", errString, description, AppName); } WriteToEventLogWindows(alternativeMessage, AppName, success?EventLogEntryType.Information:EventLogEntryType.Error, "Application"); } return(true); }
public static void WriteToResx(string fileName, string key, object newValue) { if (newValue == null || string.IsNullOrWhiteSpace(newValue.ToString())) { return; } var dict = ReadResxDictionary(fileName); if (!dict.ContainsKey(key)) { dict.Add(key, newValue); } else { dict[key] = newValue; } try { lock (m_LockObject) { if (File.Exists(fileName)) { var fi = new FileInfo(fileName) { IsReadOnly = false }; fi.Refresh(); } using (var writer = new ResXResourceWriter(fileName)) { foreach (var keypair in dict) { writer.AddResource(keypair.Key, keypair.Value); } writer.Generate(); writer.Close(); } } } catch (Exception e) { Dbg.Debug("error during resource writing. Resource {0}, error: {1}", fileName, e); throw; } }
public static void ForceResourceAdding() { Activate(); string tmp; string tmpOriginal; BaseStringsStorage.ForceAbsentResourceAdding = true; foreach (string s in Enum.GetNames(typeof(ASPxGridViewStringId))) { tmp = (string)(XtraStrings.Get("ASPxGridViewStringId." + s, XtraGridLocalizer.Active.GetLocalizedString((ASPxGridViewStringId)(Enum.Parse(typeof(ASPxGridViewStringId), s))))); tmpOriginal = ((XtraGridLocalizer)XtraGridLocalizer.Active).GetDefLocalizedString((ASPxGridViewStringId)(Enum.Parse(typeof(ASPxGridViewStringId), s))); if (tmpOriginal != tmp) { Dbg.Debug("Resource {0} is different: original - <{1}>, our - <{2}>", "ASPxGridViewStringId." + s, tmpOriginal, tmp); } } foreach (string s in Enum.GetNames(typeof(ASPxTreeListStringId))) { tmp = (string)(XtraStrings.Get("ASPxTreeListStringId." + s, XtraTreeViewLocalizer.Active.GetLocalizedString((ASPxTreeListStringId)(Enum.Parse(typeof(ASPxTreeListStringId), s))))); tmpOriginal = ((XtraTreeViewLocalizer)ASPxTreeListLocalizer.Active).GetDefLocalizedString((ASPxTreeListStringId)(Enum.Parse(typeof(ASPxTreeListStringId), s))); if (tmpOriginal != tmp) { Dbg.Debug("Resource {0} is different: original - <{1}>, our - <{2}>", "ASPxTreeListStringId." + s, tmpOriginal, tmp); } } foreach (string s in Enum.GetNames(typeof(ASPxperienceStringId))) { tmp = (string)(XtraStrings.Get("ASPxperienceStringId." + s, XtraASPxperienceLocalizer.Active.GetLocalizedString((ASPxperienceStringId)(Enum.Parse(typeof(ASPxperienceStringId), s))))); tmpOriginal = ((XtraASPxperienceLocalizer)XtraASPxperienceLocalizer.Active).GetDefLocalizedString((ASPxperienceStringId)(Enum.Parse(typeof(ASPxperienceStringId), s))); if (tmpOriginal != tmp) { Dbg.Debug("Resource {0} is different: original - <{1}>, our - <{2}>", "ASPxperienceStringId." + s, tmpOriginal, tmp); } } foreach (string s in Enum.GetNames(typeof(ASPxEditorsStringId))) { tmp = (string)(XtraStrings.Get("ASPxEditorsStringId." + s, XtraEditorsLocalizer.Active.GetLocalizedString((ASPxEditorsStringId)(Enum.Parse(typeof(ASPxEditorsStringId), s))))); tmpOriginal = ((XtraEditorsLocalizer)XtraEditorsLocalizer.Active).GetDefLocalizedString((ASPxEditorsStringId)(Enum.Parse(typeof(ASPxEditorsStringId), s))); if (tmpOriginal != tmp) { Dbg.Debug("Resource {0} is different: original - <{1}>, our - <{2}>", "ASPxEditorsStringId." + s, tmpOriginal, tmp); } } BaseStringsStorage.ForceAbsentResourceAdding = false; }