Example #1
0
        private bool CheckEmailIsFree(string email)
        {
            if (string.IsNullOrEmpty(email))
            {
                return(false);
            }
            ClientEmailIsFreeRequest request = new ClientEmailIsFreeRequest();

            if (!string.IsNullOrEmpty(email))
            {
                try { request.Email = email; } catch { }
            }
            try { request.Operator = Convert.ToInt16(JwtProps.GetOperator()); } catch { }
            HttpResponseMessage response = HttpClientService.PostAsync("api/client/CheckEmailForFree", request).Result;

            if (response.IsSuccessStatusCode)
            {
                ClientEmailIsFreeResponse data = response.Content.ReadAsAsync <ClientEmailIsFreeResponse>().Result;
                if (string.IsNullOrEmpty(data.Message))
                {
                    return(data.IsFree);
                }
            }
            return(false);
        }
Example #2
0
        public string OperatorPosListSave(string list_name, string list_id)
        {
            var operatorPosListResponse = new OperatorPosListResponse();

            try
            {
                var data = new OperatorPosListCreateRequest
                {
                    Operator    = JwtProps.GetOperator(),
                    PosList     = list_id.Split(',').Select(n => Convert.ToInt32(n)).ToList(),
                    PosListName = list_name
                };
                HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/pos/SaveOperatorPosList", data).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    operatorPosListResponse = responseMessage.Content.ReadAsAsync <OperatorPosListResponse>().Result;
                    if (operatorPosListResponse.ErrorCode == 0 && string.IsNullOrEmpty(operatorPosListResponse.Message))
                    {
                        return(JsonConvert.SerializeObject(new { success = true }));
                    }
                    return(JsonConvert.SerializeObject(operatorPosListResponse));
                }
                operatorPosListResponse.ErrorCode = 10;
                operatorPosListResponse.Message   = "Ошибка получения данных";
            }
            catch (Exception ex)
            {
                operatorPosListResponse.ErrorCode = 2;
                operatorPosListResponse.Message   = ex.Message;
            }
            return(JsonConvert.SerializeObject(operatorPosListResponse));
        }
Example #3
0
        private bool CheckPhoneOrCardNumberIsFree(string phone, string card)
        {
            if (string.IsNullOrEmpty(phone) && string.IsNullOrEmpty(card))
            {
                return(false);
            }
            LCManager.Infrastructure.Request.GetClientInfoRequest request = new LCManager.Infrastructure.Request.GetClientInfoRequest();
            if (!string.IsNullOrEmpty(card))
            {
                try { request.Card = Convert.ToInt64(card); } catch { }
            }
            if (!string.IsNullOrEmpty(phone))
            {
                try { request.Phone = Convert.ToInt64(PhoneService.GetPhoneFromStr(phone)); } catch { }
            }
            try { request.Operator = Convert.ToInt16(JwtProps.GetOperator()); } catch { }
            HttpResponseMessage response = HttpClientService.PostAsync("api/values/ClientInfo", request).Result;

            if (response.IsSuccessStatusCode)
            {
                LCManager.Infrastructure.Response.GetClientInfoResponse data = response.Content.ReadAsAsync <LCManager.Infrastructure.Response.GetClientInfoResponse>().Result;
                if (data.ErrorCode == 0)
                {
                    return
                        (string.IsNullOrEmpty(data.Name) &&
                         string.IsNullOrEmpty(data.Surname) &&
                         string.IsNullOrEmpty(data.Patronymic) &&
                         data.Id == 0 &&
                         data.Card == 0);
                }
                return(true);
            }
            return(false);
        }
Example #4
0
 public ActionResult Index()
 {
     try
     {
         ViewBag.OperatorName = Convert.ToString(HttpContext.Request.Cookies["operatorName"].Value);
         ViewBag.RoleName     = JwtProps.GetRole();
     }
     catch { }
     return(View());
 }
Example #5
0
        public string GetListOfPos()
        {
            OperatorPosListResponse operatorPosResponse = new OperatorPosListResponse();

            try
            {
                OperatorPosRequest operatorPosRequest = new OperatorPosRequest
                {
                    Operator = JwtProps.GetOperator()
                };
                HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/pos/OperatorPosList", operatorPosRequest).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    operatorPosResponse = responseMessage.Content.ReadAsAsync <OperatorPosListResponse>().Result;
                    if (operatorPosResponse.ErrorCode == 0 && string.IsNullOrEmpty(operatorPosResponse.Message))
                    {
                        PosModel.PosListData data = new PosModel.PosListData();
                        int i = 0;
                        foreach (var c in operatorPosResponse.PosLists)
                        {
                            i++;
                            #region Формируем выпадающий список для списка ТТ
                            var detailList = c.Poses.Aggregate(string.Empty, (current, pos) => current + (@"<tr>
                                        <td colspan='2' style='color:#000;'>" + pos.City + @"</td>
                                        <td colspan='2' style='color:#000;'>" + pos.Address + @"</td>
                                      </tr>"));
                            #endregion
                            Implementation.Data.OperatorPosList g = new Implementation.Data.OperatorPosList
                            {
                                Id            = c.Id,
                                Caption       = c.Caption,
                                Text          = c.Poses.Count().ToString(),
                                Poses         = c.Poses,
                                HtmlForDelete = "<img class='dell-control' data-id=" + c.Id + " src='/img/dell.png'>",
                                details       = detailList
                            };
                            data.data.Add(g);
                        }
                        return(JsonConvert.SerializeObject(data));
                    }
                    return(JsonConvert.SerializeObject(operatorPosResponse));
                }
                operatorPosResponse.ErrorCode = 10;
                operatorPosResponse.Message   = "Ошибка получения данных";
            }
            catch (Exception ex)
            {
                operatorPosResponse.ErrorCode = 2;
                operatorPosResponse.Message   = ex.Message;
            }
            return(JsonConvert.SerializeObject(operatorPosResponse));
        }
Example #6
0
        public string GetOperatorPos()
        {
            OperatorPosResponse operatorPosResponse = new OperatorPosResponse();

            try
            {
                OperatorPosRequest operatorPosRequest = new OperatorPosRequest
                {
                    Operator = JwtProps.GetOperator()
                };
                HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/pos/OperatorPos", operatorPosRequest).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    operatorPosResponse = responseMessage.Content.ReadAsAsync <OperatorPosResponse>().Result;
                    if (operatorPosResponse.ErrorCode == 0 && string.IsNullOrEmpty(operatorPosResponse.Message))
                    {
                        PosModel.PosData data = new PosModel.PosData();
                        int i = 0;
                        foreach (var c in operatorPosResponse.Poses)
                        {
                            i++;
                            var item = new LC_Manager.Implementation.Data.Pos
                            {
                                Check   = "<input type='checkbox' class='checkbox checkbox-for-shop' name='checkbox[]" + c.Id + "' id='checkbox" + c.Id + "' value='" + c.Id + "'><label for='checkbox" + c.Id + "'></label>",
                                Id      = c.Id,
                                Address = c.Address,
                                City    = c.City,
                                Region  = c.Region
                            };
                            data.data.Add(item);
                        }
                        return(JsonConvert.SerializeObject(data));
                    }
                    return(JsonConvert.SerializeObject(operatorPosResponse));
                }
                else
                {
                    operatorPosResponse.ErrorCode = 10;
                    operatorPosResponse.Message   = "Ошибка получения данных";
                }
            }
            catch (Exception ex)
            {
                operatorPosResponse.ErrorCode = 2;
                operatorPosResponse.Message   = ex.Message;
            }
            return(JsonConvert.SerializeObject(operatorPosResponse));
        }
Example #7
0
        public string GetGoods()
        {
            OperatorGoodsResponse operatorGoodsResponse = new OperatorGoodsResponse();

            try
            {
                OperatorGoodsRequest operatorGoodsRequest = new OperatorGoodsRequest
                {
                    Operator = JwtProps.GetOperator()
                };
                HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/values/OperatorGoods", operatorGoodsRequest).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    operatorGoodsResponse = responseMessage.Content.ReadAsAsync <OperatorGoodsResponse>().Result;
                    if (operatorGoodsResponse.ErrorCode == 0 && string.IsNullOrEmpty(operatorGoodsResponse.Message))
                    {
                        goodsdata data = new goodsdata();
                        foreach (var c in operatorGoodsResponse.OperatorGoods)
                        {
                            good g = new good
                            {
                                chek = "<input type='checkbox' class='checkbox checkbox-for-good' name='checkbox[]" + c.Id + "' id='checkbox" + c.Id + "' value='" + c.Id + "'><label for='checkbox" + c.Id + "'></label>",
                                id   = c.Id.ToString(),
                                name = c.Code,
                                text = c.Name
                            };
                            data.data.Add(g);
                        }
                        return(JsonConvert.SerializeObject(data));
                    }
                    return(JsonConvert.SerializeObject(operatorGoodsResponse));
                }
                else
                {
                    operatorGoodsResponse.ErrorCode = 10;
                    operatorGoodsResponse.Message   = "Ошибка получения данных";
                }
            }
            catch (Exception ex)
            {
                operatorGoodsResponse.ErrorCode = 2;
                operatorGoodsResponse.Message   = ex.Message;
            }
            return(JsonConvert.SerializeObject(operatorGoodsResponse));
        }
Example #8
0
        public JsonResult GetClientInfo(string card)
        {
            LCManager.Infrastructure.Request.GetClientInfoRequest clientInfoRequest = new LCManager.Infrastructure.Request.GetClientInfoRequest();
            if (!string.IsNullOrEmpty(card))
            {
                try { clientInfoRequest.Card = Convert.ToInt64(card); } catch { }
            }
            else
            {
                return(Json(new LCManager.Infrastructure.Response.GetClientInfoResponse {
                    ErrorCode = 10, Message = "Не указана карта клиента"
                }));
            }
            try { clientInfoRequest.Operator = Convert.ToInt16(JwtProps.GetOperator()); } catch { }
            HttpResponseMessage response = HttpClientService.PostAsync("api/values/ClientInfo", clientInfoRequest).Result;

            if (response.IsSuccessStatusCode)
            {
                LCManager.Infrastructure.Response.GetClientInfoResponse clientInfoResponse = response.Content.ReadAsAsync <LCManager.Infrastructure.Response.GetClientInfoResponse>().Result;
                if (clientInfoResponse.ErrorCode == 0)
                {
                    CardInfoResponse      response2 = new CardInfoResponse();
                    CardStatisticsRequest request2  = new CardStatisticsRequest
                    {
                        Card = clientInfoResponse.Card
                    };
                    HttpResponseMessage responseMessage2 = HttpClientService.PostAsync("api/card/GetCard", request2).Result;
                    if (responseMessage2.IsSuccessStatusCode)
                    {
                        response2 = responseMessage2.Content.ReadAsAsync <CardInfoResponse>().Result;
                        if (response2.ErrorCode == 0)
                        {
                            return(Json(new { data1 = clientInfoResponse, data2 = response2 }));
                        }
                    }
                    return(Json(new DefaultResponse {
                        ErrorCode = 11, Message = "Ошибка запроса к ClientInfo"
                    }));
                }
            }
            return(Json(new DefaultResponse {
                ErrorCode = 11, Message = "Ошибка запроса к ClientInfo"
            }));
        }
