public void Collect(CollectionMethod method) { if (GameGlobal.Player.Location is ResourcePoint && (GameGlobal.Player.Location as ResourcePoint).ToolCheck(method, GameGlobal.Player.SelectedItem as Tool)) { PhotonGlobal.PS.CollectMaterial(method, GameGlobal.Player.SelectedItem as Tool); } }
public void CollectMaterial(CollectionMethod method, Tool tool) { var parameter = new Dictionary<byte, object> { { (byte)CollectMaterialParameterItem.CollectiontMethod, method}, { (byte)CollectMaterialParameterItem.ToolID, (tool == null) ? ItemID.No : tool.id} }; peer.OpCustom((byte)OperationType.CollectMaterial, parameter, true, 0, true); }
public Item Collect(CollectionMethod method, Tool tool) { if(ToolCheck(method,tool)) { return GetMaterial(method); } else { return null; } }
public bool ToolCheck(CollectionMethod method, Tool tool) { switch (method) { case CollectionMethod.Hew: { return tool is Axe; } case CollectionMethod.Dig: { return tool is Pickaxe; } } return true; }
private Item GetMaterial(CollectionMethod method) { Dictionary<int,Item> materialTable = new Dictionary<int, Item>(); int offset = 0; foreach(var pair in collectionList[method]) { offset += pair.Value; materialTable.Add(offset, pair.Key); } Random random = new Random(); int result = random.Next(1, 10000); foreach(var pair in materialTable) { if(result <= pair.Key) { return pair.Value.Clone() as Item; } } return null; }
internal override void WriteXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("purchase"); // Start: purchase xmlWriter.WriteElementString("collection_method", CollectionMethod.ToString().EnumNameToTransportCase()); if (NetTerms.HasValue) { xmlWriter.WriteElementString("net_terms", NetTerms.Value.ToString()); } if (PoNumber != null) { xmlWriter.WriteElementString("po_number", PoNumber); } xmlWriter.WriteElementString("currency", Currency); if (ShippingAddressId.HasValue) { xmlWriter.WriteElementString("shipping_address_id", ShippingAddressId.Value.ToString()); } Account.WriteXml(xmlWriter); if (Adjustments.HasAny()) { xmlWriter.WriteStartElement("adjustments"); // Start: adjustments foreach (var adjustment in Adjustments) { adjustment.WriteEmbeddedXml(xmlWriter); } xmlWriter.WriteEndElement(); // End: adjustments } if (Subscriptions.HasAny()) { xmlWriter.WriteStartElement("subscriptions"); // Start: subscriptions foreach (var subscription in Subscriptions) { subscription.WriteEmbeddedSubscriptionXml(xmlWriter); } xmlWriter.WriteEndElement(); // End: subscriptions } if (CouponCodes.HasAny()) { xmlWriter.WriteStartElement("coupon_codes"); // Start: coupon_codes foreach (var code in CouponCodes) { xmlWriter.WriteElementString("coupon_code", code); } xmlWriter.WriteEndElement(); // End: coupon_codes } if (GiftCardRedemptionCode != null) { var gc = new GiftCard(GiftCardRedemptionCode); gc.WriteRedemptionXml(xmlWriter); } if (CustomerNotes != null) { xmlWriter.WriteElementString("customer_notes", CustomerNotes); } if (TermsAndConditions != null) { xmlWriter.WriteElementString("terms_and_conditions", TermsAndConditions); } if (VatReverseChargeNotes != null) { xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes); } if (GatewayCode != null) { xmlWriter.WriteElementString("gateway_code", GatewayCode); } xmlWriter.WriteEndElement(); // End: purchase }
protected void WriteSubscriptionXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("subscription"); // Start: subscription xmlWriter.WriteElementString("plan_code", PlanCode); xmlWriter.WriteElementString("currency", Currency); xmlWriter.WriteIfCollectionHasAny("subscription_add_ons", AddOns); xmlWriter.WriteStringIfValid("coupon_code", _couponCode); if (_couponCodes != null && _couponCodes.Length != 0) { xmlWriter.WriteStartElement("coupon_codes"); foreach (var _coupon_code in _couponCodes) { xmlWriter.WriteElementString("coupon_code", _coupon_code); } xmlWriter.WriteEndElement(); } xmlWriter.WriteElementString("customer_notes", CustomerNotes); xmlWriter.WriteElementString("terms_and_conditions", TermsAndConditions); xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes); if (UnitAmountInCents.HasValue) { xmlWriter.WriteElementString("unit_amount_in_cents", UnitAmountInCents.Value.AsString()); } xmlWriter.WriteElementString("quantity", Quantity.AsString()); if (TrialPeriodEndsAt.HasValue) { xmlWriter.WriteElementString("trial_ends_at", TrialPeriodEndsAt.Value.ToString("s")); } if (BankAccountAuthorizedAt.HasValue) { xmlWriter.WriteElementString("bank_account_authorized_at", BankAccountAuthorizedAt.Value.ToString("s")); } if (StartsAt.HasValue) { xmlWriter.WriteElementString("starts_at", StartsAt.Value.ToString("s")); } if (TotalBillingCycles.HasValue) { xmlWriter.WriteElementString("total_billing_cycles", TotalBillingCycles.Value.AsString()); } if (FirstRenewalDate.HasValue) { xmlWriter.WriteElementString("first_renewal_date", FirstRenewalDate.Value.ToString("s")); } if (Bulk.HasValue) { xmlWriter.WriteElementString("bulk", Bulk.ToString().ToLower()); } if (CollectionMethod.Like("manual")) { xmlWriter.WriteElementString("collection_method", "manual"); xmlWriter.WriteElementString("net_terms", NetTerms.Value.AsString()); xmlWriter.WriteElementString("po_number", PoNumber); } else if (CollectionMethod.Like("automatic")) { xmlWriter.WriteElementString("collection_method", "automatic"); } // <account> and billing info Account.WriteXml(xmlWriter); xmlWriter.WriteEndElement(); // End: subscription }
public static LdapData GetLdapFilter(CollectionMethod method, bool excludeDc, bool stealth) { string ldapFilter; string[] props; switch (method) { case CollectionMethod.Container: ldapFilter = ""; props = new string[] { }; break; case CollectionMethod.Group: //private static readonly HashSet<string> Groups = new HashSet<string> { "268435456", "268435457", "536870912", "536870913" }; ldapFilter = "(|(samaccounttype=268435456)(samaccounttype=268435457)(samaccounttype=536870912)(samaccounttype=536870913)(primarygroupid=*))"; props = new[] { "samaccountname", "distinguishedname", "samaccounttype", "member", "cn", "primarygroupid", "dnshostname" }; break; case CollectionMethod.ComputerOnly: if (!stealth) { ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype" }; } else { ldapFilter = "(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*))"; props = new[] { "displayname", "name", "gpcfilesyspath" }; } break; case CollectionMethod.LocalGroup: ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype" }; break; case CollectionMethod.GPOLocalGroup: ldapFilter = "(&(objectCategory=groupPolicyContainer)(name=*)(gpcfilesyspath=*))"; props = new[] { "displayname", "name", "gpcfilesyspath" }; break; case CollectionMethod.Session: ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; if (excludeDc) { ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2))(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))"; } props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype" }; break; case CollectionMethod.LoggedOn: ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype" }; break; case CollectionMethod.Trusts: ldapFilter = "(objectclass=domain)"; props = new[] { "distinguishedname" }; break; case CollectionMethod.ACL: ldapFilter = "(|(samAccountType=805306368)(samAccountType=805306369)(samAccountType=268435456)(samAccountType=268435457)(samAccountType=536870912)(samAccountType=536870913)(objectClass=domain)(objectCategory=groupPolicyContainer))"; props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype", "ntsecuritydescriptor", "displayname", "objectclass", "objectsid", "name" }; break; case CollectionMethod.SessionLoop: ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; if (excludeDc) { ldapFilter = "(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2))(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))"; } props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype" }; break; case CollectionMethod.Default: ldapFilter = "(|(samaccounttype=268435456)(samaccounttype=268435457)(samaccounttype=536870912)(samaccounttype=536870913)(primarygroupid=*)(&(sAMAccountType=805306369)(!(UserAccountControl:1.2.840.113556.1.4.803:=2))))"; props = new[] { "samaccountname", "distinguishedname", "dnshostname", "samaccounttype", "primarygroupid", "member", "cn" }; break; case CollectionMethod.ObjectProps: ldapFilter = "(|(samaccounttype=805306368)(samaccounttype=805306369))"; props = new[] { "samaccountname", "distinguishedname", "samaccounttype", "pwdlastset", "lastlogon", "objectsid", "sidhistory", "useraccountcontrol", "dnshostname", "operatingsystem", "operatingsystemservicepack", "serviceprincipalname", "displayname", "mail", "title", "homedirectory" }; break; default: throw new ArgumentOutOfRangeException(nameof(method), method, null); } return(new LdapData { Filter = ldapFilter, Properties = props }); }
internal void WriteSubscriptionXml(XmlTextWriter xmlWriter, bool embedded) { xmlWriter.WriteStartElement("subscription"); // Start: subscription xmlWriter.WriteElementString("plan_code", PlanCode); if (!embedded) { // <account> and billing info Account.WriteXml(xmlWriter); xmlWriter.WriteElementString("currency", Currency); xmlWriter.WriteElementString("customer_notes", CustomerNotes); xmlWriter.WriteElementString("terms_and_conditions", TermsAndConditions); xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes); xmlWriter.WriteElementString("po_number", PoNumber); } xmlWriter.WriteIfCollectionHasAny("subscription_add_ons", AddOns); xmlWriter.WriteStringIfValid("coupon_code", _couponCode); if (_couponCodes != null && _couponCodes.Length != 0) { xmlWriter.WriteStartElement("coupon_codes"); foreach (var _coupon_code in _couponCodes) { xmlWriter.WriteElementString("coupon_code", _coupon_code); } xmlWriter.WriteEndElement(); } if (UnitAmountInCents.HasValue) { xmlWriter.WriteElementString("unit_amount_in_cents", UnitAmountInCents.Value.AsString()); } xmlWriter.WriteElementString("quantity", Quantity.AsString()); if (TrialPeriodEndsAt.HasValue) { xmlWriter.WriteElementString("trial_ends_at", TrialPeriodEndsAt.Value.ToString("s")); } if (BankAccountAuthorizedAt.HasValue) { xmlWriter.WriteElementString("bank_account_authorized_at", BankAccountAuthorizedAt.Value.ToString("s")); } if (StartsAt.HasValue) { xmlWriter.WriteElementString("starts_at", StartsAt.Value.ToString("s")); } if (TotalBillingCycles.HasValue) { xmlWriter.WriteElementString("total_billing_cycles", TotalBillingCycles.Value.AsString()); } if (FirstRenewalDate.HasValue) { xmlWriter.WriteElementString("first_renewal_date", FirstRenewalDate.Value.ToString("s")); } if (Bulk.HasValue) { xmlWriter.WriteElementString("bulk", Bulk.ToString().ToLower()); } if (CollectionMethod.Like("manual")) { xmlWriter.WriteElementString("collection_method", "manual"); if (NetTerms.HasValue) { xmlWriter.WriteElementString("net_terms", NetTerms.Value.AsString()); } } else if (CollectionMethod.Like("automatic")) { xmlWriter.WriteElementString("collection_method", "automatic"); } if (ShippingAddressId.HasValue) { xmlWriter.WriteElementString("shipping_address_id", ShippingAddressId.Value.ToString()); } if (ImportedTrial.HasValue) { xmlWriter.WriteElementString("imported_trial", ImportedTrial.Value.ToString().ToLower()); } if (RevenueScheduleType.HasValue) { xmlWriter.WriteElementString("revenue_schedule_type", RevenueScheduleType.Value.ToString().EnumNameToTransportCase()); } if (RemainingBillingCycles.HasValue) { xmlWriter.WriteElementString("remaining_billing_cycles", RemainingBillingCycles.Value.AsString()); } if (AutoRenew.HasValue) { xmlWriter.WriteElementString("auto_renew", AutoRenew.Value.AsString()); } if (RenewalBillingCycles.HasValue) { xmlWriter.WriteElementString("renewal_billing_cycles", RenewalBillingCycles.Value.AsString()); } xmlWriter.WriteIfCollectionHasAny("custom_fields", CustomFields); if (!ShippingMethodCode.IsNullOrEmpty()) { xmlWriter.WriteElementString("shipping_method_code", ShippingMethodCode); } if (ShippingAmountInCents.HasValue) { xmlWriter.WriteElementString("shipping_amount_in_cents", ShippingAmountInCents.Value.AsString()); } xmlWriter.WriteEndElement(); // End: subscription }
/// <summary> /// Retrieve the data table to the associated query. /// </summary> /// <param name="query">SQL command (query).</param> /// <param name="path">Full path to the database file.</param> /// <returns>A dataset of type System.Data.DataTable.</returns> public static DataTable GetDataTable(string query, string path, string tableName = null) { //debug output the query string System.Diagnostics.Debug.WriteLine(query); //Build the data table; DataTable fetchedTable = null; //Configure the data access service; DataAccess da = new DataAccess(); CollectionMethod method = new CollectionMethod(da.GetTable); //Execute the query; IAsyncResult result = method.BeginInvoke(query, Query.OpenConnection(path), null, null); //Fetch the result of the query from the data service; fetchedTable = method.EndInvoke(result) as DataTable; //Return the table; if (fetchedTable != null) return fetchedTable; else return new DataTable(); }
} //CalculateBalance private int AddCollectionLog(int customerID, int loanID, CollectionType type, CollectionMethod method) { Log.Info("Adding collection log to customer {0} loan {1} type {2} method {3}", customerID, loanID, type, method); return(DB.ExecuteScalar <int>("AddCollectionLog", CommandSpecies.StoredProcedure, new QueryParameter("CustomerID", customerID), new QueryParameter("LoanID", loanID), new QueryParameter("Type", type.ToString()), new QueryParameter("Method", method.ToString()), new QueryParameter("Now", this.now))); } //AddCollectionLog