Пример #1
0
        public static bool Record(LogType logType, OpType opType, string title, string opName, int relationCode, string createUserCode, string createUserName)
        {
            LOGBASE log = new LOGBASE();

            log.createTime     = DateTime.Now;
            log.createUserCode = createUserCode;
            log.createUserName = createUserName;
            log.logType        = logType.ToString();
            log.opType         = opType.ToString();
            log.opName         = opName;
            //设置关联项
            log.relationCode = relationCode;
            log.title        = title;
            //是否设置回滚

            //合成最终日志
            log.remark = $"{createUserName} {opName} {title}";
            using (var db = DbContext.GetInstance("T_LOG"))
            {
                try
                {
                    db.Insert(log);
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        public override String ToString()
        {
            // C1250MAY10 1 1$
            String result;

            result = OpType.ToString().Substring(0, 1) + StrikePrice.ToString() + Expiration.ToString("MMMyy", CultureInfo.InvariantCulture) + "  " + Quantity.ToString() + "  " + Premium.ToString() + "$";
            return(result);
        }
Пример #3
0
        public override String ToString()
        {
            // C1250MAY10
            String result;

            result = OpType.ToString().Substring(0, 1) + StrikePrice.ToString() + Expiration.ToString("MMMyy", CultureInfo.InvariantCulture);
            return(result);
        }
Пример #4
0
        public static string GetStringValue(this OpType enumValue)
        {
            switch (enumValue)
            {
            case OpType.Index: return("index");

            case OpType.Create: return("create");
            }
            throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'OpType'");
        }
Пример #5
0
            public JsonValue ToJson()
            {
                dynamic copy = new JsonObject();

                if (!string.IsNullOrWhiteSpace(Name))
                {
                    copy.name = Name;
                }
                if (!string.IsNullOrWhiteSpace(Locale))
                {
                    copy.locale = Locale;
                }
                if (this.Optype != OpType.Error)
                {
                    copy.optype = OpType.ToString().ToLower();
                }
                if (MissingTokens.Count > 0)
                {
                    copy.missing_tokens = new JsonArray(MissingTokens.Select(t => (JsonValue)t));
                }

                return(copy);
            }
Пример #6
0
        /// <summary>
        /// Executes the associated filesystem operation
        /// </summary>
        public void Run()
        {
            try
            {
                switch (OpType)
                {
                case Type.None:
                    return;

                case Type.CreateDir:
                    DoCreateDir();
                    return;

                case Type.DeleteFile:
                    DoDeleteFile();
                    return;

                case Type.DeleteDir:
                    DoDeleteDir();
                    return;

                case Type.WriteFile:
                    DoWriteFile();
                    return;

                case Type.ReadFile:
                    DoReadFile();
                    return;

                case Type.CopyFile:
                    DoCopyFile();
                    return;

                case Type.MoveDir:
                    DoMoveDir();
                    return;

                case Type.Probe:
                    DoProbe();
                    return;

                case Type.EnumerateDir:
                    DoEnumerateDir();
                    return;

                case Type.CreateSymlink:
                    DoCreateSymlink();
                    return;

                case Type.CreateHardlink:
                    DoCreateHardlink();
                    return;

                case Type.WriteFileWithRetries:
                    DoOperationWithRetries(DoWriteFile);
                    return;

                case Type.DeleteFileWithRetries:
                    DoOperationWithRetries(DoDeleteFile);
                    return;

                case Type.Echo:
                    DoEcho();
                    return;

                case Type.Block:
                    DoBlock();
                    return;

                case Type.ReadStdIn:
                    DoReadStdIn();
                    return;

                case Type.EchoCurrentDirectory:
                    DoEchoCurrentDirectory();
                    return;

                case Type.Spawn:
                    DoSpawn();
                    return;

                case Type.AppendNewLine:
                    DoWriteFile(Environment.NewLine);
                    return;

                case Type.Fail:
                    DoFail();
                    return;

                case Type.WriteFileIfInputEqual:
                    DoWriteFileIfInputEqual();
                    return;
                }
            }
            catch (Exception e)
            {
                // Print error and exit with failure if any operation fails
                Console.Error.WriteLine("The test process failed to execute an operation: " + OpType.ToString());
                Console.Error.WriteLine(e);
                Environment.Exit(1);
            }
        }
Пример #7
0
            internal static string ToString(OpType op)
            {
                // perf: Enum.ToString() actually is very perf intensive in time & memory
                switch (op)
                {
                case OpType.Aggregate:
                    return("Aggregate");

                case OpType.And:
                    return("And");

                case OpType.Case:
                    return("Case");

                case OpType.Cast:
                    return("Cast");

                case OpType.Collect:
                    return("Collect");

                case OpType.Constant:
                    return("Constant");

                case OpType.ConstantPredicate:
                    return("ConstantPredicate");

                case OpType.CrossApply:
                    return("CrossApply");

                case OpType.CrossJoin:
                    return("CrossJoin");

                case OpType.Deref:
                    return("Deref");

                case OpType.Distinct:
                    return("Distinct");

                case OpType.Divide:
                    return("Divide");

                case OpType.Element:
                    return("Element");

                case OpType.EQ:
                    return("EQ");

                case OpType.Except:
                    return("Except");

                case OpType.Exists:
                    return("Exists");

                case OpType.Filter:
                    return("Filter");

                case OpType.FullOuterJoin:
                    return("FullOuterJoin");

                case OpType.Function:
                    return("Function");

                case OpType.GE:
                    return("GE");

                case OpType.GetEntityRef:
                    return("GetEntityRef");

                case OpType.GetRefKey:
                    return("GetRefKey");

                case OpType.GroupBy:
                    return("GroupBy");

                case OpType.GroupByInto:
                    return("GroupByInto");

                case OpType.GT:
                    return("GT");

                case OpType.In:
                    return("In");

                case OpType.InnerJoin:
                    return("InnerJoin");

                case OpType.InternalConstant:
                    return("InternalConstant");

                case OpType.Intersect:
                    return("Intersect");

                case OpType.IsNull:
                    return("IsNull");

                case OpType.IsOf:
                    return("IsOf");

                case OpType.LE:
                    return("LE");

                case OpType.Leaf:
                    return("Leaf");

                case OpType.LeftOuterJoin:
                    return("LeftOuterJoin");

                case OpType.Like:
                    return("Like");

                case OpType.LT:
                    return("LT");

                case OpType.Minus:
                    return("Minus");

                case OpType.Modulo:
                    return("Modulo");

                case OpType.Multiply:
                    return("Multiply");

                case OpType.MultiStreamNest:
                    return("MultiStreamNest");

                case OpType.Navigate:
                    return("Navigate");

                case OpType.NE:
                    return("NE");

                case OpType.NewEntity:
                    return("NewEntity");

                case OpType.NewInstance:
                    return("NewInstance");

                case OpType.DiscriminatedNewEntity:
                    return("DiscriminatedNewEntity");

                case OpType.NewMultiset:
                    return("NewMultiset");

                case OpType.NewRecord:
                    return("NewRecord");

                case OpType.Not:
                    return("Not");

                case OpType.Null:
                    return("Null");

                case OpType.NullSentinel:
                    return("NullSentinel");

                case OpType.Or:
                    return("Or");

                case OpType.OuterApply:
                    return("OuterApply");

                case OpType.PhysicalProject:
                    return("PhysicalProject");

                case OpType.Plus:
                    return("Plus");

                case OpType.Project:
                    return("Project");

                case OpType.Property:
                    return("Property");

                case OpType.Ref:
                    return("Ref");

                case OpType.RelProperty:
                    return("RelProperty");

                case OpType.ScanTable:
                    return("ScanTable");

                case OpType.ScanView:
                    return("ScanView");

                case OpType.SingleRow:
                    return("SingleRow");

                case OpType.SingleRowTable:
                    return("SingleRowTable");

                case OpType.SingleStreamNest:
                    return("SingleStreamNest");

                case OpType.SoftCast:
                    return("SoftCast");

                case OpType.Sort:
                    return("Sort");

                case OpType.Treat:
                    return("Treat");

                case OpType.UnaryMinus:
                    return("UnaryMinus");

                case OpType.UnionAll:
                    return("UnionAll");

                case OpType.Unnest:
                    return("Unnest");

                case OpType.VarDef:
                    return("VarDef");

                case OpType.VarDefList:
                    return("VarDefList");

                case OpType.VarRef:
                    return("VarRef");

                case OpType.ConstrainedSort:
                    return("ConstrainedSort");

                default:
                    Debug.Assert(false, "need to special case enum->string: " + op.ToString());
                    return(op.ToString());
                }
            }
Пример #8
0
        /// <summary>
        /// Executes the associated filesystem operation
        /// </summary>
        public void Run()
        {
            // Make sure the string version of the paths are set in case the operation is run outside of the context of
            // TestProcess.exe
            if (LinkPath.IsValid)
            {
                LinkPathAsString = LinkPath.Path.ToString(PathTable);
            }
            if (Path.IsValid)
            {
                PathAsString = Path.Path.ToString(PathTable);
            }

            try
            {
                switch (OpType)
                {
                case Type.None:
                    return;

                case Type.CreateDir:
                    DoCreateDir();
                    return;

                case Type.DeleteFile:
                    DoDeleteFile();
                    return;

                case Type.DeleteDir:
                    DoDeleteDir();
                    return;

                case Type.WriteFile:
                    DoWriteFile();
                    return;

                case Type.ReadAndWriteFile:
                    DoReadAndWriteFile();
                    return;

                case Type.ReadFile:
                    DoReadFile();
                    return;

                case Type.ReadRequiredFile:
                    DoReadRequiredFile();
                    return;

                case Type.CopyFile:
                    DoCopyFile();
                    return;

                case Type.MoveDir:
                    DoMoveDir();
                    return;

                case Type.Probe:
                    DoProbe();
                    return;

                case Type.EnumerateDir:
                    DoEnumerateDir();
                    return;

                case Type.CreateSymlink:
                    DoCreateSymlink();
                    return;

                case Type.CreateHardlink:
                    DoCreateHardlink();
                    return;

                case Type.WriteFileWithRetries:
                    DoOperationWithRetries(DoWriteFile);
                    return;

                case Type.DeleteFileWithRetries:
                    DoOperationWithRetries(DoDeleteFile);
                    return;

                case Type.Echo:
                    DoEcho();
                    return;

                case Type.Block:
                    DoBlock();
                    return;

                case Type.ReadStdIn:
                    DoReadStdIn();
                    return;

                case Type.EchoCurrentDirectory:
                    DoEchoCurrentDirectory();
                    return;

                case Type.Spawn:
                    DoSpawn();
                    return;

                case Type.AppendNewLine:
                    DoWriteFile(Environment.NewLine);
                    return;

                case Type.Fail:
                    DoFail();
                    return;

                case Type.WriteFileIfInputEqual:
                    DoWriteFileIfInputEqual();
                    return;

                case Type.LaunchDebugger:
                    Debugger.Launch();
                    return;

                case Type.MoveFile:
                    DoMoveFile();
                    return;

                case Type.SucceedOnRetry:
                    DoSucceedOnRetry();
                    return;

                case Type.WaitUntilFileExists:
                    DoWaitUntilFileExists();
                    return;
                }
            }
            catch (Exception e)
            {
                // Print error and exit with failure if any operation fails
                Console.Error.WriteLine("The test process failed to execute an operation: " + OpType.ToString());
                Console.Error.WriteLine(e);
                Environment.Exit(1);
            }
        }
Пример #9
0
 public string ToShortString()
 {
     return($"{OpType.ToString()[0]}{(Bet != 0 ? Bet.ToString() : "")}");
 }
Пример #10
0
 private static string GetTitle(OpType type)
 {
     return(type.ToString() + " Function");
 }
 public List<TtPoint> GetPoints(OpType op)
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat("{0} = '{1}'",
         TwoTrailsSchema.PointSchema.Operation,
         op.ToString());
     return GetPoints(sb.ToString());
 }
        /// <summary>
        /// Return the # of points of OpType op by looking in the points table.
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public long GetPointCount(OpType op)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendFormat("select count(*) from {0} where {1} = {2}", TwoTrailsSchema.PointSchema.TableName,
                TwoTrailsSchema.PointSchema.Operation,
                op.ToString());

            return GetCount(sql.ToString());
        }