Example #1
0
        public static string ViewMemo(ArcadeUser user, Item item)
        {
            CatalogStatus status = CatalogHelper.GetCatalogStatus(user, item);

            if (status == CatalogStatus.Unknown)
            {
                return(Format.Warning("Unknown item."));
            }

            var details = new StringBuilder();

            details.AppendLine($"> 📋 **Memo: {item.Name}** (No. **{item.MemoId:000}**)");

            if (GetResearchTier(user, item) >= 1 && !string.IsNullOrWhiteSpace(item.Memo))
            {
                details.Append($"```{item.Memo}```");
            }
            else
            {
                if (status == CatalogStatus.Seen)
                {
                    details.Append($"```This item is completely foreign to me. You might need to grab a physical instance of it.```");
                }
                else
                {
                    details.Append($"```This item is confusing to say the least. More research might need to be done.```");
                }
            }

            return(details.ToString());
        }
Example #2
0
        internal static Stream BuilderHeaderBuffer(CatalogStatus status, CatalogFormat format, DateTime update, DateTime persist, params Page[] pages)
        {
            var mStream = new MemoryStream(new byte[MaxHeaderSize]);

            using (var binWriter = new BinaryWriter(mStream, Encoding, true)) {
                binWriter.Write(update.Ticks);
                binWriter.Write(persist.Ticks);
                binWriter.Write((byte)status);
                binWriter.Write((byte)format);
                binWriter.Write(pages.Length);

                if (pages != null && pages.Length > 0)
                {
                    // with pages (Type) in reverse order create PageDescriptor array
                    var pageTypes = pages.Reverse()
                                    .SelectMany(p => {
                        var pgDescr = PageDescriptor.Create(new byte[] { 1 });
                        pgDescr.Write(0, () => (byte)p.Type);

                        return((byte[])pgDescr);
                    })
                                    .ToArray();
                    binWriter.Seek(-pageTypes.Length, SeekOrigin.End);
                    binWriter.Write(pageTypes, 0, pageTypes.Length);
                }
            }

            return(mStream);
        }
        public void WaitForInventoryInSearchResult(DateTime createdTime, CatalogStatus catalogStatus)
        {
            DateTime      lastStatusDate;
            double        timeOutInSecs = CatalogTimeOuts.CatalogSearchTimeOut.TotalSeconds;
            CatalogStatus status        = catalogStatus;

            while (timeOutInSecs > 0)
            {
                lastStatusDate = Convert.ToDateTime(CatalogsTable.GetCellValueForInventory(1, "Last Status Date"), System.Globalization.CultureInfo.InvariantCulture);
                if (CatalogsTable.GetCellValueForInventory(1, "Status") != null)
                {
                    status = UtilityMethods.ConvertToEnum <CatalogStatus>(CatalogsTable.GetCellValueForInventory(1, "Status"));
                }

                if (lastStatusDate.AddMinutes(1) > createdTime && (status == catalogStatus || status == CatalogStatus.Failed || status == CatalogStatus.FailedInstant))
                {
                    break;
                }
                else
                {
                    SearchRecordsLink.Click();
                    Thread.Sleep(TimeSpan.FromSeconds(5));
                    timeOutInSecs -= 5;
                }
            }
        }
