diff --git a/WOWS.Framwork/App.xaml b/WOWS.Framwork/App.xaml new file mode 100644 index 0000000..09d5dd1 --- /dev/null +++ b/WOWS.Framwork/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/WOWS.Framwork/App.xaml.cs b/WOWS.Framwork/App.xaml.cs new file mode 100644 index 0000000..ba8e85c --- /dev/null +++ b/WOWS.Framwork/App.xaml.cs @@ -0,0 +1,23 @@ +using WOWS.Framwork.Views; +using Prism.Ioc; +using Prism.Modularity; +using System.Windows; + +namespace WOWS.Framwork +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App + { + protected override Window CreateShell() + { + return Container.Resolve(); + } + + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + + } + } +} diff --git a/WOWS.Framwork/Properties/AssemblyInfo.cs b/WOWS.Framwork/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ceeb84b --- /dev/null +++ b/WOWS.Framwork/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WOWS.Framwork")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WOWS.Framwork")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WOWS.Framwork/Properties/Resources.Designer.cs b/WOWS.Framwork/Properties/Resources.Designer.cs new file mode 100644 index 0000000..2efa7a2 --- /dev/null +++ b/WOWS.Framwork/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WOWS.Framwork.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WOWS.Framwork.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/WOWS.Framwork/Properties/Resources.resx b/WOWS.Framwork/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/WOWS.Framwork/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WOWS.Framwork/Properties/Settings.Designer.cs b/WOWS.Framwork/Properties/Settings.Designer.cs new file mode 100644 index 0000000..872684f --- /dev/null +++ b/WOWS.Framwork/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WOWS.Framwork.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/WOWS.Framwork/Properties/Settings.settings b/WOWS.Framwork/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/WOWS.Framwork/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/WOWS.Framwork/ViewModels/MainWindowViewModel.cs b/WOWS.Framwork/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..c68a261 --- /dev/null +++ b/WOWS.Framwork/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,19 @@ +using Prism.Mvvm; + +namespace WOWS.Framwork.ViewModels +{ + public class MainWindowViewModel : BindableBase + { + private string _title = "Prism Application"; + public string Title + { + get { return _title; } + set { SetProperty(ref _title, value); } + } + + public MainWindowViewModel() + { + + } + } +} diff --git a/WOWS.Framwork/Views/MainWindow.xaml b/WOWS.Framwork/Views/MainWindow.xaml new file mode 100644 index 0000000..32bcc2d --- /dev/null +++ b/WOWS.Framwork/Views/MainWindow.xaml @@ -0,0 +1,12 @@ + + + diff --git a/WOWS.Framwork/Views/MainWindow.xaml.cs b/WOWS.Framwork/Views/MainWindow.xaml.cs new file mode 100644 index 0000000..6e17da7 --- /dev/null +++ b/WOWS.Framwork/Views/MainWindow.xaml.cs @@ -0,0 +1,22 @@ +using System.Windows; +using CefSharp; +using CefSharp.Wpf; + +namespace WOWS.Framwork.Views +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + var browser = new ChromiumWebBrowser("https://account.emofid.com/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Deasy2_client_pkce%26redirect_uri%3Dhttps%253A%252F%252Fd.easytrader.emofid.com%252Fauth-callback%26response_type%3Dcode%26scope%3Deasy2_api%2520openid%26state%3D5dfd704832824540a691e497d4613e3a%26code_challenge%3Do0DJ5QnKxCSL3iXpVcfYXfMxuGDWA5YtwBPel4ujhNg%26code_challenge_method%3DS256%26response_mode%3Dquery");; + Content = browser; + browser.RequestContext=new RequestContext(); + + + } + } +} diff --git a/WOWS.Framwork/WOWS.Framwork.csproj b/WOWS.Framwork/WOWS.Framwork.csproj new file mode 100644 index 0000000..08a3555 --- /dev/null +++ b/WOWS.Framwork/WOWS.Framwork.csproj @@ -0,0 +1,125 @@ + + + + + Debug + AnyCPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A} + WinExe + Properties + WOWS.Framwork + WOWS.Framwork + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + PackageReference + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + 83.4.20 + + + + + \ No newline at end of file diff --git a/WolfOfWallStreet.sln b/WolfOfWallStreet.sln new file mode 100644 index 0000000..23d1cb0 --- /dev/null +++ b/WolfOfWallStreet.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WolfOfWallStreet", "WolfOfWallStreet\WolfOfWallStreet.csproj", "{C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WOWS.Framwork", "WOWS.Framwork\WOWS.Framwork.csproj", "{DA191135-C0A1-46F0-AAF3-78C24D17F40A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Debug|x64.Build.0 = Debug|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Debug|x86.ActiveCfg = Debug|x64 + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Debug|x86.Build.0 = Debug|x64 + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Release|Any CPU.Build.0 = Release|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Release|x64.ActiveCfg = Release|x64 + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Release|x64.Build.0 = Release|x64 + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Release|x86.ActiveCfg = Release|Any CPU + {C9BEAE1F-FA3B-4611-8C3C-6BBDDC56328F}.Release|x86.Build.0 = Release|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Debug|x64.ActiveCfg = Debug|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Debug|x64.Build.0 = Debug|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Debug|x86.ActiveCfg = Debug|x86 + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Debug|x86.Build.0 = Debug|x86 + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Release|Any CPU.Build.0 = Release|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Release|x64.ActiveCfg = Release|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Release|x64.Build.0 = Release|Any CPU + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Release|x86.ActiveCfg = Release|x86 + {DA191135-C0A1-46F0-AAF3-78C24D17F40A}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {002E1374-F31C-4832-9309-8D77A547CBD2} + EndGlobalSection +EndGlobal diff --git a/WolfOfWallStreet/App.xaml b/WolfOfWallStreet/App.xaml new file mode 100644 index 0000000..1bf9e03 --- /dev/null +++ b/WolfOfWallStreet/App.xaml @@ -0,0 +1,40 @@ + + + + + ../Resources/Fonts/IranSansMedium.ttf #IRANSans Medium + ../Resources/Fonts/Shabnam.ttf #Shabnam + ../Resources/Fonts/Shabnam-Bold.ttf #Shabnam Bold + ../Resources/Fonts/materialdesignicons-webfont.ttf #Material Design Icons + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WolfOfWallStreet/App.xaml.cs b/WolfOfWallStreet/App.xaml.cs new file mode 100644 index 0000000..67b5345 --- /dev/null +++ b/WolfOfWallStreet/App.xaml.cs @@ -0,0 +1,34 @@ +using Prism.Ioc; +using WolfOfWallStreet.Views; +using System.Windows; +using WolfOfWallStreet.Services; +using WolfOfWallStreet.Services.Contracts; +using WolfOfWallStreet.ViewModels; +using WolfOfWallStreet.Views.Controllers; + +namespace WolfOfWallStreet +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App + { + protected override Window CreateShell() + { + return Container.Resolve(); + } + + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.Register(); + containerRegistry.Register(); + containerRegistry.Register(); + containerRegistry.Register(); + } + } +} diff --git a/WolfOfWallStreet/Extensions/StringExtensions.cs b/WolfOfWallStreet/Extensions/StringExtensions.cs new file mode 100644 index 0000000..aa29036 --- /dev/null +++ b/WolfOfWallStreet/Extensions/StringExtensions.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Extensions +{ + + public static class StringExtensions + { + public static bool HasValue(this string value, bool ignoreWhiteSpace = true) + { + return ignoreWhiteSpace ? !String.IsNullOrWhiteSpace(value) : !String.IsNullOrEmpty(value); + } + + public static int ToInt(this string value) + { + return Convert.ToInt32(value); + } + + public static decimal ToDecimal(this string value) + { + return Convert.ToDecimal(value); + } + + public static string ToNumeric(this int value) + { + return value.ToString("N0"); //"123,456" + } + + public static string ToNumeric(this decimal value) + { + return value.ToString("N0"); + } + + public static string ToCurrency(this int value) + { + //fa-IR => current culture currency symbol => ریال + //123456 => "123,123ریال" + return value.ToString("C0"); + } + + public static string ToCurrency(this decimal value) + { + return value.ToString("C0"); + } + + public static string En2Fa(this string str) + { + return str.Replace("0", "۰") + .Replace("1", "۱") + .Replace("2", "۲") + .Replace("3", "۳") + .Replace("4", "۴") + .Replace("5", "۵") + .Replace("6", "۶") + .Replace("7", "۷") + .Replace("8", "۸") + .Replace("9", "۹"); + } + + public static string Fa2En(this string str) + { + return str.Replace("۰", "0") + .Replace("۱", "1") + .Replace("۲", "2") + .Replace("۳", "3") + .Replace("۴", "4") + .Replace("۵", "5") + .Replace("۶", "6") + .Replace("۷", "7") + .Replace("۸", "8") + .Replace("۹", "9") + //iphone numeric + .Replace("٠", "0") + .Replace("١", "1") + .Replace("٢", "2") + .Replace("٣", "3") + .Replace("٤", "4") + .Replace("٥", "5") + .Replace("٦", "6") + .Replace("٧", "7") + .Replace("٨", "8") + .Replace("٩", "9"); + } + + public static string FixPersianChars(this string str) + { + return str.Replace("ﮎ", "ک") + .Replace("ﮏ", "ک") + .Replace("ﮐ", "ک") + .Replace("ﮑ", "ک") + .Replace("ك", "ک") + .Replace("ي", "ی") + .Replace(" ", " ") + .Replace("‌", " ") + .Replace("ھ", "ه");//.Replace("ئ", "ی"); + } + + public static string CleanString(this string str) + { + return str.Trim().FixPersianChars().Fa2En().NullIfEmpty(); + } + + public static string NullIfEmpty(this string str) + { + return str?.Length == 0 ? null : str; + } + + public static string FixEmail(string email) + { + return email.Trim().ToLower(); + } + + public static string GenerateGuid(int numOfCharacter) + { + return Guid.NewGuid().ToString("N").Substring(0, numOfCharacter); + } + + public static string CombineWith(this string[] array, char character) + { + string newString = ""; + foreach (var item in array) + { + if (newString == "") + newString = item; + else + newString = newString + character + item; + } + return newString; + } + + public static int GetNumOfWeek(this string week) + { + string[] weekArray = { "شنبه", "یکشنبه", "دوشنبه", "سه شنبه", "چهار شنبه", "پنج شنبه", "جمعه" }; + return Array.IndexOf(weekArray, week); + } + + public static string[] GetMonth() + { + string[] month = { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" }; + return month; + } + } +} diff --git a/WolfOfWallStreet/Helper/ScrollHelper.cs b/WolfOfWallStreet/Helper/ScrollHelper.cs new file mode 100644 index 0000000..a90f549 --- /dev/null +++ b/WolfOfWallStreet/Helper/ScrollHelper.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using HandyControl.Controls; + +namespace WolfOfWallStreet.Helper +{ + public static class ScrollHelper + { + public static bool GetAutoScroll(DependencyObject obj) + { + return (bool)obj.GetValue(AutoScrollProperty); + } + + public static void SetAutoScroll(DependencyObject obj, bool value) + { + obj.SetValue(AutoScrollProperty, value); + } + + public static readonly DependencyProperty AutoScrollProperty = + DependencyProperty.RegisterAttached("AutoScroll", typeof(bool), typeof(ScrollHelper), new PropertyMetadata(false, AutoScrollPropertyChanged)); + + private static void AutoScrollPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var scrollViewer = d as ScrollViewer; + + if (scrollViewer != null && (bool)e.NewValue) + { + scrollViewer.ScrollToBottom(); + } + } + } +} diff --git a/WolfOfWallStreet/Models/Account.cs b/WolfOfWallStreet/Models/Account.cs new file mode 100644 index 0000000..230c6f5 --- /dev/null +++ b/WolfOfWallStreet/Models/Account.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models +{ + public class Account + { + public string Name { get; set; } + public string PhoneNumber { get; set; } + public string Email { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/EasyTrader/EasyTraderDraft.cs b/WolfOfWallStreet/Models/EasyTrader/EasyTraderDraft.cs new file mode 100644 index 0000000..23b9107 --- /dev/null +++ b/WolfOfWallStreet/Models/EasyTrader/EasyTraderDraft.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.EasyTrader +{ + public class EasyTraderDraft + { + + public string isin { get; set; } + public int financeId { get; set; } + public int quantity { get; set; } + public int price { get; set; } + public int easyState { get; set; } + public int side { get; set; } + public int validityType { get; set; } + public object validityDateJalali { get; set; } + public string stockSymbol { get; set; } + public int easySource { get; set; } + public bool cautionAgreementSelected { get; set; } + public string referenceKey { get; set; } + public string responseErrorMessage { get; set; } + + } + + public class OnlinePlusDraft + { + public bool IsSymbolCautionAgreement { get; set; } + public bool CautionAgreementSelected { get; set; } + public bool IsSymbolSepahAgreement { get; set; } + public bool SepahAgreementSelected { get; set; } + public int orderCount { get; set; } + public int orderPrice { get; set; } + public int FinancialProviderId { get; set; } + public string minimumQuantity { get; set; } + public int maxShow { get; set; } + public int orderId { get; set; } + public string isin { get; set; } + public int orderSide { get; set; } + public int orderValidity { get; set; } + public object orderValiditydate { get; set; } + public bool shortSellIsEnabled { get; set; } + public int shortSellIncentivePercent { get; set; } + + public string Cocies { get; set; } + + + } +} diff --git a/WolfOfWallStreet/Models/EasyTrader/EasyTraderOrderResult.cs b/WolfOfWallStreet/Models/EasyTrader/EasyTraderOrderResult.cs new file mode 100644 index 0000000..737c565 --- /dev/null +++ b/WolfOfWallStreet/Models/EasyTrader/EasyTraderOrderResult.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.EasyTrader +{ + public class EasyTraderOrderResult + { + public bool isSuccessfull { get; set; } + public string message { get; set; } + public int omsOrderId { get; set; } + public DateTime orderEntryDate { get; set; } + public string orderEntryDateJalali { get; set; } + public object omsErrorDescription { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/EasyTrader/EasyTraderSymbol.cs b/WolfOfWallStreet/Models/EasyTrader/EasyTraderSymbol.cs new file mode 100644 index 0000000..036ae0e --- /dev/null +++ b/WolfOfWallStreet/Models/EasyTrader/EasyTraderSymbol.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.EasyTrader +{ + public class EasyTraderSymbol + { + public double minQuantityOrder { get; set; } + public double maxQuantityOrder { get; set; } + public int lowAllowedPrice { get; set; } + public int highAllowedPrice { get; set; } + public int bidPrice { get; set; } + public int askPrice { get; set; } + public bool isCaution { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/MofidOnline/MofidOnlineOrder.cs b/WolfOfWallStreet/Models/MofidOnline/MofidOnlineOrder.cs new file mode 100644 index 0000000..c63efd7 --- /dev/null +++ b/WolfOfWallStreet/Models/MofidOnline/MofidOnlineOrder.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.MofidOnline +{ + public class MofidOnlineOrder + { + public string Mode { get; set; } + public string SymbolId { get; set; } + public string OrderPrice { get; set; } + public string OrderType { get; set; } + public string OrderSide { get; set; } + public string OrderValidity { get; set; } + public string OrderValiditydate { get; set; } + public string OrderTotalQuantity { get; set; } + public string TriggerPrice { get; set; } + public string MinimumQuantity { get; set; } + public string MaxShown { get; set; } + public string BourseCode { get; set; } + public string isin { get; set; } + public string pk { get; set; } + public string OrderMode { get; set; } + public string orderid { get; set; } + public string OrderExpectedQuantity { get; set; } + public object ts { get; set; } + public string cs { get; set; } + public string ss { get; set; } + public string SymbolNsc { get; set; } + public bool SendSMS { get; set; } + public string browserTime { get; set; } + public string IsSymbolInAgreement { get; set; } + public bool AcceptedAgreement { get; set; } + + public string Cookies { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/MofidOnline/MofidOnlineOrderResult.cs b/WolfOfWallStreet/Models/MofidOnline/MofidOnlineOrderResult.cs new file mode 100644 index 0000000..2cb5942 --- /dev/null +++ b/WolfOfWallStreet/Models/MofidOnline/MofidOnlineOrderResult.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Media; +using MD.PersianDateTime.Standard; + +namespace WolfOfWallStreet.Models.MofidOnline +{ + public class MofidOnlineOrderResult + { + + public bool haserror { get; set; } + public string Value { get; set; } + public List MetaData { get; set; } + public bool IsFinish { get; set; } + public int LastDate { get; set; } + public bool ResetOrder { get; set; } + + public DateTime GetDateTime { get; set; } + + public string GetDateTimeStr + { + get + { + PersianDateTime dateTime = new PersianDateTime(GetDateTime); + return dateTime.ToString("hh:mm:ss:fff"); + } + } + public string IsSuccessStr + { + get + { + if (haserror==false) + return "بلی"; + return "خیر"; + } + } + + public Brush StatusColor + { + get + { + if (haserror==false) + return Brushes.ForestGreen; + else + return Brushes.OrangeRed; + } + } + + } +} diff --git a/WolfOfWallStreet/Models/MofidOnline/MofidOnlineSymbol.cs b/WolfOfWallStreet/Models/MofidOnline/MofidOnlineSymbol.cs new file mode 100644 index 0000000..caf21ca --- /dev/null +++ b/WolfOfWallStreet/Models/MofidOnline/MofidOnlineSymbol.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.MofidOnline +{ + public class MofidOnlineSymbol + { + public bool isFuture { get; set; } + public string nc { get; set; } + public int ltp { get; set; } + public int cp { get; set; } + public int ht { get; set; } + public int lt { get; set; } + public int st { get; set; } + public int gs { get; set; } + public int pcp { get; set; } + public string gc { get; set; } + public int nst { get; set; } + public int nt { get; set; } + public long tv { get; set; } + public string ltd { get; set; } + public int mxp { get; set; } + public int minprod { get; set; } + public double pv { get; set; } + public int vs { get; set; } + public int hp { get; set; } + public int lp { get; set; } + public int rp { get; set; } + public int bv { get; set; } + public string est { get; set; } + public int cp12 { get; set; } + public string ect { get; set; } + public int mp { get; set; } + public string mt { get; set; } + public int cpv { get; set; } + public double cpvp { get; set; } + public int lpv { get; set; } + public double lpvp { get; set; } + public int th { get; set; } + public int tl { get; set; } + public bool iscu { get; set; } + public bool isagsp { get; set; } + public bool iso { get; set; } + public int Quantity { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusAccount.cs b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusAccount.cs new file mode 100644 index 0000000..d8f1ab1 --- /dev/null +++ b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusAccount.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.OnlinePlus +{ + public class OnlinePlusAccount + { + + public string Name { get; set; } + public string PhoneNumber { get; set; } + public string email { get; set; } + public string Title { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusOrder.cs b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusOrder.cs new file mode 100644 index 0000000..94c4f27 --- /dev/null +++ b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusOrder.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.OnlinePlus +{ + public class OnlinePlusOrder + { + public bool IsSymbolCautionAgreement { get; set; } + public bool CautionAgreementSelected { get; set; } + public bool IsSymbolSepahAgreement { get; set; } + public bool SepahAgreementSelected { get; set; } + public int orderCount { get; set; } + public int orderPrice { get; set; } + public int FinancialProviderId { get; set; } + public string minimumQuantity { get; set; } + public int maxShow { get; set; } + public int orderId { get; set; } + public string isin { get; set; } + public int orderSide { get; set; } + public int orderValidity { get; set; } + public object orderValiditydate { get; set; } + public bool shortSellIsEnabled { get; set; } + public int shortSellIncentivePercent { get; set; } + + public string Cookies { get; set; } + public string Rand { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusOrderResult.cs b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusOrderResult.cs new file mode 100644 index 0000000..c29edc4 --- /dev/null +++ b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusOrderResult.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Media; +using MD.PersianDateTime.Standard; + +namespace WolfOfWallStreet.Models.OnlinePlus +{ + public class OnlinePlusOrderResult + { + public bool IsSuccessfull { get; set; } + public string MessageDesc { get; set; } + public object MessageCode { get; set; } + public object Data { get; set; } + public int Version { get; set; } + public DateTime GetDateTime { get; set; } + + public string GetDateTimeStr + { + get + { + PersianDateTime dateTime = new PersianDateTime(GetDateTime); + return dateTime.ToString("hh:mm:ss:fff"); + } + } + + public string IsSuccessStr + { + get + { + if (IsSuccessfull) + return "بلی"; + return "خیر"; + } + } + + public Brush StatusColor + { + get + { + if (IsSuccessfull) + return Brushes.ForestGreen; + else + return Brushes.OrangeRed; + } + } + } + +} diff --git a/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusRoot.cs b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusRoot.cs new file mode 100644 index 0000000..d52123c --- /dev/null +++ b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusRoot.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models.OnlinePlus +{ + public class OnlinePlusRoot + { + + public bool IsSuccessfull { get; set; } + public object MessageDesc { get; set; } + public object MessageCode { get; set; } + public T Data { get; set; } + public int Version { get; set; } + } +} diff --git a/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusSymbol.cs b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusSymbol.cs new file mode 100644 index 0000000..99475b0 --- /dev/null +++ b/WolfOfWallStreet/Models/OnlinePlus/OnlinePlusSymbol.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace WolfOfWallStreet.Models.OnlinePlus +{ + + public class OnlinePlusSymbol + { + public OnlinePlusSymbolInfo symbolinfo { get; set; } + public OnlinePlusSymbolQueue symbolqueue { get; set; } + public int Quantity { get; set; } + } + public class OnlinePlusSymbolInfo + { + public bool isFuture { get; set; } + public string nc { get; set; } + public int ltp { get; set; } + public int cp { get; set; } + public int ht { get; set; } + public int lt { get; set; } + public int st { get; set; } + public int gs { get; set; } + public int pcp { get; set; } + public string gc { get; set; } + public int nst { get; set; } + public int nt { get; set; } + public long tv { get; set; } + public string ltd { get; set; } + public int mxp { get; set; } + public int minprod { get; set; } + public double pv { get; set; } + public int vs { get; set; } + public int hp { get; set; } + public int lp { get; set; } + public int rp { get; set; } + public int bv { get; set; } + public string est { get; set; } + public int cp12 { get; set; } + public string ect { get; set; } + public double opts { get; set; } + public int mp { get; set; } + public object mt { get; set; } + public int cpv { get; set; } + public double cpvp { get; set; } + public int lpv { get; set; } + public double lpvp { get; set; } + public int th { get; set; } + public int tl { get; set; } + public bool iscu { get; set; } + public bool isagsp { get; set; } + public string ic { get; set; } + public bool iso { get; set; } + } + + public class OnlinePlusSymbolValue + { + public int BestBuyPrice { get; set; } + public int BestSellPrice { get; set; } + public int BestSellQuantity { get; set; } + public int BestBuyQuantity { get; set; } + public int NoBestBuy { get; set; } + public int NoBestSell { get; set; } + public string NSCCode { get; set; } + public int Place { get; set; } + } + + public class OnlinePlusSymbolQueue + { + public List Value { get; set; } + + public OnlinePlusSymbolValue FValue + { + get { return Value.First(); } + } + } +} diff --git a/WolfOfWallStreet/Models/Stock.cs b/WolfOfWallStreet/Models/Stock.cs new file mode 100644 index 0000000..00589d4 --- /dev/null +++ b/WolfOfWallStreet/Models/Stock.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models +{ + public static class Stock + { + public static int PoonsadHezari { get; set; } = 6000000; + public static int YekMelioni { get; set; } = 10000000; + public static int YekONimMelioni { get; set; } = 15000000; + public static int DoMelioni { get; set; } = 20000000; + public static int DoONimMelioni { get; set; } = 25000000; + public static int SeMelioni { get; set; } = 30000000; + } +} diff --git a/WolfOfWallStreet/Models/Symbol.cs b/WolfOfWallStreet/Models/Symbol.cs new file mode 100644 index 0000000..f0461b3 --- /dev/null +++ b/WolfOfWallStreet/Models/Symbol.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WolfOfWallStreet.Models +{ + public class Symbol + { + public string SymbolName { get; set; } + public string symbolISIN { get; set; } + public int totalNumberOfTrades { get; set; } + public double totalTradeValue { get; set; } + public double firstTradedPrice { get; set; } + public string tradeDate { get; set; } + public string marketUnit { get; set; } + public double basisVolume { get; set; } + public double eps { get; set; } + public double pe { get; set; } + public double e30 { get; set; } + public int lastTradedPrice { get; set; } + public DateTime tradeDateTime { get; set; } + public object cancelNav { get; set; } + public string cancelNavDate { get; set; } + public string fYear { get; set; } + public double floatPercent { get; set; } + public double volume90Avg { get; set; } + public int maxPercentChange { get; set; } + public double gpe { get; set; } + public int closingPrice { get; set; } + public double highPrice { get; set; } + public double lowPrice { get; set; } + + } +} diff --git a/WolfOfWallStreet/Properties/Settings.Designer.cs b/WolfOfWallStreet/Properties/Settings.Designer.cs new file mode 100644 index 0000000..203cdea --- /dev/null +++ b/WolfOfWallStreet/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WolfOfWallStreet.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Symbols { + get { + return ((string)(this["Symbols"])); + } + set { + this["Symbols"] = value; + } + } + } +} diff --git a/WolfOfWallStreet/Properties/Settings.settings b/WolfOfWallStreet/Properties/Settings.settings new file mode 100644 index 0000000..1882d62 --- /dev/null +++ b/WolfOfWallStreet/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/WolfOfWallStreet/Resources/Fonts/IranSansBlack.ttf b/WolfOfWallStreet/Resources/Fonts/IranSansBlack.ttf new file mode 100644 index 0000000..5fb4340 Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/IranSansBlack.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/IranSansBold.ttf b/WolfOfWallStreet/Resources/Fonts/IranSansBold.ttf new file mode 100644 index 0000000..dfa64eb Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/IranSansBold.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/IranSansMedium.ttf b/WolfOfWallStreet/Resources/Fonts/IranSansMedium.ttf new file mode 100644 index 0000000..403019f Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/IranSansMedium.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/IranSansULight.ttf b/WolfOfWallStreet/Resources/Fonts/IranSansULight.ttf new file mode 100644 index 0000000..8f06c90 Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/IranSansULight.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/Shabnam-Bold.ttf b/WolfOfWallStreet/Resources/Fonts/Shabnam-Bold.ttf new file mode 100644 index 0000000..dbae563 Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/Shabnam-Bold.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/Shabnam.ttf b/WolfOfWallStreet/Resources/Fonts/Shabnam.ttf new file mode 100644 index 0000000..7861e3f Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/Shabnam.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/fa-regular-400.ttf b/WolfOfWallStreet/Resources/Fonts/fa-regular-400.ttf new file mode 100644 index 0000000..9946893 Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/fa-regular-400.ttf differ diff --git a/WolfOfWallStreet/Resources/Fonts/materialdesignicons-webfont.ttf b/WolfOfWallStreet/Resources/Fonts/materialdesignicons-webfont.ttf new file mode 100644 index 0000000..9cc8db1 Binary files /dev/null and b/WolfOfWallStreet/Resources/Fonts/materialdesignicons-webfont.ttf differ diff --git a/WolfOfWallStreet/Services/Contracts/IBrokerService.cs b/WolfOfWallStreet/Services/Contracts/IBrokerService.cs new file mode 100644 index 0000000..0bb55d5 --- /dev/null +++ b/WolfOfWallStreet/Services/Contracts/IBrokerService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace WolfOfWallStreet.Services.Contracts +{ + public interface IBrokerService + { + Task SendOrder(); + Task GetSymbolInfo(string isin); + Task GetSymbolOrderBase(string isin); + } +} diff --git a/WolfOfWallStreet/Services/Contracts/IEasyTraderService.cs b/WolfOfWallStreet/Services/Contracts/IEasyTraderService.cs new file mode 100644 index 0000000..7eb9862 --- /dev/null +++ b/WolfOfWallStreet/Services/Contracts/IEasyTraderService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.EasyTrader; + +namespace WolfOfWallStreet.Services.Contracts +{ + public interface IEasyTraderService + { + Task SendOrder(string auth, EasyTraderDraft draft); + Task GetSymbolInfo(string auth,string isin); + Task GetSymbolOrderBase(string auth, Symbol symbol, long stockPrice); + } +} diff --git a/WolfOfWallStreet/Services/Contracts/IMofidOnlineService.cs b/WolfOfWallStreet/Services/Contracts/IMofidOnlineService.cs new file mode 100644 index 0000000..21a5f38 --- /dev/null +++ b/WolfOfWallStreet/Services/Contracts/IMofidOnlineService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.MofidOnline; + +namespace WolfOfWallStreet.Services.Contracts +{ + public interface IMofidOnlineService + { + Task SendOrder(MofidOnlineOrder draft); + Task GetSymbolOrderBase(Symbol symbol, long stockPrice); + } +} diff --git a/WolfOfWallStreet/Services/Contracts/IOnlinePlusService.cs b/WolfOfWallStreet/Services/Contracts/IOnlinePlusService.cs new file mode 100644 index 0000000..15125d3 --- /dev/null +++ b/WolfOfWallStreet/Services/Contracts/IOnlinePlusService.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.OnlinePlus; + +namespace WolfOfWallStreet.Services.Contracts +{ + public interface IOnlinePlusService + { + Task SendOrder(OnlinePlusOrder draft); + Task GetSymbolOrderBase(Symbol symbol, long stockPrice); + Task GetAccounTask(string cookiesOrAuth); + } +} diff --git a/WolfOfWallStreet/Services/EasyTraderService.cs b/WolfOfWallStreet/Services/EasyTraderService.cs new file mode 100644 index 0000000..c85ca49 --- /dev/null +++ b/WolfOfWallStreet/Services/EasyTraderService.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using RestSharp; +using WolfOfWallStreet.Extensions; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.EasyTrader; +using WolfOfWallStreet.Services.Contracts; +namespace WolfOfWallStreet.Services +{ + public class EasyTraderService : IEasyTraderService + { + private int server = 11; + public async Task SendOrder(string auth, EasyTraderDraft draft) + { + RestClient loginClient = new RestClient(); + RestRequest draftRequest = + new RestRequest(new Uri($"https://api.cl3.mofid.dev/easy/api/OmsOrder"), Method.POST); + draftRequest.AddHeader("Accept", "application/json, text/plain, */*"); + draftRequest.AddHeader("Authorization", auth); + draftRequest.AddHeader("User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.173"); + draftRequest.AddHeader("Referer", "https://d.easytrader.emofid.com/"); + draftRequest.AddHeader("Content-Type", "application/json"); + draftRequest.AddJsonBody(new EasyTraderDraft + { + cautionAgreementSelected = false, + easySource = 1, + easyState = 7, + financeId = 1, + isin = draft.isin, + price = draft.price, + quantity = draft.quantity, + referenceKey = $"{StringExtensions.GenerateGuid(8)}-3ff5-{StringExtensions.GenerateGuid(4)}-99f4-{StringExtensions.GenerateGuid(8)}", + side = 0, + stockSymbol = draft.stockSymbol, + validityDateJalali = null, + validityType = 74 + }); + var res = loginClient.Execute(draftRequest,Method.POST); + if (res.IsSuccessful) + { + return res.Data; + } + + return null; + } + + public async Task GetSymbolInfo(string auth, string isin) + { + throw new NotImplementedException(); + } + + public async Task GetSymbolOrderBase(string auth, Symbol symbol, long stockPrice) + { + RestClient loginClient = new RestClient(); + RestRequest draftRequest = + new RestRequest(new Uri($"https://d{server}.emofid.com/easy/api/MarketData/GetSymbolDetailsData/{symbol.symbolISIN}/StockOrderData"), Method.GET); + draftRequest.AddHeader("Accept", "application/json, text/plain, */*"); + draftRequest.AddHeader("Authorization", auth); + draftRequest.AddHeader("User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.173"); + draftRequest.AddHeader("Referer", "https://d.easytrader.emofid.com/"); + draftRequest.AddHeader("Content-Type", "application/json"); + var res = await loginClient.ExecuteGetAsync(draftRequest); + if (res.IsSuccessful) + { + return new EasyTraderDraft + { + price = (int)res.Data.highAllowedPrice, + stockSymbol = symbol.SymbolName, + quantity = (int)(stockPrice / res.Data.highAllowedPrice) + 2, + isin = symbol.symbolISIN + }; + } + + return null; + } + } +} diff --git a/WolfOfWallStreet/Services/MofidOnlineService.cs b/WolfOfWallStreet/Services/MofidOnlineService.cs new file mode 100644 index 0000000..61deaf6 --- /dev/null +++ b/WolfOfWallStreet/Services/MofidOnlineService.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using RestSharp; +using WolfOfWallStreet.Extensions; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.MofidOnline; +using WolfOfWallStreet.Models.OnlinePlus; +using WolfOfWallStreet.Services.Contracts; + +namespace WolfOfWallStreet.Services +{ + public class MofidOnlineService : IMofidOnlineService + { + public async Task SendOrder(MofidOnlineOrder draft) + { + RestClient client = new RestClient(); + RestRequest request = new RestRequest(new Uri($"https://mofidonline.com/9/0/SiteCustomerHandler.ashx?lan=fa&.rand=2c70981681bb45138629b0f1b82be55d"), Method.POST); + request.AddHeader("authority", "mofidonline.com"); + request.AddHeader("method", "POST"); + request.AddHeader("path", $"/9/0/SiteCustomerHandler.ashx?lan=fa&.rand={StringExtensions.GenerateGuid(32)}"); + request.AddHeader("scheme", "https"); + request.AddHeader("Accept", "*/*"); + request.AddHeader("accept-encoding", "gzip, deflate, br"); + request.AddHeader("accept-language", "en-US,en;q=0.9"); + request.AddHeader("content-length", "170"); + request.AddHeader("origin", "https://mofidonline.com"); + request.AddHeader("referer", "https://mofidonline.com/Customer/AddOrder?cr=fbff775e469a4e4d8922e6cc0fe80215&lan=fa"); + request.AddHeader("sec-fetch-dest", "empty"); + request.AddHeader("sec-fetch-mode", "cors"); + request.AddHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8"); + request.AddHeader("sec-fetch-site", "same-origin"); + request.AddHeader("user-agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 OPR/69.0.3686.95"); + request.AddHeader("x-requested-with", "XMLHttpRequest"); + foreach (var str in draft.Cookies.Split(' ')) + { + var value = str.Split('=').Last(); + request.AddCookie(str.Split('=').First(), value.Substring(0, value.Length - 1)); + } + request.AddJsonBody(new MofidOnlineOrder + { + Mode = "buysell", + SymbolId = draft.SymbolId, + OrderPrice = draft.OrderPrice, + OrderType = "76", + OrderSide = "65", + OrderValidity = "74", + OrderValiditydate = "", + OrderTotalQuantity = draft.OrderTotalQuantity, + TriggerPrice = "", + MinimumQuantity = "", + MaxShown = "", + BourseCode = "", + isin = "", + pk = "TBRFinancialDataProvider", + OrderMode = "add", + orderid = "0", + OrderExpectedQuantity = "0", + ts = null, + cs = "", + ss = null, + SymbolNsc = draft.SymbolNsc, + SendSMS = false, + browserTime = DateTime.Now.ToString("T"), + IsSymbolInAgreement = "false", + AcceptedAgreement = false + }); + + var rest = client.Execute(request, Method.POST); + if (rest.StatusCode == HttpStatusCode.OK) + { + if (rest.Data != null) + return rest.Data; + else + { + var data = JsonConvert.DeserializeObject(rest.Content); + data.GetDateTime = DateTime.Now; + + return data; + } + } + + return null; + } + + public async Task GetSymbolOrderBase(Symbol symbol, long stockPrice) + { + RestClient client = new RestClient(); + RestRequest request = new RestRequest(new Uri($"https://core.tadbirrlc.com//StockFutureInfoHandler.ashx?%7B%22Type%22:%22getSymbolFullInfo%22,%22la%22:%22fa%22,%22nscCode%22:%22{symbol.symbolISIN}%22%7D&"), Method.GET); + request.AddHeader("authority", "core.tadbirrlc.com"); + request.AddHeader("method", "POST"); + request.AddHeader("path", $"//StockFutureInfoHandler.ashx"); + request.AddHeader("scheme", "https"); + request.AddHeader("Accept", "*/*"); + request.AddHeader("accept-encoding", "gzip, deflate, br"); + request.AddHeader("accept-language", "en-US,en;q=0.9"); + request.AddHeader("content-length", "170"); + request.AddHeader("origin", "https://mofidonline.com"); + request.AddHeader("referer", " https://mofidonline.com/Customer/AddOrder?cr=fbff775e469a4e4d8922e6cc0fe80215&lan=fa"); + request.AddHeader("sec-fetch-dest", "empty"); + request.AddHeader("sec-fetch-mode", "cors"); + request.AddHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8"); + request.AddHeader("sec-fetch-site", "same-origin"); + request.AddHeader("user-agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 OPR/69.0.3686.95"); + request.AddHeader("x-requested-with", "XMLHttpRequest"); + + var rest = client.Execute(request, Method.GET); + if (rest.StatusCode == HttpStatusCode.OK) + { + MofidOnlineSymbol data; + if (rest.Data != null) + data = rest.Data; + else + data = Newtonsoft.Json.JsonConvert.DeserializeObject(rest.Content); + data.Quantity = (int)(stockPrice / data.ht)+2; + return data; + } + + return null; + } + } +} diff --git a/WolfOfWallStreet/Services/OnlinePlusService.cs b/WolfOfWallStreet/Services/OnlinePlusService.cs new file mode 100644 index 0000000..b30da34 --- /dev/null +++ b/WolfOfWallStreet/Services/OnlinePlusService.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using RestSharp; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.OnlinePlus; +using WolfOfWallStreet.Services.Contracts; + +namespace WolfOfWallStreet.Services +{ + public class OnlinePlusService : IOnlinePlusService + { + public async Task SendOrder(OnlinePlusOrder draft) + { + RestClient client = new RestClient(); + RestRequest request = new RestRequest(new Uri($"https://api2.mofidonline.com/Web/V1/Order/Post"), Method.POST); + request.AddHeader("authority", "api2.mofidonline.com"); + request.AddHeader("method", "POST"); + request.AddHeader("path", "/Web/V1/Order/Post"); + request.AddHeader("scheme", "https"); + request.AddHeader("Accept", "*/*"); + request.AddHeader("accept-encoding", "gzip, deflate, br"); + request.AddHeader("accept-language", "en-US,en;q=0.9"); + request.AddHeader("content-length", "170"); + request.AddHeader("authorization", "BasicAuthentication 2cc57a2a-a099-4ce5-8cb8-ef139fabe973"); + request.AddHeader("origin", "https://onlineplus.mofidonline.com"); + request.AddHeader("referer", "https://onlineplus.mofidonline.com/Home/Default/page-1"); + request.AddHeader("sec-fetch-dest", "empty"); + request.AddHeader("sec-fetch-mode", "cors"); + request.AddHeader("content-type", "application/json"); + request.AddHeader("sec-fetch-site", "same-origin"); + request.AddHeader("user-agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 OPR/69.0.3686.95"); + request.AddHeader("x-requested-with", "XMLHttpRequest"); + request.AddJsonBody(new OnlinePlusOrder + { + CautionAgreementSelected = false, + FinancialProviderId = 1, + IsSymbolCautionAgreement = false, + IsSymbolSepahAgreement = false, + SepahAgreementSelected = false, + isin = draft.isin, + maxShow = 0, + minimumQuantity = "", + orderCount = draft.orderCount, + orderId = 0, + orderPrice = draft.orderPrice, + orderSide = 65, + orderValidity = 74, + orderValiditydate = null, + shortSellIncentivePercent = 0, + shortSellIsEnabled = false, + }); + + var rest = client.Execute(request,Method.POST); + if (rest.IsSuccessful) + { + var date = rest.Data; + date.GetDateTime = DateTime.Now; + if (date.MessageDesc!=null&&date.MessageDesc.Contains("محدودیت ارسال سفارش در ثانیه")) + return null; + return date; + } + + return null; + + } + + public async Task GetSymbolOrderBase(Symbol symbol, long stockPrice) + { + RestClient client = new RestClient(); + RestRequest request = new RestRequest(new Uri($"https://core.tadbirrlc.com//StockFutureInfoHandler.ashx?%7B%22Type%22:%22getLightSymbolInfoAndQueue%22,%22la%22:%22Fa%22,%22nscCode%22:%22{symbol.symbolISIN}%22%7D&jsoncallback="), Method.GET); + + request.AddHeader("authority", "onlineplus.mofidonline.com"); + request.AddHeader("method", "POST"); + request.AddHeader("path", "/Customer/SendOrder"); + request.AddHeader("scheme", "https"); + request.AddHeader("Accept", "*/*"); + request.AddHeader("accept-encoding", "gzip, deflate, br"); + request.AddHeader("accept-language", "en-US,en;q=0.9"); + request.AddHeader("content-length", "170"); + request.AddHeader("origin", "https://onlineplus.mofidonline.com"); + request.AddHeader("referer", "https://onlineplus.mofidonline.com/Home/Default/page-1"); + request.AddHeader("sec-fetch-dest", "empty"); + request.AddHeader("sec-fetch-mode", "cors"); + request.AddHeader("content-type", "application/json"); + request.AddHeader("sec-fetch-site", "same-origin"); + request.AddHeader("user-agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 OPR/69.0.3686.95"); + request.AddHeader("x-requested-with", "XMLHttpRequest"); + + var res = client.Execute(request, Method.GET); + if (res.StatusCode == HttpStatusCode.OK) + { + var data = Newtonsoft.Json.JsonConvert.DeserializeObject(res.Content); + data.Quantity = (int)(stockPrice / data.symbolinfo.ht); + return data; + } + + return null; + } + + public async Task GetAccounTask(string cookiesOrAuth) + { + RestClient client = new RestClient(); + RestRequest request = new RestRequest(new Uri($"https://www.mofidonline.com/Handlers/GetAccountRemain.ashx"), Method.POST); + request.AddHeader("authority", "www.mofidonline.com"); + request.AddHeader("method", "GET"); + request.AddHeader("path", "/Handlers/GetAccountRemain.ashx"); + request.AddHeader("scheme", "https"); + request.AddHeader("Accept", "*/*"); + request.AddHeader("accept-encoding", "gzip, deflate, br"); + request.AddHeader("accept-language", "en-US,en;q=0.9"); + request.AddHeader("referer", "https://www.mofidonline.com/Home/userprofile"); + request.AddHeader("sec-fetch-dest", "empty"); + request.AddHeader("sec-fetch-mode", "cors"); + request.AddHeader("content-type", "application/json"); + request.AddHeader("sec-fetch-site", "same-origin"); + request.AddHeader("user-agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 OPR/69.0.3686.95"); + request.AddHeader("x-requested-with", "XMLHttpRequest"); + foreach (var str in cookiesOrAuth.Split(' ')) + { + var value = str.Split('=').Last(); + request.AddCookie(str.Split('=').First(), value.Substring(0, value.Length - 1)); + } + + var rest = client.Execute>(request, Method.POST); + if (rest.IsSuccessful) + { + var date = rest.Data.Data; + return date; + } + + return null; + } + } +} diff --git a/WolfOfWallStreet/Services/SettingsServices.cs b/WolfOfWallStreet/Services/SettingsServices.cs new file mode 100644 index 0000000..d55d153 --- /dev/null +++ b/WolfOfWallStreet/Services/SettingsServices.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Properties; + +namespace WolfOfWallStreet.Services +{ + public class SettingsServices + { + public SettingsServices() + { + List Symbols = new List(); + try + { + Symbols = Newtonsoft.Json.JsonConvert.DeserializeObject>(Settings.Default.Symbols); + if(Symbols==null) + Symbols = new List(); + + } + catch (Exception e) + { + Symbols = new List(); + } + + if (Symbols.Count == 0) + { + Symbols.Add(new Symbol + { + SymbolName = "سیتا", + symbolISIN = "IRO1SITA0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "آریا", + symbolISIN = "IRO3APOZ0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "پیزد", + symbolISIN = "IRO3YZTZ0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "آبادا", + symbolISIN = "IRO1NBAB0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "شتران", + symbolISIN = "IRO1PTEH0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "های وب", + symbolISIN = "IRO1HWEB0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "خگستر", + symbolISIN = "IRO1GOST0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "شگویا", + symbolISIN = "IRO3TPEZ0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "ولپارس", + symbolISIN = "IRO1LPRS0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "ونیکی", + symbolISIN = "IRO1NIKI0001" + }); + Symbols.Add(new Symbol + { + SymbolName = "شستا", + symbolISIN = "IRO1TAMN0001" + }); + Settings.Default.Symbols = Newtonsoft.Json.JsonConvert.SerializeObject(Symbols); + Properties.Settings.Default.Save(); + } + } + public List GetSymbols() + { + try + { + + var symbols = Newtonsoft.Json.JsonConvert.DeserializeObject>(Settings.Default.Symbols); + return symbols; + } + catch (Exception e) + { + return new List(); + } + } + + public void AddSymbol(Symbol symbol) + { + try + { + + var symbols = Newtonsoft.Json.JsonConvert.DeserializeObject>(Settings.Default.Symbols); + symbols.Add(symbol); + Settings.Default.Symbols = Newtonsoft.Json.JsonConvert.SerializeObject(symbols); + Properties.Settings.Default.Save(); + } + catch (Exception e) + { + var symbols = new List(); + symbols.Add(symbol); + Settings.Default.Symbols = Newtonsoft.Json.JsonConvert.SerializeObject(symbols); + Properties.Settings.Default.Save(); + } + + } + + public void RemoveSymbol(Symbol symbol) + { + try + { + + var symbols = Newtonsoft.Json.JsonConvert.DeserializeObject>(Settings.Default.Symbols); + symbols.Remove(symbols.FirstOrDefault(s=>s.symbolISIN==symbol.symbolISIN)); + Settings.Default.Symbols = Newtonsoft.Json.JsonConvert.SerializeObject(symbols); + Properties.Settings.Default.Save(); + } + catch (Exception e) + { + + } + } + } +} diff --git a/WolfOfWallStreet/ViewModels/EasyTraderControllerViewModel.cs b/WolfOfWallStreet/ViewModels/EasyTraderControllerViewModel.cs new file mode 100644 index 0000000..cea24c9 --- /dev/null +++ b/WolfOfWallStreet/ViewModels/EasyTraderControllerViewModel.cs @@ -0,0 +1,136 @@ +using Prism.Commands; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.EasyTrader; +using WolfOfWallStreet.Properties; +using WolfOfWallStreet.Services; +using WolfOfWallStreet.Services.Contracts; + +namespace WolfOfWallStreet.ViewModels +{ + public class EasyTraderControllerViewModel : ViewModelBase + { + private readonly SettingsServices _settingsServices; + private readonly IEasyTraderService _easyTraderService; + private EasyTraderDraft easyTraderDraft; + public EasyTraderDraft EasyTraderDraft + { + get { return easyTraderDraft; } + set { SetProperty(ref easyTraderDraft, value); } + } + + private string auth; + public string Auth + { + get { return auth; } + set { SetProperty(ref auth, value , nameof(Auth)); } + } + private string email; + public string Email + { + get { return email; } + set { SetProperty(ref email, value, nameof(Email)); } + } + private string phoneNumber; + public string PhoneNumber + { + get { return phoneNumber; } + set { SetProperty(ref phoneNumber, value, nameof(PhoneNumber)); } + } + + public bool Ordered { get; set; } = true; + private int server; + public int Server + { + get { return server; } + set { SetProperty(ref server, value); } + } + + public ObservableCollection Symbols { get; set; } = new ObservableCollection(); + public ICommand SelectSymbolCommand { get; set; } + public ICommand SendOrderCommand { get; set; } + public ICommand StopOrderCommand { get; set; } + public ICommand ClearOrdersCommand { get; set; } + public ObservableCollection Results { get; set; }=new ObservableCollection(); + + public EasyTraderControllerViewModel(SettingsServices settingsServices , IEasyTraderService easyTraderService) + { + _settingsServices = settingsServices; + _easyTraderService = easyTraderService; + _settingsServices.GetSymbols().ForEach(s => Symbols.Add(s)); + + } + + public override void InitialCommand() + { + base.InitialCommand(); + SelectSymbolCommand= new DelegateCommand(async symbol => + { + EasyTraderDraft = await _easyTraderService.GetSymbolOrderBase(Auth, symbol, 11000000); + }); + SendOrderCommand = new DelegateCommand(async () => + { + Ordered = true; + for (int i = 0; i < 5; i++) + { + Thread thread = new Thread(SendOrder); + thread.Start(); + } + }); + StopOrderCommand = new DelegateCommand(() => { Ordered = false; }); + ClearOrdersCommand = new DelegateCommand(() => { Results.Clear(); }); + } + + async void SendOrder() + { + + while (Ordered) + { + var res = await _easyTraderService.SendOrder(Auth, EasyTraderDraft); + Application.Current.Dispatcher.Invoke(() => Results.Add(res)); + } + } + + protected override bool SetProperty(ref T storage, T value, string propertyName = null) + { + bool flag = base.SetProperty(ref storage, value, propertyName); + if (propertyName == nameof(Auth)) + { + DecodeJwt(); + } + + return flag; + } + + private void DecodeJwt() + { + try + { + if (!string.IsNullOrEmpty(auth)) + { + var stream = auth.Replace("Bearer","").Trim(); + /*var handler = new JwtSecurityTokenHandler();var + jsonToken = handler.ReadToken(stream); + var tokenS = handler.ReadToken(stream) as JwtSecurityToken;*/ + var token = new System.IdentityModel.Tokens.Jwt.JwtSecurityToken(stream); + Email = token.Claims.FirstOrDefault(c => c.Type == "email")?.Value; + PhoneNumber = token.Claims.FirstOrDefault(c => c.Type == "phone_number")?.Value; + + } + } + catch (Exception e) + { + Console.WriteLine(e); + } + } + } +} diff --git a/WolfOfWallStreet/ViewModels/MainPageViewModel.cs b/WolfOfWallStreet/ViewModels/MainPageViewModel.cs new file mode 100644 index 0000000..a5a1869 --- /dev/null +++ b/WolfOfWallStreet/ViewModels/MainPageViewModel.cs @@ -0,0 +1,26 @@ +using Prism.Commands; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using RestSharp; +using WolfOfWallStreet.Extensions; +using WolfOfWallStreet.Models; +using MessageBox = HandyControl.Controls.MessageBox; + +namespace WolfOfWallStreet.ViewModels +{ + public class MainPageViewModel : ViewModelBase + { + public MainPageViewModel() + { + } + + + } +} diff --git a/WolfOfWallStreet/ViewModels/MainWindowViewModel.cs b/WolfOfWallStreet/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..fe53e91 --- /dev/null +++ b/WolfOfWallStreet/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,14 @@ +using Prism.Mvvm; +using Prism.Regions; +using WolfOfWallStreet.Views; + +namespace WolfOfWallStreet.ViewModels +{ + public class MainWindowViewModel : ViewModelBase + { + public MainWindowViewModel(IRegionManager manager):base(manager) + { + RegionManager.RegisterViewWithRegion("ContentRegion", typeof(MainPage)); + } + } +} diff --git a/WolfOfWallStreet/ViewModels/MofidOnlineControllerViewModel.cs b/WolfOfWallStreet/ViewModels/MofidOnlineControllerViewModel.cs new file mode 100644 index 0000000..416a15d --- /dev/null +++ b/WolfOfWallStreet/ViewModels/MofidOnlineControllerViewModel.cs @@ -0,0 +1,97 @@ +using Prism.Commands; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.MofidOnline; +using WolfOfWallStreet.Models.OnlinePlus; +using WolfOfWallStreet.Services; +using WolfOfWallStreet.Services.Contracts; +using MessageBox = HandyControl.Controls.MessageBox; + +namespace WolfOfWallStreet.ViewModels +{ + public class MofidOnlineControllerViewModel : ViewModelBase + { + private readonly SettingsServices _settingsServices; + private readonly IMofidOnlineService _mofidOnlineService; + public MofidOnlineOrder MoOrder { get; set; } = new MofidOnlineOrder(); + public bool Ordered = true; + public ICommand SendOrderCommand { get; set; } + public ICommand SelectSymbolCommand { get; set; } + public ICommand StopOrderCommand { get; set; } + public ICommand ClearOrdersCommand { get; set; } + public int Stock { get; set; } + + private MofidOnlineSymbol _mofidOnlineSymbol; + public MofidOnlineSymbol MofidOnlineSymbol + { + get { return _mofidOnlineSymbol; } + set { SetProperty(ref _mofidOnlineSymbol, value); } + } + + public ObservableCollection Symbols { get; set; } = new ObservableCollection(); + public ObservableCollection OrderResults { get; set; } = new ObservableCollection(); + public MofidOnlineControllerViewModel(SettingsServices settingsServices , IMofidOnlineService mofidOnlineService) + { + _settingsServices = settingsServices; + _mofidOnlineService = mofidOnlineService; + _settingsServices.GetSymbols().ForEach(s=>Symbols.Add(s)); + MoOrder.Cookies = + "_ga=GA1.2.425920926.1593494313; _gid=GA1.2.467195288.1596362017; ASP.NET_SessionId=umwh11qs2uqamsejqzylsow5; crisp-client%2Fsession%2Fe95056ad-2681-452d-976d-0c2a304165c9=session_1cd28bbf-3aa4-4c96-b069-313739c186a0; Token=5d18d4ca-6e0a-4821-8e43-03347dfd2aa2; .ASPXAUTH=D35126B56A8F94324B69FC0A9389F5B4CC6DDF28F8CDAFC4903D8962BFC57CA15A98712B461428FEBD51D7729EA10C77A3B9406EA2EAE241DCDE583BF5C09A3AD8F1FF4AC8963E3BA764B1FED54C8D1FB8B70803F5D9B1507B2313D521AF6A72E657F74A3E707E563CAF60C20BB47017B5A5BD7A012F96C2B4BE5ADC8D51705A7888E255F90EE7BDDCACC953CD8C7DA09A1C2CDD; LS6_https_1603_https%3A%2F%2Fpush2v7.etadbir.com%2F=|485_TadbirConnection|; LS6_https_1603_TadbirConnection=|485|; LS6_https_1603_485_TadbirConnection=1596619228044|C|LS6__mofidonline_com_485_TadbirConnection|mofidonline.com"; + + } + + public override void InitialCommand() + { + base.InitialCommand(); + SelectSymbolCommand = new DelegateCommand(async (symbol) => + { + MofidOnlineSymbol = await _mofidOnlineService.GetSymbolOrderBase(symbol, Stock); + }); + SendOrderCommand = new DelegateCommand(async () => + { + Ordered = true; + for (int i = 0; i < 7; i++) + { + Thread thr = new Thread(SendOrder); + thr.Start(); + } + }); + StopOrderCommand = new DelegateCommand(() => Ordered=false); + ClearOrdersCommand = new DelegateCommand(()=>OrderResults.Clear()); + } + + async void SendOrder() + { + while (Ordered) + { + try + { + if (string.IsNullOrEmpty(MoOrder.Cookies)) + throw new Exception("کوکی های درخواست را وارد کنید"); + MoOrder.OrderPrice = MofidOnlineSymbol.ht.ToString(); + MoOrder.OrderTotalQuantity = MofidOnlineSymbol.Quantity.ToString(); + MoOrder.SymbolNsc = MofidOnlineSymbol.nc; + MoOrder.SymbolId = ""; + MofidOnlineOrderResult res; + res = await _mofidOnlineService.SendOrder(MoOrder); + if (res != null) + { + if(res.Value.Contains("محدودیت ارسال سفارش در ثانیه") == false) + Application.Current.Dispatcher.Invoke(() => OrderResults.Add(res)); + } + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + } + } + } +} diff --git a/WolfOfWallStreet/ViewModels/OnlinePlusControllerViewModel.cs b/WolfOfWallStreet/ViewModels/OnlinePlusControllerViewModel.cs new file mode 100644 index 0000000..165ce5d --- /dev/null +++ b/WolfOfWallStreet/ViewModels/OnlinePlusControllerViewModel.cs @@ -0,0 +1,114 @@ +using Prism.Commands; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Models.OnlinePlus; +using WolfOfWallStreet.Services; +using WolfOfWallStreet.Services.Contracts; +using MessageBox = HandyControl.Controls.MessageBox; + +namespace WolfOfWallStreet.ViewModels +{ + public class OnlinePlusControllerViewModel : ViewModelBase + { + private readonly IOnlinePlusService _onlinePlusService; + private readonly SettingsServices _settingsServices; + public int Stock { get; set; } + public OnlinePlusOrder OpOrder { get; set; } = new OnlinePlusOrder(); + public bool Ordered = true; + public ICommand SendOrderCommand { get; set; } + public ICommand SelectSymbolCommand { get; set; } + public ICommand StopOrderCommand { get; set; } + public ICommand ClearOrdersCommand { get; set; } + + private OnlinePlusSymbol _onlinePlusSymbol; + public OnlinePlusSymbol OnlinePlusSymbol + { + get { return _onlinePlusSymbol; } + set { SetProperty(ref _onlinePlusSymbol, value); } + } + private string _cookies; + public string Cookies + { + get { return _cookies; } + set { SetProperty(ref _cookies, value , nameof(Cookies)); } + } + + private OnlinePlusAccount _account; + public OnlinePlusAccount Account + { + get { return _account; } + set { SetProperty(ref _account, value, nameof(Account)); } + } + + public ObservableCollection Symbols { get; set; } = new ObservableCollection(); + public ObservableCollection PlusOrderResults { get; set; } = new ObservableCollection(); + public OnlinePlusControllerViewModel(IOnlinePlusService onlinePlusService, SettingsServices settingsServices) + { + _onlinePlusService = onlinePlusService; + _settingsServices = settingsServices; + _settingsServices.GetSymbols().ForEach(s => Symbols.Add(s)); + + } + + public override void InitialCommand() + { + base.InitialCommand(); + SendOrderCommand = new DelegateCommand(async () => + { + Ordered = true; + for (int i = 0; i < 7; i++) + { + Thread thr = new Thread(Order); + thr.Start(); + } + }); + StopOrderCommand = new DelegateCommand(async () => { Ordered = false; }); + SelectSymbolCommand = new DelegateCommand(async (symbol) => + { + OnlinePlusSymbol = await _onlinePlusService.GetSymbolOrderBase(symbol, Stock); + }); + ClearOrdersCommand = new DelegateCommand(()=>PlusOrderResults.Clear()); + } + + async void Order() + { + while (Ordered) + { + try + { + OpOrder.Cookies = Cookies; + if (string.IsNullOrEmpty(OpOrder.Cookies)) + throw new Exception("کوکی های درخواست را وارد کنید"); + OpOrder.orderCount = OnlinePlusSymbol.Quantity; + OpOrder.orderPrice = OnlinePlusSymbol.symbolinfo.ht; + OpOrder.isin = OnlinePlusSymbol.symbolinfo.nc; + OnlinePlusOrderResult res; + res = await _onlinePlusService.SendOrder(OpOrder); + if(res!=null) + Application.Current.Dispatcher.Invoke(() => PlusOrderResults.Add(res)); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + Ordered = false; + } + } + } + + protected override bool SetProperty(ref T storage, T value, string propertyName = null) + { + var flag = base.SetProperty(ref storage, value, propertyName); + if(propertyName==nameof(Cookies)) + Account = _onlinePlusService.GetAccounTask(Cookies).Result; + return flag; + } + } +} diff --git a/WolfOfWallStreet/ViewModels/SymbolsControllerViewModel.cs b/WolfOfWallStreet/ViewModels/SymbolsControllerViewModel.cs new file mode 100644 index 0000000..3911a25 --- /dev/null +++ b/WolfOfWallStreet/ViewModels/SymbolsControllerViewModel.cs @@ -0,0 +1,54 @@ +using Prism.Commands; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows.Input; +using HandyControl.Controls; +using WolfOfWallStreet.Models; +using WolfOfWallStreet.Services; + +namespace WolfOfWallStreet.ViewModels +{ + public class SymbolsControllerViewModel : ViewModelBase + { + private readonly SettingsServices _settingsServices; + + public ObservableCollection Symbols { get; set; } = new ObservableCollection(); + public Symbol Symbol { get; set; } = new Symbol(); + public ICommand AddSymbolCommand { get; set; } + public ICommand RemoveSymbolCommand { get; set; } + public SymbolsControllerViewModel(SettingsServices settingsServices) + { + _settingsServices = settingsServices; + _settingsServices.GetSymbols().ForEach(s=>Symbols.Add(s)); + } + + public override void InitialCommand() + { + base.InitialCommand(); + AddSymbolCommand = new DelegateCommand((() => + { + try + { + + if (string.IsNullOrEmpty(Symbol.symbolISIN)) + throw new Exception("لطفا isin را وارد کنید"); + if (string.IsNullOrEmpty(Symbol.SymbolName)) + throw new Exception("لطفا نام سهم را وارد کنید"); + _settingsServices.AddSymbol(Symbol); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + })); + RemoveSymbolCommand = new DelegateCommand(symbol => + { + _settingsServices.RemoveSymbol(symbol); + Symbols.Remove(symbol); + }); + } + } +} diff --git a/WolfOfWallStreet/ViewModels/ViewModelBase.cs b/WolfOfWallStreet/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..eb3ebfe --- /dev/null +++ b/WolfOfWallStreet/ViewModels/ViewModelBase.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Prism.Mvvm; +using Prism.Regions; +using Prism.Services.Dialogs; + +namespace WolfOfWallStreet.ViewModels +{ + + public class ViewModelBase : BindableBase + { + private string _title; + public string Title + { + get { return _title; } + set { SetProperty(ref _title, value); } + } + public IRegionManager RegionManager { get; } + public ViewModelBase() + { + Initialize(); + InitialCommand(); + } + public ViewModelBase(IRegionManager regionManager) + { + RegionManager = regionManager; + Initialize(); + InitialCommand(); + } + public virtual void InitialCommand() + { + + } + + public virtual void Initialize() + { + + } + } +} diff --git a/WolfOfWallStreet/Views/Controllers/EasyTraderController.xaml b/WolfOfWallStreet/Views/Controllers/EasyTraderController.xaml new file mode 100644 index 0000000..741bdd3 --- /dev/null +++ b/WolfOfWallStreet/Views/Controllers/EasyTraderController.xaml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +