Ejemplo n.º 1
0
        /// <summary>
        /// Metoda rozwiązująca konflikt pomiędzy dwoma dzierżawcami, gdy przedmiot sporu jest obecnie dzierżawiony
        /// </summary>
        /// <param name="resource">Przedmiot konfliktu</param>
        /// <param name="tenant">Dzierżawca wnoszący o dzierżawę</param>
        /// <param name="leaseTill">Termin do którego wniesiono o dzierżawę</param>
        /// <returns></returns>
        private IActionResult ResolveTenantsConflict(IResourceData resourceData, ITenant tenant, DateTime leaseTill)
        {
            var concurrent = _tenants.GetTenant(resourceData.LeasedTo);

            if (concurrent == null)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Resource is leased to tenant which is not existing anymore, an error occured."));
            }
            if (concurrent.Priority < tenant.Priority)
            {
                if (LeaseResource(_resources.GetResource(resourceData.Id), tenant, leaseTill))
                {
                    // Powiadom nowego dzierżawcę
                    var msg = $"Resource with an id of:{resourceData.Id} leased to the tenant with an ID of {tenant.Id}, and message has been sent succesfully";
                    _email.NotifyByEmail(tenant.Id, _leasingDatas.GetDataAboutTenant(tenant.Id).EmailAddress,
                                         "Podpisano umowę dzierżawy", $"Dot. zasobu o id {resourceData.Id}, będzie trwać do w dn. {leaseTill}", _config);
                    // Powiadom wywłaszczonego dzierżawcę
                    msg = $"Resource with an id of:{concurrent.Id} has been expropriated from the tenant with an ID of {tenant.Id}, and message has been sent succesfully";
                    _email.NotifyByEmail(tenant.Id, _leasingDatas.GetDataAboutTenant(concurrent.Id).EmailAddress,
                                         "Wywłaszczono umowę dzierżawy", $"Dot. zasobu o id {resourceData.Id}, ze skutkiem natychmiastowym", _config);
                    return(Ok(msg));
                }
                else
                {
                    _logger.LogToFile("Something went bad when resolving the tenants conflict, inspect ResourcesController, line 368", "errors.txt");
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Somehow cannot lease the resource, check the 'errors.txt' file"));
                }
            }
            return(NotFound("Resource with such an ID is already leased by a tenant with higher priority"));
        }