Example #9
0
        private DefaultResponse ClientChangeInfo(ClientChangeModel model)
        {
            var response = new DefaultResponse();

            try
            {
                var client = new Client
                {
                    allowemail = model.AllowEmail,
                    allowpush  = model.AllowPush,
                    allowsms   = model.AllowSms,
                    email      = model.Email,
                    birthdate  = Convert.ToDateTime(model.Birthdate),
                    firstname  = model.FirstName,
                    lastname   = model.LastName,
                    middlename = model.MiddleName,
                    id         = model.Id,
                    phone      = Convert.ToInt64(PhoneService.GetPhoneFromStr(model.Phone)),
                    gender     = Convert.ToInt32(model.Sex)
                };
                ChangeClientRequest request = new ChangeClientRequest
                {
                    ClientData = client,
                    Operator   = JwtProps.GetOperator()
                };

                HttpResponseMessage changeResponse = HttpClientService.PostAsync("api/values/ChangeClient", request).Result;
                if (changeResponse.IsSuccessStatusCode)
                {
                    response = changeResponse.Content.ReadAsAsync <DefaultResponse>().Result;
                    return(response);
                }
            }
            catch (Exception e)
            {
                response.ErrorCode = 500;
                response.Message   = e.Message;
            }
            return(response);
        }
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (!String.IsNullOrEmpty(base.Roles))
            {
                _allowedRoles = base.Roles.Split(new char[] { ',' });
                for (int i = 0; i < _allowedRoles.Length; i++)
                {
                    _allowedRoles[i] = _allowedRoles[i].Trim();
                }
            }

            //Если токен отсутствует в куках, считаем не авторизованным
            if (!JwtProps.IsExistTokenInCookie())
            {
                return(false);
            }

            //Если токен истек
            if (JwtProps.IsExpiredToken())
            {
                //1 - проверяем присутствует ли в куках Refresh Token, если нет то считаем не авторизованным
                if (!JwtProps.IsExistRefreshTokenInCookie())
                {
                    return(false);
                }
                //2 - пытаемся обновить токены
                if (!AccountController.RefreshToken(JwtProps.GetUser(), JwtProps.GetRefreshToken()))
                {
                    JwtProps.Logout();
                    return(false);
                }
            }
            //Роли указанные в атрибуте
            _tokenRoles = JwtProps.GetRole();
            return(Role());
        }
Example #11
0
 public ActionResult Logoff()
 {
     JwtProps.Logout();
     return(RedirectToAction("Index", "Home"));
 }
Example #12
0
        public ActionResult Login(UserModel user, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                string     connectionString = ConfigurationManager.ConnectionStrings["Partner"].ConnectionString;
                HttpClient httpClient       = new HttpClient
                {
                    BaseAddress = new Uri(connectionString)
                };
                httpClient.DefaultRequestHeaders.Clear();
                httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                var pairs = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("username", user.Login),
                    new KeyValuePair <string, string>("password", user.Password),
                    new KeyValuePair <string, string>("grant_type", "password")
                };

                var content = new FormUrlEncodedContent(pairs);

                Log.Information("LCManagerUI. Send auth request for user:{login}", user.Login);
                HttpResponseMessage responseMessage = httpClient.PostAsync("ManagerLogin", content).Result;
                Log.Information("LCManagerUI. Response message IsSuccessStatusCode={state}", responseMessage.IsSuccessStatusCode);
                if (responseMessage.IsSuccessStatusCode)
                {
                    Token token = responseMessage.Content.ReadAsAsync <Token>().Result;
                    #region Обязательно записываем токен в куки
                    Response.SetCookie(new HttpCookie("lcmanager_token")
                    {
                        Value   = token.access_token,
                        Expires = DateTime.Now.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["jwt_token_cookie_expiration"]))
                    });
                    #endregion

                    Log.Information("LCManagerUI. Set refresh_token to cookie. Token = {token}", token.refresh_token);
                    #region Записываем refresh_token в куки
                    Response.SetCookie(new HttpCookie("lcmanager_refresh_token")
                    {
                        Value   = token.refresh_token,
                        Expires = DateTime.Now.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["jwt_refresh_token_cookie_expiration"]))
                    });
                    #endregion

                    #region Получаем информацию об операторе и записываем в куки
                    OperatorInfoRequest operatorInfoRequest = new OperatorInfoRequest
                    {
                        Operator = JwtProps.GetOperator()
                    };

                    HttpResponseMessage httpResponseMessage = HttpClientService.PostAsync("api/values/OperatorInfo", operatorInfoRequest).Result;
                    if (httpResponseMessage.IsSuccessStatusCode)
                    {
                        OperatorInfoResponse operatorInfoResponse = httpResponseMessage.Content.ReadAsAsync <OperatorInfoResponse>().Result;
                        Response.SetCookie(new HttpCookie("operatorName")
                        {
                            Value   = operatorInfoResponse.OperatorName,
                            Expires = DateTime.Now.AddDays(365)
                        });
                    }
                    #endregion
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(user));
        }
