public JsonSonuc projeSurecAktiflestir(string url) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); LoggedUserModel lgm = GetCurrentUser.GetUser(); proje_surec ps = db.proje_surec.Where(e => e.url.Equals(url)).FirstOrDefault(); if (ps == null) { return(JsonSonuc.sonucUret(false, "Proje/Süreç bulunamadı.")); } ps.durum = TamamlamaDurumlari.basladi; List <gorev_proje> projeGorevList = db.gorev_proje.Where(e => e.proje_id == ps.id && e.flag == durumlar.aktif && e.gorevler.flag == durumlar.aktif).ToList(); foreach (gorev_proje gp in projeGorevList) { gp.gorevler.durum = TamamlamaDurumlari.basladi; db.Entry(gp).State = EntityState.Modified; } db.Entry(ps).State = EntityState.Modified; db.SaveChanges(); } catch (Exception) { return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz.")); } return(JsonSonuc.sonucUret(true, "Proje/Süreç durumu güncellendi.")); }
public async Task <ActionResult> SurecBilgisi(string id) { List <object> nesneler = new List <object>(); var p = db.proje_surec.Where(e => e.flag != durumlar.silindi && e.url.Equals(id) && e.tur == ProjeSurecTur.surec).FirstOrDefaultAsync(); var fl = db.firma_musavir.Where(e => e.flag != durumlar.silindi).ToListAsync(); GorevlerController hc = new GorevlerController(); var grvl = hc.GorevleriGetir(id); await Task.WhenAll(p, fl, grvl); ViewResult grvResult = (ViewResult)grvl.Result; List <GorevVeProjeOzetModel> gorevList = (List <GorevVeProjeOzetModel>)(grvResult.Model); proje_surec prj = p.Result; if (prj == null) { prj = new proje_surec(); prj.baslangic_tarihi = DateTime.Now; prj.bitis_tarihi = DateTime.Now.AddMonths(1); } List <firma_musavir> firmaList = fl.Result; vrlfgysdbEntities db2 = new vrlfgysdbEntities(); var ml = db2.musteriler.Where(e => e.flag == durumlar.aktif && e.firma_id == prj.firma_id).ToListAsync(); /*vrlfgysdbEntities db3 = new vrlfgysdbEntities(); * var kl = db3.kullanicilar.Where(e => e.flag == durumlar.aktif && e.firma_id == prj.firma_id).ToListAsync();*/ var pm = db.proje_musteri.Where(e => e.proje_id == prj.id && e.flag == durumlar.aktif).FirstOrDefaultAsync(); //await Task.WhenAll(ml, kl, pm); await Task.WhenAll(ml, pm); List <musteriler> musteriList = ml.Result; proje_musteri pmust = pm.Result; if (pmust == null) { pmust = new proje_musteri(); } //List<kullanicilar> kullaniciList = kl.Result; nesneler.Add(prj); nesneler.Add(musteriList); nesneler.Add(pmust); //nesneler.Add(kullaniciList); nesneler.Add(firmaList); nesneler.Add(gorevList); return(View(nesneler)); }
public JsonSonuc projeYuzdesiDuzenle(int proje_id) { try { LoggedUserModel lgm = GetCurrentUser.GetUser(); vrlfgysdbEntities db = new vrlfgysdbEntities(); proje_surec prj = db.proje_surec.Where(e => e.id == proje_id).FirstOrDefault(); List <gorev_proje> projeGorevList = db.gorev_proje.Where(e => e.proje_id == proje_id && e.flag == durumlar.aktif).ToList(); int toplam = 0; int aktifGorevler = 0; foreach (gorev_proje pg in projeGorevList) { if (pg.gorevler.flag == durumlar.aktif) { toplam += pg.gorevler.yuzde; aktifGorevler++; } } if (aktifGorevler != 0) { prj.yuzde = toplam / aktifGorevler; } else { prj.yuzde = toplam; } prj.durum = TamamlamaDurumlari.basladi; db.Entry(prj).State = EntityState.Modified; db.SaveChanges(); if (prj.yuzde == 100) { List <kullanicilar> yetkiliList = db.kullanicilar.Where(e => e.flag == durumlar.aktif && e.firma_id == lgm.firma_id && e.kullanici_turu <= KullaniciTurleri.firma_yetkili).ToList(); foreach (kullanicilar usr in yetkiliList) { bildirimIslemleri.yeniBildirim(usr.id, BildirimTurleri.proje, prj.id, "", prj.isim + " isimli proje tamamlandı ve onayınızı bekliyor."); } } return(JsonSonuc.sonucUret(true, prj.yuzde)); } catch (Exception e) { return(JsonSonuc.sonucUret(false, "Proje yüzdesini düzenlerken bir hata oluştu.")); } }
public JsonSonuc silProje(string url, int firma_id) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); proje_surec prj = null; if (firma_id != 0) { prj = db.proje_surec.Where(e => e.url.Equals(url) && e.firma_id == firma_id).FirstOrDefault(); } else { prj = db.proje_surec.Where(e => e.url.Equals(url)).FirstOrDefault(); } if (prj == null) { return(JsonSonuc.sonucUret(false, "Proje bulunamadı.")); } //prj.flag = durumlar.silindi; prj.durum = TamamlamaDurumlari.pasif; db.Entry(prj).State = EntityState.Modified; db.SaveChanges(); List <gorev_proje> projeGorevList = db.gorev_proje.Where(e => e.flag == durumlar.aktif && e.proje_id == prj.id).ToList(); gorevIslemleri gis = new gorevIslemleri(); foreach (gorev_proje gp in projeGorevList) { if (gp.gorevler != null) { //gis.silGorev(gp.gorevler.url); gp.gorevler.durum = TamamlamaDurumlari.pasif; db.Entry(gp.gorevler).State = EntityState.Modified; } } db.SaveChanges(); } catch (Exception) { return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz.")); } return(JsonSonuc.sonucUret(true, "Proje pasif edildi.")); }
public string projeDuzenle(string url, int firma_id, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); proje_surec dbPrj = db.proje_surec.Where(e => e.url.Equals(url) && e.flag != durumlar.silindi).FirstOrDefault(); if (dbPrj == null || url == null || url.Equals("")) { return(yeniProje(firma_id, Request)); } else if (!(dbPrj.flag != durumlar.silindi)) { return(""); } string urlTemp = dbPrj.url; foreach (var property in dbPrj.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null) { if (response == null) { continue; } } else { PropertyInfo propertyS = dbPrj.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(dbPrj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else { propertyS.SetValue(dbPrj, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } dbPrj.url = urlTemp; string isimControl = "select * from proje_surec where id != " + dbPrj.id.ToString() + " and tur = " + ProjeSurecTur.proje + " and flag != " + durumlar.silindi.ToString() + " and isim = '" + dbPrj.isim + "' and firma_id = " + dbPrj.firma_id; ProjeSurecModel isimKontrolPs = db.Database.SqlQuery <ProjeSurecModel>(isimControl).FirstOrDefault(); if (isimKontrolPs != null) { return("proje_isim_hatasi"); } bool kullaniciKontrol = firmaProjeKontrol(dbPrj.firma_id, dbPrj.id).Result; if (!kullaniciKontrol) { return("proje_sayisi_hatasi"); } db.Entry(dbPrj).State = EntityState.Modified; db.SaveChanges(); /*#region proje_musteri * int musteri_id = Convert.ToInt32(Request["musteri_id"].ToString()); * if (musteri_id != 0) * { * proje_surec dbPs = db.proje_surec.Where(e => e.vid == dbPrj.vid).FirstOrDefault(); * proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault(); * if (pm == null) * { * pm = new proje_musteri(); * pm.date = DateTime.Now; * pm.flag = durumlar.aktif; * pm.musteri_id = musteri_id; * pm.proje_id = dbPs.id; * int vidPm = 1; * if (db.proje_musteri.Count() != 0) * { * vidPm = db.proje_musteri.Max(e => e.vid) + 1; * } * int sortPm = 1; * if (db.proje_musteri.Count() != 0) * { * sortPm = db.proje_musteri.Max(e => e.sort) + 1; * } * pm.sort = sortPm; * pm.vid = vidPm; * db.proje_musteri.Add(pm); * db.SaveChanges(); * } * else if (pm != null && pm.musteri_id != musteri_id) * { * pm.musteri_id = musteri_id; * db.Entry(pm).State = EntityState.Modified; * db.SaveChanges(); * } * } * else if (musteri_id == 0) * { * proje_surec dbPs = db.proje_surec.Where(e => e.vid == dbPrj.vid).FirstOrDefault(); * proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault(); * if (pm != null) * { * pm.flag = durumlar.silindi; * db.Entry(pm).State = EntityState.Modified; * db.SaveChanges(); * } * } #endregion proje_musteri*/ return(dbPrj.url); } catch (Exception e) { return(""); } }
public string yeniProje(int firma_id, HttpRequestBase Request) { try { vrlfgysdbEntities db = new vrlfgysdbEntities(); int vid = 1; if (db.proje_surec.Count() != 0) { vid = db.proje_surec.Max(e => e.vid) + 1; } int sort = 1; if (db.proje_surec.Count() != 0) { sort = db.proje_surec.Max(e => e.sort) + 1; } proje_surec prj = new proje_surec(); foreach (var property in prj.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null && property.PropertyType != typeof(int)) { if (response == null) { continue; } } else { PropertyInfo propertyS = prj.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(prj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else if (property.PropertyType == typeof(int)) { if (response == null) { propertyS.SetValue(prj, Convert.ChangeType(0, property.PropertyType), null); } else { propertyS.SetValue(prj, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } } else { propertyS.SetValue(prj, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } string strImageName = StringFormatter.OnlyEnglishChar(prj.isim); string createdUrl = strImageName; string tempUrl = createdUrl; bool bulundu = false; int i = 0; proje_surec pg = new proje_surec(); do { pg = db.proje_surec.Where(e => e.url.Equals(tempUrl)).FirstOrDefault(); if (pg != null) { tempUrl = tempUrl + i.ToString(); } else { createdUrl = tempUrl; bulundu = true; } i++; } while (!bulundu); prj.url = createdUrl; prj.firma_id = firma_id; prj.flag = durumlar.aktif; prj.date = DateTime.Now; prj.vid = vid; prj.ekleyen = GetCurrentUser.GetUser().id; prj.sort = sort; //prj.donem_sayisi = 0; prj.parent_vid = 0; prj.durum = TamamlamaDurumlari.bekliyor; //prj.periyot_suresi = 0; prj.periyot_turu = 0; prj.mevcut_donem = 0; prj.tur = ProjeSurecTur.proje; prj.tamamlanma_tarihi = DateTime.Now; string isimControl = "select * from proje_surec where tur = " + ProjeSurecTur.proje + " and flag != " + durumlar.silindi.ToString() + " and isim = '" + prj.isim + "' and firma_id = " + prj.firma_id; ProjeSurecModel isimKontrolPs = db.Database.SqlQuery <ProjeSurecModel>(isimControl).FirstOrDefault(); if (isimKontrolPs != null) { return("proje_isim_hatasi"); } bool kullaniciKontrol = firmaProjeKontrol(prj.firma_id, prj.id).Result; if (!kullaniciKontrol) { return("proje_sayisi_hatasi"); } db.proje_surec.Add(prj); db.SaveChanges(); /*int musteri_id = Convert.ToInt32(Request["musteri_id"].ToString()); * if (musteri_id != 0) * { * proje_surec dbPs = db.proje_surec.Where(e => e.vid == prj.vid).FirstOrDefault(); * proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault(); * if (pm == null) * { * pm = new proje_musteri(); * pm.date = DateTime.Now; * pm.flag = durumlar.aktif; * pm.musteri_id = musteri_id; * pm.proje_id = dbPs.id; * int vidPm = 1; * if (db.proje_musteri.Count() != 0) * { * vidPm = db.proje_musteri.Max(e => e.vid) + 1; * } * int sortPm = 1; * if (db.proje_musteri.Count() != 0) * { * sortPm = db.proje_musteri.Max(e => e.sort) + 1; * } * pm.sort = sortPm; * pm.vid = vidPm; * db.proje_musteri.Add(pm); * db.SaveChanges(); * } * else if (pm != null && pm.musteri_id != musteri_id) * { * pm.musteri_id = musteri_id; * db.Entry(pm).State = EntityState.Modified; * db.SaveChanges(); * } * } * else if (musteri_id == 0) * { * proje_surec dbPs = db.proje_surec.Where(e => e.vid == prj.vid).FirstOrDefault(); * proje_musteri pm = db.proje_musteri.Where(e => e.flag == durumlar.aktif && e.proje_id == dbPs.id).FirstOrDefault(); if (pm != null && pm.musteri_id != musteri_id) * if (pm != null) * { * pm.flag = durumlar.silindi; * db.Entry(pm).State = EntityState.Modified; * db.SaveChanges(); * } * }*/ return(prj.url); } catch (Exception e) { return(""); } }
public JsonSonuc yeniProjeKullanicisi(HttpRequestBase Request) { try { LoggedUserModel lgm = GetCurrentUser.GetUser(); vrlfgysdbEntities db = new vrlfgysdbEntities(); int vid = 1; if (db.kullanici_proje.Count() != 0) { vid = db.kullanici_proje.Max(e => e.vid) + 1; } int sort = 1; if (db.kullanici_proje.Count() != 0) { sort = db.kullanici_proje.Max(e => e.sort) + 1; } kullanici_proje kp = new kullanici_proje(); foreach (var property in kp.GetType().GetProperties()) { try { var response = Request[property.Name]; if (response == null && property.PropertyType != typeof(int)) { if (response == null) { continue; } } else { PropertyInfo propertyS = kp.GetType().GetProperty(property.Name); if (property.PropertyType == typeof(decimal)) { propertyS.SetValue(kp, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } else if (property.PropertyType == typeof(int)) { if (response == null) { propertyS.SetValue(kp, Convert.ChangeType(0, property.PropertyType), null); } else { propertyS.SetValue(kp, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null); } } else { propertyS.SetValue(kp, Convert.ChangeType(response, property.PropertyType), null); } } } catch (Exception) { } } kp.flag = durumlar.aktif; kp.date = DateTime.Now; kp.vid = vid; kp.sort = sort; kp.ekleyen = lgm.id; kullanici_proje dbKp = db.kullanici_proje.Where(e => e.flag == durumlar.aktif && e.proje_id == kp.proje_id && e.kullanici_id == kp.kullanici_id).FirstOrDefault(); if (dbKp != null) { return(JsonSonuc.sonucUret(true, "Kullanıcı Eklendi.")); } db.kullanici_proje.Add(kp); db.SaveChanges(); proje_surec ps = db.proje_surec.Where(e => e.id == kp.proje_id).FirstOrDefault(); if (ps != null) { if (ps.tur == ProjeSurecTur.proje) { bildirimIslemleri.yeniBildirim(kp.kullanici_id, BildirimTurleri.proje, kp.proje_id, ps.url, ps.isim + " isimli proje ilgilenmeniz için size yönlendirildi. Yönlendiren yetkili " + lgm.ad + " " + lgm.soyad + "."); } else if (ps.tur == ProjeSurecTur.surec) { bildirimIslemleri.yeniBildirim(kp.kullanici_id, BildirimTurleri.surec, kp.proje_id, ps.url, ps.isim + " isimli süreç ilgilenmeniz için size yönlendirildi. Yönlendiren yetkili " + lgm.ad + " " + lgm.soyad + "."); } } return(JsonSonuc.sonucUret(true, "Kullanıcı Eklendi.")); } catch (Exception e) { return(JsonSonuc.sonucUret(false, "İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz.")); } }