Ejemplo n.º 1
0
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
                                               string[] movedAssets, string[] movedFromPath)
    {
        if (CheckResModified(importedAssets) || CheckResModified(deletedAssets) || CheckResModified(movedAssets))
        {
            string     path = System.IO.Path.Combine(RESOURCE_PORTAL_CONFIG_FOLDER, "MapChunnel.xml");
            TextReader tr   = new StreamReader(path);
            string     text = tr.ReadToEnd();

            if (text == null)
            {
                Debug.LogError("Portal config file not exist");
                return;
            }
            else
            {
                XmlSpreadSheetReader.ReadSheet(text);
                XmlSpreadSheet sheet = XmlSpreadSheetReader.Output;
                string[]       keys  = XmlSpreadSheetReader.Keys;

                object[] levelIds = sheet[keys[0]];

                List <PortalConfigData> tempList = new List <PortalConfigData>();

                for (int i = 0; i < levelIds.Length; i++)
                {
                    if (0 == i || 1 == i)
                    {
                        continue;
                    }
                    PortalConfigData data = new PortalConfigData();
                    data._SID        = Convert.ToInt32(sheet["sid"][i]);
                    data._portalType = Convert.ToInt32(sheet["type"][i]);
                    string[] mapID = Convert.ToString(sheet["destmapid"][i]).Split('+');
                    data._desMapID = new int[mapID.Length];
                    for (int j = 0; j < mapID.Length; ++j)
                    {
                        data._desMapID[j] = int.Parse(mapID[j]);
                    }

                    tempList.Add(data);
                }

                CreateConfigDataBase(tempList);
            }
        }
    }
Ejemplo n.º 2
0
        public JsonResult SavePortalSettingsConfig(PortalConfigData portalConfigData)
        {
            try
            {
                var token = _tokenValidator.Validate(HttpContext);
                if (!token.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        NotAuthenticated = true,
                        Message = $"Unauthorized:-{token.Message}",
                    }));
                }

                var setting = _context.Settings.FirstOrDefault();
                setting.UnitsRegLevels         = portalConfigData.UnitsLevel;
                setting.HostelRatio            = portalConfigData.HostelRatio ?? "";
                setting.ExamCardNotes          = portalConfigData.ExamCardNotes ?? "";
                setting.HostelDuration         = portalConfigData.HostelDuration;
                setting.HostelBookingStartDate = portalConfigData.BookingStartDate.GetValueOrDefault().AddDays(1).Date;
                var    rations         = setting.HostelRatio.Split(")*(");
                double totalPercentage = 0;
                foreach (var ratio in rations)
                {
                    double.TryParse(ratio, out double percentage);
                    totalPercentage = totalPercentage + percentage;
                }

                if (totalPercentage > 100)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, hostel allocation percentage cannot be greater than 100%",
                    }));
                }

                if (portalConfigData.ClassStatus != null)
                {
                    setting.ClassStatus = portalConfigData.ClassStatus;
                }

                var portalConfigs = _context.PortalConfigs.ToList();
                var message       = "";
                if (portalConfigs.Count > 0)
                {
                    portalConfigs.ForEach(p =>
                    {
                        portalConfigData.PortalConfigs.ForEach(r =>
                        {
                            if (p.Code == r.Code)
                            {
                                p.Status = r.Status;
                            }
                        });
                    });
                    _context.PortalConfigs.UpdateRange(portalConfigs);
                    message = "Settings have been updated";
                }
                else
                {
                    _context.PortalConfigs.AddRange(portalConfigData.PortalConfigs);
                    message = "Settings have been saved";
                }

                _context.SaveChanges();
                return(Json(new ReturnData <ExamCardStatusModel>
                {
                    Message = message,
                    Data = new ExamCardStatusModel {
                        Status = true
                    }
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "There was a problem when switching exam card status " + ex.Message
                }));
            }
        }