Exemple #1
0
        public override IEnumerable <EmailLogViewModel> Bind(int?index, int pageSize = 50, params object[] param)
        {
            DateTime data1            = param.Count() > 0 && param[0] != null ? (DateTime)param[0] : new DateTime(1980, 1, 1);
            DateTime data2            = param.Count() > 1 && param[1] != null ? (DateTime)param[1] : Funcoes.Brasilia().Date.AddDays(30);
            string   EdificacaoID     = "";
            string   GrupoCondominoID = "";
            string   IsHome           = "N";

            if (param.Count() > 2)
            {
                IsHome = "S";
                if (param[2] != null)
                {
                    int[] GrupoCondomino = (int[])param[2];
                    for (int i = 0; i <= GrupoCondomino.Count() - 1; i++)
                    {
                        GrupoCondominoID += GrupoCondominoID[i].ToString() + ";";
                    }
                }

                if (param[3] != null)
                {
                    IEnumerable <Unidade> Unidades = (IEnumerable <Unidade>)param[3];
                    foreach (var unidade in Unidades)
                    {
                        EdificacaoID += unidade.EdificacaoID + ";";
                    }
                }
            }

            IEnumerable <EmailLogViewModel> foldase = (from info in db.EmailLogs
                                                       join gru in db.GrupoCondominos on info.GrupoCondominoID equals gru.GrupoCondominoID into GRU
                                                       from gru in GRU.DefaultIfEmpty()
                                                       join edi in db.Edificacaos on info.EdificacaoID equals edi.EdificacaoID into EDI
                                                       from edi in EDI.DefaultIfEmpty()
                                                       join eti in db.EmailTipos on info.EmailTipoID equals eti.EmailTipoID
                                                       where info.DataEmail >= data1 && info.DataEmail <= data2 &&
                                                       info.CondominioID == SessaoLocal.empresaId &&
                                                       (IsHome == "N" || info.DataEmail >= SqlFunctions.GetDate()) &&
                                                       (GrupoCondominoID == "" || GrupoCondominoID.Contains(info.GrupoCondominoID.ToString())) &&
                                                       (EdificacaoID == "" || EdificacaoID.Contains(info.EdificacaoID.ToString())) &&
                                                       (eti.CondominioID == SessaoLocal.empresaId)
                                                       orderby info.DataEmail descending
                                                       select new EmailLogViewModel
            {
                empresaId = sessaoCorrente.empresaId,
                EmailLogID = info.EmailLogID,
                CondominioID = info.CondominioID,
                EdificacaoID = info.EdificacaoID,
                Descricao_Edificacao = edi.Descricao,
                GrupoCondominoID = gru.GrupoCondominoID,
                Descricao_GrupoCondomino = gru.Descricao,
                DataEmail = info.DataEmail,
                Assunto = info.Assunto,
                EmailMensagem = info.EmailMensagem,
                EmailTipoID = info.EmailTipoID,
                UnidadeID = info.UnidadeID,
                sessionId = sessaoCorrente.sessaoId,
                Descricao_EmailTipo = eti.Descricao,
            }).ToList();

            int contador = 0;

            foreach (EmailLogViewModel log in foldase)
            {
                if (log.UnidadeID.HasValue)
                {
                    foldase.ElementAt(contador).Codigo = db.Unidades.Find(log.CondominioID, log.EdificacaoID, log.UnidadeID).Codigo;
                }
                contador++;
            }

            return(foldase);
        }
Exemple #2
0
        public ActionResult CreateContent(CreateContentViewModel viewModel)
        {
            viewModel.Languages = _context
                                  .Languages
                                  .Select(language => new SelectListItem {
                Text  = language.Definition,
                Value = SqlFunctions.StringConvert((double?)language.LanguageId).Trim()
            })
                                  .ToList();
            viewModel.ContentCategories = _context
                                          .ContentCategories
                                          .Select(category => new SelectListItem {
                Text  = category.Definition,
                Value = SqlFunctions.StringConvert((double?)category.ContentCategoryId).Trim()
            })
                                          .ToList();

            if (string.IsNullOrWhiteSpace(viewModel.Description))
            {
                ViewBag.Result        = false;
                ViewBag.ResultMessage = "Lütfen açıklama giriniz!";
                return(PartialView("_NewContent", viewModel));
            }

            var fileName = string.Empty;

            if (viewModel.PostedFile != null)
            {
                //...
                // Check File Size
                if (viewModel.PostedFile.ContentLength > 10 * 1024 * 1024)
                {
                    ViewBag.Result        = false;
                    ViewBag.ResultMessage = "Dosya boyutu max 10 MB olabilir!";
                    return(PartialView("_NewContent", viewModel));
                }

                //...
                // Check file extensions
                if (!_allowedFileExtensions.Contains(new FileInfo(viewModel.PostedFile.FileName).Extension.ToUpper()))
                {
                    ViewBag.Result        = false;
                    ViewBag.ResultMessage = "Bu dosya formatı desteklenmiyor, lütfen resim veya video dosyası ekleyiniz!";
                    return(PartialView("_NewContent", viewModel));
                }

                //...
                // Get Keyword Definition
                var keyword = _context.Keywords.FirstOrDefault(p => p.KeywordId == viewModel.KeywordId);
                if (keyword != null)
                {
                    fileName = SaveUploadedFile(HttpContext.ApplicationInstance.Context, keyword.KeywordId, keyword.Definition);
                    if (string.IsNullOrWhiteSpace(fileName))
                    {
                        ViewBag.Result        = false;
                        ViewBag.ResultMessage = "Dosya yüklenirken hata oluştu, lütfen daha sonra tekrar deneyiniz!";
                        return(PartialView("_NewContent", viewModel));
                    }
                }
                else
                {
                    ViewBag.Result        = false;
                    ViewBag.ResultMessage = "başlık bilgisi bulunamadı, lütfen daha sonra tekrar deneyiniz!";
                    return(PartialView("_NewContent", viewModel));
                }
            }

            try {
                var contentModel = new Content {
                    KeywordId         = viewModel.KeywordId,
                    LanguageId        = viewModel.LanguageId,
                    ContentCategoryId = viewModel.ContentCategoryId,
                    Url          = string.IsNullOrWhiteSpace(fileName) ? string.Empty : UploadFilePath + "/" + fileName,
                    Description  = viewModel.Description,
                    ContentType  = ContentType.FileUpload,
                    CreateUserId = WebSecurity.CurrentUserId,
                    Approved     = true,
                    LikeCount    = 0,
                    DislikeCount = 0,
                    Complaint    = 0,
                    CreateDate   = DateTime.Now
                };

                _context.Contents.Add(contentModel);
                _context.SaveChanges();

                ViewBag.Result        = true;
                ViewBag.ResultMessage = "Girdiğiniz bilgiler kaydedilmiştir!";
                return(PartialView("_NewContent", viewModel));
            }
            catch (Exception exception) {
                throw new Exception("Error in ContentController.CreateContent [Post]", exception);
            }
        }
Exemple #3
0
 /// <summary>
 /// 作業区分Combo用リスト取得
 /// </summary>
 /// <param name="eigyoushoCode"></param>
 /// <returns></returns>
 public List <M72_TNT_SELECT> Get_UserList()
 {
     using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString()))
     {
         var combolist = (from x in context.M72_TNT
                          where x.削除日時 == null
                          select new M72_TNT_SELECT
         {
             担当者ID = x.担当者ID,
             担当者表示区分 = x.担当者名 == null ? SqlFunctions.StringConvert((decimal)x.担当者ID, 8) : SqlFunctions.StringConvert((decimal)x.担当者ID, 8) + " " + x.担当者名,
             担当者名 = x.担当者名,
         }
                          ).ToList();
         if (combolist.Where(q => q.担当者ID != 99999).Any())
         {
             //初期ユーザが存在すれば削除
             if (combolist.Where(q => q.担当者ID == 99999).Any())
             {
                 combolist.RemoveAll(q => q.担当者ID == 99999);
             }
         }
         return(combolist.ToList());
     }
 }
