/// <summary>
 /// Obtains location informations from the Database creates LocationTable instances.
 /// </summary>
 /// <returns>
 /// Returns Observable collections which accept LocationTables as their type.
 /// </returns>
 public ObservableCollection <LocationTable> GetLocations()
 {
     try
     {
         ObservableCollection <LocationTable> locations = new ObservableCollection <LocationTable>();
         SQLQueryModel queryBuilder = new SQLQueryModel();
         string        query        = string.Format("SELECT locationID, zipCode, locationName FROM location;");
         DataTable     locDataTable = new DataTable();
         locDataTable = queryBuilder.ExecuteMySQLQuery(query);
         foreach (DataRow row in locDataTable.Rows)
         {
             _locationTable              = new LocationTable();
             _locationTable.LocationID   = Convert.ToInt32(row["locationID"]);
             _locationTable.LocationName = row["locationName"].ToString();
             _locationTable.ZipCode      = Convert.ToInt32(row["zipCode"]);
             locations.Add(_locationTable);
         }
         return(locations);
     }
     catch (ArgumentNullException nullex)
     {
         Protocol.WriteToProtocol(0, "RegisterNewUser() :" + nullex.Message + nullex.StackTrace, "Location is null Error");
         return(null);
     }
 }
        public async Task <IHttpActionResult> PostStudent(LocationTable location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Locations.Add(location);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (LocationExists(location.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = location.ID }, location));
        }
        public async Task <IHttpActionResult> PutStudent(string id, LocationTable location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != location.ID)
            {
                return(BadRequest());
            }

            db.Entry(location).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
 public Pprof()
 {
     Profile        = new Profile();
     _stringTable   = new StringTable(Profile);
     _functionTable = new FunctionTable(Profile, _stringTable);
     _locationTable = new LocationTable(Profile, _functionTable);
 }
 public LocationProfileController()
 {
     this._locationprofileTable = new LocationProfileTable();
     this._locationTable        = new LocationTable();
     //this._common = new CommonFunctions();
     validatepermissions = new validatePermissions();
 }
 public CircuitController()
 {
     profileTable         = new LocationProfileTable();
     HardwareModel        = new HardwareTable();
     locationTable        = new LocationTable();
     circuitTable         = new CircuitTable();
     circuitLocationTable = new CircuitLocationTable();
 }
Beispiel #7
0
 public InventoryController()
 {
     this._inventoryTable = new InventoryTable();
     this._userTable      = new UserTable();
     this._locationTable  = new LocationTable();
     this._profileTable   = new ProfileTable();
     this._hardwareTable  = new HardwareTable();
     this._logTable       = new LogBook.Controllers.LogBookController();
 }
Beispiel #8
0
 public MonitorController()
 {
     locationTable = new LocationTable();
     // _fieldsTable = new CustomFieldsTable("LocationCustomFields");
     _processesTable = new ProcessesTable();
     _diagramTable   = new DiagramTable();
     _circuitTable   = new CircuitTable();
     _usertable      = new UserTable();
     _monitorTable   = new ObjectRealMonitorTable();
 }
 public ProcessController()
 {
     processesTable         = new ProcessesTable();
     movementTable          = new MovementTable();
     authorizationTable     = new AuthorizationTable();
     locationTable          = new LocationTable();
     hardwareTable          = new HardwareTable();
     rulesTable             = new RulesTable();
     hardwareReferenceTable = new HardwareReferenceTable();
     validatepermissions    = new validatePermissions();
 }
        public async Task <IHttpActionResult> GetStudent(string id)
        {
            LocationTable location = await db.Locations.FindAsync(id);

            if (location == null)
            {
                return(NotFound());
            }

            return(Ok(location));
        }
Beispiel #11
0
 public LabelingController()
 {
     locationTable      = new LocationTable();
     userprofileTable   = new UserProfileTable();
     userTable          = new UserTable();
     objectTable        = new ObjectTable();
     objectRealTable    = new ObjectReal();
     notificationObject = new Notifications();
     classNotifications = new Notifications();
     _logTable          = new LogBook.Controllers.LogBookController();
 }