Ejemplo n.º 2
0
        public ActionResult AddConfigInfo(string id, string pid)
        {
            ConfigInfo CInfo = null;

            if (string.IsNullOrEmpty(id))//id=cofingId
            {
                CInfo = new ConfigInfo();
            }
            else
            {
                CInfo = BoFactory.GetVersionTrackBo.GetConfigInfoById(id);
            }

            IList <ConfigCategory> list = BoFactory.GetVersionTrackBo.GetMainCategoryList();//获取主程序配置分类信息

            if (list != null)
            {
                if (list.Count > 0)
                {
                    IResourceData[] datas = new IResourceData[list.Count];
                    for (int i = 0; i < list.Count; i++)
                    {
                        datas[i]      = ResourceDataFactory.GetResourceDataInstance();
                        datas[i].Code = list[i].ConfigCategoryCode;
                        datas[i].Name = list[i].DisplayName;
                    }
                    ViewData["list"] = datas;
                }
            }
            ViewData["pid"] = pid;//PluginCode

            return(View(CInfo));
        }
        public ActionResult AddConfigInfo(string id, string pid)
        {
            ConfigInfo CInfo = null;
            if (string.IsNullOrEmpty(id))//id=cofingId
                CInfo = new ConfigInfo();
            else
                CInfo = BoFactory.GetVersionTrackBo.GetConfigInfoById(id);

            IList<ConfigCategory> list = BoFactory.GetVersionTrackBo.GetMainCategoryList();//��ȡ���������÷�����Ϣ
            if (list != null)
            {
                if (list.Count > 0)
                {
                    IResourceData[] datas = new IResourceData[list.Count];
                    for (int i = 0; i < list.Count; i++)
                    {
                        datas[i] = ResourceDataFactory.GetResourceDataInstance();
                        datas[i].Code = list[i].ConfigCategoryCode;
                        datas[i].Name = list[i].DisplayName;
                    }
                    ViewData["list"] = datas;
                }
            }
            ViewData["pid"] = pid;//PluginCode

            return View(CInfo);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> AddDataAboutResource(IResourceData resourceData)
        {
            await Context.ResourceDatas.AddAsync(resourceData as ResourceData);

            await Context.SaveChangesAsync();

            return(new OkObjectResult(0)); // z tego co wiem, "exited with code 0" ogółem oznacza powodzenie, tak też robię
        }
Ejemplo n.º 5
0
        ResourceTypeCode GetResourceType(IResourceData data)
        {
            if (data is BuiltInResourceData)
                return data.Code;

            var userData = (UserResourceData)data;
            return dataToNewType[userData].Code;
        }
Ejemplo n.º 6
0
        private static void DumpData(IResourceData data)
        {
            var reader = data.Contents.CreateReader(data.Contents.FileOffset, data.Contents.GetPhysicalSize());

            byte[] dump = reader.ReadToEnd();
            PrintCompilerVersion(dump);
            File.WriteAllBytes("dump.ahk", dump);
            Console.WriteLine("Dumped AHK script with a size of {0} bytes",
                              data.Contents.GetPhysicalSize().ToString());
        }
Ejemplo n.º 7
0
        ResourceTypeCode GetResourceType(IResourceData data)
        {
            if (data is BuiltInResourceData)
            {
                return(data.Code);
            }

            var userData = (UserResourceData)data;

            return(dataToNewType[userData].Code);
        }
Ejemplo n.º 8
0
        public ActionResult UpdatePluginInfo(string verid, string isAdd)
        {
            PluginInfo pinfo = null;

            ViewData["vername"]    = "";
            ViewData["actionCode"] = "";
            ViewData["summary"]    = "";
            ViewData["versionId"]  = "";
            ViewData["isAdd"]      = "";//是否升级

            IResourceData[] datas = new IResourceData[1];
            datas[0]         = ResourceDataFactory.GetResourceDataInstance();
            datas[0].Code    = "WebPlugin";
            datas[0].Name    = "Web页面插件";
            ViewData["list"] = datas;

            if (string.IsNullOrEmpty(verid))//若为新增
            {
                pinfo = new PluginInfo();
            }
            else
            {
                SearchVersionTrack search = new SearchVersionTrack();
                search.VID = verid;
                VersionTrack vsion = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];    //获取版本信息

                pinfo = BoFactory.GetVersionTrackBo.GetPluginInfo(vsion.PluginCode.ToString()); //获取插件信息

                if (isAdd.Equals("0"))                                                          //若为修改(可修改版本信息,扩展信息,插件信息)
                {
                    ViewData["vername"] = vsion.VersionName;                                    //获取版本信息

                    SearchConfig searchconfig = new SearchConfig();
                    searchconfig.PluginCode = vsion.PluginCode.ToString();
                    IList <ActionExtend> listAction = BoFactory.GetVersionTrackBo.QueryActionExtend(searchconfig);//获取扩展信息
                    if (listAction.Count > 0)
                    {
                        ViewData["actionCode"] = listAction[0].ActionCode;
                        ViewData["summary"]    = listAction[0].Summary;
                    }
                }
                else//(只可修改插件信息)
                {
                }
                ViewData["versionId"] = verid;
            }
            if (!string.IsNullOrEmpty(isAdd))
            {
                ViewData["isAdd"] = isAdd;
            }

            return(View(pinfo));
        }
