void BuySomethingWithOptionalCurrency(ProductCode productCode, decimal price, CurrencyCode? currencyCode) { if (productCode == null) { throw new ArgumentNullException("productCode"); } currencyCode = currencyCode ?? "gbp".ToCurrencyCode(); Console.WriteLine("Bought {0} for {1}{2}", productCode, price, currencyCode); }
void BuySomething(ProductCode productCode, decimal price, CurrencyCode currencyCode) { if (productCode == null) { throw new ArgumentNullException("productCode"); } if (currencyCode == null) { throw new ArgumentNullException("currencyCode"); } Console.WriteLine("Bought {0} for {1}{2}", productCode, price, currencyCode); }
public Product(ProductCode productCode, SupplierCode supplierCode, decimal price, CurrencyCode currencyCode) { ProductCode = productCode; SupplierCode = supplierCode; Price = price; CurrencyCode = currencyCode; }
/// <summary> /// Find all matching. Note that productCode and supplierCode are optional but currencyCode is not. /// </summary> public IEnumerable<Product> FindMatchingProducts(ProductCode? productCode, SupplierCode? supplierCode, CurrencyCode currencyCode) { return _allProducts .Where(p => (!productCode.HasValue || p.ProductCode == productCode.Value) && (!supplierCode.HasValue || p.SupplierCode == supplierCode.Value) && (p.CurrencyCode == currencyCode) ); }
void BindingArcGISRuntime(object sender, EventArgs e) { ProductCode[] supportedRuntimes = new ProductCode[] { ProductCode.Engine, ProductCode.Desktop }; foreach (ProductCode c in supportedRuntimes) { if (RuntimeManager.Bind(c)) return; } MessageBox.Show("ArcGIS����ʱ��ʧ�ܣ�Ӧ�ó��رա�"); System.Environment.Exit(0); }
/// <summary> /// Create a product base on the Product Code enum /// </summary> /// <param name="pProductCode"></param> /// <returns>Product</returns> public BaseProduct Create(ProductCode pProductCode) { switch (pProductCode) { case ProductCode.SH3: return(new SlicedHam(pProductCode)); case ProductCode.YT2: return(new Yoghurt(pProductCode)); case ProductCode.TR: return(new ToiletRolls(pProductCode)); } throw new NotSupportedException(); //Should not be here }
/// <summary> /// 取引所APIクライアントの抽象クラス /// </summary> /// <param name="exchangeId">取引所ID(1〜3、例えばFX_BTC_JPYは2)</param> /// <param name="dbContextOptions">DB接続</param> /// <param name="timeoutSec">Timeout sec.</param> public ExchangeClient( int exchangeId, DbContextOptions dbContextOptions, double timeoutSec = 4 // タイムアウト (デフォルト4秒) ) { cancelOrderList = new List <Order>(); ExchangeId = exchangeId; BotStatus = new Dictionary <string, string>(); parentOrders = new List <Order>(); // TODO:パラメータ更新 using (var db = new MApplicationSettingsDbContext(dbContextOptions)) { // データを取得 var ApplicationSettings = db.MApplicationSettings; Console.WriteLine("ApplicationSettingsをセットアップします"); foreach (var ApplicationSetting in ApplicationSettings) { // TODO:FXのパラメータをセット if (ApplicationSetting.ExchangeId == exchangeId) { if (ApplicationSetting.Name == "productCode") { PRODUCT_CODE = (ProductCode)Enum.Parse(typeof(ProductCode), ApplicationSetting.Value, true); } if (ApplicationSetting.Name == "apiKey") { apiKey = ApplicationSetting.Value; } if (ApplicationSetting.Name == "apiSelect") { apiSelect = ApplicationSetting.Value; } } } } // DBから取得したAPIキーをセット m_apiClient = new ApiClient( apiKey, apiSelect, timeoutSec, "https://api.bitflyer.jp" // TODO:他の取引所に対応させること ); }
public ActionResult Index(string search_products) { List <ProductCode> same = new List <ProductCode>(); // Bir sonraki adımımız aşağıdaki gibi sadece onaylanmış olan ürünleri göstermek olacak. var product = db.Codes.Where(p => p.IsValid == 1).ToList(); foreach (var pro in product) { ProductCode p = new ProductCode(); if (pro.Tags.ToLower().Contains(search_products.ToLower())) { p = pro; same.Add(p); } else if (pro.Title.ToLower().Contains(search_products.ToLower())) { p = pro; same.Add(p); } else if (pro.Description.ToLower().Contains(search_products.ToLower())) { p = pro; same.Add(p); } else if (pro.Product_Kind.ToLower().Contains(search_products.ToLower())) { p = pro; same.Add(p); } } // var productTheme = db.Themes.Where(p => p.IsValid == 1).ToList(); // var product = db.Codes.ToList(); if (same.Count == 0) { var productTheme = db.Codes.Where(p => p.IsValid == 1).ToList(); ViewBag.TProduct = productTheme; return(View()); } else { ViewBag.TProduct = same; return(View()); } }
public ActionResult AddComment(string yorum) { Comment cm = new Comment(); int id = Convert.ToInt32(Session["UserId"]); User EkleyenUser = dbBaglantisi.Users.Where(u => u.Id == id).FirstOrDefault(); product = dbBaglantisi.Codes.Find(gelenID); cm.CommentTime = DateTime.Now; cm.User = EkleyenUser; cm.Product = product; cm.Content = yorum; dbBaglantisi.Comments.Add(cm); dbBaglantisi.SaveChanges(); return(RedirectToAction("Details", "Product", new { id = gelenID })); }
public ProductDto Add(ProductDto productDto) { ProductCode productCode = this.productCodeRepository.FindById(productDto.ProductCodeId); if (productCode == null) { throw new Exception("Product Code Is Not Valid"); } Product product = Product.Create(productDto.Name, productDto.Quantity, productDto.Cost, productCode); this.productRepository.Add(product); return(mapper.Map <Product, ProductDto>(product)); }
public void AddNewProduct(String pcode, String pdes, int pgroup) { ProductCode.SendKeys(pcode); ProductDes.SendKeys(pdes); for(int i = 2; i<5; i++) { string ProductGroup = "//*[@id='Product_ProductGroupId']/option["+i+"]"; if (i == pgroup) { DriverCmn.driver.FindElement(By.XPath(ProductGroup)).Click(); } } SaveBtn.Click(); }
public string ProcessTokensInString(string source) { source = source.Replace("{CompanyName}", CompanyName); source = source.Replace("{CompanyNumber}", CompanyNumber); source = source.Replace("{ProductName}", ProductName); source = source.Replace("{ProductDescription}", ProductDescription); source = source.Replace("{ProductCode}", ProductCode.ToString().Cast <char>().SkipWhile(c => c == '{').TakeWhile(c => c != '}').ToString()); source = source.Replace("{ProductVersion}", ProductVersion); source = source.Replace("{ProductLongVersion}", ProductLongVersion); source = source.Replace("{CopyrightNotice}", CopyrightNotice); source = source.Replace("{CompanyUrl}", CompanyUrl); source = source.Replace("{ProductUrl}", ProductUrl); source = source.Replace("{ProductPurchaseUrl}", ProductPurchaseUrl); source = source.Replace("{DefaultProductKey}", DefaultProductKey); source = source.Replace("{StartPath}", System.IO.Path.GetDirectoryName(Tools.Runtime.GetEntryAssembly().Location)); return(source); }
//public List<MA_INSTRUMENT> GetByProduct(SessionInfo sessioninfo, Guid productID) //{ // try // { // List<MA_INSTRUMENT> instruments = null; // using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) // { // instruments = unitOfWork.MA_INSTRUMENTRepository.Where(p => p.PRODUCT_ID == productID).ToList(); // } // //Return result to jTable // return instruments; // } // catch (DataServicesException ex) // { // throw this.CreateException(ex, null); // } //} public List <MA_INSTRUMENT> GetByProduct(SessionInfo sessioninfo, ProductCode productcode) { try { List <MA_INSTRUMENT> instruments = null; using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { instruments = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(productcode.ToString()); } //Return result to jTable return(instruments); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
private static void TryBindProduct( [NotNull] IList <esriLicenseProductCode> licenseProductCodes) { try { ProductCode productCode = GetProductCode(licenseProductCodes[0]); TryBindProduct(productCode); // TODO: fall back productCode } catch (Exception e) { _msg.Debug( "Binding to product failed, most likely because ArcGIS 10 is not installed", e); } }
public VendingMachineResponse SelectProduct(ProductCode code) { if (this.Products.Count(p => p.Code == code) > 0) { var product = this.Products.First(p => p.Code == code); CurrentSelectedProduct = product; if (product.Cost > this.CurrentTransaction.Balance) { var errorResponse = new VendingMachineResponse() { Message = $"PRICE: {product.Cost.ToString("C2")}. INSERT COIN.", Product = product }; return(errorResponse); } var response = new VendingMachineResponse() { Message = "THANK YOU", Product = product, }; if (product.Cost < this.CurrentTransaction.Balance) { response.Change = _changeCalculator.GetChange(CurrentTransaction.Balance - product.Cost); } this.Products.Remove(product); this.CurrentTransaction = null; this.CurrentSelectedProduct = null; return(response); } else { var response = new VendingMachineResponse() { Message = "SOLD OUT", Product = null }; return(response); }; }
public MA_INSTRUMENT Create(SessionInfo sessioninfo, MA_INSTRUMENT instrument, ProductCode product) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(product.ToString()).FirstOrDefault(p => p.LABEL == instrument.LABEL); if (checkDuplicate != null) throw this.CreateException(new Exception(), "Label is duplicated"); if (product == ProductCode.BOND) { LogBusiness logBusiness = new LogBusiness(); unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, instrument.ID, LogEvent.INSTRUMENT_AUDIT.ToString(), LookupFactorTables.MA_INSTRUMENT, "BOND", new { })); } unitOfWork.MA_INSTRUMENTRepository.Add(instrument); unitOfWork.Commit(); } return instrument; }
public MA_INSTRUMENT GetFXInstrumentByCCY(SessionInfo sessioninfo, ProductCode eProductCode, string strCCY1, string strCCY2) { try { MA_INSTRUMENT instrument = null; using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { instrument = unitOfWork.MA_INSTRUMENTRepository .GetAllByProductCode(eProductCode.ToString()) .FirstOrDefault(p => p.LABEL.Equals(strCCY1 + "/" + strCCY2) || p.LABEL.Equals(strCCY2 + "/" + strCCY1)); } return(instrument); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public static ProductCodeDto ToDto(this ProductCode code) { code.Ancillaries?.ForEach(v => v.ProdutCodeId = code.Id); var dto = new ProductCodeDto { Id = code.Id, UniqueId = Guid.NewGuid(), Name = code.Name, Code = code.Code, Excess = code.Excess, HospitalRanking = code.HospitalRanking, ExtrasRanking = code.ExtrasRanking, Ancillaries = code.Ancillaries?.Select(v => v.ToDto()).ToList() }; ((IData)code).ToDto((IDataDto)dto); return(dto); }
/// <summary> /// Override av ToString(). Returnerar strängrepresentationen av produkten. /// </summary> /// <returns>Strängrepresentationen av produkten</returns> public override string ToString() { //ProductCode;Title;ProductType;Price;Quantity;ReleaseYear;Creator;Publisher;FreeText;Status string productAsString; productAsString = ProductCode.ToString(CultureInfo.CurrentCulture) + ';'; productAsString += Title + ';'; productAsString += Type.ToString() + ';'; productAsString += Price.ToString("0.00", CultureInfo.CurrentCulture) + ';'; productAsString += Quantity.ToString(CultureInfo.CurrentCulture) + ';'; productAsString += ReleaseYear.ToString(CultureInfo.CurrentCulture) + ';'; productAsString += Creator.ToString(CultureInfo.CurrentCulture) + ';'; productAsString += Publisher.ToString(CultureInfo.CurrentCulture) + ';'; productAsString += FreeText.ToString(CultureInfo.CurrentCulture) + ';'; productAsString += Status.ToString(); return(productAsString); }
public static string ProductName(ProductCode code, bool extended = true) { return(code switch { ProductCode.Chat => "Chat", ProductCode.DiabloII => "Diablo II", ProductCode.DiabloIILordOfDestruction => "Diablo II " + (extended ? " Lord of Destruction" : " LoD"), ProductCode.DiabloRetail => "Diablo", ProductCode.DiabloShareware => "Diablo Shareware", ProductCode.StarcraftBroodwar => "Starcraft Broodwar", ProductCode.StarcraftJapanese => "Starcraft Japanese", ProductCode.StarcraftOriginal => "Starcraft Original", ProductCode.StarcraftShareware => "Starcraft Shareware", ProductCode.WarcraftII => "Warcraft II" + (extended ? " Battle.net Edition" : " BNE"), ProductCode.WarcraftIIIDemo => "Warcraft III Demo", ProductCode.WarcraftIIIFrozenThrone => "Warcraft III" + (extended ? " The Frozen Throne" : " TFT"), ProductCode.WarcraftIIIReignOfChaos => "Warcraft III" + (extended ? " Reign of Chaos" : " RoC"), _ => "Unknown" + (extended ? " (" + code.ToString() + ")" : ""), });
public static List <ProductCode> LoadExcel(string strFilePath, string conStr) { OleDbConnection oledbConn = new OleDbConnection(conStr); DataTable dt = new DataTable(); List <ProductCode> pcs = new List <ProductCode>(); try { if (oledbConn.State == ConnectionState.Closed) { oledbConn.Open(); } using (OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$] WHERE [Product Code] IS NOT NULL", oledbConn)) { OleDbDataAdapter oleda = new OleDbDataAdapter(); oleda.SelectCommand = cmd; DataSet ds = new DataSet(); oleda.Fill(ds); dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { ProductCode pc = new ProductCode(); pc.Brand = dr["Brand"].ToString(); pc.PCode = dr["Product Code"].ToString(); pc.MediaCompany = dr["Media Company"].ToString(); pc.Script = dr["Script"].ToString(); pc.Offer = dr["Offer"].ToString(); pcs.Add(pc); } } } catch { oledbConn.Close(); } finally { oledbConn.Close(); } return(pcs); }
public override string ToString() { string result = ProductCode.PadRight(4); result += ProductName.PadRight(25); result += Price.ToString("C").PadLeft(6); result += " "; if (Quanity == 0) { result += "Sold Out!"; } else { result += Quanity.ToString().PadRight(10); } return(result); }
protected void InitLogic() { this.caption.MouseDown += (sender, e) => Util.BeginDrag(this.Handle); this.btnGen.Click += (sender, e) => { try { this.txtKey.Focus(); ProductCode productCode = (ProductCode)this.cboProduct.SelectedValue; int version = (int)this.nudVersion.Value; this.txtKey.Text = KeyGen.GenerateKey(productCode, version, 999, DateTime.Now); this.txtKey.SelectAll(); } catch (Exception exp) { MessageBox.Show(this, exp.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }; this.btnClose.Click += (sender, e) => this.Close(); }
public static object GetInstrumentByName(SessionInfo sessioninfo, ProductCode productcode, string name) { try { InstrumentBusiness _instrumentBusiness = new InstrumentBusiness(); //Get data from database var ins = _instrumentBusiness.GetByProduct(sessioninfo, productcode).Where(c => c.ISACTIVE == true && c.LABEL.StartsWith(name)).OrderBy(c => c.LABEL); //Return result to jTable return(new { Result = "OK", Records = ins }); } catch (BusinessWorkflowsException bex) { return(new { Result = "ERROR", Message = bex.Message }); } catch (Exception ex) { return(new { Result = "ERROR", Message = ex.Message }); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (DiscountAmount != null) { hashCode = hashCode * 59 + DiscountAmount.GetHashCode(); } if (LineAmountTotal != null) { hashCode = hashCode * 59 + LineAmountTotal.GetHashCode(); } if (ProductCode != null) { hashCode = hashCode * 59 + ProductCode.GetHashCode(); } if (ProductPrice != null) { hashCode = hashCode * 59 + ProductPrice.GetHashCode(); } if (ProductType != null) { hashCode = hashCode * 59 + ProductType.GetHashCode(); } if (Quantity != null) { hashCode = hashCode * 59 + Quantity.GetHashCode(); } if (TaxAmount != null) { hashCode = hashCode * 59 + TaxAmount.GetHashCode(); } if (Unit != null) { hashCode = hashCode * 59 + Unit.GetHashCode(); } return(hashCode); } }
public static int UpdateProductCode(ProductCode pc, string userid) { int ret = 0; using (SqlConnection scon = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConn"].ConnectionString)) { if (scon.State == ConnectionState.Closed) { scon.Open(); } SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = scon; cmd.CommandText = "usp_UpdateListOfProductsProductCode"; cmd.Parameters.AddWithValue("@ProductCode", pc.PCode); cmd.Parameters.AddWithValue("@ScriptCode", pc.ScriptTemplate); cmd.Parameters.AddWithValue("@UserId", userid); ret = cmd.ExecuteNonQuery(); } return(ret); }
private static AoInitialize GetLicense(ProductCode product, esriLicenseProductCode level) { AoInitialize aoInit; try { Trace.TraceInformation($"Obtaining {product}-{level} license"); RuntimeManager.Bind(product); aoInit = new AoInitialize(); esriLicenseStatus licStatus = aoInit.Initialize(level); Message = $"Ready with license. Status: {licStatus}"; Trace.TraceInformation(Message); } catch (Exception ex) { Stop(); // Set Message after stop, because stop sets message to null Message = $"Fatal Error: {ex.Message}"; return(null); } return(aoInit); }
public ActionResult Theme(ProductCode gelenCode, string Gender, Boolean Privacy_policy, string category, string subcategory) { if (Privacy_policy) { gelenCode.Product_Kind = HomeController.Product_kind; gelenCode.CreateDate = DateTime.Now; gelenCode.Category = category; gelenCode.SubCategory = subcategory; gelenCode.HighResolution = Gender; gelenCode.Privacy_Policy = Privacy_policy.ToString(); gelenCode.SoftwarVersion = softwareVersion; gelenCode.FilesIncluded = fileinculeded; gelenCode.Browsers = browser; gelenCode.IsValid = 0; gelenCode.Screenshot = file_screen; gelenCode.Filepath = file_main; gelenCode.Icon = file_icon; gelenCode.CompatibleWith = compatiblewith; // gelenCode.Support = support; int UserID = (int)Session["UserId"]; User EkleyenUser = dbBaglantisi.Users.Single(u => u.Id == UserID); if (EkleyenUser != null) { gelenCode.User = EkleyenUser; } dbBaglantisi.Codes.Add(gelenCode); dbBaglantisi.SaveChanges(); creatdir("" + gelenCode.User.Id, "" + gelenCode.ID); return(RedirectToAction("Success", new { returnUrl = Request.RawUrl })); } else { @ViewBag.Imza = "Failed : Accept the Privacy Policy !! .. "; return(View()); } }
void BindingArcGISRuntime(object sender, EventArgs e) { // // TODO: Modify ArcGIS runtime binding code as needed; for example, // the list of products and their binding preference order. // ProductCode[] supportedRuntimes = new ProductCode[] { ProductCode.Engine, ProductCode.Desktop }; foreach (ProductCode c in supportedRuntimes) { if (RuntimeManager.Bind(c)) return; } // // TODO: Modify the code below on how to handle bind failure // // Failed to bind, announce and force exit Console.WriteLine("ArcGIS runtime binding failed. Application will shut down."); System.Environment.Exit(0); }
public ActionResult Details(int?id) { if (Session["UserID"] == null) { ViewBag.Control = "0"; } gelenID = Convert.ToInt32(id); var urun = dbBaglantisi.Codes.Find(Convert.ToInt32(id)); product_user_id = urun.User.Id; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } product = dbBaglantisi.Codes.Find(id); if (product == null) { return(HttpNotFound()); } return(View(product)); }
public static object GetOptionsByProduct(SessionInfo sessioninfo, ProductCode productcode) { try { InstrumentBusiness _instrumentBusiness = new InstrumentBusiness(); //Get data from database var ins = _instrumentBusiness.GetByProduct(sessioninfo, productcode) .OrderBy(p => p.LABEL) .Select(c => new { DisplayText = c.LABEL, Value = c.ID }); //Return result to jTable return(new { Result = "OK", Options = ins }); } catch (BusinessWorkflowsException bex) { return(new { Result = "ERROR", Message = bex.Message }); } catch (Exception ex) { return(new { Result = "ERROR", Message = ex.Message }); } }
private void SaveProductCode(Guid productId, Guid a1Id, Guid a2Id, Guid a3Id, Guid c1Id, Guid c2Id, Guid c3Id, Guid c4Id, Guid c5Id, Guid c6Id) { string sql = "ProductId = '" + productId.ToString() + "'"; ProductCode oCode = ProductCode.LoadWhere(sql); if (oCode == null) { oCode = new ProductCode(); oCode.ProductId = productId; oCode.Appendix1Id = a1Id; oCode.Appendix2Id = a2Id; oCode.Appendix3Id = a3Id; } oCode.Class1Id = c1Id; oCode.Class2Id = c2Id; oCode.Class3Id = c3Id; oCode.Class4Id = c4Id; oCode.Class5Id = c5Id; oCode.Class6Id = c6Id; oCode.Save(); }
void BindingArcGISRuntime(object sender, EventArgs e) { // // TODO: Modify ArcGIS runtime binding code as needed // ProductCode[] supportedRuntimes = new ProductCode[] { ProductCode.Engine, ProductCode.Desktop }; foreach (ProductCode c in supportedRuntimes) { if (RuntimeManager.Bind(c)) { return; } } if (!RuntimeManager.Bind(ProductCode.Engine)) { // Failed to bind, announce and force exit System.Windows.Forms.MessageBox.Show("Invalid ArcGIS runtime binding. Application will shut down."); System.Environment.Exit(0); } }
public void ProductCode_WithLegacyCode_ShouldNotPreserveApplicationPlatform() { DataContractSerializer serializer = new DataContractSerializer(typeof(ProductCode)); ProductCode originalProductCode = new ProductCode("ZWD150"); ProductCode deserializedProductCode = null; using (MemoryStream stream = new MemoryStream()) { XmlWriter writer = new XmlTextWriter(stream, Encoding.UTF8); serializer.WriteObject(writer, originalProductCode); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); deserializedProductCode = serializer.ReadObject(stream) as ProductCode; } Assert.NotNull(deserializedProductCode); Assert.Null(deserializedProductCode.Platform); Assert.Null(deserializedProductCode.Application); }
void BindingArcGISRuntime(object sender, EventArgs e) { // // TODO: Modify ArcGIS runtime binding code as needed; for example, // the list of products and their binding preference order. // ProductCode[] supportedRuntimes = new ProductCode[] { ProductCode.Engine, ProductCode.Desktop }; foreach (ProductCode c in supportedRuntimes) { if (RuntimeManager.Bind(c)) { return; } } // // TODO: Modify the code below on how to handle bind failure // // Failed to bind, announce and force exit XtraMessageBox.Show("ArcGIS runtime binding failed. Application will shut down."); System.Environment.Exit(0); }
public static string GenerateKey(ProductCode productCode, int version, int numberOfLicense, DateTime issueDate) { if (numberOfLicense < 0 || numberOfLicense > 999) { throw new ArgumentException($"{nameof(numberOfLicense)} must in range from 0 to 999."); } if (issueDate.Year < 2002) { throw new ArgumentException($"{nameof(issueDate)} cannot be earlier than 2002."); } if (issueDate > DateTime.Now.AddDays(7).Date) { throw new ArgumentException($"{nameof(issueDate)} cannot be later than today after a week."); } foreach (Product item in ProductCollection.Default) { if (item == null) { continue; } if (item.Code == productCode && item.Version == version) { if (item.PublishDate > issueDate) { throw new ArgumentException($"{nameof(issueDate)} cannot be earlier than the publish date."); } break; } } int rand = random.Next(0, 999); string preProductKey = $"{issueDate:yyMMdd}-{0x0B:D2}{(int)productCode:D1}{rand:D3}-{numberOfLicense:D3}"; int checksum = GetChecksum(preProductKey); return($"{preProductKey}{checksum:D3}"); }
OLife IFundService.GetFunds(ProductCode productCode) { return(OLifeLoader.LoadByProductCode(productCode)); #region XML //Serializable.OLifE obj = OLifeLoader.LoadByProductCode(productCode); //var qry = from x in obj.InvestProduct // select new InvestmentProduct // { // CarrierName = x.CarrierName, // InvestProductSysKey = new String[]{x.InvestProductSysKey}, // ProductSymbol = x.ProductSymbol, // FundFamilyName = x.FundFamilyName, // FullName = x.FullName, // SaleEffectiveDate = x.SaleEffectiveDate // }; //OLife olife = new OLife(); //olife.Items = qry.ToArray(); //return olife; #endregion }
public void GetByProductTest() { InstrumentBusiness target = new InstrumentBusiness(); // TODO: Initialize to an appropriate value SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value ProductCode productcode = new ProductCode(); // TODO: Initialize to an appropriate value List<MA_INSTRUMENT> expected = null; // TODO: Initialize to an appropriate value List<MA_INSTRUMENT> actual; actual = target.GetByProduct(sessioninfo, productcode); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public MA_INSTRUMENT GetFXInstrumentByCCY(SessionInfo sessioninfo, ProductCode eProductCode, string strCCY1, string strCCY2) { try { MA_INSTRUMENT instrument = null; using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { instrument = unitOfWork.MA_INSTRUMENTRepository .GetAllByProductCode(eProductCode.ToString()) .FirstOrDefault(p => p.LABEL.Equals(strCCY1 + "/" + strCCY2) || p.LABEL.Equals(strCCY2 + "/" + strCCY1)) ; } return instrument; } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
//public List<MA_INSTRUMENT> GetByProduct(SessionInfo sessioninfo, Guid productID) //{ // try // { // List<MA_INSTRUMENT> instruments = null; // using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) // { // instruments = unitOfWork.MA_INSTRUMENTRepository.Where(p => p.PRODUCT_ID == productID).ToList(); // } // //Return result to jTable // return instruments; // } // catch (DataServicesException ex) // { // throw this.CreateException(ex, null); // } //} public List<MA_INSTRUMENT> GetByProduct(SessionInfo sessioninfo, ProductCode productcode) { try { List<MA_INSTRUMENT> instruments = null; using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { instruments = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(productcode.ToString()); } //Return result to jTable return instruments; } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public MA_INSTRUMENT Update(SessionInfo sessioninfo, MA_INSTRUMENT instrument, ProductCode product) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(product.ToString()).FirstOrDefault(p => p.LABEL == instrument.LABEL && p.ID != instrument.ID); if (checkDuplicate != null) throw this.CreateException(new Exception(), "Label is duplicated"); var foundData = unitOfWork.MA_INSTRUMENTRepository.GetAll().FirstOrDefault(p => p.ID == instrument.ID); if (foundData == null) throw this.CreateException(new Exception(), "Data not found!"); else { if (product == ProductCode.BOND) { LogBusiness logBusiness = new LogBusiness(); var oldRecord = new { ISACTIVE = foundData.ISACTIVE, CAL_METHOD = foundData.CAL_METHOD, COUPON = foundData.COUPON, COUPON_FREQ_TYPE = foundData.MA_FREQ_TYPE!= null ?foundData.MA_PRODUCT.LABEL:string.Empty, FLAG_FIXED = foundData.FLAG_FIXED, INS_MKT = foundData.INS_MKT, ISSUER = foundData.ISSUER, LABEL = foundData.LABEL, LOT_SIZE = foundData.LOT_SIZE, MATURITY_DATE = foundData.MATURITY_DATE, PRODUCT = foundData.MA_PRODUCT!= null ? foundData.MA_PRODUCT.LABEL:string.Empty, CURRENCY = foundData.MA_CURRENCY != null ? foundData.MA_CURRENCY.LABEL:string.Empty }; var newRecord = new { ISACTIVE = instrument.ISACTIVE, CAL_METHOD = instrument.CAL_METHOD, COUPON = instrument.COUPON, COUPON_FREQ_TYPE =unitOfWork.MA_FREQ_TYPERepository.All().FirstOrDefault(f=>f.ID==instrument.COUPON_FREQ_TYPE_ID).LABEL, FLAG_FIXED = instrument.FLAG_FIXED, INS_MKT = instrument.INS_MKT, ISSUER = instrument.ISSUER, LABEL = instrument.LABEL, LOT_SIZE = instrument.LOT_SIZE, MATURITY_DATE = instrument.MATURITY_DATE, PRODUCT = unitOfWork.MA_PRODUCTRepository.All().FirstOrDefault(p => p.ID == instrument.PRODUCT_ID).LABEL, CURRENCY = unitOfWork.MA_CURRENCYRepository.All().FirstOrDefault(c => c.ID == instrument.CURRENCY_ID1).LABEL, }; var log = logBusiness.UpdateLogging(sessioninfo, foundData.ID, LogEvent.INSTRUMENT_AUDIT.ToString(), LookupFactorTables.MA_INSTRUMENT, oldRecord, newRecord); if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log); } foundData.ID = instrument.ID; foundData.ISACTIVE = instrument.ISACTIVE; foundData.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId; foundData.LOG.MODIFYDATE = DateTime.Now; foundData.CAL_METHOD = instrument.CAL_METHOD; foundData.COUPON = instrument.COUPON; foundData.COUPON_FREQ_TYPE_ID = instrument.COUPON_FREQ_TYPE_ID; foundData.FLAG_FIXED = instrument.FLAG_FIXED; foundData.INS_MKT = instrument.INS_MKT; foundData.ISSUER = instrument.ISSUER; foundData.LABEL = instrument.LABEL; foundData.LOT_SIZE = instrument.LOT_SIZE; foundData.MATURITY_DATE = instrument.MATURITY_DATE; foundData.PRODUCT_ID = instrument.PRODUCT_ID; foundData.CURRENCY_ID1 = instrument.CURRENCY_ID1; foundData.CURRENCY_ID2 = instrument.CURRENCY_ID2; unitOfWork.Commit(); } } return instrument; }
/// <summary> /// Find exact match. Note that productCode is not allowed to be null. /// </summary> public Product GetByCode(ProductCode productCode) { return _allProducts.FirstOrDefault(p => p.ProductCode == productCode); }
public static bool Bind (ProductCode code) { return true; }
public static object GetOptionsByProduct(SessionInfo sessioninfo, ProductCode productcode) { try { InstrumentBusiness _instrumentBusiness = new InstrumentBusiness(); //Get data from database var ins = _instrumentBusiness.GetByProduct(sessioninfo, productcode) .OrderBy(p => p.LABEL) .Select(c => new { DisplayText = c.LABEL, Value = c.ID }); //Return result to jTable return new { Result = "OK", Options = ins }; } catch (BusinessWorkflowsException bex) { return new { Result = "ERROR", Message = bex.Message }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }
public static object GetInstrumentByName(SessionInfo sessioninfo, ProductCode productcode,string name) { try { InstrumentBusiness _instrumentBusiness = new InstrumentBusiness(); //Get data from database var ins = _instrumentBusiness.GetByProduct(sessioninfo, productcode).Where(c => c.ISACTIVE == true && c.LABEL.StartsWith(name)).OrderBy(c => c.LABEL); //Return result to jTable return new { Result = "OK", Records = ins }; } catch (BusinessWorkflowsException bex) { return new { Result = "ERROR", Message = bex.Message }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }