コード例 #1
0
ファイル: FeatureContext.cs プロジェクト: ppetrov/Cchbc
        public FeatureContext(AppContext appContext, Feature feature)
        {
            if (appContext == null) throw new ArgumentNullException(nameof(appContext));
            if (feature == null) throw new ArgumentNullException(nameof(feature));

            this.AppContext = appContext;
            this.Feature = feature;
            this.DbContext = appContext.DbContextCreator();
        }
コード例 #2
0
ファイル: Feature.cs プロジェクト: ppetrov/Cchbc
        public static Feature StartNew(string context, string name)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (name == null) throw new ArgumentNullException(nameof(name));

            var feature = new Feature(context, name);

            feature.Start();

            return feature;
        }
コード例 #3
0
ファイル: ModalDialog.cs プロジェクト: ppetrov/Cchbc
		public async Task<DialogResult> ShowAsync(string message, Feature feature, DialogType? type = null)
		{
			if (message == null) throw new ArgumentNullException(nameof(message));
			if (feature == null) throw new ArgumentNullException(nameof(feature));

			var dialog = new MessageDialog(message);

			UICommandInvokedHandler empty = cmd => { };
			dialog.Commands.Add(new UICommand(@"Accept", empty, DialogResult.Accept));
			dialog.Commands.Add(new UICommand(@"Cancel", empty, DialogResult.Cancel));
			dialog.Commands.Add(new UICommand(@"Decline", empty, DialogResult.Decline));

			feature.Pause();

			var task = dialog.ShowAsync().AsTask();			
			var result = await task;

			feature.Resume();
			return (DialogResult)result.Id;
		}
