private DataSet GetReceipents(TO sendTo, int ID, String Topic) { DataSet ds; if (sendTo == TO.All) { DataAccess dacess = new DataAccess(); //String VendorQuery = "Select * from dbo.aSocietybillplans"; String VendorQuery = "Select * from ViewNewUserSetting where Topic ='" + Topic + "' "; ds = dacess.GetData(VendorQuery); } else if (sendTo == TO.Society) { DataAccess dacess = new DataAccess(); //String VendorQuery = "Select * from dbo.aSocietybillplans"; String VendorQuery = "Select * from ViewNewUserSetting where Topic ='" + Topic + "' and SocietyID = " + ID; ds = dacess.GetData(VendorQuery); } else { DataAccess dacess = new DataAccess(); //String VendorQuery = "Select * from dbo.aSocietybillplans"; String VendorQuery = "Select * from ViewNewUserSetting where Topic ='" + Topic + "' and ResID = " + ID; ds = dacess.GetData(VendorQuery); } return(ds); }
private List <ViewNewUserSetting> GetReceipents(TO sendTo, int ID, String Topic) { List <ViewNewUserSetting> list; if (sendTo == TO.All) { list = DbContext.ViewNewUserSettings.Where(us => us.Topic == Topic).Distinct().ToList(); } else if (sendTo == TO.Society) { list = DbContext.ViewNewUserSettings.Where(us => us.SocietyID == ID && us.Topic == Topic).Distinct().ToList(); } else if (sendTo == TO.User) { list = DbContext.ViewNewUserSettings.Where(us => us.ResID == ID && us.Topic == Topic).ToList().ToList(); } else if (sendTo == TO.Flat) { list = DbContext.ViewNewUserSettings.Where(us => us.FlatID == ID && us.Topic == Topic).ToList().ToList(); } else { list = DbContext.ViewNewUserSettings.Where(us => us.ResID == ID && us.Topic == Topic).ToList().ToList(); } return(list); }
public void Notify(TO sendTo, int ID, Message message) { String textMessage = message.Topic + "&" + message.TextMessage; DataSet ds = GetReceipents(sendTo, ID, message.Topic); { if (ds != null) { ds.Tables[0].AsEnumerable(); } var GCMList = (from g in ds.Tables[0].AsEnumerable() where g.Field <bool>("GCM") == true select g.Field <String>("RegID")).ToArray(); if (GCMList.Count() > 0) { string gcmArray = String.Concat(GCMList); SendNotification(gcmArray, textMessage); } var mailList = (from g in ds.Tables[0].AsEnumerable() where g.Field <bool>("Mail") == true select g.Field <String>("RegID")).ToArray(); foreach (String mail in mailList) { SendMail(mail, message.Topic, message.TextMessage); } } }
public static void Init() { TO.Init(); if (IS_INIT == true) { return; } float DISPLAY_WIDTH = Screen.width / 100.0f; float DISPLAY_HEIGHT = Screen.height / 100.0f; DISPLAY_RATIO = DISPLAY_WIDTH / DISPLAY_HEIGHT; float ratio = Screen.dpi * 1.0f / 160; if (ratio == 0) { ratio = 1; } WIDTH = 320 * DISPLAY_RATIO; HEIGHT = 320; WIDTH_HALF = WIDTH / 2; WIDTH_HALF_MINUS = -WIDTH_HALF; HEIGHT_HALF = HEIGHT / 2; IS_INIT = true; //Debug.Log (WIDTH); }
public async Task <IActionResult> Create(String FirstName, String LastName, String Email) { var newTO = new TO { Email = Email, FirstName = FirstName, LastName = LastName }; _context.Add(newTO); await _context.SaveChangesAsync(); var newUser = new User { Email = Email, Password = GenerateRandomPassword(), TOId = newTO.TOId }; try { _context.Add(newUser); await _context.SaveChangesAsync(); Alert("TO Adicionado com Sucesso!", "Foi adicionado um novo TO ao sistema!", NotificationType.success); } catch { Alert("Ocorreu um erro!", "Não foi possivel adicionar o TO ao sistema!", NotificationType.error); return(RedirectToAction("Search", "Teachers")); } return(RedirectToAction("SelectTfc", "Tfcs", newTO)); }
public void Notify(TO sendTo, int ID, Message message) { try { List <ViewNewUserSetting> list = GetReceipents(sendTo, ID, message.Topic); String textMessage = message.Topic + "&" + message.TextMessage; var GCMList = (from g in list where g.GCM == true select g.RegID).ToArray(); if (GCMList.Count() > 0) { string gcmArray = String.Concat(GCMList); Utility.SendGCMNotification(gcmArray, textMessage); } var mailList = (from g in list where g.Mail == true select g.EmailId).ToArray(); foreach (String mail in mailList) { Utility.SendMail(mail, message.Topic, message.TextMessage); } } catch (Exception ex) { } }
static void Main() { /* ??????? */ string[] input = Console.ReadLine().Split(); N = long.Parse(input[0]); M = int.Parse(input[1]); p = new long[M]; a = new double[M]; b = new double[M]; for (int i = 0; i < M; i++) { input = Console.ReadLine().Split(); p[i] = long.Parse(input[0]) - 1; a[i] = double.Parse(input[1]); b[i] = double.Parse(input[2]); } /* ????????TO???????????????? */ SortedList <long, long> sl = new SortedList <long, long>(); foreach (var i in p) { try { sl.Add(i, i); } catch { continue; } } N = sl.Count; /* TO??????????? */ n = 1; while (n < N) { n *= 2; } Seg = new TO[2 * n - 1]; for (int i = 0; i < 2 * n - 1; i++) { Seg[i] = new TO(1.0, 0.0); } double min = 1; double max = 1; /* ????????????? */ for (int i = 0; i < M; i++) { int p_ = sl.IndexOfKey(p[i]); double a_ = a[i]; double b_ = b[i]; Prank(p_, a_, b_); min = Math.Min(min, Seg[0].a + Seg[0].b); max = Math.Max(max, Seg[0].a + Seg[0].b); } /* ????? */ Console.WriteLine(min); Console.WriteLine(max); }
public void AddElement(TOBindingModel model) { using (var transaction = context.Database.BeginTransaction()) { try { var _TO = context.TOs.FirstOrDefault(record => record.TOName == model.TOName); if (_TO != null) { throw new Exception("Такое ТО уже существует."); } else { _TO = new TO { TOName = model.TOName, Price = model.Price }; } context.TOs.Add(_TO); context.SaveChanges(); var duplicates = model.TODetails .GroupBy(record => record.DetailId) .Select(record => new { detailId = record.Key, amount = record.Sum(rec => rec.Amount) }); foreach (var duplicate in duplicates) { context.TO_Details.Add(new TO_Detail { TOId = _TO.Id, DetailId = duplicate.detailId, Amount = duplicate.amount }); context.SaveChanges(); } transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } } }
/* ???????? */ static void Prank(int p, double a, double b) { p += n - 1; Seg[p] = new TO(a, b); while (p > 0) { p = (p - 1) / 2; double al = Seg[p * 2 + 1].a; double bl = Seg[p * 2 + 1].b; double ar = Seg[p * 2 + 2].a; double br = Seg[p * 2 + 2].b; Seg[p] = new TO(al * ar, ar * bl + br); } }
static void Main(string[] args) { TimeSpan t1 = new TimeSpan(8, 48, 0); TimeSpan t2 = new TimeSpan(9, 56, 0); TimeSpan t3 = new TimeSpan(10, 5, 0); TimeSpan t4 = new TimeSpan(13, 30, 0); TO <bool> TO = new TO <bool>(t1, true) { new TO <bool>(t2, false) { new TO <bool> (t3, true) { new TO <bool>(t4, false) } } }; Console.WriteLine("The time now is considered " + TO.OkNok(DateTime.Now)); Console.ReadLine(); }
public TO To <TO>() where TO : new() { var srcType = typeof(TI); var targetType = typeof(TO); var key = ComputeMapperKey(srcType, targetType, 0x10); if (MappersCollection.TryGetValue(key, out var del) == false) { var param = Expression.Parameter(srcType, "src"); var srcMembers = param.Type.GetFieldsAndProperties(); var targetMembers = targetType.GetFieldsAndProperties(); var memberAssignments = targetMembers.Join(srcMembers, mem => mem.Name, mem => mem.Name, (targetMember, sourceMember) => Expression.Bind(targetMember, Expression.PropertyOrField(param, sourceMember.Name))); var init = Expression.MemberInit(Expression.New(targetType), memberAssignments); del = Expression.Lambda <Func <TI, TO> >(init, param).Compile(); MappersCollection.Add(key, del); } var temp = new TO(); return(((Func <TI, TO>)del)(_src)); }
public static void Test7(DniproDB db) { TO to1 = new TO { id = 123, FirstName = "John", LastName = "Smith", Arr = new List<int>() { 1, 2, 3, 4, 5 } }; db.AddDoc<TO>(to1); TO to2 = new TO { id = 123, FirstName = "John", LastName = "Smith", Arr = new List<int>() { 7, 4, 2, 8, 9 } }; db.AddDoc<TO>(to2); TO[] tos = db.GetWhere("{'Arr':[In,2,4]}").Select<TO>(); //tos = tos; }
/// <summary> /// Build an ouput that is assumed to have valid output. /// </summary> public ThreadedWorkProduct(TO output) { ResultType = ThreadedWorkResultType.OutputProduced; Output = output; }
public ThreadedWorkProduct(TO output, ThreadedWorkResultType resultType) { Output = output; ResultType = resultType; }
public static void Test6(DniproDB db) { TO[] docs = new TO[50000]; for (int i = 0; i < 50000; i++) { docs[i] = new TO { id = i, FirstName = "John" + i.ToString(), LastName = "Smith" + i.ToString(), Arr = new List<int>() { 1, 2, 3, 4, 5 } }; } Stopwatch s = new Stopwatch(); s.Start(); db.AddDocs<TO>(docs); s.Stop(); Console.WriteLine("Test6: " + s.ElapsedMilliseconds.ToString()); }
public async Task <ActionResult> SelectTfc(TO newTO) { ViewData["newTOId"] = newTO.TOId; return(View(await _context.Tfc.ToListAsync())); }
public void Add(TO <T> nt) { this.NT = nt; }