public void AddError(string error)
 {
     ErrorsList.Add(error);
     RaisePropertyChanged(() => DawgVisible);
     RaisePropertyChanged(() => NumOfErrors);
     RaisePropertyChanged(() => Errors);
 }
Exemplo n.º 2
0
        private async Task <User> UpdatePassword(User selectedUser)
        {
            User userDetails = await _DbContext.Users.FindAsync(selectedUser.Id).ConfigureAwait(false);

            if (userDetails == null)
            {
                CoreFunc.Error(ref ErrorsList, "User not found!");
                return(null);
            }
            string passResetToken = await _UserManager.GeneratePasswordResetTokenAsync(userDetails).ConfigureAwait(false);

            IdentityResult result = await _UserManager.ResetPasswordAsync(
                userDetails, passResetToken, selectedUser.Password).ConfigureAwait(false);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ErrorsList.Add(new Error(error.Code, error.Description));
                }
                return(null);
            }

            return(userDetails);
        }
 private void ResetLog()
 {
     ErrorsList.Clear();
     RaisePropertyChanged(() => DawgVisible);
     RaisePropertyChanged(() => NumOfErrors);
     RaisePropertyChanged(() => Errors);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Маппинг IdentityError в словарь для ValidationResult
        /// </summary>
        /// <param name="errors">Коллекция Identity Error</param>
        /// <returns>Словарь ошибок для ValidationResult</returns>
        public static Dictionary <string, List <string> > ConvertToValidationResult(this IEnumerable <IdentityError> errors)
        {
            Dictionary <string, List <string> > result = new Dictionary <string, List <string> >();

            if (errors != null)
            {
                foreach (IdentityError error in errors)
                {
                    if (result.TryGetValue(error.Code, out List <string> ErrorsList))
                    {
                        ErrorsList.Add(error.Description);
                    }
                    else
                    {
                        result.TryAdd(error.Code, new List <string>()
                        {
                            error.Description
                        });
                    }
                }

                return(result);
            }

            return(result);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> ConfirmEmail([FromBody] string pathName)
        {
            try
            {
                string tokenValue = "";

                for (int i = pathName.Length - 1; i >= 0; i--)
                {
                    if (pathName[i] == '/')
                    {
                        i = -1;
                    }
                    else
                    {
                        tokenValue = pathName[i] + tokenValue;
                    }
                }

                Token token = await _DbContext.Tokens
                              .Include(t => t.User)
                              .FirstOrDefaultAsync(t => t.Url.Contains(pathName) && t.Value.Equals(tokenValue))
                              .ConfigureAwait(false);

                if (token == null || token.Type != Extras.CustomTypes.TokenTypes.ConfirmEmail)
                {
                    ErrorsList.Add(new Error("0", "Invalid Request/Token."));
                    return(StatusCode(412, ErrorsList));
                }

                if (token.ExpiaryDateTime < DateTime.UtcNow)
                {
                    ErrorsList.Add(new Error("0", "Token Expired"));
                    return(StatusCode(412, ErrorsList));
                }

                IdentityResult result = await _UserManager.ConfirmEmailAsync(token.User,
                                                                             await _UserManager.GenerateEmailConfirmationTokenAsync(token.User).ConfigureAwait(false))
                                        .ConfigureAwait(false);

                _DbContext.Entry(token.User).State = EntityState.Unchanged;
                _DbContext.Remove(entity: token);
                await _DbContext.SaveChangesAsync().ConfigureAwait(false);

                if (result.Succeeded)
                {
                    return(Ok());
                }
                else
                {
                    ErrorsList.Add(new Error("0", "Unable to process your request."));
                    return(StatusCode(412, ErrorsList));
                }
            }
            catch (Exception ex)
            {
                CoreFunc.Error(ref ErrorsList, _LoggingService.LogException(Request.Path, ex, User));
                return(StatusCode(417, ErrorsList));
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Конструктор для ошибки null argument
 /// </summary>
 public ValidationException(string nullArgName, bool isCritical = true) : base("Ошибки валидации модели")
 {
     this.IsCritical = isCritical;
     this.ErrorsList = new ErrorsList()
     {
         $"argument {nullArgName} must be not null"
     };
 }
Exemplo n.º 7
0
 public void AddError(string message, LookUps.ErrorType errorType, string propertyName = "")
 {
     ErrorsList.Add(new Error
     {
         Message      = message,
         PropertyName = propertyName,
         ErrorType    = errorType
     });
 }
Exemplo n.º 8
0
        public void Process4TotalsItems()
        {
            // verzamel de posten
            // maak alle csv posten 0

            foreach (var item in ItemsList)
            {
                item.Total = 0.0; // maak de csv post 0
            }

            // verzamel de bij/af bedragen per csv post

            foreach (var transaction in TransactionsFilteredList)
            {
                bool lFound = false;
                foreach (var item in ItemsList)
                {
                    if (transaction.IsTegenrekeningEnBevat(item.Tegenrekening, item.Bevat))
                    {
                        lFound = true;
                        try
                        {
                            if (transaction.Af_Bij == "Bij")
                            {
                                item.Total += double.Parse(transaction.Bedrag);
                            }
                            else if (transaction.Af_Bij == "Af")
                            {
                                item.Total -= double.Parse(transaction.Bedrag);
                            }
                        }
                        catch (Exception)
                        {
                            ErrorsList.Add(transaction.Naam_Omschrijving + " " + "error in double parse");
                        }
                    }
                }
                if (!lFound)
                {
                    var item = ItemsList[0];                                         // item unkown
                    if (transaction.Item.CategoryId == CategoriesList[1].CategoryId) // collect unknown
                    {
                        if (transaction.Af_Bij == "Bij")
                        {
                            item.Total += double.Parse(transaction.Bedrag);
                        }
                        else if (transaction.Af_Bij == "Af")
                        {
                            item.Total -= double.Parse(transaction.Bedrag);
                        }
                    }
                    ErrorsList.Add(transaction.ToString() + "-- not to item");
                }
            }

            // post: ivListOfCSVPosten is gevuld
        }
Exemplo n.º 9
0
        public void AddModelError(ErrorModel errorModel)
        {
            if (ErrorsList == null)
            {
                ErrorsList = new List <ErrorModel>();
            }

            ErrorsList.Add(errorModel);
        }
Exemplo n.º 10
0
        /// <summary>
        /// This method is stopping the starting procedure
        /// </summary>
        public void StopStartingProcedure()
        {
            GapCountTimer.Stop();
            IsCancelled = true;
            HasErrors   = true;

            ErrorLog log = new ErrorLog(DateTime.Now, LogNameProgramStarter, LogNameStartingProgramsHandler, "Starting procedure cancelled by User");

            ErrorsList.Add(log);
        }
Exemplo n.º 11
0
        // ----------------------------------------------------------------------------------------
        // Ошибки компиляции
        // ----------------------------------------------------------------------------------------
        public void Compile()
        {
            if (ErrorsList != null)
            {
                ErrorsList.Clear();
            }

            ErrorsList = Compiler.Instance.Compile(this);

            OnCompiled();
        }
Exemplo n.º 12
0
 public bool HasErrorByType(LookUps.ErrorType?errorType = null)
 {
     if (errorType == null)
     {
         return(ErrorsList.Count() > 0);
     }
     else
     {
         return(ErrorsList.Where(x => x.ErrorType == errorType).Count() > 0);
     }
 }
Exemplo n.º 13
0
        public List <Item> ReadListOfItems(string itemsFile)
        {
            List <Item> lListOfItems = new List <Item>();
            List <Item> lItemsToSkip = new List <Item> {
                new Item {
                    ItemName = "Post"
                }, new Item {
                    ItemName = "category"
                }, new Item {
                    ItemName = "comment"
                }
            };
            string lLine;
            int    lCounter = 0;

            lListOfItems.Clear();

            lListOfItems.Add(new Item()
            {
                ItemName = "unknown", Tegenrekening = "xxx", Bevat = "xxx", CategoryId = 0, CategoryStr = "unknown"
            });

            System.IO.StreamReader file =
                new System.IO.StreamReader(itemsFile);
            while ((lLine = file.ReadLine()) != null)
            {
                Item lItem = new Item();
                lItem.ReadLine(lLine);

                if (!lItemsToSkip.Exists(x => x.ItemName == lItem.ItemName))
                {
                    lItem.CategoryId = Convert2Id(lItem.CategoryStr);

                    if (lListOfItems.Exists(i => i.ItemName == lItem.ItemName))
                    {
                        ErrorsList.Add(lItem.ItemName + " " + lItem.Bevat + " " + "-- already exists");
                    }

                    lListOfItems.Add(lItem);

                    lCounter++;
                }
                else
                {
                    // skip item
                    int i = 1;
                }
            }
            file.Close();

            return(lListOfItems);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Validates this instance.
        /// </summary>
        /// <param name="edc">The <see cref="Entities"/>.</param>
        /// <param name="disposals">The list of disposals created already.</param>
        /// <exception cref="InputDataValidationException">Batch content validate failed;XML content validation</exception>
        public void Validate(Entities edc, IEnumerable <Disposal> disposals)
        {
            ErrorsList _validationErrors = new ErrorsList();

            if (Product == null)
            {
                _validationErrors.Add(new Warnning("Unrecognized finished good", true));
            }
            SKULookup = SKUCommonPart.Find(edc, Product.SKU);
            if (SKULookup == null)
            {
                string _msg = "Cannot find finished good SKU={0} in the SKU dictionary - dictionary update is required";
                _validationErrors.Add(new Warnning(String.Format(_msg, Product.SKU), true));
            }
            if (Product.ProductType != ProductType.Cigarette)
            {
                return;
            }
            Dictionary <string, IGrouping <string, Disposal> > _disposalGroups;

            _disposalGroups = (from _mx in disposals
                               group _mx by _mx.Disposal2IPRIndex.Batch).ToDictionary <IGrouping <string, Disposal>, string>(k => k.Key);
            Dictionary <string, decimal> _materials = new Dictionary <string, decimal>();

            //sum disposed material
            foreach (IGrouping <string, Disposal> _groupX in _disposalGroups.Values)
            {
                _materials.Add(_groupX.Key, _groupX.Sum <Disposal>(x => x.SettledQuantityDec));
            }
            foreach (Material _materialX in this.Values)
            {
                if (_materialX.ProductType.Value != Linq.ProductType.IPRTobacco)
                {
                    continue;
                }
                decimal _disposed = 0;
                if (_materials.ContainsKey(_materialX.Batch))
                {
                    _disposed = _materials[_materialX.Batch];
                }
                decimal _diff = _materialX.Accounts2Dispose.Sum <IPR>(a => a.TobaccoNotAllocatedDec) + _disposed - _materialX.TobaccoQuantityDec;
                if (_diff < -Settings.MinimalOveruse)
                {
                    string _mssg = "Cannot find any IPR account to dispose the quantity {3}: Tobacco batch: {0}, fg batch: {1}, quantity to dispose: {2} kg";
                    _validationErrors.Add(new Warnning(String.Format(_mssg, _materialX.Batch, Product.Batch, _materialX.TobaccoQuantityDec, -_diff), true));
                }
            }
            if (_validationErrors.Count > 0)
            {
                throw new InputDataValidationException("Batch content validation failed", "XML content validation", _validationErrors);
            }
        }
Exemplo n.º 15
0
        public void SetItem4Transactions()
        {
            string itemListNewFile = "posten_nieuw.csv";
            var    path            = Path.Combine(pathServer, itemListNewFile);

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            int           count                 = 0;
            int           volgnummer            = 0;
            List <string> lListNaamOmschrijving = new List <string>();

            foreach (var t in TransactionsFilteredList)
            {
                bool lFound = false;
                foreach (var p in ItemsList) // transaction of known item gets last found item (last item can overrule previous items)
                {
                    if (t.IsTegenrekeningEnBevat(p.Tegenrekening, p.Bevat))
                    {
                        lFound = true;
                        t.Item = p;
                    }
                }
                if (!lFound)                                           // transaction of unkonw item get item unknown
                {
                    Item i = ItemsList[0];                             // item unknown
                    t.Item             = i;
                    t.Item.CategoryId  = CategoriesList[1].CategoryId; // category unknown
                    t.Item.CategoryStr = CategoriesList[1].CategoryStr;

                    count++;
                    ErrorsList.Add(t.ToString() + "-- transaction not found in itemslist; set to item unknown");

                    if (!lListNaamOmschrijving.Contains(t.Naam_Omschrijving))
                    {
                        lListNaamOmschrijving.Add(t.Naam_Omschrijving);

                        using (StreamWriter sw = File.AppendText(path))
                        {
                            sw.WriteLine("");
                            //              item                                      tegenrekening                         bevat                                     category
                            sw.Write("\"" + t.Naam_Omschrijving + "\"" + "," + "\"" + t.Tegenrekening + "\"" + "," + "\"" + t.Naam_Omschrijving + "\"" + "," + "\"" + "unknown" + "\"");
                            sw.Close();
                            volgnummer++;
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void AddNewErrorItem(JToken jtError, string keyMessage)
        {
            var error     = CreateError(jtError, keyMessage);
            var exisError = ErrorsList.FirstOrDefault(model => model.Message == error.Message);

            if (exisError == null)
            {
                ErrorsList.Add(error);
            }
            else
            {
                exisError.CountFounded++;
            }
        }
Exemplo n.º 17
0
        private static void CWClearThroughCustoms(CWClearanceData _accountData, string webUrl, out string comments)
        {
            List <Warnning> _lw = new List <Warnning>();

            _accountData.CallService(webUrl, _lw);
            if (_lw.Count == 0)
            {
                comments = "CW account created";
                return;
            }
            ErrorsList _el = new ErrorsList();

            _el.AddRange(_lw);
            throw new InputDataValidationException("Create CW Account Failed", "CreateCWAccount", _el);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Analyzes the goods description.
        /// </summary>
        /// <param name="edc">The <see cref="Entities"/> instance</param>
        /// <param name="goodsDescription">The _ goods description.</param>
        /// <exception cref="InputDataValidationException">Syntax errors in the good description. AnalyzeGoodsDescription</exception>
        /// <exception cref="CAS.SmartFactory.IPR.WebsiteModel.InputDataValidationException">Syntax errors in the good description.</exception>
        private void AnalyzeGoodsDescription(Entities edc, string goodsDescription)
        {
            List <string> _sErrors = new List <string>();
            string        _na      = "Not recognized";

            TobaccoName  = goodsDescription.GetFirstCapture(Settings.GetParameter(edc, SettingsEntry.GoodsDescriptionTobaccoNamePattern), _na, _sErrors);
            GradeName    = goodsDescription.GetFirstCapture(Settings.GetParameter(edc, SettingsEntry.GoodsDescriptionWGRADEPattern), _na, _sErrors);
            SKU          = goodsDescription.GetFirstCapture(Settings.GetParameter(edc, SettingsEntry.GoodsDescriptionSKUPattern), _na, _sErrors);
            this.BatchId = goodsDescription.GetFirstCapture(Settings.GetParameter(edc, SettingsEntry.GoodsDescriptionBatchPattern), _na, _sErrors);
            if (_sErrors.Count > 0)
            {
                ErrorsList _el = new ErrorsList();
                _el.Add(_sErrors, true);
                throw new InputDataValidationException("Syntax errors in the good description.", "AnalyzeGoodsDescription", _el);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Метод добавления ошибок
        /// </summary>
        /// <param name="key"></param>
        /// <param name="errorMessage"></param>
        public void AddError(string key, string errorMessage)
        {
            IsFailed = true;

            if (Errors.TryGetValue(key, out List <string> ErrorsList))
            {
                ErrorsList.Add(errorMessage);
            }
            else
            {
                Errors.TryAdd(key, new List <string>()
                {
                    errorMessage
                });
            }
        }
Exemplo n.º 20
0
 private void GetBatchLookup(Entities edc, ErrorsList warnings)
 {
     if (ProductType != Linq.ProductType.Cigarette && ProductType != Linq.ProductType.Cutfiller)
     {
         return;
     }
     if (!IPRType.GetValueOrDefault(false))
     {
         return;
     }
     this.BatchIndex = Linq.Batch.FindStockToBatchLookup(edc, this.Batch);
     if (this.BatchIndex != null)
     {
         return;
     }
     warnings.Add(new Warnning(NoMachingBatchWarningMessage, false));
 }
Exemplo n.º 21
0
        public async Task <ErrorsList> RegistarReserva(ReservaPostModel reserva)
        {
            try
            {
                _client.DefaultRequestHeaders.Authorization =
                    new AuthenticationHeaderValue("Bearer", App.AuthToken.Token);

                var content  = JsonConvert.SerializeObject(reserva);
                var response = await _client.PostAsync(URL_reserva, new StringContent(content, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    return(new ErrorsList());
                }
                if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    var erros = new ErrorsList();
                    erros.Erros.Add(21);      // Adiciona erro 21 Erro do lado do servidor
                    return(erros);
                }
                else
                {
                    var erros = JsonConvert.DeserializeObject <ErrorsList>(response.Content.ReadAsStringAsync().Result);

                    /*
                     * if (!erros.Erros.Any())
                     * {
                     *  // TODO: Alterar o código de erro
                     *  // Adiciona erro 20 Campos de Preenchimento Obrigatorio
                     *  erros.Erros.Add(20);
                     * }*/
                    foreach (int e in erros.Erros)
                    {
                        Console.WriteLine("[ERRO] " + e);
                    }

                    return(erros);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                throw ex;
            }
        }
Exemplo n.º 22
0
        [Authorize(AppConst.AccessPolicies.Secret)] /// Done
        public async Task <IActionResult> PutTemplate([FromBody] EmailTemplate emailTemplate)
        {
            try
            {
                /// if model validation failed
                if (!TryValidateModel(emailTemplate))
                {
                    CoreFunc.ExtractErrors(ModelState, ref ErrorsList);
                    /// return Unprocessable Entity with all the errors
                    return(UnprocessableEntity(ErrorsList));
                }


                EmailTemplate foundTemplate = await _DbContext.EmailTemplates
                                              .FirstOrDefaultAsync((et) => et.Id == emailTemplate.Id)
                                              .ConfigureAwait(false);

                if (foundTemplate == null)
                {
                    ErrorsList.Add(new Error("", "Template cannot be found."));
                    /// return Unprocessable Entity with all the errors
                    return(UnprocessableEntity(ErrorsList));
                }

                foundTemplate.PrepareHtml(WebHost.WebRootPath);
                emailTemplate.RemoveHtmlComment();
                if (foundTemplate.HTML != emailTemplate.HTML)
                {
                    emailTemplate.SaveFilesToWWWRoot(WebHost.WebRootPath);
                }
                else
                {
                    emailTemplate.FolderName = foundTemplate.FolderName;
                }
                _DbContext.EmailTemplates.Update(emailTemplate);
                await _DbContext.SaveChangesAsync().ConfigureAwait(false);

                return(Ok(emailTemplate));
            }
            catch (Exception ex)
            {
                CoreFunc.Error(ref ErrorsList, _LoggingService.LogException(Request.Path, ex, User));
                return(StatusCode(417, ErrorsList));
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Imports the batch from XML.
        /// </summary>
        /// <param name="edc">The _edc.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="progressChanged">The progress changed delegate <see cref="ProgressChangedEventHandler" />.</param>
        /// <returns></returns>
        /// <exception cref="CAS.SmartFactory.IPR.WebsiteModel.InputDataValidationException">Batch XML message validation failed;XML sysntax validation</exception>
        /// <exception cref="IPRDataConsistencyException"></exception>
        public static BatchXml ImportBatchFromXml(Entities edc, Stream stream, string fileName, ProgressChangedEventHandler progressChanged)
        {
            progressChanged(null, new ProgressChangedEventArgs(1, "ImportBatchFromXml.starting"));
            string _Message = String.Format(m_Message, fileName);

            ActivityLogCT.WriteEntry(edc, m_Title, _Message);
            BatchXml _xml = BatchXml.ImportDocument(stream);

            progressChanged(null, new ProgressChangedEventArgs(1, "ImportBatchFromXml.Validate"));
            List <string> _validationErrors = new List <string>();

            _xml.Validate(Settings.GetParameter(edc, SettingsEntry.BatchNumberPattern), _validationErrors);
            if (_validationErrors.Count > 0)
            {
                ErrorsList _el = new ErrorsList(_validationErrors, true);
                throw new InputDataValidationException("Batch XML message validation failed", "XML sysntax validation", _el);
            }
            return(_xml);
        }
Exemplo n.º 24
0
        private async Task PassJsonResponseToErrorService(HttpResponseMessage response)
        {
            var stringResponse = await response.Content.ReadAsStringAsync();

            ErrorsList output = JsonConvert.DeserializeObject <ErrorsList>(stringResponse);

            if (output.Errors == null)
            {
                var error = JsonConvert.DeserializeObject <Error>(stringResponse);
                if (error != null)
                {
                    output.Errors = new List <Error>()
                    {
                        error
                    };
                }
            }
            _backendErrorsService.AddErrors(output);
        }
Exemplo n.º 25
0
        private static bool GetXmlContent(InvoiceItemXml[] invoiceEntries, Entities edc, InvoiceLib parent)
        {
            List <InvoiceContent> _invcs    = new List <InvoiceContent>();
            ErrorsList            _warnings = new ErrorsList();
            bool _result = true;

            foreach (InvoiceItemXml item in invoiceEntries)
            {
                try
                {
                    InvoiceContent _ic = CreateInvoiceContent(edc, parent, item, _warnings);
                    if (_ic == null)
                    {
                        continue;
                    }
                    _invcs.Add(_ic);
                    _result &= _ic.InvoiceContentStatus.Value == InvoiceContentStatus.OK;
                    if (parent.BillDoc.IsNullOrEmpty())
                    {
                        parent.BillDoc             = item.Bill_doc.ToString();
                        parent.InvoiceCreationDate = item.Created_on;
                    }
                }
                catch (Exception ex)
                {
                    string _msg = "Cannot create new entry for the invoice No={0}/{1}, SKU={2}, because of error: {3}";
                    _warnings.Add(new Warnning(String.Format(_msg, item.Bill_doc, item.Item, item.Description, ex.Message), true));
                }
            }
            if (_warnings.Count > 0)
            {
                throw new InputDataValidationException("there are fatal errors in the XML message.", "GetBatchLookup", _warnings);
            }
            edc.InvoiceContent.InsertAllOnSubmit(_invcs);
            edc.SubmitChanges();
            foreach (InvoiceContent _ic in _invcs)
            {
                _ic.CreateTitle();
            }
            edc.SubmitChanges();
            return(_result);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Begining starting procedure for all programs in the list
        /// </summary>
        public void Start()
        {
            //if programs list is not empty then begin starting programs
            if (ProgramsToStartList.Any())
            {
                //Start first program in the list
                StartNextProgram();

                //Start GapCountTimer and every timer tick next program will be started
                GapCountTimer.Start();
            }
            //if list is empty then don't begin starting programs and update ErrorLog
            else
            {
                HasErrors     = true;
                IsStartupDone = true;
                ErrorLog log = new ErrorLog(DateTime.Now, LogNameProgramStarter, LogNameStartingProgramsHandler, "List of programs to start is empty!");
                ErrorsList.Add(log);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Iports the stock from XML.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="url">The URL.</param>
        /// <param name="listIndex">Index of the list.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="progressChanged">The progress changed.</param>
        public static void IportStockFromXML(Stream stream, string url, int listIndex, string fileName, ProgressChangedEventHandler progressChanged)
        {
            try
            {
                using (Entities _edc = new Entities(url))
                {
                    String _message = String.Format("Import of the stock message {0} starting.", fileName);
                    ActivityLogCT.WriteEntry(_edc, m_Source, _message);
                    StockXml document = StockXml.ImportDocument(stream);
                    StockLib _entry   = Element.GetAtIndex <StockLib>(_edc.StockLibrary, listIndex);
                    _entry.Stock2JSOXLibraryIndex = null;
                    ErrorsList _warnings = new ErrorsList();
                    IportXml(document, _edc, _entry, _warnings, progressChanged);
                    InputDataValidationException _exc = new InputDataValidationException("there are errors in the stockm XML message.", "GetBatchLookup", _warnings);
                    switch (_exc.Valid)
                    {
                    case InputDataValidationException.Result.Success:
                        break;

                    case InputDataValidationException.Result.Warnings:
                        _exc.ReportActionResult(url, fileName);
                        break;

                    case InputDataValidationException.Result.FatalErrors:
                        throw _exc;
                    }
                    progressChanged(null, new ProgressChangedEventArgs(1, "Submitting Changes - Warnings"));
                    _edc.SubmitChanges();
                }
            }
            catch (WebsiteModel.InputDataValidationException _iove)
            {
                _iove.ReportActionResult(url, fileName);
                ActivityLogCT.WriteEntry(m_Source, String.Format("Import of the stock message {0} failed.", fileName), url);
            }
            catch (Exception ex)
            {
                ActivityLogCT.WriteEntry("Stock XML message import fatal error", ex.Message, url);
            }
            ActivityLogCT.WriteEntry(m_Source, String.Format("Import of the stock message {0} finished.", fileName), url);
        }
Exemplo n.º 28
0
 public void SetCategory4Transactions()
 {
     foreach (var t in TransactionsFilteredList)
     {
         bool lFound = false;
         foreach (var i in ItemsList)
         {
             if (t.Item.CategoryId == i.CategoryId)
             {
                 lFound     = true;
                 t.Category = new Category()
                 {
                     CategoryId = i.CategoryId, CategoryStr = i.CategoryStr
                 };
             }
         }
         if (!lFound)
         {
             ErrorsList.Add(t.ToString() + "-- not to category");
         }
     }
 }
Exemplo n.º 29
0
        [Authorize(AppConst.AccessPolicies.Secret)] /// Done
        public async Task <IActionResult> Put([FromBody] bool status)
        {
            try
            {
                Settings settings = new Settings();

                string settingsPath = AppFunc.GetFilePath(@"StaticFiles\Settings.json");
                if (string.IsNullOrEmpty(settingsPath))
                {
                    ErrorsList.Add(new Error("0", "Unable to change maintenance mode"));
                    /// return Unprocessable Entity with all the errors
                    return(UnprocessableEntity(ErrorsList));
                }

                JsonConvert.PopulateObject(System.IO.File.ReadAllText(settingsPath), settings);

                settings.MaintenanceModeStatus          = status;
                AppConst.Settings.MaintenanceModeStatus = status;

                await System.IO.File.WriteAllTextAsync(settingsPath, JsonConvert.SerializeObject(settings, Formatting.Indented, new JsonSerializerSettings
                {
                    Converters = new List <JsonConverter> {
                        new StringEnumConverter(), new DecimalFormatConverter()
                    },
                    ContractResolver = new DynamicContractResolver("OpenCors", "AntiforgeryCookieDomain", "ClientApp", "AdminApp", "MailServer"
                                                                   , "Sender", "Password", "AdminEmail", "PayPal", "ExternalLoginSecrets", "DbConnectionString", "GooglereCAPTCHASecret")
                }))
                .ConfigureAwait(false);

                AppConst.SetSettings();
                return(Ok(status));
            }
            catch (Exception ex)
            {
                CoreFunc.Error(ref ErrorsList, _LoggingService.LogException(Request.Path, ex, User));
                return(StatusCode(417, ErrorsList));
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// This method is executed when the overall compilation is over and allows to do more treatments
        /// </summary>
        private void EndOfCompilation(ProExecution obj)
        {
            // only do stuff we have reached the last running process
            if (_processesRunning > 0 || _hasBeenKilled)
            {
                return;
            }

            // everything ended ok, we do postprocess actions
            if (NumberOfProcesses == NumberOfProcessesEndedOk)
            {
                // we need to transfer all the files... (keep only distinct target files)
                foreach (var compilationProcess in _listOfCompilationProcesses)
                {
                    TransferedFiles.AddRange(compilationProcess.ProExecutionObject.CreateListOfFilesToDeploy());
                }
                TransferedFiles = obj.ProEnv.Deployer.DeployFiles(TransferedFiles, f => _deployPercentage = f);

                // Read all the log files stores the errors
                foreach (var compilationProcess in _listOfCompilationProcesses)
                {
                    var errorList = compilationProcess.ProExecutionObject.LoadErrorLog();
                    foreach (var keyValue in errorList)
                    {
                        ErrorsList.AddRange(keyValue.Value);
                    }
                }

                DeploymentDone = true;
            }

            ExecutionTime = GetElapsedTime();

            if (OnCompilationEnd != null)
            {
                OnCompilationEnd();
            }
        }