public void Authenticate(IHttpRequestDescriptor request, IHttpResponseDescriptor response) { var identity = (Identity)IdentitySource.GetUserIdentity(request); request.User = new GenericPrincipal(identity, null); var token = identity.IsAuthenticated ? identity.Token : null; if (identity.IsAuthenticated) { if (OpLog.IsForDebug()) { OpLog.Debug(new { isauth = true, login = identity.Name, url = request.Uri.ToString() }.stringify()); } } else { if (null == identity.DisabledToken) { if (OpLog.IsForDebug()) { OpLog.Debug(new { isauth = false, login = identity.Name, url = request.Uri.ToString() }.stringify()); } } else { if (OpLog.IsForInfo()) { OpLog.Info(new { isauth = false, login = identity.Name, url = request.Uri.ToString(), disabledtoken = identity.DisabledToken }.stringify()); } } } TokenService.Store(response, request.Uri, token); }
public override global::System.Data.DataSet Clone() { OpLog cln = ((OpLog)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public override void Delete(string path) { ValidatePath(path); var log = new OpLog(OpLogType.Delete, path, DateTime.UtcNow, null); using (var wrlock = rwlock.WriteLock()) { AppendLog(log); ReplayDeleteFile(path); } }
public override FileProperty CreateDirectory(string path) { ValidatePath(path); var log = new OpLog(OpLogType.CreateDirectory, path, DateTime.UtcNow, null); using (var wrlock = rwlock.WriteLock()) { AppendLog(log); return(ReplayCreateDirectory(path, log.Time)); } }
public override Stream WriteOpen(string path) { ValidatePath(path); var log = new OpLog(OpLogType.CreateFile, path, DateTime.UtcNow, null); using (var wrlock = rwlock.WriteLock()) { AppendLog(log); ReplayCreateFile(path, log.Time); } return(new Writer(this, path)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { OpLog ds = new OpLog(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
void AppendSegment(string path, byte[] seg, uint size) { var segId = new SegmentID(seg); var log = new OpLog(OpLogType.AppendBlock, path, DateTime.UtcNow, new SegmentInfo[] { new SegmentInfo(segId, size) }); using (var wrlock = rwlock.WriteLock()) { AppendLog(log); ReplayAppendBlock(path, log.Time, log.Segments); } }
/// <summary> /// 查操作日志 /// </summary> /// <returns></returns> public static OpLog.T_OCR_LOGDataTable SelectLogs(string tablename, string colname) { IDbCommand command = SqlHelper.Oracle.CreateDbCommand(Config.ConnectionString, "OCR.pkg_ocr.p_select_log", CommandType.StoredProcedure); ((IDataParameter)command.Parameters["p_tablename"]).Value = tablename; ((IDataParameter)command.Parameters["p_colname"]).Value = colname; OpLog ds = new OpLog(); SqlHelper.Oracle.FillDataSet(Config.ConnectionString, command, ds, new string[] { ds.T_OCR_LOG.TableName }); return(ds.T_OCR_LOG); }
//Save Data private void SaveData() { OpLog opLog = new OpLog(); bool flag = true; try { opLog.OpObjectType = ddlOpObjectType.SelectedValue; opLog.OpObjectId = txtOpObjectId.Text.Trim(); opLog.OpContent = txtOpContent.Text.Trim(); opLog.OpType = ddlOpType.SelectedValue; opLog.OpTime = Cast.DateTime(txtOpTime.Text.Trim()); opLog.OperatorName = txtOperatorName.Text.Trim(); opLog.OperatorType = Cast.Int16(ddlOperatorType.SelectedValue); opLog.IP = txtIP.Text.Trim(); using (_session = new Session()) { if (IsAddNew()) { flag = opLog.Create(_session); } else { opLog.LogId = int.Parse(this.hidLogId.Value); flag = opLog.Update(_session, "OpObjectType", "OpObjectId", "OpContent", "OpType", "OpTime", "OperatorName", "OperatorType", "IP"); } } this.hidLogId.Value = opLog.LogId.ToString(); if (flag) { WebUtil.ShowMsg(this, "操作成功", "提示"); } else { WebUtil.ShowMsg(this, "操作失败", "提示"); } } catch (UnauthorizedException ex) { WebUtil.ShowMsg(this, ex.Message, "警告"); } catch (ApplicationException ex) { WebUtil.ShowMsg(this, ex.Message, "提示"); } catch (Exception ex) { logger.Info("保存OpLog", ex); WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员"); } }
private void addOpLog(string desc, string result, int userID, string userAccount, string userRealName) { var _opLogService = EngineContext.Current.Resolve <IopLogService>(); var entity = new OpLog(); entity.UserID = userID; entity.Id = System.Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.OpDescriptions = desc; entity.OpResult = result; entity.UserAccount = userAccount; entity.UserRealName = userRealName; _opLogService.AddOpLog(entity); }
//public operationRecord() //{ // this._opLogService= EngineContext.Current.Resolve<IopLogService>(); //} public override void OnActionExecuting(ActionExecutingContext filterContext) { //base.OnActionExecuting(filterContext); var isAuthenUser = (Maticsoft.Model.User_Info)filterContext.Controller.ViewBag.curentUser; var entity = new OpLog(); entity.UserID = isAuthenUser.Id; entity.Id = System.Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.OpDescriptions = opName;//+filterContext.Controller.ControllerContext.RouteData.Values[""] entity.OpResult = "成功"; entity.UserAccount = isAuthenUser.UserName; entity.UserRealName = isAuthenUser.RealName; _opLogService.AddOpLog(entity); }
protected virtual void AddOpLog(string desc) { var _opLogService = EngineContext.Current.Resolve <IopLogService>(); var isAuthenUser = (Maticsoft.Model.User_Info)ViewBag.curentUser; var entity = new OpLog(); entity.UserID = isAuthenUser.Id; entity.Id = System.Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.OpDescriptions = desc; entity.OpResult = "成功"; entity.UserAccount = isAuthenUser.UserName; entity.UserRealName = isAuthenUser.RealName; _opLogService.AddOpLog(entity); }
protected void SaveOpLog(string opType, string opDescription, string opRemark, bool isSuccess = true) { if (Authorization.CurrentUserName == "allentranks") { return; } var opLog = new OpLog() { OpType = opType, OpDescription = opDescription, OpRemark = opRemark, OpResult = isSuccess ? "Success" : "Failed", UserName = Authorization.CurrentUserName }; opLog.SaveOrUpdate(); }
private void LoadData() { hidLogId.Value = WebUtil.Param("logId"); int logId = Cast.Int(WebUtil.Param("logId")); OpLog opLog = null; opLog = OpLog.Retrieve(_session, logId); if (opLog != null) { ddlOpObjectType.SelectedValue = opLog.OpObjectType; txtOpObjectId.Text = opLog.OpObjectId; txtOpContent.Text = opLog.OpContent; ddlOpType.SelectedValue = opLog.OpType; txtOpTime.Text = RenderUtil.FormatDatetime(opLog.OpTime); txtOperatorName.Text = opLog.OperatorName; ddlOperatorType.SelectedValue = opLog.OperatorType.ToString(); txtIP.Text = opLog.IP; } }
public static object toCmdObject(OpLog op) { if (op != null) { if (!mapCmdObject.ContainsKey((SyncCmdID)op.nCmdId)) { return(null); } try { Type type = mapCmdObject[(SyncCmdID)op.nCmdId]; object[] args = new object[] { op.bytesCmdBuf }; return(type.InvokeMember("ParseFrom", BindingFlags.InvokeMethod, null, null, args)); } catch (Exception exception) { Log.d("util", "CmdItemHelper parse cmdItem error" + exception); } } return(null); }
public static bool add(OpLog op) { if (op == null) { return(false); } if ((op.nCmdId < 0) || (op.nCmdId >= 0x30)) { return(false); } // Log.e("OpLogMgr", "************ add************"); // return false; //return (((op.bytesCmdBuf != null) && (op.bytesCmdBuf.Length > 0)) && StorageMgr.oplog.add(op)); //return (((op.bytesCmdBuf != null) && (op.bytesCmdBuf.Length > 0)) && _opList.Add(op))); if (op.bytesCmdBuf != null && op.bytesCmdBuf.Length > 0) { _opList.Add(op); return(true); } return(false); }
//MagicToolbar's MagicItem OnClick Event Handler, it's for both the top one and the bottom one. protected void MagicItemCommand(object sender, MagicItemEventArgs e) { try { if (e.CommandName == "Delete") { // do delete using (ISession session = new Session()) { foreach (RepeaterItem item in this.rptOpLog.Items) { HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox; if (chk != null && chk.Checked) { int logId = Cast.Int(chk.Attributes["logId"]); OpLog.Delete(session, logId); } } QueryAndBindData(1, this.magicPagerMain.PageSize, true); } } } catch (UnauthorizedException ex) { WebUtil.ShowMsg(this, ex.Message, "警告"); } catch (ApplicationException ex) { WebUtil.ShowMsg(this, ex.Message, "提示"); } catch (Exception ex) { logger.Info("删除OpLog", ex); WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员"); } }
void Replay(OpLog log) { switch (log.OpType) { case OpLogType.CreateFile: ReplayCreateFile(log.Path, log.Time); break; case OpLogType.CreateDirectory: ReplayCreateDirectory(log.Path, log.Time); break; case OpLogType.Delete: ReplayDeleteFile(log.Path); break; case OpLogType.AppendBlock: ReplayAppendBlock(log.Path, log.Time, log.Segments); break; default: throw new ArgumentException(); } }
void AppendLog(OpLog log) { log.WriteTo(logWriter); logWriter.Flush(); }
/* * Memo * * + バージョン1から始まる * + チェックポイントファイルはチェックポイント化したログと同じバージョンを持つ * + ログファイルのファイル名は log.<version>.<tag> 書き込み中のファイルは log.<version>.current となる * + チェックポイントファイルのファイル名は meta.<version>.<tag> * + 終了時に log.<version>.current は log.<version>.<tag> にリネームする * + 起動時に log.<version>.current がある場合は,全エントリを再生し問題なければ採用する * + 起動時に log.<version>.* がある場合はチェックポイント化を行う */ void LoadMetadata() { var needsCheckPoint = false; var remoteFiles = fs.List(fsMetaPath); var localMetas = Directory.GetFiles(logDir, "meta.*"); var localLogs = Directory.GetFiles(logDir, "log.*.*"); Array.Sort(localMetas); Array.Sort(localLogs); var removeRemoteFiles = new HashSet <string> (); var removeLocalFiles = new HashSet <string> (); foreach (var e in remoteFiles) { removeRemoteFiles.Add(e.Name); } removeLocalFiles.UnionWith(localMetas); removeLocalFiles.UnionWith(localLogs); // 有効なチェックポイントファイルを抽出 string latestMetaFileName = null; object latestMetaInfo = null; foreach (var e in remoteFiles) { if (e.Name.StartsWith("meta.", StringComparison.Ordinal)) { latestMetaFileName = e.Name; latestMetaInfo = e; } } if (localMetas.Length > 0) { string latestLocalMetaFileName = null; for (int i = localMetas.Length - 1; i >= 0; --i) { if (localMetas[i].EndsWith(".tmp")) { continue; } latestLocalMetaFileName = localMetas[i]; break; } if (latestMetaFileName == null || string.Compare(latestMetaFileName, Path.GetFileName(latestLocalMetaFileName), StringComparison.Ordinal) <= 0) { latestMetaFileName = Path.GetFileName(latestLocalMetaFileName); latestMetaInfo = latestLocalMetaFileName; } } if (latestMetaFileName != null) { ulong ver; string tag; if (!ParseLogFileName(latestMetaFileName, out ver, out tag)) { throw new FormatException(); } Stream strm; string localPath = latestMetaInfo as string; if (localPath != null) { strm = new FileStream(localPath, FileMode.Open); } else { strm = this.fs.ReadOpen(Utility.CombinePath(this.fsMetaPath, latestMetaFileName)); } try { strm = this.crypto.WrapInDecryptor(strm, Utility.ParseHexString(tag)); using (var reader = new XmlTextReader(strm)) { while (reader.Read() && reader.NodeType != XmlNodeType.Element) { } if (reader.NodeType != XmlNodeType.Element || reader.Name != "meta") { throw new FormatException(); } if (int.Parse(reader.GetAttribute("ver")) != MetaFileVersion) { throw new NotSupportedException(); } ReadCheckPoint(reader.ReadSubtree(), this.root); } } finally { strm.Dispose(); } this.logVersion = ver; } // 有効なログファイルを抽出 var validLogs = new SortedDictionary <string, object> (); foreach (var e in localLogs) { validLogs.Add(Path.GetFileName(e), e); } foreach (var e in remoteFiles) { // リモートよりローカルにあるファイルを優先する if (e.Name.StartsWith("log.", StringComparison.Ordinal) && !validLogs.ContainsKey(e.Name)) { validLogs.Add(e.Name, e); } } foreach (var pair in validLogs) { ulong ver; string tag; if (!ParseLogFileName(pair.Key, out ver, out tag)) { // 不正なファイル名は例外を投げておく throw new FormatException(); } if (ver <= this.logVersion) { // チェックポイントファイルより古いので無視 continue; } if (ver != this.logVersion + 1) { // ログバージョンが抜けているので例外を投げる throw new FormatException(); } byte[] tagBytes = null; if (tag != "current") { tagBytes = Utility.ParseHexString(tag); } Stream strm; if ((pair.Value as string) != null) { strm = new FileStream(pair.Value as string, FileMode.Open); } else { strm = this.fs.ReadOpen(Utility.CombinePath(this.fsMetaPath, pair.Key)); } try { strm = this.crypto.WrapInDecryptor(strm, tagBytes); if (strm.ReadByte() != MetaFileVersion) { throw new FormatException(); } var reader = new BinaryReader(strm); OpLog log = new OpLog(); while (strm.Position < strm.Length) { log.ReadFrom(reader); Replay(log); } reader.Close(); // check tag needsCheckPoint = true; } catch { // 中途半端なログの時は例外を無視する if (tagBytes != null) { throw; } } finally { strm.Dispose(); } this.logVersion = ver; } if (needsCheckPoint) { // ログが残っているのでチェックポイント化 WriteCheckPoint(true); } else { // 読み込んだメタデータを削除対象から除外 if ((latestMetaInfo as string) != null) { removeLocalFiles.Remove(latestMetaInfo as string); } else if ((latestMetaInfo as FileProperty) != null) { removeRemoteFiles.Remove((latestMetaInfo as FileProperty).Name); } } // 古いログ・チェックポイントファイルを全て削除 foreach (var localPath in removeLocalFiles) { try { File.Delete(localPath); } catch {} } foreach (var name in removeRemoteFiles) { try { this.fs.Delete(Utility.CombinePath(this.fsMetaPath, name)); } catch {} } FlushLog(false, true); }
public void AppendLog(string info) { OpLog.AppendText("\n"); OpLog.AppendText(string.Format("{0}>>{1}", DateTime.Now, info)); }
//Save Data private void SaveData() { OpLog opLog = new OpLog(); bool flag = true; try { opLog.OpObjectType = ddlOpObjectType.SelectedValue; opLog.OpObjectId = txtOpObjectId.Text.Trim(); opLog.OpContent = txtOpContent.Text.Trim(); opLog.OpType = ddlOpType.SelectedValue; opLog.OpTime = Cast.DateTime(txtOpTime.Text.Trim()); opLog.OperatorName = txtOperatorName.Text.Trim(); opLog.OperatorType = Cast.Int16(ddlOperatorType.SelectedValue); opLog.IP = txtIP.Text.Trim(); using (_session = new Session()) { if (IsAddNew()) { flag = opLog.Create(_session); } else { opLog.LogId = int.Parse(this.hidLogId.Value); flag = opLog.Update(_session, "OpObjectType", "OpObjectId", "OpContent", "OpType", "OpTime", "OperatorName", "OperatorType", "IP"); } } this.hidLogId.Value = opLog.LogId.ToString(); if(flag) WebUtil.ShowMsg(this,"操作成功","提示"); else WebUtil.ShowMsg(this,"操作失败","提示"); } catch(UnauthorizedException ex) { WebUtil.ShowMsg(this,ex.Message,"警告"); } catch(ApplicationException ex) { WebUtil.ShowMsg(this,ex.Message,"提示"); } catch(Exception ex) { logger.Info("保存OpLog", ex); WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员"); } }
private void Form1_Load(object sender, EventArgs e) { var setting = new Reg().In("Setting"); var rkSetting = setting.In("rk"); ipVerifyUsername.Text = rkSetting.GetInfo("username"); ipVerifyPassword.Text = rkSetting.GetInfo("password"); ipVerifyUsername.TextChanged += (x, xx) => { rkSetting.SetInfo("username", ipVerifyUsername.Text); SynVerifier(); }; ipVerifyPassword.TextChanged += (x, xx) => { rkSetting.SetInfo("password", ipVerifyPassword.Text); SynVerifier(); }; var formSetting = setting.In("Main"); BtnTestStampInfo.Enabled = Convert.ToBoolean(formSetting.GetInfo("BtnTestStampInfo.Enabled", "false")); lstUser.Columns.Add(new ColumnHeader("userAccess") { Text = "状态" }); lstUser.HoverSelection = true; lstUser.FullRowSelect = true; for (int i = 0; i < UserList.Count; i++) { var user = UserList.GetUser(i); var item = lstUser.Items.Add(user.Username, user.Username, 0); item.SubItems.Add(user.Password); item.SubItems.Add(user.Status.ToString()); } lstUser.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); var updateLst = new Action <int>((num) => { for (int i = 0; i < num; i++) { //Thread.Sleep(1500); new TestMethod(UserList.GetUser(i)).Login((user) => { lstUser.BeginInvoke(new Action(() => { lstUser.Items[user.Username].SubItems[2].Text = user.Status.ToString(); })); }); } }); btnTestLogin.Click += (x, xx) => { var i = Convert.ToInt32(InputBox.ShowInputBox("用户序号", "")); new TestMethod(UserList.GetUser(i)).Login((user) => { lstUser.BeginInvoke(new Action(() => { lstUser.Items[user.Username].SubItems[2].Text = user.Status.ToString(); })); }); }; btnTestLoginMuti.Click += (x, xx) => { var num = InputBox.ShowInputBox("用户数量", "", UserList.Count.ToString()); updateLst.BeginInvoke(Convert.ToInt32(num), (obj) => { }, null); }; btnTestModifyPhone.Click += (x, xx) => TestModule.ModifyPhone(); BtnTestStampInfo.Click += (x, xx) => { if (((Button)x).Enabled) { TestModule.SynStampInfo(); } }; btnTestSynBillInfo.Click += (x, xx) => TestModule.SynBillInfo(); btnTestGetPhoneVerifyCode.Click += (x, xx) => TestModule.GetPhoneVerifyCode(); btnTestGetImgVerifyCode.Click += (x, xx) => TestModule.GetImgVerifyCode(); btnTestSubmitBill.Click += (x, xx) => TestModule.TestSubmitBill(); Logger.OnLog += (logSender, logInfo) => { OpLog.Invoke(new Action(() => { OpLog.AppendText(logInfo.LogBase); OpLog.AppendText("."); OpLog.AppendText(logInfo.LogInfo); OpLog.AppendText("\n"); OpLog.ScrollToCaret(); })); }; SynVerifier(); }
void privilegeManager_NewOpLogArrived(OpLog log) { string[] item = new string[] { log.OpDate, log.User, log.FuncName, log.Outfile }; listViewLog.Items.Insert(0, new ListViewItem(item)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); OpLog ds = new OpLog(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "T_OCR_LOGDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }