-
Notifications
You must be signed in to change notification settings - Fork 3
added large file #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
added large file #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1797,6 +1797,72 @@ public virtual int ImportNewsletterSubscribersFromTxt(Stream stream) | |
| return count; | ||
| } | ||
|
|
||
| public virtual int ImportNewsletterSubscribersFromTxt2(Stream stream) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Getting better: Overall Code Complexity Why does this problem occur?This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals. Read more. |
||
| { | ||
| var count = 0; | ||
| using (var reader = new StreamReader(stream)) | ||
| { | ||
| while (!reader.EndOfStream) | ||
| { | ||
| var line = reader.ReadLine(); | ||
| if (string.IsNullOrWhiteSpace(line)) | ||
| continue; | ||
| var tmp = line.Split(','); | ||
|
|
||
| string email; | ||
| var isActive = true; | ||
| var storeId = _storeContext.CurrentStore.Id; | ||
| //parse | ||
| if (tmp.Length == 1) | ||
| { | ||
| //"email" only | ||
| email = tmp[0].Trim(); | ||
| } | ||
| else if (tmp.Length == 2) | ||
| { | ||
| //"email" and "active" fields specified | ||
| email = tmp[0].Trim(); | ||
| isActive = bool.Parse(tmp[1].Trim()); | ||
| } | ||
| else if (tmp.Length == 3) | ||
| { | ||
| //"email" and "active" and "storeId" fields specified | ||
| email = tmp[0].Trim(); | ||
| isActive = bool.Parse(tmp[1].Trim()); | ||
| storeId = int.Parse(tmp[2].Trim()); | ||
| } | ||
| else | ||
| throw new NopException("Wrong file format"); | ||
|
|
||
| //import | ||
| var subscription = _newsLetterSubscriptionService.GetNewsLetterSubscriptionByEmailAndStoreId(email, storeId); | ||
| if (subscription != null) | ||
| { | ||
| subscription.Email = email; | ||
| subscription.Active = isActive; | ||
| _newsLetterSubscriptionService.UpdateNewsLetterSubscription(subscription); | ||
| } | ||
| else | ||
| { | ||
| subscription = new NewsLetterSubscription | ||
| { | ||
| Active = isActive, | ||
| CreatedOnUtc = DateTime.UtcNow, | ||
| Email = email, | ||
| StoreId = storeId, | ||
| NewsLetterSubscriptionGuid = Guid.NewGuid() | ||
| }; | ||
| _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); | ||
| } | ||
|
|
||
| count++; | ||
| } | ||
| } | ||
|
|
||
| return count; | ||
| } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Import states from TXT file | ||
| /// </summary> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 1030685833 | ||
| 1743653074 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ Getting worse: Lines of Code in a Single File
The lines of code increases from 1661 to 1716, improve code health by reducing it to 1000
Why does this problem occur?
The number of Lines of Code in a single file. More Lines of Code lowers the code health. Read more.
To ignore this warning click here.