Example #4
0
 private static string GetStatusIcon(CatalogStatus status)
 {
     return(status switch
     {
         CatalogStatus.Known => "",
         CatalogStatus.Seen => "🔭 ",
         _ => "UNKNOWN_ICON"
     });
Example #5
0
        public async Task ViewItemAsync(Item item)
        {
            CatalogStatus status = CatalogHelper.GetCatalogStatus(Context.Account, item);

            if (status == CatalogStatus.Unknown && Context.Account.Items.Exists(x => x.Id == item.Id))
            {
                CatalogHelper.SetCatalogStatus(Context.Account, item, CatalogStatus.Known);
            }

            await Context.Channel.SendMessageAsync(CatalogViewer.ViewItem(item, CatalogHelper.GetCatalogStatus(Context.Account, item)));
        }
Example #6
0
 // All done, persist catalog if required
 public bool Finish()
 {
     Logger.Assert(_status != CatalogStatus.Finished);
     if (_sessionstate > SessionState.None)
     {
         EndSession(SessionResults.Ok);
     }
     Logger.WriteLine(2, "Catalog Finish '{0}'", this);
     SqlTarget.Close();
     _status = CatalogStatus.Finished;
     return(true);
 }
        public void WaitForCatalogInSearchResult(DateTime createdTime, CatalogStatus catalogStatus)
        {
            DateTime      lastStatusDate;
            double        timeOutInSecs = CatalogTimeOuts.CatalogSearchTimeOut.TotalSeconds;
            string        threadId      = string.Empty;
            CatalogStatus status        = catalogStatus;

            while (timeOutInSecs > 0)
            {
                lastStatusDate = Convert.ToDateTime(CatalogsTable.GetCellValue(1, "Last Status Date"), System.Globalization.CultureInfo.InvariantCulture);
                if (CatalogsTable.GetCellValue(1, "Status") != null)
                {
                    status = UtilityMethods.ConvertToEnum <CatalogStatus>(CatalogsTable.GetCellValue(1, "Status"));
                }

                if (lastStatusDate.AddMinutes(1) > createdTime)
                {
                    if (catalogStatus == CatalogStatus.Created && (status == CatalogStatus.Created || status == CatalogStatus.CreatedWarning || status == CatalogStatus.Failed))
                    {
                        break;
                    }
                    else if (catalogStatus == CatalogStatus.CreatedWarning && (status == CatalogStatus.Created || status == CatalogStatus.CreatedWarning || status == CatalogStatus.Failed))
                    {
                        break;
                    }
                    else if (catalogStatus == CatalogStatus.Published && (status == CatalogStatus.Published || status == CatalogStatus.PublishedWarning || status == CatalogStatus.Failed))
                    {
                        break;
                    }
                    else if (catalogStatus == CatalogStatus.CreatedInstant && (status == CatalogStatus.CreatedInstant || status == CatalogStatus.CreatedWarningInstant || status == CatalogStatus.FailedInstant))
                    {
                        break;
                    }
                    else if (catalogStatus == CatalogStatus.Failed && (status == CatalogStatus.Created || status == CatalogStatus.CreatedWarning || status == CatalogStatus.Failed))
                    {
                        break;
                    }
                    else if (catalogStatus == CatalogStatus.Failed && (status == CatalogStatus.Published || status == CatalogStatus.PublishedWarning || status == CatalogStatus.Failed))
                    {
                        break;
                    }
                }

                SearchRecordsLink.Click();
                Thread.Sleep(TimeSpan.FromSeconds(5));
                timeOutInSecs -= 5;
            }

            //threadId = CatalogsTable.GetCellValue(1, "Thread Id");
            //Console.WriteLine("Thread Id: " + threadId);
            //return threadId;
        }
Example #8
0
        // Make connection to database based on available flags and current status
        // does not return on error
        void ConnectDatabase()
        {
            if (_status > CatalogStatus.Started)
            {
                return;                             // just the once
            }
            Logger.Assert(_status == CatalogStatus.Started, _status);
            Logger.WriteLine(2, $"Catalog Connect database {this}");

            // create empty catalog
            var table = DataTableLocal.Create(_catalogtableheading);

            GlobalVars.AddEntry(CatalogTableName, table.DataType, EntryKinds.Value,
                                EntryFlags.Public | EntryFlags.System, RelationValue.Create(table));
            GlobalVars.FindEntry(CatalogTableName).Flags |= EntryFlags.Database;

            // Sql or not? Open it.
            var ext = Path.GetExtension(DatabasePath);

            if (ext == "")
            {
                DatabasePath = Path.ChangeExtension(DatabasePath, (SqlFlag) ? DefaultSqlDatabaseExtension : DefaultDatabaseExtension);
            }
            SqlFlag     |= (ext == DefaultSqlDatabaseExtension || DatabaseKind != DatabaseKinds.Memory);
            DatabaseName = Path.GetFileNameWithoutExtension(DatabasePath);
            if (SqlFlag)
            {
                if (DatabaseKind == DatabaseKinds.Memory)
                {
                    DatabaseKind = DatabaseKinds.Sqlite;
                }
                Logger.WriteLine(3, "Catalog database={0} kind={1}", DatabasePath, DatabaseKind);
                if (!SqlTarget.Open(DatabasePath, DatabaseKind))
                {
                    throw ProgramError.Fatal("Catalog", "Cannot open database: {0} ({1})", DatabasePath, DatabaseKind);
                }
            }
            else
            {
                if (LoadFlag && !Directory.Exists(DatabasePath))
                {
                    throw ProgramError.Fatal("Catalog", "Database does not exist: {0}", DatabasePath);
                }
            }
            _status = CatalogStatus.Connected;
            Logger.WriteLine(3, "[CC {0}]", this);
        }
Example #9
0
        // open the catalog for use and set database name
        // defer connect until begin session
        public void Start(string path = null)
        {
            if (_status > CatalogStatus.None)
            {
                return;                          // just the once
            }
            Logger.WriteLine(2, $"Catalog Start path:'{path}'");

            DatabasePath = path ?? DatabasePath ?? DefaultDatabaseName;
            _status      = CatalogStatus.Started;
            // if already known to be Sql get connected, else defer until reading directive or begin session
            if (SqlFlag)
            {
                ConnectDatabase();
            }
            Logger.WriteLine(3, "[CS {0}]", this);
            return;
        }
        private void WaitForCatalogInSearchResult(DateTime createdTime, CatalogStatus catalogStatus)
        {
            var timeOutInSecs = CatalogTimeOuts.CatalogSearchTimeOut.TotalSeconds;
            var status        = catalogStatus;

            while (timeOutInSecs > 0)
            {
                var lastStatusDate = Convert.ToDateTime(CatalogsTable.GetCellValue(1, "Last Status Date"), System.Globalization.CultureInfo.InvariantCulture);
                if (CatalogsTable.GetCellValue(1, "Status") != null)
                {
                    status = CatalogsTable.GetCellValue(1, "Status").ConvertToEnum <CatalogStatus>();
                }

                if (lastStatusDate.AddMinutes(1) > createdTime && (status == catalogStatus || status == CatalogStatus.Failed || status == CatalogStatus.FailedInstant))
                {
                    break;
                }
                SearchRecordsLink.Click();
                Thread.Sleep(TimeSpan.FromSeconds(5));
                timeOutInSecs -= 5;
            }
        }
Example #11
0
 // Final step is to load or create catalog in connected database
 void EnableCatalog()
 {
     if (_status > CatalogStatus.Connected)
     {
         return;                               // just the once
     }
     Logger.WriteLine(3, $"Catalog Enable {this}");
     Logger.Assert(_status == CatalogStatus.Connected, _status);
     // load or create catalog (but must start session first)
     if (LoadFlag)
     {
         if (!LinkRelvar(CatalogTableName))
         {
             throw ProgramError.Fatal("Catalog", "cannot load catalog for '{0}'", DatabaseName);
         }
         LoadFromTable();
         _status = CatalogStatus.Cataloguing;
     }
     else if (SaveFlag)
     {
         StoreToTable(); // create empty catalog
         _status = CatalogStatus.Cataloguing;
     }
 }
Example #12
0
        internal static FileInfo MakeCatalogFile(string name, CatalogStatus status, CatalogFormat format, DateTime update, DateTime persist, params PageType[] pageContent)
        {
            var dbPath = new DirectoryInfo(Path.Combine(DataDirectory.FullName, name));

            dbPath.Create();

            var length = MaxHeaderSize;
            var pages  = new Page[pageContent.Length];
            var i      = 0;

            foreach (var pc in pageContent)
            {
                pages[i] = new Page(pc);
                length  += pages[i].MaxSize;

                ++i;
            }

            var headerStream = BuilderHeaderBuffer(status, format, update, persist, pages);

            headerStream.Position = 0;

            var filePath = Path.Combine(dbPath.FullName, $"{name}.db");
            var file     = default(FileInfo);

            using (var fStream = (file = new FileInfo(filePath)).Create()) {
                headerStream.CopyTo(fStream);

                foreach (var p in pages)
                {
                    fStream.SetLength(fStream.Length + p.MaxSize);
                }
            }

            return(file);
        }
        /// <summary>
        /// Verifies Po Posting with CBL3.
        /// </summary>
        /// <param name="qatoolsTargetUrl"></param>
        /// <param name="fileName"></param>
        /// <param name="poRefNum"></param>
        /// <param name="identityName"></param>
        /// <param name="supplierPartIdExt"></param>
        /// <param name="unitPrice"></param>
        /// <param name="quantity"></param>
        public string VerifyDownloadAndPoPostingwithCxml(B2BEnvironment environment, CatalogItemType itemType, CatalogType type, CatalogStatus status, Region region, CRTStatus crtStatus,
                                                         string fileName, string poRefNum, string profileName, string identityName, string quantity)
        {
            //uniquePoRefNum = poRefNum + DateTime.Today.ToString("yyMMdd") + DateTime.Now.ToString("HHmmss");
            uniquePoRefNum = poRefNum + DateTime.Now.ToString("ffffff");
            ChannelCatalogWorkflow uxWorkFlow = new ChannelCatalogWorkflow(webDriver);
            CatalogItem            item       = uxWorkFlow.GetCatalogItem(environment, itemType, type, status, region, profileName, identityName);

            webDriver = webDriver.SwitchBrowser(BrowserName.InternetExplorer);
            webDriver.Navigate().GoToUrl(Convert.ToString(ConfigurationManager.AppSettings["BasePOURL"]));
            B2BQaToolsPage = new B2BQaToolsPage(webDriver);

            B2BQaToolsPage.PasteTargetUrl((environment == B2BEnvironment.Production) ? Convert.ToString(ConfigurationManager.AppSettings["QAToolsTargetUrlProd"])
                : Convert.ToString(ConfigurationManager.AppSettings["QAToolsTargetUrlPrev"]));

            string supplierPartIdExt = string.Empty;

            supplierPartIdExt = (crtStatus == CRTStatus.OFF) ? item.PartId : item.ManufacturerPartNumber;
            var unitPrice = Convert.ToString(item.UnitPrice);
            var file      = PoXmlGenerator.GeneratePoCxmll(fileName, uniquePoRefNum, profileName, identityName, supplierPartIdExt, unitPrice, quantity);

            B2BQaToolsPage.PasteInputXml(file);
            webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(2));
            B2BQaToolsPage.ClickSubmitMessage();
            if (B2BQaToolsPage.GetSubmissionResult().Equals("XML Response received from server Code: 200. Message: PO = " + uniquePoRefNum))
            {
                webDriver.Quit();
                Console.WriteLine("Success: PO Number: " + uniquePoRefNum);
                return(uniquePoRefNum);
            }
            else
            {
                Console.WriteLine("Error while posting PO: " + B2BQaToolsPage.GetSubmissionResult());
                Console.WriteLine("Fail: PO Number: " + uniquePoRefNum);
                throw new Exception("Error while posting PO: " + uniquePoRefNum);
            }
        }
        public Resultado Atualizar(Projeto dados)
        {
            //Resultado resultado = DadosValidos(dados);
            var resultado = new Resultado();

            if (dados == null)
            {
                resultado.Inconsistencias.Add(
                    "Preencha os Dados do Projeto");
            }
            resultado.Acao = "Atualização de Projeto";

            if (resultado.Inconsistencias.Count == 0)
            {
                Projeto Projeto = _context.Projetos.Include("CatalogEmpresa").Where(
                    p => p.Id == dados.Id).FirstOrDefault();

                if (Projeto == null)
                {
                    resultado.Inconsistencias.Add(
                        "Projeto não encontrado");
                }
                if (dados.CatalogStatusId != null)
                {
                    CatalogStatus Status = _context.CatalogStatus.Where(
                        p => p.Id == dados.CatalogStatusId).FirstOrDefault();

                    if (Status == null)
                    {
                        resultado.Inconsistencias.Add(
                            "Status não encontrado");
                    }
                }
                if (resultado.Inconsistencias.Count == 0)
                {
                    Projeto.CatalogStatusId   = dados.CatalogStatusId == null ? Projeto.CatalogStatusId : dados.CatalogStatusId;
                    Projeto.Tipo              = obterTipoProjeto(dados.Numero.ToString());
                    Projeto.Titulo            = dados.Titulo == null ? Projeto.Titulo : dados.Titulo;
                    Projeto.TituloDesc        = dados.TituloDesc == null ? Projeto.TituloDesc : dados.TituloDesc;
                    Projeto.Numero            = dados.Numero == null ? Projeto.Numero : dados.Numero;
                    Projeto.CatalogEmpresaId  = dados.CatalogEmpresaId == null ? Projeto.CatalogEmpresaId : dados.CatalogEmpresaId;
                    Projeto.CatalogSegmentoId = dados.CatalogSegmentoId == null ? Projeto.CatalogSegmentoId : dados.CatalogSegmentoId;
                    Projeto.AvaliacaoInicial  = dados.AvaliacaoInicial == null ? Projeto.AvaliacaoInicial : dados.AvaliacaoInicial;
                    Projeto.CompartResultados = (dados.CompartResultados != null && Enum.IsDefined(typeof(CompartResultados), dados.CompartResultados)) ? dados.CompartResultados : Projeto.CompartResultados;
                    Projeto.Motivacao         = dados.Motivacao == null ? Projeto.Motivacao : dados.Motivacao;
                    Projeto.Originalidade     = dados.Originalidade == null ? Projeto.Originalidade : dados.Originalidade;
                    Projeto.Aplicabilidade    = dados.Aplicabilidade == null ? Projeto.Aplicabilidade : dados.Aplicabilidade;
                    Projeto.Relevancia        = dados.Relevancia == null ? Projeto.Relevancia : dados.Relevancia;
                    Projeto.Razoabilidade     = dados.Razoabilidade == null ? Projeto.Razoabilidade : dados.Razoabilidade;
                    Projeto.Pesquisas         = dados.Pesquisas == null ? Projeto.Pesquisas : dados.Pesquisas;

                    if (dados.CatalogEmpresaId != null)
                    {
                        Empresa empresa = _context.Empresas.Where(e => e.ProjetoId == dados.Id)
                                          .Where(e => e.Classificacao == 0).FirstOrDefault();
                        if (empresa != null)
                        {
                            empresa.CatalogEmpresaId = dados.CatalogEmpresaId;
                        }
                        else
                        {
                            Projeto.Empresas = new List <Empresa> {
                                new Empresa {
                                    CatalogEmpresaId = dados.CatalogEmpresaId
                                }
                            };
                        }
                    }
                    var codigo = GerarCodigoProjeto(Projeto);
                    Projeto.Codigo = codigo;
                    _context.SaveChanges();
                }
            }
            return(resultado);
        }