Beispiel #12
0
 public static string GetLocationForID(string id)
 {
     DataRow[] rows = LocationTable.Select(COL_LOCATION_OBJECTNAME + "='" + id + "'");
     if (rows.Length > 0)
     {
         return(Convert.ToString(rows[0][COL_LOCATION_NAME]));
     }
     else
     {
         return(id);
     }
 }
        public async Task <IHttpActionResult> DeleteStudent(string id)
        {
            LocationTable location = await db.Locations.FindAsync(id);

            if (location == null)
            {
                return(NotFound());
            }

            db.Locations.Remove(location);
            await db.SaveChangesAsync();

            return(Ok(location));
        }
        private ModulePackageDirectoryEntry CreateEntry(ModulePackageFile file)
        {
            ModulePackageDirectoryEntry entry = new ModulePackageDirectoryEntry();

            int fileLocationIndex = LocationTable.IndexOf(file.FileLocation);

            if (fileLocationIndex == -1)
            {
                fileLocationIndex = LocationTable.Count;
                LocationTable.Add(file.FileLocation);
            }

            entry.FileLocationIndex = (byte)fileLocationIndex;
            entry.FileName          = file.FileName;
            entry.FileSize          = (uint)file.FileContents.Length;

            return(entry);
        }
        public static void AddOrReplaceLocationData(string city, string postal, string cityCode, string country, string language, string state)
        {
            try
            {
                using (SQLiteConnection dbConn = new SQLiteConnection(new SQLitePlatformWinRT(), path))
                {
                    LocationTable newRow = new LocationTable
                    {
                        Id       = 0,
                        City     = city,
                        Postal   = postal,
                        CityCode = cityCode,
                        Country  = country,
                        Language = language,
                        State    = state
                    };

                    // ReSharper disable once AccessToDisposedClosure
                    dbConn.RunInTransaction(() => { dbConn.InsertOrReplace(newRow); });

                    TableQuery <ModuleTable> query = dbConn.Table <ModuleTable>();

                    foreach (ModuleTable moduleTable in query)
                    {
                        Module.Module module = (Module.Module)DeserializeModule(moduleTable.ModuleConfig);

                        module.City         = city;
                        module.Postal       = postal;
                        module.CityCode     = cityCode;
                        module.Country      = country;
                        module.Language     = language;
                        module.NewsCountry  = (Countries)Enum.Parse(typeof(Countries), country.ToUpper());
                        module.NewsLanguage = (Languages)Enum.Parse(typeof(Languages), language.ToUpper());

                        AddOrReplaceModule(moduleTable.ModuleName, module);
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Log.WriteException(exception);
            }
        }
Beispiel #16
0
        #pragma warning disable 1998
        private static async Task <Module> getModule(string value)
        #pragma warning restore 1998
        {
            ModuleType      moduleType      = ModuleType.NONE;
            string          city            = string.Empty;
            string          country         = string.Empty;
            string          language        = string.Empty;
            LatitudeCoords  latitudeCoords  = null;
            LongitudeCoords longitudeCoords = null;
            Categories      categories      = Categories.Business;
            Countries       countries       = Countries.AE;
            Languages       languages       = Languages.AF;

            if (value != string.Empty)
            {
                if (!value.Contains("news"))
                {
                    LocationTable locationTable = DataAccess.GetLocationData()?[0];

                    moduleType = (ModuleType)Enum.Parse(typeof(ModuleType), value.ToUpper());

                    if (locationTable != null)
                    {
                        switch (moduleType)
                        {
                        case ModuleType.NONE:
                            break;

                        case ModuleType.TIME:

                            Coordinates coordinates = await GoogleMapsGeocoding.GetCoordinatesForCity(locationTable.City, locationTable.State, locationTable.Country);

                            latitudeCoords  = coordinates.Latitude;
                            longitudeCoords = coordinates.Longitude;
                            break;

                        case ModuleType.WEATHER:

                            city     = locationTable.City;
                            country  = locationTable.Country;
                            language = locationTable.Language;
                            break;

                        case ModuleType.WEATHERFORECAST:

                            city     = locationTable.City;
                            country  = locationTable.Country;
                            language = locationTable.Language;
                            break;

                        case ModuleType.NEWS:
                            break;

                        case ModuleType.QUOTE:
                            break;

                        case ModuleType.JOKE:
                            break;
                        }
                    }
                }
                else
                {
                    moduleType = ModuleType.NEWS;

                    value = value.Remove(0, 4);

                    // To UppperCamelCase
                    value = value.First().ToString().ToUpper() + value.Substring(1);

                    categories = (Categories)Enum.Parse(typeof(Categories), value);

                    LocationTable locationTable = DataAccess.GetLocationData()?[0];

                    // ReSharper disable once InvertIf
                    if (locationTable != null)
                    {
                        countries = (Countries)Enum.Parse(typeof(Countries), locationTable.Country.ToUpper());

                        languages = (Languages)Enum.Parse(typeof(Languages), locationTable.Language.ToUpper());
                    }
                }
            }

            return(new Module
            {
                ModuleType = moduleType,
                City = city,
                Country = country,
                Language = language,
                LatitudeCoords = latitudeCoords,
                LongitudeCoords = longitudeCoords,
                NewsCategory = categories,
                NewsCountry = countries,
                NewsLanguage = languages
            });
        }
Beispiel #17
0
        private void CreateModel(ref LayoutModel model)
        {
            iRstSrv.TableData[] data = null;

            /*
             * check:
             * - TablePositionText = null -> post from location page or location-list-(edit-layout) page
             * - TablePositionText != null -> back from table-numbering page or refresh the page
             */
            if (string.IsNullOrEmpty(model.TablePositionText))
            {
                switch (model.Mode)
                {
                case Mode.CreateAfterRegistering:
                case Mode.CreateFromLocationList:
                case Mode.Create:
                case Mode.EditFromLocation:

                    if (model.IsReload)
                    {
                        break;
                    }

                    /*
                     * TODO:
                     * - Get table list from database
                     * - Compare with input (if from location)
                     * - Delete tables or add new table
                     */

                    // create from data that passed from location page
                    List <TableInfo> tableInfo = CreateTableInfo(model.TableText);

                    Dictionary <int, int> addDict = new Dictionary <int, int>();

                    List <int> deleteIDQueue = new List <int>();

                    var response = iRstSrvClient.Get().LocationGetTablesList_00_00_001(Common.Restaurant.RestaurantID.ToString(), model.LocationID.ToString(), Common.Token);

                    List <int> checkList = new List <int>();

                    foreach (var info in tableInfo)
                    {
                        checkList.Add(info.ChairNo);

                        LocationTable matched = null;

                        if (response.LocationTablesList != null)
                        {
                            var findQuery = response.LocationTablesList.Where(table => table.TableType == info.ChairNo);

                            if (findQuery.Count() > 0)
                            {
                                matched = findQuery.Single();


                                if (matched.TableIDs.Length > info.TableNo)
                                {
                                    // delete exist table
                                    for (int i = info.TableNo; i < matched.TableIDs.Length; i++)
                                    {
                                        deleteIDQueue.Add(matched.TableIDs[i]);
                                    }
                                }
                                else if (matched.TableIDs.Length < info.TableNo)
                                {
                                    int addingAmount = info.TableNo - matched.TableIDs.Length;

                                    addDict[matched.TableType] = addingAmount;
                                }
                            }
                        }

                        if (matched == null)
                        {
                            addDict[info.ChairNo] = info.TableNo;
                        }
                    }

                    if (response.LocationTablesList != null)
                    {
                        foreach (var e in response.LocationTablesList)
                        {
                            if (checkList.Contains(e.TableType))
                            {
                                continue;
                            }
                            else
                            {
                                foreach (var id in e.TableIDs)
                                {
                                    deleteIDQueue.Add(id);
                                }
                            }
                        }
                    }

                    // delete table from delete-id-queue
                    if (deleteIDQueue.Count > 0)
                    {
                        StringBuilder xml = new StringBuilder();
                        xml.Append("<tablelist>");

                        foreach (var id in deleteIDQueue)
                        {
                            xml.AppendFormat("<table><tableid>{0}</tableid></table>", id);
                        }

                        xml.Append("</tablelist>");

                        var deleteTableResponse = iRstSrvClient.Get().TableDeleteList_00_00_001(Common.Restaurant.RestaurantID.ToString(),
                                                                                                model.LocationID.ToString(), xml.ToString(), Common.Token);
                    }

                    // create table-data from add-dict
                    iRstSrv.TableData[] tableData = CreateTableData(addDict);

                    if (tableData.Length > 0)
                    {
                        StringBuilder xml = new StringBuilder();
                        xml.Append("<tablelist>");

                        foreach (var table in tableData)
                        {
                            xml.Append("<table>");
                            xml.AppendFormat("<tablenumber>{0}</tablenumber>", table.LayoutCode);
                            xml.AppendFormat("<noofchairs>{0}</noofchairs>", table.NoOfChairs);
                            xml.AppendFormat("<post>{0}</post>", table.PosT);
                            xml.AppendFormat("<posl>{0}</posl>", table.PosL);
                            xml.AppendFormat("<tableid>{0}</tableid>", table.TableID);
                            xml.Append("</table>");
                        }

                        xml.Append("</tablelist>");

                        var addTablesResponse = iRstSrvClient.Get().TableAddUpdateList_00_00_001(Common.Restaurant.RestaurantID.ToString(),
                                                                                                 model.LocationID.ToString(), xml.ToString(), Common.Token);
                    }
                    break;
                }

                data = iRstSrvClient.Get().TableGetList_01_03_092(Common.Restaurant.RestaurantID.ToString(), model.LocationID.ToString(), Common.Token).Tables;
            }
            else
            {
                data = Utils.ParseFullInfo(model.TablePositionText);
            }

            if (model.IsReload)
            {
                data = ResetPosition(data);
            }

            //CreateModel(ref model);
            model.Tables = Utils.CalculateTableWidth(data);
        }
        #pragma warning disable 1998
        private static async Task <Module> GetModule(string value)
        #pragma warning restore 1998
        {
            try
            {
                ModuleType      moduleType      = ModuleType.None;
                string          city            = string.Empty;
                string          postal          = string.Empty;
                string          cityCode        = string.Empty;
                string          country         = string.Empty;
                string          language        = string.Empty;
                LatitudeCoords  latitudeCoords  = null;
                LongitudeCoords longitudeCoords = null;
                Categories      categories      = Categories.Business;
                Countries       countries       = Countries.AE;
                Languages       languages       = Languages.AF;

                if (value != string.Empty)
                {
                    if (!value.Contains("news"))
                    {
                        LocationTable locationTable = DataAccess.GetLocationData()?[0];

                        moduleType = (ModuleType)Enum.Parse(typeof(ModuleType), Regex.Replace(value, @"[\d-]", string.Empty).ToUpper());

                        if (locationTable != null)
                        {
                            switch (moduleType)
                            {
                            case ModuleType.None:
                                break;

                            case ModuleType.Time:

                                Coordinates coordinates = await GoogleMapsGeocoding.GetCoordinatesForPostal(locationTable.Postal, locationTable.Country);

                                if (coordinates == null)
                                {
                                    break;
                                }

                                latitudeCoords  = coordinates.Latitude;
                                longitudeCoords = coordinates.Longitude;
                                break;

                            case ModuleType.Weather:

                                city     = locationTable.City;
                                postal   = locationTable.Postal;
                                cityCode = locationTable.CityCode;
                                country  = locationTable.Country;
                                language = locationTable.Language;
                                break;

                            case ModuleType.Weatherforecast:

                                city     = locationTable.City;
                                postal   = locationTable.Postal;
                                cityCode = locationTable.CityCode;
                                country  = locationTable.Country;
                                language = locationTable.Language;
                                break;

                            case ModuleType.News:
                                break;

                            case ModuleType.Quote:
                                break;

                            case ModuleType.Joke:
                                break;
                            }
                        }
                    }
                    else
                    {
                        moduleType = ModuleType.News;

                        value = value.Remove(0, 4);

                        // To UppperCamelCase
                        value = value.First().ToString().ToUpper() + value.Substring(1);

                        categories = (Categories)Enum.Parse(typeof(Categories), Regex.Replace(value, @"[\d-]", string.Empty));

                        LocationTable locationTable = DataAccess.GetLocationData()?[0];

                        // ReSharper disable once InvertIf
                        if (locationTable != null)
                        {
                            countries = (Countries)Enum.Parse(typeof(Countries), locationTable.Country.ToUpper());

                            languages = (Languages)Enum.Parse(typeof(Languages), locationTable.Language.ToUpper());
                        }
                    }
                }

                return(new Module
                {
                    ModuleType = moduleType,
                    City = city,
                    Postal = postal,
                    CityCode = cityCode,
                    Country = country,
                    Language = language,
                    LatitudeCoords = latitudeCoords,
                    LongitudeCoords = longitudeCoords,
                    NewsCategory = categories,
                    NewsCountry = countries,
                    NewsLanguage = languages
                });
            }
            catch (Exception exception)
            {
                Log.Log.WriteException(exception);
                return(new Module());
            }
        }