示例#1
0
        public static void perform(dynamic objInvoice = null)
        {
            ActivityLogModel objLog       = new ActivityLogModel();
            dynamic          log_invoices = null;

            if (objInvoice != null)
            {
                log_invoices = objLog.where (objLog, "invoice_id='" + objInvoice.id + "'");
            }
            else
            {
                log_invoices = objLog.where (objLog, "model='invoice'");
            }
            if (log_invoices.Count > 0)
            {
                List <string> activites      = new List <string>();
                dynamic       activityObject = new ExpandoObject();
                foreach (var log_invoice in log_invoices)
                {
                    String activity = invoiceData(log_invoice);
                    activites.Add(activity);
                }

                dynamic postData = new ExpandoObject();
                postData.activities = activites;
                string json     = JsonConvert.SerializeObject(postData);
                string response = WebAPI.postRequest("activities/offline_changes", json);
                ActivityLogModel.remove(response);
            }
            else
            {
                Console.WriteLine("Everything sync");
            }
        }
        public virtual ActionResult ActivityLogsList(DataSourceRequest command, ActivityLogModel model, string sort, string sortDir)
        {
            DateTime?startDateValue = (model.CreatedOnFrom == null) ? null
                : (DateTime?)model.CreatedOnFrom.Value;

            DateTime?endDateValue = (model.CreatedOnTo == null) ? null
                            : (DateTime?)model.CreatedOnTo.Value.AddDays(1);

            var items = _dqQueService.GetAllActivityLogs(model.USER_NAME, model.FULLNAME, model.BRANCH_CODE, startDateValue, endDateValue,
                                                         command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));
            //var logItems = _logger.GetAllLogs(createdOnFromValue, createdToFromValue, model.Message,
            //    logLevel, command.Page - 1, command.PageSize);
            DateTime _today    = DateTime.Now.Date;
            var      gridModel = new DataSourceResult
            {
                Data = items.Select(x => new ActivityLogModel
                {
                    Id            = x.ID,
                    ACTIVITY_ID   = x.ACTIVITY_ID,
                    USER_ID       = x.USER_ID,
                    USER_NAME     = x.USER_NAME,
                    FULLNAME      = x.FULLNAME,
                    ACTIVITY_DESC = x.ACTIVITY_DESC,
                    ACTIVITY_DATE = x.ACTIVITY_DATE,
                    BRANCH_CODE   = x.BRANCH_CODE,
                    BRANCH_NAME   = x.BRANCH_NAME,
                }),
                Total = items.TotalCount
            };

            return(Json(gridModel));
        }
示例#3
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            var log = new ActivityLogModel()
            {
                IPAddress   = HttpContext.Current.Request.UserHostAddress,
                HostName    = HttpContext.Current.Request.UserHostAddress,
                Username    = HttpContext.Current.User != null ? HttpContext.Current.User.Identity.Name : null,
                Modul       = this.Modul,
                Action      = this.Action,
                CreatedDate = DateTime.Now
            };

            var form = filterContext.HttpContext.Request.Form;

            if (form != null)
            {
                try {
                    var dictionary = form.AllKeys.ToDictionary(k => k, k => form[k]);

                    var jsonPostedData = JsonConvert.SerializeObject(dictionary);

                    log.Data = jsonPostedData;
                }
                catch (Exception e) {
                }
            }

            InsertLog(log);
        }
示例#4
0
        public async Task UpdateActivity(ActivityLogEditViewModel saveModel)
        {
            ActivityLogModel model = (ActivityLogModel)saveModel;
            await ActivityLogRepository.UpdateActivity(model);

            await ActivityLogRepository.MergeActivityTypes(model.Id, model.Types.Cast <int>());
        }
示例#5
0
 public void createInvoice()
 {
     try
     {
         UpStream.perform();
         this.inv = new InvoiceModel();
         var ms = (DateTime.Now - DateTime.MinValue).TotalMilliseconds * 10;
         inv.id            = ms.ToString();
         inv.number        = "IN" + ms.ToString();
         inv.date          = DateTime.Now.ToString("yyyy-MM-dd");
         inv.department_id = DepartmentSettings.DepartmentId;
         inv.till_id       = DepartmentSettings.TillId;
         inv.barcode       = inv.number;
         dynamic invoice = inv.create(inv);
         if (invoice != null)
         {
             ActivityLogModel.track("invoice", "create", this.inv.id);
             invoiceNumber.Text = "" + invoice.number;
         }
         else
         {
             invoiceNumber.Text = "Unable to create Invoice";
         }
     }
     catch (Exception ex)
     {
         invoiceNumber.Text = "Error: " + ex.Message.ToString();
     }
 }
        public async Task <ActivityLogModel> GetActivityByTitle(string title)
        {
            const string sql = @"
                SELECT  [Id], [Title], [Title2], [Title3],
                        [Organizers], [Location], [StartDate],
                        [EndDate], [OnCampus], [WebSite], [Notes],
                        [Created], [CreatedBy]
                FROM    [dbo].[ActivityLog]
                WHERE   [Title] = @Title";

            ActivityLogModel activity = null;

            try
            {
                IEnumerable <dynamic> rows = await UnitOfWork.Context().QueryAsync <dynamic>(sql,
                                                                                             new { Title = title });

                activity = ProcessRows(rows).SingleOrDefault();
            }
            catch (Exception e)
            {
                e.Data["SQL"] = sql;
                ErrorStore.LogException(e, HttpContext.Current);
                activity = null;
            }

            return(activity);
        }
        public async Task UpdateActivity(ActivityLogModel model)
        {
            const string sql = @"
                UPDATE  [dbo].[ActivityLog]
                SET     [Title] = @Title,
                        [Title2] = @Title2,
                        [Title3] = @Title3,
                        [Organizers] = @Organizers,
                        [Location] = @Location,
                        [StartDate] = @StartDate,
                        [EndDate] = @EndDate,
                        [OnCampus] = @OnCampus,
                        [WebSite] = @WebSite,
                        [Notes] = @Notes
                WHERE   [Id] = @Id";

            try
            {
                model.StartDate = model.StartDate.ToUniversalTime();
                model.EndDate   = model.EndDate.ToUniversalTime();

                await UnitOfWork.Context().ExecuteAsync(sql, model);
            }
            catch (Exception e)
            {
                e.Data["SQL"] = sql;
                ErrorStore.LogException(e, HttpContext.Current);
                throw e;
            }
        }
        public async Task <int> InsertActivity(ActivityLogModel model, int userId)
        {
            const string sql = @"
                INSERT INTO [dbo].[ActivityLog]
                (
                    [Title], [Title2], [Title3], [Organizers],
                    [Location], [StartDate], [EndDate], [OnCampus],
                    [WebSite], [Notes], [Created], [CreatedBy]
                )
                OUTPUT INSERTED.Id
                VALUES
                (
                    @Title, @Title2, @Title3, @Organizers,
                    @Location, @StartDate, @EndDate, @OnCampus,
                    @WebSite, @Notes, @Created, @CreatedBy
                )";

            try
            {
                model.StartDate = model.StartDate.ToUniversalTime();
                model.EndDate   = model.EndDate.ToUniversalTime();
                model.Created   = DateTime.Now.ToUniversalTime();
                model.CreatedBy = userId;

                return((await UnitOfWork.Context().QueryAsync <int>(sql, model)).Single());
            }
            catch (Exception e)
            {
                e.Data["SQL"] = sql;
                ErrorStore.LogException(e, HttpContext.Current);
                throw e;
            }
        }