Exemple #4
0
 public void RefreshRow(int NumOfMatchups)
 {
     deleteDailySummary();
     //                            TableName     ColNames (csv)     DTO                     Insert into DTO Method
     SqlFunctions.DALInsertRow(DailySummaryTable, ColumnNames, populateDTO(NumOfMatchups), populateoDailySummaryValuesForInsert, _ConnectionString);
 }
Exemple #5
0
 public CandidatesService()
 {
     _sf = new SqlFunctions();
 }
        public static object GetManJender()
        {
            DataTable DTJender = SqlFunctions.GetData("select genderid,gender from mangender");

            return(DTJender);
        }
Exemple #7
0
        //找單一USER
        public object SearchUser(string userID)
        {
            var User = practiceEntities.Members.Where(x => x.Account.Contains(userID))
                       .Select(x => new {
                Account  = x.Account,
                Password = x.Password,
                Name     = x.Name,
                Phone    = x.Phone,
                Tel      = x.Tel,
                Gender   = x.Gender,
                Birthday = SqlFunctions.DateName("year", x.Birthday) + "/" + x.Birthday.Value.Month + "/" + SqlFunctions.DateName("day", x.Birthday)
            })
                       .ToList();

            return(User);
        }
Exemple #8
0
        public static DataTable GetMerchIDs(String SupplierID, String isQuarterlyData)
        {
            DataTable DT = SqlFunctions.GetData(" Select Distinct(Merchid),merchandising from vSupplierContacts_Quaterly_suppliers where QuarterlyData=" + isQuarterlyData + " and Supplierid=" + SupplierID);

            return(DT);
        }