コード例 #4
0
ファイル: FeatureManager.cs プロジェクト: ppetrov/Cchbc
        public void Write(Feature feature, string details = null)
        {
            if (feature == null) throw new ArgumentNullException(nameof(feature));

            // Stop the feature
            feature.Stop();

            var currentDetails = details;
            if (feature.TimeSpent != TimeSpan.Zero)
            {
                currentDetails = feature.TimeSpent.ToString(@"c");
            }

            using (var context = this.DbContextCreator())
            {
                var featureRow = this.Save(context, feature.Context, feature.Name);

                FeatureAdapter.InsertFeatureEntry(context, featureRow.Id, currentDetails ?? string.Empty);

                context.Complete();
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
        private static void InspectFeature(Feature f)
        {
            //var buffer = new StringBuilder();

            //var ctxName = feature.Context + "(" + feature.Name + ")";
            //buffer.Append(ctxName.PadRight(25));
            //buffer.Append(' ');
            //buffer.Append(feature.Details.PadRight(12));
            //buffer.Append(' ');
            //buffer.AppendLine(feature.TimeSpent.TotalMilliseconds.ToString(CultureInfo.InvariantCulture).PadRight(6));

            //if (feature.Steps.Any())
            //{
            //	var totalMilliseconds = feature.TimeSpent.TotalMilliseconds;
            //	var remaingTime = totalMilliseconds - (feature.Steps.Select(v => v.TimeSpent.TotalMilliseconds).Sum());

            //	foreach (var s in feature.Steps.Concat(new[] { new FeatureEntryStep(@"Other", TimeSpan.FromMilliseconds(remaingTime), string.Empty) }))
            //	{
            //		buffer.Append('\t');

            //		var value = s.Name.Replace(@"Async", string.Empty);
            //		value = Regex.Replace(value, @"[A-Z]", m => @" " + m.Value).TrimStart();
            //		buffer.Append(value.PadRight(24));
            //		buffer.Append(' ');
            //		buffer.Append(s.Details.PadRight(4));
            //		buffer.Append(' ');
            //		var milliseconds = s.TimeSpent.TotalMilliseconds;
            //		var tmp = (milliseconds / totalMilliseconds) * 100;
            //		var graph = new string('-', (int)tmp);

            //		buffer.Append(milliseconds.ToString(CultureInfo.InvariantCulture).PadRight(8));
            //		buffer.Append(tmp.ToString(@"F2").PadLeft(5));
            //		buffer.Append(@"% ");
            //		buffer.AppendLine(graph);
            //	}
            //}

            //buffer.AppendLine();
            //var output = buffer.ToString();
            //Debug.WriteLine(output);
            //Console.WriteLine(output);

            //File.AppendAllText(@"C:\temp\diagnostics.txt", output);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static string InsertVisit(Feature f)
 {
     {
         // TODO : !!!
         return @"new visit";
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static void InsertActivity(Feature feature, string visit, string activity)
 {
     {
         var copy = activity + @"+" + visit;
     }
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static string GetVisit(Feature f)
 {
     {
         // TODO : !!!
         return null;
         return "Get from db";
     }
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static List<object> GetDays(Feature feature, DateTime value)
 {
     {
         Thread.Sleep(5);
         return new List<object>();
     }
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
        private static string CreateVisit(Feature f)
        {
            var canCreateActivityForOutlet = CanCreateActivityForOutlet(f);
            if (canCreateActivityForOutlet.Type != PermissionType.Allow) return null;

            {
                var visit = GetVisit(f);
                if (visit != null) return visit;

                return InsertVisit(f);
            }
        }
コード例 #11
0
ファイル: FeatureManager.cs プロジェクト: ppetrov/Cchbc
        public void Write(Feature feature, Exception exception)
        {
            if (feature == null) throw new ArgumentNullException(nameof(feature));
            if (exception == null) throw new ArgumentNullException(nameof(exception));

            using (var context = this.DbContextCreator())
            {
                var featureRow = this.Save(context, feature.Context, feature.Name);
                var exceptionId = FeatureAdapter.GetOrCreateException(context, exception.ToString());

                FeatureAdapter.InsertExceptionEntry(context, featureRow.Id, exceptionId);

                context.Complete();
            }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
        private static void CopyActivity(Feature feature, string activity)
        {
            var date = SelectDateFromDialog(feature);
            if (date == null) return;

            var days = GetDays(feature, date.Value);

            var isDayActive = IsDayActive(feature, days);
            if (!isDayActive) return;

            var isDayInThePast = IsDayInThePast(feature, days);
            if (isDayInThePast) return;

            var copyActivity = activity + @"*";
            CreateActivity(feature, activity);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static PermissionResult CanCreateActivityForOutlet(Feature f)
 {
     {
         {
             var assignment = "From the for outlet";
             if (assignment == null)
             {
                 // TODO : Display message
                 return PermissionResult.Deny("No outlet assignment");
             }
             var hasAssignment = assignment.Length > 0;
             if (!hasAssignment)
             {
                 // TODO : Display message
                 return PermissionResult.Deny("Invalid assignment");
             }
         }
         //Is R E D Activities Allowed
         {
             // TODO : !!!
             return PermissionResult.Allow.Result;
         }
     }
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 public Task<DialogResult> ShowAsync(string message, Feature feature, DialogType? type = null)
 {
     return Task.FromResult(DialogResult.Cancel);
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static DateTime? SelectDateFromDialog(Feature feature)
 {
     {
         // TODO : !!! Get from the UI
         return DateTime.Today.AddDays(1);
     }
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static bool IsDayActive(Feature feature, List<object> days)
 {
     {
         //Thread.Sleep(100);
         // TODO : Query the db
         return true;
     }
 }
コード例 #17
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
 private static bool IsDayInThePast(Feature feature, List<object> days)
 {
     {
         // TODO : Query the db
         //Thread.Sleep(100);
         return false;
     }
 }
コード例 #18
0
ファイル: Program.cs プロジェクト: ppetrov/Cchbc
        private static void CreateActivity(Feature feature, string activity)
        {
            {
                var visit = CreateVisit(feature);
                if (visit == null) return;

                InsertActivity(feature, visit, activity);
            }
        }