Beispiel #1
0
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     base.OnActionExecuted(filterContext);
     log.FinishExecution = DateTime.Now;
     log.ExecutionTime   = (log.FinishExecution - log.StartExecution).TotalMilliseconds;
     ActionLogger.GetInstance().AddLog(log);
 }
Beispiel #2
0
        int IEditRegistryItemTask.UpdateItem(int itemId, int registryId, string itemContent, Guid userID, string userName, string fullName, bool isRF)
        {
            int           idd        = dao.SaveItem(registryId, itemId, itemContent, isRF);
            List <string> parameters = new List <string>();

            parameters.Add(itemId.ToString());
            ActionLogger   al  = new ActionLogger(new ActionContext(new Guid("35E02BB1-3EB2-49FF-85B3-AB838E3B5C3B"), userID, userName, fullName, parameters));
            XPathDocument  xpd = new XPathDocument(new StringReader(itemContent));
            XPathNavigator xp  = xpd.CreateNavigator();

            al.AppliesToDocuments.Add(idd);
            al.ActionData.Add("numerPozycjiDziennika", itemId.ToString());
            al.ActionData.Add("dataPisma", xp.SelectSingleNode("/wpis/dataPisma").Value);
            al.ActionData.Add("dataWplywu", xp.SelectSingleNode("/wpis/dataWplywu").Value);
            al.ActionData.Add("nadawca", xp.SelectSingleNode("/wpis/nadawca").Value);
            al.ActionData.Add("znakPisma", xp.SelectSingleNode("/wpis/numerPisma").Value);
            al.ActionData.Add("opis", xp.SelectSingleNode("/wpis/opis").Value);
            al.ActionData.Add("kategoriaDokumentu", xp.SelectSingleNode("/wpis/klasyfikacjaDokumentu/kategoria").Value);
            al.ActionData.Add("rodzajDokumentu", xp.SelectSingleNode("/wpis/klasyfikacjaDokumentu/rodzaj").Value);
            al.ActionData.Add("numerDokumentu", xp.SelectSingleNode("/wpis/klasyfikacjaDokumentu/wartosc").Value);
            al.ActionData.Add("typKorespondencji", xp.SelectSingleNode("/wpis/typKorespondencji/rodzaj").Value);
            al.ActionData.Add("numerKorespondencji", xp.SelectSingleNode("/wpis/typKorespondencji/wartosc").Value);
            al.ActionData.Add("uwagi", xp.SelectSingleNode("/wpis/uwagi").Value);
            al.ActionData.Add("znakReferenta", xp.SelectSingleNode("/wpis/znakReferenta/pracownik").Value);
            al.ActionData.Add("wydzial", xp.SelectSingleNode("/wpis/znakReferenta/wydzial").Value);
            al.ActionData.Add("kwota", string.IsNullOrEmpty(xp.SelectSingleNode("/wpis/kwota").Value) ? "0" : xp.SelectSingleNode("/wpis/kwota").Value);
            al.ActionData.Add("dodatkoweMaterialy", xp.SelectSingleNode("/wpis/dodatkoweMaterialy").Value);
            al.Execute();
            return(idd);
        }
