static void Main(string[] args) { var firstDate = Console.ReadLine(); var secondDate = Console.ReadLine(); Console.WriteLine(DataModifier.GetDaysBetweenDates(firstDate, secondDate)); }
static void Main(string[] args) { string DataInPath = ConfigReader.Read("DataInPath"); string DataOutPath = ConfigReader.Read("DataOutPath"); string ConfigPath = ConfigReader.Read("ConfigPath"); Logger.Log("DataInPath: " + DataInPath); Logger.Log("DataOutPath : " + DataOutPath); Logger.Log("ConfigPath: " + ConfigPath); try { _modifier = ConfigPath == null ? null : new DataModifier(File.ReadAllLines(ConfigPath)); _sw = new StreamWriter(new FileStream(DataOutPath, FileMode.Create, FileAccess.Write), Encoding.GetEncoding(1251)); _loader.ProceedRowFunc = ProceedRow; _loader.Load(DataInPath); } catch (Exception e) { Logger.Log(e); } finally { _sw.Close(); } }
static void Main(string[] args) { DataModifier data = new DataModifier(); var firstDate = Console.ReadLine(); var secondDate = Console.ReadLine(); Console.WriteLine(data.CalculatesTheDifferenceBetweeenTwoDate(firstDate, secondDate)); }
static void Main(string[] args) { var date1 = Console.ReadLine(); var date2 = Console.ReadLine(); var dataModifier = new DataModifier(); Console.WriteLine(dataModifier.CalculateDifference(date1, date2)); }
// protected static void atkHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.atk += eftD; // } // protected static void defHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.defense += eftD; // } // protected static void aspdHandler(Effect eftD, DataModifier dmAdd, DataModifier dmMult) { if(eftD.isPer) { dmMult.atkSpd += eftD.num; } else { dmAdd.atkSpd += eftD.num; } }
public void DeleteSiteByObjid(int objid) { ClarifyDataAccessWS clarifyDA = new ClarifyDataAccessWS(session); DataModifier generic = clarifyDA.CreateDataModifier(); DeleteModifier delete = generic.CreateDeleteModifier("site", "site"); delete.AppendUniqueFilter("objid", objid.ToString()); ModifierResultProtocol[] results = generic.Update(); Assert.AreEqual(objid, results[0].Objid); }
private static void ByClientMode(string dataPath, string ids, string target, DataModifier modifier, AbstractClassifier cls) { try { cls.LoadClassifier(); // loading data var loader = target == null ? new DataLoader() : new DataLoader(target); loader.AddIdsString(ids); loader.Load(dataPath); using (var sw = new StreamWriter(new FileStream(dataPath + "_calc.csv", FileMode.Create, FileAccess.Write))) { if (target != null) { sw.WriteLine(loader.IdName + ";prob;target"); } else { sw.WriteLine(loader.IdName + ";prob"); } int idx = 0; // calculating prob for each row foreach (var row in loader.Rows) { idx++; double[] mvals = GetRowValues(modifier, loader, row); var prob = cls.PredictProba(mvals); string targStr = target != null ? (";" + row.Target) : null; string oinfo = prob.ObjectInfo != null ? (";" + prob.ObjectInfo) : null; sw.WriteLine(row.Id + ";" + prob.Probs[1] + targStr + oinfo); if (idx % 123 == 0) { Logger.Log(idx + " lines writed;"); sw.Flush(); } } Logger.Log(idx + " lines writed; done;"); sw.Close(); } } catch (Exception e) { Logger.Log(e); } }
public string InsertSiteGetIDNum() { ClarifyDataAccessWS clarifyDA = new ClarifyDataAccessWS(session); string siteIDNum = session.GetNextNumScheme("Site ID"); DataModifier generic = clarifyDA.CreateDataModifier(); InsertModifier insert = generic.CreateInsertModifier("SiteInsert", "site"); insert.SetField("site_id", siteIDNum); insert.SetField("name", "unit test"); insert.SetField("type", "1"); ModifierResultProtocol[] result = generic.Update(); return(siteIDNum); }
public static void Main(string[] args) { string dataPath = ConfigReader.Read("DataPath"); string confPath = ConfigReader.Read("ConfPath"); int bucketSize = int.Parse(ConfigReader.Read("BucketSize")); string classifierType = ConfigReader.Read("ClassifierType"); string idName = ConfigReader.Read("IdName"); string targetName = ConfigReader.Read("TargetName"); Logger.Log("DataPath = " + dataPath); Logger.Log("ConfPath = " + confPath); Logger.Log("BucketSize = " + bucketSize); Logger.Log("ClassifierType = " + classifierType); Logger.Log("IdName = " + idName); Logger.Log("TargetName = " + targetName); try { // loading modifier DataModifier modifier = null; if (confPath != null) { modifier = new DataModifier(File.ReadAllLines(confPath)); } // loading classifier AbstractClassifier cls = LoadClassifier(classifierType); if (bucketSize > 0) { // by tree bucket mode Logger.Log("by tree bucket mode, BucketSize = " + bucketSize); ByBucketMode(dataPath, idName, targetName, bucketSize, modifier, cls); } else { // by client mode Logger.Log("by client mode"); ByClientMode(dataPath, idName, targetName, modifier, cls); } } catch (Exception e) { Logger.Log(e); } }
private static double[] GetRowValues(DataModifier modifier, DataLoader loader, Domain.DataRow <float> row) { if (modifier == null) { return(Array.ConvertAll(row.Values, x => (double)x)); } var vals = new Dictionary <string, double>(); for (int i = 0; i < row.Values.Length; i++) { string colname = loader.RowColumnByIdx[i]; vals.Add(colname, row.Values[i]); } var mvals = modifier.GetModifiedDataVector(vals); return(mvals); }
private void CreateNewContact() { try { EnableValidators(); Page.Validate(); if (Page.IsValid) { // Create new Clarify Data Access Web Service Client ClarifyDataAccessWS dataAccess = new ClarifyDataAccessWS(Global.ClarifySessWS); // Create a DataModifier for modifying data on the database DataModifier dataModifier = dataAccess.CreateDataModifier(); // Create modify items for the tables we want to insert new records InsertModifier contactInsert = dataModifier.CreateInsertModifier("contactInsert", "contact"); InsertModifier contactRoleInsert = dataModifier.CreateInsertModifier("contactRoleInsert", "contact_role"); InsertModifier siteInsert = dataModifier.CreateInsertModifier("siteInsert", "site"); InsertModifier addressInsert = dataModifier.CreateInsertModifier("addressInsert", "address"); ReferenceModifier stateProvRef = dataModifier.CreateReferenceModifier("stateProvRef", "state_prov"); ReferenceModifier timezoneRef = dataModifier.CreateReferenceModifier("timezoneRef", "time_zone"); ReferenceModifier countryRef = dataModifier.CreateReferenceModifier("countryRef", "country"); // Append fields that we want to insert values into contactInsert.SetField("first_name", this.firstName.Text); contactInsert.SetField("last_name", this.lastName.Text); contactInsert.SetField("phone", this.phoneNumber.Text); // Relate this inserted record to another Modifier contactInsert.RelateRecord("contact2contact_role", contactRoleInsert); contactRoleInsert.SetField("role_name", "Default"); contactRoleInsert.SetField("primary_site", "1"); contactRoleInsert.RelateRecord("contact_role2site", siteInsert); // Get next Site ID from web service string siteID = Global.ClarifySessWS.GetNextNumScheme("Site ID"); siteInsert.SetField("site_id", siteID); siteInsert.SetField("name", this.siteName.Text); siteInsert.RelateRecord("cust_primaddr2address", addressInsert); siteInsert.RelateRecord("cust_billaddr2address", addressInsert); siteInsert.RelateRecord("cust_shipaddr2address", addressInsert); addressInsert.SetField("address", this.address1.Text); addressInsert.SetField("address_2", this.address2.Text); addressInsert.SetField("city", this.city.Text); addressInsert.SetField("state", this.state.SelectedValue); addressInsert.SetField("zipcode", this.zip.Text); addressInsert.RelateRecord("address2state_prov", stateProvRef); addressInsert.RelateRecord("address2time_zone", timezoneRef); addressInsert.RelateRecord("address2country", countryRef); // This we select an existing record to use as a relation for addressInsert stateProvRef.AppendUniqueFilter("full_name", this.state.SelectedValue); timezoneRef.AppendUniqueFilter("name", "CST"); countryRef.AppendUniqueFilter("name", "USA"); // Run the query and retrieve the results ModifierResultProtocol[] results = dataModifier.Update(); // Show the results to the user System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (ModifierResultProtocol result in results) { if (sb.Length > 0) { sb.Append("<br/>"); } sb.Append(string.Format("{0} on table [{1}] with objid of [{2}]", result.Action, result.Table, result.Objid)); } this.messageLabel.Text = String.Format("<b>Save successful.</b><br/>" + sb.ToString()); // Clear form ClearEntryFields(); } } catch (SoapException ex) { string message = ex.Detail.InnerText.Trim().Length > 0 ? ex.Detail.InnerText.Trim() : ex.Message; this.messageLabel.Text += String.Format("<b>Error adding contact.</b><br/>{0}", message.Replace("\n", "<br/>")); } }
public DataValueSource(DataModifier modifier, string mode) { this.modifier = modifier; this.mode = mode; }
protected static void defPsyHandler(Effect eftD, DataModifier dmAdd, DataModifier dmMult) { if(eftD.isPer) { dmMult.defense.PSY += eftD.num; } else { dmAdd.defense.PSY += eftD.num; } }
private static void ByBucketMode(string dataPath, string ids, string target, int bucketsize, DataModifier modifier, AbstractClassifier acls) { try { // classifier var cls = acls as DecisionForest; if (cls == null) { Logger.Log("classifier is not DecisionForest"); return; } // loading data var loader = target == null ? new DataLoader() : new DataLoader(target); loader.AddIdsString(ids); loader.Load(dataPath); int cnt = 0; int idx = 0; int totaltrees = 0; var probDict = new Dictionary <string, double>(); do { Logger.Log("Processing bucket #" + idx); cls.Clear(); cnt = cls.LoadClassifier(); if (cnt > 0) { totaltrees += cls.CountAllTrees; // calculating prob for each row foreach (var row in loader.Rows) { var mvals = GetRowValues(modifier, loader, row); var prob = cls.PredictCounts(mvals); if (!probDict.ContainsKey(row.Id)) { probDict.Add(row.Id, 0); } probDict[row.Id] += prob[1]; } idx++; } }while (cnt >= bucketsize); using (var sw = new StreamWriter(new FileStream(dataPath + "_calc.csv", FileMode.Create, FileAccess.Write))) { if (target != null) { sw.WriteLine(loader.IdName + ";prob;target"); } else { sw.WriteLine(loader.IdName + ";prob"); } foreach (var row in loader.Rows) { double prob = probDict[row.Id] / totaltrees; string targStr = target != null ? (";" + row.Target) : null; sw.WriteLine(row.Id + ";" + prob + targStr); } sw.Close(); } } catch (Exception e) { Logger.Log(e); } }
// // //xingyh // protected static void plantFDefHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.defense += eftD; // } // // protected static void plantAAtkHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.atk += eftD; // } // // protected static void plantADefHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.defense += eftD; // } // // protected static void plantTAtkHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.atk += eftD; // } // // protected static void plantTDefHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.defense += eftD; // } // // protected static void plantIAtkHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.atk += eftD; // } // // protected static void plantIDefHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.defense += eftD; // } // // protected static void critHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.crtlStk += eftD; // } // // protected static void evadeHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.evade += eftD; // } // // protected static void rcdHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.rcd += eftD; // } // // protected static void expHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.exp += eftD; // } protected static void goldHandler(Effect eftD, DataModifier dmAdd, DataModifier dmMult) { GlobalModifier.gold += (int)eftD.num; }
// protected static void fuelHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // GlobalModifier.fuelChance += eftD.num; // } // // protected static void luckHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // GlobalModifier.luck += eftD.num; // } protected static void hpHandler(Effect eftD, DataModifier dmAdd, DataModifier dmMult) { if(eftD.isPer) { dmMult.maxHp += (int)eftD.num; } else { dmAdd.maxHp += (int)eftD.num; } }
protected static void atkExpHandler(Effect eftD, DataModifier dmAdd, DataModifier dmMult) { if(eftD.isPer) { dmMult.attack.EXP += eftD.num; } else { dmAdd.attack.EXP += eftD.num; } }
// protected static void healPartHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.atkHealPart += eftD; // } // // protected static void healSelfHandler (Effect eftD, DataModifier dmAdd, DataModifier dmMult) // { // dm.atkHealSelf += eftD; // } protected static void deDefHandler(Effect eftD, DataModifier dmAdd, DataModifier dmMult) { GlobalModifier.de_def += (int)eftD.num; }
public void resetEft() { /*eAttack = 0; eMaxHp = 0; eDefense= 0; eAtkSpd = 0; eMoveSpd= 0; eCrtlStk= 0;*/ itemAdd = new DataModifier(); itemMult = new DataModifier(); skillAdd = new DataModifier(); skillMult = new DataModifier(); }