Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Count,MachineGroupId,Capacity,Id")] M_Resource machine)
        {
            if (id != machine.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(entity: machine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MachineExists(id: machine.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(actionName: "Index"));
            }
            ViewData[index : "MachineGroupId"] = new SelectList(items : _context.ResourceSkills, dataValueField : "Id", dataTextField : "Name", selectedValue : machine.Name);
            return(View(model: machine));
        }
Пример #2
0
        private async Task <APIResult> CheckResource(HttpContext ctx, string path)
        {
            resource = resourceService.Detail(path);
            if (resource == null)
            {
                return(APIResult.失败.SetMessage(LocalResource.NotFound));
            }

            if (resource.Authorize)
            {
                var token = ctx.Request.Headers["token"];
                if (string.IsNullOrEmpty(token))
                {
                    return(APIResult.用户_未登录);
                }

                int.TryParse(await redisClient.GetDatabase().StringGetAsync(SignInKey + token), out userId);
                var roleId = roleService.GetRoles(userId).Select(f => f.Id).ToList();
                if (roleId.Count == 0)
                {
                    return(APIResult.没有访问权限);
                }
                else
                {
                    var access = roleService.ValidatorRole(resource.Id, roleId.ToArray());
                    if (!access)
                    {
                        return(APIResult.没有访问权限);
                    }
                }
            }

            return(APIResult.成功);
        }
Пример #3
0
        /// <summary>
        /// 获取资源文件信息
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="directoryInfo"></param>
        /// <param name="fileInfo"></param>
        /// <param name="path"></param>
        /// <param name="result"></param>
        private static void GetResourceDirectoryInfo(M_Resource resource, ref DirectoryInfo directoryInfo, ref List <FileInfo> fileInfo, ref string path, ref bool result)
        {
            string serverName = string.Empty;

            switch (resource.RSType)
            {
            case MyResourceType.ZhangTao:
                path = Application.StartupPath + @"\SowerTestClient\Paper\Account";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                directoryInfo = new DirectoryInfo(path);
                fileInfo      = directoryInfo.GetFiles("*.casf").ToList();
                break;

            case MyResourceType.TiKU:
                path = Application.StartupPath + @"\data";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                directoryInfo = new DirectoryInfo(path);
                fileInfo      = directoryInfo.GetFiles("*.sdb").ToList();
                break;

            case MyResourceType.ZiLiao:
                path = Application.StartupPath + @"\Common\Resource";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                directoryInfo = new DirectoryInfo(path);
                fileInfo      = directoryInfo.GetFiles().ToList();
                break;

            default:
                path = Application.StartupPath + @"\Common\Resource";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                directoryInfo = new DirectoryInfo(path);
                fileInfo      = directoryInfo.GetFiles().ToList();
                break;
            }

            if (fileInfo == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(resource.RSPath))
            {
                return;
            }

            serverName = GetServerName(resource.RSPath);
            result     = fileInfo.Exists(f => Path.GetFileNameWithoutExtension(f.Name) == serverName);
        }
Пример #4
0
        private bool DownLoadFile(string copyPath)
        {
            bool downResult      = false;
            bool downMyJobResult = false;

            string downLoadUrl = string.Empty;
            string filePath    = string.Empty;
            string fileName    = string.Empty;
            string savePath    = string.Empty;

            string ftpFilePath   = "C:\\data\\";
            string ftpServerIp   = UserConfigSettings.Instance.ReadSetting("题库地址");
            string ftpRemotePath = UserConfigSettings.Instance.ReadSetting("题库目录");
            string ftpPort       = UserConfigSettings.Instance.ReadSetting("端口号");
            string ftpUserId     = UserConfigSettings.Instance.ReadSetting("ftp用户名");
            string ftpPassword   = UserConfigSettings.Instance.ReadSetting("ftp密码");
            bool   anonymous     = bool.Parse(UserConfigSettings.Instance.ReadSetting("匿名"));
            FtpWeb ftpWeb        = new FtpWeb(ftpServerIp, ftpRemotePath, ftpUserId, ftpPassword, ftpPort, 10000, false, anonymous);

            M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;

            try
            {
                btnDownLoad.Enabled = false;
                //下载地址
                downLoadUrl = fileHost.Replace(@"\", @"/") + resource.RSPath;
                //文件路径
                filePath = resource.RSPath;
                //文件名
                fileName = Path.GetFileName(filePath);
                //下载文件保存路径
                savePath = string.Format("C:\\{0}_{1}", PublicClass.StudentCode, fileName);
                //下载作业
                //downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "下载进度:");
                ftpWeb.Download(ftpFilePath, resource.RSPath, "", tsbBar, tsbMessage, "下载进度:");

                if (downResult)
                {
                    //解压资源到目录
                    ZipFileTools.UnZipSZL(savePath, copyPath);
                    //删除下载文件
                    File.Delete(savePath);
                    //设置已下载状态
                    dgvResult.SelectedRows[0].Cells["DownLoadState"].Value = "已下载";
                    downMyJobResult = true;
                }
            }
            catch (Exception ex)
            {
                PublicClass.ShowMessageOk(ex.Message);
                downMyJobResult = false;
            }
            finally
            {
                btnDownLoad.Enabled = true;
            }

            return(downMyJobResult);
        }
Пример #5
0
        public M_Resource Add(M_Resource resource)
        {
            resource.CreateTime = DateTime.Now;
            resource.State      = 0;
            resource            = dbContext.M_Resource.Insert.Add(resource);

            return(resource);
        }
Пример #6
0
 private M_ResourceSetup CreateNewSetup(M_Resource resource, M_ResourceCapabilityProvider capabilityProvider, bool usedInProcessing, bool usedInSetup, long setupTime)
 {
     return(new M_ResourceSetup
     {
         ResourceCapabilityProviderId = capabilityProvider.Id, ResourceId = resource.Id,
         Name = $"Setup {capabilityProvider.Name} {resource.Name}", UsedInProcess = usedInProcessing, UsedInSetup = usedInSetup,
         SetupTime = setupTime
     });
 }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Name,Count,MachineGroupId,Capacity,Id")] M_Resource machine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(entity: machine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(actionName: "Index"));
            }
            ViewData[index : "MachineGroupId"] = new SelectList(items : _context.ResourceSkills, dataValueField : "Id", dataTextField : "Name", selectedValue : machine.Name);
            return(View(model: machine));
        }
