Beispiel #1
0
 /// <summary>
 /// Synchronizes Job State with Background Runspace
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void powerShellCommand_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     try
     {
         if (e.InvocationStateInfo.State == PSInvocationState.Completed)
         {
             runspace.Close();
         }
         if (e.InvocationStateInfo.State == PSInvocationState.Failed)
         {
             ErrorRecord err = new ErrorRecord(e.InvocationStateInfo.Reason, "JobFailed", ErrorCategory.OperationStopped, this);
             Error.Add(err);
             runspace.Close();
         }
         JobState js = (JobState)Enum.Parse(typeof(JobState), e.InvocationStateInfo.State.ToString(), true);
         this.SetJobState(js);
     }
     catch
     {
     }
 }
Beispiel #2
0
 /// <summary>
 /// Creates a new, unstarted instance of <see cref="PingJob"/>.
 /// </summary>
 /// <param name="command">The PowerShell script command responsible for the creation of the new job.</param>
 /// <param name="name">The friendly name of the new job.</param>
 /// <param name="computerNameOrIp">The ComputerName or IP address to be pinged by this job.</param>
 public PingJob(string?command, string?name, string computerNameOrIp)
     : base(command, name)
 {
     _location            = computerNameOrIp ?? throw new ArgumentNullException(nameof(computerNameOrIp));
     _sync                = new object();
     _ping                = new Ping();
     _status              = "Not Started";
     _ping.PingCompleted += OnPingCompleted;
     _ping.Disposed      += (a, b) =>
     {
         if (!IsFinished)
         {
             Error.Add(new ErrorRecord(
                           new ObjectDisposedException(nameof(Ping)),
                           "PingDisposed",
                           ErrorCategory.InvalidOperation,
                           _ping));
             SetJobState(JobState.Failed);
         }
     };
 }
Beispiel #3
0
        public void postavi1(DateTime o)
        {
            Br++;
            DP = o;
            var compare = DateTime.Now.CompareTo(o);

            if (compare >= 0)
            {
                if (Error.Contains("Datum mora biti u budućnosti! ") == false)
                {
                    Error.Add("Datum mora biti u budućnosti! ");
                }
            }
            else
            {
                if (Error.Contains("Datum mora biti u budućnosti! "))
                {
                    Error.Remove("Datum mora biti u budućnosti! ");
                }
            }
        }
Beispiel #4
0
        public ErrorChart(ChartView BaseChart)
        {
            errorChart = new Error();
            var        = new Variables.Variables();

            for (int i = 0; i < var.GetValorErrorLabels.Length; i++)
            {
                errorChart.Add(var.GetValorsError[i, 0], var.GetValorsError[i, 1], var.GetValorsError[i, 2], var.GetPaletteBasic[i]);
            }

            BaseChart.Chart.Series.Add(errorChart);

            BaseChart.Chart.Axes.Left.Visible   = true;
            BaseChart.Chart.Axes.Bottom.Visible = true;

            BaseChart.Chart.Header.Text = "Error";

            BaseChart.Chart.Axes.Left.AxisPen.Visible = true;
            BaseChart.Chart.Axes.Left.Visible         = true;
            BaseChart.Chart.Axes.Left.Ticks.Visible   = true;
            BaseChart.Chart.Axes.Left.Grid.Visible    = true;
            BaseChart.Chart.Axes.Left.AxisPen.Visible = true;
            BaseChart.Chart.Axes.Left.Increment       = 20;
            BaseChart.Chart.Axes.Left.Title.Visible   = false;

            BaseChart.Chart.Axes.Bottom.Visible         = true;
            BaseChart.Chart.Axes.Bottom.AxisPen.Visible = true;
            BaseChart.Chart.Axes.Bottom.Grid.Visible    = false;
            BaseChart.Chart.Axes.Bottom.Title.Visible   = false;

            errorChart.ErrorWidth      = 80;
            errorChart.ErrorPen.Width  = 6;
            errorChart.ErrorPen.EndCap = PenLineCap.Square;
            errorChart.ErrorStyle      = ErrorStyles.TopBottom;

            BaseChart.Chart.Legend.Visible = false;

            BaseChart.Chart.Axes.Left.SetMinMax(0, BaseChart.Chart.Axes.Left.MaxYValue + 5);
            BaseChart.Chart.Axes.Bottom.SetMinMax(0, BaseChart.Chart.Axes.Bottom.MaxXValue);
        }
Beispiel #5
0
        /// <summary>
        /// Inserts the feed back.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="message">The message.</param>
        public void InsertFeedBack(string type, string message)
        {
            switch (type)
            {
            case FeedbackType.Error:
                Error.Add(message);
                break;

            case FeedbackType.Success:
                Success.Add(message);
                break;

            case FeedbackType.Warning:
                Warning.Add(message);
                break;

            case FeedbackType.Info:
                Info.Add(message);
                break;
            }
            Refresh();
        }
Beispiel #6
0
 /// <summary>
 /// Executed when the <see cref="Task"/> this job represents has completed.
 /// </summary>
 /// <param name="completedTask"><see cref="_task"/> after completing.</param>
 private async Task OnTaskCompleted(Task completedTask)
 {
     // 1. Is there any reason for this method to return Task?
     // 2. Is there any reason to say _task = task; _task.ContinueWith() instead of just _task = task.ContinueWith()?
     //    When this method does not return null that returns Task<Task>. But ... does that matter?
     if (completedTask.IsCanceled)
     {
         SetJobState(JobState.Stopped);
     }
     else if (completedTask.IsFaulted)
     {
         var exception = completedTask.Exception.InnerExceptions.Count == 1
             ? completedTask.Exception.InnerExceptions[0]
             : completedTask.Exception;
         Error.Add(new ErrorRecord(
                       exception,
                       "TaskException",
                       ErrorCategory.NotSpecified,
                       completedTask)
         {
             ErrorDetails = new ErrorDetails($"An exception occurred in the task. {exception.Message}")
         });
         SetJobState(JobState.Failed);
     }
     else
     {
         var expectingOutput = !(_task.GetType().GetProperty("Result")?.PropertyType.Name.Equals("VoidTaskResult")) ?? false;
         if (expectingOutput)
         {
             var invokeResult = await(dynamic) completedTask;
             if (invokeResult != null)
             {
                 Output.Add(PSObject.AsPSObject(invokeResult));
             }
         }
         SetJobState(JobState.Completed);
     }
 }