Beispiel #3
0
        public override ActionResult AppDosage(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var model = new AppDosageRepository().GetStageByAppDosageId(id.Value);

            if (model == null)
            {
                return(HttpNotFound());
            }
            FillDosageControl(model);

            model.EXP_DrugDosage.EXP_DrugDeclaration.ExpDicPrimaryOtds = new ReadOnlyDictionaryRepository().GetExpDicPrimaryOTDs().Where(e => e.ParentId == null).ToList();
            model.ExpertisePharmacologicalFinalDoc = model.EXP_ExpertisePharmacologicalFinalDoc.FirstOrDefault();
            if (model.ExpertisePharmacologicalFinalDoc == null)
            {
                model.ExpertisePharmacologicalFinalDoc = new EXP_ExpertisePharmacologicalFinalDoc();
                model.ExpertisePharmacologicalFinalDoc.EXP_ExpertiseStageDosage = model;
            }
            var repository = new ReadOnlyDictionaryRepository();

            ViewData["FinalyDocResultList" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(repository.GetStageResultsByStage(model.EXP_ExpertiseStage.StageId), "Id", "NameRu",
                                                                                                      model.ResultId);

            var stageName = ExpStageNameHelper.GetName(GetStage());

            ActionLogger.WriteInt(stageName + ": Получение заявки №" + model.EXP_DrugDosage.RegNumber); //todo во всех контроллерах так, позже можно замутить через наследование
            return(PartialView("~/Views/DrugDeclaration/AppDosage.cshtml", model));
        }
Beispiel #4
0
        public ActionResult ActionLogsRead([DataSourceRequest] DataSourceRequest request)
        {
            ActionLogger.WriteInt("Получение списка логов действий");
            var data = db.ActionLogsViews;

            return(Json(data.ToDataSourceResult(request)));
        }
Beispiel #5
0
        public void SetExpertiseStageDosageResult(Guid dosageStageId, int resultId)
        {
            var creatorId   = UserHelper.GetCurrentEmployee().Id;
            var dosageStage = AppContext.EXP_ExpertiseStageDosage.First(e => e.Id == dosageStageId);

            dosageStage.ResultId = resultId;
            var r = new EXP_ExpertiseStageDosageResult();

            r.ResultDate      = DateTime.Now;
            r.ResultId        = resultId;
            r.ResultCreatorId = creatorId;
            r.StageDosageId   = dosageStageId;
            //todo тут похорошему ещё говнопроверок надо напихать, если заявка на совете, похорошему её нельзя редактировать
            var lastResultInCommission = AppContext.CommissionDrugDosages.FirstOrDefault(x => x.DrugDosageId == dosageStage.DosageId && x.StageId == dosageStage.StageId && x.ConclusionTypeId == null);

            if (lastResultInCommission != null)
            {
                lastResultInCommission.EXP_ExpertiseStageDosageResult = r;
            }
            AppContext.EXP_ExpertiseStageDosageResult.Add(r);
            var addLogInfo = "";

            addLogInfo += "resultId: " + resultId;
            ActionLogger.WriteInt(AppContext, creatorId, "Заявка №" + dosageStage.EXP_DrugDosage.RegNumber + " выставление результата ", addLogInfo);
            AppContext.SaveChanges();
        }
Beispiel #6
0
        public ActionResult Design(Guid[] id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var model = GetAssessmentStage(id[0]);

            model.OBK_AssessmentDeclaration.Applicant = new EmployeesRepository().GetById(model.OBK_AssessmentDeclaration.EmployeeId);

            //проверка для кнопки выдать результат
            var certificateOfComplection = model.OBK_AssessmentDeclaration.OBK_CertificateOfCompletion.FirstOrDefault(
                e => e.AssessmentDeclarationId == model.DeclarationId);
            var expDocument = db.OBK_StageExpDocument.FirstOrDefault(o => o.AssessmentDeclarationId == model.OBK_AssessmentDeclaration.Id);

            if (certificateOfComplection == null)
            {
                ViewBag.outputResultAct = false;
                ViewBag.ZBKTaken        = false;
            }
            else
            {
                ViewBag.outputResultAct = (certificateOfComplection.ActReturnedBack == true && model.OBK_AssessmentDeclaration.ZBKTaken == true);
                ViewBag.ZBKTaken        = (model.OBK_AssessmentDeclaration.ZBKTaken) == true;
                ViewBag.ActReturnedBack = certificateOfComplection.ActReturnedBack;
            }
            FillDeclarationControl(model.OBK_AssessmentDeclaration);
            var stageName = GetName(model.StageId);

            ActionLogger.WriteInt(stageName + ": Получение заявления №" + model.OBK_AssessmentDeclaration.Number);

            //  new SafetyAssessmentRepository().AddHistory(model.DeclarationId, OBK_Ref_StageStatus.Completed, model.OBK_AssessmentDeclaration.EmployeeId);

            return(PartialView(model));
        }
Beispiel #7
0
 public ActionResult PermissionRoleDestroy([DataSourceRequest] DataSourceRequest request, PermissionRole dictionary)
 {
     if (dictionary != null)
     {
         var roleId = dictionary.Id;
         var dbRole = db.PermissionRoles.SingleOrDefault(x => x.Id == roleId);
         if (dbRole == null)
         {
             ModelState.AddModelError("Message", Convert.ToString("Роль не найдена"));
             return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
         }
         var dbEmployees = db.EmployeePermissionRoles.Where(x => x.PermissionRoleId == roleId)
                           .Join(db.Employees, x => x.EmployeeId, x => x.Id, (r, e) => e).ToList();
         if (dbEmployees.Count > 0)
         {
             var empl          = dbEmployees[0];
             var employeeNames = empl.LastName + " " + empl.FirstName + " " + empl.MiddleName;
             var otherCount    = dbEmployees.Count - 1;
             if (otherCount > 0)
             {
                 employeeNames += " и ещё " + otherCount + " сотрудник(ов)";
             }
             ModelState.AddModelError("Message", Convert.ToString("Роль использует " + employeeNames));
             return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
         }
         db.PermissionRoles.Remove(dbRole);
         ActionLogger.WriteInt(db, "Удаление роли прав доступа", "RoleId: " + dbRole.Id + "; Name: " + dbRole.Name);
         db.SaveChanges();
         EmployePermissionHelper.RemoveRolePermissionKeys(dbRole.Id);
     }
     return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
 }
        private void Login()
        {
            try
            {
                int roleId = loginViewModel.GetLoginRole(UsernameTextBox.Text, Crypto.ConvertToHash(PasswordTextBox.Password));

                if (roleId > 0)
                {
                    // Report all action data
                    ActionLogger.ReportAllDataNow();

                    // Add login action to action logger
                    ActionLogger.Log(GetType().FullName + nameof(Login), UsernameTextBox.Text, roleId, $"<User_Login>");

                    // Open admin main view
                    foreach (Window window in Application.Current.Windows)
                    {
                        if (window.GetType() == typeof(MainWindow))
                        {
                            (window as MainWindow).MainContentControl.DataContext = new AdminMainView(roleId, UsernameTextBox.Text);
                        }
                    }
                }
                else
                {
                    NotifyInvalidLoginCredentials();
                }
            }
            catch
            {
                NotifyInvalidLoginCredentials();
            }
        }
Beispiel #9
0
        public ActionResult PermissionRoleValueList()
        {
            ActionLogger.WriteInt("Получение списка ролей доступа");
            var data = db.PermissionRoles.Select(o => new { Id = o.Id, Name = o.Name }).OrderBy(x => x.Name).ToList();

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        public ActionResult ResetPassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                Employee employee = UserHelper.GetCurrentEmployee();

                if (employee != null)
                {
                    MembershipUser user = Membership.GetUser(employee.Login);
                    if (user != null)
                    {
                        try
                        {
                            user.ChangePassword(model.OldPassword, model.NewPassword);

                            LogHelper.Log.DebugFormat("Смена пароля для {0}", employee.Login);
                            ActionLogger.WriteExt("Сменил себе пароль");
                            return(RedirectToAction("ResetPasswordConfirmation", "Account"));
                        }
                        catch (Exception e)
                        {
                            ActionLogger.WriteExt("Пытался сменить себе пароль");
                            return(Json(new MessageModel()
                            {
                                IsError = true, Message = e.Message
                            }));
                        }
                    }
                }
            }
            ActionLogger.WriteExt("Пытался сменить себе пароль");
            return(View(model));
        }
Beispiel #11
0
        public void Debug_With_Generic_Type_Should_Emit_Message_And_Type_Provided()
        {
            string   passedMessage = null;
            LogLevel?passedLevel   = null;
            Type     passedType    = null;

            var logger = new ActionLogger(
                null,
                (message, type, level) =>
            {
                passedMessage = message;
                passedType    = type;
                passedLevel   = level;
            },
                null,
                null);

            var fullLogger = new WrappingFullLogger(logger);

            fullLogger.Debug <DummyObjectClass2>("This is a test.");

            Assert.Equal("This is a test.", passedMessage);
            Assert.Equal(LogLevel.Debug, passedLevel);
            Assert.Equal(typeof(DummyObjectClass2), passedType);
        }
        public override ActionResult AppDosage(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var dosageRepository = new AppDosageRepository();
            var model            = dosageRepository.GetStageByAppDosageId(id.Value);

            if (model == null)
            {
                return(HttpNotFound());
            }
            FillDosageControl(model);
            var safetyReportDosageStage = dosageRepository.GetStageDosage(model.DosageId, CodeConstManager.STAGE_SAFETYREPORT);

            model.ExpertiseSafetyreportFinalDoc = safetyReportDosageStage != null?safetyReportDosageStage.EXP_ExpertiseSafetyreportFinalDoc.FirstOrDefault() : null;

            model.EXP_DrugDosage.EXP_DrugDeclaration.ExpDicPrimaryOtds = new ReadOnlyDictionaryRepository().GetExpDicPrimaryOTDs().Where(e => e.ParentId == null).ToList();
            var repository = new ReadOnlyDictionaryRepository();

            ViewData["FinalyDocResultList" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(repository.GetStageResultsByStage(model.EXP_ExpertiseStage.StageId), "Id", "NameRu",
                                                                                                      model.ResultId);

            var stageName = ExpStageNameHelper.GetName(GetStage());

            ActionLogger.WriteInt(stageName + ": Получение заявки №" + model.EXP_DrugDosage.RegNumber);
            return(PartialView("~/Views/DrugDeclaration/AppDosage.cshtml", model));
        }
Beispiel #13
0
        public ActionResult DeletePermissionRole(int roleId)
        {
            var dbRole = db.PermissionRoles.SingleOrDefault(x => x.Id == roleId);

            if (dbRole == null)
            {
                return(Json(new { success = false, message = "Роль не найдена" }));
            }
            var dbEmployees = db.EmployeePermissionRoles.Where(x => x.PermissionRoleId == roleId)
                              .Join(db.Employees, x => x.EmployeeId, x => x.Id, (r, e) => e).ToList();

            if (dbEmployees.Count > 0)
            {
                var empl          = dbEmployees[0];
                var employeeNames = empl.LastName + " " + empl.FirstName + " " + empl.MiddleName;
                var otherCount    = dbEmployees.Count - 1;
                if (otherCount > 0)
                {
                    employeeNames += " и ещё " + otherCount + " сотрудник(ов)";
                }
                return(Json(new { success = false, message = "Роль использует " + employeeNames }));
            }
            db.PermissionRoles.Remove(dbRole);
            ActionLogger.WriteInt(db, "Удаление роли прав доступа", "RoleId: " + roleId + "; RoleName" + dbRole.Name);
            db.SaveChanges();
            return(Json(new { success = true, message = "Роль успешно удалена" }));
        }
Beispiel #14
0
        public void ActionLogger_Log_TakesString_LogTextNotNull()
        {
            ActionLogger.Log("Test Location", "Test Username", 0, "Test Action Message");

            string actualResult = File.ReadAllText($"{Paths.TempDir}CSI_Action_Log_{DateTime.Today.ToString("MM-dd-yy")}.txt");

            Assert.IsNotNull(actualResult);
        }
Beispiel #15
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            //if (DateTime.Now > new DateTime(2016, 12, 31))
            //	return RedirectToAction("LogOn", "Account");

            if (ModelState.IsValid)
            {
                ncelsEntities ncelsEntities = new ncelsEntities();


                Employee employee = ncelsEntities.Employees.Include("Position").FirstOrDefault(o => o.Login == model.UserName);

                if (employee != null && employee.Position.PositionState == 1)
                {
                    if (Membership.ValidateUser(model.UserName, model.Password))
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                        Session[UserHelper.ConnectKey] = DateTime.Now.Year.ToString();
                        SaveUserName();

                        ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Успех");

                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                            !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        var user = Membership.GetUser(model.UserName);
                        if (user != null && (user.IsLockedOut || !user.IsApproved))
                        {
                            ModelState.AddModelError("", Messages.AccountController_LogOn_Пользователь_заблокирован_);
                            ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Пользователь заблокирован");
                        }
                        else
                        {
                            ModelState.AddModelError("", Messages.AccountController_LogOn_Имя_пользователя_или_пароль_не_верны_);
                            ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Неверное имя пользователя или пароль");
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("", Messages.AccountController_LogOn_Пользователь_заблокирован_);
                    ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Пользователь заблокирован/не найден");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #16
0
        public void ActionLogger_GetAllData_ReturnsNotNull()
        {
            // Log data to make sure there is always something there when this test is run
            ActionLogger.Log("Test Location", "Test Username", 0, "Test Action Message");

            var data = ActionLogger.GetAllData();

            Assert.IsNotNull(data);
        }
Beispiel #17
0
        public void ActionLogger_Log_TakesString_CreatesLogFile()
        {
            ActionLogger.Log("Test Location", "Test Username", 0, "Test Action Message");

            bool actual   = File.Exists($"{Paths.TempDir}CSI_Action_Log_{DateTime.Today.ToString("MM-dd-yy")}.txt");
            bool expected = true;

            Assert.AreEqual(expected, actual);
        }
        protected void zapisz_Click(object sender, EventArgs e)
        {
            DocumentDAO dao = new DocumentDAO();
            FileStream  fs  = File.OpenRead(Pemi.Esoda.Tools.Configuration.PhysicalTemporaryDirectory + "\\" + temporaryFileName);

            if (forceUpdate.Visible && forceUpdate.Checked)
            {
                dao.AddNewVersionOfDocumentItem(IdDokumentu, IdOryginalu, fileDescription.Text, fs, mimeType.Text, fileName.Text, DocumentItemCategory.Uploaded);
                IdOryginalu = Guid.Empty;
            }
            else
            {
                Guid itemId = Guid.Empty;
                dao.AddNewDocumentItem(IdDokumentu, fileName.Text, fileDescription.Text, fs, mimeType.Text, ref itemId, DocumentItemCategory.Uploaded);
                //int docId = dao.AddNewDocument(new Guid(Membership.GetUser().ProviderUserKey.ToString()), md.GetXml());

                DocumentItemDTO docItem = dao.GetItem(itemId);
                string          imie = String.Empty, nazwisko = string.Empty;
                DbDataReader    dr = (DbDataReader)(new UserDAO()).GetEmployee(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
                if (dr.Read())
                {
                    imie     = dr["imie"].ToString();
                    nazwisko = dr["nazwisko"].ToString();
                }
                dr.Close();

                List <string> paramList = new List <string>();
                paramList.Add(fileName.Text);
                ActionLogger al = new ActionLogger(new ActionContext(new Guid("9cd585bb-2a06-4c24-b415-aa3f8b00ea5f"), new Guid(Membership.GetUser().ProviderUserKey.ToString()), Membership.GetUser().UserName, Membership.GetUser().Comment, paramList));

                al.AppliesToDocuments.Add(IdDokumentu);
                al.ActionData.Add("idDokumentu", IdDokumentu.ToString());
                al.ActionData.Add("idPracownika", Membership.GetUser().UserName);
                al.ActionData.Add("imie", imie);
                al.ActionData.Add("nazwisko", nazwisko);
                al.ActionData.Add("dataDodania", docItem.CreationDate.ToString());
                al.ActionData.Add("idPliku", docItem.ID.ToString());
                al.ActionData.Add("nazwaPliku", fileName.Text);

                /* Nr systemowy dokumentu logicznego
                 * Id pracownika (login) (który dokonuje operacji do³¹czenia)
                 * imie pracownika
                 * nazwisko pracownika,
                 * Data dolaczenia pliku
                 * Czas dolaczenia pliku
                 * Id systemowe (guid?) dolaczanego pliku
                 * Nazwa do³¹czanego pliku*/


                al.Execute();
            }
            fs.Close();
            DeleteTemporaryFile();

            Response.Redirect("~/Dokumenty/SkladnikiDokumentu.aspx?id=" + CoreObject.GetId(Request).ToString());
        }
Beispiel #19
0
        public ActionResult ListRegister([DataSourceRequest] DataSourceRequest request, string type, int stage, DeclarationRegistryFilter customFilter = null)
        {
            var stageName = ExpStageNameHelper.GetName(stage);

            ActionLogger.WriteInt(stageName + ": Получение списка заявлений");
            var list   = new DrugDeclarationRepository().DrugDeclarationRegisterByStatus(type, stage, UserHelper.GetCurrentEmployee().Id, customFilter);
            var result = list.ToDataSourceResult(request);

            return(Json(result));
        }
Beispiel #20
0
        public ActionResult SendToNextStage(Guid expStageId, int[] nextStageIds, int?stageResultId = null)
        {
            var repository = new ExpertiseStageRepository();

            if (repository.HasNotFixedRemarks(expStageId))
            {
                return(Json(
                           new
                {
                    failed = true,
                    msg = "Невозможно передать на следующий этап так как есть не исправленные замечания"
                }, JsonRequestBehavior.AllowGet));
            }
            string resultDescription;

            var expertiseStage = repository.GetById(expStageId);
            var dec            = repository.GetDeclarationByStage(expStageId);

            if (expertiseStage.EXP_DIC_Stage.Code == CodeConstManager.STAGE_SAFETYREPORT.ToString())
            {
                var rDictionary = new ReadOnlyDictionaryRepository();
                EXP_DIC_StageResult stageResult = null;
                if (stageResultId.HasValue)
                {
                    stageResult = rDictionary.GetStageResultById(stageResultId.Value);
                }

                if (stageResult != null && stageResult.Code == EXP_DIC_StageResult.DoesNotMatchCode)
                {
                    repository.ToBackStage(dec.Id, expStageId, nextStageIds, out resultDescription);
                }
                else
                {
                    repository.ToNextStage(dec.Id, expStageId, nextStageIds, out resultDescription);
                }
            }
            else
            {
                repository.ToNextStage(dec.Id, expStageId, nextStageIds, out resultDescription);
            }
            var from = ExpStageNameHelper.GetName(expertiseStage.StageId);
            var to   = "";

            foreach (var nextStageId in nextStageIds)
            {
                if (!String.IsNullOrEmpty(to))
                {
                    to += ", ";
                }
                var stageName = ExpStageNameHelper.GetName(nextStageId);
                to += stageName;
            }
            ActionLogger.WriteInt(" Отправка заявления №" + dec.Number + " на другой этап", "from: " + from + "; to:" + to);
            return(Json("OK", JsonRequestBehavior.AllowGet));
        }
        private int saveGenericDocument(string filePath, string originalFilename, string mimeType, Guid documentGuid, Guid?elementVersionGuid, string description, string desiredName, string ticket)
        {
            DocumentDAO dao    = new DocumentDAO();
            Guid        userID = new MSOIntegrationDAO().GetUseGuidFromTicket(ticket);
            Guid        itemId = Guid.Empty;

            int documentID = dao.GetDocumentIDForGuid(documentGuid);

            if (documentID == 0)
            {
                return(-1);
            }
            FileStream fs = File.OpenRead(filePath);

            try
            {
                if (!elementVersionGuid.HasValue)
                {
                    dao.AddNewDocumentItem(documentID, originalFilename, description, fs, mimeType, ref itemId, DocumentItemCategory.Created);

                    DocumentItemDTO docItem  = dao.GetItem(itemId);
                    string[]        fullname = Membership.GetUser(userID).Comment.Split(' ');

                    string imie     = fullname.Length >= 2 ? fullname[1] : string.Empty;
                    string nazwisko = fullname.Length >= 1 ? fullname[0] : string.Empty;


                    List <string> paramList = new List <string>();
                    paramList.Add(originalFilename);


                    ActionLogger al = new ActionLogger(new ActionContext(new Guid("9cd585bb-2a06-4c24-b415-aa3f8b00ea5f"), userID, Membership.GetUser(userID).UserName, Membership.GetUser(userID).Comment, paramList));

                    al.AppliesToDocuments.Add(documentID);
                    al.ActionData.Add("idDokumentu", documentID.ToString());
                    al.ActionData.Add("idPracownika", Membership.GetUser(userID).UserName);
                    al.ActionData.Add("imie", imie);
                    al.ActionData.Add("nazwisko", nazwisko);
                    al.ActionData.Add("dataDodania", docItem.CreationDate.ToString());
                    al.ActionData.Add("idPliku", docItem.ID.ToString());
                    al.ActionData.Add("nazwaPliku", originalFilename);
                    al.Execute();
                }
                else
                {
                    dao.AddNewVersionOfDocumentItem(documentID, elementVersionGuid.Value, description, fs, mimeType, desiredName, DocumentItemCategory.Created);
                }
            }
            catch
            {
                return(-2);
            }
            return(0);
        }
Beispiel #22
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                Employee employee = _context.Employees.FirstOrDefault(o => o.Login == model.Email);
                if (employee != null)
                {
                    if (Membership.ValidateUser(model.Email, model.Password))
                    {
                        FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
                        Session[UserHelper.ConnectKey] = DateTime.Now.Year.ToString();
                        SaveUserName();
                        ActionLogger.WriteExt("Вход в систему: " + model.Email, "Успех");

                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                            !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        var user = Membership.GetUser(model.Email);
                        if (user == null)
                        {
                            LogHelper.Log.Debug("User is null");
                        }
                        if (user != null && (user.IsLockedOut || !user.IsApproved))
                        {
                            ModelState.AddModelError("", Messages.AccountController_LogOn_Пользователь_заблокирован_);
                            ActionLogger.WriteExt("Вход в систему: " + model.Email, "Пользователь заблокирован");
                        }
                        else
                        {
                            ModelState.AddModelError("", Messages.AccountController_LogOn_Имя_пользователя_или_пароль_не_верны_);
                            ActionLogger.WriteExt("Вход в систему: " + model.Email, "Неверное имя пользователя или пароль");
                        }
                    }
                }
                else
                {
                    LogHelper.Log.Debug("employee is null");
                    ModelState.AddModelError("", Messages.AccountController_LogOn_Пользователь_заблокирован_);
                    ActionLogger.WriteExt("Вход в систему: " + model.Email, "Пользователь заблокирован/не найден");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #23
0
        public ActionResult PermissionRoleRead([DataSourceRequest] DataSourceRequest request)
        {
            ActionLogger.WriteInt(db, "Получение списка ролей прав доступа");
            var data = db.PermissionRoles.OrderByDescending(m => m.Id).Select(o => new
            {
                o.Id,
                o.Name,
            });

            return(Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }
Beispiel #24
0
        protected void zakonczAkcje(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Update")
            {
                if (Page.IsValid)
                {
                    int     id  = -1;
                    CaseDAO dao = new CaseDAO();
                    id = int.Parse((frmSprawa.FindControl("hfCaseId") as HiddenField).Value);
                    string opis      = (frmSprawa.FindControl("txtOpis") as TextBox).Text;
                    string znakPisma = (frmSprawa.FindControl("txtZnakPisma") as TextBox).Text;

                    DateTime dataRozpoczecia;
                    if (!DateTime.TryParse((frmSprawa.FindControl("dataRozpoczecia") as TextBox).Text, out dataRozpoczecia))
                    {
                        dataRozpoczecia = DateTime.MinValue;
                    }

                    DateTime dataPisma;
                    if (!DateTime.TryParse((frmSprawa.FindControl("txtDataPisma") as TextBox).Text, out dataPisma))
                    {
                        dataPisma = DateTime.MinValue;
                    }

                    DateTime dataZakonczenia;
                    if (!DateTime.TryParse((frmSprawa.FindControl("dataZakonczenia") as TextBox).Text, out dataZakonczenia))
                    {
                        dataZakonczenia = DateTime.MinValue;
                    }

                    string uwagi = (frmSprawa.FindControl("txtUwagi") as TextBox).Text;

                    int status  = int.Parse((frmSprawa.FindControl("ddlStatus") as DropDownList).SelectedValue);
                    int nadawca = int.Parse((frmSprawa.FindControl("hfCustomerId") as HiddenField).Value);



                    List <string> parameters = new List <string>();
                    parameters.Add(Membership.GetUser().Comment);
                    ActionLogger al = new ActionLogger(new ActionContext(new Guid("05555FAA-A86A-40C1-9A69-6512276C7098"), new Guid(Membership.GetUser().ProviderUserKey.ToString()), Membership.GetUser().UserName, Membership.GetUser().Comment, parameters));
                    al.AppliesToCases.Add(id);
                    al.Execute();

                    dao.UpdateCase(id, opis, znakPisma, dataRozpoczecia, dataPisma, dataZakonczenia, uwagi, status, nadawca, -1, new Guid(Membership.GetUser().ProviderUserKey.ToString()));

                    Response.Redirect("~/Sprawy/AkcjeSprawy.aspx?id=" + id.ToString(), false);
                }
            }
            else if (e.CommandName == "Cancel")
            {
                Response.Redirect("~/Sprawy/AkcjeSprawy.aspx?id=" + CoreObject.GetId(Request));
            }
        }
Beispiel #25
0
        private void LogoutButton_Click(object sender, RoutedEventArgs e)
        {
            ActionLogger.Log(GetType().FullName + nameof(LogoutButton_Click), UserRole, "<User_Logout>");

            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    (window as MainWindow).MainContentControl.DataContext = new MainView();
                }
            }
        }
Beispiel #26
0
 public ActionResult PermissionRoleUpdate([DataSourceRequest] DataSourceRequest request, PermissionRole dictionary)
 {
     if (dictionary != null && ModelState.IsValid)
     {
         var dbPermissionRole = db.PermissionRoles.Single(o => o.Id == dictionary.Id);
         var prevName         = dbPermissionRole.Name;
         dbPermissionRole.Name = dictionary.Name;
         ActionLogger.WriteInt(db, "Обновление роли прав доступа", "RoleId: " + dbPermissionRole.Id + "; PrevName: " + prevName + "; CurrentName: " + dictionary.Name);
         db.SaveChanges();
     }
     return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
 }
Beispiel #27
0
        public ActionResult PermissionRoleCreate([DataSourceRequest] DataSourceRequest request, PermissionRole dictionary)
        {
            if (dictionary != null)
            {
                db.PermissionRoles.Add(dictionary);
                ActionLogger.WriteInt(db, "Создание роли прав доступа", "Name: " + dictionary.Name);
                db.SaveChanges();
                EmployePermissionHelper.AddRoleDefaultPermissionKeys(dictionary.Id);
            }

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
Beispiel #28
0
 public ActionResult EmployeePermissionRoleDestroy([DataSourceRequest] DataSourceRequest request, PermissionRoleModel dictionary, Guid employeeId)
 {
     if (dictionary != null)
     {
         var dbEmployeeRole = db.EmployeePermissionRoles.Single(x => x.Id == dictionary.EmployeeRoleId);
         db.EmployeePermissionRoles.Remove(dbEmployeeRole);
         ActionLogger.WriteInt(db, "Удаление сотруднику роли прав доступа", "RoleId: " + dbEmployeeRole.PermissionRoleId + "; EmployeeId: " + dbEmployeeRole.EmployeeId);
         db.SaveChanges();
         EmployePermissionHelper.ClearEmployeePermission();
     }
     return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
 }
Beispiel #29
0
        private void saveChanges()
        {
            DaneDokumentu.DaneDokumentuDataTable dt = (DaneDokumentu.DaneDokumentuDataTable)ViewState["dmd"];
            XmlDocument xpd = new XmlDocument();

            xpd.Load(new StringReader(dt[0].metadane));
            XPathNavigator xpn = xpd.CreateNavigator();

            //xpn.SelectSingleNode("/metadane/nadawca/@id").SetValue(interesant.SelectedValue);

            xpn.SelectSingleNode("/metadane/nadawca/@id").SetValue(hfCustomerId.Value);
            int typeId, catId;

            //(new UserDAO()).GetCustomerTypeCat(int.Parse(interesant.SelectedValue), out typeId, out catId);
            (new UserDAO()).GetCustomerTypeCat(int.Parse(hfCustomerId.Value), out typeId, out catId);
            xpn.SelectSingleNode("/metadane/nadawca/@typ").SetValue(typeId.ToString());
            xpn.SelectSingleNode("/metadane/nadawca/@kategoria").SetValue(catId.ToString());

            //xpn.SelectSingleNode("/metadane/nadawca").SetValue(interesant.SelectedItem.Text);
            xpn.SelectSingleNode("/metadane/nadawca").SetValue(lblInteresant.Text);

            //if(znakPisma.Text.Length>0)
            xpn.SelectSingleNode("/metadane/numerPisma").SetValue(znakPisma.Text);
            xpn.SelectSingleNode("/metadane/klasyfikacjaDokumentu/kategoria/@id").SetValue(kategoria.SelectedIndex == -1?"0":kategoria.SelectedValue);
            xpn.SelectSingleNode("/metadane/klasyfikacjaDokumentu/kategoria").SetValue(kategoria.SelectedIndex == -1 ? "nieokreœlona" : kategoria.SelectedItem.Text);
            xpn.SelectSingleNode("/metadane/klasyfikacjaDokumentu/rodzaj/@id").SetValue(rodzaj.SelectedIndex == -1?"0":rodzaj.SelectedValue);
            xpn.SelectSingleNode("/metadane/klasyfikacjaDokumentu/rodzaj").SetValue(rodzaj.SelectedIndex == -1?"nieokreœlony": rodzaj.SelectedItem.Text);
            string newMetadata = xpn.SelectSingleNode("/metadane").OuterXml;

            DaneDokumentuTableAdapters.DaneDokumentuDAO dao = new Pemi.Esoda.Web.UI.Akcje.DaneDokumentuTableAdapters.DaneDokumentuDAO();


            ActionLogger al = new ActionLogger(new ActionContext(new Guid("5B1EDF0C-DE49-4D5C-A116-54A5E25C6FB8"), new Guid(Membership.GetUser().ProviderUserKey.ToString()), Membership.GetUser().UserName, Membership.GetUser().Comment, new List <string>()));

            al.AppliesToDocuments.Add((int)ViewState["docId"]);
            //al.ActionData.Add("interesant", interesant.SelectedItem.Text);

            al.ActionData.Add("interesant", (lblInteresant.Text.Length > 0)?lblInteresant.Text:"-");
            al.ActionData.Add("status", status.SelectedItem.Text);
            al.ActionData.Add("znakPisma", (znakPisma.Text.Length > 0)?znakPisma.Text:"-");
            al.ActionData.Add("kategoria", kategoria.SelectedIndex == -1?"0":kategoria.SelectedItem.Text);
            al.ActionData.Add("rodzaj", rodzaj.SelectedIndex == -1?"0":rodzaj.SelectedItem.Text);
            al.Execute();

            int res = dao.Update((int)ViewState["docId"], newMetadata, int.Parse(status.SelectedValue));

            if (res == 0)
            {
                BaseContentPage.SetError("oops...", "~/Akcje/EdycjaDokumentu.aspx");
            }
            //Session["context"] = null;
        }
Beispiel #30
0
        int IEditRegistryItemTask.AcquireItemID(int registryId, Guid userID, string userName, string fullName, bool isRF)
        {
            int[]         ids        = dao.AcquireItemID(registryId, userID, isRF);
            List <string> parameters = new List <string>();

            parameters.Add(ids[0].ToString());
            ActionLogger al = new ActionLogger(new ActionContext(new Guid("5F5E6C05-A007-4121-BD56-56317F154C28"), userID, userName, fullName, parameters));

            al.AppliesToDocuments.Add(ids[1]);
            al.ActionData.Add("numerPozycjiDziennika", ids[0].ToString());
            al.Execute();
            return(ids[0]);
        }