コード例 #1
0
        private void ProcessLoginError(SessionResponse ssnResponse, ServiceInvocationEventArgs invokerEventArgs)
        {
            Exception    thrownException = invokerEventArgs.Exception;
            StatusDetail errorStatus     = ssnResponse != null
                                        ? StatusResponse.GetStatusError(ssnResponse.status)
                                        : null;

            if (errorStatus != null)
            {
                thrownException = new NsException(errorStatus.message, thrownException);
            }
            else if (invokerEventArgs.InvokationAttempt == Configuration.RetryCount)
            {
                thrownException = new RetryCountExhaustedException("Login Failed.", thrownException);
            }
            else // If the _nsSvc.login(..) call repeatedly threw exceptions...
            {
                thrownException = new NsException("Login Failed.\nExceptions have been logged.", thrownException);
            }

            invokerEventArgs.Exception = thrownException;
            if (thrownException != null)
            {
                OnServiceInvocationError(invokerEventArgs);
                throw thrownException;
            }
        }
コード例 #2
0
        private void ProcessDeleteBatch(BaseRef[] batch, List <WriteResponse> responses, string methodName)
        {
            _log.Debug(string.Format("Processing Batch -- Size: {0} Ref(s), Operation: {1}", batch.Length, methodName));
            try
            {
                responses.AddRange(InvokeService <WriteResponse[]>(batch, methodName));
            }
            catch (Exception e)
            {
                _log.Debug("Processing Batch Error: {0}", e);

                StatusDetail statDetail = new StatusDetail();
                statDetail.message = e.GetType().Name + " while processing batch: " + e.Message;
                statDetail.type    = StatusDetailType.ERROR;
                statDetail.code    = StatusDetailCodeType.UNEXPECTED_ERROR;

                Status stat = new Status();
                stat.isSuccess          = false;
                stat.isSuccessSpecified = true;
                stat.statusDetail       = new StatusDetail[] { statDetail };

                WriteResponse response = new WriteResponse();
                response.status = stat;

                for (int i = 0; i < batch.Length; i++)
                {
                    responses.Add(response);
                }
            }
        }
コード例 #3
0
        private void ProcessBatch(Record[] batch, List <WriteResponse> responses, string methodName)
        {
            _log.Debug(string.Format("Processing Batch -- Size: {0} Record(s) , Operation: {1}", batch.Length, methodName));
            try
            {
                responses.AddRange(InvokeService <WriteResponse[]>(batch, methodName));
            }
            catch (Exception e)
            {
                _log.Debug("Processing Batch Error: {0}", e);

                StatusDetail statDetail = new StatusDetail();
                statDetail.code    = StatusDetailCodeType.UNEXPECTED_ERROR;
                statDetail.message = "Batch threw an Exception";

                Status status = new Status();
                status.isSuccess          = false;
                status.isSuccessSpecified = true;
                status.statusDetail       = new StatusDetail[] { statDetail };

                var wr = new WriteResponse()
                {
                    status = status
                };
                for (int i = 0; i < batch.Length; i++)
                {
                    responses.Add(wr);
                }
            }
        }
コード例 #4
0
        public async Task <IActionResult> Status()
        {
            Identity currentIdentity = await GetIdentity();

            if (!currentIdentity.IsSiteAdmin())
            {
                return(Unauthorized());
            }

            List <string> currentLogins = new();

            foreach (var login in _identityManager.GetCurrentIdentities())
            {
                if (login is DiscordOAuthIdentity)
                {
                    try
                    {
                        var user = login.GetCurrentUser();
                        if (user == null)
                        {
                            currentLogins.Add($"Invalid user.");
                        }
                        else
                        {
                            currentLogins.Add($"{user.Username}#{user.Discriminator}");
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, "Error getting logged in user.");
                        currentLogins.Add($"Invalid user.");
                    }
                }
            }

            StatusRepository repo = StatusRepository.CreateDefault(_serviceProvider);

            StatusDetail botDetails = repo.GetBotStatus();
            StatusDetail dbDetails  = await repo.GetDbStatus();

            StatusDetail cacheDetails = repo.GetCacheStatus();

            return(Ok(new
            {
                botStatus = botDetails,
                dbStatus = dbDetails,
                cacheStatus = cacheDetails,
                loginsInLast15Minutes = currentLogins,
                defaultLanguage = _config.GetDefaultLanguage(),
                trackedInvites = await InviteRepository.CreateDefault(_serviceProvider).CountInvites(),
                modCases = await ModCaseRepository.CreateDefault(_serviceProvider, currentIdentity).CountAllCases(),
                guilds = await GuildConfigRepository.CreateDefault(_serviceProvider).CountGuildConfigs(),
                automodEvents = await AutoModerationEventRepository.CreateDefault(_serviceProvider).CountEvents(),
                userNotes = await UserNoteRepository.CreateWithBotIdentity(_serviceProvider).CountUserNotes(),
                userMappings = await UserMapRepository.CreateWithBotIdentity(_serviceProvider).CountAllUserMaps(),
                apiTokens = await TokenRepository.CreateDefault(_serviceProvider).CountTokens(),
                nextCache = _scheduler.GetNextCacheSchedule(),
                cachedDataFromDiscord = _discordAPI.GetCache().Keys
            }));
        }
コード例 #5
0
 private FileExistDialog.FileExistActionEnum GetDecisionFromMessageBox(StatusDetail statusDetail, string targetPath)
 {
     using (var msgBox = new FileExistDialog(statusDetail.SourceFile, targetPath))
     {
         msgBox.ShowDialog();
         return(msgBox.SelectedAction);
     }
 }
コード例 #6
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Status != null?Status.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (StatusDetail != null ? StatusDetail.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                return(hashCode);
            }
        }
コード例 #7
0
        public void Synch(StatusDetail statusDetail, Guid batchId)
        {
            log.Info($"Calling filebot for the file: {statusDetail.SourceFile}");
            var arguments = AutoRenamerConfig.Instance.FilebotExpression.Value.Replace("%FILENAME%", statusDetail.SourceFile);

            log.Debug($"Filebot arguments: {arguments}");

            Process process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden,
                    FileName               = "filebot",
                    Arguments              = arguments,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true
                }
            };

            process.Start();
            var output = process.StandardOutput.ReadToEnd();

            process.WaitForExit();

            log.Debug(output);
            var regex = new Regex(@"\[TEST\] Rename \[.+?\] to \[(.+?)\]");
            var match = regex.Match(output);

            if (match.Success && match.Groups.Count >= 2)
            {
                var newName = match.Groups[1].Value;
                log.Info($"Detected new name: {newName}.");

                var targetPath = Path.Combine(statusDetail.DestinationFolder,
                                              newName.StartsWith("\\") ? newName.Substring(1) : newName);
                CopyFile(statusDetail, targetPath, batchId);
            }
            else
            {
                var msg = $"Cannot detect the tv show for the file: {statusDetail.SourceFile}";
                log.Error(msg);
                statusDetail.Reason = msg;
                statusDetail.Status = StatusEnum.Error;
            }
        }
コード例 #8
0
 public IHttpActionResult SaveStatus(StatusDetail ArrivalLog)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         ArrivalLog.Id          = Guid.NewGuid();
         ArrivalLog.CreatedDate = DateTime.Now;
         db.StatusDetails.Add(ArrivalLog);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         return(Ok(new { Error = "Some error occured" }));
     }
     return(Ok(new { success = "true" }));
 }
コード例 #9
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (Status != null)
         {
             hashCode = hashCode * 59 + Status.GetHashCode();
         }
         if (StatusDetail != null)
         {
             hashCode = hashCode * 59 + StatusDetail.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         return(hashCode);
     }
 }
