Exemplo n.º 1
0
        public async Task <IActionResult> CreateDB(string test)
        {
            try
            {
                using (var cont = new CheckContext(Configuration["ConnectionStrings:database"]))
                {
                    cont.Database.EnsureCreated();
                    cont.Users.Add(new User {
                        Login = "******", Mail = "*****@*****.**", Password = "******"
                    });
                    await cont.SaveChangesAsync();

                    cont.Users.Remove(cont.Users.FirstOrDefault(x => x.Login == "Temp" && x.Mail == "*****@*****.**" && x.Password == "temp"));
                    await cont.SaveChangesAsync();
                }
                return(Ok(new Message {
                    Code = MessageCode.error, Text = $"Database has been successfully created"
                }));
            } catch (Exception exc)
            {
                return(Ok(new Message {
                    Code = MessageCode.error, Text = $"There was some troubles while creating a DataBase. Error:{exc.Message}", Data = exc.StackTrace
                }));
            }
        }
Exemplo n.º 2
0
 public static Error emptyCollection(
     Object o, FieldHierarchyStr hierarchy, CheckContext context
     ) => new Error(
     Type.EmptyCollection,
     $"{context}. Property: {hierarchy.s}",
     o
     );
Exemplo n.º 3
0
            public CheckNotification AddCheckNotification(bool isHealthy)
            {
                using (var checkContext = new CheckContext(Options))
                {
                    var check = new Check {
                        Name = CheckName
                    };
                    var checkNotification = new CheckNotification
                    {
                        Check       = check,
                        CheckResult = new CheckResult
                        {
                            Check      = check,
                            CheckBatch = new CheckBatch(),
                            Type       = isHealthy ? CheckResultType.Success : CheckResultType.Failure
                        },
                        IsHealthy = isHealthy,
                        Version   = 1
                    };

                    checkContext.CheckNotifications.Add(checkNotification);
                    checkContext.SaveChanges();

                    return(checkNotification);
                }
            }
Exemplo n.º 4
0
        private static async Task CheckForVideoFile(string item, string title, string setName, dynamic obj)
        {
            var file = new FileInfo(item);

            if (obj != null && obj.data?.filelen != file.Length)
            {
                Logger.Warn($"file {title} {setName} reuploading");
                await Cloud.DeleteFile(BucketName, $"/{title}/{setName}.mp4");

                await Cloud.SliceUploadFile(BucketName, $"/{title}/{setName}.mp4", item);

                using (var context = new AnimateDatabaseContext())
                    using (var ctx = new CheckContext())
                    {
                        var id = context.AnimateList.FirstOrDefault(anime => anime.EnUs == title).Id;
                        if (id != -1)
                        {
                            if (ctx.CheckList.Count(check => check.ID == id && check.SetName == setName) == 0)
                            {
                                ctx.CheckList.Add(new CheckModel {
                                    ItemID = id, Name = title, SetName = setName
                                });
                            }
                            if (ShareToWeibo && ctx.WeiboList.Count(check => check.ID == id && check.SetName == setName) == 0)
                            {
                                ctx.WeiboList.Add(new WeiboModel {
                                    ItemID = id, Name = title, SetName = setName, ZhTW = ""
                                });
                            }
                            ctx.SaveChanges();
                        }
                    }
                Logger.Info($"reupload {title} {setName} complete");
            }
        }
        public virtual void Check(CheckContext context)
        {
            var localItems = context.Of <LocalPathItems>().Value;

            var file = localItems
                       .Where(f => Path.GetFileName(f) == "AssemblyInfo.cs")
                       .ToList();

            if (file.Count == 0)
            {
                throw new CheckException("Cannot find assembly information file.");
            }

            if (file.Count > 1)
            {
                throw new CheckException($"There should be only one assembly information file, but {file.Count} files were found.");
            }

            if (file[0] == @"Properties\AssemblyInfo.cs")
            {
                return;
            }

            throw new CheckException("Project file should be named 'AssemblyInfo.cs' and placed in 'Properties' folder.");
        }
