Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SuperKey = ApplicationCommon.GetSuperKey();
            SetId    = ApplicationCommon.GetSetId();

            if (!string.IsNullOrEmpty(SuperKey))
            {
                var lstEntityKeys = ApplicationCommon.GetSuperKeyDetails(PrimaryEntity.Value(), SuperKey);

                foreach (var entityKey in lstEntityKeys)
                {
                    AddDetailControl(false, entityKey);

                    if (string.IsNullOrEmpty(DeleteIds))
                    {
                        DeleteIds = entityKey.ToString();
                    }
                    else
                    {
                        DeleteIds += ", " + entityKey.ToString();
                    }
                }
            }
            else if (SetId != 0)
            {
                AddDetailControl(true, SetId);

                DeleteIds = SetId.ToString();
            }

            ShowAuditHistory(true);
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SuperKey = ApplicationCommon.GetSuperKey();

            // should be client side ... maybe
            if (!string.IsNullOrEmpty(SuperKey))
            {
                BtnCancel.Visible = true;
                BtnUpdate.Visible = true;
                BtnClone.Visible  = false;

                var lstEntityKeys = ApplicationCommon.GetSuperKeyDetails(PrimaryEntity.Value(), SuperKey);

                foreach (var entityKey in lstEntityKeys)
                {
                    AddUpdateControl(false, entityKey);
                }

                return;
            }

            SetId = ApplicationCommon.GetSetId();
            if (SetId != 0)
            {
                BtnUpdate.Visible = true;
                BtnCancel.Visible = true;
                BtnClone.Visible  = false;

                AddUpdateControl(true, SetId);
            }
        }
Exemplo n.º 3
0
            private void InvocationsReExecutor(
                SecondaryEntity state,
                MyGssNode stack,
                Node position,
                MyTransition currentTransition,
                PrimaryEntity newType)
            {
                var invocation = (ResolvedInvocationStatement <Node>)currentTransition.Statement;

                if (newType is IInvokable <Node> invocable)
                {
                    //Logging.Log("dynamic re-invocation");

                    if (state is UnknownEntity)
                    {
                        Push(state, new MyStackData(currentTransition, state, true), invocable.EntryPoint);
                        invocable.MarkAsInvoked();
                    }
                    else
                    {
                        var recipientId = invocation.PassedParameters[state];
                        var exists      = invocable.Variables.TryGetValue(recipientId.Value, out var recipient);

                        if (exists)
                        {
                            Push(recipient, new MyStackData(currentTransition, state, true), invocable.EntryPoint);
                        }
                    }
                }

                if (newType is ResolvedClassId classId)
                {
                    var target = myProcessingProgram
                                 .FindClassById(classId)
                                 .FindMethodInFullHierarchy(invocation.TargetMethodId);

                    if (target == null)
                    {
                        return;
                    }

                    if (state is UnknownEntity)
                    {
                        Push(state, new MyStackData(currentTransition, state, true), target.EntryPoint);
                        target.MarkAsInvoked();
                    }
                    else
                    {
                        var recipientId = invocation.PassedParameters[state];
                        var exists      = target.Variables.TryGetValue(recipientId.Value, out var recipient);

                        if (exists)
                        {
                            Push(recipient, new MyStackData(currentTransition, state, true), target.Start);
                        }
                    }
                }
            }
Exemplo n.º 4
0
 private void OnNewBottomEntityAdded(PrimaryEntity entity)
 {
     if (!TopLevelClosure.Value.Collected.Contains(entity))
     {
         if (mySubscriptions.IsValueCreated)
         {
             mySubscriptions.Value.Fire(entity);
         }
     }
 }
Exemplo n.º 5
0
        private void OnNewOwnerInstanceAdded(PrimaryEntity entity)
        {
            var classId = entity as ResolvedClassId;
            //Trace.Assert(classId != null);

            var method = FindClassMethod(classId, MethodId);

            if (method != null)
            {
                AddPrimary(method);
            }
        }
Exemplo n.º 6
0
        private void OnNewOwnerInstanceAdded(PrimaryEntity entity)
        {
            var classId = entity as ResolvedClassId;

            //TODO: Trace.Assert(classId != null);
            if (classId == null)
            {
                return;
            }

            var field = FindClassField(classId, FieldId);

            field.PropagateForward(this);
            this.PropagateForward(field);
        }
        public void RefreshFromSdkMessageFilter(SdkMessageFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            if (filter.SdkMessageFilterId != null)
            {
                MessageEntityId = filter.SdkMessageFilterId.Value;
            }

            if (filter.SdkMessageId != null)
            {
                MessageId = filter.SdkMessageId.Id;
            }

            if (!string.IsNullOrEmpty(filter.PrimaryObjectTypeCode))
            {
                PrimaryEntity = filter.PrimaryObjectTypeCode;
            }

            if (!string.IsNullOrEmpty(filter.SecondaryObjectTypeCode))
            {
                SecondaryEntity = filter.SecondaryObjectTypeCode;
            }

            if (filter.CustomizationLevel != null)
            {
                CustomizationLevel = filter.CustomizationLevel.Value;
            }

            if ((string.IsNullOrWhiteSpace(PrimaryEntity) || PrimaryEntity.Equals("none")) &&
                (string.IsNullOrWhiteSpace(SecondaryEntity) || SecondaryEntity.Equals("none")))
            {
                Availability = CrmPluginStepDeployment.Both;
            }
            else
            {
                Availability = (CrmPluginStepDeployment)Enum.ToObject(typeof(CrmPluginStepDeployment),
                                                                      filter.Availability.GetValueOrDefault());
            }

            CreatedOn  = filter.CreatedOn;
            ModifiedOn = filter.ModifiedOn;
        }
Exemplo n.º 8
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            ViewName = "CommonUpdate";

            DynamicUpdatePanelCore.AddColumns(GetColumns());
            SuperKey = ApplicationCommon.GetSuperKey();
            SetId    = ApplicationCommon.GetSetId();

            var results = GetEntityData(null).Clone();

            if (!string.IsNullOrEmpty(SuperKey))
            {
                var lstEntityKeys = ApplicationCommon.GetSuperKeyDetails(PrimaryEntity.Value(), SuperKey);

                foreach (var entityKey in lstEntityKeys)
                {
                    var dt = GetEntityData(entityKey);
                    if (dt.Rows.Count == 1)
                    {
                        results.ImportRow(dt.Rows[0]);
                    }
                }
            }
            else
            {
                var dt = GetEntityData(SetId);
                if (dt.Rows.Count == 1)
                {
                    results.ImportRow(dt.Rows[0]);
                }
            }
            SelectedData = results.Copy();

            DynamicUpdatePanelCore.SetUp(GetColumns(), PrimaryEntityKey, GetData());
        }
Exemplo n.º 9
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SuperKey = ApplicationCommon.GetSuperKey();

            if (!string.IsNullOrEmpty(SuperKey))
            {
                var lstEntityKeys = ApplicationCommon.GetSuperKeyDetails(PrimaryEntity.Value(), SuperKey);

                foreach (var entityKey in lstEntityKeys)
                {
                    AddDetailControl(false, entityKey);
                }

                return;
            }

            SetId = ApplicationCommon.GetSetId();
            if (SetId != 0)
            {
                AddDetailControl(true, SetId);
            }
        }
Exemplo n.º 10
0
 public virtual void AddPrimary(PrimaryEntity entity)
 {
     TopLevelClosure.Value.PutData(entity);
     BottomLevelClosure.Value.PutData(entity);
 }
Exemplo n.º 11
0
 public bool HasSpecificPrimary(PrimaryEntity entity)
 {
     return((TopLevelClosure?.Value?.Collected?.Contains(entity) ?? false) ||
            (BottomLevelClosure?.Value?.Collected?.Contains(entity) ?? false));
 }