Exemple #9
0
        public JsonResult DataTable(int length, int start)
        {
            var e = _eventService.Table.AsQueryable();

            var query = HttpContext.Request.Params["search[value]"];

            if (!string.IsNullOrEmpty(query))
            {
                e = e.Where(x => x.Name.Contains(query) || x.Details.Contains(query));
            }

            #region Sort Column and Direction

            /*
             *  Sort column is (zero) index based and determined on the front end. Please reference the javascript if incorrect columns are being sorted.
             */
            var sortColumn = Convert.ToInt32(HttpContext.Request.Params["order[0][column]"]);
            var sortDir    = HttpContext.Request.Params["order[0][dir]"];

            switch (sortColumn)
            {
            case 0:
                if (sortDir == "desc")
                {
                    e = e.OrderByDescending(ob => ob.ID);
                }
                else
                {
                    e = e.OrderBy(ob => ob.ID);
                }
                break;

            case 1:
                if (sortDir == "desc")
                {
                    e = e.OrderByDescending(ob => ob.Name);
                }
                else
                {
                    e = e.OrderBy(ob => ob.Name);
                }
                break;

            case 3:
                if (sortDir == "desc")
                {
                    e = e.OrderByDescending(ob => ob.EndDate);
                }
                else
                {
                    e = e.OrderBy(ob => ob.EndDate);
                }
                break;

            case 2:
            default:
                if (sortDir == "desc")
                {
                    e = e.OrderByDescending(ob => ob.StartDate);
                }
                else
                {
                    e = e.OrderBy(ob => ob.StartDate);
                }
                break;
            }
            #endregion

            var response = new
            {
                iTotalRecords        = e.Count(),
                iTotalDisplayRecords = e.Count(),
                d = e.Select(x => new EventDataViewModel
                {
                    Id          = x.ID,
                    Name        = x.Name,
                    EndDate     = SqlFunctions.DatePart("mm", x.EndDate) + "/" + SqlFunctions.DatePart("dd", x.EndDate) + "/" + SqlFunctions.DatePart("yyyy", x.EndDate),
                    StartDate   = SqlFunctions.DatePart("mm", x.StartDate) + "/" + SqlFunctions.DatePart("dd", x.StartDate) + "/" + SqlFunctions.DatePart("yyyy", x.StartDate),
                    IsPublished = x.IsPublished
                })
                    .Skip(start)
                    .Take(length)
                    .ToList()
            };



            return(Json(response));
        }
        private List <Task> GetSeachResult(string search, HaberAramaModel model)
        {
            db.Configuration.LazyLoadingEnabled = false;

            List <Task> Tasks    = new List <Task>();
            var         taskNews = Task.Factory.StartNew(() =>
            {
                using (Entities dbContext = new Entities())
                {
                    model.Haberler = dbContext.Haberler.Where(ur => ur.Ad.Contains(search) && ur.Aktif == true).ToList();
                    if (model.Haberler.Count < 1)
                    {
                        try
                        {
                            var urun = db.Haberler.Where(k => SqlFunctions.SoundCode(k.Ad) == SqlFunctions.SoundCode(search) && k.Aktif == true).Select(k => new { k.Ad }).FirstOrDefault();

                            if (urun != null)
                            {
                                model.DidYouMean = urun.Ad;
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            });

            Tasks.Add(taskNews);


            return(Tasks);
        }
Exemple #11
0
        public static DataTable GetSuppliers(String isQuarterlyData)
        {
            DataTable DT = SqlFunctions.GetData("Select Distinct(SupplierID),Name from vSupplierContacts_Quaterly_suppliers where QuarterlyData=" + isQuarterlyData + " order by Name");

            return(DT);
        }
        private List <Task> AramaSonucGetir(string search, AramaModel model)
        {
            db.Configuration.LazyLoadingEnabled = false;
            List <Task> Tasks        = new List <Task>();
            var         taskCustomer = Task.Factory.StartNew(() =>
            {
                using (Entities dbContext = new Entities())
                {
                    model.Kurumlar = dbContext.Kurumlar.Include("Kategoriler").Where(ur => ur.KurumAdi.Contains(search) && ur.Durum == true).Take(10).ToList();
                    if (model.Kurumlar.Count < 1)
                    {
                        try
                        {
                            var urun = db.Kurumlar.Where(k => SqlFunctions.SoundCode(k.KurumAdi) == SqlFunctions.SoundCode(search) && k.Durum == true).Select(k => new { k.KurumAdi }).FirstOrDefault();

                            if (urun != null)
                            {
                                model.DidYouMean = urun.KurumAdi;
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            });

            Tasks.Add(taskCustomer);
            var taskSupplier = Task.Factory.StartNew(() =>
            {
                using (Entities dbContext = new Entities())
                {
                    model.Kategoriler = dbContext.Kategoriler.Where(k => k.KategoriAdi.Contains(search) && k.Aktif == true).ToList();

                    if (model.Kategoriler.Count < 1)
                    {
                        try
                        {
                            var kat = db.Kategoriler.Where(k => SqlFunctions.SoundCode(k.KategoriAdi) == SqlFunctions.SoundCode(search) && k.Aktif == true).Select(k => new { k.KategoriAdi }).FirstOrDefault();

                            if (kat != null)
                            {
                                model.DidYouMean = kat.KategoriAdi;
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            });

            Tasks.Add(taskSupplier);

            return(Tasks);
        }
        public List <V_HR_AttendTimeOriginalWithName> Select(string date, string name)
        {
            DateTime?keyDate = null;
            DateTime dateTime;

            if (DateTime.TryParse(date, out dateTime))
            {
                keyDate = dateTime;
            }
            using (Entities db = new Entities())
            {
                string fitformat = string.Format("%{0}%", name == null ? "" : name.Trim());
                return(db.V_HR_AttendTimeOriginalWithName.Where(l => (EntityFunctions.DiffDays(keyDate, l.AttendTime) ?? 0) == 0 &&
                                                                (SqlFunctions.PatIndex(fitformat, l.Name) > 0 || SqlFunctions.PatIndex(fitformat, l.UserId) > 0)).ToList());
            }
        }
Exemple #14
0
        public void AutoConfirm()
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                long   stateId = dbc.GetId <IdNameEntity>(i => i.Name == "已完成");
                string val     = dbc.GetParameter <SettingEntity>(s => s.Name == "自动确认收货时间", s => s.Param);
                double day;
                double.TryParse(val, out day);
                if (day == 0)
                {
                    day = 7;
                }
                //Expression<Func<OrderEntity, bool>> timewhere = r => r.ConsignTime == null ? false : r.ConsignTime.Value.AddDays(Convert.ToDouble(val)) < DateTime.Now;
                //var orders = dbc.GetAll<OrderEntity>().Where(r => r.OrderState.Name == "已发货").Where(timewhere.Compile()).ToList();
                var orders = dbc.GetAll <OrderEntity>().AsNoTracking().Where(r => r.OrderState.Name == "已发货").Where(r => SqlFunctions.DateAdd("day", day, r.ConsignTime) < DateTime.Now);
                foreach (OrderEntity order in orders)
                {
                    order.EndTime      = DateTime.Now;
                    order.OrderStateId = stateId;
                }
                val = dbc.GetParameter <SettingEntity>(s => s.Name == "不能退货时间", s => s.Param);
                double.TryParse(val, out day);
                if (day == 0)
                {
                    day = 3;
                }
                var           orders1    = dbc.GetAll <OrderEntity>().Where(r => r.CloseTime == null).Where(r => r.OrderState.Name == "已完成" || r.OrderState.Name == "退货审核").Where(r => SqlFunctions.DateAdd("day", day, r.EndTime) < DateTime.Now);
                List <string> orderCodes = new List <string>();
                foreach (OrderEntity order in orders1)
                {
                    order.OrderStateId = stateId;
                    order.CloseTime    = DateTime.Now;
                    orderCodes.Add(order.Code);
                }
                var journals = dbc.GetAll <JournalEntity>().AsNoTracking().Where(j => orderCodes.Contains(j.OrderCode) && j.JournalTypeId == 1 && j.IsEnabled == false);
                Dictionary <long, long> dicts = new Dictionary <long, long>();
                foreach (JournalEntity journal in journals)
                {
                    dicts.Add(journal.Id, journal.UserId);
                }
                foreach (var dict in dicts)
                {
                    var           user    = dbc.GetAll <UserEntity>().SingleOrDefault(u => u.Id == dict.Value);
                    JournalEntity journal = dbc.GetAll <JournalEntity>().SingleOrDefault(j => j.Id == dict.Key);
                    user.Amount           = user.Amount + journal.InAmount.Value;
                    user.FrozenAmount     = user.FrozenAmount - journal.InAmount.Value;
                    user.BonusAmount      = user.BonusAmount + journal.InAmount.Value;
                    journal.BalanceAmount = user.Amount;
                    journal.IsEnabled     = true;
                }

                dbc.SaveChanges();
            }
        }
Exemple #15
0
        public static DataTable GetStoreidsBy_Date_Region_Cluster(String RegionID, String year, String Monthid)
        {
            DataTable DT = SqlFunctions.GetData("SELECT STOREID,sum(Sales) As SALES FROM vsales WHERE [year] = " + year + " AND monthid=" + Monthid + " AND (SALES>0) AND RegionID=" + RegionID + " AND sourceid=1 Group by storeid order by storeid");

            return(DT);
        }
Exemple #16
0
        public List <PhysicianBillingByShiftViewModel> GetRecordsForBilling(List <string> physicians, DateTime startdate, DateTime enddate, List <PhysicianBillingByShiftViewModel> scheduleList, List <int> caseStatus,
                                                                            ShiftType shiftType)
        {
            //enddate = enddate.AddDays(1);
            List <@case> list = new List <@case>();

            foreach (var item in physicians)
            {
                var obj = db.cases.Where(x => x.cas_phy_key == item &&
                                         (x.cas_billing_bic_key == 1 || x.cas_billing_bic_key == 2) && x.cas_billing_bic_key != null &&
                                         DbFunctions.TruncateTime(startdate) <= DbFunctions.TruncateTime(x.cas_physician_assign_date) && DbFunctions.TruncateTime(x.cas_physician_assign_date) <= DbFunctions.TruncateTime(enddate) && x.cas_billing_physician_blast == false && x.cas_cst_key == 20).ToList();
                list.AddRange(obj);
            }
            List <PhysicianBillingByShiftViewModel> onShiftCasesList = null;
            var onShiftQuery = (from c in _unitOfWork.CaseRepository.Query()
                                join s in _unitOfWork.ScheduleRepository.Query() on c.cas_phy_key equals s.uss_user_id
                                join u in _unitOfWork.UserRepository.Query() on c.cas_phy_key equals u.Id
                                let time_from_calc = SqlFunctions.DateAdd("hh", -2, s.uss_time_from_calc)
                                                     let time_to_calc = SqlFunctions.DateAdd("hh", 2, s.uss_time_to_calc)
                                                                        where c.cas_phy_key != null && (c.cas_billing_bic_key == 1 || c.cas_billing_bic_key == 2) &&
                                                                        c.cas_physician_assign_date != null &&
                                                                        c.cas_billing_bic_key != null &&
                                                                        c.cas_cst_key == 20 &&
                                                                        c.cas_billing_physician_blast == false &&
                                                                        time_from_calc <= c.cas_physician_assign_date &&
                                                                        time_to_calc >= c.cas_physician_assign_date &&
                                                                        DbFunctions.TruncateTime(c.cas_physician_assign_date) >= DbFunctions.TruncateTime(startdate) &&
                                                                        DbFunctions.TruncateTime(c.cas_physician_assign_date) <= DbFunctions.TruncateTime(enddate)
                                                                        orderby(c.cas_phy_key)
                                                                        select new { c, s, u });

            if (physicians != null)
            {
                onShiftQuery = onShiftQuery.Where(x => physicians.Contains(x.c.cas_phy_key));
            }
            if (caseStatus != null)
            {
                onShiftQuery = onShiftQuery.Where(x => caseStatus.Contains(x.c.cas_cst_key));
            }
            onShiftCasesList = (from onShiftModel in onShiftQuery
                                group
                                new { onShiftModel.c, onShiftModel.s } by
                                new
            {
                AssignDate = DBHelper.FormatDateTime(DbFunctions.TruncateTime(onShiftModel.s.uss_date).Value, false),
                Schedule = DbFunctions.Right("00" + SqlFunctions.DateName("hour", onShiftModel.s.uss_time_from_calc.Value), 2)
                           + ":"
                           + DbFunctions.Right("00" + SqlFunctions.DateName("minute", onShiftModel.s.uss_time_from_calc.Value), 2)
                           + " - "
                           + DbFunctions.Right("00" + SqlFunctions.DateName("hour", onShiftModel.s.uss_time_to_calc.Value), 2)
                           + ":"
                           + DbFunctions.Right("00" + SqlFunctions.DateName("minute", onShiftModel.s.uss_time_to_calc.Value), 2),
                Physician = onShiftModel.u.LastName + " " + onShiftModel.u.FirstName,
                PhysicianKey = onShiftModel.c.cas_phy_key,
                uss_time_from_calc = onShiftModel.s.uss_time_from_calc.Value,
                uss_time_to_calc = onShiftModel.s.uss_time_to_calc.Value,
                assign_date = (DateTime)onShiftModel.c.cas_physician_assign_date
            } into g
                                select new PhysicianBillingByShiftViewModel
            {
                AssignDate = g.Key.AssignDate,
                assign_date = (DateTime)g.Key.assign_date,
                Schedule = g.Key.Schedule,
                Physician = g.Key.Physician,
                PhysicianKey = g.Key.PhysicianKey,
                Open = g.Sum(x => x.c.cas_cst_key == (int)CaseStatus.Open ? 1 : 0),
                WaitingToAccept = g.Sum(x => x.c.cas_cst_key == (int)CaseStatus.WaitingToAccept ? 1 : 0),
                Accepted = g.Sum(x => x.c.cas_cst_key == (int)CaseStatus.Accepted ? 1 : 0),
                Complete = g.Sum(x => x.c.cas_cst_key == (int)CaseStatus.Complete ? 1 : 0),
                CC1_StrokeAlert = g.Sum(x => x.c.cas_billing_bic_key == 1 ? 1 : 0),
                CC1_STAT = g.Sum(x => x.c.cas_billing_bic_key == 2 ? 1 : 0),
                New = g.Sum(x => x.c.cas_billing_bic_key == 3 ? 1 : 0),
                FU = g.Sum(x => x.c.cas_billing_bic_key == 4 ? 1 : 0),
                EEG = g.Sum(x => x.c.cas_billing_bic_key == 5 ? 1 : 0),
                LTM_EEG = g.Sum(x => x.c.cas_billing_bic_key == 6 ? 1 : 0),
                TC = g.Sum(x => x.c.cas_billing_bic_key == 7 ? 1 : 0),
                Not_Seen = g.Sum(x => x.c.cas_billing_bic_key == 8 ? 1 : 0),
                Blast = g.Sum(x => x.c.cas_billing_physician_blast ? 1 : 0),
                Total = g.Sum(x => x.c.cas_key > 0 ? 1 : 0),
                time_from_calc = g.Key.uss_time_from_calc,
                time_to_calc = g.Key.uss_time_to_calc
            }).ToList();
            HashSet <string> _listids = new HashSet <string>(list.Select(s => s.cas_physician_assign_date.ToString()));
            HashSet <string> _caseids = new HashSet <string>(onShiftCasesList.Select(s => s.assign_date.ToString()));
            var          newM         = _listids.Except(_caseids).ToList();
            List <@case> difference   = new List <@case>();

            foreach (var item in newM)
            {
                var getR = list.Where(x => x.cas_physician_assign_date.ToString() == item).FirstOrDefault();
                difference.Add(getR);
            }
            foreach (var item in difference)
            {
                PhysicianBillingByShiftViewModel obj = new PhysicianBillingByShiftViewModel();
                DateTime dt = (DateTime)item.cas_physician_assign_date;
                obj.AssignDate = dt.ToString("M/d/yyy");//DBHelper.FormatDateTime(DbFunctions.TruncateTime(dt).Value, false);//dt.ToString("MM/dd/yyyy");
                var isExist = scheduleList.Where(x => x.AssignDate == obj.AssignDate && x.PhysicianKey == item.cas_phy_key).FirstOrDefault();
                if (isExist != null)
                {
                    obj.Schedule = isExist.Schedule;
                }
                else
                {
                    obj.Schedule = "Off (" + dt.ToString("hh:mm tt") + ")";
                }
                var _name = _unitOfWork.ApplicationUsers.Where(x => x.Id == item.cas_phy_key).FirstOrDefault();
                obj.Physician       = _name.LastName + " " + _name.FirstName;
                obj.PhysicianKey    = item.cas_phy_key;
                obj.Open            = item.cas_cst_key == (int)CaseStatus.Open ? 1 : 0;
                obj.WaitingToAccept = item.cas_cst_key == (int)CaseStatus.WaitingToAccept ? 1 : 0;
                obj.Accepted        = item.cas_cst_key == (int)CaseStatus.Accepted ? 1 : 0;
                obj.Complete        = item.cas_cst_key == (int)CaseStatus.Complete ? 1 : 0;
                obj.CC1_StrokeAlert = item.cas_billing_bic_key == 1 ? 1 : 0;
                obj.CC1_STAT        = item.cas_billing_bic_key == 2 ? 1 : 0;
                obj.New             = item.cas_billing_bic_key == 3 ? 1 : 0;
                obj.FU       = item.cas_billing_bic_key == 4 ? 1 : 0;
                obj.EEG      = item.cas_billing_bic_key == 5 ? 1 : 0;
                obj.LTM_EEG  = item.cas_billing_bic_key == 6 ? 1 : 0;
                obj.TC       = item.cas_billing_bic_key == 7 ? 1 : 0;
                obj.Not_Seen = item.cas_billing_bic_key == 8 ? 1 : 0;
                obj.Blast    = item.cas_billing_physician_blast ? 1 : 0;
                obj.Total    = item.cas_key > 0 ? 1 : 0;
                scheduleList.Add(obj);
            }

            #region Testing on shift

            /* can be open  after testing
             *
             * onShiftCasesList = (from onShiftModel in difference
             *                  join s in user_Schedules on onShiftModel.cas_phy_key equals s.uss_user_id
             *                  join u in userList on onShiftModel.cas_phy_key equals u.Id
             *                  group
             *                      new { onShiftModel } by
             *                          new
             *                          {
             *                              AssignDate = DBHelper.FormatDateTime(DbFunctions.TruncateTime(s.uss_date).Value, false),
             *                              Schedule = DbFunctions.Right("00" + SqlFunctions.DateName("hour", s.uss_time_from_calc.Value), 2)
             + ":"
             + DbFunctions.Right("00" + SqlFunctions.DateName("minute", s.uss_time_from_calc.Value), 2)
             + " - "
             + DbFunctions.Right("00" + SqlFunctions.DateName("hour", s.uss_time_to_calc.Value), 2)
             + ":"
             + DbFunctions.Right("00" + SqlFunctions.DateName("minute", s.uss_time_to_calc.Value), 2),
             +                              Physician = u.LastName + " " + u.FirstName,
             +                              PhysicianKey = onShiftModel.cas_phy_key,
             +                              uss_time_from_calc = s.uss_time_from_calc.Value,
             +                              uss_time_to_calc = s.uss_time_to_calc.Value,
             +                              assign_date = onShiftModel.cas_physician_assign_date
             +                          } into g
             +                  select new PhysicianBillingByShiftViewModel
             +                  {
             +                      AssignDate = g.Key.AssignDate,
             +                      assign_date = (DateTime)g.Key.assign_date,
             +                      Schedule = g.Key.Schedule,
             +                      Physician = g.Key.Physician,
             +                      PhysicianKey = g.Key.PhysicianKey,
             +                      Open = g.Sum(x => x.onShiftModel.cas_cst_key == (int)CaseStatus.Open ? 1 : 0),
             +                      WaitingToAccept = g.Sum(x => x.onShiftModel.cas_cst_key == (int)CaseStatus.WaitingToAccept ? 1 : 0),
             +                      Accepted = g.Sum(x => x.onShiftModel.cas_cst_key == (int)CaseStatus.Accepted ? 1 : 0),
             +                      Complete = g.Sum(x => x.onShiftModel.cas_cst_key == (int)CaseStatus.Complete ? 1 : 0),
             +                      CC1_StrokeAlert = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 1 ? 1 : 0),
             +                      CC1_STAT = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 2 ? 1 : 0),
             +                      New = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 3 ? 1 : 0),
             +                      FU = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 4 ? 1 : 0),
             +                      EEG = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 5 ? 1 : 0),
             +                      LTM_EEG = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 6 ? 1 : 0),
             +                      TC = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 7 ? 1 : 0),
             +                      Not_Seen = g.Sum(x => x.onShiftModel.cas_billing_bic_key == 8 ? 1 : 0),
             +                      Blast = g.Sum(x => x.onShiftModel.cas_billing_physician_blast ? 1 : 0),
             +                      Total = g.Sum(x => x.onShiftModel.cas_key > 0 ? 1 : 0),
             +                  }).ToList();
             +
             */

            #endregion
            return(scheduleList);
        }
Exemple #17
0
        public static DataTable GetSalesBy_Cluster_Region_Source_ID_Day_Storeid(string profileid, string regionid, string id_Day_String, string storeId_String)
        {
            DataTable DT = SqlFunctions.GetData("SELECT BARCODE, Description AS PRODUCT,Sizedesc AS SIZE,BRAND,SEGMENT,CATEGORY,sum(sales) AS [SALES 2009] FROM vSales where profileid=" + profileid + " AND RegionID=" + regionid + " AND sourceid=1 AND id_DAY in(" + id_Day_String + ") AND STOREID in(" + storeId_String + ") Group by Barcode,description,sizedesc,brand,segment,category order by [SALES 2009] desc");

            return(DT);
        }
        /// <summary>
        /// Gets the summary data.
        /// </summary>
        private void GetSummaryData()
        {
            SummaryState = new List <ConnectionTypeSummary>();

            var rockContext   = new RockContext();
            var opportunities = new ConnectionOpportunityService(rockContext)
                                .Queryable().AsNoTracking();

            var typeFilter = GetAttributeValue("ConnectionTypes").SplitDelimitedValues().AsGuidList();

            if (typeFilter.Any())
            {
                opportunities = opportunities.Where(o => typeFilter.Contains(o.ConnectionType.Guid));
            }

            // Loop through opportunities
            foreach (var opportunity in opportunities)
            {
                // Check to see if person can view the opportunity because of admin rights to this block or admin rights to
                // the opportunity
                bool canView = UserCanAdministrate || opportunity.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
                bool campusSpecificConnector = false;
                var  campusIds = new List <int>();

                if (CurrentPersonId.HasValue)
                {
                    // Check to see if person belongs to any connector group that is not campus specific
                    if (!canView)
                    {
                        canView = opportunity
                                  .ConnectionOpportunityConnectorGroups
                                  .Any(g =>
                                       !g.CampusId.HasValue &&
                                       g.ConnectorGroup != null &&
                                       g.ConnectorGroup.Members.Any(m => m.PersonId == CurrentPersonId.Value));
                    }

                    // If user is not yet authorized to view the opportunity, check to see if they are a member of one of the
                    // campus-specific connector groups for the opportunity, and note the campus
                    if (!canView)
                    {
                        foreach (var groupCampus in opportunity
                                 .ConnectionOpportunityConnectorGroups
                                 .Where(g =>
                                        g.CampusId.HasValue &&
                                        g.ConnectorGroup != null &&
                                        g.ConnectorGroup.Members.Any(m => m.PersonId == CurrentPersonId.Value)))
                        {
                            campusSpecificConnector = true;
                            canView = true;
                            campusIds.Add(groupCampus.CampusId.Value);
                        }
                    }
                }

                // Is user is authorized to view this opportunity type...
                if (canView)
                {
                    // Check if the opportunity's type has been added to summary yet, and if not, add it
                    var connectionTypeSummary = SummaryState.Where(c => c.Id == opportunity.ConnectionTypeId).FirstOrDefault();
                    if (connectionTypeSummary == null)
                    {
                        connectionTypeSummary = new ConnectionTypeSummary
                        {
                            Id            = opportunity.ConnectionTypeId,
                            Name          = opportunity.ConnectionType.Name,
                            Opportunities = new List <OpportunitySummary>()
                        };
                        SummaryState.Add(connectionTypeSummary);
                    }

                    // Count number of idle requests (no activity in past X days)

                    var connectionRequestsQry = new ConnectionRequestService(rockContext).Queryable().Where(a => a.ConnectionOpportunityId == opportunity.Id);
                    var currentDateTime       = RockDateTime.Now;
                    int idleCount             = connectionRequestsQry
                                                .Where(cr =>
                                                       (
                                                           cr.ConnectionState == ConnectionState.Active ||
                                                           (cr.ConnectionState == ConnectionState.FutureFollowUp && cr.FollowupDate.HasValue && cr.FollowupDate.Value < _midnightToday)
                                                       ) &&
                                                       (
                                                           (cr.ConnectionRequestActivities.Any() && cr.ConnectionRequestActivities.Max(ra => ra.CreatedDateTime) < SqlFunctions.DateAdd("day", -cr.ConnectionOpportunity.ConnectionType.DaysUntilRequestIdle, currentDateTime))) ||
                                                       (!cr.ConnectionRequestActivities.Any() && cr.CreatedDateTime < SqlFunctions.DateAdd("day", -cr.ConnectionOpportunity.ConnectionType.DaysUntilRequestIdle, currentDateTime))
                                                       )
                                                .Count();

                    // Count the number requests that have a status that is considered critical.
                    int criticalCount = connectionRequestsQry
                                        .Where(r =>
                                               r.ConnectionStatus.IsCritical &&
                                               (
                                                   r.ConnectionState == ConnectionState.Active ||
                                                   (r.ConnectionState == ConnectionState.FutureFollowUp && r.FollowupDate.HasValue && r.FollowupDate.Value < _midnightToday)
                                               )
                                               )
                                        .Count();

                    // Add the opportunity
                    var opportunitySummary = new OpportunitySummary
                    {
                        Id            = opportunity.Id,
                        Name          = opportunity.Name,
                        IconCssClass  = opportunity.IconCssClass,
                        IdleCount     = idleCount,
                        CriticalCount = criticalCount
                    };

                    // If the user is limited requests with specific campus(es) set the list, otherwise leave it to be null
                    opportunitySummary.CampusSpecificConnector = campusSpecificConnector;
                    opportunitySummary.ConnectorCampusIds      = campusIds.Distinct().ToList();

                    connectionTypeSummary.Opportunities.Add(opportunitySummary);
                }
            }

            // Get a list of all the authorized opportunity ids
            var allOpportunities = SummaryState.SelectMany(s => s.Opportunities).Select(o => o.Id).Distinct().ToList();

            // Get all the active and past-due future followup request ids, and include the campus id and personid of connector
            var midnightToday  = RockDateTime.Today.AddDays(1);
            var activeRequests = new ConnectionRequestService(rockContext)
                                 .Queryable().AsNoTracking()
                                 .Where(r =>
                                        allOpportunities.Contains(r.ConnectionOpportunityId) &&
                                        (r.ConnectionState == ConnectionState.Active ||
                                         (r.ConnectionState == ConnectionState.FutureFollowUp && r.FollowupDate.HasValue && r.FollowupDate.Value < midnightToday)))
                                 .Select(r => new
            {
                r.ConnectionOpportunityId,
                r.CampusId,
                ConnectorPersonId = r.ConnectorPersonAlias != null ? r.ConnectorPersonAlias.PersonId : -1
            })
                                 .ToList();

            // Based on the active requests, set additional properties for each opportunity
            foreach (var opportunity in SummaryState.SelectMany(s => s.Opportunities))
            {
                // Get the active requests for this opportunity that user is authorized to view (based on campus connector)
                var opportunityRequests = activeRequests
                                          .Where(r =>
                                                 r.ConnectionOpportunityId == opportunity.Id &&
                                                 (
                                                     !opportunity.CampusSpecificConnector ||
                                                     (r.CampusId.HasValue && opportunity.ConnectorCampusIds.Contains(r.CampusId.Value))
                                                 ))
                                          .ToList();

                // The count of active requests assigned to the current person
                opportunity.AssignedToYou = opportunityRequests.Count(r => r.ConnectorPersonId == CurrentPersonId);

                // The count of active requests that are unassigned
                opportunity.UnassignedCount = opportunityRequests.Count(r => r.ConnectorPersonId == -1);

                // Flag indicating if current user is connector for any of the active types
                opportunity.HasActiveRequestsForConnector = opportunityRequests.Any(r => r.ConnectorPersonId == CurrentPersonId);
            }

            //Set the Idle tooltip
            var           connectionTypes = opportunities.Where(o => allOpportunities.Contains(o.Id)).Select(o => o.ConnectionType).Distinct().ToList();
            StringBuilder sb = new StringBuilder();

            if (connectionTypes.Select(t => t.DaysUntilRequestIdle).Distinct().Count() == 1)
            {
                sb.Append(String.Format("Idle (no activity in {0} days)", connectionTypes.Select(t => t.DaysUntilRequestIdle).Distinct().First()));
            }
            else
            {
                sb.Append("Idle (no activity in several days)<br/><ul class='list-unstyled'>");
                foreach (var connectionType in connectionTypes)
                {
                    sb.Append(String.Format("<li>{0}: {1} days</li>", connectionType.Name, connectionType.DaysUntilRequestIdle));
                }
                sb.Append("</ul>");
            }

            var statusTemplate    = this.GetAttributeValue("StatusTemplate");
            var statusMergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage);

            statusMergeFields.Add("ConnectionOpportunities", allOpportunities);
            statusMergeFields.Add("ConnectionTypes", connectionTypes);
            statusMergeFields.Add("IdleTooltip", sb.ToString());
            lStatusBarContent.Text = statusTemplate.ResolveMergeFields(statusMergeFields);
            BindSummaryData();
        }
Exemple #19
0
        public ActionResult SubmitCreate(Clan clan, HttpPostedFileBase image, HttpPostedFileBase bgimage, bool noFaction = false)
        {
            //using (var scope = new TransactionScope())
            //{
            ZkDataContext db      = new ZkDataContext();
            bool          created = clan.ClanID == 0; // existing clan vs creation

            //return Content(noFaction ? "true":"false");
            if (noFaction)
            {
                clan.FactionID = null;
            }

            Faction new_faction = db.Factions.SingleOrDefault(x => x.FactionID == clan.FactionID);

            if ((new_faction != null) && new_faction.IsDeleted)
            {
                return(Content("Cannot create clans in deleted factions"));
            }

            if (string.IsNullOrEmpty(clan.ClanName) || string.IsNullOrEmpty(clan.Shortcut))
            {
                return(Content("Name and shortcut cannot be empty!"));
            }
            if (!ZkData.Clan.IsShortcutValid(clan.Shortcut))
            {
                return(Content("Shortcut must have at least 1 characters and contain only numbers and letters"));
            }

            if (created && (image == null || image.ContentLength == 0))
            {
                return(Content("A clan image is required"));
            }

            Clan orgClan = null;

            if (!created)
            {
                if (!Global.Account.HasClanRight(x => x.RightEditTexts) || clan.ClanID != Global.Account.ClanID)
                {
                    return(Content("Unauthorized"));
                }

                // check if our name or shortcut conflicts with existing clans
                var existingClans = db.Clans.Where(x => ((SqlFunctions.PatIndex(clan.Shortcut, x.Shortcut) > 0 || SqlFunctions.PatIndex(clan.ClanName, x.ClanName) > 0) && x.ClanID != clan.ClanID));
                if (existingClans.Count() > 0)
                {
                    if (existingClans.Any(x => !x.IsDeleted))
                    {
                        return(Content("Clan with this shortcut or name already exists"));
                    }
                }

                orgClan             = db.Clans.Single(x => x.ClanID == clan.ClanID);
                orgClan.ClanName    = clan.ClanName;
                orgClan.Shortcut    = clan.Shortcut;
                orgClan.Description = clan.Description;
                orgClan.SecretTopic = clan.SecretTopic;
                orgClan.Password    = clan.Password;

                if (image != null && image.ContentLength > 0)
                {
                    var im = Image.FromStream(image.InputStream);
                    if (im.Width != 64 || im.Height != 64)
                    {
                        im = im.GetResized(64, 64, InterpolationMode.HighQualityBicubic);
                    }
                    im.Save(Server.MapPath(orgClan.GetImageUrl()));
                }
                if (bgimage != null && bgimage.ContentLength > 0)
                {
                    var im = Image.FromStream(bgimage.InputStream);
                    im.Save(Server.MapPath(orgClan.GetBGImageUrl()));
                }

                if (clan.FactionID != orgClan.FactionID)
                {
                    // set factions of members
                    Faction oldFaction = orgClan.Faction;
                    orgClan.FactionID = clan.FactionID;
                    foreach (Account member in orgClan.Accounts)
                    {
                        if (member.FactionID != clan.FactionID && member.FactionID != null)
                        {
                            FactionsController.PerformLeaveFaction(member.AccountID, true, db);
                        }
                        member.FactionID = clan.FactionID;
                    }
                    db.SubmitChanges(); // make sure event gets correct details
                    if (clan.FactionID != null)
                    {
                        db.Events.InsertOnSubmit(Global.CreateEvent("Clan {0} moved to faction {1}", orgClan, orgClan.Faction));
                    }
                    else
                    {
                        db.Events.InsertOnSubmit(Global.CreateEvent("Clan {0} left faction {1}", orgClan, oldFaction));
                    }
                }
                db.SubmitChanges();
            }
            else
            {
                if (Global.Clan != null)
                {
                    return(Content("You already have a clan"));
                }
                // should just change their faction for them?
                if (Global.FactionID != 0 && Global.FactionID != clan.FactionID)
                {
                    return(Content("Clan must belong to same faction you are in"));
                }

                // check if our name or shortcut conflicts with existing clans
                // if so, allow us to create a new clan over it if it's a deleted clan, else block action
                var existingClans = db.Clans.Where(x => ((SqlFunctions.PatIndex(clan.Shortcut, x.Shortcut) > 0 || SqlFunctions.PatIndex(clan.ClanName, x.ClanName) > 0) && x.ClanID != clan.ClanID));
                if (existingClans.Count() > 0)
                {
                    if (existingClans.Any(x => !x.IsDeleted))
                    {
                        return(Content("Clan with this shortcut or name already exists"));
                    }
                    Clan deadClan = existingClans.First();
                    clan = deadClan;
                    if (noFaction)
                    {
                        clan.FactionID = null;
                    }
                }
                else
                {
                    db.Clans.InsertOnSubmit(clan);
                }

                var acc = db.Accounts.Single(x => x.AccountID == Global.AccountID);
                acc.ClanID = clan.ClanID;

                // we created a new clan, set self as founder and rights
                var leader = db.RoleTypes.FirstOrDefault(x => x.RightKickPeople && x.IsClanOnly);
                if (leader != null)
                {
                    db.AccountRoles.InsertOnSubmit(new AccountRole()
                    {
                        AccountID    = acc.AccountID,
                        Clan         = clan,
                        RoleType     = leader,
                        Inauguration = DateTime.UtcNow
                    });
                }

                db.SubmitChanges(); // needed to get clan id for images

                if (image != null && image.ContentLength > 0)
                {
                    var im = Image.FromStream(image.InputStream);
                    if (im.Width != 64 || im.Height != 64)
                    {
                        im = im.GetResized(64, 64, InterpolationMode.HighQualityBicubic);
                    }
                    im.Save(Server.MapPath(clan.GetImageUrl()));
                }
                if (bgimage != null && bgimage.ContentLength > 0)
                {
                    var im = Image.FromStream(bgimage.InputStream);
                    im.Save(Server.MapPath(clan.GetBGImageUrl()));
                }

                db.Events.InsertOnSubmit(Global.CreateEvent("New clan {0} formed by {1}", clan, acc));
                db.SubmitChanges();
            }

            //scope.Complete();
            Global.Server.ChannelManager.AddClanChannel(clan);;
            Global.Server.SetTopic(clan.GetClanChannel(), clan.SecretTopic, Global.Account.Name);
            //}
            return(RedirectToAction("Detail", new { id = clan.ClanID }));
        }
Exemple #20
0
        public IQueryable <JobReturnHeaderViewModel> GetJobReturnHeaderListPendingToReview(int id, string Uname)
        {
            List <string> UserRoles      = (List <string>)System.Web.HttpContext.Current.Session["Roles"];
            var           JobOrderHeader = GetJobReturnHeaderList(id, Uname).AsQueryable();

            var PendingToReview = from p in JobOrderHeader
                                  where p.Status == (int)StatusConstants.Submitted && (SqlFunctions.CharIndex(Uname, (p.ReviewBy ?? "")) == 0)
                                  select p;

            return(PendingToReview);
        }
Exemple #21
0
        //找所有USER
        public object AllUser()
        {
            var User = practiceEntities.Members.Select(x => new {
                Account  = x.Account,
                Password = x.Password,
                Name     = x.Name,
                Phone    = x.Phone,
                Tel      = x.Tel,
                Gender   = x.Gender,
                Birthday = SqlFunctions.DateName("year", x.Birthday) + "/" + x.Birthday.Value.Month + "/" + SqlFunctions.DateName("day", x.Birthday)
                           // ,Idx = index + 1
            }).ToList();
            var result = User.AsEnumerable()
                         .Select((x, index) => new
            {
                Account  = x.Account,
                Password = x.Password,
                Name     = x.Name,
                Phone    = x.Phone,
                Tel      = x.Tel,
                Gender   = x.Gender,
                Birthday = x.Birthday,
                Idx      = index + 1
            }).ToList();

            return(User);
        }
        private static void MissionList(SmrReports me, ExcelPackage package, NameValueCollection entries)
        {
            var sheet = package.Workbook.Worksheets[1];

            int year;

            if (!int.TryParse(entries["year"], out year))
            {
                year = DateTime.Now.AddMonths(-2).Year;
            }

            DateTime start = new DateTime(year, 1, 1);
            DateTime stop  = new DateTime(year + 1, 1, 1);

            IQueryable <MissionRoster> rosters = GetMissionRostersQuery(me, start, stop);

            MissionInfo[] missions = GetMissions(rosters);

            var stats = rosters.GroupBy(f => f.Mission.Id)
                        .Select(f => new
            {
                Id      = f.Key,
                Persons = f.Select(g => g.Person.Id).Distinct().Count(),
                Hours   = f.Sum(g => SqlFunctions.DateDiff("minute", g.TimeIn, g.TimeOut) / 60.0),
                Miles   = f.Sum(g => g.Miles)
            })
                        .ToDictionary(f => f.Id, f => f);

            var total = rosters
                        .GroupBy(f => 1)
                        .Select(f => new
            {
                Persons = f.Select(g => g.Person.Id).Distinct().Count(),
                Hours   = f.Sum(g => SqlFunctions.DateDiff("minute", g.TimeIn, g.TimeOut) / 60.0),
                Miles   = f.Sum(g => g.Miles)
            })
                        .Single();

            sheet.Cells[1, 1].Value += string.Format(" ({0})", year);

            for (int i = 0; i < missions.Length; i++)
            {
                var col = 1;
                var row = i + 4;
                sheet.Cells[row, col++].Value = missions[i].StartTime;
                sheet.Cells[row, col++].Value = missions[i].StateNumber;
                sheet.Cells[row, col++].Value = string.Format("{0}{1}", missions[i].Title, (missions[i].MissionType ?? string.Empty).Contains("turnaround") ? " (Turnaround)" : string.Empty);
                sheet.Cells[row, col++].Value = stats[missions[i].Id].Persons;
                sheet.Cells[row, col++].Value = stats[missions[i].Id].Hours;
                sheet.Cells[row, col++].Value = stats[missions[i].Id].Miles;
            }
            sheet.Row(missions.Length + 4).Style.Border.Top.Style = ExcelBorderStyle.Thin;
            sheet.Row(missions.Length + 4).Style.Border.Top.Color.SetColor(System.Drawing.Color.FromArgb(0, 76, 154));
            sheet.Row(missions.Length + 4).Style.Font.Color.SetColor(System.Drawing.Color.FromArgb(0, 76, 154));
            sheet.Row(missions.Length + 4).Style.Font.Bold = true;
            sheet.Cells[missions.Length + 4, 3].Value      = "Total Missions = " + missions.Length;
            sheet.Cells[missions.Length + 4, 4].Value      = total.Persons;
            sheet.Cells[missions.Length + 4, 5].Value      = total.Hours;
            sheet.Cells[missions.Length + 4, 6].Value      = total.Miles;
            sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
        }
Exemple #23
0
 private void deleteDailySummary()
 {
     string strSql = $"DELETE From {DailySummaryTable} Where LeagueName = '{_oLeagueDTO.LeagueName}' AND GameDate = '{_GameDate.ToShortDateString()}'";
     int    rows   = SysDAL.DALfunctions.ExecuteSqlNonQuery(SqlFunctions.GetConnectionString(), strSql);
 }
Exemple #24
0
        public List <V_GM_DetailProject> GetProjectByParams(string keyWord)
        {
            string fitformat = string.Format("%{0}%", keyWord ?? "");

            return(_entities.V_GM_DetailProject.Where(l => SqlFunctions.PatIndex(fitformat, l.ClientName) > 0 || SqlFunctions.PatIndex(fitformat, l.ProjectName) > 0).ToList());
        }
        public ProductionTaskQuery Withfilter(IEnumerable <filterRule> filters)
        {
            if (filters != null)
            {
                foreach (var rule in filters)
                {
                    if (rule.field == "Id" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.Id == val);
                    }



                    if (rule.field == "OrderKey" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.OrderKey.Contains(rule.value));
                    }



                    if (rule.field == "SKUId" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.SKUId == val);
                    }



                    if (rule.field == "DesignName" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.DesignName.Contains(rule.value));
                    }



                    if (rule.field == "ComponentSKU" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.ComponentSKU.Contains(rule.value));
                    }



                    if (rule.field == "ALTSku" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.ALTSku.Contains(rule.value));
                    }



                    if (rule.field == "GraphSKU" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.GraphSKU.Contains(rule.value));
                    }



                    if (rule.field == "ProductionQty" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.ProductionQty == val);
                    }



                    if (rule.field == "ProcessName" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.ProcessName.Contains(rule.value));
                    }



                    if (rule.field == "ProcessOrder" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.ProcessOrder == val);
                    }



                    if (rule.field == "ProcessSetp" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.ProcessSetp.Contains(rule.value));
                    }



                    if (rule.field == "AltElapsedTime" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.AltElapsedTime == val);
                    }



                    if (rule.field == "ProductionLine" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.ProductionLine.Contains(rule.value));
                    }



                    if (rule.field == "Equipment" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.Equipment.Contains(rule.value));
                    }



                    if (rule.field == "OrderPlanDate" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.OrderPlanDate) >= 0);
                    }


                    if (rule.field == "Owner" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.Owner.Contains(rule.value));
                    }



                    if (rule.field == "PlanStartDateTime" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.PlanStartDateTime) >= 0);
                    }



                    if (rule.field == "PlanCompletedDateTime" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.PlanCompletedDateTime) >= 0);
                    }



                    if (rule.field == "ActualStartDateTime" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.ActualStartDateTime) >= 0);
                    }



                    if (rule.field == "ActualCompletedDateTime" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.ActualCompletedDateTime) >= 0);
                    }



                    if (rule.field == "ActualElapsedTime" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.ActualElapsedTime == val);
                    }



                    if (rule.field == "Status" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.Status == val);
                    }



                    if (rule.field == "Issue" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.Issue.Contains(rule.value));
                    }



                    if (rule.field == "Remark" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.Remark.Contains(rule.value));
                    }



                    if (rule.field == "OrderId" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.OrderId == val);
                    }
                }
            }
            return(this);
        }