示例#9
0
        public string LogActivity(ActivityLogModel activityLogModel)
        {
            string success;

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    db.ActivityLogs.Add(new ActivityLog()
                    {
                        ActivityCode = activityLogModel.ActivityCode,
                        FolderId     = activityLogModel.FolderId,
                        VisitorId    = activityLogModel.VisitorId,
                        CalledFrom   = activityLogModel.CalledFrom,
                        Occured      = DateTime.Now
                    });
                    db.SaveChanges();
                }
                success = "ok";
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
示例#10
0
        public ActionResult ActivityLog(string username, ActivityLogModel model)
        {
            List <ActivityLogModel> log = _log.ActivityLog(username, model.FromDate, model.ToDate, model.Email, model.MobileNumber).MapObjects <ActivityLogModel>();


            //List<LogModel> logModels = log.MapObjects<LogModel>();

            //foreach (var item in log)
            //{
            //    item.Action = StaticData.GetActions("PendingTransaction", item.AgentId.EncryptParameter(), this, "", "", item.TxnId);
            //}
            //Column Creator
            IDictionary <string, string> param = new Dictionary <string, string>();

            param.Add("page_name", "Page Name");
            param.Add("page_url", "Page Url");
            param.Add("ipaddress", "IP Address");
            param.Add("browser_detail", "Browser Detail");
            param.Add("Email", "Email");
            param.Add("MobileNumber", "Mobile Number");
            param.Add("CreatedBy", "Created By");
            param.Add("CreatedLocalDate", "Date");
            ProjectGrid.column = param;
            //Ends
            var grid = ProjectGrid.MakeGrid(log, "hidebreadcrumb", "", 10, false, "", "", "", "", "", "");

            ViewData["grid"] = grid;

            return(View(model));
        }
