Beispiel #1
0
        public Responce <List <AppUsersDTO> > GetUsersList()
        {
            Responce <List <AppUsersDTO> > responce    = new Responce <List <AppUsersDTO> >();
            List <AppUsersDTO>             appUsersDTO = new List <AppUsersDTO>();

            try
            {
                responce.Success = true;
                using (SSCEntities db = new SSCEntities())
                {
                    appUsersDTO = db.UserDetailWithRole?.Select(a => new AppUsersDTO()
                    {
                        Id = a.Id, Name = a.Name, Email = a.Email, City = a.City, Phone = a.Phonenumber, RoleId = a.RoleId, UserRole = a.UserRole
                    }).ToList();
                    responce.ResponeContent = appUsersDTO;
                }
            }
            catch (Exception ex)
            {
                responce.Success        = false;
                responce.Message        = $"ERROR GetUsersList : {ex.InnerException}";
                responce.ResponeContent = appUsersDTO;
            }
            return(responce);
        }
Beispiel #2
0
        public Responce machinestart([FromBody] Input Input)
        {
            Excute   Inter = new Excute();
            Responce Res   = Inter.HandleInfo(Input);

            return(Res);
        }
Beispiel #3
0
        public Responce <List <AppRolesDTO> > GetRoles()
        {
            Responce <List <AppRolesDTO> > responce     = new Responce <List <AppRolesDTO> >();
            List <AppRolesDTO>             appRolesDTOs = new List <AppRolesDTO>();

            try
            {
                responce.Success = true;
                using (SSCEntities db = new SSCEntities())
                {
                    appRolesDTOs = db.AspNetRoles.Select(a => new AppRolesDTO()
                    {
                        Id = a.Id, Name = a.Name
                    }).ToList();
                    responce.ResponeContent = appRolesDTOs;
                }
            }
            catch (Exception ex)
            {
                responce.Success        = false;
                responce.Message        = $"ERROR GetRoles :{ex.InnerException}";
                responce.ResponeContent = appRolesDTOs;
            }
            return(responce);
        }
Beispiel #4
0
        public async Task <Responce <List <CityDTO> > > GetCities(MobileRequest mobileRequest)

        {
            Responce <List <CityDTO> > Responce = new Responce <List <CityDTO> >();

            Responce.Success = true;
            try
            {
                List <CityDTO> Citys = new List <CityDTO>();
                Citys = SSCEntities.Citys.Where(a => a.IsActive == true).Select(a => new CityDTO()
                {
                    Id           = a.Id,
                    CityName     = a.CityName,
                    CountryId    = a.CountryId,
                    CreatedBy    = a.CreatedBy,
                    AdminEmail   = a.AdminEmail,
                    CreatedDate  = a.CreatedDate,
                    ModifiedBy   = a.ModifiedBy,
                    ModifiedDate = a.ModifiedDate,
                    MCEmail      = a.MCEmail,
                    FcciEmail    = a.FcciEmail,
                    IsActive     = a.IsActive ?? false
                }).ToList();
                Responce.ResponeContent = Citys;
                return(Responce);
            }
            catch (Exception ex)
            {
                Responce.Success = false;
                Responce.Message = $"ERROR GetCities :{ex.InnerException}";
            }
            return(Responce);
        }
Beispiel #5
0
        public Responce LeaveFeedback(long chatId, string username, string text)
        {
            try
            {
                _service.CreateFeedback(new Feedback {
                    ChatId = chatId, Date = DateTime.Now, Id = Guid.NewGuid(), Text = text, UserName = username
                });

                var table = _service.GetActiveTable(chatId);
                if (table != null)
                {
                    if (table.TableNumber == null)
                    {
                        _service.DeleteTable(table.Id);
                    }
                    else
                    {
                        _service.UpdateTableState(table.Id, SessionState.Sitted);
                    }
                }

                return(new Responce
                {
                    ChatId = chatId,
                    ResponceText = "Спасибо за ваш отзыв!"
                });
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #6
0
        private byte[] ReadResponseStream()
        {
            var start         = DateTime.Now;
            var timeout       = ResponseParams.DownloadTimeoutMs;
            var maxPageSize   = ResponseParams.MaxPageSize;
            var enableTimeout = timeout != Timeout.Infinite;
            var buffer        = new byte[8 * 1024];

            try
            {
                byte[] data = null;
                using (var stream = Responce.GetResponseStream())
                    using (var ms = new MemoryStream())
                    {
                        int readed;
                        while ((readed = stream.Read(buffer, 0, buffer.Length)) > 0 && ms.Length < maxPageSize)
                        {
                            ms.Write(buffer, 0, readed);
                            if (enableTimeout && (DateTime.Now - start).TotalMilliseconds > timeout)
                            {
                                break;
                            }
                        }
                        data = ms.GetBuffer();
                    }
                return(data);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #7
0
    public IEnumerator Send_Info()
    {
        StartCoroutine(Block());
        Player player = new Player();

        player.login = send_btn.self.input_login.text;

        Request request = new Request(player);


        Debug.Log(MainScript.self.servername + "api/v1/player/register?data=" + JsonUtility.ToJson(request));
        WWW www = new WWW(MainScript.self.servername + "api/v1/player/register?data=" + JsonUtility.ToJson(request));

        yield return(www);

        Debug.Log(www.text);
        if (www.text.Contains("wrong login"))
        {
            MainScript.self.ErrorScreen.SetActive(true);

            MainScript.self.fon_login.GetComponent <fon_login>().error2.text = "Неправильно введен номер телефона";
        }
        else
        {
            MainScript.self.fon_login.GetComponent <fon_login>().error2.text = "";
        }
        Responce responce = JsonUtility.FromJson <Responce>(www.text);

        Debug.Log(JsonUtility.ToJson(responce));

        MainScript.self.player = responce.player;
        Debug.Log(MainScript.self.servername + "register.php?data=" + JsonUtility.ToJson(player));
    }
#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
        public async Task <Responce <List <SpeciesDTO> > > GetAllSpecies(MobileRequest mobileRequest)
#pragma warning restore CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
        {
            Responce <List <SpeciesDTO> > Responce = new Responce <List <SpeciesDTO> >();

            Responce.Success = true;
            try
            {
                List <SpeciesDTO> species = new List <SpeciesDTO>();

                species = (from lo in SSCEntities.Species
                           select lo).Select(a => new SpeciesDTO()
                {
                    Id           = a.Id,
                    SpeciesName  = a.SpeciesName,
                    Icon         = a.Icon,
                    CreatedBy    = a.CreatedBy,
                    CreatedDate  = a.CreatedDate,
                    ModifiedBy   = a.ModifiedBy,
                    ModifiedDate = a.ModifiedDate,
                }).ToList();

                Responce.ResponeContent = species;
                return(Responce);
            }
            catch (Exception ex)
            {
                Responce.Success = false;
                Responce.Message = $"ERROR GetAllSpecies :{ex.InnerException}";
            }
            return(Responce);
        }
Beispiel #9
0
        /// <summary>
        /// Assigns a responce to a key if that key is currently has no associated action.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="responce">A Responce deligate for the responce method.</param>
        /// <returns>Boolean to indicate success or failure.</returns>
        public bool AddKeyAction(Keys key, Responce responce, XmlNodeList stringNodes)
        {
            if (ReservedKeys.Contains(key))
            {
                throw new InvalidOperationException("The key " + key.ToString() + " is listed as a reserved key. This can't be assigned a custom action.");
            }

            if (!Actions.ContainsKey(key))
            {
                List <string> args = new List <string>();

                foreach (XmlNode stringNode in stringNodes)
                {
                    args.Add(stringNode.Attributes["data"].Value);
                }

                Actions[key] = new Tuple <Responce, string[]>(responce, args.ToArray());

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <IHttpActionResult> GetComplaints(MobileRequest mobileRequest)
        {
            Responce <List <ComplaintsDTO> > responce = new Responce <List <ComplaintsDTO> >();

            var HttpRequest = HttpContext.Current.Request;

            try
            {
                string UserName = User.Identity.GetUserId();
                //mobileRequest.Username = UserName;


                if (!string.IsNullOrEmpty(UserName))
                {
                    mobileRequest.Username = UserName;
                }
                responce = await _complaintService.GetComplaint(mobileRequest);

                return(Ok(responce));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 private void ReceiveCallback(IAsyncResult result)
 {
     try
     {
         int bytesReceived = ((Socket)result.AsyncState).EndReceive(result);
         if (bytesReceived != 0)
         {
             String respStr = Encoding.Unicode.GetString(_inbuffer);
             respStr  = respStr.Substring(0, respStr.IndexOf('\0'));
             Responce = Serializator.DeserializeResponce(respStr);
             if (Responce is AnalyzeResponce)
             {
                 _dbprovider.SaveReport(Responce as AnalyzeResponce);
             }
             OnResponceReceived();
             _inbuffer = new byte[512];
             _clientSocket.BeginReceive(_inbuffer, 0, _inbuffer.Length, SocketFlags.None, ReceiveCallback, _clientSocket);
         }
         else
         {
             _clientSocket.Close();
         }
     }
     catch (ObjectDisposedException)
     {
         LogInfo("Получение данных остановлено;");
     }
     catch (Exception exc)
     {
         _clientSocket.Close();
         LogInfo(exc.Message);
     }
 }
Beispiel #12
0
        public ResponceAndDataList <ExtractionDto> ReadExtractions(Guid wellId, string dateFrom, string dateTo)
        {
            var _dateFrom = dateFrom.GetDate();
            var _dateTo   = dateTo.GetDate();

            try
            {
                List <ExtractionDto> extractions = db.Добыча
                                                   .Where
                                                   (
                    e =>
                    e.ID_Скважины == wellId &&
                    e.Дата >= _dateFrom &&
                    e.Дата <= _dateTo
                                                   )
                                                   .Select(x => new ExtractionDto {
                    ID = x.ID_Добычи, Value = x.Значение, Date = x.Дата
                })
                                                   .ToList();

                return(new ResponceAndDataList <ExtractionDto>
                {
                    Responce = Responce.CreateOkRespond(),
                    Data = extractions
                });
            }
            catch (Exception e)
            {
                return(new ResponceAndDataList <ExtractionDto> {
                    Responce = Responce.CreateErrorRespond(e.Message)
                });
            }
        }
Beispiel #13
0
        public async Task <Responce <bool> > UpdateCityMail(ChnageCityMailRequest chnageCityMailRequest)
        {
            Responce <bool> Responce = new Responce <bool>();

            Responce.Success = true;
            try
            {
                using (var db = new SSCEntities())
                {
                    Citys citys = db.Citys.Find(chnageCityMailRequest.Cityid);
                    citys.MCEmail         = chnageCityMailRequest.MCEmail;
                    citys.FcciEmail       = chnageCityMailRequest.FCCIEmail;
                    db.Entry(citys).State = System.Data.Entity.EntityState.Modified;
                    await db.SaveChangesAsync();

                    Responce.ResponeContent = true;
                }
            }
            catch (Exception ex)
            {
                Responce.Success        = false;
                Responce.ResponeContent = false;
                Responce.Message        = $"ERROR UpdateCityMail :{ex.InnerException}";
            }
            return(Responce);
        }
Beispiel #14
0
        public async Task <Responce <List <CityLowsDTO> > > GetCitieLows(MobileRequest mobileRequest)

        {
            Responce <List <CityLowsDTO> > Responce = new Responce <List <CityLowsDTO> >();

            Responce.Success = true;
            try
            {
                List <CityLowsDTO> CityLows = new List <CityLowsDTO>();
                CityLows = SSCEntities.CityLows.Select(a => new CityLowsDTO()
                {
                    Id     = a.Id,
                    CityId = a.CityId,
                    LowId  = a.LowId
                }).ToList();
                Responce.ResponeContent = CityLows;
                return(Responce);
            }
            catch (Exception ex)
            {
                Responce.Success = false;
                Responce.Message = $"ERROR GetCities :{ex.InnerException}";
            }
            return(Responce);
        }
Beispiel #15
0
        public async Task <Responce <List <CityDTO> > > GetAllCities(MobileRequest mobileRequest)
#pragma warning restore CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
        {
            Responce <List <CityDTO> > Responce = new Responce <List <CityDTO> >();

            Responce.Success = true;
            try
            {
                List <CityDTO> Citys = new List <CityDTO>();
                Citys = SSCEntities.Citys?.Select(a => new CityDTO()
                {
                    Id           = a.Id,
                    CityName     = a.CityName,
                    CountryId    = a.CountryId,
                    CreatedBy    = a.CreatedBy,
                    AdminEmail   = a.AdminEmail,
                    CreatedDate  = a.CreatedDate,
                    ModifiedBy   = a.ModifiedBy,
                    ModifiedDate = a.ModifiedDate,
                    MCEmail      = a.MCEmail,
                    FcciEmail    = a.FcciEmail,
                    IsActive     = a.IsActive ?? false
                }).ToList();
                Responce.ResponeContent = Citys;
                return(Responce);
            }
            catch (Exception ex)
            {
                Responce.Success = false;
                Responce.Message = $"ERROR GetCities :{ex.InnerException}";
            }
            return(Responce);
        }
Beispiel #16
0
        public Responce updateProduct(String database, DetalleProducto producto)
        {
            Responce respuesta = new Responce();

            using (IDbConnection db = new SqlConnection(ConfigurationManager.AppSettings[database].ToString()))
            {
                DynamicParameters parameter = new DynamicParameters();

                parameter.Add("@idProductoEcommerce", producto.idProductoEcommerce);
                parameter.Add("@producto", producto.producto);
                parameter.Add("@descripcion", producto.descripcion);
                parameter.Add("@unidadVenta", producto.unidadVenta);
                parameter.Add("@precioVenta", producto.precioVenta);
                parameter.Add("@idCategoriaEcommerce", producto.idCategoriaEcommerce);
                parameter.Add("@idMarcaEcommerce", producto.idMarcaEcommerce);
                parameter.Add("@identificador", producto.identificador);



                try
                {
                    respuesta = db.QuerySingle <Responce>("BC_SP_CREA_EDITAR_PRODUCTO_ECOMMERCE_ADMIN", parameter, commandType: CommandType.StoredProcedure);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

            return(respuesta);
        }
Beispiel #17
0
        public Responce CancelTable(long chatId)
        {
            try
            {
                var table = _service.GetActiveTable(chatId);
                if (table != null)
                {
                    if (table.TableNumber == null)
                    {
                        _service.DeleteTable(table.Id);
                    }
                    else
                    {
                        _service.UpdateTableState(table.Id, SessionState.Sitted);
                    }
                }

                return(new Responce
                {
                    ChatId = chatId,
                    ResponceText = "Вы в главном меню."
                });
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #18
0
        public Responce RemoveFromOrder(long chatId)
        {
            try
            {
                var table = _service.GetActiveTable(chatId);

                if (table.Orders.Any())
                {
                    if (table.Cheque != null && table.Cheque.PaymentRecieved)
                    {
                        return new Responce {
                                   ResponceText = "Извините, но заказ уже оплачен!"
                        }
                    }
                    ;

                    var resp = ShowCart(chatId);
                    resp.ResponceText += Environment.NewLine + "Отправьте сообщением номер блюда, которое вы хотите убрать из заказа";

                    return(resp);
                }
                else
                {
                    return(new Responce {
                        ResponceText = "Вы пока еще ничего не заказали :("
                    });
                }
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #19
0
        public IActionResult DeleteConfirm(int responceID)
        {
            Responce res = ResponceDB.GetOneResponce(responceID, context);

            ResponceDB.DeleteResponce(res, context);
            return(RedirectToAction("Responces"));
        }
Beispiel #20
0
        public Responce Greetings(long chatId)
        {
            try
            {
                var newTable = _service.CreateTable(chatId);

                var restaurants = _service.GetAllActiveRestaurants();

                if (restaurants.Count > 1)
                {
                    return(new Responce
                    {
                        ChatId = chatId,
                        ResponceText = "В каком вы заведении?"
                    });
                }
                else
                {
                    var rest = restaurants.FirstOrDefault();
                    _service.AssignRestaurant(chatId, rest.Name);
                    _service.UpdateTableState(chatId, SessionState.InQueue);

                    return(new Responce
                    {
                        ChatId = chatId,
                        ResponceText = "Введите номер стола за которым вы сидите:"
                    });
                }
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #21
0
        public Responce AddRemark(long chatId, string message)
        {
            try
            {
                var table = _service.GetActiveTable(chatId);

                if (table != null)
                {
                    _service.UpdateDishRemark(table.Id, message);
                    _service.UpdateTableState(chatId, SessionState.Sitted);

                    return(new Responce {
                        ChatId = chatId, ResponceText = "Хорошо, чтобы оформить заказ перейдите в корзину."
                    });
                }
                else
                {
                    return(new Responce {
                        ChatId = chatId, ResponceText = "Нажмите \"Заказ за столиком\" в главном меню, чтобы сделать заказ!"
                    });
                }
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #22
0
        public Responce CloseTimeArriving(long chatId)
        {
            try
            {
                var table = _service.GetActiveTable(chatId);

                if (table != null)
                {
                    _service.UpdateTableState(chatId, SessionState.Sitted);

                    return(new Responce
                    {
                        ChatId = chatId,
                        ResponceText = "Напишите \"Меню\" в чат и я принесу его вам.",
                    });
                }
                else
                {
                    return(Responce.UnknownResponce(chatId));
                }
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #23
0
        public Responce CloseMenu(long chatId)
        {
            try
            {
                var table = _service.GetActiveTable(chatId);

                if (table != null)
                {
                    if (table.State != SessionState.OrderPosted)
                    {
                        _service.UpdateTableState(chatId, SessionState.Sitted);
                    }

                    return(new Responce
                    {
                        ChatId = chatId,
                        ResponceText = "Нажмите \"Меню\" и я принесу его вам.",
                    });
                }
                else
                {
                    return(new Responce
                    {
                        ChatId = chatId,
                        ResponceText = "Нажмите \"Заказ за столиком\", чтобы сделать заказ!",
                    });
                }
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #24
0
        public Responce LeaveBooking(long chatId, string text)
        {
            try
            {
                _service.CreateBooking(new Booking {
                    ChatId = chatId, Date = DateTime.Now, Id = Guid.NewGuid(), Text = text
                });

                var table = _service.GetActiveTable(chatId);
                if (table != null)
                {
                    if (table.TableNumber == null)
                    {
                        _service.DeleteTable(table.Id);
                    }
                    else
                    {
                        _service.UpdateTableState(table.Id, SessionState.Sitted);
                    }
                }

                return(new Responce
                {
                    ChatId = chatId,
                    ResponceText = "Скоро с вами свяжутся!"
                });
            }
            catch (Exception)
            {
                return(Responce.UnknownResponce(chatId));
            }
        }
Beispiel #25
0
 public static void AddExceptionHandler(this IApplicationBuilder app)
 {
     app.UseExceptionHandler(builder =>
     {
         builder.Run(async context =>
         {
             context.Response.ContentType = "application/json";
             var ex = context.Features.Get <IExceptionHandlerFeature>();
             if (ex != null)
             {
                 var response = new Responce <object>()
                 {
                     Result = null,
                     Error  = new Error()
                     {
                         Id      = ErrorType.Validation,
                         Message = ex.Error.Message
                     }
                 };
                 await context.Response.WriteAsync(JsonConvert.SerializeObject(response, new JsonSerializerSettings {
                     Formatting = Formatting.Indented
                 }));
             }
         });
     });
 }
Beispiel #26
0
        public ActionResult DeleteConfirmed(int id)
        {
            Responce responce = db.Responce.Find(id);

            db.Responce.Remove(responce);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public Responce createUser(HttpListenerRequest request)
        {
            User user = parseUser(request);

            userRepository.createUser(user);

            return(Responce.ok((UserPlane)user));
        }
Beispiel #28
0
        public override ISignalRRecvQueueMsg TakePendingMsg()
        {
            Responce newResponce = null;

            this.internalResponceQueue.TryDequeue(out newResponce);

            return(new ServerResponce(newResponce));
        }
        public async Task <IHttpActionResult> ChangePassword(ForgotPasswordRequest model)
        {
            Responce <bool> responce = new Responce <bool>();

            responce.Success = true;
            try
            {
                var user = await UserManager.FindByNameAsync(model.Email);

                if (user != null)
                {
                    if (string.Equals(model.OTP, user.OTP) == true)
                    {
                        string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                        IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, code, model.Password);

                        //user.OTP = string.Empty;
                        //await UserManager.UpdateAsync(user);
                        if (!result.Succeeded)
                        {
                            List <string> errors = new List <string>();
                            foreach (var item in result.Errors)
                            {
                                errors.Add(item);
                            }
                            var Allerrors = string.Join(",", errors);
                            responce.ResponeContent = false;
                            responce.Fail(Allerrors);
                            return(Content(HttpStatusCode.BadRequest, responce));
                        }
                        responce.ResponeContent = true;
                        responce.Success        = true;
                        return(Ok(responce));
                    }
                    else
                    {
                        responce.Success        = false;
                        responce.ResponeContent = false;
                        return(Content(HttpStatusCode.BadRequest, responce));
                    }
                }
                else
                {
                    responce.Success        = false;
                    responce.ResponeContent = false;
                    return(Content(HttpStatusCode.BadRequest, responce));
                }
            }
            catch (Exception ex)
            {
                responce.Success        = false;
                responce.ResponeContent = false;

                responce.Message = $"ERROR ChangePassword :{ex.ToString()}";
                return(Content(HttpStatusCode.BadRequest, responce));
            }
        }
Beispiel #30
0
        public Responce getAnimals(HttpListenerRequest request)
        {
            foreach (Consuming animal in DB.animals)
            {
                animal.calculateFeedDate();
            }

            return(Responce.ok(DB.getAnimals()));
        }