Добавьте файлы проекта.
This commit is contained in:
19
SvetoforVKBot/App_Start/RouteConfig.cs
Normal file
19
SvetoforVKBot/App_Start/RouteConfig.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace SvetoforVKBot
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
routes.MapRoute(
|
||||
name: "Default",
|
||||
url: "{controller}/{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
SvetoforVKBot/App_Start/WebApiConfig.cs
Normal file
28
SvetoforVKBot/App_Start/WebApiConfig.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace SvetoforVKBot.App_Start
|
||||
{
|
||||
public class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
|
||||
{
|
||||
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
|
||||
name: "DefaultApi",
|
||||
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
SvetoforVKBot/App_Start/WebConfiguration.cs
Normal file
76
SvetoforVKBot/App_Start/WebConfiguration.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace SvetoforVKBot.App_Start
|
||||
{
|
||||
public class WebConfiguration: System.Configuration.ConfigurationSection
|
||||
{
|
||||
[ConfigurationProperty("name", IsKey = true, IsRequired = true, DefaultValue = "Debug")]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)this["name"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["name"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("token", IsRequired = true, DefaultValue = "")]
|
||||
public string Token
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)this["token"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["token"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("secret", IsRequired = true, DefaultValue = "")]
|
||||
public string SecretKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)this["secret"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["secret"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("confirmation", IsRequired = true, DefaultValue = "")]
|
||||
public string Confirmation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)this["confirmation"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["confirmation"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("groupdialoglink", IsRequired = true, DefaultValue = "")]
|
||||
public string GroupDialogsLink
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)this["groupdialoglink"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["groupdialoglink"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4997
SvetoforVKBot/Content/bootstrap-grid.css
vendored
Normal file
4997
SvetoforVKBot/Content/bootstrap-grid.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
SvetoforVKBot/Content/bootstrap-grid.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-grid.css.map
Normal file
File diff suppressed because one or more lines are too long
7
SvetoforVKBot/Content/bootstrap-grid.min.css
vendored
Normal file
7
SvetoforVKBot/Content/bootstrap-grid.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
SvetoforVKBot/Content/bootstrap-grid.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-grid.min.css.map
Normal file
File diff suppressed because one or more lines are too long
4996
SvetoforVKBot/Content/bootstrap-grid.rtl.css
vendored
Normal file
4996
SvetoforVKBot/Content/bootstrap-grid.rtl.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
SvetoforVKBot/Content/bootstrap-grid.rtl.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-grid.rtl.css.map
Normal file
File diff suppressed because one or more lines are too long
7
SvetoforVKBot/Content/bootstrap-grid.rtl.min.css
vendored
Normal file
7
SvetoforVKBot/Content/bootstrap-grid.rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
SvetoforVKBot/Content/bootstrap-grid.rtl.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-grid.rtl.min.css.map
Normal file
File diff suppressed because one or more lines are too long
427
SvetoforVKBot/Content/bootstrap-reboot.css
vendored
Normal file
427
SvetoforVKBot/Content/bootstrap-reboot.css
vendored
Normal file
@@ -0,0 +1,427 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
:root {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--bs-body-font-family);
|
||||
font-size: var(--bs-body-font-size);
|
||||
font-weight: var(--bs-body-font-weight);
|
||||
line-height: var(--bs-body-line-height);
|
||||
color: var(--bs-body-color);
|
||||
text-align: var(--bs-body-text-align);
|
||||
background-color: var(--bs-body-bg);
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 1rem 0;
|
||||
color: inherit;
|
||||
background-color: currentColor;
|
||||
border: 0;
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
hr:not([size]) {
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
h6, h5, h4, h3, h2, h1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: calc(1.375rem + 1.5vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: calc(1.325rem + 0.9vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: calc(1.3rem + 0.6vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h3 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: calc(1.275rem + 0.3vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
abbr[title],
|
||||
abbr[data-bs-original-title] {
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
cursor: help;
|
||||
-webkit-text-decoration-skip-ink: none;
|
||||
text-decoration-skip-ink: none;
|
||||
}
|
||||
|
||||
address {
|
||||
margin-bottom: 1rem;
|
||||
font-style: normal;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul,
|
||||
dl {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
ol ol,
|
||||
ul ul,
|
||||
ol ul,
|
||||
ul ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-bottom: 0.5rem;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 0.2em;
|
||||
background-color: #fcf8e3;
|
||||
}
|
||||
|
||||
sub,
|
||||
sup {
|
||||
position: relative;
|
||||
font-size: 0.75em;
|
||||
line-height: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0d6efd;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
color: #0a58ca;
|
||||
}
|
||||
|
||||
a:not([href]):not([class]), a:not([href]):not([class]):hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
pre,
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 1em;
|
||||
direction: ltr /* rtl:ignore */;
|
||||
unicode-bidi: bidi-override;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
overflow: auto;
|
||||
font-size: 0.875em;
|
||||
}
|
||||
pre code {
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 0.875em;
|
||||
color: #d63384;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
a > code {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
kbd {
|
||||
padding: 0.2rem 0.4rem;
|
||||
font-size: 0.875em;
|
||||
color: #fff;
|
||||
background-color: #212529;
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
kbd kbd {
|
||||
padding: 0;
|
||||
font-size: 1em;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
img,
|
||||
svg {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
table {
|
||||
caption-side: bottom;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
caption {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
color: #6c757d;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: inherit;
|
||||
text-align: -webkit-match-parent;
|
||||
}
|
||||
|
||||
thead,
|
||||
tbody,
|
||||
tfoot,
|
||||
tr,
|
||||
td,
|
||||
th {
|
||||
border-color: inherit;
|
||||
border-style: solid;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
button:focus:not(:focus-visible) {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
input,
|
||||
button,
|
||||
select,
|
||||
optgroup,
|
||||
textarea {
|
||||
margin: 0;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
[role=button] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select {
|
||||
word-wrap: normal;
|
||||
}
|
||||
select:disabled {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
[list]::-webkit-calendar-picker-indicator {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button,
|
||||
[type=button],
|
||||
[type=reset],
|
||||
[type=submit] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
button:not(:disabled),
|
||||
[type=button]:not(:disabled),
|
||||
[type=reset]:not(:disabled),
|
||||
[type=submit]:not(:disabled) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
legend {
|
||||
float: left;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: calc(1.275rem + 0.3vw);
|
||||
line-height: inherit;
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
legend {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
legend + * {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
::-webkit-datetime-edit-fields-wrapper,
|
||||
::-webkit-datetime-edit-text,
|
||||
::-webkit-datetime-edit-minute,
|
||||
::-webkit-datetime-edit-hour-field,
|
||||
::-webkit-datetime-edit-day-field,
|
||||
::-webkit-datetime-edit-month-field,
|
||||
::-webkit-datetime-edit-year-field {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::-webkit-inner-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
[type=search] {
|
||||
outline-offset: -2px;
|
||||
-webkit-appearance: textfield;
|
||||
}
|
||||
|
||||
/* rtl:raw:
|
||||
[type="tel"],
|
||||
[type="url"],
|
||||
[type="email"],
|
||||
[type="number"] {
|
||||
direction: ltr;
|
||||
}
|
||||
*/
|
||||
::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
::-webkit-color-swatch-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::file-selector-button {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
font: inherit;
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
output {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=bootstrap-reboot.css.map */
|
||||
1
SvetoforVKBot/Content/bootstrap-reboot.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-reboot.css.map
Normal file
File diff suppressed because one or more lines are too long
8
SvetoforVKBot/Content/bootstrap-reboot.min.css
vendored
Normal file
8
SvetoforVKBot/Content/bootstrap-reboot.min.css
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}
|
||||
/*# sourceMappingURL=bootstrap-reboot.min.css.map */
|
||||
1
SvetoforVKBot/Content/bootstrap-reboot.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-reboot.min.css.map
Normal file
File diff suppressed because one or more lines are too long
424
SvetoforVKBot/Content/bootstrap-reboot.rtl.css
vendored
Normal file
424
SvetoforVKBot/Content/bootstrap-reboot.rtl.css
vendored
Normal file
@@ -0,0 +1,424 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
:root {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--bs-body-font-family);
|
||||
font-size: var(--bs-body-font-size);
|
||||
font-weight: var(--bs-body-font-weight);
|
||||
line-height: var(--bs-body-line-height);
|
||||
color: var(--bs-body-color);
|
||||
text-align: var(--bs-body-text-align);
|
||||
background-color: var(--bs-body-bg);
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 1rem 0;
|
||||
color: inherit;
|
||||
background-color: currentColor;
|
||||
border: 0;
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
hr:not([size]) {
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
h6, h5, h4, h3, h2, h1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: calc(1.375rem + 1.5vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: calc(1.325rem + 0.9vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: calc(1.3rem + 0.6vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h3 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: calc(1.275rem + 0.3vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
abbr[title],
|
||||
abbr[data-bs-original-title] {
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
cursor: help;
|
||||
-webkit-text-decoration-skip-ink: none;
|
||||
text-decoration-skip-ink: none;
|
||||
}
|
||||
|
||||
address {
|
||||
margin-bottom: 1rem;
|
||||
font-style: normal;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul {
|
||||
padding-right: 2rem;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul,
|
||||
dl {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
ol ol,
|
||||
ul ul,
|
||||
ol ul,
|
||||
ul ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-bottom: 0.5rem;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 0.2em;
|
||||
background-color: #fcf8e3;
|
||||
}
|
||||
|
||||
sub,
|
||||
sup {
|
||||
position: relative;
|
||||
font-size: 0.75em;
|
||||
line-height: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0d6efd;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
color: #0a58ca;
|
||||
}
|
||||
|
||||
a:not([href]):not([class]), a:not([href]):not([class]):hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
pre,
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 1em;
|
||||
direction: ltr ;
|
||||
unicode-bidi: bidi-override;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
overflow: auto;
|
||||
font-size: 0.875em;
|
||||
}
|
||||
pre code {
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 0.875em;
|
||||
color: #d63384;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
a > code {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
kbd {
|
||||
padding: 0.2rem 0.4rem;
|
||||
font-size: 0.875em;
|
||||
color: #fff;
|
||||
background-color: #212529;
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
kbd kbd {
|
||||
padding: 0;
|
||||
font-size: 1em;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
img,
|
||||
svg {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
table {
|
||||
caption-side: bottom;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
caption {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
color: #6c757d;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: inherit;
|
||||
text-align: -webkit-match-parent;
|
||||
}
|
||||
|
||||
thead,
|
||||
tbody,
|
||||
tfoot,
|
||||
tr,
|
||||
td,
|
||||
th {
|
||||
border-color: inherit;
|
||||
border-style: solid;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
button:focus:not(:focus-visible) {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
input,
|
||||
button,
|
||||
select,
|
||||
optgroup,
|
||||
textarea {
|
||||
margin: 0;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
[role=button] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select {
|
||||
word-wrap: normal;
|
||||
}
|
||||
select:disabled {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
[list]::-webkit-calendar-picker-indicator {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button,
|
||||
[type=button],
|
||||
[type=reset],
|
||||
[type=submit] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
button:not(:disabled),
|
||||
[type=button]:not(:disabled),
|
||||
[type=reset]:not(:disabled),
|
||||
[type=submit]:not(:disabled) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
legend {
|
||||
float: right;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: calc(1.275rem + 0.3vw);
|
||||
line-height: inherit;
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
legend {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
legend + * {
|
||||
clear: right;
|
||||
}
|
||||
|
||||
::-webkit-datetime-edit-fields-wrapper,
|
||||
::-webkit-datetime-edit-text,
|
||||
::-webkit-datetime-edit-minute,
|
||||
::-webkit-datetime-edit-hour-field,
|
||||
::-webkit-datetime-edit-day-field,
|
||||
::-webkit-datetime-edit-month-field,
|
||||
::-webkit-datetime-edit-year-field {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::-webkit-inner-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
[type=search] {
|
||||
outline-offset: -2px;
|
||||
-webkit-appearance: textfield;
|
||||
}
|
||||
|
||||
[type="tel"],
|
||||
[type="url"],
|
||||
[type="email"],
|
||||
[type="number"] {
|
||||
direction: ltr;
|
||||
}
|
||||
::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
::-webkit-color-swatch-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::file-selector-button {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
font: inherit;
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
output {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
/*# sourceMappingURL=bootstrap-reboot.rtl.css.map */
|
||||
1
SvetoforVKBot/Content/bootstrap-reboot.rtl.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-reboot.rtl.css.map
Normal file
File diff suppressed because one or more lines are too long
8
SvetoforVKBot/Content/bootstrap-reboot.rtl.min.css
vendored
Normal file
8
SvetoforVKBot/Content/bootstrap-reboot.rtl.min.css
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-right:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-right:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:right}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:right;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:right}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}[type=email],[type=number],[type=tel],[type=url]{direction:ltr}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}
|
||||
/*# sourceMappingURL=bootstrap-reboot.rtl.min.css.map */
|
||||
1
SvetoforVKBot/Content/bootstrap-reboot.rtl.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-reboot.rtl.min.css.map
Normal file
File diff suppressed because one or more lines are too long
4866
SvetoforVKBot/Content/bootstrap-utilities.css
vendored
Normal file
4866
SvetoforVKBot/Content/bootstrap-utilities.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
SvetoforVKBot/Content/bootstrap-utilities.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-utilities.css.map
Normal file
File diff suppressed because one or more lines are too long
7
SvetoforVKBot/Content/bootstrap-utilities.min.css
vendored
Normal file
7
SvetoforVKBot/Content/bootstrap-utilities.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
SvetoforVKBot/Content/bootstrap-utilities.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-utilities.min.css.map
Normal file
File diff suppressed because one or more lines are too long
4857
SvetoforVKBot/Content/bootstrap-utilities.rtl.css
vendored
Normal file
4857
SvetoforVKBot/Content/bootstrap-utilities.rtl.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
SvetoforVKBot/Content/bootstrap-utilities.rtl.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap-utilities.rtl.css.map
Normal file
File diff suppressed because one or more lines are too long
7
SvetoforVKBot/Content/bootstrap-utilities.rtl.min.css
vendored
Normal file
7
SvetoforVKBot/Content/bootstrap-utilities.rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
11221
SvetoforVKBot/Content/bootstrap.css
vendored
Normal file
11221
SvetoforVKBot/Content/bootstrap.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
SvetoforVKBot/Content/bootstrap.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap.css.map
Normal file
File diff suppressed because one or more lines are too long
7
SvetoforVKBot/Content/bootstrap.min.css
vendored
Normal file
7
SvetoforVKBot/Content/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
SvetoforVKBot/Content/bootstrap.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap.min.css.map
Normal file
File diff suppressed because one or more lines are too long
11197
SvetoforVKBot/Content/bootstrap.rtl.css
vendored
Normal file
11197
SvetoforVKBot/Content/bootstrap.rtl.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
SvetoforVKBot/Content/bootstrap.rtl.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap.rtl.css.map
Normal file
File diff suppressed because one or more lines are too long
7
SvetoforVKBot/Content/bootstrap.rtl.min.css
vendored
Normal file
7
SvetoforVKBot/Content/bootstrap.rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
SvetoforVKBot/Content/bootstrap.rtl.min.css.map
Normal file
1
SvetoforVKBot/Content/bootstrap.rtl.min.css.map
Normal file
File diff suppressed because one or more lines are too long
268
SvetoforVKBot/Controllers/ExportDataController.cs
Normal file
268
SvetoforVKBot/Controllers/ExportDataController.cs
Normal file
@@ -0,0 +1,268 @@
|
||||
using SvetoforVKBot.Models;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Web.Mvc;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model;
|
||||
using System.Security.Cryptography;
|
||||
using Newtonsoft.Json;
|
||||
using VkNet.Model.Attachments;
|
||||
using System.Linq;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.Sheets.v4;
|
||||
using Google.Apis.Sheets.v4.Data;
|
||||
using SvetoforVKBot.App_Start;
|
||||
using System.Configuration;
|
||||
using SvetoforVKBot.Data;
|
||||
|
||||
namespace SvetoforVKBot.Controllers
|
||||
{
|
||||
class GoogleApi : IDisposable
|
||||
{
|
||||
readonly string[] Scopes = { SheetsService.Scope.Spreadsheets };
|
||||
readonly string ApplicationName = "chatbot-vk-instagram";
|
||||
|
||||
//readonly string sheet = "Лист1";
|
||||
readonly string credential_file = "client_secret.json";
|
||||
SheetsService service;
|
||||
|
||||
public GoogleApi()
|
||||
{
|
||||
try
|
||||
{
|
||||
GoogleCredential credential;
|
||||
string filePath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + @"\" + credential_file;
|
||||
using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) //new FileStream(credential_file, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
credential = GoogleCredential.FromStream(stream)
|
||||
.CreateScoped(Scopes);
|
||||
}
|
||||
// Create Google Sheets API service.
|
||||
service = new SheetsService(new BaseClientService.Initializer()
|
||||
{
|
||||
HttpClientInitializer = credential,
|
||||
ApplicationName = ApplicationName,
|
||||
});
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
Console.WriteLine("Ошибка при работе с google sheets: {0}", ee.Message);
|
||||
}
|
||||
}
|
||||
public void AppendEntry(string range, List<IList<object>> rangesValues, string sheet)
|
||||
{
|
||||
var valueRange = new ValueRange();
|
||||
valueRange.Values = rangesValues;
|
||||
var appendRequest = service.Spreadsheets.Values.Append(valueRange, sheet, range);
|
||||
appendRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.USERENTERED;
|
||||
var appendReponse = appendRequest.Execute();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ExportDataController : Controller
|
||||
{
|
||||
readonly string SheetAllUsersId = "1jr68NfIrlz2bVsN-HZg0Kv2sSJ82J5G-EbtXl-YMK44";
|
||||
readonly string SheetConsultationsId = "1nWHvWufxDy6g2ZJtqd4K8MDM6Gh8OHWasRGXIyqbT2k";
|
||||
|
||||
private SvetoforVKBot.Data.SvetoforVKBotEntities db = new SvetoforVKBot.Data.SvetoforVKBotEntities();
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
db.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private const int SELFCHATID = 59111081;
|
||||
//GET: AllUsers
|
||||
public HttpStatusCodeResult AllUsers()
|
||||
{
|
||||
List<ChatId> ids = new List<ChatId>();
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
MessageEditParams editParams = new MessageEditParams();
|
||||
HttpStatusCodeResult httpResult = new HttpStatusCodeResult(200);
|
||||
|
||||
var client = new VkApi();
|
||||
List<string> phones;
|
||||
string agree;
|
||||
string reg;
|
||||
var phone = "";
|
||||
try
|
||||
{
|
||||
client.AuthorizeAsync(new ApiAuthParams
|
||||
{
|
||||
AccessToken = ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).Token
|
||||
});
|
||||
|
||||
#region Добавление в гугл таблицу
|
||||
|
||||
using (GoogleApi myApi = new GoogleApi())
|
||||
{
|
||||
List<IList<object>> rangeObj = new List<IList<object>>();
|
||||
|
||||
var users = db.Users.Where(usr => usr.export == 0).ToList();
|
||||
|
||||
foreach (var u in users)
|
||||
{
|
||||
phones = JsonConvert.DeserializeObject<List<string>>(u.phone);
|
||||
if (phones.Count > 0)
|
||||
phone = phones[0];
|
||||
else
|
||||
phone = "-";
|
||||
|
||||
if (u.reg == 1)
|
||||
reg = "Зарегистрирован";
|
||||
else
|
||||
reg = "Не зарегистрирован";
|
||||
|
||||
if (u.agree == 1)
|
||||
agree = "Есть";
|
||||
else
|
||||
agree = "Нет";
|
||||
|
||||
rangeObj.Add(new List<object>()
|
||||
{
|
||||
u.chatId.ToString(),
|
||||
u.firstName.ToString(),
|
||||
u.lastName.ToString(),
|
||||
u.fio.ToString(),
|
||||
reg,
|
||||
phone,
|
||||
u.birthday.ToShortDateString(),
|
||||
agree,
|
||||
});
|
||||
|
||||
var con = db.Users.Where(el => el.chatId == u.chatId).Single<Users>();
|
||||
con.export = 1;
|
||||
db.SaveChanges();
|
||||
|
||||
Thread.Sleep(30);
|
||||
}
|
||||
|
||||
//Добавление в таблицу данных объектов
|
||||
myApi.AppendEntry($"Лист1!A:H", rangeObj, SheetAllUsersId);
|
||||
}
|
||||
#endregion Добавление в гугл таблицу
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ExportDataController: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
|
||||
return httpResult;
|
||||
}
|
||||
|
||||
public HttpStatusCodeResult PersonalConsultations()
|
||||
{
|
||||
List<ChatId> ids = new List<ChatId>();
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
MessageEditParams editParams = new MessageEditParams();
|
||||
HttpStatusCodeResult httpResult = new HttpStatusCodeResult(200);
|
||||
|
||||
var client = new VkApi();
|
||||
List<string> phones;
|
||||
string phone = "";
|
||||
string birthdate = "";
|
||||
string date = "";
|
||||
try
|
||||
{
|
||||
client.AuthorizeAsync(new ApiAuthParams
|
||||
{
|
||||
AccessToken = ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).Token
|
||||
});
|
||||
|
||||
#region Добавление в гугл таблицу
|
||||
|
||||
using (GoogleApi myApi = new GoogleApi())
|
||||
{
|
||||
List<IList<object>> rangeObj = new List<IList<object>>();
|
||||
|
||||
var consultations = db.PersonalConsultations.Join(db.Users, pc => pc.chatId, u => u.chatId, (pc, u) =>
|
||||
new PersonalCons{
|
||||
chatId = pc.chatId,
|
||||
fio = u.fio,
|
||||
phone = u.phone,
|
||||
birthdate = u.birthday,
|
||||
question = u.question,
|
||||
date = pc.datetime,
|
||||
state = pc.state
|
||||
})
|
||||
.Where(c => c.state == 1)
|
||||
.ToList();
|
||||
|
||||
foreach (var c in consultations)
|
||||
{
|
||||
phones = JsonConvert.DeserializeObject<List<string>>(c.phone);
|
||||
if (phones.Count > 0)
|
||||
phone = phones[0];
|
||||
else
|
||||
phone = "-";
|
||||
|
||||
birthdate = c.birthdate.ToShortDateString();
|
||||
date = c.date.ToString("dd.MM.yyyy HH:mm");
|
||||
|
||||
rangeObj.Add(new List<object>()
|
||||
{
|
||||
c.chatId,
|
||||
c.fio,
|
||||
phone,
|
||||
birthdate,
|
||||
c.question,
|
||||
date,
|
||||
});
|
||||
|
||||
var con = db.PersonalConsultations.Where(el => el.chatId == c.chatId).Single<PersonalConsultation>();
|
||||
con.state = 2;
|
||||
db.SaveChanges();
|
||||
|
||||
Thread.Sleep(30);
|
||||
}
|
||||
|
||||
//Добавление в таблицу данных объектов
|
||||
myApi.AppendEntry($"Лист1!A:H", rangeObj, SheetConsultationsId);
|
||||
}
|
||||
#endregion Добавление в гугл таблицу
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ExportDataController: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
|
||||
return httpResult;
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
SvetoforVKBot/Controllers/HomeController.cs
Normal file
12
SvetoforVKBot/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace SvetoforVKBot.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public string Index()
|
||||
{
|
||||
return "Ok :)";
|
||||
}
|
||||
}
|
||||
}
|
||||
109
SvetoforVKBot/Controllers/MessageController.cs
Normal file
109
SvetoforVKBot/Controllers/MessageController.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using SvetoforVKBot.Models;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Security.Cryptography;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Dop;
|
||||
using System.Configuration;
|
||||
using SvetoforVKBot.App_Start;
|
||||
|
||||
namespace SvetoforVKBot.Controllers
|
||||
{
|
||||
public class MessageController : ApiController
|
||||
{
|
||||
// Подключаем контекст базы данных
|
||||
private SvetoforVKBot.Data.SvetoforVKBotEntities db = new SvetoforVKBot.Data.SvetoforVKBotEntities();
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
db.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
[Route(@"api/message/update")] //webhook uri part
|
||||
public async Task<HttpResponseMessage> Update([FromBody]JObject json)
|
||||
{
|
||||
var getData = new GetData();
|
||||
var getPhoneRecallMeCommand = new GetPhoneRecallMeCommand();
|
||||
var getAskQuestionsCommand = new GetAskQuestionsCommand();
|
||||
var checkTag = new CheckTag();
|
||||
var client = await Bot.Get();
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
HttpResponseMessage httpRespOK = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent("ok", System.Text.Encoding.ASCII),
|
||||
StatusCode = HttpStatusCode.OK
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var update = JsonConvert.DeserializeObject<RootObject>(json.ToString());
|
||||
var commands = Bot.Commands;
|
||||
if (update.secret == ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).SecretKey)
|
||||
{
|
||||
switch (update.type)
|
||||
{
|
||||
case "confirmation":
|
||||
return new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(((WebConfiguration)ConfigurationManager.GetSection("VKApi")).Confirmation, System.Text.Encoding.ASCII),
|
||||
StatusCode = HttpStatusCode.OK
|
||||
};
|
||||
|
||||
case "message_new":
|
||||
|
||||
getData.updateUser(update, client, db);
|
||||
|
||||
foreach (var command in commands)
|
||||
{
|
||||
if (update.@object.message.text != null)
|
||||
if (command.StartsWith(update.@object.message.text))
|
||||
{
|
||||
command.Execute(update, client, db);
|
||||
return httpRespOK;
|
||||
}
|
||||
|
||||
if (update.@object.message.payload != null)
|
||||
if (command.StartsWith(update.@object.message.payload))
|
||||
{
|
||||
command.ExecutePL(update, client, db);
|
||||
return httpRespOK;
|
||||
}
|
||||
}
|
||||
checkTag.Execute(update, client, db);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return httpRespOK;
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в MessageController: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return httpRespOK;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
323
SvetoforVKBot/Controllers/NotifiesController.cs
Normal file
323
SvetoforVKBot/Controllers/NotifiesController.cs
Normal file
@@ -0,0 +1,323 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SvetoforVKBot.Models;
|
||||
using SvetoforVKBot.Models.Commands.Admin;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web.Mvc;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Linq;
|
||||
using System.Configuration;
|
||||
using SvetoforVKBot.App_Start;
|
||||
|
||||
namespace SvetoforVKBot.Controllers
|
||||
{
|
||||
public class NotifiesController : Controller
|
||||
{
|
||||
// Подключаем контекст базы данных
|
||||
private SvetoforVKBot.Data.SvetoforVKBotEntities db = new SvetoforVKBot.Data.SvetoforVKBotEntities();
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
db.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GET: Notifies
|
||||
|
||||
public HttpStatusCodeResult Execute()
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
HttpStatusCodeResult httpResult = new HttpStatusCodeResult(200);
|
||||
//SqlConnection Con = new SqlConnection(AppSettings.ConnectionString);
|
||||
|
||||
var client = new VkApi();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
var keyboardBuilder2 = new KeyboardBuilder().Clear();
|
||||
DateTime dt = DateTime.Now.AddHours(0);
|
||||
List<OrderLog> orders = new List<OrderLog>();
|
||||
string highWorkload = "0";
|
||||
List<int> ids = new List<int>();
|
||||
List<int> ids2 = new List<int>();
|
||||
List<int> idsFood = new List<int>();
|
||||
List<UserObject> waterNotifiesList = new List<UserObject>();
|
||||
string msg = "";
|
||||
|
||||
string name = "";
|
||||
int age = 0;
|
||||
int genderCoef = 0;
|
||||
double kkalResult = 0;
|
||||
double colorPercent = 0;
|
||||
double dayCoef = 0;
|
||||
double curDayKkal = 0;
|
||||
double kkalResultLow = 0;
|
||||
double kkalResultHigh = 0;
|
||||
try
|
||||
{
|
||||
client.AuthorizeAsync(new ApiAuthParams
|
||||
{
|
||||
AccessToken = ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).Token
|
||||
});
|
||||
|
||||
|
||||
if (DateTime.Now.DayOfWeek == DayOfWeek.Monday && DateTime.Now.Hour == 11)
|
||||
{
|
||||
ids = db.Users.Where(e => e.notifyCount > 0 && e.reg == 1 && e.waterNotify == 0).ToList().ConvertAll(e => e.chatId);
|
||||
|
||||
@params.Message = "Зачем организму нужна вода?🤔\n\n" +
|
||||
"Наш организм можно сравнить с отлаженным часовым механизмом. Для его запуска необходимо наладить питьевой режим.\n" +
|
||||
"Роль жидкости неоценима: именно она наполняет энергией в течение дня, заряжает силами на работу и учебу, служит " +
|
||||
"питанием для физических и умственных процессов.\n\n" +
|
||||
"Мы поможем Вам сформировать привычку пить достаточное количество воды!💦\n" +
|
||||
"Нажмите \"Напоминать\" и в течение дня Вам будут приходить напоминания о необходимости выпить стакан воды.";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Напоминать", "selectGoWaterNotify", KeyboardButtonColor.Positive)
|
||||
.AddLine()
|
||||
.AddButton("Неинтересно", "selectWaterNotifyCount-10", KeyboardButtonColor.Negative)
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Primary)
|
||||
.SetInline();
|
||||
|
||||
foreach (var id in ids)
|
||||
{
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = id;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
if (DateTime.Now.Hour == 7 && DateTime.Now.DayOfWeek != DayOfWeek.Saturday && DateTime.Now.DayOfWeek != DayOfWeek.Sunday)
|
||||
//if (false)
|
||||
{
|
||||
//Проверить корректность работы
|
||||
db.Users.ToList().ForEach(e => { e.choosenProducts = "[]"; e.cart = "{\"orders\":[]}"; });
|
||||
db.SaveChanges();
|
||||
|
||||
idsFood = db.Users.Where(e => e.notifyCount >= 1 && e.weight != 0 && e.height != 0 && e.reg == 1 && e.track != 0).ToList().ConvertAll(e => e.chatId);
|
||||
|
||||
Dictionary<int, string> tracks = new Dictionary<int, string>(7);
|
||||
tracks.Add(1, "Оптимизация питания");
|
||||
tracks.Add(2, "Снижение жировой массы");
|
||||
tracks.Add(3, "Увеличение мышечной массы");
|
||||
tracks.Add(4, "Персональный режим");
|
||||
|
||||
//idsFood = new List<int>{3158149, 10160301 };
|
||||
//idsFood = new List<int>{59111081};
|
||||
foreach (var idFood in idsFood)
|
||||
{
|
||||
keyboardBuilder.Clear();
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == idFood);
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
|
||||
if ((DateTime.Now.Month >= user.birthday.Month) && (DateTime.Now.Day >= user.birthday.Day))
|
||||
age = DateTime.Now.Year - user.birthday.Year;
|
||||
else
|
||||
age = DateTime.Now.Year - user.birthday.Year - 1;
|
||||
|
||||
#region ccalCalculator
|
||||
Dictionary<int, string> days = new Dictionary<int, string>(7);
|
||||
days.Add(1, "Понедельник");
|
||||
days.Add(2, "Вторник");
|
||||
days.Add(3, "Среда");
|
||||
days.Add(4, "Четверг");
|
||||
days.Add(5, "Пятница");
|
||||
days.Add(6, "Суббота");
|
||||
days.Add(7, "Воскресенье");
|
||||
|
||||
Dictionary<int, string> gend = new Dictionary<int, string>(3);
|
||||
gend.Add(0, "Мужской");
|
||||
gend.Add(1, "Мужской");
|
||||
gend.Add(2, "Женский");
|
||||
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
int nextDay = curDay + 1;
|
||||
|
||||
if (nextDay == 8)
|
||||
nextDay = 1;
|
||||
|
||||
if (user.gender == 1)
|
||||
{
|
||||
genderCoef = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
genderCoef = -161;
|
||||
}
|
||||
switch (user.track)
|
||||
{
|
||||
case 1: //не изменяя веса
|
||||
colorPercent = 1;
|
||||
break;
|
||||
case 2:
|
||||
colorPercent = 0.75; //1 - 15%
|
||||
break;
|
||||
case 3:
|
||||
colorPercent = 1.2; //1 - 15%
|
||||
break;
|
||||
default:
|
||||
colorPercent = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 7; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 2:
|
||||
dayCoef = 0.8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dayCoef = 1.2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dayCoef = 0.9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
dayCoef = 1.1;
|
||||
break;
|
||||
|
||||
default:
|
||||
dayCoef = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
kkalResult = Math.Round((((10 * user.weight) + (6.25 * user.height) - (5 * age) + genderCoef) * user.activityCoef) * colorPercent * dayCoef);
|
||||
kkalResultHigh = Math.Round(kkalResult * 1.2);
|
||||
kkalResultLow = Math.Round(kkalResult * 0.9);
|
||||
|
||||
if (i == curDay)
|
||||
//if (i == curDay)
|
||||
{
|
||||
curDayKkal = kkalResult;
|
||||
}
|
||||
}
|
||||
#endregion ccalCalculator
|
||||
|
||||
|
||||
user.kkal = Convert.ToInt32(curDayKkal);
|
||||
db.SaveChanges();
|
||||
|
||||
@params.Message = "☀Доброе утро!\n" +
|
||||
$"Ваша норма калорий на сегодня: {Math.Round(curDayKkal * 0.9)} - {Math.Round(curDayKkal * 1.2)}\n" +
|
||||
"Мы подготовили для Вас блюда👇🏻\n\n" +
|
||||
"Меню также доступно в Личном кабинете в разделе \"Дневной рацион\"";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton($"Завтрак (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-1-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Обед (до {Math.Round(curDayKkal * 1.2 * 0.4)} ккал)", "selectPersonalMenu-2-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Перекус (до {Math.Round(curDayKkal * 1.2 * 0.1)} ккал)", "selectPersonalMenu-3-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Ужин (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-4-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default)
|
||||
.SetInline();
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = idFood; //10160301;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
Thread.Sleep(1500);
|
||||
}
|
||||
}
|
||||
|
||||
if (DateTime.Now.Hour == 10 ||
|
||||
DateTime.Now.Hour == 12 ||
|
||||
DateTime.Now.Hour == 14 ||
|
||||
DateTime.Now.Hour == 16 ||
|
||||
DateTime.Now.Hour == 18 ||
|
||||
DateTime.Now.Hour == 20)
|
||||
{
|
||||
|
||||
waterNotifiesList = db.Users.Where(e => e.waterNotify >= 1 && e.waterNotify != 10).ToList().ConvertAll(e => new UserObject() {
|
||||
chatId = e.chatId,
|
||||
waterNotify = e.waterNotify
|
||||
});
|
||||
|
||||
@params2.Message = "🍹💦Время выпить воды!";
|
||||
|
||||
keyboardBuilder2
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Отключить уведомления", "selectOffWaterNotify", KeyboardButtonColor.Default)
|
||||
.SetInline();
|
||||
|
||||
foreach (var us in waterNotifiesList)
|
||||
{
|
||||
if (us.waterNotify == 1 && DateTime.Now.Hour == 14)
|
||||
{
|
||||
@params2.Keyboard = keyboardBuilder2.Build();
|
||||
@params2.UserId = us.chatId;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params2);
|
||||
}
|
||||
else if (us.waterNotify == 3 && (DateTime.Now.Hour == 10 || DateTime.Now.Hour == 14 || DateTime.Now.Hour == 18))
|
||||
{
|
||||
@params2.Keyboard = keyboardBuilder2.Build();
|
||||
@params2.UserId = us.chatId;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params2);
|
||||
}
|
||||
else if (us.waterNotify == 6)
|
||||
{
|
||||
@params2.Keyboard = keyboardBuilder2.Build();
|
||||
@params2.UserId = us.chatId;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params2);
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
return httpResult;
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в NotifiesController: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.Send(@params);
|
||||
return httpResult;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
111
SvetoforVKBot/Controllers/SportDaysController.cs
Normal file
111
SvetoforVKBot/Controllers/SportDaysController.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SvetoforVKBot.App_Start;
|
||||
using SvetoforVKBot.Models;
|
||||
using SvetoforVKBot.Models.Commands.Admin;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web.Mvc;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Controllers
|
||||
{
|
||||
public class SportDaysController : Controller
|
||||
{
|
||||
// Подключаем контекст базы данных
|
||||
private SvetoforVKBot.Data.SvetoforVKBotEntities db = new SvetoforVKBot.Data.SvetoforVKBotEntities();
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
db.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
// GET: SportDays
|
||||
public HttpStatusCodeResult Execute()
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
HttpStatusCodeResult httpResult = new HttpStatusCodeResult(200);
|
||||
|
||||
var client = new VkApi();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
var keyboardBuilder2 = new KeyboardBuilder().Clear();
|
||||
DateTime dt = DateTime.Now.AddHours(0);
|
||||
List<OrderLog> orders = new List<OrderLog>();
|
||||
string highWorkload = "0";
|
||||
List<int> ids = new List<int>();
|
||||
List<int> ids2 = new List<int>();
|
||||
string msg = "";
|
||||
try
|
||||
{
|
||||
client.AuthorizeAsync(new ApiAuthParams
|
||||
{
|
||||
AccessToken = ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).Token
|
||||
});
|
||||
|
||||
//if (DateTime.Now.DayOfWeek == DayOfWeek.Monday && DateTime.Now.Hour == 9)
|
||||
if (DateTime.Now.DayOfWeek == DayOfWeek.Monday && DateTime.Now.Hour == 13)
|
||||
{
|
||||
|
||||
ids = db.Users.Where(e => e.notifyCount > 0 && e.reg == 1 && e.sportDays != "[]" && e.activityKind != 3).ToList().ConvertAll(e => e.chatId);
|
||||
|
||||
@params.Message = "Добрый день☀\n" +
|
||||
"Сегодня понедельник - самое время обновить график тренировок на неделю.\n" +
|
||||
"Нажмите кнопку \"Обновить\" 😉";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Обновить", "selectUpdateSportDays", KeyboardButtonColor.Positive)
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Primary)
|
||||
.SetInline();
|
||||
|
||||
foreach (var id in ids)
|
||||
{
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = id;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
return httpResult;
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SportDaysController: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.Send(@params);
|
||||
return httpResult;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
SvetoforVKBot/Data/CategoriesDostavka.cs
Normal file
26
SvetoforVKBot/Data/CategoriesDostavka.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class CategoriesDostavka
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int categoryId { get; set; }
|
||||
public string idIiko { get; set; }
|
||||
public string name { get; set; }
|
||||
public string btnName { get; set; }
|
||||
public string kbColor { get; set; }
|
||||
public int inTheOrder { get; set; }
|
||||
public int subMenu { get; set; }
|
||||
}
|
||||
}
|
||||
22
SvetoforVKBot/Data/PersonalConsultation.cs
Normal file
22
SvetoforVKBot/Data/PersonalConsultation.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class PersonalConsultation
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int chatId { get; set; }
|
||||
public System.DateTime datetime { get; set; }
|
||||
public int state { get; set; }
|
||||
}
|
||||
}
|
||||
39
SvetoforVKBot/Data/ProductsDostavka.cs
Normal file
39
SvetoforVKBot/Data/ProductsDostavka.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class ProductsDostavka
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string idIiko { get; set; }
|
||||
public string article { get; set; }
|
||||
public int colorId { get; set; }
|
||||
public int categoryId { get; set; }
|
||||
public string name { get; set; }
|
||||
public string fullName { get; set; }
|
||||
public string description { get; set; }
|
||||
public string descriptionCarousel { get; set; }
|
||||
public string photo { get; set; }
|
||||
public string photoCarousel { get; set; }
|
||||
public decimal price { get; set; }
|
||||
public string additions { get; set; }
|
||||
public string recommends { get; set; }
|
||||
public string weekDays { get; set; }
|
||||
public int timeLunch { get; set; }
|
||||
public int kkal { get; set; }
|
||||
public decimal belki { get; set; }
|
||||
public decimal zhiry { get; set; }
|
||||
public decimal uglevody { get; set; }
|
||||
public string foodType { get; set; }
|
||||
}
|
||||
}
|
||||
25
SvetoforVKBot/Data/Reports.cs
Normal file
25
SvetoforVKBot/Data/Reports.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Reports
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int chatId { get; set; }
|
||||
public int state { get; set; }
|
||||
public int rate { get; set; }
|
||||
public int result { get; set; }
|
||||
public string comment { get; set; }
|
||||
public System.DateTime datetime { get; set; }
|
||||
}
|
||||
}
|
||||
22
SvetoforVKBot/Data/SportKinds.cs
Normal file
22
SvetoforVKBot/Data/SportKinds.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class SportKinds
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string btnName { get; set; }
|
||||
public int kind { get; set; }
|
||||
}
|
||||
}
|
||||
23
SvetoforVKBot/Data/Svetofor.cs
Normal file
23
SvetoforVKBot/Data/Svetofor.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Svetofor
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int colorId { get; set; }
|
||||
public string name { get; set; }
|
||||
public string btnName { get; set; }
|
||||
public string kbColor { get; set; }
|
||||
}
|
||||
}
|
||||
38
SvetoforVKBot/Data/SvetoforVkBotModel.Context.cs
Normal file
38
SvetoforVKBot/Data/SvetoforVkBotModel.Context.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class SvetoforVKBotEntities : DbContext
|
||||
{
|
||||
public SvetoforVKBotEntities()
|
||||
: base("name=u1118637_SvetoforVKBotEntities")
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<PersonalConsultation>()
|
||||
.HasKey(i => i.id);
|
||||
//throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
public virtual DbSet<CategoriesDostavka> CategoriesDostavkas { get; set; }
|
||||
public virtual DbSet<ProductsDostavka> ProductsDostavkas { get; set; }
|
||||
public virtual DbSet<Reports> Reports { get; set; }
|
||||
public virtual DbSet<SportKinds> SportKinds { get; set; }
|
||||
public virtual DbSet<Svetofor> Svetofors { get; set; }
|
||||
public virtual DbSet<Users> Users { get; set; }
|
||||
public virtual DbSet<PersonalConsultation> PersonalConsultations { get; set; }
|
||||
}
|
||||
}
|
||||
636
SvetoforVKBot/Data/SvetoforVkBotModel.Context.tt
Normal file
636
SvetoforVKBot/Data/SvetoforVkBotModel.Context.tt
Normal file
@@ -0,0 +1,636 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"SvetoforVkBotModel.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
|
||||
var itemCollection = loader.CreateEdmItemCollection(inputFile);
|
||||
var modelNamespace = loader.GetModelNamespace(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
|
||||
if (container == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
<#
|
||||
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#
|
||||
PushIndent(" ");
|
||||
}
|
||||
|
||||
#>
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
<#
|
||||
if (container.FunctionImports.Any())
|
||||
{
|
||||
#>
|
||||
using System.Data.Entity.Core.Objects;
|
||||
using System.Linq;
|
||||
<#
|
||||
}
|
||||
#>
|
||||
|
||||
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
|
||||
{
|
||||
public <#=code.Escape(container)#>()
|
||||
: base("name=<#=container.Name#>")
|
||||
{
|
||||
<#
|
||||
if (!loader.IsLazyLoadingEnabled(container))
|
||||
{
|
||||
#>
|
||||
this.Configuration.LazyLoadingEnabled = false;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
// Note: the DbSet members are defined below such that the getter and
|
||||
// setter always have the same accessibility as the DbSet definition
|
||||
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
throw new UnintentionalCodeFirstException();
|
||||
}
|
||||
|
||||
<#
|
||||
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.DbSet(entitySet)#>
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var edmFunction in container.FunctionImports)
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#+
|
||||
|
||||
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
if (typeMapper.IsComposable(edmFunction))
|
||||
{
|
||||
#>
|
||||
|
||||
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
|
||||
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
else
|
||||
{
|
||||
#>
|
||||
|
||||
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
{
|
||||
<#+
|
||||
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
|
||||
#>
|
||||
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
|
||||
}
|
||||
<#+
|
||||
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
|
||||
{
|
||||
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
|
||||
{
|
||||
#>
|
||||
var <#=name#> = <#=isNotNull#> ?
|
||||
<#=notNullInit#> :
|
||||
<#=nullInit#>;
|
||||
|
||||
<#+
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Context_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string DbSetInitializer(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} = Set<{1}>();",
|
||||
_code.Escape(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
10
SvetoforVKBot/Data/SvetoforVkBotModel.Designer.cs
generated
Normal file
10
SvetoforVKBot/Data/SvetoforVkBotModel.Designer.cs
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
// Создание кода T4 для модели "C:\Users\daria\OneDrive\Desktop\SvetoforVKBot\SvetoforVKBot\SvetoforVKBot\Data\SvetoforVkBotModel.edmx" включено.
|
||||
// Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
|
||||
// на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
|
||||
// открыта в конструкторе.
|
||||
|
||||
// Если не сформированы контекст и классы сущности, возможная причина в том, что вы создали пустую модель, но
|
||||
// еще не выбрали версию Entity Framework для использования. Чтобы сформировать класс контекста и классы сущностей
|
||||
// для своей модели, откройте модель в конструкторе, щелкните правой кнопкой область конструктора и
|
||||
// выберите "Обновить модель из базы данных", "Сформировать базу данных из модели" или "Добавить элемент формирования
|
||||
// кода...".
|
||||
9
SvetoforVKBot/Data/SvetoforVkBotModel.cs
Normal file
9
SvetoforVKBot/Data/SvetoforVkBotModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
436
SvetoforVKBot/Data/SvetoforVkBotModel.edmx
Normal file
436
SvetoforVKBot/Data/SvetoforVkBotModel.edmx
Normal file
@@ -0,0 +1,436 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Runtime content -->
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema Namespace="Хранилище u1118637_SvetoforVKBotModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
|
||||
<EntityType Name="CategoriesDostavka">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="categoryId" Type="int" Nullable="false" />
|
||||
<Property Name="idIiko" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="50" />
|
||||
<Property Name="btnName" Type="nvarchar" MaxLength="50" />
|
||||
<Property Name="kbColor" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="inTheOrder" Type="int" Nullable="false" />
|
||||
<Property Name="subMenu" Type="int" Nullable="false" />
|
||||
</EntityType>
|
||||
<!--Ошибки, обнаруженные при создании:
|
||||
предупреждение 6002: В таблице или представлении "u1118637_SvetoforVKBot.dbo.PersonalConsultation" не определен первичный ключ. Ключ был выведен, а определение таблицы или представления было создано в режиме только для чтения.-->
|
||||
<EntityType Name="PersonalConsultation">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="chatId" Type="int" Nullable="false" />
|
||||
<Property Name="datetime" Type="datetime" Nullable="false" />
|
||||
<Property Name="state" Type="int" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProductsDostavka">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="idIiko" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="article" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="colorId" Type="int" Nullable="false" />
|
||||
<Property Name="categoryId" Type="int" Nullable="false" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="fullName" Type="nvarchar" MaxLength="100" Nullable="false" />
|
||||
<Property Name="description" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="descriptionCarousel" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="photo" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="photoCarousel" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="price" Type="decimal" Precision="10" Scale="2" Nullable="false" />
|
||||
<Property Name="additions" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="recommends" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="weekDays" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="timeLunch" Type="int" Nullable="false" />
|
||||
<Property Name="kkal" Type="int" Nullable="false" />
|
||||
<Property Name="belki" Type="decimal" Precision="18" Scale="2" Nullable="false" />
|
||||
<Property Name="zhiry" Type="decimal" Precision="18" Scale="2" Nullable="false" />
|
||||
<Property Name="uglevody" Type="decimal" Precision="18" Scale="2" Nullable="false" />
|
||||
<Property Name="foodType" Type="nvarchar(max)" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Reports">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="chatId" Type="int" Nullable="false" />
|
||||
<Property Name="state" Type="int" Nullable="false" />
|
||||
<Property Name="rate" Type="int" Nullable="false" />
|
||||
<Property Name="result" Type="int" Nullable="false" />
|
||||
<Property Name="comment" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="datetime" Type="datetime" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="SportKinds">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="btnName" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="kind" Type="int" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Svetofor">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="colorId" Type="int" Nullable="false" />
|
||||
<Property Name="name" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="btnName" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="kbColor" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Users">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
|
||||
<Property Name="chatId" Type="int" Nullable="false" />
|
||||
<Property Name="admin" Type="int" Nullable="false" />
|
||||
<Property Name="firstName" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="lastName" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="fio" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="reg" Type="int" Nullable="false" />
|
||||
<Property Name="tag" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="voronka" Type="nvarchar" MaxLength="50" Nullable="false" />
|
||||
<Property Name="cart" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="addresses" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="phone" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="activityKind" Type="int" Nullable="false" />
|
||||
<Property Name="sportId" Type="int" Nullable="false" />
|
||||
<Property Name="sourse" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="hoursReklama" Type="int" Nullable="false" />
|
||||
<Property Name="korpus" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="notifyCount" Type="int" Nullable="false" />
|
||||
<Property Name="weight" Type="int" Nullable="false" />
|
||||
<Property Name="height" Type="int" Nullable="false" />
|
||||
<Property Name="birthday" Type="datetime" Nullable="false" />
|
||||
<Property Name="agree" Type="int" Nullable="false" />
|
||||
<Property Name="gender" Type="int" Nullable="false" />
|
||||
<Property Name="report" Type="int" Nullable="false" />
|
||||
<Property Name="kkal" Type="int" Nullable="false" />
|
||||
<Property Name="day" Type="int" Nullable="false" />
|
||||
<Property Name="colorId" Type="int" Nullable="false" />
|
||||
<Property Name="activityCoef" Type="float" Nullable="false" />
|
||||
<Property Name="question" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="sportDays" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="personal" Type="int" Nullable="false" />
|
||||
<Property Name="answer" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="statusId" Type="int" Nullable="false" />
|
||||
<Property Name="track" Type="int" Nullable="false" />
|
||||
<Property Name="waterNotify" Type="int" Nullable="false" />
|
||||
<Property Name="choosenProducts" Type="nvarchar(max)" Nullable="false" />
|
||||
<Property Name="child" Type="int" Nullable="false" />
|
||||
<Property Name="export" Type="int" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="Хранилище u1118637_SvetoforVKBotModelContainer">
|
||||
<EntitySet Name="CategoriesDostavka" EntityType="Self.CategoriesDostavka" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="ProductsDostavka" EntityType="Self.ProductsDostavka" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Reports" EntityType="Self.Reports" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="SportKinds" EntityType="Self.SportKinds" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Svetofor" EntityType="Self.Svetofor" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
|
||||
<EntitySet Name="PersonalConsultation" EntityType="Self.PersonalConsultation" Schema="dbo" store:Type="Tables">
|
||||
</EntitySet>
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema Namespace="u1118637_SvetoforVKBotModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
|
||||
<EntityType Name="CategoriesDostavka">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="categoryId" Type="Int32" Nullable="false" />
|
||||
<Property Name="idIiko" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
|
||||
<Property Name="btnName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
|
||||
<Property Name="kbColor" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="inTheOrder" Type="Int32" Nullable="false" />
|
||||
<Property Name="subMenu" Type="Int32" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="ProductsDostavka">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="idIiko" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="article" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="colorId" Type="Int32" Nullable="false" />
|
||||
<Property Name="categoryId" Type="Int32" Nullable="false" />
|
||||
<Property Name="name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="fullName" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="descriptionCarousel" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="photo" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="photoCarousel" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="price" Type="Decimal" Precision="10" Scale="2" Nullable="false" />
|
||||
<Property Name="additions" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="recommends" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="weekDays" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="timeLunch" Type="Int32" Nullable="false" />
|
||||
<Property Name="kkal" Type="Int32" Nullable="false" />
|
||||
<Property Name="belki" Type="Decimal" Precision="18" Scale="2" Nullable="false" />
|
||||
<Property Name="zhiry" Type="Decimal" Precision="18" Scale="2" Nullable="false" />
|
||||
<Property Name="uglevody" Type="Decimal" Precision="18" Scale="2" Nullable="false" />
|
||||
<Property Name="foodType" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Reports">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="chatId" Type="Int32" Nullable="false" />
|
||||
<Property Name="state" Type="Int32" Nullable="false" />
|
||||
<Property Name="rate" Type="Int32" Nullable="false" />
|
||||
<Property Name="result" Type="Int32" Nullable="false" />
|
||||
<Property Name="comment" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="datetime" Type="DateTime" Nullable="false" Precision="3" />
|
||||
</EntityType>
|
||||
<EntityType Name="SportKinds">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="btnName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="kind" Type="Int32" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Svetofor">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="colorId" Type="Int32" Nullable="false" />
|
||||
<Property Name="name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="btnName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="kbColor" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="Users">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="chatId" Type="Int32" Nullable="false" />
|
||||
<Property Name="admin" Type="Int32" Nullable="false" />
|
||||
<Property Name="firstName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="lastName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="fio" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="reg" Type="Int32" Nullable="false" />
|
||||
<Property Name="tag" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="voronka" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="cart" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="addresses" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="phone" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="activityKind" Type="Int32" Nullable="false" />
|
||||
<Property Name="sportId" Type="Int32" Nullable="false" />
|
||||
<Property Name="sourse" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="hoursReklama" Type="Int32" Nullable="false" />
|
||||
<Property Name="korpus" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="notifyCount" Type="Int32" Nullable="false" />
|
||||
<Property Name="weight" Type="Int32" Nullable="false" />
|
||||
<Property Name="height" Type="Int32" Nullable="false" />
|
||||
<Property Name="birthday" Type="DateTime" Nullable="false" Precision="3" />
|
||||
<Property Name="agree" Type="Int32" Nullable="false" />
|
||||
<Property Name="gender" Type="Int32" Nullable="false" />
|
||||
<Property Name="report" Type="Int32" Nullable="false" />
|
||||
<Property Name="kkal" Type="Int32" Nullable="false" />
|
||||
<Property Name="day" Type="Int32" Nullable="false" />
|
||||
<Property Name="colorId" Type="Int32" Nullable="false" />
|
||||
<Property Name="activityCoef" Type="Double" Nullable="false" />
|
||||
<Property Name="question" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="sportDays" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="personal" Type="Int32" Nullable="false" />
|
||||
<Property Name="answer" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="statusId" Type="Int32" Nullable="false" />
|
||||
<Property Name="track" Type="Int32" Nullable="false" />
|
||||
<Property Name="waterNotify" Type="Int32" Nullable="false" />
|
||||
<Property Name="choosenProducts" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" Nullable="false" />
|
||||
<Property Name="child" Type="Int32" Nullable="false" />
|
||||
<Property Name="export" Type="Int32" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityType Name="PersonalConsultation">
|
||||
<Key>
|
||||
<PropertyRef Name="id" />
|
||||
</Key>
|
||||
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Name="chatId" Type="Int32" Nullable="false" />
|
||||
<Property Name="datetime" Type="DateTime" Nullable="false" Precision="3" />
|
||||
<Property Name="state" Type="Int32" Nullable="false" />
|
||||
</EntityType>
|
||||
<EntityContainer Name="u1118637_SvetoforVKBotEntities" annotation:LazyLoadingEnabled="true">
|
||||
<EntitySet Name="CategoriesDostavka" EntityType="Self.CategoriesDostavka" />
|
||||
<EntitySet Name="ProductsDostavka" EntityType="Self.ProductsDostavka" />
|
||||
<EntitySet Name="Reports" EntityType="Self.Reports" />
|
||||
<EntitySet Name="SportKinds" EntityType="Self.SportKinds" />
|
||||
<EntitySet Name="Svetofor" EntityType="Self.Svetofor" />
|
||||
<EntitySet Name="Users" EntityType="Self.Users" />
|
||||
<EntitySet Name="PersonalConsultation" EntityType="Self.PersonalConsultation" />
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
<edmx:Mappings>
|
||||
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
|
||||
<EntityContainerMapping StorageEntityContainer="Хранилище u1118637_SvetoforVKBotModelContainer" CdmEntityContainer="u1118637_SvetoforVKBotEntities">
|
||||
<EntitySetMapping Name="CategoriesDostavka">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.CategoriesDostavka">
|
||||
<MappingFragment StoreEntitySet="CategoriesDostavka">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="categoryId" ColumnName="categoryId" />
|
||||
<ScalarProperty Name="idIiko" ColumnName="idIiko" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="btnName" ColumnName="btnName" />
|
||||
<ScalarProperty Name="kbColor" ColumnName="kbColor" />
|
||||
<ScalarProperty Name="inTheOrder" ColumnName="inTheOrder" />
|
||||
<ScalarProperty Name="subMenu" ColumnName="subMenu" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="ProductsDostavka">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.ProductsDostavka">
|
||||
<MappingFragment StoreEntitySet="ProductsDostavka">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="idIiko" ColumnName="idIiko" />
|
||||
<ScalarProperty Name="article" ColumnName="article" />
|
||||
<ScalarProperty Name="colorId" ColumnName="colorId" />
|
||||
<ScalarProperty Name="categoryId" ColumnName="categoryId" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="fullName" ColumnName="fullName" />
|
||||
<ScalarProperty Name="description" ColumnName="description" />
|
||||
<ScalarProperty Name="descriptionCarousel" ColumnName="descriptionCarousel" />
|
||||
<ScalarProperty Name="photo" ColumnName="photo" />
|
||||
<ScalarProperty Name="photoCarousel" ColumnName="photoCarousel" />
|
||||
<ScalarProperty Name="price" ColumnName="price" />
|
||||
<ScalarProperty Name="additions" ColumnName="additions" />
|
||||
<ScalarProperty Name="recommends" ColumnName="recommends" />
|
||||
<ScalarProperty Name="weekDays" ColumnName="weekDays" />
|
||||
<ScalarProperty Name="timeLunch" ColumnName="timeLunch" />
|
||||
<ScalarProperty Name="kkal" ColumnName="kkal" />
|
||||
<ScalarProperty Name="belki" ColumnName="belki" />
|
||||
<ScalarProperty Name="zhiry" ColumnName="zhiry" />
|
||||
<ScalarProperty Name="uglevody" ColumnName="uglevody" />
|
||||
<ScalarProperty Name="foodType" ColumnName="foodType" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Reports">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.Reports">
|
||||
<MappingFragment StoreEntitySet="Reports">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="chatId" ColumnName="chatId" />
|
||||
<ScalarProperty Name="state" ColumnName="state" />
|
||||
<ScalarProperty Name="rate" ColumnName="rate" />
|
||||
<ScalarProperty Name="result" ColumnName="result" />
|
||||
<ScalarProperty Name="comment" ColumnName="comment" />
|
||||
<ScalarProperty Name="datetime" ColumnName="datetime" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="SportKinds">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.SportKinds">
|
||||
<MappingFragment StoreEntitySet="SportKinds">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="btnName" ColumnName="btnName" />
|
||||
<ScalarProperty Name="kind" ColumnName="kind" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Svetofor">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.Svetofor">
|
||||
<MappingFragment StoreEntitySet="Svetofor">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="colorId" ColumnName="colorId" />
|
||||
<ScalarProperty Name="name" ColumnName="name" />
|
||||
<ScalarProperty Name="btnName" ColumnName="btnName" />
|
||||
<ScalarProperty Name="kbColor" ColumnName="kbColor" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="Users">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.Users">
|
||||
<MappingFragment StoreEntitySet="Users">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="chatId" ColumnName="chatId" />
|
||||
<ScalarProperty Name="admin" ColumnName="admin" />
|
||||
<ScalarProperty Name="firstName" ColumnName="firstName" />
|
||||
<ScalarProperty Name="lastName" ColumnName="lastName" />
|
||||
<ScalarProperty Name="fio" ColumnName="fio" />
|
||||
<ScalarProperty Name="reg" ColumnName="reg" />
|
||||
<ScalarProperty Name="tag" ColumnName="tag" />
|
||||
<ScalarProperty Name="voronka" ColumnName="voronka" />
|
||||
<ScalarProperty Name="cart" ColumnName="cart" />
|
||||
<ScalarProperty Name="addresses" ColumnName="addresses" />
|
||||
<ScalarProperty Name="phone" ColumnName="phone" />
|
||||
<ScalarProperty Name="activityKind" ColumnName="activityKind" />
|
||||
<ScalarProperty Name="sportId" ColumnName="sportId" />
|
||||
<ScalarProperty Name="sourse" ColumnName="sourse" />
|
||||
<ScalarProperty Name="hoursReklama" ColumnName="hoursReklama" />
|
||||
<ScalarProperty Name="korpus" ColumnName="korpus" />
|
||||
<ScalarProperty Name="notifyCount" ColumnName="notifyCount" />
|
||||
<ScalarProperty Name="weight" ColumnName="weight" />
|
||||
<ScalarProperty Name="height" ColumnName="height" />
|
||||
<ScalarProperty Name="birthday" ColumnName="birthday" />
|
||||
<ScalarProperty Name="agree" ColumnName="agree" />
|
||||
<ScalarProperty Name="gender" ColumnName="gender" />
|
||||
<ScalarProperty Name="report" ColumnName="report" />
|
||||
<ScalarProperty Name="kkal" ColumnName="kkal" />
|
||||
<ScalarProperty Name="day" ColumnName="day" />
|
||||
<ScalarProperty Name="colorId" ColumnName="colorId" />
|
||||
<ScalarProperty Name="activityCoef" ColumnName="activityCoef" />
|
||||
<ScalarProperty Name="question" ColumnName="question" />
|
||||
<ScalarProperty Name="sportDays" ColumnName="sportDays" />
|
||||
<ScalarProperty Name="personal" ColumnName="personal" />
|
||||
<ScalarProperty Name="answer" ColumnName="answer" />
|
||||
<ScalarProperty Name="statusId" ColumnName="statusId" />
|
||||
<ScalarProperty Name="track" ColumnName="track" />
|
||||
<ScalarProperty Name="waterNotify" ColumnName="waterNotify" />
|
||||
<ScalarProperty Name="choosenProducts" ColumnName="choosenProducts" />
|
||||
<ScalarProperty Name="child" ColumnName="child" />
|
||||
<ScalarProperty Name="export" ColumnName="export" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
<EntitySetMapping Name="PersonalConsultation">
|
||||
<EntityTypeMapping TypeName="u1118637_SvetoforVKBotModel.PersonalConsultation">
|
||||
<MappingFragment StoreEntitySet="PersonalConsultation">
|
||||
<ScalarProperty Name="id" ColumnName="id" />
|
||||
<ScalarProperty Name="chatId" ColumnName="chatId" />
|
||||
<ScalarProperty Name="datetime" ColumnName="datetime" />
|
||||
<ScalarProperty Name="state" ColumnName="state" />
|
||||
</MappingFragment>
|
||||
</EntityTypeMapping>
|
||||
</EntitySetMapping>
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
</edmx:Runtime>
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<Connection>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Connection>
|
||||
<Options>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||
<DesignerProperty Name="EnablePluralization" Value="false" />
|
||||
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
|
||||
<DesignerProperty Name="UseLegacyProvider" Value="false" />
|
||||
<DesignerProperty Name="CodeGenerationStrategy" Value="Нет" />
|
||||
</DesignerInfoPropertySet>
|
||||
</Options>
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<Diagrams></Diagrams>
|
||||
</Designer>
|
||||
</edmx:Edmx>
|
||||
18
SvetoforVKBot/Data/SvetoforVkBotModel.edmx.diagram
Normal file
18
SvetoforVKBot/Data/SvetoforVkBotModel.edmx.diagram
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<edmx:Diagrams>
|
||||
<Diagram DiagramId="a8ef8796c9db4356af2b00adfe4cd94e" Name="Diagram1">
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.CategoriesDostavka" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.ProductsDostavka" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.Reports" Width="1.5" PointX="4.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.SportKinds" Width="1.5" PointX="4.75" PointY="4.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.Svetofor" Width="1.5" PointX="6.75" PointY="0.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.Users" Width="1.5" PointX="0.75" PointY="6.75" IsExpanded="true" />
|
||||
<EntityTypeShape EntityType="u1118637_SvetoforVKBotModel.PersonalConsultation" Width="1.5" PointX="6.75" PointY="3.75" IsExpanded="true" />
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
</edmx:Edmx>
|
||||
733
SvetoforVKBot/Data/SvetoforVkBotModel.tt
Normal file
733
SvetoforVKBot/Data/SvetoforVkBotModel.tt
Normal file
@@ -0,0 +1,733 @@
|
||||
<#@ template language="C#" debug="false" hostspecific="true"#>
|
||||
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
|
||||
output extension=".cs"#><#
|
||||
|
||||
const string inputFile = @"SvetoforVkBotModel.edmx";
|
||||
var textTransform = DynamicTextTransformation.Create(this);
|
||||
var code = new CodeGenerationTools(this);
|
||||
var ef = new MetadataTools(this);
|
||||
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
|
||||
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
|
||||
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
|
||||
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
|
||||
|
||||
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
WriteHeader(codeStringGenerator, fileManager);
|
||||
|
||||
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(entity.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
|
||||
<#=codeStringGenerator.EntityClassOpening(entity)#>
|
||||
{
|
||||
<#
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
|
||||
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
|
||||
var complexProperties = typeMapper.GetComplexProperties(entity);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public <#=code.Escape(entity)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var navigationProperty in collectionNavigationProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(entity);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach (var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(complexProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
var navigationProperties = typeMapper.GetNavigationProperties(entity);
|
||||
if (navigationProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach (var navigationProperty in navigationProperties)
|
||||
{
|
||||
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
|
||||
{
|
||||
#>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(complex.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
|
||||
{
|
||||
<#
|
||||
var complexProperties = typeMapper.GetComplexProperties(complex);
|
||||
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
|
||||
|
||||
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
public <#=code.Escape(complex)#>()
|
||||
{
|
||||
<#
|
||||
foreach (var edmProperty in propertiesWithDefaultValues)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
|
||||
<#
|
||||
}
|
||||
|
||||
foreach (var complexProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
|
||||
var simpleProperties = typeMapper.GetSimpleProperties(complex);
|
||||
if (simpleProperties.Any())
|
||||
{
|
||||
foreach(var edmProperty in simpleProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
|
||||
if (complexProperties.Any())
|
||||
{
|
||||
#>
|
||||
|
||||
<#
|
||||
foreach(var edmProperty in complexProperties)
|
||||
{
|
||||
#>
|
||||
<#=codeStringGenerator.Property(edmProperty)#>
|
||||
<#
|
||||
}
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
|
||||
{
|
||||
fileManager.StartNewFile(enumType.Name + ".cs");
|
||||
BeginNamespace(code);
|
||||
#>
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
|
||||
<#
|
||||
if (typeMapper.EnumIsFlags(enumType))
|
||||
{
|
||||
#>
|
||||
[Flags]
|
||||
<#
|
||||
}
|
||||
#>
|
||||
<#=codeStringGenerator.EnumOpening(enumType)#>
|
||||
{
|
||||
<#
|
||||
var foundOne = false;
|
||||
|
||||
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
|
||||
{
|
||||
foundOne = true;
|
||||
#>
|
||||
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
|
||||
<#
|
||||
}
|
||||
|
||||
if (foundOne)
|
||||
{
|
||||
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
|
||||
}
|
||||
#>
|
||||
}
|
||||
<#
|
||||
EndNamespace(code);
|
||||
}
|
||||
|
||||
fileManager.Process();
|
||||
|
||||
#>
|
||||
<#+
|
||||
|
||||
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
|
||||
{
|
||||
fileManager.StartHeader();
|
||||
#>
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
|
||||
//
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
|
||||
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
|
||||
<#+
|
||||
fileManager.EndBlock();
|
||||
}
|
||||
|
||||
public void BeginNamespace(CodeGenerationTools code)
|
||||
{
|
||||
var codeNamespace = code.VsNamespaceSuggestion();
|
||||
if (!String.IsNullOrEmpty(codeNamespace))
|
||||
{
|
||||
#>
|
||||
namespace <#=code.EscapeNamespace(codeNamespace)#>
|
||||
{
|
||||
<#+
|
||||
PushIndent(" ");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndNamespace(CodeGenerationTools code)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
|
||||
{
|
||||
PopIndent();
|
||||
#>
|
||||
}
|
||||
<#+
|
||||
}
|
||||
}
|
||||
|
||||
public const string TemplateId = "CSharp_DbContext_Types_EF6";
|
||||
|
||||
public class CodeStringGenerator
|
||||
{
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(typeMapper, "typeMapper");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
|
||||
_code = code;
|
||||
_typeMapper = typeMapper;
|
||||
_ef = ef;
|
||||
}
|
||||
|
||||
public string Property(EdmProperty edmProperty)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
Accessibility.ForProperty(edmProperty),
|
||||
_typeMapper.GetTypeName(edmProperty.TypeUsage),
|
||||
_code.Escape(edmProperty),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
|
||||
}
|
||||
|
||||
public string NavigationProperty(NavigationProperty navProp)
|
||||
{
|
||||
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2} {{ {3}get; {4}set; }}",
|
||||
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
|
||||
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
|
||||
_code.Escape(navProp),
|
||||
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
|
||||
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
|
||||
}
|
||||
|
||||
public string AccessibilityAndVirtual(string accessibility)
|
||||
{
|
||||
return accessibility + (accessibility != "private" ? " virtual" : "");
|
||||
}
|
||||
|
||||
public string EntityClassOpening(EntityType entity)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1}partial class {2}{3}",
|
||||
Accessibility.ForType(entity),
|
||||
_code.SpaceAfter(_code.AbstractOption(entity)),
|
||||
_code.Escape(entity),
|
||||
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
|
||||
}
|
||||
|
||||
public string EnumOpening(SimpleType enumType)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} enum {1} : {2}",
|
||||
Accessibility.ForType(enumType),
|
||||
_code.Escape(enumType),
|
||||
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
|
||||
}
|
||||
|
||||
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
|
||||
{
|
||||
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
|
||||
{
|
||||
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
|
||||
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
|
||||
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
|
||||
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
|
||||
}
|
||||
}
|
||||
|
||||
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} IQueryable<{1}> {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
_code.Escape(edmFunction),
|
||||
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
|
||||
}
|
||||
|
||||
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
|
||||
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
|
||||
edmFunction.NamespaceName,
|
||||
edmFunction.Name,
|
||||
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
|
||||
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
|
||||
}
|
||||
|
||||
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
|
||||
if (includeMergeOption)
|
||||
{
|
||||
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} {1} {2}({3})",
|
||||
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
|
||||
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
_code.Escape(edmFunction),
|
||||
paramList);
|
||||
}
|
||||
|
||||
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
|
||||
{
|
||||
var parameters = _typeMapper.GetParameters(edmFunction);
|
||||
var returnType = _typeMapper.GetReturnType(edmFunction);
|
||||
|
||||
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
|
||||
if (includeMergeOption)
|
||||
{
|
||||
callParams = ", mergeOption" + callParams;
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
|
||||
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
|
||||
edmFunction.Name,
|
||||
callParams);
|
||||
}
|
||||
|
||||
public string DbSet(EntitySet entitySet)
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
|
||||
Accessibility.ForReadOnlyProperty(entitySet),
|
||||
_typeMapper.GetTypeName(entitySet.ElementType),
|
||||
_code.Escape(entitySet));
|
||||
}
|
||||
|
||||
public string UsingDirectives(bool inHeader, bool includeCollections = true)
|
||||
{
|
||||
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
|
||||
? string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}using System;{1}" +
|
||||
"{2}",
|
||||
inHeader ? Environment.NewLine : "",
|
||||
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
|
||||
inHeader ? "" : Environment.NewLine)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeMapper
|
||||
{
|
||||
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
|
||||
|
||||
private readonly System.Collections.IList _errors;
|
||||
private readonly CodeGenerationTools _code;
|
||||
private readonly MetadataTools _ef;
|
||||
|
||||
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
|
||||
{
|
||||
ArgumentNotNull(code, "code");
|
||||
ArgumentNotNull(ef, "ef");
|
||||
ArgumentNotNull(errors, "errors");
|
||||
|
||||
_code = code;
|
||||
_ef = ef;
|
||||
_errors = errors;
|
||||
}
|
||||
|
||||
public static string FixNamespaces(string typeName)
|
||||
{
|
||||
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
|
||||
}
|
||||
|
||||
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
|
||||
{
|
||||
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, string modelNamespace)
|
||||
{
|
||||
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
|
||||
}
|
||||
|
||||
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
|
||||
{
|
||||
if (edmType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = edmType as CollectionType;
|
||||
if (collectionType != null)
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
|
||||
}
|
||||
|
||||
var typeName = _code.Escape(edmType.MetadataProperties
|
||||
.Where(p => p.Name == ExternalTypeNameAttributeName)
|
||||
.Select(p => (string)p.Value)
|
||||
.FirstOrDefault())
|
||||
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
|
||||
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
|
||||
_code.Escape(edmType));
|
||||
|
||||
if (edmType is StructuralType)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
if (edmType is SimpleType)
|
||||
{
|
||||
var clrType = UnderlyingClrType(edmType);
|
||||
if (!IsEnumType(edmType))
|
||||
{
|
||||
typeName = _code.Escape(clrType);
|
||||
}
|
||||
|
||||
typeName = FixNamespaces(typeName);
|
||||
|
||||
return clrType.IsValueType && isNullable == true ?
|
||||
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
|
||||
typeName;
|
||||
}
|
||||
|
||||
throw new ArgumentException("edmType");
|
||||
}
|
||||
|
||||
public Type UnderlyingClrType(EdmType edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
var primitiveType = edmType as PrimitiveType;
|
||||
if (primitiveType != null)
|
||||
{
|
||||
return primitiveType.ClrEquivalentType;
|
||||
}
|
||||
|
||||
if (IsEnumType(edmType))
|
||||
{
|
||||
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
|
||||
}
|
||||
|
||||
return typeof(object);
|
||||
}
|
||||
|
||||
public object GetEnumMemberValue(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var valueProperty = enumMember.GetType().GetProperty("Value");
|
||||
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public string GetEnumMemberName(MetadataItem enumMember)
|
||||
{
|
||||
ArgumentNotNull(enumMember, "enumMember");
|
||||
|
||||
var nameProperty = enumMember.GetType().GetProperty("Name");
|
||||
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
|
||||
}
|
||||
|
||||
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var membersProperty = enumType.GetType().GetProperty("Members");
|
||||
return membersProperty != null
|
||||
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
|
||||
: Enumerable.Empty<MetadataItem>();
|
||||
}
|
||||
|
||||
public bool EnumIsFlags(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
|
||||
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public bool IsEnumType(GlobalItem edmType)
|
||||
{
|
||||
ArgumentNotNull(edmType, "edmType");
|
||||
|
||||
return edmType.GetType().Name == "EnumType";
|
||||
}
|
||||
|
||||
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
|
||||
{
|
||||
ArgumentNotNull(enumType, "enumType");
|
||||
|
||||
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
|
||||
}
|
||||
|
||||
public string CreateLiteral(object value)
|
||||
{
|
||||
if (value == null || value.GetType() != typeof(TimeSpan))
|
||||
{
|
||||
return _code.CreateLiteral(value);
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
|
||||
}
|
||||
|
||||
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
|
||||
{
|
||||
ArgumentNotNull(types, "types");
|
||||
ArgumentNotNull(sourceFile, "sourceFile");
|
||||
|
||||
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
if (types.Any(item => !hash.Add(item)))
|
||||
{
|
||||
_errors.Add(
|
||||
new CompilerError(sourceFile, -1, -1, "6023",
|
||||
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return GetItemsToGenerate<SimpleType>(itemCollection)
|
||||
.Where(e => IsEnumType(e));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
|
||||
{
|
||||
return itemCollection
|
||||
.OfType<T>()
|
||||
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
|
||||
{
|
||||
return itemCollection
|
||||
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
|
||||
.Select(g => GetGlobalItemName(g));
|
||||
}
|
||||
|
||||
public string GetGlobalItemName(GlobalItem item)
|
||||
{
|
||||
if (item is EdmType)
|
||||
{
|
||||
return ((EdmType)item).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((EntityContainer)item).Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
|
||||
{
|
||||
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type);
|
||||
}
|
||||
|
||||
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
|
||||
{
|
||||
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
|
||||
}
|
||||
|
||||
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
|
||||
return returnParamsProperty == null
|
||||
? edmFunction.ReturnParameter
|
||||
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool IsComposable(EdmFunction edmFunction)
|
||||
{
|
||||
ArgumentNotNull(edmFunction, "edmFunction");
|
||||
|
||||
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
|
||||
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
|
||||
}
|
||||
|
||||
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
|
||||
{
|
||||
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
|
||||
}
|
||||
|
||||
public TypeUsage GetReturnType(EdmFunction edmFunction)
|
||||
{
|
||||
var returnParam = GetReturnParameter(edmFunction);
|
||||
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
|
||||
}
|
||||
|
||||
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
|
||||
{
|
||||
var returnType = GetReturnType(edmFunction);
|
||||
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ArgumentNotNull<T>(T arg, string name) where T : class
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(name);
|
||||
}
|
||||
}
|
||||
#>
|
||||
56
SvetoforVKBot/Data/Users.cs
Normal file
56
SvetoforVKBot/Data/Users.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан по шаблону.
|
||||
//
|
||||
// Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
|
||||
// Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Users
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int chatId { get; set; }
|
||||
public int admin { get; set; }
|
||||
public string firstName { get; set; }
|
||||
public string lastName { get; set; }
|
||||
public string fio { get; set; }
|
||||
public int reg { get; set; }
|
||||
public string tag { get; set; }
|
||||
public string voronka { get; set; }
|
||||
public string cart { get; set; }
|
||||
public string addresses { get; set; }
|
||||
public string phone { get; set; }
|
||||
public int activityKind { get; set; }
|
||||
public int sportId { get; set; }
|
||||
public string sourse { get; set; }
|
||||
public int hoursReklama { get; set; }
|
||||
public string korpus { get; set; }
|
||||
public int notifyCount { get; set; }
|
||||
public int weight { get; set; }
|
||||
public int height { get; set; }
|
||||
public System.DateTime birthday { get; set; }
|
||||
public int agree { get; set; }
|
||||
public int gender { get; set; }
|
||||
public int report { get; set; }
|
||||
public int kkal { get; set; }
|
||||
public int day { get; set; }
|
||||
public int colorId { get; set; }
|
||||
public double activityCoef { get; set; }
|
||||
public string question { get; set; }
|
||||
public string sportDays { get; set; }
|
||||
public int personal { get; set; }
|
||||
public string answer { get; set; }
|
||||
public int statusId { get; set; }
|
||||
public int track { get; set; }
|
||||
public int waterNotify { get; set; }
|
||||
public string choosenProducts { get; set; }
|
||||
public int child { get; set; }
|
||||
public int export { get; set; }
|
||||
}
|
||||
}
|
||||
1
SvetoforVKBot/Global.asax
Normal file
1
SvetoforVKBot/Global.asax
Normal file
@@ -0,0 +1 @@
|
||||
<%@ Application Codebehind="Global.asax.cs" Inherits="SvetoforVKBot.MvcApplication" Language="C#" %>
|
||||
17
SvetoforVKBot/Global.asax.cs
Normal file
17
SvetoforVKBot/Global.asax.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Http;
|
||||
using SvetoforVKBot.App_Start;
|
||||
|
||||
namespace SvetoforVKBot
|
||||
{
|
||||
public class MvcApplication : System.Web.HttpApplication
|
||||
{
|
||||
async protected void Application_Start()
|
||||
{
|
||||
AreaRegistration.RegisterAllAreas();
|
||||
GlobalConfiguration.Configure(WebApiConfig.Register);
|
||||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||||
}
|
||||
}
|
||||
}
|
||||
133
SvetoforVKBot/Models/Bot.cs
Normal file
133
SvetoforVKBot/Models/Bot.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using SvetoforVKBot.Models.Commands;
|
||||
using SvetoforVKBot.Models.Commands.Admin;
|
||||
using VkNet;
|
||||
using VkNet.Model;
|
||||
using SvetoforVKBot.Models.Commands.Registration;
|
||||
using SvetoforVKBot.Models.Commands.LK;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu.Products;
|
||||
using SvetoforVKBot.Models.Commands.LK.Calculators;
|
||||
using SvetoforVKBot.Models.Commands.LK.Reports;
|
||||
using SvetoforVKBot.Models.Commands.ExpertLK;
|
||||
using SvetoforVKBot.Models.Commands.LK.Consultation;
|
||||
using SvetoforVKBot.Models.Commands.LK.Cart;
|
||||
using SvetoforVKBot.Models.Commands.LK.Tracks;
|
||||
using SvetoforVKBot.Models.Commands.LK.EditData;
|
||||
using SvetoforVKBot.Models.Commands.Water;
|
||||
using System.Configuration;
|
||||
using SvetoforVKBot.App_Start;
|
||||
|
||||
namespace SvetoforVKBot.Models
|
||||
{
|
||||
public static class Bot
|
||||
{
|
||||
private static VkApi client;
|
||||
|
||||
private static List<Command> commandsList;
|
||||
|
||||
public static IReadOnlyList<Command> Commands => commandsList.AsReadOnly();
|
||||
|
||||
public static async Task<VkApi> Get()
|
||||
{
|
||||
commandsList = new List<Command>
|
||||
{
|
||||
//Основные
|
||||
new StartCommand(),
|
||||
new StartLowerCommand(),
|
||||
new StartPLCommand(),
|
||||
new SelectRoleCommand(),
|
||||
new SelectAboutCommand(),
|
||||
new SelectAskQuestionsCommand(),
|
||||
|
||||
//Регистрация
|
||||
new SelectParticipateCommand(),
|
||||
new SelectChildAgeCommand(),
|
||||
new SelectAgreementCommand(),
|
||||
new SelectAcceptPDCommand(),
|
||||
new SelectDateCommand(),
|
||||
new SelectDateNavigationCommand(),
|
||||
new SelectDRMonthCommand(),
|
||||
new SelectGenderCommand(),
|
||||
new SelectActivityCoefCommand(),
|
||||
new SelectActivityKindCommand(),
|
||||
new SelectSportsCommand(),
|
||||
new SelectDayCommand(),
|
||||
new SelectNotifyCountCommand(),
|
||||
new SelectVyatsuRoleCommand(),
|
||||
|
||||
//Личный кабинет
|
||||
new SelectEditDataCommand(),
|
||||
new SelectMenuCommand(),
|
||||
new SelectDayMenuCommand(),
|
||||
new SelectColorCommand(),
|
||||
new SelectProductCommand(),
|
||||
new SelectCalculatorCcalCommand(),
|
||||
new SelectCalcCcalResultCommand(),
|
||||
new SelectIdealWeightCommand(),
|
||||
new SelectCreateReportCommand(),
|
||||
new SelectReportRateCommand(),
|
||||
new SelectReportCcalCommand(),
|
||||
new SelectConsultationCommand(),
|
||||
new SelectPersonalMenuCommand(),
|
||||
|
||||
//Редактирование данных
|
||||
new SelectEditNotifyCount(),
|
||||
new SelectUpdateSportDaysCommand(),
|
||||
|
||||
//Вода
|
||||
new SelectGoWaterNotifyCommand(),
|
||||
new SelectOffWaterNotifyCommand(),
|
||||
new SelectWaterNotifyCountCommand(),
|
||||
|
||||
//Треки
|
||||
new SelectTrackCommand(),
|
||||
new SelectRationCommand(),
|
||||
new SelectExampleMenuCommand(),
|
||||
new SelectChooseTrackCommand(),
|
||||
|
||||
//Корзина
|
||||
new SelectAddToCartCommand(),
|
||||
new SelectCartCommand(),
|
||||
new SelectEditCartCommand(),
|
||||
new SelectConfirmClearCartCommand(),
|
||||
|
||||
//Дополнительные
|
||||
new SelectAskQuestionsCommand(),
|
||||
|
||||
//Админ
|
||||
new SelectGetPhotoCommand(),
|
||||
new SelectAdminCommand(),
|
||||
new SelectStatisticCommand(),
|
||||
new SelectTestNotifyCommand(),
|
||||
|
||||
//Консультации
|
||||
new SelectLiveConsultationCommand(),
|
||||
new SelectSubmitConsultationCommand(),
|
||||
new SelectMoreAboutSpecCommand(),
|
||||
|
||||
//Эксперт
|
||||
new SelectExpertLKCommand(),
|
||||
new SelectParticipantsCommand(),
|
||||
new SelectParticipantInfoCommand(),
|
||||
new SelectUpPersonalPlanCommand(),
|
||||
new SelectPersonalPlanCommand(),
|
||||
|
||||
//Питание
|
||||
new SelectDayFoodCommand(),
|
||||
};
|
||||
|
||||
client = new VkApi();
|
||||
|
||||
|
||||
|
||||
await client.AuthorizeAsync(new ApiAuthParams
|
||||
{
|
||||
AccessToken = ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).Token
|
||||
});
|
||||
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
189
SvetoforVKBot/Models/Commands/Admin/SelectAdminCommand.cs
Normal file
189
SvetoforVKBot/Models/Commands/Admin/SelectAdminCommand.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model;
|
||||
using System.Collections.ObjectModel;
|
||||
using VkNet.Model.Attachments;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectAdminCommand : Command
|
||||
{
|
||||
private const int ADMIN1 = 59111081;
|
||||
private const int ADMIN2 = 369217524;
|
||||
private const int ADMIN3 = 10160301;
|
||||
public override string Name => "{\"button\":\"selectAdminMenu\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
SalesFunnel salesFunnel = new SalesFunnel();
|
||||
//var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
try
|
||||
{
|
||||
if (update.@object.message.from_id == ADMIN1 || update.@object.message.from_id == ADMIN2 || update.@object.message.from_id == ADMIN3 || update.@object.message.from_id == 178385801)
|
||||
{
|
||||
|
||||
//List<MediaAttachment> listVideo = new List<MediaAttachment>()
|
||||
//{
|
||||
// new VkNet.Model.Attachments.Video() { Id = 456239343, OwnerId = 59111081, AccessKey = "5530abb97b1da2077b" }
|
||||
//};
|
||||
//@params.Attachments = listVideo;
|
||||
|
||||
Uri URL = new Uri("https://docs.google.com/spreadsheets/d/1nWHvWufxDy6g2ZJtqd4K8MDM6Gh8OHWasRGXIyqbT2k/");
|
||||
Uri URLSHEET_ALL = new Uri("https://docs.google.com/spreadsheets/d/1jr68NfIrlz2bVsN-HZg0Kv2sSJ82J5G-EbtXl-YMK44/");
|
||||
Uri URLDOC = new Uri("https://docs.google.com/document/d/1DQcBuS9g6KYphJZRdcc-tdqgQ_oSvV2PsZt3U-pO_oo/");
|
||||
Uri URLDIALOGS = new Uri("https://vk.com/gim194717824");
|
||||
/*
|
||||
if (admin == 1)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("📅Каталог мероприятий", "selectEvents-0-1", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("➕Добавить мероприятие", "Добавить мероприятие", KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("Создать рассылку", "Создать рассылку", KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("Статистика", "Статистика", KeyboardButtonColor.Default)
|
||||
.AddButton("Обращения", "Обращения", KeyboardButtonColor.Default);
|
||||
@params.Message = "Режим администратора. Выберите интересующее действие👇🏻";
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
//keyboardBuilder.AddButton("Открыть таблицу", URL, "open_link");
|
||||
var row = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URL,
|
||||
Label = "Заявки на консультацию",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row));
|
||||
|
||||
var row1 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URLSHEET_ALL,
|
||||
Label = "Все участники",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
|
||||
|
||||
row1 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URLDIALOGS,
|
||||
Label = "Перейти в диалоги",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
|
||||
|
||||
row1 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URLDOC,
|
||||
Label = "Инструкция",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
|
||||
|
||||
var row2 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Label = "Статистика",
|
||||
Payload = "{\"button\":\"selectStatistic\"}",
|
||||
Type = KeyboardButtonActionType.Text},
|
||||
Color = KeyboardButtonColor.Primary
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row2));
|
||||
|
||||
|
||||
//var row3 = new List<MessageKeyboardButton>()
|
||||
//{
|
||||
// new MessageKeyboardButton() {
|
||||
// Action = new MessageKeyboardButtonAction(){
|
||||
// Label = "Личный кабинет специалиста",
|
||||
// Payload = "{\"button\":\"selectExpertLK\"}",
|
||||
// Type = KeyboardButtonActionType.Text},
|
||||
// Color = KeyboardButtonColor.Primary
|
||||
// }
|
||||
//};
|
||||
//listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row3));
|
||||
|
||||
var row4 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Label = "В начало",
|
||||
Payload = "{\"button\":\"startPL\"}",
|
||||
Type = KeyboardButtonActionType.Text},
|
||||
Color = KeyboardButtonColor.Default
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row4));
|
||||
|
||||
var buttons = new ReadOnlyCollection<ReadOnlyCollection<MessageKeyboardButton>>(listButtons);
|
||||
|
||||
var keyboard = new MessageKeyboard()
|
||||
{
|
||||
Buttons = buttons,
|
||||
OneTime = false
|
||||
};
|
||||
|
||||
//@params.Attachments = listVideo;
|
||||
@params.Keyboard = keyboard;
|
||||
@params.UserId = chatId;
|
||||
@params.Message = "✅ Вы перешли в панель администратора. Выберите интересующее действие";
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectAdminCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
SvetoforVKBot/Models/Commands/Admin/SelectGetPhotoCommand.cs
Normal file
82
SvetoforVKBot/Models/Commands/Admin/SelectGetPhotoCommand.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectGetPhotoCommand : Command
|
||||
{
|
||||
public override string Name => "/getphoto";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string str = "";
|
||||
|
||||
try
|
||||
{
|
||||
//string[] payload = update.@object.message.text.Split('-');
|
||||
string response = "";
|
||||
|
||||
if (chatId != 59111081) return;
|
||||
|
||||
foreach (var att in update.@object.message.attachments)
|
||||
{
|
||||
switch (att.type)
|
||||
{
|
||||
case "photo":
|
||||
var usPhoto = client.Photo.GetMessagesUploadServer(peerId: 0);
|
||||
var strArray = att.photo.sizes[att.photo.sizes.Count - 1].url.Split('.');
|
||||
|
||||
response = UploadFile(
|
||||
serverUrl: usPhoto.UploadUrl,
|
||||
file: att.photo.sizes[att.photo.sizes.Count - 1].url,
|
||||
fileExtension: strArray[strArray.Length - 1]).Result;
|
||||
|
||||
foreach (var a in client.Photo.SaveMessagesPhoto(response))
|
||||
{
|
||||
|
||||
str = "{\"id\": " + a.Id +
|
||||
", \"owner_id\": " + a.OwnerId +
|
||||
", \"access_key\": \"" + a.AccessKey + "\"}";
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "video":
|
||||
str = "{\"id\": " + att.video.id +
|
||||
", \"owner_id\": " + att.video.owner_id +
|
||||
", \"access_key\": \"" + att.video.access_key + "\"}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@params.Message = str;
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectGetPhotoCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
114
SvetoforVKBot/Models/Commands/Admin/SelectStatisticCommand.cs
Normal file
114
SvetoforVKBot/Models/Commands/Admin/SelectStatisticCommand.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectStatisticCommand : Command
|
||||
{
|
||||
private const int ADMIN1 = 59111081;
|
||||
private const int ADMIN2 = 10160301;
|
||||
private const int ADMIN3 = 369217524;
|
||||
private const int ADMIN4 = 178385801;
|
||||
//chatId == 59111081 || chatId == 10160301 || chatId == 369217524 || chatId == 178385801
|
||||
public override string Name => "{\"button\":\"selectStatistic\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
double sumOrders = 0;
|
||||
DateTime dt;
|
||||
DateTime dt1;
|
||||
DateTime dt2;
|
||||
List<UserStats> userStats = new List<UserStats>();
|
||||
List<UserStats> userStats1 = new List<UserStats>();
|
||||
SalesFunnel salesFunnel = new SalesFunnel();
|
||||
|
||||
try
|
||||
{
|
||||
if (update.@object.message.from_id == ADMIN1 || update.@object.message.from_id == ADMIN2 || update.@object.message.from_id == ADMIN3 || update.@object.message.from_id == ADMIN4)
|
||||
{
|
||||
|
||||
userStats = db.Users.ToList().ConvertAll<UserStats>(x => new UserStats {
|
||||
chatId = x.chatId,
|
||||
sourses = JsonConvert.DeserializeObject<Sourses>(x.sourse),
|
||||
voronka = x.voronka,
|
||||
});
|
||||
|
||||
/*SqlCommand getUsers = new SqlCommand("SELECT chatId, sourse, voronka FROM Users;", Con);
|
||||
SqlDataReader rgetUsers = getUsers.ExecuteReader();
|
||||
while (rgetUsers.Read())
|
||||
userStats.Add(new UserStats()
|
||||
{
|
||||
chatId = Convert.ToInt32(rgetUsers["chatId"]),
|
||||
sourses = JsonConvert.DeserializeObject<Sourses>(rgetUsers["sourse"].ToString()),
|
||||
voronka = rgetUsers["voronka"].ToString(),
|
||||
});
|
||||
rgetUsers.Close();*/
|
||||
|
||||
msg += "📊 Статистика \n" +
|
||||
"ВСЕГО: сег вч нед мес all\n";
|
||||
|
||||
foreach (var st in salesFunnel.stages)
|
||||
{
|
||||
dt = DateTime.Now;
|
||||
dt2 = DateTime.Now;
|
||||
|
||||
msg += st + ": " + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt.Date)).Count;
|
||||
|
||||
dt = dt.AddDays(-1);
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt.Date)).Count;
|
||||
|
||||
dt2 = dt2.AddDays(-7);
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt2.Date)).Count;
|
||||
dt2 = dt2.AddDays(7);
|
||||
|
||||
dt2 = dt2.AddMonths(-1);
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt2.Date)).Count;
|
||||
dt2 = dt2.AddMonths(1);
|
||||
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st)).Count;
|
||||
|
||||
msg += "\n";
|
||||
}
|
||||
|
||||
msg += "Всего пользователей: " + userStats.Count + "\n";
|
||||
msg += "\n";
|
||||
|
||||
@params.UserId = chatId;
|
||||
@params.Message = msg;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectStatisticCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
220
SvetoforVKBot/Models/Commands/Admin/SelectTestNotifyCommand.cs
Normal file
220
SvetoforVKBot/Models/Commands/Admin/SelectTestNotifyCommand.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectTestNotifyCommand : Command
|
||||
{
|
||||
public override string Name => "/test";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
string name = "";
|
||||
int age = 0;
|
||||
int genderCoef = 0;
|
||||
double kkalResult = 0;
|
||||
double colorPercent = 0;
|
||||
double dayCoef = 0;
|
||||
double curDayKkal = 0;
|
||||
double kkalResultLow = 0;
|
||||
double kkalResultHigh = 0;
|
||||
try
|
||||
{
|
||||
Dictionary<int, string> tracks = new Dictionary<int, string>(7);
|
||||
tracks.Add(1, "Оптимизация питания");
|
||||
tracks.Add(2, "Снижение жировой массы");
|
||||
tracks.Add(3, "Увеличение мышечной массы");
|
||||
tracks.Add(4, "Персональный режим");
|
||||
|
||||
//-- Вот этот запрос лучше сработает на стороне
|
||||
db.Database.ExecuteSqlCommand("UPDATE Users SET choosenProducts = @choosenProducts, cart = @cart;",
|
||||
new object[] {
|
||||
new SqlParameter("@choosenProducts", "[]"),
|
||||
new SqlParameter("@cart", "{\"orders\":[]}")
|
||||
});
|
||||
|
||||
//--
|
||||
var user = db.Users.Single(usr => usr.chatId == 59111081);
|
||||
int id = user.id;
|
||||
string fio = user.fio;
|
||||
var birthday = user.birthday;
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
int choosenTrack = user.track;
|
||||
int height = user.height;
|
||||
int weight = user.weight;
|
||||
int gender = user.gender; // 1 - М / 2 - Ж
|
||||
var activityCoef = user.activityCoef;
|
||||
//--
|
||||
if ((DateTime.Now.Month >= birthday.Month) && (DateTime.Now.Day >= birthday.Day))
|
||||
age = DateTime.Now.Year - birthday.Year;
|
||||
else
|
||||
age = DateTime.Now.Year - birthday.Year - 1;
|
||||
|
||||
#region ccalCalculator
|
||||
Dictionary<int, string> days = new Dictionary<int, string>(7);
|
||||
days.Add(1, "Понедельник");
|
||||
days.Add(2, "Вторник");
|
||||
days.Add(3, "Среда");
|
||||
days.Add(4, "Четверг");
|
||||
days.Add(5, "Пятница");
|
||||
days.Add(6, "Суббота");
|
||||
days.Add(7, "Воскресенье");
|
||||
|
||||
Dictionary<int, string> gend = new Dictionary<int, string>(3);
|
||||
gend.Add(0, "Мужской");
|
||||
gend.Add(1, "Мужской");
|
||||
gend.Add(2, "Женский");
|
||||
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
int nextDay = curDay + 1;
|
||||
|
||||
if (nextDay == 8)
|
||||
nextDay = 1;
|
||||
|
||||
//if (weight == 0 || height == 0)
|
||||
//{
|
||||
// keyboardBuilder
|
||||
// .AddButton("📝Редактировать данные", "selectEditData-0", KeyboardButtonColor.Primary)
|
||||
// .AddLine()
|
||||
// .AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
// @params.Message = "Не хватает данных о росте/весе.\n" +
|
||||
// "Нажмите \"📝Редактировать данные\" и заполните показатели.";
|
||||
|
||||
// @params.Keyboard = keyboardBuilder.Build();
|
||||
// @params.UserId = chatId;
|
||||
// @params.RandomId = GetRandomId();
|
||||
// client.Messages.SendAsync(@params);
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
if (gender == 1)
|
||||
{
|
||||
genderCoef = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
genderCoef = -161;
|
||||
}
|
||||
switch (choosenTrack)
|
||||
{
|
||||
case 1: //не изменяя веса
|
||||
colorPercent = 1;
|
||||
break;
|
||||
case 2:
|
||||
colorPercent = 0.75; //1 - 15%
|
||||
break;
|
||||
case 3:
|
||||
colorPercent = 1.2; //1 - 15%
|
||||
break;
|
||||
default:
|
||||
colorPercent = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 7; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 2:
|
||||
dayCoef = 0.8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dayCoef = 1.2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dayCoef = 0.9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
dayCoef = 1.1;
|
||||
break;
|
||||
|
||||
default:
|
||||
dayCoef = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
kkalResult = Math.Round((((10 * weight) + (6.25 * height) - (5 * age) + genderCoef) * activityCoef) * colorPercent * dayCoef);
|
||||
kkalResultHigh = Math.Round(kkalResult * 1.2);
|
||||
kkalResultLow = Math.Round(kkalResult * 0.9);
|
||||
|
||||
//if (i == nextDay)
|
||||
if (i == curDay)
|
||||
{
|
||||
curDayKkal = kkalResult;
|
||||
}
|
||||
}
|
||||
#endregion ccalCalculator
|
||||
|
||||
//-- неожиданно пришлось преобразовывать типы данных к инту от double)
|
||||
var curChatIdUser = db.Users.Single(usr => usr.chatId == chatId);
|
||||
curChatIdUser.kkal = Convert.ToInt32(curDayKkal);
|
||||
db.SaveChanges();
|
||||
|
||||
|
||||
//@params.Message = "🌙Добрый вечер!\n" +
|
||||
// $"Ваша норма калорий на завтра: {Math.Round(curDayKkal * 0.9)} - {Math.Round(curDayKkal * 1.2)}\n" +
|
||||
// "Мы подготовили для Вас блюда👇🏻";
|
||||
@params.Message = "☀Доброе утро!\n" +
|
||||
$"Ваша норма калорий на сегодня: {Math.Round(curDayKkal * 0.9)} - {Math.Round(curDayKkal * 1.2)}\n" +
|
||||
"Мы подготовили для Вас блюда👇🏻\n\n" +
|
||||
"Меню также доступно в Личном кабинете в разделе \"Дневной рацион\"";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton($"Завтрак (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-1-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Обед (до {Math.Round(curDayKkal * 1.2 * 0.4)} ккал)", "selectPersonalMenu-2-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Перекус (до {Math.Round(curDayKkal * 1.2 * 0.1)} ккал)", "selectPersonalMenu-3-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Ужин (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-4-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default)
|
||||
.SetInline();
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = 59111081; //10160301;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectTestNotifyCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
69
SvetoforVKBot/Models/Commands/Command.cs
Normal file
69
SvetoforVKBot/Models/Commands/Command.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VkNet;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands
|
||||
{
|
||||
public abstract class Command
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db);
|
||||
|
||||
public abstract void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db);
|
||||
|
||||
public bool StartsWith(string command)
|
||||
{
|
||||
return command.StartsWith(this.Name);
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
|
||||
}
|
||||
|
||||
public async Task<string> UploadFile(string serverUrl, string file, string fileExtension)
|
||||
{
|
||||
// Получение массива байтов из файла
|
||||
var data = GetBytesNet(file);
|
||||
|
||||
// Создание запроса на загрузку файла на сервер
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var requestContent = new MultipartFormDataContent();
|
||||
var content = new ByteArrayContent(data);
|
||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
|
||||
requestContent.Add(content, "file", $"file.{fileExtension}");
|
||||
|
||||
var response = client.PostAsync(serverUrl, requestContent).Result;
|
||||
return Encoding.Default.GetString(await response.Content.ReadAsByteArrayAsync());
|
||||
}
|
||||
}
|
||||
private byte[] GetBytesNet(string fileUrl)
|
||||
{
|
||||
using (var webClient = new WebClient())
|
||||
{
|
||||
return webClient.DownloadData(fileUrl);
|
||||
}
|
||||
}
|
||||
private byte[] GetBytesLocal(string filePath)
|
||||
{
|
||||
return File.ReadAllBytes(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.ExpertLK
|
||||
{
|
||||
public class SelectExpertLKCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectExpertLK\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
try
|
||||
{
|
||||
@params.Message = "Личный кабинет специалиста.\n";
|
||||
|
||||
//вот это
|
||||
chatIds = db.PersonalConsultations.Where(c => c.chatId == chatId && c.state == 1)?
|
||||
.ToList().ConvertAll<int>(el => el.chatId);
|
||||
//вместо этого
|
||||
//SqlCommand getCons = new SqlCommand("SELECT * FROM PersonalConsultation WHERE chatId = @chatId AND state = 1;", Con);
|
||||
//getCons.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCons = getCons.ExecuteReader();
|
||||
//if (rgetCons.HasRows)
|
||||
//{
|
||||
// while (rgetCons.Read())
|
||||
// chatIds.Add(Convert.ToInt32(rgetCons["chatId"]));
|
||||
|
||||
// rgetCons.Close();
|
||||
//}
|
||||
//else
|
||||
// rgetCons.Close();
|
||||
|
||||
if (chatIds.Count > 0)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Участники: " + chatIds.Count.ToString(), "selectParticipants", KeyboardButtonColor.Positive)
|
||||
.AddButton("Вопросы", "selectExQuestions", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "selectAdminMenu", KeyboardButtonColor.Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Участники", "selectExpertLK", KeyboardButtonColor.Primary)
|
||||
.AddButton("Вопросы", "selectExQuestions", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "selectAdminMenu", KeyboardButtonColor.Default);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectExpertLKCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.ExpertLK
|
||||
{
|
||||
public class SelectParticipantInfoCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectParticipantInfo-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { }
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
string name = "";
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int userId = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
//@params.Message = "Выберите участника.\n";
|
||||
|
||||
var user = db.Users.Single(usr => usr.id == userId);
|
||||
int uChatId = Convert.ToInt32(user.chatId);
|
||||
string fio = user.fio;
|
||||
var birthday = user.birthday;
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
|
||||
@params.Message = "Участник:\n\n" +
|
||||
fio + "\n" +
|
||||
"Дата рождения: " + birthday.ToShortDateString() + "\n" +
|
||||
"Телефон: " + jsPhones[0];
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Вкл. персональный режим", "selectPersonalPlan-" + userId, KeyboardButtonColor.Positive)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectParticipantInfoCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.ExpertLK
|
||||
{
|
||||
public class SelectParticipantsCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectParticipants\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
string name = "";
|
||||
try
|
||||
{
|
||||
@params.Message = "Выберите участника.\n";
|
||||
|
||||
//SqlCommand getCons = new SqlCommand("SELECT * FROM PersonalConsultation WHERE chatId = @chatId;", Con);
|
||||
//getCons.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCons = getCons.ExecuteReader();
|
||||
//if (rgetCons.HasRows)
|
||||
//{
|
||||
// while (rgetCons.Read())
|
||||
// chatIds.Add(Convert.ToInt32(rgetCons["chatId"]));
|
||||
|
||||
// rgetCons.Close();
|
||||
//}
|
||||
//else
|
||||
// rgetCons.Close();
|
||||
|
||||
//if (chatIds.Count > 0)
|
||||
//{
|
||||
// foreach (var c in chatIds)
|
||||
// {
|
||||
// SqlCommand getUser = new SqlCommand("SELECT * FROM Users WHERE chatId = @chatId;", Con);
|
||||
// getUser.Parameters.AddWithValue("@chatId", c);
|
||||
// SqlDataReader rgetUser = getUser.ExecuteReader();
|
||||
// while (rgetUser.Read())
|
||||
// users.Add(new UserObject()
|
||||
// {
|
||||
// id = Convert.ToInt32(rgetUser["id"]),
|
||||
// chatId = Convert.ToInt32(rgetUser["chatId"]),
|
||||
// fio = rgetUser["fio"].ToString(),
|
||||
// birthday = DateTime.Parse(rgetUser["birthday"].ToString()),
|
||||
// });
|
||||
|
||||
// rgetUser.Close();
|
||||
// }
|
||||
|
||||
// int btnRow = 0;
|
||||
|
||||
// foreach (var u in users)
|
||||
// {
|
||||
// if (u.fio.Length >= 36)
|
||||
// name = u.fio.Substring(0, 35) + "...";
|
||||
// else
|
||||
// name = u.fio;
|
||||
|
||||
|
||||
// keyboardBuilder
|
||||
// .AddButton(name, "selectParticipantInfo-"+ u.id, KeyboardButtonColor.Primary)
|
||||
// .AddLine();
|
||||
|
||||
// btnRow++;
|
||||
// if (btnRow == 8)
|
||||
// break;
|
||||
// }
|
||||
// keyboardBuilder
|
||||
// .AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// keyboardBuilder
|
||||
// .AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectParticipantsCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.ExpertLK
|
||||
{
|
||||
public class SelectUpPersonalPlanCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectPersonalPlan-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
string name = "";
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int userId = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
//@params.Message = "Выберите участника.\n";
|
||||
|
||||
|
||||
var user = db.Users.Single(usr => usr.id == userId);
|
||||
int uChatId = user.chatId;
|
||||
string fio = user.fio;
|
||||
|
||||
user.personal = 1;
|
||||
db.Entry(db.PersonalConsultations.Where(el => el.chatId == uChatId)).Property("state").CurrentValue = 2;
|
||||
db.SaveChanges();
|
||||
|
||||
//SqlCommand updTag = new SqlCommand("UPDATE Users SET personal = @personal WHERE chatId = @chatId;", Con);
|
||||
//updTag.Parameters.AddWithValue("@chatId", uChatId);
|
||||
//updTag.Parameters.AddWithValue("@personal", 1);
|
||||
//updTag.ExecuteNonQuery();
|
||||
|
||||
//SqlCommand updState = new SqlCommand("UPDATE PersonalConsultation SET state = @state WHERE chatId = @chatId;", Con);
|
||||
//updState.Parameters.AddWithValue("@chatId", uChatId);
|
||||
//updState.Parameters.AddWithValue("@state", 2);
|
||||
//updState.ExecuteNonQuery();
|
||||
|
||||
@params.Message = "✅Персональный режим для участника " + fio + " включен";
|
||||
|
||||
keyboardBuilder
|
||||
//.AddButton("Вкл. персональный режим", "selectPersonalPlan-", KeyboardButtonColor.Positive)
|
||||
//.AddLine()
|
||||
.AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectUpPersonalPlanCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
SvetoforVKBot/Models/Commands/GetAskQuestionsCommand.cs
Normal file
78
SvetoforVKBot/Models/Commands/GetAskQuestionsCommand.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading;
|
||||
using System.Linq;
|
||||
using SvetoforVKBot.App_Start;
|
||||
using System.Configuration;
|
||||
|
||||
namespace SvetoforVKBot.Models.Dop
|
||||
{
|
||||
public class GetAskQuestionsCommand
|
||||
{
|
||||
private const int MODER = 59111081; //35688505; //59111081
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.tag = "Задал вопрос";
|
||||
db.SaveChanges();
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("В начало", "startPL", KeyboardButtonColor.Positive);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = "Вопрос отправлен 📩 \n" +
|
||||
"✅Ответим в течение часа";
|
||||
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.Send(@params);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
@params2.Message = "❓Вопрос. \nСсылка на диалог: " + ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).GroupDialogsLink + chatId;
|
||||
|
||||
List<long> listFrwMsg = new List<long>() { update.@object.message.id };
|
||||
@params2.UserId = MODER;
|
||||
@params2.ForwardMessages = listFrwMsg;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.Send(@params2);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetAskQuestionsCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
118
SvetoforVKBot/Models/Commands/GetPhoneRecallMeCommand.cs
Normal file
118
SvetoforVKBot/Models/Commands/GetPhoneRecallMeCommand.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using System.Threading;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Dop
|
||||
{
|
||||
public class GetPhoneRecallMeCommand
|
||||
{
|
||||
private const int MODER = 59111081;
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
int i = 0;
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
string phone = regex.Replace(update.@object.message.text, "");
|
||||
|
||||
if (phone.Length == 11)
|
||||
if (phone.StartsWith("8"))
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
|
||||
|
||||
if (jsPhones.Contains(phone))
|
||||
{
|
||||
jsPhones[jsPhones.FindIndex(p => p.Equals(phone))] = jsPhones[0];
|
||||
jsPhones[0] = phone;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsPhones.Count > 0)
|
||||
{
|
||||
for (i = jsPhones.Count; i > 0; i--)
|
||||
{
|
||||
if (i != 4)
|
||||
{
|
||||
if (i == jsPhones.Count)
|
||||
jsPhones.Add("");
|
||||
|
||||
jsPhones[i] = jsPhones[i - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
jsPhones.Add("");
|
||||
|
||||
jsPhones[0] = phone;
|
||||
}
|
||||
|
||||
user.phone = JsonConvert.SerializeObject(jsPhones);
|
||||
user.tag = "Заказ обратного звонка";
|
||||
db.SaveChanges();
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("🏠 В начало", "startPL", KeyboardButtonColor.Positive);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = "✅Спасибо за заявку! \n" +
|
||||
"\n" +
|
||||
"Менеджер перезвонит Вам в ближайшее время и ответит на Ваши вопросы.";
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
@params2.Message = "🎉Заказ обратного звонка. \n";
|
||||
|
||||
List<long> listFrwMsg = new List<long>() { update.@object.message.id };
|
||||
@params2.UserId = MODER;
|
||||
@params2.ForwardMessages = listFrwMsg;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.Send(@params2);
|
||||
}
|
||||
else
|
||||
@params.Message = "Контактный телефон в формате 89123456789 (11 цифр, без плюса и через \"8\" обязательно).";
|
||||
else
|
||||
@params.Message = "Контактный телефон в формате 89123456789 (11 цифр, без плюса и через \"8\" обязательно).";
|
||||
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetPhoneRecallMeCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Calculators
|
||||
{
|
||||
public class SelectCalcCcalResultCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectCalcCcalResult-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
int age = 0;
|
||||
int genderCoef = 0;
|
||||
double kkalResult = 0;
|
||||
double kkalResultLow = 0;
|
||||
double kkalResultHigh = 0;
|
||||
double colorPercent = 0;
|
||||
double dayCoef = 0;
|
||||
double curDayKkal = 0;
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curColor = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
Dictionary<int, string> days = new Dictionary<int, string>(7);
|
||||
days.Add(1, "Понедельник");
|
||||
days.Add(2, "Вторник");
|
||||
days.Add(3, "Среда");
|
||||
days.Add(4, "Четверг");
|
||||
days.Add(5, "Пятница");
|
||||
days.Add(6, "Суббота");
|
||||
days.Add(7, "Воскресенье");
|
||||
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
List<int> sportDays = JsonConvert.DeserializeObject<List<int>>(user.sportDays);
|
||||
|
||||
string cons = "✅Прошёл консультацию";
|
||||
|
||||
if ((DateTime.Now.Month >= user.birthday.Month) && (DateTime.Now.Day >= user.birthday.Day))
|
||||
age = DateTime.Now.Year - user.birthday.Year;
|
||||
else
|
||||
age = DateTime.Now.Year - user.birthday.Year - 1;
|
||||
|
||||
if (user.weight == 0 || user.height == 0)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("📝Редактировать данные", "selectEditData-0", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Message = "Для подсчёта калорий не хватает данных о росте/весе.\n" +
|
||||
"Нажмите \"📝Редактировать данные\" и заполните показатели.";
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (user.gender == 1)
|
||||
{
|
||||
genderCoef = 5;
|
||||
//cons = "✅Прошёл консультацию";
|
||||
}
|
||||
else
|
||||
{
|
||||
genderCoef = -161;
|
||||
//cons = "✅Прошла консультацию";
|
||||
}
|
||||
switch (user.track)
|
||||
{
|
||||
case 1: //не изменяя веса
|
||||
colorPercent = 1;
|
||||
break;
|
||||
case 2:
|
||||
colorPercent = 0.75; //1 - 15%
|
||||
break;
|
||||
case 3:
|
||||
colorPercent = 1.2; //1 - 15%
|
||||
break;
|
||||
default:
|
||||
colorPercent = 1;
|
||||
break;
|
||||
}
|
||||
@params.Message = "Ваш результат:\n\n";
|
||||
|
||||
for (int i = 1; i <= 7; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 2:
|
||||
dayCoef = 0.8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dayCoef = 1.2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dayCoef = 0.9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
dayCoef = 1.1;
|
||||
break;
|
||||
|
||||
default:
|
||||
dayCoef = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
kkalResult = Math.Round((((10 * user.weight) + (6.25 * user.height) - (5 * age) + genderCoef) * user.activityCoef) * colorPercent * dayCoef);
|
||||
kkalResultHigh = Math.Round(kkalResult * 1.2);
|
||||
kkalResultLow = Math.Round(kkalResult * 0.9);
|
||||
|
||||
if (i == curDay)
|
||||
{
|
||||
@params.Message += $"⭐ {days[i]}: {kkalResultLow}-{kkalResultHigh} ккал\n";
|
||||
curDayKkal = kkalResult;
|
||||
}
|
||||
else
|
||||
@params.Message += $"{days[i]}: {kkalResultLow}-{kkalResultHigh} ккал\n";
|
||||
}
|
||||
//kkalResult = Math.Round((((10 * weight) + (6.25 * height) - (5 * age) + genderCoef) * activityCoef) * colorPercent);
|
||||
|
||||
keyboardBuilder.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
user.kkal = Convert.ToInt32(curDayKkal);
|
||||
db.SaveChanges();
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectCalcCcalResultCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Calculators
|
||||
{
|
||||
public class SelectCalculatorCcalCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectCalculatorCcal\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
@params.Message = "🚦Выберите на клавиатуре комфортный для Вас режим сохранения/потери веса.\n";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("🟥Не изменяя вес", "selectCalcCcalResult-1", KeyboardButtonColor.Primary) //К
|
||||
.AddLine()
|
||||
.AddButton("🟨Снижение веса", "selectCalcCcalResult-2", KeyboardButtonColor.Primary) //Ж
|
||||
.AddLine()
|
||||
.AddButton("🟩Быстрое снижение веса", "selectCalcCcalResult-3", KeyboardButtonColor.Primary) //З
|
||||
.AddLine()
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectCalculatorCcalCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Calculators
|
||||
{
|
||||
public class SelectIdealWeightCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectIdealWeight\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
double indexMT = 23;
|
||||
double indexMTLow = 18.5;
|
||||
double indexMTHigh = 25;
|
||||
string IMT = "";
|
||||
double idealWeight = 0;
|
||||
double normWeightLow = 0;
|
||||
double normWeightHigh = 0;
|
||||
int age = 0;
|
||||
try
|
||||
{
|
||||
Data.Users user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
|
||||
age = DateTime.Today.Year - user.birthday.Year;
|
||||
|
||||
idealWeight = Math.Round(indexMT * user.height / 100.0 * user.height / 100.0, 1);
|
||||
normWeightLow = Math.Round(indexMTLow * user.height / 100.0 * user.height / 100.0, 1);
|
||||
normWeightHigh = Math.Round(indexMTHigh * user.height / 100.0 * user.height / 100.0, 1);
|
||||
//indexMT = Math.Round(weight / (double)(height / 100.0 * height / 100.0), 1);
|
||||
@params.Message = "⭐Ваш идеальный вес: " + idealWeight + " кг.\n" +
|
||||
"✅Диапазон нормального веса: " + normWeightLow + " - " + normWeightHigh + " кг.\n\n" +
|
||||
"Идеальный для здоровья вес рассчитывается, исходя из ИМТ равного 23.";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectIdealWeightCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
163
SvetoforVKBot/Models/Commands/LK/Cart/SelectAddToCartCommand.cs
Normal file
163
SvetoforVKBot/Models/Commands/LK/Cart/SelectAddToCartCommand.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectAddToCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectAddToCart-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
double sum = 0;
|
||||
string backPL = "startPL";
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
List<ProductsDostavka> souses = new List<ProductsDostavka>();
|
||||
ShowPersonalMenuCarusel showProductCaruselMain = new ShowPersonalMenuCarusel();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
int kkals = 0;
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curCategory = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
int curProduct = Convert.ToInt32(regex.Replace(payload[2], ""));
|
||||
int curDayKkal = Convert.ToInt32(regex.Replace(payload[3], ""));
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
var prodDb = db.ProductsDostavkas.Where(p =>
|
||||
p.id == curProduct &&
|
||||
JsonConvert.DeserializeObject<List<int>>(p.weekDays).Exists(e => e == curDay));
|
||||
products = prodDb.ToList().ConvertAll<ProductsDostavka>(el => new ProductsDostavka()
|
||||
{
|
||||
id = el.id,
|
||||
idIiko = el.idIiko,
|
||||
article = el.article,
|
||||
categoryId = el.categoryId,
|
||||
name = el.name,
|
||||
fullName = el.fullName,
|
||||
description = el.description,
|
||||
price = Convert.ToDouble( el.price),
|
||||
photo = el.photo,
|
||||
additions = JsonConvert.DeserializeObject<List<string>>(el.additions),
|
||||
recommends = JsonConvert.DeserializeObject<List<string>>(el.recommends),
|
||||
kkal = el.kkal,
|
||||
});
|
||||
|
||||
var orderPizza = new Order();
|
||||
var orderSous = new Order();
|
||||
if (cartObject.orders.Exists(o => o.id.Equals(curCategory + "-" + curProduct)))
|
||||
cartObject.orders.Find(o => o.id.Equals(curCategory + "-" + curProduct)).number++;
|
||||
else
|
||||
{
|
||||
var order = new Order()
|
||||
{
|
||||
id = curCategory + "-" + curProduct,
|
||||
idIiko = products[0].idIiko,
|
||||
fullname = products[0].fullName,
|
||||
name = products[0].name,
|
||||
price = products[0].price,
|
||||
number = 1,
|
||||
article = products[0].article,
|
||||
kkal = products[0].kkal,
|
||||
};
|
||||
cartObject.orders.Add(order);
|
||||
|
||||
}
|
||||
|
||||
user.cart = JsonConvert.SerializeObject(cartObject);
|
||||
db.SaveChanges();
|
||||
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sum += o.price * o.number;
|
||||
kkals += o.kkal * o.number;
|
||||
}
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton($"Завтрак (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-1-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Обед (до {Math.Round(curDayKkal * 1.2 * 0.4)} ккал)", "selectPersonalMenu-2-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Перекус (до {Math.Round(curDayKkal * 1.2 * 0.1)} ккал)", "selectPersonalMenu-3-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Ужин (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-4-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine();
|
||||
|
||||
if (cartObject.orders.Count > 0)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default)
|
||||
.AddButton("Корзина: " + sum + " р", "selectCart-0", KeyboardButtonColor.Negative);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
}
|
||||
if (update.@object.client_info.carousel == true)
|
||||
{
|
||||
msg = "✅ " + products.Find(p => p.id == curProduct).fullName + " добавлен в корзину.";
|
||||
|
||||
}
|
||||
|
||||
//@params.Template = templateBuilder.Build();
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = msg;
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
//else
|
||||
//{
|
||||
// switch (curCategory)
|
||||
// {
|
||||
// case 1:
|
||||
// if (update.@object.client_info.carousel == true)
|
||||
// showProductCaruselDouble.Execute(update, client, Con, curCategory, curProduct);
|
||||
// else
|
||||
// showProductDouble.Execute(update, client, Con, curCategory, curProduct, 2);
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// if (update.@object.client_info.carousel == true)
|
||||
// showProductCaruselMain.Execute(update, client, Con, curCategory, curProduct, 1);
|
||||
// else
|
||||
// showProductMain.Execute(update, client, Con, curCategory, curProduct, 0, 2);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectAddToCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
SvetoforVKBot/Models/Commands/LK/Cart/SelectCartCommand.cs
Normal file
49
SvetoforVKBot/Models/Commands/LK/Cart/SelectCartCommand.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using SvetoforVKBot.Models.Commands.LK.Cart;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model;
|
||||
using VkNet.Model.RequestParams;
|
||||
using Newtonsoft.Json;
|
||||
using VkNet.Model.Keyboard;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectCart-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db){ }
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
List<Button> buttons = new List<Button>();
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curCart = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
ShowCart showCart = new ShowCart();
|
||||
showCart.Execute(update, client, db, curCart);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu.Products;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectConfirmClearCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectConfirmClearCart\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var jsCart = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
jsCart.orders.RemoveAll(o => o.id.StartsWith("0-") == false);
|
||||
user.cart = JsonConvert.SerializeObject(jsCart);
|
||||
db.SaveChanges();
|
||||
|
||||
msg = "✅Корзина очищена.\nВозвращаю в Личный кабинет.\n";
|
||||
|
||||
ShowLKCommand showLK = new ShowLKCommand();
|
||||
showLK.Execute(update, client, db);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectConfirmClearCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Commands.LK.Cart;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu.Products;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectEditCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectEditCart-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
string msg = "";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int action = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
int curCart = Convert.ToInt32(regex.Replace(payload[2], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
|
||||
if (cartObject.orders[curCart].id.StartsWith("0-")) return;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 1: // -
|
||||
if (cartObject.orders[curCart].number == 1)
|
||||
cartObject.orders.RemoveAt(curCart);
|
||||
else
|
||||
cartObject.orders[curCart].number--;
|
||||
break;
|
||||
case 2: // +
|
||||
cartObject.orders[curCart].number++;
|
||||
break;
|
||||
};
|
||||
|
||||
if (action > 2)
|
||||
{
|
||||
int count = action - 3;
|
||||
if (count == 0)
|
||||
cartObject.orders.RemoveAt(curCart);
|
||||
else
|
||||
cartObject.orders[curCart].number = count;
|
||||
}
|
||||
|
||||
user.cart = JsonConvert.SerializeObject(cartObject);
|
||||
db.SaveChanges();
|
||||
|
||||
if (cartObject.orders.Count > 0)
|
||||
{
|
||||
if (curCart >= cartObject.orders.Count)
|
||||
curCart = cartObject.orders.Count - 1;
|
||||
ShowCart showCart = new ShowCart();
|
||||
showCart.Execute(update, client, db, curCart);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "Корзина оказалась пустой. \n" +
|
||||
"\n" +
|
||||
"Возвращаю в Личный кабинет";
|
||||
ShowLKCommand showLK = new ShowLKCommand();
|
||||
showLK.Execute(update, client, db);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectEditCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
192
SvetoforVKBot/Models/Commands/LK/Cart/ShowCart.cs
Normal file
192
SvetoforVKBot/Models/Commands/LK/Cart/ShowCart.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class ShowCart
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db, int curCart) //curCart - порядковый номер в массиве корзины
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
int cartCount = 0;
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
//string voronka = "";
|
||||
List<CategoriesDostavka> categories = new List<CategoriesDostavka>();
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int prevCart = 0, nextCart = 0;
|
||||
double sum = 0;
|
||||
double fullSum = 0;
|
||||
string label = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
int kkals = 0;
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
|
||||
//SqlCommand getCart = new SqlCommand("SELECT cart, voronka FROM Users WHERE chatId = @chatId;", Con);
|
||||
//getCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCart = getCart.ExecuteReader();
|
||||
//rgetCart.Read();
|
||||
//var cartObject = JsonConvert.DeserializeObject<CartObject>(rgetCart["cart"].ToString());
|
||||
//voronka = rgetCart["voronka"].ToString();
|
||||
//rgetCart.Close();
|
||||
|
||||
//cartObject.orders.RemoveAll(o => o.article.StartsWith("00-"));
|
||||
cartObject.dostavkaCost = 100;
|
||||
|
||||
//if (cartObject.orders.Count == 0)
|
||||
//{
|
||||
// msg = "Корзина пуста.\n📋Возвращаю в основное меню";
|
||||
// ShowMenuDostavka showMenuDostavka = new ShowMenuDostavka();
|
||||
// showMenuDostavka.Execute(update, client, Con, msg, 1, 0);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (curCart >= cartObject.orders.Count)
|
||||
{
|
||||
curCart = cartObject.orders.Count - 1;
|
||||
prevCart = curCart - 1;
|
||||
nextCart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevCart = curCart - 1;
|
||||
nextCart = curCart + 1;
|
||||
}
|
||||
if ((curCart + 1) == cartObject.orders.Count)
|
||||
{
|
||||
prevCart = curCart - 1;
|
||||
nextCart = 0;
|
||||
}
|
||||
if (curCart == 0)
|
||||
{
|
||||
prevCart = cartObject.orders.Count - 1;
|
||||
nextCart = curCart + 1;
|
||||
}
|
||||
string promo = "";
|
||||
msg = "Ваша корзина: \n";
|
||||
|
||||
double sumCheck = 0;
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sumCheck += o.price * o.number;
|
||||
}
|
||||
|
||||
for (i = 0; i < cartObject.orders.Count; i++)
|
||||
{
|
||||
cartCount++;
|
||||
switch (cartObject.orders[i].id)
|
||||
{
|
||||
|
||||
default:
|
||||
msg += (i + 1).ToString() + ". " +
|
||||
cartObject.orders[i].fullname + " - " + cartObject.orders[i].kkal + " ккал. " +
|
||||
cartObject.orders[i].number + " шт. " +
|
||||
(cartObject.orders[i].price * cartObject.orders[i].number).ToString() + " ₽ \n";
|
||||
sum += cartObject.orders[i].price * cartObject.orders[i].number;
|
||||
kkals += cartObject.orders[i].kkal * cartObject.orders[i].number;
|
||||
break;
|
||||
}
|
||||
//msg += (i + 1).ToString() + ". " +
|
||||
// cartObject.orders[i].fullname + " - " +
|
||||
// cartObject.orders[i].number + " шт. " +
|
||||
// (cartObject.orders[i].price * cartObject.orders[i].number).ToString() + " ₽ \n";
|
||||
|
||||
|
||||
/*cartCount++;
|
||||
for (j = 0; j < cartObject.orders.Count; j++)
|
||||
{
|
||||
msg += " " + cartCount.ToString() + "." + (j + 1).ToString() + " Доп - " +
|
||||
cartObject.orders[i].addition[j].fullname + " - " +
|
||||
cartObject.orders[i].addition[j].number + " шт. " +
|
||||
(cartObject.orders[i].addition[j].price * cartObject.orders[i].addition[j].number).ToString() + " ₽ \n";
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
fullSum = sum;
|
||||
|
||||
user.cart = JsonConvert.SerializeObject(cartObject);
|
||||
db.SaveChanges();
|
||||
|
||||
//SqlCommand updCart = new SqlCommand("UPDATE Users SET cart = @cart WHERE chatId = @chatId;", Con);
|
||||
//updCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
//updCart.Parameters.AddWithValue("@cart", JsonConvert.SerializeObject(cartObject));
|
||||
//updCart.ExecuteNonQuery();
|
||||
|
||||
msg += "\n" +
|
||||
"Итого: " + fullSum + " ₽ | " + kkals + " ккал.";
|
||||
|
||||
label = cartObject.orders[curCart].name + " " +
|
||||
cartObject.orders[curCart].price + " ₽ * " +
|
||||
cartObject.orders[curCart].number + " = " +
|
||||
(cartObject.orders[curCart].price * cartObject.orders[curCart].number).ToString() + " ₽";
|
||||
|
||||
if (label.Length > 40)
|
||||
label = cartObject.orders[curCart].name + " " +
|
||||
(cartObject.orders[curCart].price * cartObject.orders[curCart].number).ToString() + " ₽";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton(label, "selectCart-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("-", "selectEditCart-1-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton(cartObject.orders[curCart].number + " шт", "selectCartCount-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton("+", "selectEditCart-2-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton("🗑Очистить", "selectConfirmClearCart", KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("<<", "selectCart-" + prevCart, KeyboardButtonColor.Primary)
|
||||
.AddButton((curCart + 1).ToString() + "/" + cartObject.orders.Count, "selectCart-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton(">>", "selectCart-" + nextCart, KeyboardButtonColor.Primary);
|
||||
|
||||
keyboardBuilder
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
|
||||
@params.Message = msg;
|
||||
@params.UserId = chatId;
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.DontParseLinks = true;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ShowCart: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using SvetoforVKBot.App_Start;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Consultation
|
||||
{
|
||||
public class GetConsultationCommand
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
if (update.@object.message.text.Length > 0)
|
||||
{
|
||||
var ids = new long[] { chatId };
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.question = update.@object.message.text.Trim();
|
||||
user.tag = "Личный кабинет";
|
||||
db.SaveChanges();
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = "✅Вопрос принят. Менеджер ответит Вам в ближайшее время!\n";
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
@params2.Message = "❓Вопрос. \nСсылка на диалог: " + ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).GroupDialogsLink + chatId;
|
||||
|
||||
List<long> listFrwMsg = new List<long>() { update.@object.message.id };
|
||||
@params2.PeerId = 2000000002;
|
||||
//@params2.UserId = 59111081;
|
||||
@params2.ForwardMessages = listFrwMsg;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.Send(@params2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.Message = "Не распознал сообщение 😕 Попробуйте, пожалуйста, ещё раз";
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetReportCommentCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Consultation
|
||||
{
|
||||
public class SelectConsultationCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectConsultation\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.tag = "Консультация - Вопрос";
|
||||
db.SaveChanges();
|
||||
|
||||
@params.Message = //"Вы можете записаться на онлайн-консультацию к специалисту.\n" +
|
||||
"Напишите свой вопрос сюда одним сообщением. " + //Это будет служить Вашей заявкой.\n" +
|
||||
"Менеджер свяжется с Вами для ответа и уточнения информации."; //"Мы оповестим Вас о ближайшей консультации, к которой Вы сможете присоединиться.\n\n";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectExpertLKCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Consultation
|
||||
{
|
||||
public class SelectLiveConsultationCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectLiveConsultation\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
@params.Message = "-----Информация о приёме на консультации.-----\n\n" +
|
||||
"Вы можете оформить заявку на запись. Для этого нажмите кнопку \"Оставить заявку\".\n" +
|
||||
"Ваши данные будут отправлены менеджеру, с Вами свяжутся для уточнения даты и времени консультации.";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Оставить заявку", "selectSubmitConsultation", KeyboardButtonColor.Positive) //К
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в selectLiveConsultation: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Consultation
|
||||
{
|
||||
public class SelectMoreAboutSpecCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectMoreAboutSpec\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
//{"id": 457239276, "owner_id": -194717824, "access_key": "3f83861845f644622f"}
|
||||
|
||||
List<MediaAttachment> listPhoto = new List<MediaAttachment>()
|
||||
{
|
||||
new VkNet.Model.Attachments.Photo() { Id = 457239276, OwnerId = -194717824, AccessKey = "3f83861845f644622f"}
|
||||
};
|
||||
|
||||
@params.Message =
|
||||
"📌Кадочникова Наталья Ивановна\n" +
|
||||
"Кандидат биологических наук, доцент кафедры медико-биологических дисциплин факультета физической культуры и спорта ВятГУ." +
|
||||
"\n\n" +
|
||||
"⭐Стаж работы более 20 лет, автор более 100 научных публикаций в области физиологии." +
|
||||
"\n\n" +
|
||||
"⭐Участник Международных и Всероссийских научно-практических конференций по спортивной науке." +
|
||||
"\n\n" +
|
||||
"🎓Прошла обучение по программам:" +
|
||||
"\n" +
|
||||
"✅По использованию анализатора состава тела АВС-01 «Медасс» в практике спортивной медицины " +
|
||||
"и реабилитологии (г. Москва АО НТЦ «Медасс», март 2016)" +
|
||||
"\n\n" +
|
||||
"✅«Оптимальное питание» (г. Москва, ФНМО РУДН, март 2019)" +
|
||||
"\n\n" +
|
||||
"✅«Питание в фитнесе» (г. Москва, ФНМО РУДН, апрель 2019)" +
|
||||
"\n\n" +
|
||||
"✅ «Современное диетическое и персонализированное питание» (г. Москва, МГУТУ им. К.Г. Разумовского, март 2021)." +
|
||||
"\n\n";
|
||||
|
||||
|
||||
@params.Message += "📍Консультации проводятся по субботам по адресу: г. Киров, ул. Молодой Гвардии, д.13.\n" +
|
||||
"☎Тел. 70-81-22.\n" +
|
||||
"Стоимость и условия по телефону.";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Оставить заявку", "selectSubmitConsultation", KeyboardButtonColor.Positive) //К
|
||||
.AddLine()
|
||||
.AddButton("Назад", "selectTrack-4", KeyboardButtonColor.Default);
|
||||
@params.Attachments = listPhoto;
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectMoreAboutSpecCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Linq;
|
||||
using System.Configuration;
|
||||
using SvetoforVKBot.App_Start;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Consultation
|
||||
{
|
||||
public class SelectSubmitConsultationCommand : Command
|
||||
{
|
||||
public const int MODER = 59111081;
|
||||
public override string Name => "{\"button\":\"selectSubmitConsultation\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
string msg = "";
|
||||
DateTime dt = DateTime.Now;
|
||||
string msgManager = "";
|
||||
List<int> ids = new List<int>();
|
||||
try
|
||||
{
|
||||
if (db.PersonalConsultations.Where(c => c.chatId == chatId).Count() > 0)
|
||||
{
|
||||
@params.Message = "Ваша заявка уже на рассмотрении. Чтобы вернуться назад, нажмите кнопку \"Личный кабинет\".";
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Positive);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return;
|
||||
}
|
||||
|
||||
//https://vk.com/doc59111081_594730049
|
||||
List<MediaAttachment> listDoc = new List<MediaAttachment>()
|
||||
{
|
||||
new Document() { Id = 594730049, OwnerId = 59111081 }
|
||||
};
|
||||
|
||||
|
||||
db.PersonalConsultations.Add(new Data.PersonalConsultation()
|
||||
{
|
||||
chatId = chatId,
|
||||
datetime = dt,
|
||||
state = 1,
|
||||
});
|
||||
db.SaveChanges();
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
|
||||
@params.Message = "📌Ваша заявка:\n\n";
|
||||
|
||||
msg = "ФИО: " + user.fio +
|
||||
"\n" +
|
||||
"Телефон: " + jsPhones[0] +
|
||||
"\n" +
|
||||
"Дата рождения: " + user.birthday.ToShortDateString() +
|
||||
"\n\n" +
|
||||
"Дата заявки: " + dt.ToString("dd.MM.yyyy HH:mm");
|
||||
|
||||
@params.Message += msg +
|
||||
"\n\n" +
|
||||
"Заявка отправлена! Менеджер свяжется с Вами в ближайшее время. Чтобы вернуться назад, нажмите кнопку \"Личный кабинет\".\n\n" +
|
||||
"Квитанция на оплату 👇🏻";
|
||||
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Positive);
|
||||
@params.Attachments = listDoc;
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
@params2.Message = "✅Новая заявка на консультацию:\n\n" +
|
||||
"ФИО: " + user.fio +
|
||||
"\n" +
|
||||
"Телефон: " + jsPhones[0] +
|
||||
"\n" +
|
||||
"Дата рождения: " + user.birthday.ToShortDateString() +
|
||||
"\n" +
|
||||
"Рост: " + user.height +
|
||||
"\n" +
|
||||
"Вес: " + user.weight +
|
||||
"\n\n" +
|
||||
"Дата заявки: " + dt.ToString("dd.MM.yyyy HH:mm") +
|
||||
"\n" +
|
||||
"Диалог с пользователем: " + ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).GroupDialogsLink + chatId;
|
||||
//https://vk.com/gim194717824?sel=
|
||||
@params2.PeerId = 2000000002;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params2);
|
||||
|
||||
Thread.Sleep(1500);
|
||||
|
||||
ids = db.PersonalConsultations.Where(c => c.state == 2).ToList().ConvertAll<int>(el => el.chatId);
|
||||
|
||||
string strIds = "Участники, записавшиеся на консультацию:\n";
|
||||
|
||||
if (ids.Count >= 6)
|
||||
{
|
||||
foreach (var id in ids)
|
||||
{
|
||||
strIds += ((WebConfiguration)ConfigurationManager.GetSection("VKApi")).GroupDialogsLink + id + " \n";
|
||||
|
||||
//Проверить как записывает
|
||||
var con = db.PersonalConsultations.Where(el => el.chatId == chatId);
|
||||
db.Entry(con).Property("state").CurrentValue = 3;
|
||||
db.SaveChanges();
|
||||
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
@params2.Message = "🔔 Набралась группа на консультацию! Оповестите их о подробностях." +
|
||||
"\n\n" +
|
||||
strIds;
|
||||
@params2.PeerId = 2000000002;
|
||||
@params2.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params2);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectSubmitConsultationCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.EditData
|
||||
{
|
||||
public class GetEditFIOCommand
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
|
||||
try
|
||||
{
|
||||
if (update.@object.message.text.Length > 0 && update.@object.message.text.Length <= 50)
|
||||
{
|
||||
var ids = new long[] { chatId };
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.fio = update.@object.message.text.Trim();
|
||||
user.tag = "Личный кабинет - Данные";
|
||||
db.SaveChanges();
|
||||
|
||||
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
|
||||
selectEditData.Execute(update, client, db);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.Message = "Данные введены некорректно 😕 Напишите, пожалуйста, текст длиной до 50 символов.";
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetEditFIOCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
111
SvetoforVKBot/Models/Commands/LK/EditData/GetEditPhoneCommand.cs
Normal file
111
SvetoforVKBot/Models/Commands/LK/EditData/GetEditPhoneCommand.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Commands.LK;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.EditData
|
||||
{
|
||||
public class GetEditPhoneCommand
|
||||
{
|
||||
public bool Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
int i = 0;
|
||||
var row = new List<MessageKeyboardButton>();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
string phone = regex.Replace(update.@object.message.text, "");
|
||||
|
||||
if (phone.Length == 11)
|
||||
if (phone.StartsWith("8") || phone.StartsWith("7"))
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
|
||||
if (jsPhones.Contains(phone))
|
||||
{
|
||||
jsPhones[jsPhones.FindIndex(p => p.Equals(phone))] = jsPhones[0];
|
||||
jsPhones[0] = phone;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsPhones.Count > 0)
|
||||
{
|
||||
for (i = jsPhones.Count; i > 0; i--)
|
||||
{
|
||||
if (i != 4)
|
||||
{
|
||||
if (i == jsPhones.Count)
|
||||
jsPhones.Add("");
|
||||
|
||||
jsPhones[i] = jsPhones[i - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
jsPhones.Add("");
|
||||
|
||||
jsPhones[0] = phone;
|
||||
}
|
||||
|
||||
user.tag = "Личный кабинет - Данные";
|
||||
user.phone = JsonConvert.SerializeObject(jsPhones);
|
||||
|
||||
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
|
||||
selectEditData.Execute(update, client, db);
|
||||
|
||||
}
|
||||
else
|
||||
@params.Message = "Контактный телефон в формате 89123456789 (11 цифр, без плюса и через \"8\" или \"7\" обязательно).";
|
||||
else
|
||||
@params.Message = "Контактный телефон в формате 89123456789 (11 цифр, без плюса и через \"8\" или \"7\" обязательно).";
|
||||
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetEditPhoneCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using Newtonsoft.Json;
|
||||
using VkNet.Enums.Filters;
|
||||
using System.Text.RegularExpressions;
|
||||
using SvetoforVKBot.Models.Commands.LK;
|
||||
using System.Collections.Generic;
|
||||
using SvetoforVKBot.Models.Commands.LK.SportsLK;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.EditData
|
||||
{
|
||||
public class SelectEditNotifyCount : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectEditNotifyCount-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
double activityCoef = 0;
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int notifyCount = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.notifyCount = notifyCount;
|
||||
user.tag = "Личный кабинет - Данные";
|
||||
db.SaveChanges();
|
||||
|
||||
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
|
||||
selectEditData.Execute(update, client, db);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectEditNotifyCountCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Commands.Registration;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.EditData
|
||||
{
|
||||
public class SelectUpdateSportDaysCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectUpdateSportDays\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
MessagesSendParams @params2 = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
string msg = "";
|
||||
DateTime dt = DateTime.Now;
|
||||
string msgManager = "";
|
||||
List<int> ids = new List<int>();
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.sportDays = "[]";
|
||||
db.SaveChanges();
|
||||
|
||||
ShowSportDays showSportDays = new ShowSportDays();
|
||||
showSportDays.Execute(update, client, db);
|
||||
return;
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectUpdateSportDaysCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
SvetoforVKBot/Models/Commands/LK/GetHeightCommand.cs
Normal file
70
SvetoforVKBot/Models/Commands/LK/GetHeightCommand.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model.Keyboard;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using SvetoforVKBot.Models.Dop;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK
|
||||
{
|
||||
public class GetHeightCommand
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
int i = 0;
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
if (int.TryParse(update.@object.message.text.Trim(), out int height))
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.height = height;
|
||||
user.tag = "Личный кабинет - Данные";
|
||||
db.SaveChanges();
|
||||
|
||||
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
|
||||
selectEditData.Execute(update, client, db);
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.UserId = chatId;
|
||||
@params.Message = "Вы некорректно ввели рост 🤔 Введите, пожалуйста, число (до 3 символов).";
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetHeightCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
76
SvetoforVKBot/Models/Commands/LK/GetWeightCommand.cs
Normal file
76
SvetoforVKBot/Models/Commands/LK/GetWeightCommand.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model.Keyboard;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using SvetoforVKBot.Models.Dop;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK
|
||||
{
|
||||
public class GetWeightCommand
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
int i = 0;
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
if (int.TryParse(update.@object.message.text.Trim(), out int weight))
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.weight = weight;
|
||||
user.tag = "Личный кабинет - Данные";
|
||||
db.SaveChanges();
|
||||
|
||||
/*SqlCommand editUser = new SqlCommand("UPDATE Users SET tag = @tag, weight = @weight WHERE chatId = @chatId;", Con);
|
||||
editUser.Parameters.AddWithValue("@chatId", chatId);
|
||||
editUser.Parameters.AddWithValue("@tag", "Личный кабинет - Данные");
|
||||
editUser.Parameters.AddWithValue("@weight", weight);
|
||||
editUser.ExecuteNonQuery();*/
|
||||
|
||||
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
|
||||
selectEditData.Execute(update, client, db);
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.UserId = chatId;
|
||||
@params.Message = "Вы некорректно ввели вес 🤔 Введите, пожалуйста, число (до 3 символов).";
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetWeightCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu.Products;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using Newtonsoft.Json;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu.Products
|
||||
{
|
||||
public class SelectProductCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectProduct-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
string voronka = "";
|
||||
double sum = 0;
|
||||
string backPL = "startPL";
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
ShowProductCaruselMain showProductCaruselMain = new ShowProductCaruselMain();
|
||||
ShowProductMain showProductMain = new ShowProductMain();
|
||||
CategoriesDostavka categories = new CategoriesDostavka();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curCategory = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
int curProduct = Convert.ToInt32(regex.Replace(payload[2], ""));
|
||||
int curWay = Convert.ToInt32(regex.Replace(payload[3], "")); //для ShowProductCaruselMain направление навигации, 1 по умолчанию
|
||||
|
||||
var cats = db.CategoriesDostavkas.Where(e => e.subMenu == curCategory);
|
||||
if(cats.Count() > 0)
|
||||
{
|
||||
ShowMenuDostavka showMenuDostavka = new ShowMenuDostavka();
|
||||
showMenuDostavka.Execute(update, client, db, msg, 2, categories.subMenu); //1
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (curCategory)
|
||||
{
|
||||
default:
|
||||
if (update.@object.client_info.carousel == true)
|
||||
showProductCaruselMain.Execute(update, client, db, curCategory, curProduct, curWay);
|
||||
else
|
||||
showProductMain.Execute(update, client, db, curCategory, curProduct, 0, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectProductCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Utils;
|
||||
using VkNet.Model.Template;
|
||||
using VkNet.Model.Template.Carousel;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu.Products
|
||||
{
|
||||
public class ShowProductCaruselMain
|
||||
{
|
||||
private const string PHOTOIDNEXT = "-194717824_457239273_446146426236760985";
|
||||
//{"id": 457239273, "owner_id": -194717824, "access_key": "446146426236760985"}
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db, int curCategory, int curProduct, int curWay)
|
||||
//curCategory - id Categories, curProduct - порядковый номер в массиве продуктов, curWay - для showProductCarusel направление навигации
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
int i = 0;
|
||||
int prevCatalog = 0, nextCatalog = 0;
|
||||
int naviState = 0;
|
||||
double sum = 0;
|
||||
string desc = "";
|
||||
//int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
//if (curDay == 0) curDay = 7;
|
||||
|
||||
List<CategoriesDostavka> categories = new List<CategoriesDostavka>();
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
var row = new List<MessageKeyboardButton>();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
TemplateBuilder templateBuilder = new TemplateBuilder();
|
||||
CarouselElementAction carouselElementAction = new CarouselElementAction();
|
||||
carouselElementAction.Type = CarouselElementActionType.OpenPhoto;
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
int curDay = user.day;
|
||||
|
||||
//SqlCommand getCart = new SqlCommand("SELECT cart, day, colorId FROM Users WHERE chatId = @chatId;", Con);
|
||||
//getCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCart = getCart.ExecuteReader();
|
||||
//rgetCart.Read();
|
||||
//var cartObject = JsonConvert.DeserializeObject<CartObject>(rgetCart["cart"].ToString());
|
||||
//int curDay = Convert.ToInt32(rgetCart["day"]);
|
||||
//int colorId = Convert.ToInt32(rgetCart["colorId"]);
|
||||
//rgetCart.Close();
|
||||
|
||||
if (curDay == 8) curDay = (int)DateTime.Now.DayOfWeek;
|
||||
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sum += o.price * o.number;
|
||||
}
|
||||
|
||||
categories = db.CategoriesDostavkas.ToList().ConvertAll<CategoriesDostavka>(c =>
|
||||
new CategoriesDostavka()
|
||||
{
|
||||
categoryId = c.categoryId,
|
||||
name = c.name,
|
||||
btnName = c.btnName,
|
||||
kbColor = c.kbColor,
|
||||
});
|
||||
|
||||
|
||||
//SqlCommand getCategories = new SqlCommand("SELECT * FROM CategoriesDostavka;", Con);
|
||||
//getCategories.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCategories = getCategories.ExecuteReader();
|
||||
//while (rgetCategories.Read())
|
||||
// categories.Add(new CategoriesDostavka()
|
||||
// {
|
||||
// categoryId = Convert.ToInt32(rgetCategories["categoryId"]),
|
||||
// name = rgetCategories["name"].ToString(),
|
||||
// btnName = rgetCategories["btnName"].ToString(),
|
||||
// kbColor = rgetCategories["kbColor"].ToString(),
|
||||
// });
|
||||
//rgetCategories.Close();
|
||||
|
||||
|
||||
products = db.ProductsDostavkas.Where(p => p.categoryId == curCategory &&
|
||||
JsonConvert.DeserializeObject<List<int>>(p.weekDays).Exists(day => day == curDay)).
|
||||
ToList().ConvertAll<ProductsDostavka>(e => new ProductsDostavka()
|
||||
{
|
||||
id = e.id,
|
||||
article = e.article,
|
||||
colorId = e.colorId,
|
||||
categoryId = e.categoryId,
|
||||
name = e.name,
|
||||
fullName = e.fullName,
|
||||
description = e.description,
|
||||
descriptionCarousel = e.descriptionCarousel,
|
||||
price = Convert.ToDouble(e.price),
|
||||
photo = e.photo,
|
||||
photoCarousel = e.photoCarousel,
|
||||
additions = JsonConvert.DeserializeObject<List<string>>(e.additions),
|
||||
recommends = JsonConvert.DeserializeObject<List<string>>(e.recommends),
|
||||
});
|
||||
|
||||
//SqlCommand getProducts = new SqlCommand("SELECT * FROM ProductsDostavka WHERE categoryId = @categoryId;", Con);
|
||||
//getProducts.Parameters.AddWithValue("@categoryId", curCategory);
|
||||
////getProducts.Parameters.AddWithValue("@colorId", colorId);
|
||||
//SqlDataReader rgetProducts = getProducts.ExecuteReader();
|
||||
//while (rgetProducts.Read())
|
||||
//{
|
||||
// var weekDays = JsonConvert.DeserializeObject<List<int>>(rgetProducts["weekDays"].ToString());
|
||||
// foreach (int weekDay in weekDays)
|
||||
// {
|
||||
// if (weekDay == curDay)
|
||||
// {
|
||||
// products.Add(new ProductsDostavka()
|
||||
// {
|
||||
// id = Convert.ToInt32(rgetProducts["id"]),
|
||||
// article = rgetProducts["article"].ToString(),
|
||||
// colorId = Convert.ToInt32(rgetProducts["colorId"]),
|
||||
// categoryId = Convert.ToInt32(rgetProducts["categoryId"]),
|
||||
// name = rgetProducts["name"].ToString(),
|
||||
// fullName = rgetProducts["fullName"].ToString(),
|
||||
// descriptionCarousel = rgetProducts["descriptionCarousel"].ToString(),
|
||||
// price = Convert.ToInt32(rgetProducts["price"]),
|
||||
// photo = rgetProducts["photo"].ToString(),
|
||||
// photoCarousel = rgetProducts["photoCarousel"].ToString(),
|
||||
// //weight = rgetProducts["weight"].ToString(),
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//rgetProducts.Close();
|
||||
|
||||
nextCatalog = curProduct + 9;
|
||||
prevCatalog = curProduct - 9;
|
||||
|
||||
if (curProduct > 0 && products.Count > 6)
|
||||
{
|
||||
if (nextCatalog > products.Count) nextCatalog = products.Count - (products.Count - curProduct);
|
||||
|
||||
if (prevCatalog < 0) prevCatalog = 0;
|
||||
}
|
||||
|
||||
for (i = curProduct; i < products.Count; i++)
|
||||
{
|
||||
var jsPhoto = JsonConvert.DeserializeObject<CatalogPhotoObject>(products[i].photoCarousel);
|
||||
|
||||
desc = products[i].descriptionCarousel; //+ " " + products[i].weight;
|
||||
if (desc.Length > 80) desc = desc.Substring(0, 77) + "..."; //desc.Substring(0, 77)
|
||||
|
||||
templateBuilder.AddTemplateElement(new CarouselElement()
|
||||
{
|
||||
Title = products[i].fullName,
|
||||
Description = desc,
|
||||
PhotoId = jsPhoto.owner_id + "_" + jsPhoto.id + "_" + jsPhoto.access_key,
|
||||
Buttons = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton(){
|
||||
Action = new MessageKeyboardButtonAction(){ Label = "Подробнее",
|
||||
Payload = "{\"button\":\"selectAddToCart-" + curCategory + "-" + i + "\"}",
|
||||
Type = KeyboardButtonActionType.Text },
|
||||
Color = KeyboardButtonColor.Default
|
||||
},
|
||||
},
|
||||
Action = carouselElementAction,
|
||||
});
|
||||
|
||||
if (templateBuilder.Elements.Count == 9 && products.Count > 10)
|
||||
break;
|
||||
}
|
||||
|
||||
if (products.Count > 10)
|
||||
{
|
||||
switch (curWay)
|
||||
{
|
||||
case 1:
|
||||
if (curProduct < (products.Count - 9))
|
||||
naviState = 1;
|
||||
else
|
||||
naviState = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (curProduct == 0)
|
||||
naviState = 1;
|
||||
else
|
||||
naviState = 2;
|
||||
break;
|
||||
default:
|
||||
naviState = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (naviState)
|
||||
{
|
||||
case 1:
|
||||
templateBuilder.AddTemplateElement(new CarouselElement()
|
||||
{
|
||||
Title = ".",
|
||||
Description = ".",
|
||||
PhotoId = PHOTOIDNEXT,
|
||||
Buttons = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){ Label = ">> Следующие " + (products.Count - nextCatalog).ToString(),
|
||||
Payload = "{\"button\":\"selectProduct-" + products[nextCatalog].categoryId + "-" + nextCatalog + "-1\"}",
|
||||
Type = KeyboardButtonActionType.Text },
|
||||
Color = KeyboardButtonColor.Primary
|
||||
},
|
||||
},
|
||||
Action = carouselElementAction,
|
||||
});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
templateBuilder.AddTemplateElement(new CarouselElement()
|
||||
{
|
||||
Title = ".",
|
||||
Description = ".",
|
||||
PhotoId = PHOTOIDNEXT,
|
||||
Buttons = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){ Label = "<< Предыдущие " + curProduct,
|
||||
Payload = "{\"button\":\"selectProduct-" + products[prevCatalog].categoryId + "-" + prevCatalog + "-2\"}",
|
||||
Type = KeyboardButtonActionType.Text },
|
||||
Color = KeyboardButtonColor.Primary
|
||||
},
|
||||
},
|
||||
Action = carouselElementAction,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@params.Template = templateBuilder.Build();
|
||||
@params.Message = "😍";
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ShowProductCaruselMain: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu.Products
|
||||
{
|
||||
public class ShowProductMain
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db, int curCategory, int curProduct, int curAddition, int plAction)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
int i = 0;
|
||||
int index = 0;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
int prevCatalog = 0, nextCatalog = 0;
|
||||
//double sumCart = 0;
|
||||
double sum = 0;
|
||||
Additions addition = new Additions();
|
||||
//DateTime startDate = new DateTime(2020, 09, 14);
|
||||
//DateTime currentDate = DateTime.Now;
|
||||
//TimeSpan offset = currentDate - startDate;
|
||||
//int curDay = offset.Days % 14 + 1;
|
||||
|
||||
string backPL = "selectMenu-0";
|
||||
|
||||
List<CategoriesDostavka> categories = new List<CategoriesDostavka>();
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
int curDay = user.day;
|
||||
|
||||
//int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
//if (curDay == 0) curDay = 7;
|
||||
|
||||
if (curDay == 8) curDay = (int)DateTime.Now.DayOfWeek;
|
||||
|
||||
/*
|
||||
* foreach (var o in cartObject.orders)
|
||||
sum += o.price * o.number;
|
||||
*/
|
||||
|
||||
|
||||
categories = db.CategoriesDostavkas.ToList().ConvertAll<CategoriesDostavka>(c =>
|
||||
new CategoriesDostavka()
|
||||
{
|
||||
categoryId = c.categoryId,
|
||||
name = c.name,
|
||||
btnName = c.btnName,
|
||||
kbColor = c.kbColor,
|
||||
});
|
||||
|
||||
|
||||
products = db.ProductsDostavkas.Where(p => p.categoryId == curCategory &&
|
||||
JsonConvert.DeserializeObject<List<int>>(p.weekDays).Exists(day => day == curDay)).
|
||||
ToList().ConvertAll<ProductsDostavka>(e => new ProductsDostavka()
|
||||
{
|
||||
id = e.id,
|
||||
article = e.article,
|
||||
colorId = e.colorId,
|
||||
categoryId = e.categoryId,
|
||||
name = e.name,
|
||||
fullName = e.fullName,
|
||||
description = e.description,
|
||||
descriptionCarousel = e.descriptionCarousel,
|
||||
price = Convert.ToDouble(e.price),
|
||||
photo = e.photo,
|
||||
photoCarousel = e.photoCarousel,
|
||||
additions = JsonConvert.DeserializeObject<List<string>>(e.additions),
|
||||
recommends = JsonConvert.DeserializeObject<List<string>>(e.recommends),
|
||||
});
|
||||
|
||||
|
||||
switch (plAction)
|
||||
{
|
||||
case 1:
|
||||
var jsPhoto = JsonConvert.DeserializeObject<CatalogPhotoObject>(products[curProduct].photo);
|
||||
List<MediaAttachment> listPhoto = new List<MediaAttachment>()
|
||||
{
|
||||
new VkNet.Model.Attachments.Photo() { Id = jsPhoto.id, OwnerId = jsPhoto.owner_id, AccessKey = jsPhoto.access_key}
|
||||
};
|
||||
@params.Attachments = listPhoto;
|
||||
@params.Message = products[curProduct].fullName + "\n" +
|
||||
products[curProduct].description + "\n"; // + " " + products[curProduct].weight
|
||||
break;
|
||||
case 2:
|
||||
if (curAddition == 0)
|
||||
@params.Message = "✅ " + products[curProduct].fullName + " добавлен в корзину.";
|
||||
else
|
||||
{
|
||||
// Нет таблицы с модификаторами
|
||||
|
||||
//SqlCommand getAddition = new SqlCommand("SELECT * FROM Modifiers WHERE article = @article;", Con);
|
||||
//getAddition.Parameters.AddWithValue("@article", curAddition);
|
||||
//SqlDataReader rgetAddition = getAddition.ExecuteReader();
|
||||
//if (rgetAddition.HasRows)
|
||||
//{
|
||||
// rgetAddition.Read();
|
||||
// addition = new Additions()
|
||||
// {
|
||||
// name = rgetAddition["name"].ToString(),
|
||||
// price = Convert.ToInt32(rgetAddition["price"]),
|
||||
// fullName = rgetAddition["fullName"].ToString(),
|
||||
// article = rgetAddition["article"].ToString(),
|
||||
// };
|
||||
//}
|
||||
//rgetAddition.Close();
|
||||
|
||||
@params.Message = "✅ " + products[curProduct].fullName + " с " + addition.fullName + " добавлен в корзину.";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (curProduct >= products.Count)
|
||||
{
|
||||
curProduct = products.Count - 1;
|
||||
prevCatalog = curProduct - 1;
|
||||
nextCatalog = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevCatalog = curProduct - 1;
|
||||
nextCatalog = curProduct + 1;
|
||||
}
|
||||
|
||||
if ((curProduct + 1) == products.Count)
|
||||
{
|
||||
prevCatalog = curProduct - 1;
|
||||
nextCatalog = 0;
|
||||
}
|
||||
if (curProduct == 0)
|
||||
{
|
||||
prevCatalog = products.Count - 1;
|
||||
nextCatalog = curProduct + 1;
|
||||
}
|
||||
if (products.Count == 1)
|
||||
{
|
||||
prevCatalog = 0;
|
||||
nextCatalog = 0;
|
||||
}
|
||||
|
||||
#region keyboard
|
||||
//keyboardBuilder
|
||||
// .AddButton("Подробнее", "selectAddToCart-" + curCategory + "-" + curProduct, KeyboardButtonColor.Primary)
|
||||
// .AddLine();
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("<<", "selectProduct-" + curCategory + "-" + prevCatalog + "-1", KeyboardButtonColor.Primary)
|
||||
.AddButton((curProduct + 1) + "/" + products.Count, "selectProduct-" + curCategory + "-" + curProduct + "-1", KeyboardButtonColor.Default)
|
||||
.AddButton(">>", "selectProduct-" + curCategory + "-" + nextCatalog + "-1", KeyboardButtonColor.Primary)
|
||||
.AddLine();
|
||||
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Вернуться в меню", "selectDayMenu-" + curDay, KeyboardButtonColor.Default)
|
||||
//.AddButton("Корзина: " + sum + " р", "selectCart-0", KeyboardButtonColor.Negative)
|
||||
.AddLine()
|
||||
.AddButton("День недели", "selectMenu-0", KeyboardButtonColor.Default);
|
||||
//.AddLine();
|
||||
|
||||
|
||||
#endregion keyboard
|
||||
/*
|
||||
if (products.Count > 10) //14
|
||||
{
|
||||
if (curProduct < (products.Count - 10)) index = curProduct + 1;
|
||||
else index = products.Count - 10;
|
||||
}
|
||||
else index = 0;
|
||||
|
||||
int rowCount = 3;
|
||||
|
||||
for (i = index; i < products.Count; i += 2)
|
||||
{
|
||||
if (i + 1 < products.Count)
|
||||
keyboardBuilder
|
||||
.AddButton(products[i].name, "selectProduct-" + curCategory + "-" + i.ToString() + "-1", KeyboardButtonColor.Default)
|
||||
.AddButton(products[i + 1].name, "selectProduct-" + curCategory + "-" + (i + 1).ToString() + "-1", KeyboardButtonColor.Default)
|
||||
.AddLine();
|
||||
else
|
||||
keyboardBuilder
|
||||
.AddButton(products[i].name, "selectProduct-" + curCategory + "-" + i.ToString() + "-1", KeyboardButtonColor.Default)
|
||||
.AddLine();
|
||||
rowCount += 1;
|
||||
|
||||
if (rowCount == 8) break;
|
||||
}
|
||||
*/
|
||||
|
||||
@params.UserId = chatId;
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ShowProductMain: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
SvetoforVKBot/Models/Commands/LK/Menu/SelectColorCommand.cs
Normal file
60
SvetoforVKBot/Models/Commands/LK/Menu/SelectColorCommand.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu
|
||||
{
|
||||
public class SelectColorCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectColor-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<Data.Svetofor> categories = new List<Data.Svetofor>();
|
||||
var row = new List<MessageKeyboardButton>();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
var kbColor = KeyboardButtonColor.Positive;
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int colorId = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.colorId = colorId;
|
||||
db.SaveChanges();
|
||||
|
||||
msg = "📋Основное меню\n";
|
||||
|
||||
ShowMenuDostavka showMenuDostavka = new ShowMenuDostavka();
|
||||
showMenuDostavka.Execute(update, client, db, msg, 2, 0);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectColorCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu
|
||||
{
|
||||
public class SelectDayMenuCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectDayMenu-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
List<Data.Svetofor> categories = new List<Data.Svetofor>();
|
||||
var row = new List<MessageKeyboardButton>();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
var kbColor = KeyboardButtonColor.Positive;
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curDay = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.tag = "Меню";
|
||||
user.day = curDay;
|
||||
db.SaveChanges();
|
||||
|
||||
keyboardBuilder.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
msg = "📋Основное меню\n";
|
||||
|
||||
ShowMenuDostavka showMenuDostavka = new ShowMenuDostavka();
|
||||
showMenuDostavka.Execute(update, client, db, msg, 2, 0);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectDayMenuCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
65
SvetoforVKBot/Models/Commands/LK/Menu/SelectMenuCommand.cs
Normal file
65
SvetoforVKBot/Models/Commands/LK/Menu/SelectMenuCommand.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu
|
||||
{
|
||||
public class SelectMenuCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectMenu-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curSubMenu = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
@params.Message = "📅На какой день показать меню? Выберите на клавиатуре\n";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Сегодня", "selectDayMenu-8", KeyboardButtonColor.Positive)
|
||||
.AddLine()
|
||||
.AddButton("Пн", "selectDayMenu-1", KeyboardButtonColor.Primary)
|
||||
.AddButton("Вт", "selectDayMenu-2", KeyboardButtonColor.Primary)
|
||||
.AddButton("Ср", "selectDayMenu-3", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Чт", "selectDayMenu-4", KeyboardButtonColor.Primary)
|
||||
.AddButton("Пт", "selectDayMenu-5", KeyboardButtonColor.Primary)
|
||||
.AddButton("Сб", "selectDayMenu-6", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
//ShowMenuDostavka showMenuDostavka = new ShowMenuDostavka();
|
||||
//showMenuDostavka.Execute(update, client, Con, msg, 2, curSubMenu);
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectMenuCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu
|
||||
{
|
||||
public class SelectPersonalMenuCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectPersonalMenu-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
double sum = 0;
|
||||
string backPL = "startPL";
|
||||
int kkals = 0;
|
||||
|
||||
try
|
||||
{
|
||||
switch (DateTime.Now.DayOfWeek)
|
||||
{
|
||||
case DayOfWeek.Saturday:
|
||||
case DayOfWeek.Sunday:
|
||||
keyboardBuilder
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
@params.Message = "Рекомендации по дневному меню доступны с понедельника по пятницу.\n" +
|
||||
"Чтобы вернуться в Личный кабинет, нажмите кнопку \"Назад\"";
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return;
|
||||
}
|
||||
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int foodType = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
int curDayKkal = Convert.ToInt32(regex.Replace(payload[2], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sum += o.price * o.number;
|
||||
kkals += o.kkal * o.number;
|
||||
}
|
||||
|
||||
//keyboardBuilder
|
||||
// .AddButton($"Завтрак (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-1-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
// .AddLine()
|
||||
// .AddButton($"Обед (до {Math.Round(curDayKkal * 1.2 * 0.4)} ккал)", "selectPersonalMenu-2-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
// .AddLine()
|
||||
// .AddButton($"Перекус (до {Math.Round(curDayKkal * 1.2 * 0.1)} ккал)", "selectPersonalMenu-3-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
// .AddLine()
|
||||
// .AddButton($"Ужин (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-4-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
// .AddLine();
|
||||
|
||||
//if (cartObject.orders.Count > 0)
|
||||
//{
|
||||
// keyboardBuilder
|
||||
// .AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default)
|
||||
// .AddButton("Корзина: " + sum + " р", "selectCart-0", KeyboardButtonColor.Negative);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// keyboardBuilder
|
||||
// .AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
//}
|
||||
|
||||
////@params.Template = templateBuilder.Build();
|
||||
//@params.Keyboard = keyboardBuilder.Build();
|
||||
//@params.Message = "Если хотите подобрать блюда ещё раз, нажмите кнопку повторно😉";
|
||||
//@params.UserId = chatId;
|
||||
//@params.RandomId = GetRandomId();
|
||||
//client.Messages.SendAsync(@params);
|
||||
|
||||
ShowPersonalMenuCarusel showPersonalMenu = new ShowPersonalMenuCarusel();
|
||||
showPersonalMenu.Execute(update, client, db, foodType, 0, 1, curDayKkal);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectMenuCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
139
SvetoforVKBot/Models/Commands/LK/Menu/ShowMenuDostavka.cs
Normal file
139
SvetoforVKBot/Models/Commands/LK/Menu/ShowMenuDostavka.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Attachments;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu
|
||||
{
|
||||
public class ShowMenuDostavka
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db, string msg, int plAction, int subMenu)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
var ids = new long[] { chatId };
|
||||
var user = client.Users.Get(ids);
|
||||
string voronka = "";
|
||||
double sum = 0;
|
||||
string backPL = "";
|
||||
List<CategoriesDostavka> categories = new List<CategoriesDostavka>();
|
||||
var row = new List<MessageKeyboardButton>();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
var kbColor = KeyboardButtonColor.Positive;
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
categories = db.CategoriesDostavkas.Where(c=>c.subMenu == subMenu).ToList().ConvertAll<CategoriesDostavka>(c =>
|
||||
new CategoriesDostavka()
|
||||
{
|
||||
categoryId = c.categoryId,
|
||||
inTheOrder = c.inTheOrder,
|
||||
name = c.name,
|
||||
btnName = c.btnName,
|
||||
kbColor = c.kbColor,
|
||||
});
|
||||
|
||||
//SqlCommand getCategories = new SqlCommand("SELECT * FROM CategoriesDostavka WHERE subMenu = @subMenu;", Con);
|
||||
//getCategories.Parameters.AddWithValue("@subMenu", subMenu);
|
||||
//SqlDataReader rgetCategories = getCategories.ExecuteReader();
|
||||
//while (rgetCategories.Read())
|
||||
// categories.Add(new CategoriesDostavka()
|
||||
// {
|
||||
// categoryId = Convert.ToInt32(rgetCategories["categoryId"]),
|
||||
// inTheOrder = Convert.ToInt32(rgetCategories["inTheOrder"]),
|
||||
// name = rgetCategories["name"].ToString(),
|
||||
// btnName = rgetCategories["btnName"].ToString(),
|
||||
// kbColor = rgetCategories["kbColor"].ToString(),
|
||||
// });
|
||||
//rgetCategories.Close();
|
||||
|
||||
categories.RemoveAll(c => c.inTheOrder.Equals(0));
|
||||
categories.Sort((x, y) => x.inTheOrder.CompareTo(y.inTheOrder));
|
||||
|
||||
int btnCount = 0;
|
||||
foreach (var c in categories)
|
||||
{
|
||||
switch (c.kbColor)
|
||||
{
|
||||
case "Default":
|
||||
kbColor = KeyboardButtonColor.Default;
|
||||
break;
|
||||
case "Positive":
|
||||
kbColor = KeyboardButtonColor.Positive;
|
||||
break;
|
||||
case "Negative":
|
||||
kbColor = KeyboardButtonColor.Negative;
|
||||
break;
|
||||
case "Primary":
|
||||
kbColor = KeyboardButtonColor.Primary;
|
||||
break;
|
||||
}
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton(c.btnName, "selectProduct-" + c.categoryId + "-0-1", kbColor);
|
||||
|
||||
btnCount += 1;
|
||||
|
||||
if (btnCount % 2 == 0)
|
||||
{
|
||||
keyboardBuilder.AddLine();
|
||||
}
|
||||
}
|
||||
if (btnCount % 2 != 0)
|
||||
{
|
||||
keyboardBuilder.AddLine();
|
||||
}
|
||||
|
||||
if (subMenu == 0)
|
||||
{
|
||||
backPL = "startPL";
|
||||
}
|
||||
else
|
||||
backPL = "selectMenu-0";
|
||||
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Назад", "selectMenu-0", KeyboardButtonColor.Default)
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
|
||||
@params.UserId = chatId;
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = msg;
|
||||
@params.DontParseLinks = true;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ShowMenuDostavka: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
430
SvetoforVKBot/Models/Commands/LK/Menu/ShowPersonalMenuCarusel.cs
Normal file
430
SvetoforVKBot/Models/Commands/LK/Menu/ShowPersonalMenuCarusel.cs
Normal file
@@ -0,0 +1,430 @@
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Security.Cryptography;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Utils;
|
||||
using VkNet.Model.Template;
|
||||
using VkNet.Model.Template.Carousel;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Menu
|
||||
{
|
||||
public class ShowPersonalMenuCarusel
|
||||
{
|
||||
private const string PHOTOIDNEXT = "-194717824_457239273_446146426236760985";
|
||||
//{"id": 457239273, "owner_id": -194717824, "access_key": "446146426236760985"}
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db, int curCategory, int curProduct, int curWay, double curDayKkal)
|
||||
//curCategory - id Categories, curProduct - порядковый номер в массиве продуктов, curWay - для showProductCarusel направление навигации
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
int i = 0;
|
||||
int prevCatalog = 0, nextCatalog = 0;
|
||||
int naviState = 0;
|
||||
double sum = 0;
|
||||
string desc = "";
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
List<CategoriesDostavka> categories = new List<CategoriesDostavka>();
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
List<ProductsDostavka> allProducts = new List<ProductsDostavka>();
|
||||
List<ProductsDostavka> randomFood = new List<ProductsDostavka>();
|
||||
//List<ProductsDostavka> personalProducts = new List<ProductsDostavka>();
|
||||
var row = new List<MessageKeyboardButton>();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
TemplateBuilder templateBuilder = new TemplateBuilder();
|
||||
CarouselElementAction carouselElementAction = new CarouselElementAction();
|
||||
carouselElementAction.Type = CarouselElementActionType.OpenPhoto;
|
||||
double belkiLow = 0, zhiryLow = 0, uglevodyLow = 0, belkiHigh = 0, zhiryHigh = 0, uglevodyHigh = 0;
|
||||
double curBelki = 0, curZhiry = 0, curUglevody = 0;
|
||||
double foodPercent = 0;
|
||||
double belkiPercent = 0, zhiryPercent = 0, uglevodyPercent = 0;
|
||||
double dayKkal = 0;
|
||||
string foodTime = "";
|
||||
try
|
||||
{
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
var choosenProducts = JsonConvert.DeserializeObject<List<int>>(user.choosenProducts);
|
||||
List<int> sportDays = JsonConvert.DeserializeObject<List<int>>(user.sportDays);
|
||||
|
||||
//if (curDay == 8) curDay = (int)DateTime.Now.DayOfWeek;
|
||||
int nextDay = curDay + 1;
|
||||
|
||||
if (nextDay == 8)
|
||||
nextDay = 1;
|
||||
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sum += o.price * o.number;
|
||||
}
|
||||
|
||||
|
||||
categories = db.CategoriesDostavkas.ToList().ConvertAll<CategoriesDostavka>(c =>
|
||||
new CategoriesDostavka()
|
||||
{
|
||||
categoryId = c.categoryId,
|
||||
name = c.name,
|
||||
btnName = c.btnName,
|
||||
kbColor = c.kbColor,
|
||||
});
|
||||
|
||||
allProducts = db.ProductsDostavkas.Where(p => p.categoryId != 0 &&
|
||||
JsonConvert.DeserializeObject<List<int>>(p.weekDays).Exists(day => day == curDay)).
|
||||
ToList().ConvertAll<ProductsDostavka>(e=>new ProductsDostavka()
|
||||
{
|
||||
id = e.id,
|
||||
article = e.article,
|
||||
colorId = e.colorId,
|
||||
categoryId = e.categoryId,
|
||||
name = e.name,
|
||||
fullName = e.fullName,
|
||||
descriptionCarousel = e.descriptionCarousel,
|
||||
price = Convert.ToDouble(e.price),
|
||||
photo = e.photo,
|
||||
photoCarousel = e.photoCarousel,
|
||||
kkal = e.kkal,
|
||||
foodType = JsonConvert.DeserializeObject<List<int>>(e.foodType),
|
||||
belki = Convert.ToDouble(e.belki),
|
||||
zhiry = Convert.ToDouble(e.zhiry),
|
||||
uglevody = Convert.ToDouble(e.uglevody),
|
||||
});
|
||||
|
||||
ProductsDostavka water = new ProductsDostavka();
|
||||
water = allProducts.Find(p => p.article.Equals("55"));
|
||||
allProducts.Remove(water);
|
||||
//allProducts.RemoveAll(p => !p.foodType.Contains(curCategory));
|
||||
if (choosenProducts.Count > 0)
|
||||
allProducts.RemoveAll(p => choosenProducts.Contains(p.id));
|
||||
|
||||
switch (user.track)
|
||||
{
|
||||
case 1:
|
||||
belkiLow = 1.4;
|
||||
belkiHigh = 2;
|
||||
|
||||
zhiryLow = 1;
|
||||
zhiryHigh = 1.1;
|
||||
|
||||
uglevodyLow = 2.4;
|
||||
uglevodyHigh = 3;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
belkiLow = 1.2;
|
||||
belkiHigh = 1.7;
|
||||
|
||||
zhiryLow = 0.9;
|
||||
zhiryHigh = 1;
|
||||
|
||||
uglevodyLow = 2;
|
||||
uglevodyHigh = 2.6;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
belkiLow = 1.6;
|
||||
belkiHigh = 2.2;
|
||||
|
||||
zhiryLow = 1.1;
|
||||
zhiryHigh = 1.2;
|
||||
|
||||
uglevodyLow = 2.8;
|
||||
uglevodyHigh = 3.4;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (curCategory)
|
||||
{
|
||||
case 1:
|
||||
allProducts.RemoveAll(p => p.categoryId == 1);
|
||||
|
||||
foodPercent = 0.3;
|
||||
belkiPercent = 0.3;
|
||||
uglevodyPercent = 0.4;
|
||||
zhiryPercent = 0.2;
|
||||
foodTime = "🥐Завтрак";
|
||||
randomFood = allProducts.FindAll(ap => (ap.categoryId != 1) && ap.zhiry <= zhiryLow * user.weight * zhiryPercent && ap.uglevody <= uglevodyLow * user.weight * uglevodyPercent);
|
||||
|
||||
//Углеводы - 0.4
|
||||
//Белки - 0.3
|
||||
//Жиры - 0.2
|
||||
//Кнопка ещё один вариант
|
||||
//web
|
||||
break;
|
||||
|
||||
case 2:
|
||||
foodPercent = 0.4;
|
||||
belkiPercent = 0.3;
|
||||
uglevodyPercent = 0.3;
|
||||
zhiryPercent = 0.4;
|
||||
foodTime = "🍲Обед";
|
||||
randomFood = allProducts.FindAll(ap => ap.categoryId == 1 && ap.zhiry <= zhiryLow * user.weight * zhiryPercent && ap.uglevody <= uglevodyLow * user.weight * uglevodyPercent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
allProducts.RemoveAll(p => p.categoryId == 1);
|
||||
|
||||
foodPercent = 0.1;
|
||||
belkiPercent = 0.2;
|
||||
uglevodyPercent = 0.2;
|
||||
zhiryPercent = 0.2;
|
||||
foodTime = "🥪Перекус";
|
||||
//ap.categoryId == 5 || ap.categoryId == 4
|
||||
randomFood = allProducts.FindAll(ap => (ap.categoryId != 1) && ap.zhiry <= zhiryLow * user.weight * zhiryPercent && ap.uglevody <= uglevodyLow * user.weight * uglevodyPercent);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
allProducts.RemoveAll(p => p.categoryId == 1);
|
||||
|
||||
foodPercent = 0.3;
|
||||
belkiPercent = 0.2;
|
||||
uglevodyPercent = 0.2;
|
||||
zhiryPercent = 0.2;
|
||||
randomFood = allProducts.FindAll(ap => (ap.categoryId != 1) && ap.zhiry <= zhiryLow * user.weight * zhiryPercent && ap.uglevody <= uglevodyLow * user.weight * uglevodyPercent);
|
||||
foodTime = "🥗Ужин";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
double maxKkal = Math.Round(curDayKkal * 1.2 * foodPercent);
|
||||
double minKkal = Math.Round(curDayKkal * 0.9 * foodPercent);
|
||||
|
||||
Random rand = new Random();
|
||||
if (choosenProducts.Count > 0)
|
||||
randomFood.RemoveAll(p => choosenProducts.Contains(p.id));
|
||||
|
||||
int randomBludo = rand.Next(0, randomFood.Count);
|
||||
|
||||
if (curCategory == 3)
|
||||
{
|
||||
products.Add(randomFood.Find(rf => rf.kkal <= maxKkal));
|
||||
}
|
||||
else
|
||||
{
|
||||
products.Add(randomFood[randomBludo]);
|
||||
}
|
||||
|
||||
curBelki = products[0].belki;
|
||||
curZhiry = products[0].zhiry;
|
||||
curUglevody = products[0].uglevody;
|
||||
dayKkal = products[0].kkal;
|
||||
choosenProducts.Add(products[0].id);
|
||||
ProductsDostavka tmp = new ProductsDostavka();
|
||||
for (i = 0; i < allProducts.Count; i++)
|
||||
{
|
||||
tmp = allProducts[i];
|
||||
allProducts.RemoveAt(i);
|
||||
allProducts.Insert(rand.Next(allProducts.Count), tmp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var ap in allProducts)
|
||||
{
|
||||
//if (dayKkal + ap.kkal <= maxKkal) //curBelki <= belkiLow * weight * foodPercent && curUglevody + ap.uglevody < uglevodyHigh * weight * foodPercent)
|
||||
if (curBelki + ap.belki <= belkiHigh * user.weight * belkiPercent &&
|
||||
curUglevody + ap.uglevody <= uglevodyHigh * user.weight * uglevodyPercent)// &&
|
||||
//curZhiry + ap.zhiry <= zhiryHigh * weight * zhiryPercent)
|
||||
{
|
||||
if (!products.Exists(p => p.categoryId == ap.categoryId))
|
||||
{
|
||||
if (true)//curUglevody + ap.uglevody < uglevodyHigh * weight * foodPercent curBelki < belkiHigh * weight * foodPercent && curZhiry < zhiryHigh * weight * foodPercent && curUglevody < uglevodyHigh * weight * foodPercent)
|
||||
{
|
||||
|
||||
curBelki += ap.belki;
|
||||
curZhiry += ap.zhiry;
|
||||
curUglevody += ap.uglevody;
|
||||
dayKkal += ap.kkal;
|
||||
products.Add(ap);
|
||||
choosenProducts.Add(ap.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
//else break;
|
||||
}
|
||||
|
||||
//if (dayKkal < minKkal)
|
||||
//{
|
||||
// if (curCategory != 3)
|
||||
// {
|
||||
// products.Add(allProducts.Find(ap => !choosenProducts.Contains(ap.id) && ap.zhiry <= zhiryLow * weight * zhiryPercent && ap.uglevody <= uglevodyLow * weight * uglevodyPercent && ap.categoryId != 7));
|
||||
// curBelki += products[products.Count - 1].belki;
|
||||
// curZhiry += products[products.Count - 1].zhiry;
|
||||
// curUglevody += products[products.Count - 1].uglevody;
|
||||
// dayKkal += products[products.Count - 1].kkal;
|
||||
// choosenProducts.Add(products[products.Count - 1].id);
|
||||
// }
|
||||
// //else
|
||||
// // products.Add(allProducts.Find(ap => !choosenProducts.Contains(ap.id) && ap.kkal <= maxKkal - minKkal));
|
||||
// //choosenProducts.Add(products[products.Count - 1].id);
|
||||
//}
|
||||
|
||||
if (!products.Exists(p => p.categoryId == 7))
|
||||
products.Add(water);
|
||||
//(p => p.article.Equals("55")))
|
||||
|
||||
//if (curCategory != 4)
|
||||
//{
|
||||
// SqlCommand updCart = new SqlCommand("UPDATE Users SET choosenProducts = @choosenProducts WHERE chatId = @chatId;", Con);
|
||||
// updCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
// updCart.Parameters.AddWithValue("@choosenProducts", JsonConvert.SerializeObject(choosenProducts));
|
||||
// updCart.ExecuteNonQuery();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SqlCommand updCart = new SqlCommand("UPDATE Users SET choosenProducts = @choosenProducts WHERE chatId = @chatId;", Con);
|
||||
// updCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
// updCart.Parameters.AddWithValue("@choosenProducts", "[]");
|
||||
// updCart.ExecuteNonQuery();
|
||||
//}
|
||||
|
||||
nextCatalog = curProduct + 9;
|
||||
prevCatalog = curProduct - 9;
|
||||
|
||||
if (curProduct > 0 && products.Count > 6)
|
||||
{
|
||||
if (nextCatalog > products.Count) nextCatalog = products.Count - (products.Count - curProduct);
|
||||
|
||||
if (prevCatalog < 0) prevCatalog = 0;
|
||||
}
|
||||
|
||||
for (i = curProduct; i < products.Count; i++)
|
||||
{
|
||||
var jsPhoto = JsonConvert.DeserializeObject<CatalogPhotoObject>(products[i].photoCarousel);
|
||||
|
||||
desc = products[i].descriptionCarousel; //+ " " + products[i].weight;
|
||||
if (desc.Length > 80) desc = desc.Substring(0, 77) + "..."; //desc.Substring(0, 77)
|
||||
|
||||
templateBuilder.AddTemplateElement(new CarouselElement()
|
||||
{
|
||||
Title = products[i].fullName,
|
||||
Description = desc + " | " + products[i].kkal + " ккал\n" +
|
||||
$"Б\\Ж\\У: {products[i].belki}г\\{products[i].zhiry}г\\{products[i].uglevody}г",
|
||||
PhotoId = jsPhoto.owner_id + "_" + jsPhoto.id + "_" + jsPhoto.access_key,
|
||||
Buttons = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton(){
|
||||
Action = new MessageKeyboardButtonAction(){ Label = "Добавить в корзину " + products[i].price + "р",
|
||||
Payload = "{\"button\":\"selectAddToCart-" + products[i].categoryId + "-" + products[i].id + "-" + curDayKkal + "\"}",
|
||||
Type = KeyboardButtonActionType.Text },
|
||||
Color = KeyboardButtonColor.Positive
|
||||
},
|
||||
//new MessageKeyboardButton(){
|
||||
// Action = new MessageKeyboardButtonAction(){ Label = "Подробнее",
|
||||
// Payload = "{\"button\":\"selectAddToCart-" + curCategory + "-" + i + "\"}",
|
||||
// Type = KeyboardButtonActionType.Text },
|
||||
// Color = KeyboardButtonColor.Default
|
||||
//},
|
||||
},
|
||||
Action = carouselElementAction,
|
||||
});
|
||||
|
||||
if (templateBuilder.Elements.Count == 9 && products.Count > 10)
|
||||
break;
|
||||
}
|
||||
|
||||
if (products.Count > 10)
|
||||
{
|
||||
switch (curWay)
|
||||
{
|
||||
case 1:
|
||||
if (curProduct < (products.Count - 9))
|
||||
naviState = 1;
|
||||
else
|
||||
naviState = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (curProduct == 0)
|
||||
naviState = 1;
|
||||
else
|
||||
naviState = 2;
|
||||
break;
|
||||
default:
|
||||
naviState = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (naviState)
|
||||
{
|
||||
case 1:
|
||||
templateBuilder.AddTemplateElement(new CarouselElement()
|
||||
{
|
||||
Title = ".",
|
||||
Description = ".",
|
||||
PhotoId = PHOTOIDNEXT,
|
||||
Buttons = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){ Label = ">> Следующие " + (products.Count - nextCatalog).ToString(),
|
||||
Payload = "{\"button\":\"selectProduct-" + products[nextCatalog].categoryId + "-" + nextCatalog + "-1\"}",
|
||||
Type = KeyboardButtonActionType.Text },
|
||||
Color = KeyboardButtonColor.Primary
|
||||
},
|
||||
},
|
||||
Action = carouselElementAction,
|
||||
});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
templateBuilder.AddTemplateElement(new CarouselElement()
|
||||
{
|
||||
Title = ".",
|
||||
Description = ".",
|
||||
PhotoId = PHOTOIDNEXT,
|
||||
Buttons = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){ Label = "<< Предыдущие " + curProduct,
|
||||
Payload = "{\"button\":\"selectProduct-" + products[prevCatalog].categoryId + "-" + prevCatalog + "-2\"}",
|
||||
Type = KeyboardButtonActionType.Text },
|
||||
Color = KeyboardButtonColor.Primary
|
||||
},
|
||||
},
|
||||
Action = carouselElementAction,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@params.Message = foodTime + "\n" +
|
||||
"Калории: " + dayKkal + " ккал \n" +
|
||||
$"Б\\Ж\\У: {curBelki}г\\{curZhiry}г\\{curUglevody}г \n\n" +
|
||||
$"Если хотите подобрать блюда ещё раз, нажмите кнопку повторно😉";
|
||||
@params.Template = templateBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ShowProductCaruselMain: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
SvetoforVKBot/Models/Commands/LK/Reports/CompareReport.cs
Normal file
15
SvetoforVKBot/Models/Commands/LK/Reports/CompareReport.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace SvetoforVKBot.Data
|
||||
{
|
||||
public partial class Reports : IComparable<Reports>
|
||||
{
|
||||
public int CompareTo(Reports other) // Сделаем сравнение по максимальному id
|
||||
{
|
||||
return (id < other.id) ? -1 : (id > other.id) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Reports
|
||||
{
|
||||
public class GetReportCommentCommand
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
if (update.@object.message.text.Length > 0)
|
||||
{
|
||||
var ids = new long[] { chatId };
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.tag = "Личный кабинет";
|
||||
db.SaveChanges();
|
||||
|
||||
var report = db.Reports.Where(r=>r.chatId == chatId).Max();
|
||||
report.comment = update.@object.message.text.Trim();
|
||||
report.datetime = DateTime.Now;
|
||||
report.state = 1;
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = "✅Отчет сохранён. Увидимся завтра!\n";
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.Message = "Не распознал сообщение 😕 Попробуйте, пожалуйста, ещё раз";
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в GetReportCommentCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
|
||||
public int GetRandomId()
|
||||
{
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Reports
|
||||
{
|
||||
public class SelectCreateReportCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectCreateReport\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
|
||||
@params.Message = "✏Отчёт за " + DateTime.Now.ToShortDateString() + "\n\n" +
|
||||
user.firstName + ", как Вы себя чувствуете?";
|
||||
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("😀", "selectReportRate-10", KeyboardButtonColor.Primary)
|
||||
.AddButton("😐", "selectReportRate-5", KeyboardButtonColor.Primary)
|
||||
.AddButton("🙁", "selectReportRate-1", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectCreateReportCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Reports
|
||||
{
|
||||
public class SelectReportCcalCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectReportCcal-";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
var chatId = update.@object.message.from_id;
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int result = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.tag = "Отчет - Комменнт";
|
||||
db.SaveChanges();
|
||||
|
||||
var report = db.Reports.Where(r => r.chatId == chatId).Max();
|
||||
report.result = result;
|
||||
db.SaveChanges();
|
||||
|
||||
@params.Message = "Оставьте несколько слов о прошедшем дне😌";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("Пропустить", "Пропустить", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectReportCcalCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user