コード例 #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (createTime_ != null)
            {
                hash ^= CreateTime.GetHashCode();
            }
            if (endTime_ != null)
            {
                hash ^= EndTime.GetHashCode();
            }
            if (Target.Length != 0)
            {
                hash ^= Target.GetHashCode();
            }
            if (Verb.Length != 0)
            {
                hash ^= Verb.GetHashCode();
            }
            if (StatusDetail.Length != 0)
            {
                hash ^= StatusDetail.GetHashCode();
            }
            if (CancelRequested != false)
            {
                hash ^= CancelRequested.GetHashCode();
            }
            if (ApiVersion.Length != 0)
            {
                hash ^= ApiVersion.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #11
0
        /// <summary>
        /// Returns true if ThingStatusInfo instances are equal
        /// </summary>
        /// <param name="input">Instance of ThingStatusInfo to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ThingStatusInfo input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Status == input.Status ||
                     (Status != null &&
                      Status.Equals(input.Status))
                     ) &&
                 (
                     StatusDetail == input.StatusDetail ||
                     (StatusDetail != null &&
                      StatusDetail.Equals(input.StatusDetail))
                 ) &&
                 (
                     Description == input.Description ||
                     (Description != null &&
                      Description.Equals(input.Description))
                 ));
        }
コード例 #12
0
        private void CopyFile(StatusDetail statusDetail, string targetPath, Guid batchId)
        {
            bool copy    = false;
            var  status  = statusDetail.Status;
            bool updated = true;

            if (File.Exists(targetPath))
            {
                var decision =
                    DecisionManager.Instance.GetDecision <FileExistDialogDecision>(batchId);

                var choice = FileExistDialog.FileExistActionEnum.None;

                if (decision != null &&
                    ((FileExistDialog.FileExistActionEnum)decision.Choice & FileExistDialog.FileExistActionEnum.All) == FileExistDialog.FileExistActionEnum.All)
                {
                    choice = (FileExistDialog.FileExistActionEnum)decision.Choice;
                }
                else
                {
                    choice = GetDecisionFromMessageBox(statusDetail, targetPath);
                    DecisionManager.Instance.SaveDecision(new Decision(batchId, (int)choice));
                }


                if ((choice & FileExistDialog.FileExistActionEnum.Override) ==
                    FileExistDialog.FileExistActionEnum.Override)
                {
                    copy = true;
                    statusDetail.Status = StatusEnum.Synched;
                }
                else if ((choice & FileExistDialog.FileExistActionEnum.SkipButSynched) ==
                         FileExistDialog.FileExistActionEnum.SkipButSynched)
                {
                }
                else if (choice == FileExistDialog.FileExistActionEnum.None)
                {
                    return;
                }
                else
                {
                    updated = false;
                }

                log.Debug($"Conflict with the target file: '{targetPath}' - Source : '{statusDetail.SourceFile}' - Copy: {copy} - New status: {status}");
            }
            else //No conflicts
            {
                copy = true;
            }

            if (copy)
            {
                string directory = Path.GetDirectoryName(targetPath);
                CreateDirectory(new DirectoryInfo(directory));

                log.Info($"Copying from: '{statusDetail.SourceFile}' to '{targetPath}'");
                var fileCopier = new CustomFileCopier(statusDetail.SourceFile, targetPath, this);
                fileCopier.OnProgressChanged += (double persentage, ref bool cancel) =>
                {
                    IncrementProgress(10 + (int)((persentage / 100) * 90)); //10% for the name the rest for the copy
                };
                fileCopier.Copy();
                log.Info("File copied");
            }

            if (updated)
            {
                statusDetail.DestinationFile = targetPath;
                statusDetail.SynchDate       = DateTime.Now;
                statusDetail.Status          = StatusEnum.Synched;
            }
        }
コード例 #13
0
 public TaskStatus GetDefaultTaskStatus(BusinessAccount businessAccount, StatusDetail detail)
 {
     return businessAccount.TaskStatuses.FirstOrDefault(ts => ts.StatusDetails.Contains(detail));
 }