Ejemplo n.º 9
0
        public ActionResult UpdatePluginInfo(string verid)
        {
            ViewData["actionCode"] = "";
            ViewData["summary"]    = "";
            ViewData["IsAction"]   = "";
            SearchVersionTrack search = new SearchVersionTrack();

            search.VID = verid;
            VersionTrack version = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];               //获取插件ID

            PluginInfo pinfo = BoFactory.GetVersionTrackBo.GetPluginInfo(version.PluginCode.ToString()); //获取插件信息

            if (pinfo.PluginCateCode.Equals(Constants.ActionCateCode))
            {
                ViewData["IsAction"] = "1";
            }

            IList <PluginCategory> list = BoFactory.GetVersionTrackBo.GetPluginCategoryInfo();//获取非web插件的分类信息

            if (list != null)
            {
                if (list.Count > 0)
                {
                    IResourceData[] datas = new IResourceData[list.Count];
                    for (int i = 0; i < list.Count; i++)
                    {
                        datas[i]      = ResourceDataFactory.GetResourceDataInstance();
                        datas[i].Code = list[i].PluginCateCode;
                        datas[i].Name = list[i].DisplayName;
                    }
                    ViewData["list"] = datas;
                }
            }

            SearchConfig searchconfig = new SearchConfig();

            searchconfig.PluginCode = version.PluginCode.ToString();
            IList <ActionExtend> listAction = BoFactory.GetVersionTrackBo.QueryActionExtend(searchconfig);//获取扩展信息

            if (listAction.Count > 0)
            {
                ViewData["actionCode"] = listAction[0].ActionCode;
                ViewData["summary"]    = listAction[0].Summary;
            }

            ViewData["versionId"] = verid;
            ViewData["vername"]   = version.VersionName;

            return(View(pinfo));
        }
Ejemplo n.º 10
0
        public static byte[] GetBytes(this IResourceData obj)
        {
            switch (obj)
            {
            case BuiltInResourceData d1:
                return(d1.Data as byte[] ?? throw new Exception("BuildInResourceData's data is not a byte[]"));

            case BinaryResourceData d2:
                return(d2.Data);

            default:
                throw new Exception("Unexpected type: " + obj.GetType());
            }
        }
        public ActionResult AddConfigInfo(string id, string pid)
        {
            ConfigInfo CInfo = null;
            if (string.IsNullOrEmpty(id))//id=cofingId
                CInfo = new ConfigInfo();
            else
                CInfo = BoFactory.GetVersionTrackBo.GetConfigInfoById(id);

            IResourceData[] datas = new IResourceData[1];
            datas[0] = ResourceDataFactory.GetResourceDataInstance();
            datas[0].Code = "PluginConfig";
            datas[0].Name = "������˲������";
            ViewData["list"] = datas;

            ViewData["pid"] = pid;//pluginId
            return View(CInfo);
        }
Ejemplo n.º 12
0
        public IActionResult SetDataAboutResource(Guid resourceId, IResourceData newData)
        {
            var processed = GetDataAboutResource(resourceId);

            if (processed == null)
            {
                throw new Exception("No resourceData found with such an Id");
            }

            processed.Availability = newData.Availability;
            processed.LeasedTo     = newData.LeasedTo;
            processed.OccupiedTill = newData.OccupiedTill;

            Context.Update(processed);
            Context.SaveChanges();

            return(new OkObjectResult(0));
        }
Ejemplo n.º 13
0
        public ActionResult AddConfigInfo(string id, string pid)
        {
            ConfigInfo CInfo = null;

            if (string.IsNullOrEmpty(id))//id=cofingId
            {
                CInfo = new ConfigInfo();
            }
            else
            {
                CInfo = BoFactory.GetVersionTrackBo.GetConfigInfoById(id);
            }

            IResourceData[] datas = new IResourceData[1];
            datas[0]         = ResourceDataFactory.GetResourceDataInstance();
            datas[0].Code    = "PluginConfig";
            datas[0].Name    = "常规个人插件配置";
            ViewData["list"] = datas;

            ViewData["pid"] = pid;//pluginId
            return(View(CInfo));
        }
Ejemplo n.º 14
0
 public ResourceElementOptions(ResourceElement resEl)
 {
     Name         = resEl.Name;
     ResourceData = resEl.ResourceData;
 }
