private List<Collaborators> FindCommonCollaborators(List<IProject> sortedProjects)
        {
            //List<Tuple<IProject, List<IPeople>, List<IPeople>>> collaborators = new List<Tuple<IProject, List<IPeople>, List<IPeople>>>();
            List<Collaborators> collaborators = new List<Collaborators>();
            var previous = new List<IPeople>();
            for (int i = 0; i < sortedProjects.Count; i++)
            {
                var project = sortedProjects[i];

                var projectCollaborators = this.people.Where(x => x.Contributions.Any(y => y.Project == project.Name)).Distinct().Cast<IPeople>().ToList();

                if (i == 0)
                {   // Has no collaborators with the previous
                    collaborators.Add(new Collaborators(project, new List<IPeople>(), projectCollaborators));
                    previous = new List<IPeople>(projectCollaborators);   // Initialize the common collaborators
                    continue;
                }

                ReportProgress(15 + (i * 45 / sortedProjects.Count), string.Format("Finding common collaborators for {0}. Completed {1}/{2} projects", project.Name, i, sortedProjects.Count));
                var commonCollaborators = previous.Join(projectCollaborators, c => c.Name, p => p.Name, (c, p) => c).ToList();

                previous = previous.Concat(projectCollaborators).Distinct().ToList();   // Add new people to the heap

                Collaborators myCollaborators = new Collaborators(project, commonCollaborators, projectCollaborators);
                GetCommonPhaseCollaborators(ref myCollaborators, commonCollaborators, project);
                collaborators.Add(myCollaborators);
            }

            return collaborators;
        }
Ejemplo n.º 2
0
        public Collaborator AddCollaborator(Collaborator collab)
        {
            collab.CollaboratorId = Collaborators.Any() ? Collaborators.Max(c => c.CollaboratorId) + 1 : 1;
            Collaborators.Add(collab);

            return(collab);
        }
        private void GetCommonPhaseCollaborators(ref Collaborators myCollaborators, List<IPeople> commonCollaborators, IProject project)
        {
            List<ICategory> phases = this.categories.Where(x => string.Equals(x.Project, project.Name)).ToList();

            foreach (ICategory phase in phases)
            {
                List<IPeople> commonPhaseCollaborators = commonCollaborators.Where(x => phase.Contributions.Any(y => string.Equals(y.Contributor, x.Name, StringComparison.OrdinalIgnoreCase))).ToList();
                myCollaborators.CommonPhaseCollaborators[phase] = commonPhaseCollaborators;
            }
        }