コード例 #14
0
        private void CopyFile(StatusDetail statusDetail, string targetPath, Guid batchId)
        {
            bool copy    = false;
            var  status  = statusDetail.Status;
            bool updated = true;

            FileExistDialog.FileExistActionEnum decision = FileExistDialog.FileExistActionEnum.None;

            if (File.Exists(targetPath))
            {
                if (LastBatchId == batchId &&
                    (LastDecision == FileExistDialog.FileExistActionEnum.OverrideAll ||
                     LastDecision == FileExistDialog.FileExistActionEnum.SkipAndLetStatusAll ||
                     LastDecision == FileExistDialog.FileExistActionEnum.SkipButSynchedAll))
                {
                    decision = LastDecision;
                }
                else
                {
                    decision = GetDecisionFromMessageBox(statusDetail, targetPath);
                }

                switch (decision)
                {
                case FileExistDialog.FileExistActionEnum.Override:     // Override
                case FileExistDialog.FileExistActionEnum.OverrideAll:  // Override
                    copy = true;
                    statusDetail.Status = StatusEnum.Synched;
                    break;

                case FileExistDialog.FileExistActionEnum.SkipButSynched:     // Skip but mark as synched
                case FileExistDialog.FileExistActionEnum.SkipButSynchedAll:  // Skip but mark as synched
                    statusDetail.Status = StatusEnum.Synched;
                    break;

                case FileExistDialog.FileExistActionEnum.None:
                    return;

                default:
                    updated = false;
                    break;
                }

                log.Debug($"Conflict with the target file: '{targetPath}' - Source : '{statusDetail.SourceFile}' - Copy: {copy} - New status: {status}");
            }
            else //No conflicts
            {
                copy = true;
            }

            if (copy)
            {
                string directory = Path.GetDirectoryName(targetPath);
                CreateDirectory(new DirectoryInfo(directory));

                log.Info($"Copying from: '{statusDetail.SourceFile}' to '{targetPath}'");
                File.Copy(statusDetail.SourceFile, targetPath, true);
                log.Info("File copied");
            }

            if (updated)
            {
                statusDetail.DestinationFile = targetPath;
                statusDetail.SynchDate       = DateTime.Now;
                statusDetail.Status          = StatusEnum.Synched;
            }
        }
コード例 #15
0
 public RenameAndCopyTasks(Guid taskBatchId, StatusDetail statusDetail)
     : base(taskBatchId, Path.GetFileName(statusDetail.SourceFile), statusDetail.SourceFile)
 {
     _statusDetail = statusDetail;
 }
コード例 #16
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var pedido = new Pedido();
                if (!string.IsNullOrEmpty(Request.QueryString["idPedido"]))
                {
                    pedido.ID = Convert.ToInt32(Request.QueryString["idPedido"]);
                }

                pedido = commands["CONSULTAR"].execute(pedido).Entidades.Cast <Pedido>().ElementAt(0);

                pedido.EnderecoEntrega = commands["CONSULTAR"].execute(new Endereco()
                {
                    ID = pedido.EnderecoEntrega.ID
                }).Entidades.Cast <Endereco>().ElementAt(0);

                pedido.Detalhes = commands["CONSULTAR"].execute(new PedidoDetalhe()
                {
                    IdPedido = pedido.ID
                }).Entidades.Cast <PedidoDetalhe>().ToList();

                pedido.CCs = commands["CONSULTAR"].execute(new CartaoCreditoPedido()
                {
                    IdPedido = pedido.ID
                }).Entidades.Cast <CartaoCreditoPedido>().ToList();

                entidades = new List <EntidadeDominio>();
                entidades = commands["CONSULTAR"].execute(new PedidoXCupom()
                {
                    ID = pedido.ID
                }).Entidades;
                if (entidades.Count > 0)
                {
                    pedido.CupomPromocional = commands["CONSULTAR"].execute(new PedidoXCupom()
                    {
                        ID = pedido.ID
                    }).Entidades.Cast <PedidoXCupom>().ElementAt(0).Cupom;
                }


                entidades = new List <EntidadeDominio>();
                entidades = commands["CONSULTAR"].execute(new Cupom()
                {
                    IdPedido = pedido.ID
                }).Entidades;
                if (entidades.Count > 0)
                {
                    pedido.CuponsTroca = commands["CONSULTAR"].execute(new Cupom()
                    {
                        IdPedido = pedido.ID
                    }).Entidades.Cast <Cupom>().ToList();
                }


                // Set OrderId.
                Session["currentOrderId"] = pedido.ID;

                // Exibi as informações Entrega
                List <Pedido> listaPedido = new List <Pedido>();
                listaPedido.Add(pedido);
                ShipInfo.DataSource = listaPedido;
                ShipInfo.DataBind();

                // Exibi as informações Status
                List <Pedido> listaStatus = new List <Pedido>();
                listaStatus.Add(pedido);
                StatusDetail.DataSource = listaStatus;
                StatusDetail.DataBind();

                // Exibi as informações Total
                List <Pedido> listaTotal = new List <Pedido>();
                listaTotal.Add(pedido);
                TotalDetail.DataSource = listaTotal;
                TotalDetail.DataBind();

                if (pedido.Status.ID == 6 || pedido.Status.ID == 7 || pedido.Status.ID == 8)
                {
                    ShipInfo.Visible = false;
                }
                else
                {
                    ShipInfo.Visible = true;
                }

                // Mostra os detalhes do pedido
                OrderItemList.DataSource = pedido.Detalhes;
                OrderItemList.DataBind();
            }
            else
            {
                //Response.Redirect("./CheckoutError.aspx?Desc=ID%20de%20pedido%20incompatível.");
            }
        }