Exemple #26
0
        public static DataTable GetTopsGenericReportData(string regionid, string dateFrom1, string dateTo1, string formattedCategories, string formattedStoreID)
        {
            DataTable DTGenericResults = SqlFunctions.GetData("select store,geography,region,city,format,storetype,type,profile,source,barcode,description,uos,unit,sizedesc,casepack,discontinued,merchandising_group,Merchandising,sparid,productclass,category,department,segment,family,base,manufacturer,brand,height,width,depth,sales,units,id_day,costofsales,profit,currentprice,currentcost from vsales where regionid=" + regionid + " and storeid in(" + formattedStoreID + ") and (id_day>=" + dateFrom1 + ") and (id_day<=" + dateTo1 + ") and merchid in (" + formattedCategories + ")");

            return(DTGenericResults);
        }
Exemple #27
0
        public ActionResult CreateKeyword(FormCollection form, KeywordViewModel viewModel)
        {
            try {
                //...
                // Languages
                viewModel.Languages = _context
                                      .Languages
                                      .Select(language => new SelectListItem {
                    Text  = language.Definition,
                    Value = SqlFunctions.StringConvert((double?)language.LanguageId).Trim()
                })
                                      .ToList();

                //...
                // Tags
                viewModel.Tags = _context.Tags.Where(p => p.TagParentId != null).ToList();

                // ...
                // Validations
                if (string.IsNullOrWhiteSpace(viewModel.Definition))
                {
                    ViewBag.Result        = false;
                    ViewBag.ResultMessage = "Lütfen başlık bölümünü doldurunuz!";
                    return(PartialView("_NewKeyword", viewModel));
                }

                if (viewModel.SelectedTags == null)
                {
                    ViewBag.Result        = false;
                    ViewBag.ResultMessage = "Lütfen en az bir etiket seçiniz!";
                    return(PartialView("_NewKeyword", viewModel));
                }

                // Check keyword for existence
                var keywordExists = _context.Keywords.Any(p => p.Definition.ToLower().Equals(viewModel.Definition.ToLower()));

                if (keywordExists)
                {
                    ViewBag.Result        = false;
                    ViewBag.ResultMessage = "Bu başlık daha önceden girilmiş.";
                    return(PartialView("_NewKeyword", viewModel));
                }

                //...
                // Create Keyword
                var keyword = new Keyword {
                    Definition = viewModel.Definition,
                    LanguageId = viewModel.LanguageId,
                    Synonym    = viewModel.Synonym,
                    Antonym    = viewModel.Antonym,
                    //Order = viewModel.Order,
                    Approved     = true,
                    CreateUserId = WebSecurity.CurrentUserId,
                    CreateDate   = DateTime.Now
                };

                _context.Keywords.Add(keyword);
                _context.SaveChanges();

                //...
                // Create Tags for newly created keyword
                foreach (var item in form["SelectedTags"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                {
                    var keywordTag = new KeywordTag {
                        KeywordId  = keyword.KeywordId,
                        TagId      = Convert.ToInt32(item),
                        CreateDate = DateTime.Now
                    };
                    _context.KeywordTags.Add(keywordTag);
                }

                //...
                // Save changes
                _context.SaveChanges();

                ViewBag.Result        = true;
                ViewBag.ResultMessage = "Girdiğiniz içerik başarıyla kaydedilmiştir.";
                return(PartialView("_NewKeyword", viewModel));
            }
            catch (Exception exception) {
                throw new Exception("Error in ContentController.CreateKeyword [Post]", exception);
            }
        }
Exemple #28
0
        public static DataTable ExecuteGenerated_MonthlyDataRun_Query(String Query)
        {
            DataTable DT = SqlFunctions.GetData(Query);

            return(DT);
        }
Exemple #29
0
        //    var range = context.vwInstitutionCroatias.Where(n => n.insName.Contains("brod")).ToList();
        //    Type elementType = Type.GetType("WpfMedaSlovenija.vwInstitutionCroatia");
        //    Type listType = typeof(List<>).MakeGenericType(new Type[] { elementType });
        //    object query4 = Activator.CreateInstance(listType);
        //    listType.InvokeMember("AddRange", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, query4, new object[] { range
        //});
        //                        //PropertyInfo p = listType.GetProperty("AddRange");
        //                        var l = context.vwInstitutionCroatias.ToList();
        ////p.SetValue(query4, range,null);
        //var query1 = new List<vwInstitutionCroatia>();

        ////
        //Type tableType = Type.GetType("WpfMedaSlovenija.MedaEntitiesDb");
        //var tbl = Activator.CreateInstance(tableType);

        ////

        //Type typeContext = Type.GetType("WpfMedaSlovenija");
        //PropertyInfo p = typeContext.GetProperty("vwInstitutionCroatias");
        //var param = System.Linq.Expressions.Expression.Parameter(Type.GetType("WpfMedaSlovenija.vwInstitutionCroatia"));
        //var condition = System.Linq.Expressions.Expression.Lambda<Func<vwInstitutionCroatia, bool>>(
        //               System.Linq.Expressions.Expression.Equal(
        //               System.Linq.Expressions.Expression.Property(param, "insName"),
        //               System.Linq.Expressions.Expression.Constant(s, typeof(string))
        //               ),
        //               param);
        //var condition1 = System.Linq.Expressions.Expression.Lambda<Func<vwInstitutionCroatia, bool>>(
        //    System.Linq.Expressions.Expression.Call(
        //        System.Linq.Expressions.Expression.Constant(s),
        //        typeof(ICollection<Boolean>).GetMethod("Contains"),
        //        System.Linq.Expressions.Expression.Property(param, "insName"))
        //    , param);
        //var item1 = context.vwInstitutionCroatias.Where(condition1);
        //var item = context.vwInstitutionCroatias.SingleOrDefault(condition);


        private void GetSearchResult()
        {
            string textSearch = txtSearch.Text;
            int    counter    = 0;

            using (MedaEntitiesDb context = new MedaEntitiesDb())
            {
                if (String.IsNullOrWhiteSpace(txtSearch.Text))
                {
                    dgInstitution.ItemsSource = null;
                    PopulateDatagrid(Int32.Parse(cmbCountry.SelectedValue.ToString()));
                    return;
                }
                List <vwInstitution> query1 = new List <vwInstitution>();
                if (textSearch.Contains("@"))
                {
                    string[] arraySearch = textSearch.Split('@');
                    foreach (string s in arraySearch)
                    {
                        System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(s);
                        switch (counter)
                        {
                        case 0:

                            if (s.Length > 0)
                            {
                                query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(s, n.insName) > 0).ToList());
                            }
                            break;

                        case 1:
                            if (s.Length > 0)
                            {
                                query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(s, n.ctyName) > 0).ToList());
                            }
                            break;

                        case 2:
                            if (s.Length > 0)
                            {
                                query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(s, n.insAddress) > 0).ToList());
                            }
                            break;

                        case 3:
                            if (s.Length > 0)
                            {
                                query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(s, n.hdoName) > 0).ToList());
                            }
                            break;

                        default:
                            break;
                        }

                        counter++;
                    }
                    dgInstitution.ItemsSource = null;
                    dgInstitution.ItemsSource = query1.ToList();
                }
                else
                {
                    if (textSearch.Length > 0)
                    {
                        query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(txtSearch.Text, n.insName) > 0).ToList());
                        query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(txtSearch.Text, n.ctyName) > 0).ToList());
                        query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(txtSearch.Text, n.insAddress) > 0).ToList());
                        query1.AddRange(context.vwInstitutions.Where(n => n.ctrID == (int)cmbCountry.SelectedValue).Where(n => SqlFunctions.PatIndex(txtSearch.Text, n.hdoName) > 0).ToList());
                        dgInstitution.ItemsSource = null;
                        dgInstitution.ItemsSource = query1.Distinct().ToList();
                    }
                }
            }
        }