Пример #8
0
        internal M_Resource[] Init(MasterDBContext context)
        {
            var resources = new M_Resource[] {
                SAW_1,
                SAW_2,
                DRILL_1,
                ASSEMBLY_1,
                ASSEMBLY_2
            };

            context.Resources.AddRange(entities: resources);
            context.SaveChanges();
            return(resources);
        }
Пример #9
0
        private void btnDownLoad_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvResult.SelectedRows.Count == 0)
                {
                    return;
                }

                M_Resource      resource      = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;
                DirectoryInfo   directoryInfo = null;
                List <FileInfo> fileInfo      = null;

                string path          = string.Empty;
                string resourceModel = cboResourceModel.SelectedValue.ToString();
                bool   result        = false;
                GetResourceDirectoryInfo(resource, ref directoryInfo, ref fileInfo, ref path, ref result);
                this.ParentForm.Enabled = false;
                if (result)
                {
                    DialogResult dialogResult = PublicClass.ShowMessageOKCancel("该资源文件已经存在,您确定继续下载并覆盖吗?");
                    if (dialogResult == DialogResult.OK)
                    {
                        DownLoad(directoryInfo.FullName);
                    }
                }
                else
                {
                    switch (resourceModel)
                    {
                    case "1":
                        DownLoad(directoryInfo.FullName);
                        break;

                    case "2":
                        Process.Start(resource.Url);
                        break;

                    default:
                        break;
                    }
                }
                this.ParentForm.Enabled = true;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(frmLogin), ex);
                CommonUtil.WriteLog(ex);
            }
        }
Пример #10
0
        public List <M_ResourceCapabilityProvider> GetCapabilityProviders(M_Resource resource)
        {
            var capabilityForResource = _dBContext.ResourceSetups
                                        .Include(x => x.ResourceCapabilityProvider)
                                        .ThenInclude(x => x.ResourceCapability)
                                        .Where(x => x.ResourceId == resource.Id).ToList();

            var capabilityProviderIds  = capabilityForResource.Select(x => x.ResourceCapabilityProviderId);
            var capabilitesForResource = _dBContext.ResourceCapabilityProviders
                                         .Include(x => x.ResourceCapability)
                                         .ThenInclude(x => x.ParentResourceCapability)
                                         .Include(x => x.ResourceSetups)
                                         .ThenInclude(x => x.Resource)
                                         .Where(x => capabilityProviderIds.Contains(x.Id));

            return(capabilitesForResource.ToList());
        }
