|
@@ -16,6 +16,7 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
using Avalonia.Input;
|
|
|
using System.Reflection.Metadata.Ecma335;
|
|
|
using System.Text.RegularExpressions;
|
|
|
+using System.Text;
|
|
|
|
|
|
namespace AvaloniaApplication1
|
|
|
{
|
|
@@ -198,7 +199,7 @@ namespace AvaloniaApplication1
|
|
|
{
|
|
|
Zod = "Ñêîðïèîí";
|
|
|
}
|
|
|
- if (day >= 22 && mounth == 11 || day <= 21 && mounth == 12)
|
|
|
+ if (day >= 22 && day <= 31 && mounth == 11 || day <= 21 && mounth == 12)
|
|
|
{
|
|
|
Zod = "Ñòðåëåö";
|
|
|
}
|
|
@@ -214,12 +215,17 @@ namespace AvaloniaApplication1
|
|
|
{
|
|
|
Zod = "Ðûáû";
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Zod = "Äåíü èëè ìåñÿö íå ñóùåñòâóåò";
|
|
|
+ }
|
|
|
return Zod;
|
|
|
}
|
|
|
|
|
|
[Obsolete]
|
|
|
public async void Filee(object source, RoutedEventArgs args)
|
|
|
{
|
|
|
+ string header = "";
|
|
|
string path;
|
|
|
int k = 0;
|
|
|
OpenFileDialog OFD = new OpenFileDialog();
|
|
@@ -228,50 +234,176 @@ namespace AvaloniaApplication1
|
|
|
var result = await OFD.ShowAsync(this);
|
|
|
if (result != null)
|
|
|
{
|
|
|
+ Error.Text = "Ñ÷èòûâàíèå óñïåøíî";
|
|
|
path = result[0];
|
|
|
string[] lines = File.ReadAllLines(path);
|
|
|
- DateB[] dateB = new DateB[lines.Length - 1];
|
|
|
- using (StreamReader sr = new StreamReader(path))
|
|
|
- {
|
|
|
- string line = sr.ReadLine();
|
|
|
- line = sr.ReadLine();
|
|
|
- while (line != null)
|
|
|
- {
|
|
|
- string[] strs = line.Split(";").ToArray();
|
|
|
- dateB[k].dayB = strs[0];
|
|
|
- dateB[k].mounthB = strs[1];
|
|
|
- dateB[k].yearB = strs[2];
|
|
|
- k++;
|
|
|
- line = sr.ReadLine();
|
|
|
- }
|
|
|
- };
|
|
|
- int s = 0;
|
|
|
- using (StreamWriter sw = new StreamWriter(path, true))
|
|
|
+ if (lines.Length > 0)
|
|
|
{
|
|
|
- using (StreamReader sr = new StreamReader(path))
|
|
|
+ DateB[] dateB = new DateB[lines.Length - 1];
|
|
|
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
+ using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding(1251)))
|
|
|
{
|
|
|
string line = sr.ReadLine();
|
|
|
- string[] strs = line.Split(";").ToArray();
|
|
|
- strs[3] = "Çíàê çîäèàêà";
|
|
|
- strs[4] = "Âîñòî÷íûé çíàê";
|
|
|
- sw.Write(strs[0] + ';' + strs[1] + ';' + strs[2] + ';' + strs[3] + ';' + strs[4]);
|
|
|
+ header = line;
|
|
|
line = sr.ReadLine();
|
|
|
while (line != null)
|
|
|
{
|
|
|
- strs = line.Split(";").ToArray();
|
|
|
- bool isNumericDay = Regex.IsMatch(dateB[s].dayB, @"^\d+$");
|
|
|
- bool isNumericMounth = Regex.IsMatch(dateB[s].mounthB, @"^\d+$");
|
|
|
- bool isNumericYear = Regex.IsMatch(dateB[s].yearB, @"^\d+$");
|
|
|
- if (isNumericDay && isNumericMounth == true)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- s++;
|
|
|
- line = sr.ReadLine();
|
|
|
+ string[] strs = line.Split(";").ToArray();
|
|
|
+ dateB[k].dayB = strs[0];
|
|
|
+ dateB[k].mounthB = strs[1];
|
|
|
+ dateB[k].yearB = strs[2];
|
|
|
+ k++;
|
|
|
+ line = sr.ReadLine();
|
|
|
}
|
|
|
-
|
|
|
};
|
|
|
+ int s = 0;
|
|
|
+ using (StreamWriter sw = new StreamWriter("Output.csv", false, Encoding.GetEncoding(1251)))
|
|
|
+ {
|
|
|
+ sw.WriteLine(header + ";" + "Çíàê çîäèàêà" + ";" + "Âîñòî÷íûé êàëåíäàðü");
|
|
|
+ for (int i = 0; i<k; i++)
|
|
|
+ {
|
|
|
+ bool isNumericMounthNotInt = Regex.IsMatch(dateB[i].mounthB, @"^(\d+|0),\d+$");
|
|
|
+ bool isNumericDayDate = Regex.IsMatch(dateB[i].dayB, @"^\d{2}\.\d{2}\.\d{4}$");
|
|
|
+ bool isNumericDayOtr = Regex.IsMatch(dateB[i].dayB, @"^-?\d+$");
|
|
|
+ bool isNumericMounthOtr = Regex.IsMatch(dateB[i].mounthB, @"^-?\d+$");
|
|
|
+ bool isNumericYearOtr = Regex.IsMatch(dateB[i].yearB, @"^-?\d+$");
|
|
|
+ bool isNumericDay = Regex.IsMatch(dateB[i].dayB, @"^\d+$");
|
|
|
+ bool isNumericMounth = Regex.IsMatch(dateB[i].mounthB, @"^\d+$");
|
|
|
+ bool isNumericYear = Regex.IsMatch(dateB[i].yearB, @"^\d+$");
|
|
|
+ if (isNumericDay == true & isNumericMounth == true && isNumericYear == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (isNumericDay == true & isNumericMounth == false && isNumericYear == true)
|
|
|
+ {
|
|
|
+ if(dateB[i].mounthB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if(isNumericMounthOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if(dateB[i].mounthB != " ")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå ÿâëÿåòñÿ ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (isNumericDay == false & isNumericMounth == true && isNumericYear == true)
|
|
|
+ {
|
|
|
+ if (dateB[i].dayB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (isNumericDayOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB != " ")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå ÿâëÿåòñÿ ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (isNumericDay == true & isNumericMounth == true && isNumericYear == false)
|
|
|
+ {
|
|
|
+ if (dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (isNumericYearOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
|
|
|
+ }
|
|
|
+ else if (dateB[i].yearB != " ")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + Zodiac(int.Parse(dateB[i].dayB), int.Parse(dateB[i].mounthB)) + ";" + "Ãîä íå ÿâëÿåòñÿ ÷èñëîì");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (isNumericDay == false && isNumericMounth == false && isNumericYear == false)
|
|
|
+ {
|
|
|
+ if (dateB[i].dayB == "" && dateB[i].mounthB == "" && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB == "" && dateB[i].mounthB == "" && isNumericYearOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB == "" && isNumericMounthOtr == true && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí. Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (isNumericDayOtr == true && dateB[i].mounthB == "" && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì. Ìåñÿö íå óêàçàí" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (isNumericDayDate == true && dateB[i].mounthB == "" && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Â äíå óêàçàíà ïîëíàÿ äàòà. Ìåñÿö íå óêàçàí" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB == "" && dateB[i].mounthB == "" && dateB[i].yearB != "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + "Ãîä íå ÿâëÿåòñÿ ÷èñëîì");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (isNumericDay == false & isNumericMounth == false && isNumericYear == true)
|
|
|
+ {
|
|
|
+ if (dateB[i].dayB == "" && dateB[i].mounthB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö íå óêàçàíû" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (isNumericDayOtr == true && dateB[i].mounthB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì. Ìåñÿö íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB == "" && isNumericMounthOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí. Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB != "" && dateB[i].mounthB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå ÿâëÿåòñÿ ÷èñëîì. Ìåñÿö íå óêàçàí" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (dateB[i].dayB == "" && dateB[i].mounthB != "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü íå óêàçàí. Ìåñÿö íå ÿâëÿåòñÿ ÷èñëîì" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ else if (isNumericDayOtr == true && isNumericMounthOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Äåíü è ìåñÿö ÿâëÿþòñÿ îòðèöàòåëüíûìè ÷èñëàìè" + ";" + Vostoch(int.Parse(dateB[i].yearB)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (isNumericDay == true & isNumericMounth == false && isNumericYear == false)
|
|
|
+ {
|
|
|
+ if (dateB[i].mounthB == "" && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå óêàçàí" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (isNumericMounthOtr == true && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if(isNumericMounthNotInt == true && dateB[i].yearB == "")
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö ÿâëÿåòñÿ íå öåëûì ÷èñëì" + ";" + "Ãîä íå óêàçàí");
|
|
|
+ }
|
|
|
+ else if (dateB[i].mounthB != "" && isNumericYearOtr == true)
|
|
|
+ {
|
|
|
+ sw.WriteLine(dateB[i].dayB + ";" + dateB[i].mounthB + ";" + dateB[i].yearB + ";" + "Ìåñÿö íå ÿâëÿåòñÿ ÷èñëîì" + ";" + "Ãîä ÿâëÿåòñÿ îòðèöàòåëüíûì ÷èñëîì");
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Process.Start(new ProcessStartInfo
|
|
|
+ {
|
|
|
+ FileName = "Output.csv",
|
|
|
+ UseShellExecute = true
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Error.Text = "Âûáðàííûé ôàéë ïóñò";
|
|
|
}
|
|
|
}
|
|
|
}
|