Exemplo n.º 12
0
 public void Fire(PrimaryEntity entity)
 {
     OnNewPrimaryAdded?.Invoke(entity);
 }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension <ITracingService>();

            tracer.Trace("Inicialize context");
            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();

            //Create an Organization Service
            tracer.Trace("Inicialize serviceFactory");
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();

            tracer.Trace("Inicialize orgService");
            IOrganizationService orgService = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

            //Registered Step Guid
            var pluginStepGuid = Guid.Empty;

            try
            {
                //Plugin Step object
                tracer.Trace("Inicialize pluginStep");
                CrmPluginStep pluginStep = new CrmPluginStep();

                pluginStep.PrimaryEntity = PrimaryEntity.Get <string>(executionContext);
                tracer.Trace("PrimaryEntity: " + pluginStep.PrimaryEntity);

                pluginStep.PluginAssemblyName = AssemblyName.Get <string>(executionContext);
                tracer.Trace("PluginAssemblyName: " + pluginStep.PluginAssemblyName);

                pluginStep.EventHandler = EventHandler.Get <string>(executionContext);
                tracer.Trace("EventHandler: " + pluginStep.EventHandler);

                pluginStep.Mode = Mode.Get <int>(executionContext);
                tracer.Trace("Mode: " + pluginStep.Mode);

                pluginStep.Rank = Rank.Get <int>(executionContext);
                tracer.Trace("Rank: " + pluginStep.Rank);

                pluginStep.FilteringAttributes = FilteringAttributes.Get <string>(executionContext);
                tracer.Trace("FilteringAttributes: " + pluginStep.FilteringAttributes);

                pluginStep.InvocationSource = InvocationSource.Get <int>(executionContext);
                tracer.Trace("InvocationSource: " + pluginStep.InvocationSource);

                pluginStep.Stage = Stage.Get <int>(executionContext);
                tracer.Trace("Stage: " + pluginStep.Stage);

                pluginStep.Deployment = Deployment.Get <int>(executionContext);
                tracer.Trace("Deployment: " + pluginStep.Deployment);

                pluginStep.Message = Message.Get <string>(executionContext);
                tracer.Trace("Message: " + pluginStep.Message);

                pluginStep.Name = pluginStep.EventHandler + ": " + pluginStep.Message + " of " + pluginStep.PrimaryEntity;
                tracer.Trace("Name: " + pluginStep.Name);

                pluginStep.tracer = tracer;

                tracer.Trace("--- Register Plugin Step --- ");
                //Register Step
                pluginStepGuid = pluginStep.RegisterPluginStep(ref orgService);

                tracer.Trace("pluginStepGuid: " + pluginStepGuid);
                PluginStepGuid.Set(executionContext, pluginStepGuid.ToString());
            }
            catch (Exception e)
            {
                throw new InvalidPluginExecutionException("(RegisterPluginStep) Error! " + e.Message);
            }
        }