Example #13
0
        public string GetBookkeeping(JQueryDataTableParamModel param)
        {
            BookkeepingsResponse response = new BookkeepingsResponse();
            BookkeepingRequest   request  = new BookkeepingRequest();

            try { request.Operator = JwtProps.GetOperator(); } catch { }
            try { request.Partner = JwtProps.GetPartner(); } catch { }
            try { request.Pos = JwtProps.GetPos(); } catch { }
            try
            {
                if (!string.IsNullOrEmpty(Request["columns[1][search][value]"]))
                {
                    request.Name = Request["columns[1][search][value]"];
                }
                request.DateStart = Request["date_from"];
                request.DateEnd   = Request["date_to"];
                request.Page      = Convert.ToInt64(param.start);
                request.PageSize  = Convert.ToInt64(param.length);

                var i = 0;
                if (request.IsOperator)
                {
                    i = 1;
                    if (!string.IsNullOrEmpty(Request["columns[2][search][value]"]))
                    {
                        request.PosName = Request["columns[2][search][value]"];
                    }
                }

                if (!string.IsNullOrEmpty(Request["columns[" + (2 + i) + "][search][value]"]))
                {
                    var values = Request["columns[" + (2 + i) + "][search][value]"].Split('-');
                    try { request.PurchasesMore = values[0]; } catch { };
                    try { request.PurchasesLess = values[1]; } catch { };
                }
                if (!string.IsNullOrEmpty(Request["columns[" + (3 + i) + "][search][value]"]))
                {
                    var values = Request["columns[" + (3 + i) + "][search][value]"].Split('-');
                    try { request.AddedMore = values[0]; } catch { };
                    try { request.AddedLess = values[1]; } catch { };
                }
                if (!string.IsNullOrEmpty(Request["columns[" + (4 + i) + "][search][value]"]))
                {
                    var values = Request["columns[" + (4 + i) + "][search][value]"].Split('-');
                    try { request.RedeemedMore = values[0]; } catch { };
                    try { request.RedeemedLess = values[1]; } catch { };
                }
                if (!string.IsNullOrEmpty(Request["columns[" + (5 + i) + "][search][value]"]))
                {
                    var values = Request["columns[" + (5 + i) + "][search][value]"].Split('-');
                    try { request.ClientsMore = values[0]; } catch { };
                    try { request.ClientsLess = values[1]; } catch { };
                }
                try { request.Page++; } catch { }
                HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/bookkeeping/GetBookkeepings", request).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    try { response = responseMessage.Content.ReadAsAsync <BookkeepingsResponse>().Result; } catch { }
                    if (response.ErrorCode == 0)
                    {
                        var longArrayByMonth    = new long[12];
                        var decimalArrayByMonth = new decimal[12];

                        BookkeepingDataTableModel bookkeepings = new BookkeepingDataTableModel();
                        foreach (Bookkeeping item in response.Bookkeepings)
                        {
                            longArrayByMonth[0]  = item.GainMonth1;
                            longArrayByMonth[1]  = item.GainMonth2;
                            longArrayByMonth[2]  = item.GainMonth3;
                            longArrayByMonth[3]  = item.GainMonth4;
                            longArrayByMonth[4]  = item.GainMonth5;
                            longArrayByMonth[5]  = item.GainMonth6;
                            longArrayByMonth[6]  = item.GainMonth7;
                            longArrayByMonth[7]  = item.GainMonth8;
                            longArrayByMonth[8]  = item.GainMonth9;
                            longArrayByMonth[9]  = item.GainMonth10;
                            longArrayByMonth[10] = item.GainMonth11;
                            longArrayByMonth[11] = item.GainMonth12;
                            var buysArrayString = string.Join(",", longArrayByMonth);

                            longArrayByMonth[0]  = item.ClientsMonth1;
                            longArrayByMonth[1]  = item.ClientsMonth2;
                            longArrayByMonth[2]  = item.ClientsMonth3;
                            longArrayByMonth[3]  = item.ClientsMonth4;
                            longArrayByMonth[4]  = item.ClientsMonth5;
                            longArrayByMonth[5]  = item.ClientsMonth6;
                            longArrayByMonth[6]  = item.ClientsMonth7;
                            longArrayByMonth[7]  = item.ClientsMonth8;
                            longArrayByMonth[8]  = item.ClientsMonth9;
                            longArrayByMonth[9]  = item.ClientsMonth10;
                            longArrayByMonth[10] = item.ClientsMonth11;
                            longArrayByMonth[11] = item.ClientsMonth12;
                            var clientsArrayString = string.Join(",", longArrayByMonth);

                            longArrayByMonth[0]  = item.AddedMonth1;
                            longArrayByMonth[1]  = item.AddedMonth2;
                            longArrayByMonth[2]  = item.AddedMonth3;
                            longArrayByMonth[3]  = item.AddedMonth4;
                            longArrayByMonth[4]  = item.AddedMonth5;
                            longArrayByMonth[5]  = item.AddedMonth6;
                            longArrayByMonth[6]  = item.AddedMonth7;
                            longArrayByMonth[7]  = item.AddedMonth8;
                            longArrayByMonth[8]  = item.AddedMonth9;
                            longArrayByMonth[9]  = item.AddedMonth10;
                            longArrayByMonth[10] = item.AddedMonth11;
                            longArrayByMonth[11] = item.AddedMonth12;
                            var addedArrayString = string.Join(",", longArrayByMonth);

                            longArrayByMonth[0]  = item.RedeemedMonth1;
                            longArrayByMonth[1]  = item.RedeemedMonth2;
                            longArrayByMonth[2]  = item.RedeemedMonth3;
                            longArrayByMonth[3]  = item.RedeemedMonth4;
                            longArrayByMonth[4]  = item.RedeemedMonth5;
                            longArrayByMonth[5]  = item.RedeemedMonth6;
                            longArrayByMonth[6]  = item.RedeemedMonth7;
                            longArrayByMonth[7]  = item.RedeemedMonth8;
                            longArrayByMonth[8]  = item.RedeemedMonth9;
                            longArrayByMonth[9]  = item.RedeemedMonth10;
                            longArrayByMonth[10] = item.RedeemedMonth11;
                            longArrayByMonth[11] = item.RedeemedMonth12;
                            var redeemedArrayString = string.Join(",", longArrayByMonth);

                            BookkeepingViewModel bonus = new BookkeepingViewModel
                            {
                                id        = item.Id,
                                caption   = item.Caption,
                                posname   = item.PosName,
                                purchases = item.Gain.ToString(CultureInfo.InvariantCulture),
                                added     = item.Added.ToString(CultureInfo.InvariantCulture),
                                redeemed  = item.Redeemed.ToString(CultureInfo.InvariantCulture),
                                clients   = item.Clients.ToString(CultureInfo.InvariantCulture),
                                diagrams  = @"
                                <div class='line-chart-bl' style='padding-bottom: 20px;'>
                                    <div class='line-chart__head'>
                                        <div id='line-chart-leg' class='line-chart-legend'></div>
                                    </div>
                                    <div class='line-chart__bottom'><canvas id='canvas' class='line-chart'></canvas>
                                        <div id='chartjs-tooltip-1' class='linejs-tooltip'></div>
                                    </div>
                                </div>
                                <script>
                                        var lineChartData = {
                                            labels: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
                                            datasets: [
                                                {
                                                    label: 'Выручка',
                                                    borderColor: '#58AEDC',
                                                    pointBackgroundColor: '#58AEDC',
                                                    pointRadius: 2,
                                                    backgroundColor: '#58AEDC',
                                                    data: [" + buysArrayString + @"],
                                                    fill: !1,
                                                    borderWidth: 2,
                                                },
                                                {
                                                    label: 'Начислено',
                                                    borderColor: '#11B9A3',
                                                    pointBackgroundColor: '#11B9A3',
                                                    pointRadius: 2,
                                                    backgroundColor: '#11B9A3',
                                                    data: [" + addedArrayString + @"],
                                                    fill: !1,
                                                    borderWidth: 2,
                                                }, {
                                                    label: 'Списано',
                                                    borderColor: '#E5C861',
                                                    pointBackgroundColor: '#E5C861',
                                                    pointRadius: 2,
                                                    backgroundColor: '#E5C861',
                                                    data: [" + redeemedArrayString + @"],
                                                    fill: !1,
                                                    borderWidth: 2,
                                                }, {
                                                    label: 'Клиенты',
                                                    borderColor: '#567BA5',
                                                    pointBackgroundColor: '#567BA5',
                                                    pointRadius: 2,
                                                    backgroundColor: '#567BA5',
                                                    data: [" + clientsArrayString + @"],
                                                    fill: !1,
                                                    borderWidth: 2,
                                                }
                                                ]
                                        };
                                        typeDiagram = 'line';
                                </script>"
                            };
                            bookkeepings.data.Add(bonus);
                        }
                        bookkeepings.draw            = param.draw;
                        bookkeepings.recordsTotal    = response.RecordTotal;
                        bookkeepings.recordsFiltered = response.RecordFilterd;
                        var data = JsonConvert.SerializeObject(bookkeepings);
                        return(data);
                    }
                    return(responseMessage.ReasonPhrase);
                }
                response.ErrorCode = 10;
                response.Message   = "Ошибка получения данных";
            }
            catch (Exception ex)
            {
                response.ErrorCode = 2;
                response.Message   = ex.Message;
            }
            return(JsonConvert.SerializeObject(response));
        }