Пример #11
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var path = context.HttpContext.Request.Path.Value;

            resource = GetService <ResourceService>().Detail(path);
            if (context.ModelState.IsValid == false)
            {
                foreach (var value in context.ModelState.Values)
                {
                    if (value.Errors.Any())
                    {
                        context.Result = APIResult.参数格式不正确.SetMessage($"参数格式不正确:{value.Errors.First().ErrorMessage}");
                        return;
                    }
                }
            }
        }
Пример #12
0
 internal MasterTableResource()
 {
     SAW_1 = new M_Resource {
         Name = "Saw 1", Count = 1
     };
     SAW_2 = new M_Resource {
         Name = "Saw 2", Count = 1
     };
     DRILL_1 = new M_Resource {
         Name = "Drill 1", Count = 1
     };
     ASSEMBLY_1 = new M_Resource {
         Name = "Assembly Unit 1", Count = 1
     };
     ASSEMBLY_2 = new M_Resource {
         Name = "Assembly Unit 2", Count = 1
     };
 }
Пример #13
0
        private void GetSetups(M_Resource resource, ProductionDomainContext masterCtx)
        {
            if (!resource.IsPhysical)
            {
                return;
            }
            var setups = masterCtx.ResourceSetups
                         .Include(x => x.ResourceCapabilityProvider)
                         .ThenInclude(x => x.ResourceCapability)
                         .Include(x => x.Resource)
                         .Where(x => x.ResourceId == resource.Id).ToList();

            System.Diagnostics.Debug.WriteLine($"Creating Resource: {resource.Name} with following setups...");
            foreach (var setup in setups)
            {
                System.Diagnostics.Debug.WriteLine($"{setup.Name} : {setup.ResourceCapabilityProvider.Name} : {setup.ResourceCapabilityProviderId}");
            }
        }
Пример #14
0
        public async Task <IActionResult> Setup(string setup)
        {
            _context.Resources.RemoveRange(entities: _context.Resources.Where(predicate: x => x.Capacity == 0).ToList());
            if (setup == "Large")
            {
                var Resources = new M_Resource[] {
                    new M_Resource {
                        Capacity = 0, Name = "Saw 3", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "Saw 4", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "Saw 5", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "Saw 6", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "Drill 2", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "Drill 3", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "AssemblyUnit 3", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "AssemblyUnit 4", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "AssemblyUnit 5", Count = 1
                    },
                    new M_Resource {
                        Capacity = 0, Name = "AssemblyUnit 6", Count = 1
                    }
                };
                _context.Resources.AddRange(entities: Resources);
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(actionName: "Index"));
        }
Пример #15
0
        private void btnLook_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvResult.SelectedRows.Count == 0)
                {
                    return;
                }

                string     path     = string.Empty;
                M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;

                switch (resource.RSType)
                {
                case MyResourceType.ZhangTao:
                    path = Application.StartupPath + @"\SowerTestClient\Paper\Account";
                    break;

                case MyResourceType.TiKU:
                    path = Application.StartupPath + @"\data";
                    break;

                case MyResourceType.ZiLiao:
                    path = Application.StartupPath + @"\Common\Resource";
                    break;

                default:
                    path = Application.StartupPath + @"\Common\Resource";
                    break;
                }

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                Process.Start(path);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(frmLogin), ex);
                CommonUtil.WriteLog(ex);
            }
        }
Пример #16
0
        private void dgvResult_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dgvResult.SelectedRows.Count == 0)
                {
                    return;
                }
                M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;

                if (e.ColumnIndex == 13)
                {
                    Process.Start(resource.Url);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(frmLogin), ex);
                CommonUtil.WriteLog(ex);
            }
        }