Exemplo n.º 14
0
        public ActionResult PrimaryPageView(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var expertiseStage = new ExpertiseStageRepository().GetById(id);

            if (expertiseStage == null)
            {
                return(HttpNotFound());
            }
            var primaryRepository = new DrugPrimaryRepository();
            var ntd = primaryRepository.GetPrimaryNtdByDeclarationId(expertiseStage.DeclarationId);

            if (ntd == null)
            {
                ntd = new EXP_DrugPrimaryNTD
                {
                    DrugDeclarationId   = expertiseStage.DeclarationId,
                    EXP_DrugDeclaration = expertiseStage.EXP_DrugDeclaration
                };
            }
            var repository = new ReadOnlyDictionaryRepository();

            ViewData["TypeNDList" + expertiseStage.DeclarationId] = new SelectList(repository.GetDicTypeNDs(), "Id", "NameRu",
                                                                                   ntd.TypeNDId);
            ViewData["TypeFileNDList" + expertiseStage.DeclarationId] = new SelectList(repository.GetDicTypeFileNDs(), "Id", "NameRu",
                                                                                       ntd.TypeFileNDId);

            var model = new PrimaryEntity
            {
                EXP_DrugPrimaryNTD  = ntd,
                EXP_DrugDeclaration = expertiseStage.EXP_DrugDeclaration,
                DrugDeclarationId   = expertiseStage.DeclarationId.ToString(),
                Applicant           = new EmployeesRepository().GetById(expertiseStage.EXP_DrugDeclaration.OwnerId),
                Editor = UserHelper.GetCurrentEmployee(),
                ExpExpertiseStageRemarks = new List <EXP_ExpertiseStageRemark>(),
                ExpDrugPrimaryKinds      = primaryRepository.GetPrimaryKindList(expertiseStage.DeclarationId),
                ExpeditedType            = expertiseStage.EXP_DrugDeclaration.ExpeditedType,
                ExpStageId   = expertiseStage.Id,
                CurrentStage = new StageModel()
                {
                    CurrentStage = GetExpertiseStage(expertiseStage.Id),
                    StageResults = repository.GetStageResultsByStage(expertiseStage.StageId)
                }
            };
            var employeName = "";

            if (UserHelper.GetCurrentEmployee() != null)
            {
                employeName = UserHelper.GetCurrentEmployee().DisplayName;
            }
            ViewBag.CurrentEmployeeName = employeName;
            var markList    = primaryRepository.GetPrimaryMarkList(expertiseStage.DeclarationId, CodeConstManager.STAGE_PRIMARY);
            var remarkTypes = repository.GetRemarkTypes().ToArray();

            ViewData["RemarkTypes" + model.DrugDeclarationId] = new SelectList(remarkTypes, "Id", "NameRu",
                                                                               null);
            foreach (var expDrugPrimaryRemark in markList)
            {
                model.ExpExpertiseStageRemarks.Add(expDrugPrimaryRemark);
            }
            foreach (var expDrugPrimaryRemark in model.ExpExpertiseStageRemarks)
            {
                ViewData["RemarkTypes" + model.DrugDeclarationId + "_" + expDrugPrimaryRemark.Id] = new SelectList(remarkTypes, "Id", "NameRu",
                                                                                                                   expDrugPrimaryRemark.RemarkTypeId);
            }
            model.ExpDrugCorespondences = primaryRepository.GetDrugCorespondences(expertiseStage.DeclarationId);


            return(PartialView(model));
        }
        private void SetMessageEntityId(ref IOrganizationService service)
        {
            Entity message = RetrieveEntity(ref service, "sdkmessagefilter", new string[] { "sdkmessageid", "primaryobjecttypecode" }, new string[] { MessageId.ToString(), PrimaryEntity.ToLower() }, new ColumnSet(true), ConditionOperator.Equal);

            if (message != null)
            {
                MessageEntityId = message.Id;
            }
        }