Example #14
0
        public FileResult BookkeepingReport(
            string from,
            string to,
            string name,
            string buys,
            string added,
            string redeemed,
            string clients)
        {
            ReportResponse     response = new ReportResponse();
            BookkeepingRequest request  = new BookkeepingRequest();

            try { request.Operator = JwtProps.GetOperator(); } catch { }
            try { request.Partner = JwtProps.GetPartner(); } catch { }
            try { request.Pos = JwtProps.GetPos(); } catch { }
            try
            {
                if (!string.IsNullOrEmpty(name))
                {
                    request.Name = name;
                }
                request.DateStart = from;
                request.DateEnd   = to;
                request.Page      = -1;
                request.PageSize  = -1;

                if (!string.IsNullOrEmpty(buys))
                {
                    var values = buys.Split('-');
                    try { request.PurchasesMore = values[0]; } catch { };
                    try { request.PurchasesLess = values[1]; } catch { };
                }
                if (!string.IsNullOrEmpty(added))
                {
                    var values = added.Split('-');
                    try { request.AddedMore = values[0]; } catch { };
                    try { request.AddedLess = values[1]; } catch { };
                }
                if (!string.IsNullOrEmpty(redeemed))
                {
                    var values = redeemed.Split('-');
                    try { request.RedeemedMore = values[0]; } catch { };
                    try { request.RedeemedLess = values[1]; } catch { };
                }
                if (!string.IsNullOrEmpty(clients))
                {
                    var values = clients.Split('-');
                    try { request.ClientsMore = values[0]; } catch { };
                    try { request.ClientsLess = values[1]; } catch { };
                }
                HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/reports/BookkeepingReport", request).Result;
                if (responseMessage.IsSuccessStatusCode)
                {
                    response = responseMessage.Content.ReadAsAsync <ReportResponse>().Result;
                    if (response.ErrorCode != 0 || !string.IsNullOrEmpty(response.Message))
                    {
                        return(null);
                    }
                    var reportName = "Отчёт по сверке";
                    if (!string.IsNullOrEmpty(from))
                    {
                        reportName = reportName + " с " + from;
                    }
                    if (!string.IsNullOrEmpty(to))
                    {
                        reportName = reportName + " по " + to;
                    }
                    reportName = reportName + ".xlsx";
                    return(File(response.Report, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", reportName));
                }
                return(null);
            }
            catch { return(null); }
        }
Example #15
0
        public JsonResult OperatorGoodImportFromExcel(HttpPostedFileBase file)
        {
            if (Request.Files.Count > 0)
            {
                var goodList = new List <Good>();
                using (var excel = new ExcelPackage(Request.Files[0].InputStream))
                {
                    var sheet = excel.Workbook.Worksheets.First();
                    for (var rowNum = 2; rowNum <= sheet.Dimension.End.Row; rowNum++)
                    {
                        try
                        {
                            goodList.Add(new Good
                            {
                                Code = sheet.Cells[rowNum, 2].Text,
                                Name = sheet.Cells[rowNum, 1].Text
                            });
                        }
                        catch { }
                    }
                }
                OperatorGoodImportResponse operatorGoodImportResponse = new OperatorGoodImportResponse();
                try
                {
                    short partner = JwtProps.GetPartner();
                    if (partner == 0)
                    {
                        partner = JwtProps.GetDefaultPartner();
                    }
                    var data = new OperatorGoodImportRequest
                    {
                        Partner = partner,
                        Goods   = goodList
                    };
                    HttpResponseMessage responseMessage = HttpClientService.PostAsync("api/values/ImportOperatorGoods", data).Result;
                    if (responseMessage.IsSuccessStatusCode)
                    {
                        operatorGoodImportResponse = responseMessage.Content.ReadAsAsync <OperatorGoodImportResponse>().Result;
                        if (operatorGoodImportResponse.ErrorCode == 0 && string.IsNullOrEmpty(operatorGoodImportResponse.Message))
                        {
                            return(Json(new { success = true }));
                        }
                        return(Json(new { success = false }));
                    }
                    operatorGoodImportResponse.ErrorCode = 10;
                    operatorGoodImportResponse.Message   = "Ошибка импорта данных";
                }
                catch (Exception e)
                {
                }



                //var reader = new StreamReader(Request.Files[0].InputStream);
                //var ex=new ExcelPackage(Request.Files[0].InputStream);
                //var book = ex.
                //    Factory.GetWorkbookSet().Workbooks.OpenFromStream(Request.Files[0].InputStream);
                //var sheet = book.ActiveWorksheet;

                //var usedColumns = sheet.UsedRange.ColumnCount;
                //var usedRows = sheet.UsedRange.RowCount;


                //for (var row = 0; row < usedRows; row++)
                //{
                //    for (var col = 0; col < usedColumns; col++)
                //    {
                //        var iss = sheet.Cells[row, col].Text;
                //    }
                //}

                //book.Close();



                return(Json(new { success = true }));
            }

            //ПОКА ЗАГЛУШКА ВОЗВРАЩАЮЩАЯ УСПЕХ
            //После уточнения механизма загрузки данных будет реализовано
            return(Json(new { success = true }));
        }