示例#11
0
 public void InsertLog(ActivityLogModel activityLogModel)
 {
     using (ApplicationDbContext context = new ApplicationDbContext()) {
         var log = Mapper.Map <ActivityLog>(activityLogModel);
         log.Init();
         log.SetCreated();
         context.ActivityLogs.Add(log);
         context.SaveChanges();
     }
 }
        // GET: Admin/ActivityLog
        public ActionResult Index()
        {
            ActivityLogBLL   bll   = new ActivityLogBLL();
            ActivityLogModel model = new ActivityLogModel();

            model.currentPage = 1;
            model.totalPage   = bll.CountPage("");
            model.list        = bll.GetList(1, "");
            return(View(model));
        }
        private async Task DeleteDocument()
        {
            if (SelectedDocument != null)
            {
                if (MessageBox.Show($"Are you sure you want to delete '{SelectedDocument.Title}' Document?", "Delete Record", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
                {
                    return;
                }
                CanDeleteDocument = false;
                try
                {
                    HttpResponseMessage result = await apiHelper.DeleteDocument(ParentLayout.LoggedInUser.Token, SelectedDocument.ID).ConfigureAwait(false);

                    if (result.IsSuccessStatusCode)
                    {
                        #region Log Data

                        ActivityLogModel logData = new ActivityLogModel()
                        {
                            Type        = "Document",
                            Description = $"Document '{SelectedDocument.Title}' deleted by '{ParentLayout.LoggedInUser.Name}'",
                            ProjectID   = ParentLayout.SelectedProject.ID,
                            CreatedBy   = ParentLayout.LoggedInUser.Name,
                            CreatedOn   = DateTime.Now
                        };

                        await logAPIHelper.PostActivityLog(ParentLayout.LoggedInUser.Token, logData);

                        #endregion

                        if (!string.IsNullOrEmpty(SelectedDocument.Title))
                        {
                            FTPHelper.DeletFile(SelectedDocument.DocUrl);
                        }

                        await GetDocuments();
                    }
                    else
                    {
                        MessageBox.Show("Error in deleting Document", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanSaveDocument = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanDeleteDocument = true;
                }
            }
            else
            {
                MessageBox.Show("Please select a document to be deleted", "Select Document", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#14
0
        public async Task AddActivityLogAsync(ActivityLogModel model)
        {
            var cmdParameters = "@ip, @username, @request";
            var cmd           = new NpgsqlCommand();

            cmd.CommandText = $@"INSERT INTO {activityLogTable} ({insertActivityLogColumns}) VALUES ({cmdParameters});";
            cmd.Parameters.AddWithValue("@ip", model.IP);
            cmd.Parameters.AddWithValue("@username", model.User);
            cmd.Parameters.AddWithValue("@request", model.Request);

            await db.CommandNonqueryAsync(cmd);
        }
示例#15
0
        public async Task <int> InsertActivity(ActivityLogCreateViewModel createModel, int userId)
        {
            ActivityLogModel model = (ActivityLogModel)createModel;

            model.CreatedBy = userId;

            int activityId = await ActivityLogRepository.InsertActivity(model, userId);

            await ActivityLogRepository.MergeActivityTypes(activityId, createModel.Types);

            return(activityId);
        }
        private async Task DeleteTask()
        {
            if (SelectedTask != null)
            {
                if (MessageBox.Show($"Are you sure you want to delete {SelectedTask.Title} Task?", "Delete Record", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
                {
                    return;
                }
                CanDeleteTask = false;
                try
                {
                    HttpResponseMessage result = await apiHelper.DeleteTask(ParentLayout.LoggedInUser.Token, SelectedTask.ID).ConfigureAwait(false);

                    if (result.IsSuccessStatusCode)
                    {
                        #region Log Data

                        ActivityLogModel logData = new ActivityLogModel()
                        {
                            Type        = "Task",
                            Description = $"Task '{SelectedTask.Title}' deleted by '{ParentLayout.LoggedInUser.Name}'",
                            ProjectID   = ParentLayout.SelectedProject.ID,
                            CreatedBy   = ParentLayout.LoggedInUser.Name,
                            CreatedOn   = DateTime.Now
                        };

                        await logAPIHelper.PostActivityLog(ParentLayout.LoggedInUser.Token, logData);

                        #endregion

                        await GetTasks();

                        ClearFields();
                        await GetTeamMembers();
                    }
                    else
                    {
                        MessageBox.Show("Error in deleting Task", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    CanDeleteTask = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    CanDeleteTask = true;
                }
            }
            else
            {
                MessageBox.Show("Please select a Task to be deleted", "Select Project", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public ActionResult List()
        {
            var model = new ActivityLogModel();

            if (!User.Identity.IsAuthenticated)
            {
                return(AccessDeniedView());
            }

            identity           = ((CustomPrincipal)User).CustomIdentity;
            _permissionservice = new PermissionsService(identity.Name, identity.UserRoleId);

            IQueryable <CM_BRANCH> curBranchList = db.CM_BRANCH.OrderBy(x => x.BRANCH_NAME); //.Where(a => a.BRANCH_ID == identity.BranchId);

            if (_permissionservice.IsLevel(AuthorizationLevel.Enterprise))
            {
            }
            else if (_permissionservice.IsLevel(AuthorizationLevel.Regional))
            {
                curBranchList = curBranchList.Where(a => a.REGION_ID == identity.RegionId);
            }
            else if (_permissionservice.IsLevel(AuthorizationLevel.Zonal))
            {
                curBranchList = curBranchList.Where(a => a.ZONECODE == identity.ZoneId).OrderBy(a => a.BRANCH_NAME);
            }
            else if (_permissionservice.IsLevel(AuthorizationLevel.Branch))
            {
                curBranchList = curBranchList.Where(a => a.BRANCH_ID == identity.BranchId).OrderBy(a => a.BRANCH_NAME);
            }
            else
            {
                curBranchList = curBranchList.Where(a => a.BRANCH_ID == "-1");
            }

            model.Branches = new SelectList(curBranchList, "BRANCH_ID", "BRANCH_NAME").ToList();


            if (_permissionservice.IsLevel(AuthorizationLevel.Enterprise))
            {
                model.Branches.Add(new SelectListItem
                {
                    Value    = "0",
                    Text     = "All",
                    Selected = true
                });
            }


            _messagingService.SaveUserActivity(identity.ProfileId, "Viewed Activity Logs", DateTime.Now);

            return(View(model));
        }
示例#18
0
        public void loadInvoiceItem()
        {
            ActivityLogModel log          = new ActivityLogModel();
            dynamic          invoiceItems = log.where (log, "model = 'invoice_items'");

            if (invoiceItems.Count > 0)
            {
                foreach (var invoiceItem in invoiceItems)
                {
                    invoiceItemList.Rows.Add(invoiceItem.id, invoiceItem.model, invoiceItem.action, invoiceItem.date, invoiceItem.ref_id, invoiceItem.department_id);
                }
            }
        }
示例#19
0
        public void loadInvoice()
        {
            ActivityLogModel log      = new ActivityLogModel();
            dynamic          invoices = log.where (log, "model = 'invoice'");

            if (invoices.Count > 0)
            {
                foreach (var invoice in invoices)
                {
                    invoiceList.Rows.Add(invoice.id, invoice.model, invoice.action, invoice.date, invoice.ref_id, invoice.department_id);
                }
            }
        }
示例#20
0
        public void loadPayment()
        {
            ActivityLogModel log      = new ActivityLogModel();
            dynamic          payments = log.where (log, "model = 'payment'");

            if (payments.Count > 0)
            {
                foreach (var payment in payments)
                {
                    paymentsList.Rows.Add(payment.id, payment.model, payment.action, payment.date, payment.ref_id, payment.department_id);
                }
            }
        }
示例#21
0
        /// <summary>
        /// Register activity log.
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="message"></param>
        /// <param name="url"></param>
        /// <param name="data"></param>
        public static void RegisterActivityLog(int?userId, string message, string url, object data)
        {
            var model = new ActivityLogModel
            {
                UserId    = userId,
                Message   = message,
                Url       = url,
                JsonData  = JsonConvert.SerializeObject(data),
                CreatedOn = DateTime.Now
            };

            //Create query
        }
示例#22
0
        public void loadMembership()
        {
            ActivityLogModel log         = new ActivityLogModel();
            dynamic          memberships = log.where (log, "model = 'membership'");

            if (memberships.Count > 0)
            {
                foreach (var membership in memberships)
                {
                    membershipList.Rows.Add(membership.id, membership.model, membership.action, membership.date, membership.ref_id, membership.department_id);
                }
            }
        }
示例#23
0
        public void ActivityLogEditViewModel_ActivityLogModel()
        {
            ActivityLogEditViewModel vm = new ActivityLogEditViewModel()
            {
                Types = new List <int> {
                    (int)ActivityLogTypes.Community, (int)ActivityLogTypes.SiteVisit
                }
            };
            ActivityLogModel model = (ActivityLogModel)vm;

            Assert.IsNotNull(model.Types);
            Assert.AreEqual(2, model.Types.Length);
            Assert.AreEqual(ActivityLogTypes.Community, model.Types[0]);
            Assert.AreEqual(ActivityLogTypes.SiteVisit, model.Types[1]);
        }
示例#24
0
        public JsonResult UpdateActivityLog(ActivityLogModel model)
        {
            JourListDMContainer dm = new JourListDMContainer();

            if (User.Identity.IsAuthenticated != true)
            {
                return(JsonError("Please log in"));
            }

            var member = dm.Members.SingleOrDefault(z => z.Name == User.Identity.Name);

            if (member == null)
            {
                return(JsonError("You do not exist"));
            }

            var log = dm.ActivityLogs.SingleOrDefault(z => z.Id == model.LogId);

            if (log == null)
            {
                return(JsonError("That log does not exist"));
            }

            if (log.Journal.Member != member)
            {
                return(JsonError("This log does not belong to you"));
            }

            var unit = dm.Units.SingleOrDefault(z => z.Id == model.UnitId);

            if (unit == null)
            {
                return(JsonError("A unit by that ID does not exist"));
            }
            if (unit.UnitType != log.Activity.Unit.UnitType)
            {
                return(JsonError("Your unit is not the same type as the activity's"));
            }

            log.Unit      = unit;
            log.Hyperlink = model.Hyperlink;
            log.Notes     = model.Notes;
            log.Quantity  = model.Quantity;

            dm.SaveChanges();

            return(JsonOk(model));
        }
        public ActionResult Index(ActivityLogModel model)
        {
            if (model.searchWord == null)
            {
                model.searchWord = "";
            }
            if (model.currentPage == 0)
            {
                model.currentPage = 1;
            }
            ActivityLogBLL bll = new ActivityLogBLL();

            model.list      = bll.GetList(model.currentPage, model.searchWord);
            model.totalPage = bll.CountPage(model.searchWord);
            return(View(model));
        }
 public async Task <HttpResponseMessage> PostActivityLog(string token, ActivityLogModel activityLogData)
 {
     try
     {
         httpClient.DefaultRequestHeaders.Clear();
         httpClient.DefaultRequestHeaders.Accept.Clear();
         httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         httpClient.DefaultRequestHeaders.Add("Authorization", $"bearer {token}");
         using (HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/ActivityLog", activityLogData))
         {
             return(response);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
示例#27
0
        public async Task <ActivityLogViewViewModel> FindAllInfoById(int id)
        {
            ActivityLogModel activityLogModel = await FindById(id);

            if (activityLogModel == null)
            {
                return(null);
            }

            ActivityLogViewViewModel viewModel = new ActivityLogViewViewModel();

            viewModel.ActivityLog  = activityLogModel;
            viewModel.Participants = await ActivityLogPersonRepository.FindActivityParticipants(id);

            viewModel.CreatedBy = await UserRepository.GetUser(activityLogModel.CreatedBy);

            viewModel.HasDocuments = (await DocumentRepository.GetActivityLogDocumentsList(id)).Any();

            return(viewModel);
        }
示例#28
0
        public string createLineItem(dynamic product)
        {
            InvoiceItemModel inv_item = new InvoiceItemModel();
            var ms = (DateTime.Now - DateTime.MinValue).TotalMilliseconds * 10;

            inv_item.id         = "INT" + ms.ToString();
            inv_item.quantity   = 1;
            inv_item.product_id = product.id;
            inv_item.unit       = product.unit;
            inv_item.price      = product.sale_price;
            inv_item.vat        = Math.Round(product.sale_price * (product.vat / 100), 2);
            inv_item.total      = product.sale_price;
            inv_item.name       = product.name;
            inv_item.invoice_id = this.inv.id;
            inv_item.date       = DateTime.Now.ToString("yyyy-MM-dd");
            inv_item.create(inv_item);
            textBoxVat.Text = "" + this.inv.vat;
            ActivityLogModel.track("invoice_item", "create", inv_item.id);
            return(inv_item.id);
        }
        public virtual ActionResult ExportExcelAll(ActivityLogModel model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(AccessDeniedView());
            }
            var items = _dqQueService.GetAllActivityLogs(model.USER_NAME, model.FULLNAME, model.BRANCH_CODE, model.CreatedOnFrom, model.CreatedOnTo);

            try
            {
                byte[] bytes = _exportManager.ExportDocumentsToXlsx(items);
                identity = ((CustomPrincipal)User).CustomIdentity;
                _messagingService.SaveUserActivity(identity.ProfileId, "Downloaded Activity Logs Report", DateTime.Now);
                return(File(bytes, MimeTypes.TextXlsx, "activityLogs.xlsx"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("List"));
            }
        }
示例#30
0
        public async Task <ActivityLogViewViewModel> FindByTitle(string title)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                return(null);
            }

            ActivityLogModel activityLogModel = await ActivityLogRepository.GetActivityByTitle(title);

            if (activityLogModel == null)
            {
                return(null);
            }

            ActivityLogViewViewModel viewModel = new ActivityLogViewViewModel();

            viewModel.ActivityLog = activityLogModel;
            viewModel.CreatedBy   = await UserRepository.GetUser(activityLogModel.CreatedBy);

            return(viewModel);
        }