Пример #17
0
        public static ProposalForCapabilityProvider CreateDummyProposalForCapabilityProvider()
        {
            M_Resource OperatorResource = new M_Resource {
                Name = "Operator", IResourceRef = "Operator"
            };
            M_Resource MachineResource = new M_Resource {
                Name = "Machine", IResourceRef = "Machine"
            };
            M_Resource WorkerResource = new M_Resource {
                Name = "Worker", IResourceRef = "Worker"
            };
            M_Resource MachineResource2 = new M_Resource {
                Name = "Machine2", IResourceRef = "Machine2"
            };

            var _proposalForCapabilityProvider
                = new ProposalForCapabilityProvider(
                      new M_ResourceCapabilityProvider
            {
                Name           = "TestCapability",
                ResourceSetups = new List <M_ResourceSetup>
                {
                    new M_ResourceSetup {
                        Name = "Operator", UsedInSetup = true, UsedInProcess = false, Resource = OperatorResource
                    },
                    new M_ResourceSetup {
                        Name = "Machine", UsedInSetup = true, UsedInProcess = true, Resource = MachineResource
                    },
                    new M_ResourceSetup {
                        Name = "Worker", UsedInSetup = false, UsedInProcess = true, Resource = WorkerResource
                    },
                    new M_ResourceSetup {
                        Name = "Machine2", UsedInSetup = true, UsedInProcess = true, Resource = MachineResource2
                    },
                }
            });

            return(_proposalForCapabilityProvider);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private static M_Resource[] CreateResources()
        {
            var resources = new M_Resource[]
            {
                new M_Resource {
                    Name = RESCOURCE_SAW1, Count = 1, ResourceSetups = new List <M_ResourceSetup>()
                },
                new M_Resource {
                    Name = RESCOURCE_SAW2, Count = 1, ResourceSetups = new List <M_ResourceSetup>()
                },
                new M_Resource {
                    Name = RESCOURCE_DRILL1, Count = 1, ResourceSetups = new List <M_ResourceSetup>()
                },
                new M_Resource {
                    Name = RESCOURCE_ASSEMBLY1, Count = 1, ResourceSetups = new List <M_ResourceSetup>()
                },
                new M_Resource {
                    Name = RESCOURCE_ASSEMBLY2, Count = 1, ResourceSetups = new List <M_ResourceSetup>()
                },
            };

            return(resources);
        }
Пример #19
0
 private void dgvResult_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (dgvResult.SelectedRows.Count == 0)
         {
             return;
         }
         M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;
         if (resource.DownLoadState == "已下载")
         {
             tsbBar.Value = 100;
         }
         else
         {
             tsbBar.Value = 0;
         }
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog(typeof(frmLogin), ex);
         CommonUtil.WriteLog(ex);
     }
 }
Пример #20
0
 public Resource(ActorPaths actorPaths, M_Resource resource, long time, bool debug, IActorRef principal) : base(actorPaths: actorPaths, time: time, debug: debug, principal: principal)
 {
     _resource = resource;
 }
Пример #21
0
 // public Constructor
 public static Props Props(ActorPaths actorPaths, M_Resource resource, long time, bool debug, IActorRef principal)
 {
     return(Akka.Actor.Props.Create(factory: () => new Resource(actorPaths, resource, time, debug, principal)));
 }
Пример #22
0
 public List <ProductionOrderOperation> GetAllOperationsOnResource(M_Resource resource)
 {
     return(_dbTransactionData.ProductionOrderOperationGetAll().GetAll()
            .Where(x => x.GetMachineId().GetValue().Equals(resource.Id)).ToList());
 }