Exemplo n.º 6
0
 public static Error badTextFieldTag(
     Object o, FieldHierarchyStr hierarchy, CheckContext context
     ) => new Error(
     Type.TextFieldBadTag,
     $"{context}. Property: {hierarchy.s}",
     o
     );
Exemplo n.º 7
0
 public static Error requiredComponentMissing(
     GameObject go, System.Type requiredType, System.Type requiredBy, CheckContext context
     ) => new Error(
     Type.MissingRequiredComponent,
     $"{context}. {requiredType} missing (required by {requiredBy})",
     go
     );
Exemplo n.º 8
0
 public static Error duplicateUniqueValueError(
     string category, object fieldValue, Object checkedObject, CheckContext context
     ) => new Error(
     Type.DuplicateUniqueValue,
     $"{context}. Duplicate value '{fieldValue}' in category '{category}'",
     checkedObject
     );
Exemplo n.º 9
0
 public static Error textFieldBadTag(
     Object o, string hierarchy, CheckContext context
     ) => new Error(
     Type.TextFieldBadTag,
     $"{context}. Property: {hierarchy}",
     o
     );
Exemplo n.º 10
0
 public static Error nullReference(
     Object o, string hierarchy, CheckContext context
     ) => new Error(
     Type.NullReference,
     $"{context}. Property: {hierarchy}",
     o
     );
Exemplo n.º 11
0
 private static async Task CheckQuality()
 {
     using (var ctx = new CheckContext())
     {
         if (EnableAdvLogging)
         {
             Logger.Info("checking for quality");
         }
         for (int i = 0; i < ctx.CheckList.Count(); i++)
         {
             var item = ctx.CheckList.ToList()[i];
             if (EnableAdvLogging)
             {
                 Logger.Info($"checking for {item} quality");
             }
             if (CheckForVideoQuality(item.Name, item.SetName, await AutoRetry(Cloud.GetFileStat(BucketName, $"/{item.Name}/{item.SetName}.mp4"))))
             {
                 ctx.CheckList.Remove(item);
                 ctx.SaveChanges();
                 if (EnableAdvLogging)
                 {
                     Logger.Info($"{item} quality is done, remove");
                 }
             }
         }
         if (EnableAdvLogging)
         {
             Logger.Info("checking for quality is done");
         }
     }
 }
        public virtual void Check(CheckContext context)
        {
            var projectFile      = context.Of <ProjectFile>().Value;
            var localItems       = context.Of <LocalPathItems>().Value;
            var projectExtension = context.Of <ProjectExtension>().Value;

            var file = localItems
                       .Where(f => Path.GetExtension(f) == "." + projectExtension)
                       .ToList();

            if (file.Count == 0)
            {
                throw new CheckException($"Cannot find project file '*.{projectExtension}'.");
            }

            if (file.Count > 1)
            {
                throw new CheckException($"There should be only one project file '*.{projectExtension}', but {file.Count} files were found.");
            }

            if (file[0] == projectFile)
            {
                return;
            }

            throw new CheckException($"Project file should be named '{projectFile}' and placed in project root folder.");
        }
Exemplo n.º 13
0
 public static Error emptyCollection(
     Object o, string hierarchy, CheckContext context
     ) => new Error(
     Type.EmptyCollection,
     $"{context}. Property: {hierarchy}",
     o
     );
Exemplo n.º 14
0
 public static Error unityEventInvalid(
     Object o, string property, int number, CheckContext context
     ) => new Error(
     Type.UnityEventInvalid,
     $"UnityEvent {property} callback number {number} is not valid in {context}.",
     o
     );
Exemplo n.º 15
0
 public static Error missingReference(
     Object o, string property, CheckContext context
     ) => new Error(
     Type.MissingReference,
     $"{context}. Property: {property}",
     o
     );
