/// <summary> /// 分页查询会员信息 /// </summary> /// <param name="currentPage"></param> /// <param name="pageSize"></param> /// <param name="memberQueryInfo"></param> /// <returns></returns> public async Task <VMResult <PageMemberInfo> > PageGetMemberInfo(int currentPage, int pageSize, MemberQueryInfo memberQueryInfo) { VMResult <PageMemberInfo> r = new VMResult <PageMemberInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { StringBuilder strSql = new StringBuilder(); StringBuilder strPageSql = new StringBuilder(); strSql.Append(@"SELECT * FROM Member m where 1=1"); if (!string.IsNullOrWhiteSpace(memberQueryInfo.UserName)) { strSql.Append(" and m.Name like'%" + memberQueryInfo.UserName + "%'"); } if (!string.IsNullOrWhiteSpace(memberQueryInfo.CardNumber)) { strSql.Append(" and m.CardNum = '" + memberQueryInfo.CardNumber + "'"); } if (memberQueryInfo.PayTypeID != 0) { strSql.Append(" and m.PayType = '" + memberQueryInfo.PayTypeID + "'"); } if (memberQueryInfo.Birthday != null) { strSql.Append(" and m.Birthday='" + memberQueryInfo.Birthday + "'"); } //总条数 int TotalCount = (await conn.QueryAsync <MemberInfo>(strSql.ToString())).Count(); //开始条数 int startNumber = (currentPage - 1) * pageSize; strPageSql.Append(@"SELECT DATA.* FROM (" + strSql + ") DATA ORDER BY 1 OFFSET " + startNumber + "ROWS FETCH NEXT " + pageSize + "ROWS ONLY"); var value = await conn.QueryAsync <MemberInfo>(strPageSql.ToString()); if (value != null) { r.Data.MemberInfos = value; r.Data.total = TotalCount; r.ResultCode = 0; } else { r.ResultMsg = "分页查询失败"; } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// Gets the mapping output object for specified input without Override input value /// </summary> /// <param name="res">The mapping output object with input specifications</param> /// <returns> Returns the mapping output object for specified input without Override input value</returns> public static VMResult GetVMResultforMapwithoutOverride(VMResult res) { VMSpecs specsWithoutOverride = new VMSpecs() { InputOriginalValues = null, InstanceName = string.Empty, OperatingSystem = res.Specs.OperatingSystem, CPUCores = res.Specs.CPUCores, MemoryInMB = res.Specs.MemoryInMB, SSDStorageInGB = res.Specs.SSDStorageInGB, SSDNumOfDisks = res.Specs.SSDNumOfDisks, HDDStorageInGB = res.Specs.HDDStorageInGB, HDDNumOfDisks = res.Specs.HDDNumOfDisks, PricePerMonth = 0, AzureVMOverride = string.Empty, Comments = string.Empty, IsValid = true, ValidationMessage = string.Empty }; VMResult vmResWithoutInputOverride = new VMResult(specsWithoutOverride); vmResWithoutInputOverride.ProjAzureVM.PremiumDisks = res.ProjAzureVM.PremiumDisks; vmResWithoutInputOverride.ProjAzureVM.StandardDisks = res.ProjAzureVM.StandardDisks; return(vmResWithoutInputOverride); }
/// <summary> /// 根据供应商ID获取供应商详细信息 /// </summary> /// <param name="ID"></param> /// <returns></returns> public async Task <VMResult <SupplierInfo> > GetSupplierInfoByID(int ID) { VMResult <SupplierInfo> r = new VMResult <SupplierInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"SELECT * FROM Supplier s WHERE s.ID=@ID"; var value = await conn.QueryFirstOrDefaultAsync <SupplierInfo>(strSql, new { ID }); if (value == null) { r.ResultMsg = "根据ID获取供应商信息失败"; return(r); } r.Data = value; r.ResultCode = 0; } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 根据ID获取商品信息 /// </summary> /// <param name="ID"></param> /// <returns></returns> public async Task <VMResult <GoodsInfo> > GetGoodsInfoByID(int ID) { VMResult <GoodsInfo> r = new VMResult <GoodsInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"SELECT g.*,s.Name AS SupplierName FROM Goods g LEFT JOIN Supplier s ON s.ID=g.SupplierID WHERE g.ID=@ID"; var value = await conn.QueryFirstOrDefaultAsync <GoodsInfo>(strSql, new { ID }); if (value == null) { r.ResultMsg = "根据ID获取商品信息失败"; return(r); } r.Data = value; r.ResultCode = 0; } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
public async Task <VMResult <UserInfo> > Login(string account, string password) { VMResult <UserInfo> r = new VMResult <UserInfo>(); string md5PassWord = EncryptString(password); using (var conn = DapperHelper.CreateConnection()) { string strSql = @"SELECT * FROM [User] u WHERE u.Account=@Account and u.Password=@Password"; var value = await conn.QueryFirstOrDefaultAsync <UserInfo>(strSql, new { Account = account, Password = md5PassWord }); if (value == null) { r.ResultMsg = "账号或用户名错误"; } else { r.ResultCode = 0; r.Data = value; } } return(r); }
/// <summary> /// 新增会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > AddMemberInfo(MemberInfo memberInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string CardNumSql = @"SELECT m.CardNum FROM Member m WHERE m.CardNum=@CardNum"; var CardNum = await conn.QueryFirstOrDefaultAsync <string>(CardNumSql, new{ memberInfo.CardNum }); if (!string.IsNullOrWhiteSpace(CardNum)) { r.ResultMsg = "此会员卡号已存在"; } else { string strSql = @"INSERT INTO Member (CardNum,Name,Birthday,Money,Integral,PayType,Phone,Address,Creater,CreateTime) VALUES (@CardNum,@Name,@Birthday,@Money,@Integral,@PayType,@Phone,@Address,@Creater,@CreateTime)"; var value = await conn.ExecuteAsync(strSql, new { memberInfo.CardNum, memberInfo.Name, memberInfo.Birthday, memberInfo.Money, memberInfo.Integral, memberInfo.PayType, memberInfo.Phone, memberInfo.Address, memberInfo.Creater, CreateTime = DateTime.Now }); if (value == 0) { r.ResultMsg = "新增会员信息失败"; } else { r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 分页查询商品信息 /// </summary> /// <param name="currentPage"></param> /// <param name="pageSize"></param> /// <param name="goodsQueryInfo"></param> /// <returns></returns> public async Task <VMResult <pageGoodsInfo> > GetPageGoodsInfo(int currentPage, int pageSize, GoodsQueryInfo goodsQueryInfo) { VMResult <pageGoodsInfo> r = new VMResult <pageGoodsInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { StringBuilder strSql = new StringBuilder(); StringBuilder strPageSql = new StringBuilder(); strSql.Append(@"SELECT g.* ,s.Name AS SupplierName FROM Goods g LEFT JOIN Supplier s ON s.ID=g.SupplierID WHERE 1 = 1"); if (!string.IsNullOrWhiteSpace(goodsQueryInfo.Name)) { strSql.Append(" and g.Name='" + goodsQueryInfo.Name + "'"); } if (!string.IsNullOrWhiteSpace(goodsQueryInfo.Code)) { strSql.Append(" and g.Code='" + goodsQueryInfo.Code + "'"); } if (goodsQueryInfo.SupplierId != 0) { strSql.Append(" and g.SupplierID='" + goodsQueryInfo.SupplierId + "'"); } int total = (await conn.QueryAsync <GoodsInfo>(strSql.ToString())).Count(); int startNumber = (currentPage - 1) * pageSize; strPageSql.Append(@"SELECT DATA.* FROM (" + strSql + ") DATA ORDER BY 1 OFFSET " + startNumber + "ROWS FETCH NEXT " + pageSize + "ROWS ONLY"); var value = await conn.QueryAsync <GoodsInfo>(strPageSql.ToString()); if (value == null) { r.ResultMsg = "查询商品信息失败"; } else { r.Data.goodsInfos = value; r.Data.total = total; r.ResultCode = 0; } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 分页查询供应商信息 /// </summary> /// <param name="pageSupplierQueryInfo"></param> /// <returns></returns> public async Task <VMResult <PageSupplierInfo> > PageGetSupplierInfo(PageSupplierQueryInfo pageSupplierQueryInfo) { VMResult <PageSupplierInfo> r = new VMResult <PageSupplierInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { StringBuilder strSql = new StringBuilder(); StringBuilder strPageSql = new StringBuilder(); DynamicParameters paras = new DynamicParameters(); strSql.Append(@"SELECT * FROM Supplier s where 1=1"); if (!string.IsNullOrWhiteSpace(pageSupplierQueryInfo.supplierQueryInfo.Name)) { strSql.Append(" and s.Name='" + pageSupplierQueryInfo.supplierQueryInfo.Name + "'"); } if (!string.IsNullOrWhiteSpace(pageSupplierQueryInfo.supplierQueryInfo.Mobile)) { strSql.Append(" and s.Mobile='" + pageSupplierQueryInfo.supplierQueryInfo.Mobile + "'"); } if (!string.IsNullOrWhiteSpace(pageSupplierQueryInfo.supplierQueryInfo.LinkName)) { strSql.Append(" and s.LinkName='" + pageSupplierQueryInfo.supplierQueryInfo.LinkName + "'"); } int total = (await conn.QueryAsync <SupplierInfo>(strSql.ToString())).Count(); int startNumber = (pageSupplierQueryInfo.CurrentPage - 1) * pageSupplierQueryInfo.PageSize; strPageSql.Append(@"SELECT DATA.* FROM (" + strSql + ") DATA ORDER BY 1 OFFSET " + startNumber + "ROWS FETCH NEXT " + pageSupplierQueryInfo.PageSize + "ROWS ONLY"); var value = await conn.QueryAsync <SupplierInfo>(strPageSql.ToString()); if (value == null) { r.ResultMsg = "分页查询失败"; } else { r.Data.SupplierInfos = value; r.Data.total = total; r.ResultCode = 0; } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
static int Run(string input, string name) { Scanner scanner = new Scanner(input, name); List <Token> tokens = scanner.Tokens; if (scanner.HasScanned == false) { return(0); } Parser parser = new Parser(tokens, name); Node program = parser.ParsedTree; if (parser.HasParsed == false) { return(0); } Chunker chunker = new Chunker(program, name, Prelude.GetPrelude()); Chunk chunk = chunker.Chunk; if (chunker.HasChunked == true) { VM vm = new VM(chunk); VMResult result = vm.ProtectedRun(); if (result.status != VMResultType.OK) { Console.WriteLine("Program returned ERROR!"); } else if (result.value.Type != UnitType.Null) { Console.WriteLine("Program returned: " + result.value); } // Print modules Unit machine_modules = chunk.GetUnitFromTable("machine", "modules"); Console.WriteLine(vm.ProtectedCallFunction(machine_modules, null)); // Print memory_use Unit machine_memory_use = chunk.GetUnitFromTable("machine", "memory_use"); Console.WriteLine(vm.ProtectedCallFunction(machine_memory_use, null)); // Print Global variable errors Unit errors_unit = vm.GetGlobal(chunk, "errors"); if (errors_unit.Type == UnitType.Integer) { Console.WriteLine("Total errors in test: " + errors_unit.integerValue); } } return(0); }
/// <summary> /// 根据查询条件查询 /// </summary> /// <param name="memberQueryInfo"></param> /// <returns></returns> public async Task <VMResult <PageMemberInfo> > GetMemberInfo(MemberQueryInfo memberQueryInfo) { VMResult <PageMemberInfo> r = new VMResult <PageMemberInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT * FROM Member m where 1=1"); if (!string.IsNullOrWhiteSpace(memberQueryInfo.UserName)) { strSql.Append(" and m.Name like'%" + memberQueryInfo.UserName + "%'"); } if (!string.IsNullOrWhiteSpace(memberQueryInfo.CardNumber)) { strSql.Append(" and m.CardNum = '" + memberQueryInfo.CardNumber + "'"); } if (memberQueryInfo.PayTypeID != 0) { strSql.Append(" and m.PayType = '" + memberQueryInfo.PayTypeID + "'"); } if (memberQueryInfo.Birthday != null) { strSql.Append(" and m.Birthday='" + memberQueryInfo.Birthday + "'"); } var value = await conn.QueryAsync <MemberInfo>(strSql.ToString()); if (value != null) { r.Data.MemberInfos = value; r.Data.total = value.ToList().Count;; r.ResultCode = 0; } else { r.ResultMsg = "查询用户信息为空!"; } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
public VMResult UploadTrayCellInfo(string info) { try { return(MesAcc.UploadTrayCellInfo(info)); } catch (Exception ex) { VMResult re = new VMResult(); re.ResultCode = -1; re.ResultMsg = "MES网络异常:" + ex.Message; return(re); } }
public VMResult UpdateStep(int StepNow, string TrayNo) { try { return(MesAcc.UpdateStep(StepNow, TrayNo)); } catch (Exception ex) { VMResult re = new VMResult(); re.ResultCode = -1; re.ResultMsg = "MES网络异常:" + ex.Message; return(re); } }
/// <summary> /// 更新会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > UpdateMemberInfo(MemberInfo memberInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"UPDATE Member set CardNum=@CardNum,Name=@Name,Birthday=@Birthday,Money=@Money,Integral=@Integral,PayType=@PayType, Phone=@Phone,Address=@Address,Updater=@Updater,UpdateTime=@UpdateTime WHERE ID=@ID"; var value = await conn.ExecuteAsync(strSql, new { memberInfo.CardNum, memberInfo.Name, memberInfo.Birthday, memberInfo.Money, memberInfo.Integral, memberInfo.PayType, memberInfo.Phone, memberInfo.Address, memberInfo.Updater, UpdateTime = DateTime.Now, memberInfo.ID }); if (value == 0) { r.ResultMsg = "修改会员信息失败"; } else { r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// Get the data disk count for the mapped managed disks for the instance /// </summary> /// <param name="vmRes">The mapping output object</param> /// <returns> Returns the data disk count for the mapped managed disks for the instance</returns> private static int GetDataDiskCount(VMResult vmRes) { int dataDiskCount = 0; dataDiskCount = (vmRes.ProjAzureVM.PremiumDisks != null && vmRes.ProjAzureVM.PremiumDisks.Count > 0) ? GetDiskCount(vmRes.ProjAzureVM.PremiumDisks) : dataDiskCount; dataDiskCount = (vmRes.ProjAzureVM.StandardDisks != null && vmRes.ProjAzureVM.StandardDisks.Count > 0) ? (dataDiskCount + GetDiskCount(vmRes.ProjAzureVM.StandardDisks)) : dataDiskCount; // Exclude OS Disk from count if (dataDiskCount > 0) { dataDiskCount--; } return(dataDiskCount); }
/// <summary> /// Gets the unique list of mapped Azure VM SKUs for Override output /// </summary> /// <param name="listOfProjectedVMs">The list of mapped Azure VMs</param> /// <param name="location">The Azure location</param> /// <param name="azureVMSizeList">The list of Azure VM SKUs</param> /// <param name="rateCalc">The object that can fetch the rates for Azure resources</param> /// <param name="mappingCoefficientCoresSelection">Mapping Coefficient for CPU Cores</param> /// <param name="mappingCoefficientMemorySelection">Mapping Coefficient for Memory</param> /// <returns> Returns the unique list of mapped Azure VM SKUs for Override output</returns> public static List <OverrideVMSpecs> GetUniqueProjectedListOfVMs(List <VMResult> listOfProjectedVMs, string location, List <AzureVMSizeListItem> azureVMSizeList, AzureResourceRateCalc rateCalc, double mappingCoefficientCoresSelection, double mappingCoefficientMemorySelection) { List <OverrideVMSpecs> uniqueListOfProjectedVMs = new List <OverrideVMSpecs>(); foreach (VMResult vmRes in listOfProjectedVMs) { if (!vmRes.Specs.IsValid || vmRes.ProjAzureVM == null) { continue; } bool mappedAzureVMHasSSD = (vmRes.ProjAzureVM.PremiumDisks != null && vmRes.ProjAzureVM.PremiumDisks.Count > 0) ? true : false; int dataDiskCount = GetDataDiskCount(vmRes); if (!uniqueListOfProjectedVMs.Exists( x => (x.OperatingSystem.Equals(vmRes.Specs.OperatingSystem, StringComparison.OrdinalIgnoreCase) && x.CPUCores == vmRes.Specs.CPUCores && x.MemoryInMB == vmRes.Specs.MemoryInMB && x.NumberOfDataDisks == dataDiskCount && x.HasSSDStorage == mappedAzureVMHasSSD))) { VMResult vmResUnique = null; if (vmRes.ProjAzureVM.IsMappedasperOverride) { vmResUnique = GetVMResultforMapwithoutOverride(vmRes); ProjectAzureVM(vmResUnique, location, azureVMSizeList, rateCalc, null, mappingCoefficientCoresSelection, mappingCoefficientMemorySelection); } else { vmResUnique = vmRes; } uniqueListOfProjectedVMs.Add(new OverrideVMSpecs() { OperatingSystem = vmRes.Specs.OperatingSystem, CPUCores = vmRes.Specs.CPUCores, MemoryInMB = vmRes.Specs.MemoryInMB, NumberOfDataDisks = dataDiskCount, HasSSDStorage = mappedAzureVMHasSSD, AzureProjVMSize = vmResUnique.ProjAzureVM.VMSize == null ? string.Empty : vmResUnique.ProjAzureVM.VMSize.Name, AzureProjVMCores = vmResUnique.ProjAzureVM.VMSize == null ? 0 : vmResUnique.ProjAzureVM.VMSize.NumberOfCores, AzureProjVMMemory = vmResUnique.ProjAzureVM.VMSize == null ? 0 : vmResUnique.ProjAzureVM.VMSize.MemoryInMB }); } } return(uniqueListOfProjectedVMs); }
/// <summary> /// 分页获取员工信息 /// </summary> /// <param name="currentPage"></param> /// <param name="pageSize"></param> /// <param name="staffQueryInfo"></param> /// <returns></returns> public async Task <VMResult <PageStaffInfo> > GetPageStaffInfo(int currentPage, int pageSize, StaffQueryInfo staffQueryInfo) { VMResult <PageStaffInfo> r = new VMResult <PageStaffInfo>(); try { using (var conn = DapperHelper.CreateConnection()) { StringBuilder strSql = new StringBuilder(); StringBuilder strPageSql = new StringBuilder(); strSql.Append(@"SELECT * FROM Staff s WHERE 1=1"); if (string.IsNullOrWhiteSpace(staffQueryInfo.Account)) { strSql.Append(" and s.Account='" + staffQueryInfo.Account + "'"); } if (string.IsNullOrWhiteSpace(staffQueryInfo.Name)) { strSql.Append(" and s.Name='" + staffQueryInfo.Name + "'"); } int total = (await conn.QueryAsync <StaffInfo>(strSql.ToString())).Count(); int startNumber = (currentPage - 1) * pageSize; strPageSql.Append(@"SELECT DATA.* FROM (" + strSql + ") DATA ORDER BY 1 OFFSET " + startNumber + "ROWS FETCH NEXT " + pageSize + "ROWS ONLY"); var value = await conn.QueryAsync <StaffInfo>(strPageSql.ToString()); if (value == null) { r.ResultMsg = "查询员工信息失败"; } else { r.Data.StaffInfos = value; r.Data.total = total; r.ResultCode = 0; } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// Loads the monthly cost for the compute hours component of the mapped Azure VM /// </summary> /// <param name="vmRes">The mapping output object</param> /// <param name="hoursinaMonth">Hours in a month</param> public static void LoadComputeHoursMonthlyCost(VMResult vmRes, int hoursinaMonth) { try { if (vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound) { vmRes.ProjAzureVM.ComputeHoursMonthlyCost = vmRes.ProjAzureVM.ComputeHoursRate * hoursinaMonth; vmRes.ProjAzureVM.AzureVMTotalMonthlyCost = vmRes.ProjAzureVM.ComputeHoursMonthlyCost + vmRes.ProjAzureVM.PremiumDisksMonthlyCost + vmRes.ProjAzureVM.StandardDisksMonthlyCost; vmRes.ProjAzureVM.MonthlyGrossMarginEstimates = vmRes.Specs.PricePerMonth - vmRes.ProjAzureVM.AzureVMTotalMonthlyCost; } } catch (Exception) { throw; } }
/// <summary> /// 编辑商品信息 /// </summary> /// <param name="updateGoodsInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > UpdateGoodsInfo(GoodsInfo updateGoodsInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"UPDATE Goods SET Name=@Name,Code=@Code,Spec=@Spec,RetailPrice=@RetailPrice,PurchasePrice=@PurchasePrice ,StorageNum=@StorageNum,SupplierID=@SupplierID, Updater=@Updater,UpdateTime=@UpdateTime WHERE ID=@ID"; var value = await conn.ExecuteAsync(strSql, new { updateGoodsInfo.Name, updateGoodsInfo.Code, updateGoodsInfo.Spec, updateGoodsInfo.RetailPrice, updateGoodsInfo.PurchasePrice, updateGoodsInfo.StorageNum, updateGoodsInfo.SupplierID, updateGoodsInfo.Updater, UpdateTime = DateTime.Now, updateGoodsInfo.ID }); if (value == 0) { r.ResultMsg = "编辑商品信息失败"; return(r); } r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 新增供应商信息 /// </summary> /// <param name="addGoodsInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > AddGoodsInfo(GoodsInfo addGoodsInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"INSERT INTO Goods (Name,Code,Spec,RetailPrice,PurchasePrice,StorageNum,SupplierID, Creater,CreateTime) VALUES (@Name,@Code,@Spec,@RetailPrice,@PurchasePrice,@StorageNum,@SupplierID,@Creater,@CreateTime)"; var value = await conn.ExecuteAsync(strSql, new { addGoodsInfo.Name, addGoodsInfo.Code, addGoodsInfo.Spec, addGoodsInfo.RetailPrice, addGoodsInfo.PurchasePrice, addGoodsInfo.StorageNum, addGoodsInfo.SupplierID, addGoodsInfo.Creater, CreateTime = DateTime.Now }); if (value == 0) { r.ResultMsg = "新增商品信息失败"; } else { r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 编辑员工信息 /// </summary> /// <param name="updateStaffInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > UpdateStaffInfo(StaffInfo updateStaffInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @" UPDATE Staff SET Account=@Account,Name=@Name,Age=@Age,Phone=@Phone,Salary=@Salary, EntryDate=@EntryDate,Updater=@Updater,UpdateTime=@UpdateTime WHERE ID=@ID"; var value = await conn.ExecuteAsync(strSql, new { updateStaffInfo.Account, updateStaffInfo.Name, updateStaffInfo.Age, updateStaffInfo.Phone, updateStaffInfo.Salary, updateStaffInfo.EntryDate, updateStaffInfo.Updater, UpdateTime = DateTime.Now, updateStaffInfo.ID }); if (value == 0) { r.ResultMsg = "编辑员工信息失败"; return(r); } r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 新增员工信息 /// </summary> /// <param name="addStaffInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > AddStaffInfo(StaffInfo addStaffInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"INSERT INTO Staff (Account,Name,Age,Phone,Salary,EntryDate,Creater,CreateTime) VALUES (@Account,@Name,@Age,@Phone,@Salary,@EntryDate,@Creater,@CreateTime)"; var value = await conn.ExecuteAsync(strSql, new { addStaffInfo.Account, addStaffInfo.Name, addStaffInfo.Age, addStaffInfo.Phone, addStaffInfo.Salary, addStaffInfo.EntryDate, addStaffInfo.Creater, CreateTime = DateTime.Now }); if (value == 0) { r.ResultMsg = "新增员工信息失败"; return(r); } r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// Loads the monthly cost for the mapped managed disks in the mapping output /// </summary> /// <param name="vmRes">the object containing the mapping output</param> /// <param name="location">the Azure location</param> /// <param name="rateCalc">the object that can fetch the rates for Azure resources</param> public static void LoadMonthlyCostForManagedDisks(VMResult vmRes, string location, AzureResourceRateCalc rateCalc) { try { if (vmRes.ProjAzureVM.PremiumDisks != null && vmRes.ProjAzureVM.PremiumDisks.Count > 0) { vmRes.ProjAzureVM.PremiumDisksMonthlyCost = GetCostforSpecifiedListofDisks(vmRes.ProjAzureVM.PremiumDisks, location, rateCalc); } if (vmRes.ProjAzureVM.StandardDisks != null && vmRes.ProjAzureVM.StandardDisks.Count > 0) { vmRes.ProjAzureVM.StandardDisksMonthlyCost = GetCostforSpecifiedListofDisks(vmRes.ProjAzureVM.StandardDisks, location, rateCalc); } } catch (Exception) { throw; } }
/// <summary> /// 编辑供应商信息 /// </summary> /// <param name="updatesSupplierInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > UpdateSupplierInfo(SupplierInfo updatesSupplierInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"UPDATE Supplier SET Name=@Name,LinkName=@LinkName, Mobile=@Mobile,Remark=@Remark,Updater=@Updater,UpdateTime=@UpdateTime WHERE ID=@ID"; var value = await conn.ExecuteAsync(strSql, new { updatesSupplierInfo.Name, updatesSupplierInfo.LinkName, updatesSupplierInfo.Mobile, updatesSupplierInfo.Remark, updatesSupplierInfo.Updater, UpdateTime = DateTime.Now, updatesSupplierInfo.ID }); if (value == 0) { r.ResultMsg = "编辑供应商信息失败"; return(r); } r.ResultCode = 0; r.Data = true; transaction.Complete(); } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// 新增供应商信息 /// </summary> /// <param name="addSupplierInfo"></param> /// <returns></returns> public async Task <VMResult <bool> > AddSupplierInfo(SupplierInfo addSupplierInfo) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"INSERT INTO Supplier (Name,LinkName,Mobile,Remark,Creater,CreateTime) VALUES (@Name,@LinkName,@Mobile,@Remark,@Creater,@CreateTime)"; var value = await conn.ExecuteAsync(strSql, new { addSupplierInfo.Name, addSupplierInfo.LinkName, addSupplierInfo.Mobile, addSupplierInfo.Remark, addSupplierInfo.Creater, CreateTime = DateTime.Now }); if (value == 0) { r.ResultMsg = "新增供应商信息失败"; return(r); } r.ResultCode = 0; r.Data = true; transaction.Complete(); } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
/// <summary> /// Maps the storage to managed disks /// </summary> /// <param name="specs">the object containing the input specifications</param> /// <param name="vmRes">the mapping output object</param> /// <param name="osDiskSSDSelection">The size of the OS Disk to be mapped if SSD</param> /// <param name="osDiskHDDSelection">The size of the OS Disk to be mapped if HDD</param> public static void MapStorage(VMSpecs specs, VMResult vmRes, string osDiskSSDSelection, string osDiskHDDSelection) { try { bool isOSDiskPremium = specs.SSDStorageInGB > 0 ? true : false; if (specs.SSDStorageInGB > 0) { vmRes.ProjAzureVM.PremiumDisks = MapStorageToManagedDisks(premiumManagedDiskList, specs.SSDStorageInGB, specs.SSDNumOfDisks, isOSDiskPremium); } if (specs.HDDStorageInGB > 0) { vmRes.ProjAzureVM.StandardDisks = MapStorageToManagedDisks(standardManagedDiskList, specs.HDDStorageInGB, specs.HDDNumOfDisks, !isOSDiskPremium); } if (isOSDiskPremium) { vmRes.ProjAzureVM.PremiumDisks = AddOSDisk(premiumManagedDiskList, vmRes.ProjAzureVM.PremiumDisks, osDiskSSDSelection); } else { vmRes.ProjAzureVM.StandardDisks = AddOSDisk(standardManagedDiskList, vmRes.ProjAzureVM.StandardDisks, osDiskHDDSelection); } if (vmRes.ProjAzureVM.PremiumDisks != null && vmRes.ProjAzureVM.PremiumDisks.Count > 0) { vmRes.ProjAzureVM.PremiumDisksStr = GetDiskListStr(vmRes.ProjAzureVM.PremiumDisks); } if (vmRes.ProjAzureVM.StandardDisks != null && vmRes.ProjAzureVM.StandardDisks.Count > 0) { vmRes.ProjAzureVM.StandardDisksStr = GetDiskListStr(vmRes.ProjAzureVM.StandardDisks); } } catch (Exception) { throw; } }
private bool MESBatteryFill(int fillSeq, string palletID, List <string> batteryList, ref string reStr) { try { ANCStepResult stepRe = MesAcc.GetStep(palletID); if (stepRe.ResultCode != 0) { reStr = stepRe.ResultMsg; return(false); } int channelMax = 36; JObject jsonObj = new JObject(new JProperty("Type", "One"), new JProperty("TrayNO", palletID)); if (fillSeq > 1) { jsonObj["Type"] = "Two"; } for (int i = 0; i < Math.Min(channelMax, batteryList.Count()); i++) { jsonObj.Add("Cell" + (i + 1).ToString(), batteryList[i]); } VMResult re = MesAcc.UploadTrayCellInfo(jsonObj.ToString()); if (re.ResultCode != 0) { reStr = re.ResultMsg; return(false); } else { return(true); } } catch (Exception ex) { reStr = ex.ToString(); return(false); } }
/// <summary> /// 删除会员信息 /// </summary> /// <param name="ID"></param> /// <returns></returns> public async Task <VMResult <bool> > DeleteMemberInfo(int ID) { VMResult <bool> r = new VMResult <bool>(); r.Data = false; try { using (TransactionScope transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { using (var conn = DapperHelper.CreateConnection()) { string strSql = @"DELETE FROM Member WHERE ID=@ID"; var value = await conn.ExecuteAsync(strSql, new { ID }); if (value == 0) { r.ResultMsg = "删除会员信息失败"; } else { r.Data = true; r.ResultCode = 0; transaction.Complete(); } } } } catch (Exception ex) { r.ResultMsg = ex.Message; } return(r); }
public override bool ExeBusiness(ref string reStr) { //Console.WriteLine("TES P1"); if (!nodeEnabled) { return(true); } if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } if (db2Vals[0] != 2) { db1ValsToSnd[1] = 1; } //任务撤销 if (db2Vals[1] == 3 && db1ValsToSnd[0] != 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(this.nodeName, string.Format("装载任务{0}撤销,托盘号:{1}", this.currentTask.TaskID, this.rfidUID)); currentTaskDescribe = "装载任务撤销"; this.currentTask = null; this.currentTaskPhase = 0; } Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); db1ValsToSnd[0] = 3;// return(true); } if (db1ValsToSnd[0] == 3 && db2Vals[1] == 1) { //任务撤销命令复位,应答也复位 db1ValsToSnd[0] = 1; } if (!FillTaskRequire(ref reStr)) { return(false); } // Console.WriteLine("TES P2"); //if(this.currentTask == null) //{ // return true; //} switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始执行装载任务"; this.db1ValsToSnd[1] = 2; //如果是一次装载,判断是否第一步 if (this.nodeID == "3001") { //如果是第1步,则上传MES步次,直接放行。通知PLC不用扫条码 ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; break; } if (SysCfg.SysCfgModel.ZhuyeMode == 1) //一步模式 { #region 一步模式 this.db1ValsToSnd[2] = 2; logRecorder.AddDebugLog(nodeName, string.Format("一次注液一步模式下,托盘{0}当前步次{1},等待装载 ", this.rfidUID, stepRe.Step)); #endregion } else if (SysCfg.SysCfgModel.ZhuyeMode == 2) //两步模式 { #region 两步模式 if (stepRe.Step < 3) { this.currentTaskDescribe = string.Format("{0}一次注液第1步,将跳过装载", this.rfidUID); int updateStep = 2; logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}当前步次{1},完成一次注液第1步后过站,不装载 ", this.rfidUID, stepRe.Step)); VMResult re = MesAcc.UpdateStep(updateStep, this.rfidUID); if (re.ResultCode != 0) { this.currentTaskDescribe = "更新MES步次失败," + re.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx ,11-16 } this.db1ValsToSnd[2] = 1; this.db1ValsToSnd[0] = 2; this.currentTaskPhase = 3; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } else if (stepRe.Step == 3) { this.db1ValsToSnd[2] = 2; logRecorder.AddDebugLog(nodeName, string.Format("一次注液两步模式下,托盘{0}当前步次{1},完成一次注液第2步后装载 ", this.rfidUID, stepRe.Step)); } else { if (this.db1ValsToSnd[2] != 3) { logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}步次错误,当前步次:{1} ", this.rfidUID, stepRe.Step)); } this.db1ValsToSnd[2] = 3; break; } #endregion } else { if (this.db1ValsToSnd[2] != 3) { logRecorder.AddDebugLog(nodeName, string.Format("一次注液模式错误,实际为{0}", SysCfg.SysCfgModel.ZhuyeMode)); } this.db1ValsToSnd[2] = 3; break; } } this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { if (this.db1ValsToSnd[0] == 4) { //装载错误状态 break; } //等待扫码完成 currentTaskDescribe = "RFID读取完成,等待电池条码数据"; if (db2Vals[1] != 2) { break; } if (SysCfg.SysCfgModel.SimMode) { //生成模拟数据 GenerateSimBatterys(); } //取电池条码数据 List <string> batteryList = new List <string>(); int validBatNum = 0; for (int i = 0; i < PalletCapacity; i++) { List <byte> batteryBytes = new List <byte>(); for (int j = 0; j < 20; j++) { int indexSt = 2 + i * 20 + j; batteryBytes.Add((byte)(this.db2Vals[indexSt] & 0xff)); batteryBytes.Add((byte)((this.db2Vals[indexSt] >> 8) & 0xff)); } //字节流转换成字符串 string batteryID = System.Text.ASCIIEncoding.UTF8.GetString(batteryBytes.ToArray()); batteryID = batteryID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' }).ToUpper(); if (batteryID.Contains("ERROR")) { batteryID = ""; } if (batteryID.Length > 22) { validBatNum++; if (batteryID.Length < 35 && batteryID.Substring(16, 6).ToUpper() == "17K03C") { batteryID = batteryID.Insert(22, "1"); } } batteryList.Add(batteryID); } if (validBatNum < 1) { if (this.db1ValsToSnd[0] != 5) { logRecorder.AddDebugLog(nodeName, string.Format("{0}电池数据为空", rfidUID)); } this.db1ValsToSnd[0] = 5; break; } #region 调用MES接口上传绑定数据,更新步次 int fillSeq = 1; if (this.nodeID == "3002") { fillSeq = 2; } logRecorder.AddDebugLog(nodeName, string.Format("{0}开始上传MES", rfidUID)); if (!MESBatteryFill(fillSeq, rfidUID, batteryList, ref reStr)) { logRecorder.AddDebugLog(nodeName, string.Format(" {0}MES装载错误:{1}", rfidUID, reStr)); this.db1ValsToSnd[0] = 4; //装载错误 currentTaskDescribe = string.Format(" 装载错误{0}", reStr); logRecorder.AddDebugLog(nodeName, currentTaskDescribe); break; //zwx,11-16 } else { logRecorder.AddDebugLog(nodeName, string.Format("{0}MES装载成功", rfidUID)); } ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx,11-16 } int updateStep = 0; if (this.nodeID == "3001") { updateStep = 4; } else { updateStep = 8; } VMResult re = MesAcc.UpdateStep(updateStep, this.rfidUID); if (re.ResultCode != 0) { this.currentTaskDescribe = "更新MES步次失败," + re.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx ,11-16 } #endregion //自动装载都是1次装载 #region 杭可 //string sndStr = ""; //if (!hkAccess.BatteryFill(0, this.rfidUID, batteryList, ref sndStr, ref reStr)) //{ // logRecorder.AddDebugLog(nodeName, string.Format(" 装载错误:{0},发送数据:{1}", reStr, sndStr)); // this.db1ValsToSnd[0] = 4;//装载错误 // currentTaskDescribe = string.Format(" 装载错误{0}", reStr); // break; //} #endregion #region 本地数据装载 for (int i = 0; i < batteryList.Count(); i++) { string batteryID = batteryList[i]; if (string.IsNullOrWhiteSpace(batteryID) || (batteryID.Length < 23)) { continue; } MesDBAccess.Model.ProductOnlineModel productModel = null; if (productOnlineBll.Exists(batteryID)) { productModel = productOnlineBll.GetModel(batteryID); productModel.productID = batteryID; productModel.palletID = this.rfidUID; productModel.modifyTime = System.DateTime.Now; productModel.processStepID = this.mesProcessStepID[0].ToString(); productModel.productCata = SysCfg.EnumProductCata.电芯.ToString(); productModel.palletBinded = true; productModel.stationID = this.nodeID; productModel.checkResult = "0"; if (batteryID.Length > 22) { productModel.batchName = batteryID.Substring(16, 6); } int seq = i + 1; productModel.tag1 = seq.ToString(); int rowIndex = i / 12 + 1; productModel.tag2 = rowIndex.ToString(); int colIndex = i - (rowIndex - 1) * 12 + 1; productModel.tag3 = colIndex.ToString(); productModel.tag5 = "0"; if (!productOnlineBll.Update(productModel)) { return(false); } } else { productModel = new MesDBAccess.Model.ProductOnlineModel(); productModel.onlineTime = System.DateTime.Now; productModel.modifyTime = System.DateTime.Now; productModel.productID = batteryID; productModel.palletID = this.rfidUID; productModel.processStepID = this.mesProcessStepID[0].ToString(); productModel.productCata = SysCfg.EnumProductCata.电芯.ToString(); productModel.palletBinded = true; productModel.stationID = this.nodeID; productModel.checkResult = "0"; productModel.tag5 = "0"; if (batteryID.Length > 22) { productModel.batchName = batteryID.Substring(16, 6); } int seq = i + 1; productModel.tag1 = seq.ToString(); int rowIndex = i / 12 + 1; productModel.tag2 = rowIndex.ToString(); int colIndex = i - (rowIndex - 1) * 12 + 1; productModel.tag3 = colIndex.ToString(); if (!productOnlineBll.Add(productModel)) { return(false); } } } #endregion logRecorder.AddDebugLog(nodeName, string.Format(" 装载成功{0},更新MES工步:{1}", rfidUID, updateStep)); AddProduceRecord(this.rfidUID, string.Format("装载:{0},更新MES步次{1}", nodeName, updateStep)); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.db1ValsToSnd[0] = 2; break; } case 3: { currentTaskDescribe = "托盘跟电池条码数据绑定完成,等待扫码完成信号复位"; if (this.db2Vals[1] != 1) { break; } DevCmdReset(); this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; currentTaskDescribe = "等待执行下一个任务"; //等待扫码完成 break; } default: break; } //Console.WriteLine("TES P3"); return(true); }
/// <summary> /// Maps the instance to an Azure VM SKU /// </summary> /// <param name="vmRes">The object that will contain the mapping output</param> /// <param name="location">The Azure location</param> /// <param name="azureVMSizeList">The list of Azure VM SKUs</param> /// <param name="rateCalc">The object that can fetch the rates for Azure resources</param> /// <param name="listOfOverrideVMSizes">The list of Input Override Azure VM SKUs if provided</param> /// <param name="mappingCoefficientCoresSelection">Mapping Coefficient for CPU Cores</param> /// <param name="mappingCoefficientMemorySelection">Mapping Coefficient for Memory</param> public static void ProjectAzureVM(VMResult vmRes, string location, List <AzureVMSizeListItem> azureVMSizeList, AzureResourceRateCalc rateCalc, List <OverrideVMSpecs> listOfOverrideVMSizes, double mappingCoefficientCoresSelection, double mappingCoefficientMemorySelection) { AzureVMProjector.rateCalc = rateCalc; AzureVMProjector.location = location; try { int dataDiskCount = 0; dataDiskCount = GetDataDiskCount(vmRes); // Check if Preferred VM Size Exists bool isPreferredVMSizeValid = false; AzureVMSizeListItem vmListItemForMatchedOverride = null; // Override with VM Specific if provided if (!string.IsNullOrWhiteSpace(vmRes.Specs.AzureVMOverride)) { vmListItemForMatchedOverride = azureVMSizeList.Find(x => x.Name.Equals(vmRes.Specs.AzureVMOverride, StringComparison.OrdinalIgnoreCase)); if (vmListItemForMatchedOverride != null) { if (vmListItemForMatchedOverride.MaxDataDiskCount >= dataDiskCount) { isPreferredVMSizeValid = true; vmRes.ProjAzureVM.ComputeHoursRate = GetAzureVMCost(vmListItemForMatchedOverride, vmRes.Specs); vmRes.ProjAzureVM.VMSize = vmListItemForMatchedOverride; vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsVMMapasperSpecificOverride; } else { vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsSpecificOverrideExceedDiskCount; } } else { vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsSpecificOverrideNotFound; } } // Override with generic Override file if match found and not already mapped by specific override value if (!isPreferredVMSizeValid && listOfOverrideVMSizes != null) { OverrideVMSpecs matchedOverrideVMDetails = listOfOverrideVMSizes.Find(x => (x.IsValid && vmRes.Specs.CPUCores == x.CPUCores && vmRes.Specs.MemoryInMB == x.MemoryInMB && vmRes.Specs.OperatingSystem.Equals(x.OperatingSystem, StringComparison.OrdinalIgnoreCase) && ((x.HasSSDStorage && vmRes.Specs.SSDStorageInGB > 0) || (!x.HasSSDStorage && vmRes.Specs.SSDStorageInGB == 0)) && (x.NumberOfDataDisks == dataDiskCount) && !string.IsNullOrWhiteSpace(x.AzureVMOverride))); if (matchedOverrideVMDetails != null) { vmListItemForMatchedOverride = azureVMSizeList.Find(x => x.Name.Equals(matchedOverrideVMDetails.AzureVMOverride, StringComparison.OrdinalIgnoreCase)); if (vmListItemForMatchedOverride != null) { if (vmListItemForMatchedOverride.MaxDataDiskCount >= dataDiskCount) { isPreferredVMSizeValid = true; vmRes.ProjAzureVM.ComputeHoursRate = GetAzureVMCost(vmListItemForMatchedOverride, vmRes.Specs); vmRes.ProjAzureVM.VMSize = vmListItemForMatchedOverride; vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsVMMappedasperGenericOverride; } else { vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsGenericOverrideExceedDiskCount; } } else { vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsGenericOverrideNotFound; } } } // If PreferredVMSize does not exist or if PreferredVMSize is not valid, loop thru' the list to project using projection algorithm if (!isPreferredVMSizeValid) { foreach (AzureVMSizeListItem vmListItem in azureVMSizeList) { bool considerListItem = false; // If Current Azure VM Size does not support Premium Disks and VM contains mapped premium disks - skip the size if (vmRes.ProjAzureVM.PremiumDisks != null && vmRes.ProjAzureVM.PremiumDisks.Count > 0 && !AzureVMMeterHelper.CheckIfAzureVMInstanceTypeIsPremiumSupported(vmListItem)) { continue; } // If Current Azure VM Size does is for Premium Disks and VM contains does not contains premium disks - skip the size if ((vmRes.ProjAzureVM.PremiumDisks == null || (vmRes.ProjAzureVM.PremiumDisks != null && vmRes.ProjAzureVM.PremiumDisks.Count == 0)) && AzureVMMeterHelper.CheckIfAzureVMInstanceTypeIsPremiumSupported(vmListItem)) { continue; } // Skip if number of data disks mapped is more than maximum of current item if (dataDiskCount > vmListItem.MaxDataDiskCount) { continue; } if (vmListItem.NumberOfCores >= mappingCoefficientCoresSelection * vmRes.Specs.CPUCores) { if (vmListItem.MemoryInMB >= mappingCoefficientMemorySelection * vmRes.Specs.MemoryInMB) { considerListItem = true; } } if (considerListItem) { bool mapCurrentItem = false; double currentVMSizeListItemRate = GetAzureVMCost(vmListItem, vmRes.Specs); if (vmRes.ProjAzureVM.VMSize == null) { mapCurrentItem = true; } else { if (vmRes.ProjAzureVM.ComputeHoursRate > currentVMSizeListItemRate) { mapCurrentItem = true; } } if (mapCurrentItem) { vmRes.ProjAzureVM.IsMappedasperOverride = false; vmRes.ProjAzureVM.VMSize = vmListItem; vmRes.ProjAzureVM.ComputeHoursRate = currentVMSizeListItemRate; } } } } else { vmRes.ProjAzureVM.IsMappedasperOverride = true; } if (vmRes.ProjAzureVM.VMSize == null) { vmRes.ProjAzureVM.IsNoMapFound = true; vmRes.ProjAzureVM.AzureProjectionComments = AzureVMProjectionCommentsLiterals.ProjectionCommentsVMCannotbeMapped; } else { vmRes.ProjAzureVM.IsNoMapFound = false; } } catch (Exception) { throw; } }
/// <summary> /// Generates the strings array for the output of mapping output file /// </summary> /// <param name="vmRes">Mapping output object</param> /// <param name="isOutputMemoryInGB">A value indicating if Memory is in GB or not</param> /// <returns> Returns the strings array for the output of mapping output file</returns> public static String[] UnloadVMSpecsOutput(VMResult vmRes, bool isOutputMemoryInGB) { string[] outputVMSpecsStr = new string[NumberOfTotalColumnsVMResult]; try { // Write Input VM Specs including validation results columns int column = 0; if (vmRes.Specs.IsValid) { outputVMSpecsStr[column++] = vmRes.Specs.InstanceName; outputVMSpecsStr[column++] = vmRes.Specs.OperatingSystem; outputVMSpecsStr[column++] = vmRes.Specs.CPUCores.ToString(); outputVMSpecsStr[column++] = isOutputMemoryInGB ? Math.Round(vmRes.Specs.MemoryInMB / 1024, 2).ToString() : Math.Round(vmRes.Specs.MemoryInMB, 2).ToString(); outputVMSpecsStr[column++] = Math.Round(vmRes.Specs.SSDStorageInGB, 2).ToString(); outputVMSpecsStr[column++] = vmRes.Specs.SSDNumOfDisks.ToString(); outputVMSpecsStr[column++] = Math.Round(vmRes.Specs.HDDStorageInGB, 2).ToString(); outputVMSpecsStr[column++] = vmRes.Specs.HDDNumOfDisks.ToString(); outputVMSpecsStr[column++] = Math.Round(vmRes.Specs.PricePerMonth, 2).ToString(); outputVMSpecsStr[column++] = vmRes.Specs.AzureVMOverride; outputVMSpecsStr[column++] = vmRes.Specs.Comments; outputVMSpecsStr[column++] = vmRes.Specs.IsValid ? Constants.BoolDisplayValueForTRUE : Constants.BoolDisplayValueForFALSE; outputVMSpecsStr[column++] = vmRes.Specs.ValidationMessage; } else { outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.InstanceName; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.OperatingSystem; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.CPUCores; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.Memory; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.SSDStorageInGB; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.SSDNumOfDisks; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.HDDStorageInGB; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.HDDNumOfDisks; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.PricePerMonth; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.AzureVMOverride; outputVMSpecsStr[column++] = vmRes.Specs.InputOriginalValues.Comments; outputVMSpecsStr[column++] = vmRes.Specs.IsValid ? Constants.BoolDisplayValueForTRUE : Constants.BoolDisplayValueForFALSE; outputVMSpecsStr[column++] = vmRes.Specs.ValidationMessage; } // Write Azure VM Projected Key columns if (vmRes.Specs.IsValid) { outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound && vmRes.ProjAzureVM.VMSize != null ? vmRes.ProjAzureVM.VMSize.Name : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound && vmRes.ProjAzureVM.VMSize != null? vmRes.ProjAzureVM.VMSize.NumberOfCores.ToString() : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound && vmRes.ProjAzureVM.VMSize != null ? (isOutputMemoryInGB ? Math.Round((double)vmRes.ProjAzureVM.VMSize.MemoryInMB / 1024, 2).ToString() : vmRes.ProjAzureVM.VMSize.MemoryInMB.ToString()) : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound ? Math.Round(vmRes.ProjAzureVM.ComputeHoursMonthlyCost, 2).ToString() : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null? Math.Round(vmRes.ProjAzureVM.PremiumDisksMonthlyCost, 2).ToString() : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null? Math.Round(vmRes.ProjAzureVM.StandardDisksMonthlyCost, 2).ToString() : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound ? Math.Round(vmRes.ProjAzureVM.AzureVMTotalMonthlyCost, 2).ToString() : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound ? Math.Round(vmRes.ProjAzureVM.MonthlyGrossMarginEstimates, 2).ToString() : string.Empty; // Write Azure VM Projected Other columns outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null ? vmRes.ProjAzureVM.PremiumDisksStr : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null ? vmRes.ProjAzureVM.StandardDisksStr : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null && !vmRes.ProjAzureVM.IsNoMapFound ? Math.Round(vmRes.ProjAzureVM.ComputeHoursRate, 2).ToString() : string.Empty; outputVMSpecsStr[column++] = vmRes.ProjAzureVM != null ? vmRes.ProjAzureVM.AzureProjectionComments : string.Empty; } } catch (Exception) { throw; } return(outputVMSpecsStr); }