Ejemplo n.º 15
0
		public ResourceElementOptions(ResourceElement resEl) {
			this.Name = resEl.Name;
			this.ResourceData = resEl.ResourceData;
		}
        public ActionResult UpdatePluginInfo(string verid, string isAdd)
        {
            PluginInfo pinfo = null;
            ViewData["vername"] = "";
            ViewData["actionCode"] = "";
            ViewData["summary"] = "";
            ViewData["versionId"] = "";
            ViewData["isAdd"] = "";//�Ƿ�����

            IResourceData[] datas = new IResourceData[1];
            datas[0] = ResourceDataFactory.GetResourceDataInstance();
            datas[0].Code = "WebPlugin";
            datas[0].Name = "Webҳ����";
            ViewData["list"] = datas;

            if (string.IsNullOrEmpty(verid))//������
                pinfo = new PluginInfo();
            else
            {
                SearchVersionTrack search = new SearchVersionTrack();
                search.VID = verid;
                VersionTrack vsion = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];//��ȡ�汾��Ϣ

                pinfo = BoFactory.GetVersionTrackBo.GetPluginInfo(vsion.PluginCode.ToString());//��ȡ�����Ϣ

                if (isAdd.Equals("0"))//��Ϊ�޸ģ����޸İ汾��Ϣ,��չ��Ϣ�������Ϣ��
                {
                    ViewData["vername"] = vsion.VersionName;//��ȡ�汾��Ϣ

                    SearchConfig searchconfig = new SearchConfig();
                    searchconfig.PluginCode = vsion.PluginCode.ToString();
                    IList<ActionExtend> listAction = BoFactory.GetVersionTrackBo.QueryActionExtend(searchconfig);//��ȡ��չ��Ϣ
                    if (listAction.Count > 0)
                    {
                        ViewData["actionCode"] = listAction[0].ActionCode;
                        ViewData["summary"] = listAction[0].Summary;
                    }
                }
                else//��ֻ���޸IJ����Ϣ��
                { }
                ViewData["versionId"] = verid;
            }
            if (!string.IsNullOrEmpty(isAdd))
                ViewData["isAdd"] = isAdd;

            return View(pinfo);
        }
Ejemplo n.º 17
0
 public ResourceController(IResourceData data)
 {
     this.MaxValue     = data.InitMaxValue;
     this.CurrentValue = data.StartValue;
 }
        public ActionResult UpdatePluginInfo(string verid)
        {
            ViewData["actionCode"] = "";
            ViewData["summary"] = "";
            ViewData["IsAction"] = "";
            SearchVersionTrack search = new SearchVersionTrack();
            search.VID = verid;
            VersionTrack version = BoFactory.GetVersionTrackBo.GetVersionTrack(search)[0];//��ȡ���ID

            PluginInfo pinfo = BoFactory.GetVersionTrackBo.GetPluginInfo(version.PluginCode.ToString());//��ȡ�����Ϣ
            if (pinfo.PluginCateCode.Equals(Constants.ActionCateCode))
                ViewData["IsAction"] = "1";

            IList<PluginCategory> list = BoFactory.GetVersionTrackBo.GetPluginCategoryInfo();//��ȡ��web����ķ�����Ϣ
            if (list != null)
            {
                if (list.Count > 0)
                {
                    IResourceData[] datas = new IResourceData[list.Count];
                    for (int i = 0; i < list.Count; i++)
                    {
                        datas[i] = ResourceDataFactory.GetResourceDataInstance();
                        datas[i].Code = list[i].PluginCateCode;
                        datas[i].Name = list[i].DisplayName;
                    }
                    ViewData["list"] = datas;
                }
            }

            SearchConfig searchconfig = new SearchConfig();
            searchconfig.PluginCode = version.PluginCode.ToString();
            IList<ActionExtend> listAction = BoFactory.GetVersionTrackBo.QueryActionExtend(searchconfig);//��ȡ��չ��Ϣ
            if (listAction.Count > 0)
            {
                ViewData["actionCode"] = listAction[0].ActionCode;
                ViewData["summary"] = listAction[0].Summary;
            }

            ViewData["versionId"] = verid;
            ViewData["vername"] = version.VersionName;

            return View(pinfo);
        }