Exemplo n.º 16
0
 public static Error customError(
     Object o, FieldHierarchyStr hierarchy, ErrorMsg error, CheckContext context
     ) => new Error(
     Type.CustomValidation,
     $"{context}. Property: {hierarchy.s}. Error: {error}",
     o
     );
Exemplo n.º 17
0
 public static Error customError(
     Object o, FieldHierarchyStr hierarchy, ErrorMsg error, CheckContext context, bool useErrorMessageContext
     ) => new Error(
     Type.CustomValidation,
     $"{context}. Property: {hierarchy.s}. Error: {error}",
     useErrorMessageContext ? error.context.getOrElse(o) : o
     );
Exemplo n.º 18
0
 public static Error nullReference(
     Object o, FieldHierarchyStr hierarchy, CheckContext context
     ) => new Error(
     Type.NullReference,
     $"{context}. Property: {hierarchy.s}",
     o
     );
Exemplo n.º 19
0
        public override string Get(CheckContext context)
        {
            var name = context.Of <LocalName>().Value;
            var ext  = context.Of <ProjectExtension>().Value;

            return($"{name}.{ext}");
        }
Exemplo n.º 20
0
 public static Error customValidationException(
     Object o, FieldHierarchyStr hierarchy, Exception exception, CheckContext context
     ) => new Error(
     Type.CustomValidationException,
     $"{context}. Property: {hierarchy.s}. Error while running {nameof(OnObjectValidate)}:\n{exception}",
     o
     );