Пример #23
0
        public static IEnumerable <object[]> GetProposalTestData()
        {
            var testKit           = new TestKit();
            var operatorTestProbe = testKit.CreateTestProbe();
            var machineTestProbe  = testKit.CreateTestProbe();
            var workerTestProbe   = testKit.CreateTestProbe();
            var machine2TestProbe = testKit.CreateTestProbe();

            OperatorResource = new M_Resource {
                Name = "Operator", IResourceRef = operatorTestProbe.Ref
            };
            MachineResource = new M_Resource {
                Name = "Machine", IResourceRef = machineTestProbe.Ref
            };
            WorkerResource = new M_Resource {
                Name = "Worker", IResourceRef = workerTestProbe.Ref
            };
            MachineResource2 = new M_Resource {
                Name = "Machine2", IResourceRef = machine2TestProbe.Ref
            };


            _proposalForCapabilityProvider = new ProposalForCapabilityProvider(
                new M_ResourceCapabilityProvider
            {
                Name           = "TestCapability",
                ResourceSetups = new List <M_ResourceSetup>
                {
                    new M_ResourceSetup {
                        Name = "Operator", UsedInSetup = true, UsedInProcess = false, Resource = OperatorResource, SetupTime = 2
                    },
                    new M_ResourceSetup {
                        Name = "Machine", UsedInSetup = true, UsedInProcess = true, Resource = MachineResource
                    },
                    new M_ResourceSetup {
                        Name = "Worker", UsedInSetup = false, UsedInProcess = true, Resource = WorkerResource
                    },
                    new M_ResourceSetup {
                        Name = "Machine2", UsedInSetup = true, UsedInProcess = true, Resource = MachineResource2
                    },
                }
            });

            yield return(new object[] { // Test One with Setup
                new List <FProposal>()
                {
                    new FProposal(new List <FQueueingScope> {    // operator
                        new FQueueingScope(true, false, new FScope(2, 6)),
                        new FQueueingScope(true, false, new FScope(9, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , OperatorResource.IResourceRef as IActorRef
                                  , jobKey),
                    new FProposal(new List <FQueueingScope> {    // machine
                        new FQueueingScope(true, true, new FScope(3, 8)),
                        new FQueueingScope(true, true, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource.IResourceRef as IActorRef
                                  , jobKey),
                    new FProposal(new List <FQueueingScope> {    // worker
                        new FQueueingScope(true, false, new FScope(1, 1)),
                        new FQueueingScope(true, false, new FScope(4, 8)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , WorkerResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> {    // machine2
                        new FQueueingScope(true, true, new FScope(4, 8)),
                        new FQueueingScope(true, true, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource2.IResourceRef as IActorRef, jobKey),
                }, /* OperatorResource Start = */ 4L, /* MachineResource = */ 4L, /* Worker Start = */ 6L, "#1 Fit with setup"
            });

            yield return(new object[] { // Test Two without setup
                new List <FProposal>()
                {
                    new FProposal(new List <FQueueingScope> {    // operator
                        new FQueueingScope(true, false, new FScope(4, 6)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , OperatorResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> {    // machine
                        new FQueueingScope(true, false, new FScope(4, 8)),
                        new FQueueingScope(true, true, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> {    // worker
                        new FQueueingScope(true, false, new FScope(1, 1)),
                        new FQueueingScope(true, false, new FScope(4, 8)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , WorkerResource.IResourceRef as IActorRef, jobKey)
                }, /* Operator Start = */ 0L, /* Machine Start = */ 4L, /* Worker Start = */ 4, "#2 fit without setup"
            });

            yield return(new object[] { // Test Three NoFit
                new List <FProposal>()
                {
                    new FProposal(new List <FQueueingScope> {    // operator
                        new FQueueingScope(true, false, new FScope(5, 7)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , OperatorResource.IResourceRef as IActorRef
                                  , jobKey),
                    new FProposal(new List <FQueueingScope> {    // machine
                        new FQueueingScope(true, true, new FScope(3, 6)),
                        new FQueueingScope(true, true, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> {    // worker
                        new FQueueingScope(true, false, new FScope(1, 1)),
                        new FQueueingScope(true, false, new FScope(4, 6)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , WorkerResource.IResourceRef as IActorRef, jobKey)
                }, /* Operator Start = */ 10L, /* Machine Start = */ 10L, /* Worker Start = */ 12, "#3 No fit"
            });

            yield return(new object[] { // Fits with Setup but setup pushes scope
                new List <FProposal>()
                {
                    new FProposal(new List <FQueueingScope> { // operator
                        new FQueueingScope(true, false, new FScope(4, 7)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , OperatorResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> { // machine
                        new FQueueingScope(true, true, new FScope(3, 8)),
                        new FQueueingScope(true, true, new FScope(11, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> { // worker
                        new FQueueingScope(true, false, new FScope(2, 8)),
                        new FQueueingScope(true, false, new FScope(11, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , WorkerResource.IResourceRef as IActorRef, jobKey)
                }, /* Operator Start = */ 4L, /* Machine Start = */ 4L, /* Worker Start = */ 6, "#4 Fit with Setup but setup pushes scope"
            });

            yield return(new object[] { // Exact Fit
                new List <FProposal>()
                {
                    new FProposal(new List <FQueueingScope> { // operator
                        new FQueueingScope(true, false, new FScope(3, 5)),
                        new FQueueingScope(true, false, new FScope(9, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , OperatorResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> { // machine
                        new FQueueingScope(true, true, new FScope(3, 7)),
                        new FQueueingScope(true, true, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> { // worker
                        new FQueueingScope(true, false, new FScope(5, 7)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , WorkerResource.IResourceRef as IActorRef, jobKey)
                }, /* Operator Start = */ 3L, /* Machine Start = */ 3L, /* Worker Start = */ 5L, "#5 Exact Fit"
            });

            yield return(new object[] { // Detached Setup
                new List <FProposal>()
                {
                    new FProposal(new List <FQueueingScope> { // operator
                        new FQueueingScope(true, false, new FScope(2, 3)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , OperatorResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> { // machine
                        new FQueueingScope(true, true, new FScope(3, 8)),
                        new FQueueingScope(true, true, new FScope(11, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , MachineResource.IResourceRef as IActorRef, jobKey),
                    new FProposal(new List <FQueueingScope> { // worker
                        new FQueueingScope(true, false, new FScope(5, 7)),
                        new FQueueingScope(true, false, new FScope(10, long.MaxValue))
                    }
                                  , new FPostponeds.FPostponed(0)
                                  , _proposalForCapabilityProvider.ProviderId
                                  , WorkerResource.IResourceRef as IActorRef, jobKey)
                }, /* Operator Start = */ 11L, /* Machine Start = */ 11L, /* Worker Start = */ 13L, "#6 Detached Setup"
            });
        }
Пример #24
0
 public Resource(M_Resource resource)
 {
     _resource = resource;
 }
Пример #25
0
        /// <summary>
        /// 下载资源文件
        /// </summary>
        /// <param name="copyPath"></param>
        /// <returns></returns>
        private void DownLoad(string copyPath)
        {
            bool   downResult  = false;
            string downLoadUrl = string.Empty;
            string filePath    = string.Empty;
            string fileName    = string.Empty;
            string savePath    = string.Empty;
            string downPath    = Globals.DownLoadDir;

            try
            {
                if (dgvResult.SelectedRows.Count == 0)
                {
                    return;
                }
                M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;
                btnDownLoad.Enabled = false;
                //下载地址
                downLoadUrl = string.Format("{0}/{1}", fileHost, resource.RSPath.Replace(@"\", @"/"));
                //文件路径
                filePath = resource.RSPath;
                //文件名
                fileName = Path.GetFileName(filePath);
                //下载文件保存路径
                savePath = string.Format("{0}{1}", downPath, fileName);
                //下载作业
                downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "下载进度:");
                if (downResult)
                {
                    switch (resource.RSType)
                    {
                    case MyResourceType.ZhangTao:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;

                    case MyResourceType.TiKU:
                        downPath = string.Format(@"{0}\{1}", downPath, Path.GetFileNameWithoutExtension(fileName));
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, downPath);
                        DirectoryInfo directoryInfo = new DirectoryInfo(downPath);
                        FileInfo[]    fileInfo      = directoryInfo.GetFiles(); //只取.srk文件
                        if (fileInfo.Length > 0)
                        {
                            DownLoadTopicDB(fileInfo[0].FullName);
                        }
                        DirFileHelper.DeleteDirectory(downPath);
                        break;

                    case MyResourceType.ZiLiao:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;

                    default:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;
                    }
                    //删除下载文件
                    DirFileHelper.DeleteFile(savePath);
                    //设置已下载状态
                    dgvResult.SelectedRows[0].Cells["DownLoadState"].Value = "已下载";
                }
            }
            catch (Exception ex)
            {
                Msg.ShowError("资源下载失败,详情请参考系统错误日志。");
                LogHelper.WriteLog(typeof(frmResource), ex);
                CommonUtil.WriteLog(ex);
            }
            finally
            {
                btnDownLoad.Enabled = true;
            }
        }