Exemple #30
0
        public WorkQuery Withfilter(IEnumerable <filterRule> filters)
        {
            if (filters != null)
            {
                foreach (var rule in filters)
                {
                    if (rule.field == "Id" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.Id == val);
                    }



                    if (rule.field == "WorkNo" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.WorkNo.Contains(rule.value));
                    }



                    if (rule.field == "WorkTypeId" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.WorkTypeId == val);
                    }



                    if (rule.field == "OrderKey" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.OrderKey.Contains(rule.value));
                    }



                    if (rule.field == "OrderId" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.OrderId == val);
                    }



                    if (rule.field == "PO" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.PO.Contains(rule.value));
                    }



                    if (rule.field == "User" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.User.Contains(rule.value));
                    }



                    if (rule.field == "WorkDate" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.WorkDate) >= 0);
                    }



                    if (rule.field == "Status" && !string.IsNullOrEmpty(rule.value))
                    {
                        int val = Convert.ToInt32(rule.value);
                        And(x => x.Status == val);
                    }



                    if (rule.field == "Review" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.Review.Contains(rule.value));
                    }



                    if (rule.field == "ProductionConfirm" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.ProductionConfirm.Contains(rule.value));
                    }



                    if (rule.field == "OutsourceConfirm" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.OutsourceConfirm.Contains(rule.value));
                    }



                    if (rule.field == "AssembleConfirm" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.AssembleConfirm.Contains(rule.value));
                    }



                    if (rule.field == "PurchaseConfirm" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.PurchaseConfirm.Contains(rule.value));
                    }



                    if (rule.field == "ReviewDate" && !string.IsNullOrEmpty(rule.value))
                    {
                        var date = Convert.ToDateTime(rule.value);
                        And(x => SqlFunctions.DateDiff("d", date, x.ReviewDate) >= 0);
                    }


                    if (rule.field == "Remark" && !string.IsNullOrEmpty(rule.value))
                    {
                        And(x => x.Remark.Contains(rule.value));
                    }
                }
            }
            return(this);
        }