Beispiel #7
0
        //private void CheckIfDJournalIsBalanced(List<CashierTotal> ppt)
        //{
        //  var balanced = CashierTotal.IsDjournalBalanced(ppt);
        //  if (balanced)
        //  {
        //    Error.Add("Djournal is " + balancedText);
        //    var keys = String.Join(", \n", CashierTotal.GetOutOfBalanceCashierIds(DJournalDate));
        //    Error.Add("The following keys have issues:\n" + keys);
        //  }
        //}

        private void CheckIfDJournalIsBalanced()
        {
            var balanced = CashierTotal.IsDjournalBalanced(ProcessedPaymentTotals, GUTotals, GLAccountTotals);

            if (!balanced)
            {
                var key_list = CashierTotal.GetOutOfBalanceCashierIds(DJournalDate);


                if (key_list.Count > 0)
                {
                    var keys = String.Join(", \n", key_list);

                    var errorString = new StringBuilder();
                    errorString.Append($"The DJournal for ")
                    .Append(this.DJournalDate.ToShortDateString())
                    .Append(" is out of balance.")
                    .AppendLine()
                    .Append("The following keys have issues:")
                    .AppendLine()
                    .Append(keys)
                    .AppendLine();


                    Error.Add(errorString.ToString());
                }
                else
                {
                    Error.Add($@"The Djournal for
          {this.DJournalDate.ToShortDateString()} is out of balance. 
          There may be an issue with the total payments, total charges, or the GU amounts.");
                }
            }
            else
            {
                CanDJournalBeFinalized = true;
            }
        }
Beispiel #8
0
        private void HookupHostDataDelegates(ThreadJobHost host)
        {
            ThreadJobHostUI hostUI = host.UI as ThreadJobHostUI;

            System.Diagnostics.Debug.Assert(hostUI != null, "Host UI cannot be null.");

            hostUI.Output.DataAdded += (sender, dataAddedEventArgs) =>
            {
                Collection <PSObject> output = hostUI.Output.ReadAll();
                foreach (var item in output)
                {
                    _output.Add(item);
                }
            };

            hostUI.Error.DataAdded += (sender, dataAddedEventArgs) =>
            {
                Collection <ErrorRecord> error = hostUI.Error.ReadAll();
                foreach (var item in error)
                {
                    Error.Add(item);
                }
            };
        }
Beispiel #9
0
 public override IMom Clone(DateTime time, ErrMom err)
 {
     return(new MomErrBool(time, OwnBool, Error.Add(err)));
 }
Beispiel #10
0
 public override IMom Clone(DateTime time, ErrMom err)
 {
     return(new MomErrInt(time, OwnInteger, Error.Add(err)));
 }
Beispiel #11
0
 public override IMom Clone(DateTime time, ErrMom err)
 {
     return(new MomErrString(time, OwnString, Error.Add(err)));
 }
Beispiel #12
0
 public static void ApiErrorCode(this Error error, string code)
 {
     error.Add(ApiError.ErrorCodeKey, code);
 }
Beispiel #13
0
 public void LogError(string severity, string err)
 {
     Warning.Add(err);
     Error.Add(err);
     Information.Add(err);
 }
Beispiel #14
0
 public static void AddError(string personalError)
 {
     Error.Add(personalError);
 }
Beispiel #15
0
 public static void StatusCode(this Error error, int code)
 {
     error.Add(ApiError.StatusCodeKey, code);
 }
Beispiel #16
0
 public override IReadMean ToMom(DateTime time, MomErr err)
 {
     return(new BoolMom(time, _bool, Error.Add(err)));
 }
Beispiel #17
0
        public DJournal(DateTime dateToProcess, UserAccess ua, bool finalize = false)
        {
            DJournalDate = dateToProcess;
            //check for dates not finalized after initial finalize date
            this.ProcessedPaymentTotals = CashierTotal.ProcessPaymentTypeTotals(dateToProcess);
            this.GUTotals        = CashierTotal.GetGUTotals(dateToProcess);
            this.GLAccountTotals = Account.GetGLAccountTotals(dateToProcess);
            var tempCd = CashierDetailData.Get(dateToProcess);

            string[] ImpactFeePaymentTypes =
            {
                "IFCR",
                "IFEX",
                "IFWS",
                "IFWR",
                "IFSCR",
                "IFS2",
                "IFS3",
                "MFS1",
                "MFS2",
                "MFS4",
                "MFS7",
                "MFS10"
            };
            this.CashierData = (from c in tempCd
                                where !ImpactFeePaymentTypes.Contains(c.PaymentType)
                                select c).ToList();
            this.ImpactFeeData = (from c in tempCd
                                  where ImpactFeePaymentTypes.Contains(c.PaymentType)
                                  select c).ToList();

            CheckIfDJournalIsBalanced();

            if (!CanDJournalBeFinalized)
            {
                CheckCatCodesAgainstGL();
            }

            CanDJournalBeFinalized = false;
            //
            Log = DJournalLog.Get(dateToProcess);
            var NextDateToFinalize = LastDateFinalized().AddDays(1);
            var rolloutDate        = DateTime.Parse("8/23/2018");

            if (dateToProcess < rolloutDate && !Log.IsCreated && !finalize)
            {
                Log.DJournalDate = dateToProcess;
                Log.FinalizedOn  = rolloutDate;
                Log.CreatedBy    = "Prior to Claypay";
            }
            if (finalize)
            {
                if (Log.IsCreated)
                {
                    Error.Add($"{dateToProcess.ToShortDateString()} has already been finalized.");
                }
                if (!ua.djournal_access)
                {
                    Error.Add("DJournal was not finalized. User does not have the correct level of access.");
                }
                if (DJournalDate.Date != NextDateToFinalize.Date)
                {
                    Error.Add("The dates must be finalized in order.  You must finalize " + NextDateToFinalize.ToShortDateString() + "next.");
                }
                if (NextDateToFinalize.Date == DateTime.Now.Date)
                {
                    Error.Add("You must wait until tomorrow to finalize today.");
                }
            }


            // in order for the Djournal to be able to be finalized, the following must be true
            // 1) it can't already be finalized
            // 2) The date be be prior to today
            // 3) The date must be one day later than the most recent date finalized
            // 4) The user must have DJournal access.
            // 5) No errors can be present
            CanDJournalBeFinalized =
                !Log.IsCreated &&                               // 1
                DJournalDate.Date < DateTime.Now.Date &&        // 2
                NextDateToFinalize.Date == DJournalDate.Date && // 3
                ua.djournal_access &&                           // 4
                Error.Count == 0;                               // 5

            if (finalize && CanDJournalBeFinalized)
            {
                if (DJournalLog.Create(dateToProcess, ua.user_name) != -1)
                {
                    CanDJournalBeFinalized = false; // It just was finalized
                    Log = DJournalLog.Get(dateToProcess);
                }
                else
                {
                    Error.Add($"There was an issue saving the DJournal log for {dateToProcess.ToShortDateString()}.");
                }
            }
        }
 public void AddError(ErrorResponseModel error)
 {
     Error.Add(error);
 }
Beispiel #19
0
 public override IReadMean ToMom(DateTime time, MomErr err)
 {
     return(new ValueMom(time, Error.Add(err)));
 }
Beispiel #20
0
 public override IReadMean ToMom(DateTime time, MomErr err)
 {
     return(new IntMom(time, _int, Error.Add(err)));
 }
Beispiel #21
0
 /// <summary>
 /// Error creation.
 /// </summary>
 /// <param name="msg">Template message.</param>
 /// <param name="args">Error arguments.</param>
 void CreateError(string msg, params object[] args)
 {
     Error.Add(string.Format(msg, args));
 }
Beispiel #22
0
 public static void AddError(Exception ex)
 {
     Error.Add(ex.Message);
 }
 protected virtual void OnError(ErrorRecord nonTerminalError)
 {
     Error.Add(nonTerminalError);
 }
Beispiel #24
0
        /// <summary>
        /// Authenticate users using SurveyMonkey Account.
        /// </summary>
        /// <param name="app">The <see cref="IAppBuilder"/> passed to the configuration method</param>
        /// <param name="clientId">The application client ID assigned by the  authentication service</param>
        /// <param name="clientSecret">The application client secret assigned by the  authentication service</param>
        /// <param name="callbackPath">The return URL specified in the SurveyMonkey API App</param>
        /// <param name="apiKey">The SurveyMonkey API Key</param>

        public static IAppBuilder UseSurveyMonkeyAuthentication(this IAppBuilder app, string clientId, string clientSecret, string callbackPath, string apiKey)
        {
            Error Errors = new Error();
            SurveyMonkeyAuthenticationOptions surveyMonkeyAuthenticationOptions = new SurveyMonkeyAuthenticationOptions(Constants.DefaultAuthenticationType, apiKey, callbackPath);

            surveyMonkeyAuthenticationOptions.ClientId     = clientId;
            surveyMonkeyAuthenticationOptions.ClientSecret = clientSecret;
            surveyMonkeyAuthenticationOptions.Provider     = new SurveyMonkeyAuthenticationProvider
            {
                OnAuthenticated = async context =>
                {
                    if (context.AccountType != "select_yearly" && context.AccountType != "basic")
                    {
                        MappedResult <GroupRequestResult> group = await context.Client.DownloadJsonAsync <GroupRequestResult>(surveyMonkeyAuthenticationOptions.Endpoints.UserGroupEndpoint);

                        if (group.IsSuccessfull)
                        {
                            var    groupData       = group.Result.Data;
                            string groupMembersUri = string.Format(surveyMonkeyAuthenticationOptions.Endpoints.GroupMemberEndpoint, groupData.First().Id);
                            MappedResult <GroupMembersRequestResult> groupMembers = await context.Client.DownloadJsonAsync <GroupMembersRequestResult>(groupMembersUri);

                            if (groupMembers.IsSuccessfull)
                            {
                                List <Member> groupMembersData = groupMembers.Result.Data;
                                Member        memberData       = groupMembersData.Where(e => e.Username == context.UserName).First();
                                string        groupMemberUri   = string.Format(surveyMonkeyAuthenticationOptions.Endpoints.MemberEndpoint, group.Result.Data.First().Id, memberData.Id);
                                MappedResult <MemberRequestResult> groupMember = await context.Client.DownloadJsonAsync <MemberRequestResult>(groupMemberUri);

                                if (groupMember.IsSuccessfull)
                                {
                                    var UserGroup = group.Result.Data.First().Name;
                                    var Role      = groupMember.Result.Type;

                                    context.Identity.AddClaim(new Claim("urn:" + context.AuthenticationType + ":access_token", context.AccessToken, Constants.XmlSchemaString, context.AuthenticationType));
                                    if (!string.IsNullOrWhiteSpace(UserGroup))
                                    {
                                        context.Identity.AddClaim(new Claim("urn:" + context.AuthenticationType + ":group", UserGroup, Constants.XmlSchemaString, context.AuthenticationType));
                                    }

                                    if (!string.IsNullOrWhiteSpace(Role))
                                    {
                                        context.Identity.AddClaim(new Claim(ClaimTypes.Role, Role, Constants.XmlSchemaString, context.AuthenticationType));
                                    }
                                }
                                else
                                {
                                    Errors.Add("member", groupMember.ReasonPhrase);
                                }
                            }
                            else
                            {
                                Errors.Add("members", groupMembers.ReasonPhrase);
                            }
                        }
                        else
                        {
                            Errors.Add("groups", group.ReasonPhrase);
                        }
                    }

                    if (Errors.Count > 0)
                    {
                        await Task.FromResult(Errors);
                    }
                },
                OnApplyRedirect = context => context.Response.Redirect(context.RedirectUri)
            };

            return(UseSurveyMonkeyAuthentication(
                       app,
                       surveyMonkeyAuthenticationOptions
                       ));
        }
Beispiel #25
0
 public override IReadMean ToMom(DateTime time, MomErr err)
 {
     return(new StringMom(time, _string, Error.Add(err)));
 }
Beispiel #26
0
 public override IReadMean ToMom(DateTime time, MomErr err)
 {
     return(new WeightedMom(time, Real, Weight, Error.Add(err)));
 }