Example #15
0
 public Active(CatalogStatus status)
 {
     Initialize();
     this.Catalog = status.Catalog;
 }
 public void SearchInventoryFeedRecords(string profileName, string identityName, Region region, DateTime anyTimeAfter, CatalogStatus catalogStatus)
 {
     ClearAllLink.Click();
     SelectOptionFromDropDown(SelectRegionSpan, "US");
     SelectOptionFromDropDown(SelectCustomerNameSpan, profileName);
     SelectOptionFromDropDown(SelectIdentityNameSpan, identityName.ToUpper());
     SelectCatalogStatus(catalogStatus.ConvertToString());
     InventoryCheckbox.Click();
     SearchRecordsLink.Click();
     CatalogsTable.WaitForElementVisible(TimeSpan.FromSeconds(30));
     WaitForInventoryInSearchResult(anyTimeAfter.ConvertToUtcTimeZone(), catalogStatus);
 }
        public void SearchCatalog(string profileName, string identityName, DateTime anyTimeAfter, CatalogStatus catalogStatus, CatalogType catalogType)
        {
            SelectOptionFromDropDown(SelectRegionSpan, "US");
            SelectOptionFromDropDown(SelectCustomerNameSpan, profileName);
            SelectOptionFromDropDown(SelectIdentityNameSpan, identityName.ToUpper());

            SelectOriginalOrDeltaCheckBox(catalogType);
            SelectCatalogStatus(catalogStatus.ConvertToString());
            SearchRecordsLink.Click();
            CatalogsTable.WaitForElementVisible(TimeSpan.FromSeconds(30));
            WaitForCatalogInSearchResult(anyTimeAfter.ConvertToUtcTimeZone(), catalogStatus);
        }
 public void DisplayInventoryFeedRecords(string profileName, string identityName, CatalogStatus catalogStatus)
 {
     ClearAllLink.Click();
     SelectOptionFromDropDown(SelectRegionSpan, "US");
     SelectOptionFromDropDown(SelectCustomerNameSpan, profileName);
     SelectOptionFromDropDown(SelectIdentityNameSpan, identityName.ToUpper());
     SelectCatalogStatus(catalogStatus.ConvertToString());
     InventoryCheckbox.Click();
     SearchRecordsLink.Click();
     CatalogsTable.WaitForElementVisible(TimeSpan.FromSeconds(30));
 }