Exemplo n.º 16
0
        protected void FillDeclarationControl(EXP_DrugDeclaration model)
        {
            model.EditorId            = UserHelper.GetCurrentEmployee().Id.ToString();
            model.ExpDrugExportTrades = new List <EXP_DrugExportTrade>();
            var exportTrades = model.EXP_DrugExportTrade.OrderBy(e => e.Id);

            foreach (var record in exportTrades)
            {
                model.ExpDrugExportTrades.Add(record);
            }

            model.ExpDrugPatents = new List <EXP_DrugPatent>();
            var expPatent = model.EXP_DrugPatent.OrderBy(e => e.Id);

            foreach (var record in expPatent)
            {
                model.ExpDrugPatents.Add(record);
            }

            model.ExpDrugTypes = new List <EXP_DrugType>();
            var expDrugType = model.EXP_DrugType.OrderBy(e => e.Id);

            foreach (var record in expDrugType)
            {
                model.ExpDrugTypes.Add(record);
            }

            /*     model.ExpDrugWrappings = new List<EXP_DrugWrapping>();
             *   var expDrugWrapping = model.EXP_DrugWrapping.OrderBy(e => e.Id);
             *   foreach (var record in expDrugWrapping)
             *   {
             *       model.ExpDrugWrappings.Add(record);
             *   }*/

            model.ExpDrugOtherCountries = new List <EXP_DrugOtherCountry>();
            var expDrugOtherCountries = model.EXP_DrugOtherCountry.OrderBy(e => e.Id);

            foreach (var record in expDrugOtherCountries)
            {
                model.ExpDrugOtherCountries.Add(record);
            }
            model.ExpDrugProtectionDocs = new List <EXP_DrugProtectionDoc>();
            var expDrugProtectionDocs = model.EXP_DrugProtectionDoc.OrderBy(e => e.Id);

            foreach (var record in expDrugProtectionDocs)
            {
                model.ExpDrugProtectionDocs.Add(record);
            }
            model.ExpDrugOrganizationses = new List <EXP_DrugOrganizations>();
            var expDrugOrganizationses = model.EXP_DrugOrganizations.OrderBy(e => e.Id);

            foreach (var record in expDrugOrganizationses)
            {
                model.ExpDrugOrganizationses.Add(record);
            }
            model.ExpDrugDosages = new List <EXP_DrugDosage>();
            var expDrugDosages = model.EXP_DrugDosage.OrderBy(e => e.Id);

            model.ConclusionSafetyReports = new List <ConclusionSafetyReport>();
            foreach (var record in expDrugDosages)
            {
                if (record.RegisterId > 0 && record.sr_register != null)
                {
                    record.ReestrNumber  = record.sr_register.reg_number + "/" + record.sr_register.reg_number_kz;
                    record.ReestrRegDate = record.sr_register.reg_date.ToShortDateString();
                    if (record.sr_register.expiration_date != null)
                    {
                        record.ReestrExpirationDate = record.sr_register.expiration_date.Value.ToShortDateString();
                    }
                    var reestrDrug = new ExternalRepository().GEtRegisterDrugById(record.RegisterId);
                    if (reestrDrug != null)
                    {
                        record.NumberNd = reestrDrug.nd_number;
                    }
                }
                record.ExpDrugWrappings = new List <EXP_DrugWrapping>();
                foreach (var expDrugWrapping in record.EXP_DrugWrapping)
                {
                    record.ExpDrugWrappings.Add(expDrugWrapping);
                }
                record.ExpDrugPrices = new List <EXP_DrugPrice>();
                foreach (var drugPrice in record.EXP_DrugPrice)
                {
                    record.ExpDrugPrices.Add(drugPrice);
                }
                model.ExpDrugDosages.Add(record);

                record.ExpDrugSubstances = new List <EXP_DrugSubstance>();

                for (var d = 0; d < record.EXP_DrugSubstance.Count; d++)
                {
                    record.ExpDrugSubstances.Add(record.EXP_DrugSubstance.ToList()[d]);
                    record.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures = new List <EXP_DrugSubstanceManufacture>();
                    foreach (var expDrugSubstanceManufacture in record.EXP_DrugSubstance.ToList()[d].EXP_DrugSubstanceManufacture)
                    {
                        record.EXP_DrugSubstance.ToList()[d].ExpDrugSubstanceManufactures.Add(expDrugSubstanceManufacture);
                    }
                }

                /*      foreach (var substance in record.EXP_DrugSubstance)
                 *    {
                 *        record.ExpDrugSubstances.Add(substance);
                 *
                 *    }*/

                if (model.StatusId > 6)
                {
                    model.ConclusionSafetyReports.Add(new SafetyreportRepository().ConclusionSafetyReportsFromDosage(record.Id, false));
                    model.ConclusionSafetyReports.Add(new SafetyreportRepository().ConclusionSafetyReportsFromDosage(record.Id, true));
                }
            }
            if (model.StatusId > 6)
            {
                var item = new SafetyreportRepository().ConclusionSafetyReportsFromFiles(model.Id, UserHelper.GetCurrentEmployee());
                foreach (var conclusionSafetyReport in item)
                {
                    model.ConclusionSafetyReports.Add(conclusionSafetyReport);
                }
            }
            if (model.ConclusionSafetyReports.Count > 0)
            {
                model.IsShowConclision = true;
            }
            model.ExpDrugChangeTypes = new List <EXP_DrugChangeType>();
            var changeTypes = model.EXP_DrugChangeType.OrderBy(e => e.Id);

            foreach (var record in changeTypes)
            {
                model.ExpDrugChangeTypes.Add(record);
            }

            /*  model.ExpDrugPrices = new List<EXP_DrugPrice>();
             * var expDrugPrices = model.EXP_DrugPrice.OrderBy(e => e.Id);
             * foreach (var record in expDrugPrices)
             * {
             *    model.ExpDrugPrices.Add(record);
             * }*/
            model.MethodUseIds =
                model.EXP_DrugUseMethod.Select(e => e.UseMethodsId.ToString(CultureInfo.InvariantCulture)).ToList();

            if (model.TypeId > 1)
            {
                if (model.TypeId == 3)
                {
                    model.IsShowChange = true;
                }
                else
                {
                    if (model.sr_register != null && model.sr_register.expiration_date != null)
                    {
                        if (model.TypeId != 2)
                        {
                            var t     = model.sr_register.expiration_date.Value - model.CreatedDate;
                            var month = t.TotalDays;

                            if (month > 90)
                            {
                                model.IsShowChange = true;
                            }
                        }
                    }
                }
            }

            var primaryEntity = new PrimaryEntity
            {
                EXP_DrugDeclaration = model,
                DrugDeclarationId   = model.ObjectId,
                Editor = UserHelper.GetCurrentEmployee(),
                ExpExpertiseStageRemarks = new List <EXP_ExpertiseStageRemark>(),
            };

            FillViewBag(model);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();
            ITracingService t = tracingService;

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace("Entered DeleteEntity.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                                 executionContext.ActivityInstanceId,
                                 executionContext.WorkflowInstanceId);

            // Create the context
            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();

            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            tracingService.Trace("DeleteEntity.Execute(), Correlation Id: {0}, Initiating User: {1}",
                                 context.CorrelationId,
                                 context.InitiatingUserId);

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                // Courtesy of Gonzalo Ruiz https://crm2011workflowutils.codeplex.com/
                if (PrimaryEntity.Get(executionContext))
                {
                    t.Trace("Deleting process primary entity");
                    service.Delete(context.PrimaryEntityName, context.PrimaryEntityId);
                }
                else
                {
                    string relatedAttribute = RelatedAttributeName.Get(executionContext);
                    if (string.IsNullOrEmpty(relatedAttribute))
                    {
                        Helpers.Throw("If deleting related entity, related attribute name must be specified in the process delete step configuration");
                    }

                    // Retrieve primary entity with the required attribute
                    t.Trace("Retrieving process primary entity");
                    Entity primaryEntity = service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet(relatedAttribute));

                    if (primaryEntity.Contains(relatedAttribute))
                    {
                        EntityReference reference = primaryEntity[relatedAttribute] as EntityReference;
                        if (reference == null)
                        {
                            Helpers.Throw(string.Format("The attribute {0} on entity {1} is expected to be of EntityReference type",
                                                        relatedAttribute, context.PrimaryEntityName));
                        }

                        t.Trace("Deleting entity related to primary entity by attribute " + relatedAttribute);
                        service.Delete(reference.LogicalName, reference.Id);
                    }
                }
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }

            tracingService.Trace("Exiting DeleteEntity.Execute(), Correlation Id: {0}", context.CorrelationId);
        }