Exemplo n.º 21
0
		public void Check(CheckContext context)
		{
			var debug = context.ProjectDebugProperties.Result;
			debug.CheckRequired("OutputPath", @"bin\");

			var release = context.ProjectReleaseProperties.Result;
			release.CheckRequired("OutputPath", @"bin\");
		}
Exemplo n.º 22
0
 public static Error unityEventInvalid(
     Object o, FieldHierarchyStr hierarchy, int index, CheckContext context
     ) => new Error(
     Type.UnityEventInvalid,
     $"{unityEventMessagePrefix(hierarchy.s, index)} is not valid " +
     unityEventMessageSuffix(context),
     o
     );
Exemplo n.º 23
0
		/// <summary>
		/// Loads required data.
		/// </summary>
		public void Load(CheckContext context)
		{
			var remotePath = context.Of<RemotePath>().Value;
			SolutionPath = Path.GetDirectoryName(remotePath).Replace('\\', '/');

			if (context.Args.DebugMode)
				Console.WriteLine($"{nameof(SolutionPath)} = {SolutionPath}");
		}
Exemplo n.º 24
0
 public static Error unityEventInvalid(
     Object o, string property, int index, CheckContext context
     ) => new Error(
     Type.UnityEventInvalid,
     $"{unityEventMessagePrefix(property, index)} is not valid " +
     unityEventMessageSuffix(context),
     o
     );
Exemplo n.º 25
0
        public static ImmutableList <Error> checkComponent(
            CheckContext context, Object component, Option <CustomObjectValidator> customObjectValidatorOpt
            )
        {
            var errors = ImmutableList <Error> .Empty;

            foreach (var mb in F.opt(value: component as MonoBehaviour))
            {
                var componentType = component.GetType();
                if (!context.checkedComponentTypes.Contains(item: componentType))
                {
                    errors  = errors.AddRange(items: checkComponentType(context: context, go: mb.gameObject, type: componentType));
                    context = context.withCheckedComponentType(c: componentType);
                }
            }

            var serObj = new SerializedObject(obj: component);
            var sp     = serObj.GetIterator();

            while (sp.NextVisible(enterChildren: true))
            {
                if (
                    sp.propertyType == SerializedPropertyType.ObjectReference &&
                    sp.objectReferenceValue == null &&
                    sp.objectReferenceInstanceIDValue != 0
                    )
                {
                    errors = errors.Add(value: Error.missingReference(
                                            o: component, property: sp.name, context: context
                                            ));
                }

                if (sp.type == nameof(UnityEvent))
                {
                    var evt = sp.findFieldValueInObject(component).flatMap(o => F.opt(o as UnityEvent)).getOrThrow(() =>
                                                                                                                   new Exception(
                                                                                                                       $"There should have been a {nameof(UnityEvent)} in property '{sp.name}' " +
                                                                                                                       $"on '{component}' @ '{AssetDatabase.GetAssetPath(component)}', " +
                                                                                                                       $"but we could not find it! This seems like a programmer error!"
                                                                                                                       )
                                                                                                                   );
                    errors = errors.AddRange(checkUnityEvent(
                                                 evt: evt, component: component, propertyName: sp.name, context: context
                                                 ).asEnum());
                }
            }

            var fieldErrors = validateFields(
                containingComponent: component,
                objectBeingValidated: component,
                createError: new ErrorFactory(component, context),
                customObjectValidatorOpt: customObjectValidatorOpt
                );

            errors = errors.AddRange(items: fieldErrors);

            return(errors);
        }
		public void Check(CheckContext context)
		{
			var properties = context.ProjectCommonProperties.Result;

			properties.CheckRequired("SccAuxPath", "SAK");
			properties.CheckRequired("SccLocalPath", "SAK");
			properties.CheckRequired("SccProjectName", "SAK");
			properties.CheckRequired("SccProvider", "SAK");
		}
Exemplo n.º 27
0
        public void Check(CheckContext context)
        {
            var properties = context.ProjectCommonProperties.Result;

            properties.CheckRequired("SccAuxPath", "SAK");
            properties.CheckRequired("SccLocalPath", "SAK");
            properties.CheckRequired("SccProjectName", "SAK");
            properties.CheckRequired("SccProvider", "SAK");
        }
Exemplo n.º 28
0
        public static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(AppContext.BaseDirectory)
                          .AddJsonFile("appsettings.json")
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
            Task.Run(async() =>
            {
                Cloud = new VideoCloud(AppID, SecretID, SecretKey);
                OpenWeen.Core.Api.Entity.AccessToken = AccessToken;
                while (true)
                {
                    await CheckQuality();
                    if (ShareToWeibo)
                    {
                        await CheckWeiboShare();
                    }
                    await UploadTask();
                    if (EnableAdvLogging)
                    {
                        Logger.Info("Waiting...");
                    }
                    await Task.Delay(TimeSpan.FromMinutes(Interval));
                }
            });
            Console.WriteLine("Running...");
            do
            {
                while (!Console.KeyAvailable)
                {
                    switch (Console.ReadLine())
                    {
                    case "status":
                        using (var ctx = new CheckContext())
                        {
                            Console.WriteLine($"{nameof(ctx.CheckList)} {ctx.CheckList.Count()}");
                            foreach (var item in ctx.CheckList)
                            {
                                Console.WriteLine(item);
                            }
                            Console.WriteLine($"{nameof(ctx.WeiboList)} {ctx.WeiboList.Count()}");
                            foreach (var item in ctx.WeiboList)
                            {
                                Console.WriteLine(item);
                            }
                            //Console.WriteLine(File.ReadLines("log.txt").LastOrDefault());
                        }
                        break;

                    default:
                        break;
                    }
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);
        }
Exemplo n.º 29
0
 public static ImmutableList <Error> checkRecursively(
     CheckContext context, IEnumerable <Object> objects,
     Option <CustomObjectValidator> customValidatorOpt = default,
     Act <Progress> onProgress = null, Action onFinish = null
     ) => check(
     context,
     collectDependencies(objects.ToArray()),
     customValidatorOpt: customValidatorOpt, onProgress: onProgress, onFinish: onFinish,
     uniqueValuesCache: UniqueValuesCache.create.some()
     );
Exemplo n.º 30
0
            public CheckResult AddCheckResult(CheckResult checkResult)
            {
                using (var checkContext = new CheckContext(Options))
                {
                    checkContext.CheckResults.Add(checkResult);
                    checkContext.SaveChanges();

                    return(checkResult);
                }
            }
Exemplo n.º 31
0
        public void Check(CheckContext context)
        {
            var debug = context.ProjectDebugProperties.Result;

            debug.CheckRequired("OutputPath", @"bin\Debug\");

            var release = context.ProjectReleaseProperties.Result;

            release.CheckRequired("OutputPath", @"bin\Release\");
        }
		public void Check(CheckContext context)
		{
			var solutionItems = context.Of<SolutionPathItems>().Value;

			if (!solutionItems.Contains(".nuget/"))
				return;

			throw new CheckException(@"Solution folder should not contain '.nuget' folder inside.
Please consider using 'nuget.config' file from repository root.");
		}
Exemplo n.º 33
0
		public override string Get(CheckContext context)
		{
			const string prefix = "CnetContent.";

			var name = context.Of<ProjectName>().Value;
			if (name.StartsWith(prefix))
				name = name.Substring(prefix.Length);

			return name;
		}
Exemplo n.º 34
0
        public static ImmutableList <Error> check(
            CheckContext context, ICollection <Object> objects,
            Option <CustomObjectValidator> customValidatorOpt = default,
            Act <Progress> onProgress = null, Action onFinish = null,
            Option <UniqueValuesCache> uniqueValuesCache = default
            )
        {
            Option.ensureValue(ref customValidatorOpt);
            Option.ensureValue(ref uniqueValuesCache);

            var errors  = ImmutableList <Error> .Empty;
            var scanned = 0;

            foreach (var o in objects)
            {
                onProgress?.Invoke(new Progress(scanned++, objects.Count));

                var goOpt = F.opt(o as GameObject);
                if (goOpt.isSome)
                {
                    var go = goOpt.get;
                    foreach (var transform in go.transform.andAllChildrenRecursive())
                    {
                        var components = transform.GetComponents <Component>();
                        foreach (var c in components)
                        {
                            errors =
                                c
                ? errors.AddRange(checkComponent(context, c, customValidatorOpt, uniqueValuesCache))
                : errors.Add(Error.missingComponent(transform.gameObject));
                        }
                    }
                }
                else
                {
                    errors = errors.AddRange(checkComponent(context, o, customValidatorOpt, uniqueValuesCache));
                }
            }

            foreach (var valuesCache in uniqueValuesCache)
            {
                foreach (var df in valuesCache.getDuplicateFields())
                {
                    foreach (var obj in df.objectsWithThisValue)
                    {
                        errors = errors.Add(Error.duplicateUniqueValueError(df.category, df.fieldValue, obj, context));
                    }
                }
            }

            onFinish?.Invoke();

            // FIXME: there should not be a need to a Distinct call here, we have a bug somewhere in the code.
            return(errors.Distinct().ToImmutableList());
        }
        public override List <string> Get(CheckContext context)
        {
            var remoteSolution = context.Of <RemoteSolution>();
            var sourceControl  = context.Of <SourceControlProvider>().Value;

            Console.Write("Getting source control items from the solution folder... ");
            var items = sourceControl.GetChildItems(remoteSolution.SolutionPath);

            Console.WriteLine($"{items.Count} found.");
            return(items);
        }
		public void Check(CheckContext context)
		{
			var solutionName = context.Of<RemoteSolution>().SolutionName;
			var solutionItems = context.Of<SolutionPathItems>().Value;

			var solution = solutionItems
				.Where(item => Path.GetFileName(item) == solutionName)
				.FirstOrDefault();

			if (solution != null)
				return;

			throw new CheckException($"Project should have a primary solution file '{solutionName}' placed in parent folder.");
		}
		public void Check(CheckContext context)
		{
			var project = context.ProjectDocument.Result;
			var configurations = project.GetUsedConfigurations();
			configurations.Remove("Debug");
			configurations.Remove("Release");

			if (configurations.Count == 0)
				return;

			throw new FailedCheckException(
				@"Found unknown configuration '{0}'.
Please use standard configurations only: 'Debug' and 'Release'.",
				configurations[0]);
		}
Exemplo n.º 38
0
		public void Check(CheckContext context)
		{
			var config = context.TfsNugetConfig.Result;

			var compare = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <solution>
    <add key=""disableSourceControlIntegration"" value=""true"" />
  </solution>
</configuration>";

			if (config != compare)
				throw new FailedCheckException(@"File 'nuget.config' has a strange contents.
Please try to copy it from a different solution.");
		}
		public void Check(CheckContext context)
		{
			var debug = context.ProjectDebugProperties.Result;
			debug.CheckRequired("DebugSymbols", "true");
			debug.CheckRequired("DebugType", "full");
			debug.CheckRequired("DefineConstants", p => p == "DEBUG;TRACE" || p == "TRACE;DEBUG", "Should define DEBUG and TRACE.");
			debug.CheckRequired("ErrorReport", "prompt");
			debug.CheckOptional("Optimize", "false");
			debug.CheckOptional("WarningLevel", "4");

			var release = context.ProjectReleaseProperties.Result;
			release.CheckOptional("DebugSymbols", "true");
			release.CheckRequired("DebugType", "pdbonly");
			release.CheckRequired("DefineConstants", "TRACE");
			release.CheckRequired("ErrorReport", "prompt");
			release.CheckRequired("Optimize", "true");
			release.CheckOptional("WarningLevel", "4");
		}
		public virtual void Check(CheckContext context)
		{
			var localItems = context.Of<LocalPathItems>().Value;

			var file = localItems
				.Where(f => Path.GetFileName(f) == "AssemblyInfo.cs")
				.ToList();

			if (file.Count == 0)
				throw new CheckException("Cannot find assembly information file.");

			if (file.Count > 1)
				throw new CheckException($"There should be only one assembly information file, but {file.Count} files were found.");

			if (file[0] == @"Properties\AssemblyInfo.cs")
				return;

			throw new CheckException("Project file should be named 'AssemblyInfo.cs' and placed in 'Properties' folder.");
		}
		public virtual void Check(CheckContext context)
		{
			var projectFile = context.Of<ProjectFile>().Value;
			var localItems = context.Of<LocalPathItems>().Value;
			var projectExtension = context.Of<ProjectExtension>().Value;

			var file = localItems
				.Where(f => Path.GetExtension(f) == "." + projectExtension)
				.ToList();

			if (file.Count == 0)
				throw new CheckException($"Cannot find project file '*.{projectExtension}'.");

			if (file.Count > 1)
				throw new CheckException($"There should be only one project file '*.{projectExtension}', but {file.Count} files were found.");

			if (file[0] == projectFile)
				return;

			throw new CheckException($"Project file should be named '{projectFile}' and placed in project root folder.");
		}
		public override void Check(CheckContext context)
		{
			Check(context.LocalFiles.Result, ".ccproj");
		}
		public void Check(CheckContext context)
		{
			var properties = context.ProjectCommonProperties.Result;
			properties.CheckRequired("AssemblyName", Args.AssemblyName);
		}
		public void Check(CheckContext context)
		{
			var properties = context.ProjectCommonProperties.Result;
			properties.CheckRequired("RootNamespace", Args.RootNamespace);
		}
		/// <summary>
		/// Loads required data.
		/// </summary>
		public void Load(CheckContext context)
		{
			m_args = context.Args;
		}
		public void Check(CheckContext context)
		{
			var properties = context.ProjectCommonProperties.Result;
			properties.CheckRequired("OutputType", "Library");
		}
		public void Check(CheckContext context)
		{
			var properties = context.ProjectCommonProperties.Result;
			properties.CheckRequired("TargetFrameworkVersion", "v3.5");
		}