Example #19
0
        public static string ViewResearch(ArcadeUser user, Item item)
        {
            bool          allowTooltips = user.Config.Tooltips;
            CatalogStatus status        = CatalogHelper.GetCatalogStatus(user, item);

            if (status == CatalogStatus.Unknown)
            {
                return(Format.Warning("Unknown item."));
            }

            long tier = GetResearchTier(user, item);

            var details = new StringBuilder();

            if (allowTooltips)
            {
                var tooltips = new List <string>();

                if (tier >= 1 && !string.IsNullOrWhiteSpace(item.Memo))
                {
                    tooltips.Add(WriteMemoTooltip(item.Id));
                }

                if (CanResearch(user, item))
                {
                    tooltips.Add(WriteTooltip(item.Id));
                }

                details.Append($"{Format.Tooltip(tooltips)}\n\n");
            }

            details.AppendLine($"> **Research: {item.Name}**");

            if (GetMaxResearchTier(item) == 0)
            {
                details.AppendLine("> Research cannot progress. Unknown entity.");
                return(details.ToString());
            }

            details.AppendLine($"> Current Tier: **{tier}**");

            if (status == CatalogStatus.Seen)
            {
                details.AppendLine("• You need to learn more about this item up close before you can begin research.");
                return(details.ToString());
            }

            details.AppendLine($"\n> **Tiers**");

            if (!string.IsNullOrWhiteSpace(item.Memo))
            {
                details.AppendLine($"• **Tier 1**: Research memo");
            }

            foreach ((int level, string summary) in item.ResearchTiers.OrderBy(x => x.Key))
            {
                details.AppendLine($"• **Tier {level}**: {summary}");
            }

            return(details.ToString());
        }