コード例 #17
0
ファイル: Logging.cs プロジェクト: osustarg/robot-control-app
 public void Record(string url)
 {
     try
     {
         string[] logText = { StatusType.ToString().Replace(",", "-"), StatusMessage.Replace(",", "-"), StatusDetail.Replace(",", "-"), DateTime.Now.ToString() };
         if (!File.Exists(url))
         {
             CreateNewFile(url);
         }
         File.AppendAllText(url, String.Join(",", logText) + Environment.NewLine + Environment.NewLine);
     }
     catch (Exception)
     {
     }
 }
コード例 #18
0
        public async Task Status()
        {
            await Context.Interaction.DeferAsync(ephemeral : true);

            EmbedBuilder embed = new EmbedBuilder()
                                 .WithTitle(Translator.T().CmdStatusTitle())
                                 .WithColor(Color.Green)
                                 .WithCurrentTimestamp();

            StatusRepository repo = StatusRepository.CreateDefault(ServiceProvider);

            StatusDetail botDetails = repo.GetBotStatus();
            StatusDetail dbDetails  = await repo.GetDbStatus();

            StatusDetail cacheDetails = repo.GetCacheStatus();

            string lastDisconnect = string.Empty;

            if (botDetails.LastDisconnect != null)
            {
                lastDisconnect = Translator.T().CmdStatusLastDisconnectAt(botDetails.LastDisconnect.Value.ToDiscordTS());
            }

            embed.AddField(
                GetCheckEmote(botDetails.Online) + " " + Translator.T().CmdStatusBot(),
                $"{botDetails.ResponseTime:0.0}ms\n{lastDisconnect}",
                false
                );
            embed.AddField(
                GetCheckEmote(dbDetails.Online) + " " + Translator.T().CmdStatusDatabase(),
                $"{dbDetails.ResponseTime:0.0}ms",
                false
                );
            embed.AddField(
                GetCheckEmote(cacheDetails.Online) + " " + Translator.T().CmdStatusInternalCache(),
                $"{cacheDetails.ResponseTime:0.0}ms",
                false
                );

            if (!(botDetails.Online && dbDetails.Online && cacheDetails.Online))
            {
                embed.WithColor(Color.Red);
            }

            StringBuilder loggedInString = new();
            int           loggedInCount  = 0;

            foreach (var item in IdentityManager.GetCurrentIdentities().Where(x => x is DiscordOAuthIdentity))
            {
                var user = item.GetCurrentUser();
                if (user != null)
                {
                    loggedInString.AppendLine($"{user.Username}#{user.Discriminator}");
                    loggedInCount++;
                }
            }
            if (loggedInCount != 0)
            {
                embed.AddField(
                    $"{Translator.T().CmdStatusCurrentlyLoggedIn()} [{loggedInCount}]",
                    loggedInString.ToString().Truncate(1024),
                    false
                    );
            }

            await Context.Interaction.ModifyOriginalResponseAsync((msg) => { msg.Embed = embed.Build(); });
        }
コード例 #19
0
 public void Synch(StatusDetail statusDetail, Guid batchId)
 {
 }