Ejemplo n.º 4
0
 public ActionResult Delete(int id)
 {
     using (MyDatabaseEntities db = new MyDatabaseEntities())
     {
         Collaborators coll = db.Collaborators.Where(x => x.Id == id).FirstOrDefault <Collaborators>();
         db.Collaborators.Remove(coll);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
        private bool SendMail(Collaborators objCollaborators)
        {
            bool IsMailSent = false;

            try
            {
                MailMessage mail = new MailMessage();

                string SMPTPServer = ConfigurationManager.AppSettings["SMTPServer"] != null ?
                                     ConfigurationManager.AppSettings["SMTPServer"].ToString() : string.Empty;
                string SenderAddress = ConfigurationManager.AppSettings["SenderAddress"] != null ?
                                       ConfigurationManager.AppSettings["SenderAddress"].ToString() : string.Empty;
                string RecipientAddress = ConfigurationManager.AppSettings["RecipientAddress"] != null ?
                                          ConfigurationManager.AppSettings["RecipientAddress"].ToString() : string.Empty;
                int PortNumber = ConfigurationManager.AppSettings["PortNumber"] != null?
                                 Convert.ToInt32(ConfigurationManager.AppSettings["PortNumber"].ToString()) : 0;

                string UserName = ConfigurationManager.AppSettings["UserName"] != null ?
                                  ConfigurationManager.AppSettings["UserName"].ToString() : string.Empty;
                string Password = ConfigurationManager.AppSettings["Password"] != null ?
                                  ConfigurationManager.AppSettings["Password"].ToString() : string.Empty;
                string VerifyURL = ConfigurationManager.AppSettings["VerifyURL"] != null ?
                                   ConfigurationManager.AppSettings["VerifyURL"].ToString() : string.Empty;

                SmtpClient SmtpServer = new SmtpClient(SMPTPServer);

                mail.From = new MailAddress(SenderAddress);
                mail.To.Add(RecipientAddress);
                mail.Subject = "Test Mail for Cloud Kickers";
                mail.Body    = "Test Mail for Cloud Kickers";
                //Attachment attachment = new Attachment(filename);
                //mail.Attachments.Add(attachment);

                RandomStringGenerator objRandomStringGenerator = new RandomStringGenerator();
                string strVerifyToken = objRandomStringGenerator.Generate(64);
                VerifyURL = VerifyURL.Replace("@Token", strVerifyToken);
                VerifyURL = VerifyURL.Replace("@Email", objCollaborators.CollabeMail);
                VerifyURL = VerifyURL.Replace("@VaultID", objCollaborators.VaultID.ToString());
                VerifyURL = VerifyURL.Replace("#", "&");

                mail.Body = VerifyURL;

                SmtpServer.Port        = PortNumber;
                SmtpServer.Credentials = new System.Net.NetworkCredential(UserName, Password);
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
                IsMailSent = true;
            }
            catch (Exception ex)
            {
            }
            return(IsMailSent);
        }
        public HttpResponseMessage DeleteCollaborator(Collaborators objCollaborators)
        {
            //_unitOfCollaborator.GetRepoInstance<TblCollaborator>().Delete(objTblCollaborator);
            HttpResponseMessage objHTTPResponseMessage;

            _unitOfCollaborator = new GenericUnitOfWork();
            ObjectResult <string> objResult = _unitOfCollaborator.GetRepoInstance <TblCollaborator>().SPDelete(objCollaborators.CollabeID, objCollaborators.UserID, objCollaborators.IPAddress);

            objHTTPResponseMessage = Request.CreateResponse(objResult.FirstOrDefault());
            return(objHTTPResponseMessage);
        }
        private TblCollaborator ConvertToCollaboratorDataModel(Collaborators objCollaborators)
        {
            TblCollaborator objTblCollaborators = new TblCollaborator();

            objTblCollaborators.CollabeEmail = objCollaborators.CollabeMail;
            objTblCollaborators.VaultID      = objCollaborators.VaultID;
            objTblCollaborators.UserID       = objCollaborators.UserID;
            objTblCollaborators.CollabID     = 1;
            objTblCollaborators.Token        = string.Empty;
            return(objTblCollaborators);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> PartnerRegistrationForm([Bind("ID,email,fullName,password,office,joinDate,gender,birthday, cmnd, place, day, field,position, house, nation, city, phone, district, town, zip, office_name")] Collaborators collaborator)
        {
            //if (ModelState.IsValid)
            //{
            collaborator.joinDate = DateTime.Now.Date;
            collaborator.office   = "Cộng tác viên";

            _context.Add(collaborator);
            await _context.SaveChangesAsync();

            //var contracts = await _context.Contracts.OrderBy(m => m.ID).ToListAsync();
            //var autho = _context.Administrator.First();
            return(RedirectToAction("Collaborators", "Administrator"));
        }
Ejemplo n.º 9
0
        public bool DeleteCollaborators(Collaborators collaborator)
        {
            var r = StaticFunctions.Request(
                "Farms/Collaborators/",
                JsonConvert.SerializeObject(collaborator),
                HttpMethod.Delete,
                User.FindFirst(claim => claim.Type == "Token")?.Value
                );

            if (r != null)
            {
                return(JsonConvert.DeserializeObject <bool>(r));
            }
            return(false);
        }
Ejemplo n.º 10
0
        public Collaborators AddOrUpdateCollaborators(Collaborators collaborator)
        {
            var r = StaticFunctions.Request(
                "Farms/Collaborators/",
                JsonConvert.SerializeObject(collaborator),
                HttpMethod.Post,
                User.FindFirst(claim => claim.Type == "Token")?.Value
                );

            if (r != null)
            {
                var _r = JsonConvert.DeserializeObject <Collaborators>(r);
                return(_r);
            }
            return(null);
        }
        public async Task <IActionResult> Collabor_Edit(int id, [Bind("policy,ID,email, fullName, password, office, joinDate, gender, birthday,cmnd,place, day, office_name,field, position, house, town, nation, city, district,zip, phone")] Collaborators collaborator)
        {
            if (id != collaborator.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _context.Update(collaborator);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Collaborators"));
            }
            return(View(collaborator));
        }
Ejemplo n.º 12
0
        private bool IsDuplicateCollaborator(Collaborators objCollaborator)
        {
            bool IsDuplicateCollaborator = false;

            using (CKANDBEntities context = new CKANDBEntities())
            {
                if ((from x in context.TblCollaborators
                     where
                     x.VaultID == objCollaborator.VaultID &&
                     x.CollabeEmail == objCollaborator.CollabeMail &&
                     x.UserID == objCollaborator.UserID
                     select x.ID).Count() > 0)
                {
                    IsDuplicateCollaborator = true;
                }
            }
            return(IsDuplicateCollaborator);
        }
Ejemplo n.º 13
0
 public ActionResult AddOrEdit(Collaborators coll)
 {
     using (MyDatabaseEntities db = new MyDatabaseEntities())
     {
         if (coll.Id == 0)
         {
             db.Collaborators.Add(coll);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(coll).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Ejemplo n.º 14
0
        public HttpResponseMessage PostCollaborator(Collaborators objCollaborators)
        {
            //TblCollaborator objTblCollaborator = ConvertToCollaboratorDataModel(objCollaborators);
            //_unitOfCollaborator.GetRepoInstance<TblCollaborator>().Insert(objTblCollaborator);
            //_unitOfCollaborator.SaveChanges();
            HttpResponseMessage objHTTPResponseMessage;

            _unitOfCollaborator = new GenericUnitOfWork();

            RandomStringGenerator objRandomStringGenerator = new RandomStringGenerator();

            objCollaborators.Token = objRandomStringGenerator.Generate(64);

            ObjectResult <string> objResult = _unitOfCollaborator.GetRepoInstance <TblCollaborator>().SPSave(objCollaborators.VaultID, objCollaborators.CollabeMail, objCollaborators.UserID, objCollaborators.CollabeID, objCollaborators.Token, objCollaborators.IPAddress);

            objHTTPResponseMessage = Request.CreateResponse(objResult.FirstOrDefault());
            if (objHTTPResponseMessage.StatusCode == HttpStatusCode.OK)
            {
                SendMail(objCollaborators);
            }
            return(objHTTPResponseMessage);
        }
        public async Task <IActionResult> Home(Collaborators c)
        {
            var autho = await _context.Collaborators.SingleOrDefaultAsync(coll => coll.email == c.email);

            if (autho != null)
            {
                if (c.email.Equals(autho.email) && c.password.Equals(autho.password))
                {
                    var customers = await _context.Customers.Where(cm => cm.CollaboratorsID == autho.ID).ToListAsync();

                    CustomerModal modal = new CustomerModal();
                    modal.coll      = autho;
                    modal.customers = customers;
                    coll            = autho;
                    return(View(modal));
                }
                else
                {
                    return(View("Error"));
                }
            }

            return(View("Error"));
        }
 protected override Task Load()
 {
     return(Collaborators.SimpleCollectionLoad(this.GetApplication().Client.Users[Username].Repositories[Repository].GetCollaborators()));
 }
Ejemplo n.º 17
0
 public Collaborator GetCollaboratorById(int id)
 {
     return(Collaborators.FirstOrDefault(m => m.CollaboratorId == id));
 }
Ejemplo n.º 18
0
 public void DeleteCollaborator(int id)
 {
     Collaborators.RemoveAll(m => m.CollaboratorId == id);
 }
Ejemplo n.º 19
0
        internal void Initialize()
        {
            if (Version != CurrentVersion)
            {
                return;
            }

            var teamById    = Teams.ToDictionary(t => t.Id);
            var repoByName  = Repos.ToDictionary(r => r.Name);
            var userByLogin = Users.ToDictionary(u => u.Login);

            foreach (var repo in Repos)
            {
                repo.Org = this;
            }

            foreach (var team in Teams)
            {
                team.Org = this;

                if (!string.IsNullOrEmpty(team.ParentId) && teamById.TryGetValue(team.ParentId, out var parentTeam))
                {
                    team.Parent = parentTeam;
                    parentTeam.Children.Add(team);
                }

                foreach (var maintainerLogin in team.MaintainerLogins)
                {
                    if (userByLogin.TryGetValue(maintainerLogin, out var maintainer))
                    {
                        team.Maintainers.Add(maintainer);
                    }
                }

                foreach (var memberLogin in team.MemberLogins)
                {
                    if (userByLogin.TryGetValue(memberLogin, out var member))
                    {
                        team.Members.Add(member);
                        member.Teams.Add(team);
                    }
                }

                foreach (var repoAccess in team.Repos)
                {
                    repoAccess.Team = team;

                    if (repoByName.TryGetValue(repoAccess.RepoName, out var repo))
                    {
                        repoAccess.Repo = repo;
                        repo.Teams.Add(repoAccess);
                    }
                }

                team.Repos.RemoveAll(r => r.Repo == null);
            }

            foreach (var collaborator in Collaborators)
            {
                if (repoByName.TryGetValue(collaborator.RepoName, out var repo))
                {
                    collaborator.Repo = repo;
                    repo.Users.Add(collaborator);
                }

                if (userByLogin.TryGetValue(collaborator.UserLogin, out var user))
                {
                    collaborator.User = user;
                    user.Repos.Add(collaborator);
                }
            }

            Collaborators.RemoveAll(c => c.Repo == null || c.User == null);

            foreach (var user in Users)
            {
                user.Org = this;
            }
        }
Ejemplo n.º 20
0
 public Task Load(bool forceDataRefresh)
 {
     return(Collaborators.SimpleCollectionLoad(Application.Client.Users[Username].Repositories[Repository].GetCollaborators(), forceDataRefresh));
 }
Ejemplo n.º 21
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() + Collaborators.GetHashCode());
 }
        public async Task <IActionResult> CreateAppoinment([Bind("Customer,Gender,Address,Phone,Email,Job,WorkPlace,Cmnd,Day,Place,Money,Purpose,Requires,Price,Details,DType,Cash,NCH1,NCH2,NCH21,NCH3,NMS,NS,NSHH,NSH,HKTT,password,Contract,supporter")] Appoinment appoinment)
        {
            //if (ModelState.IsValid)
            //{
            var colls = await _context.Collaborators.ToListAsync();

            if (colls == null)
            {
                return(NotFound());
            }
            _colls = colls;
            foreach (Collaborators coll in colls)
            {
                if (coll.password == appoinment.password)
                {
                    TempData["name"]       = coll.fullName;
                    appoinment.sale        = coll.email;
                    appoinment.SaleDetails = coll.office;
                    break;
                }
            }
            string str = "";

            if (appoinment.sale == null)
            {
                return(View());
            }
            if (!Check(appoinment.sale, appoinment.password))
            {
                return(View());
            }
            else
            {
                //var recaptcha = await _recaptcha.Validate(Request);
                //if (!recaptcha.success)
                //{
                //    ModelState.AddModelError("Recaptcha", "There was an error validating recatpcha. Please try again!");
                //    return View();
                //}
                List <Appoinment> appoinments = await _context.appoinment.ToListAsync();

                if (appoinments.Count > 0)
                {
                    appoinment.Contract = _context.appoinment.Max(c => c.Contract) + 1;
                    if (appoinment.NCH1 > 0 || appoinment.NCH2 > 0 || appoinment.NCH3 > 0 || appoinment.NCH21 > 0)
                    {
                        appoinment.ph = _context.appoinment.Max(c => c.ph) + appoinment.NCH2 + appoinment.NCH1 + appoinment.NCH3 + appoinment.NCH21;
                        str          += "Căn hộ: " + Convert.ToString(appoinment.ph) + "\n";
                    }
                    if (appoinment.NSH > 0)
                    {
                        appoinment.psh = _context.appoinment.Max(c => c.psh) + appoinment.NSH;
                        str           += "Nhà phố: " + Convert.ToString(appoinment.psh) + "\n";
                    }
                    if (appoinment.NSHH > 0)
                    {
                        appoinment.pshh = _context.appoinment.Max(c => c.pshh) + appoinment.NSHH;
                        str            += "Shophouse: " + Convert.ToString(appoinment.pshh) + "\n";
                    }
                    if (appoinment.NMS > 0)
                    {
                        appoinment.pms = _context.appoinment.Max(c => c.pms) + appoinment.NMS;
                        str           += "Biệt thự: " + Convert.ToString(appoinment.pms) + "\n";
                    }
                    if (appoinment.NS > 0)
                    {
                        appoinment.pns = _context.appoinment.Max(c => c.pns) + appoinment.NS;
                        str           += "Shop (kios chung cư): " + Convert.ToString(appoinment.pns) + "\n";
                    }
                }
                else
                {
                    Random rd = new Random();
                    appoinment.Contract = rd.Next(100, 151);
                    if (appoinment.NCH1 > 0 || appoinment.NCH2 > 0 || appoinment.NCH3 > 0 || appoinment.NCH21 > 0)
                    {
                        appoinment.ph = rd.Next(100, 151);
                        str          += "Căn hộ: " + Convert.ToString(appoinment.ph) + "\n";
                    }
                    if (appoinment.NSH > 0)
                    {
                        appoinment.psh = rd.Next(100, 151);
                        str           += "Nhà phố: " + Convert.ToString(appoinment.psh) + "\n";
                    }
                    if (appoinment.NSHH > 0)
                    {
                        appoinment.pshh = rd.Next(100, 151);
                        str            += "Shophouse: " + Convert.ToString(appoinment.pshh) + "\n";
                    }
                    if (appoinment.NMS > 0)
                    {
                        appoinment.pms = rd.Next(100, 151);
                        str           += "Biệt thự: " + Convert.ToString(appoinment.pms) + "\n";
                    }
                }
                appoinment.IsActive = true;
                appoinment.New      = true;
                appoinment.Official = false;
                appoinment.cTime    = DateTime.Now.ToString("ddMMyyyy HH:mm:ss.FFFFFFF");
                appoinment.Confirm  = false;
                var customers = await _context.Customers.Where(c => c.CollaboratorsID == coll.ID).ToListAsync();

                foreach (var c in customers)
                {
                    if (c.phone == appoinment.Phone)
                    {
                        if (appoinment.supporter)
                        {
                            c.charges = 1.0;
                        }
                        else
                        {
                            c.charges = 1.3;
                        }
                        break;
                    }
                }
                _context.Add(appoinment);
                AppModal modal = new AppModal();
                modal.appoinment = appoinment;
                Collaborators co = _colls.Find(x => x.email == appoinment.sale);
                modal.collaborator = co;
                await _context.SaveChangesAsync();

                TempData["ct"] = appoinment.Contract;
                TempData["pt"] = str;
                return(View("Confirm", modal));
            }
            //}
            //return NotFound();
        }