示例#1
0
        //public bool DeleteAll( Entity parent, ref SaveStatus status )
        //{
        //	bool isValid = true;
        //	//Entity parent = EntityManager.GetEntity( parentUid );
        //	if ( parent == null || parent.Id == 0 )
        //	{
        //		status.AddError( thisClassName + ".DeleteAll Error - the provided target parent entity was not provided." );
        //		return false;
        //	}
        //	using ( var context = new EntityContext() )
        //	{
        //		context.HoldersProfile.RemoveRange( context.HoldersProfile.Where( s => s.EntityId == parent.Id ) );
        //		int count = context.SaveChanges();
        //		if ( count > 0 )
        //		{
        //			isValid = true;
        //		}
        //		else
        //		{
        //			//if doing a delete on spec, may not have been any properties
        //		}
        //	}

        //	return isValid;
        //}
        /// <summary>
        /// Parts:
        /// - Jurisdiction
        /// - DataSetProfile
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            bool   isAllValid    = true;
            Entity relatedEntity = EntityManager.GetEntity(entity.RowId);

            if (relatedEntity == null || relatedEntity.Id == 0)
            {
                status.AddError("Error - the related Entity was not found.");
                return(false);
            }

            //JurisdictionProfile
            Entity_JurisdictionProfileManager jpm = new Entity_JurisdictionProfileManager();

            //do deletes - NOTE: other jurisdictions are added in: UpdateAssertedIns
            jpm.DeleteAll(relatedEntity, ref status);
            if (!jpm.SaveList(entity.Jurisdiction, entity.RowId, Entity_JurisdictionProfileManager.JURISDICTION_PURPOSE_SCOPE, ref status))
            {
                isAllValid = false;
            }
            //datasetProfiles
            if (!new DataSetProfileManager().SaveList(entity.RelevantDataSet, relatedEntity, ref status))
            {
                isAllValid = false;
            }

            return(isAllValid);
        }
        public async Task <SaveStatus> RegisterUser(RegisterIDTO objRegister)
        {
            try
            {
                using (IDbConnection conn = Connection)
                {
                    var param = new DynamicParameters();
                    param.Add("@FirstName", objRegister.FirstName, DbType.String, direction: ParameterDirection.Input);
                    param.Add("@LastName", objRegister.LastName, DbType.String, direction: ParameterDirection.Input);
                    param.Add("@Email", objRegister.loginDetails.Email, DbType.String, direction: ParameterDirection.Input);
                    param.Add("@Password", EncodeDecodeBase64.Base64Encode(objRegister.loginDetails.Password), DbType.String, direction: ParameterDirection.Input);
                    param.Add("@ReturnValue", DbType.Int32, direction: ParameterDirection.ReturnValue);


                    await conn.ExecuteAsync("usp_RegisterUser", param, commandType : CommandType.StoredProcedure);

                    var        retValue = param.Get <int>("@ReturnValue");
                    SaveStatus status   = (SaveStatus)retValue;
                    return(status);
                }
            }
            catch (Exception e)
            {
                return(SaveStatus.Failure);
            }
        }
示例#3
0
        public bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            status.HasSectionErrors = false;
            Entity relatedEntity = EntityManager.GetEntity(entity.RowId);

            if (relatedEntity == null || relatedEntity.Id == 0)
            {
                status.AddError("Error - the related Entity was not found.");
                return(false);
            }

            //ConditionProfile
            Entity_ConditionProfileManager emanager = new Entity_ConditionProfileManager();

            //deleteall is handled in SaveList
            //emanager.DeleteAll( relatedEntity, ref status );

            emanager.SaveList(entity.Requires, Entity_ConditionProfileManager.ConnectionProfileType_Requirement, entity.RowId, ref status);
            emanager.SaveList(entity.Recommends, Entity_ConditionProfileManager.ConnectionProfileType_Recommendation, entity.RowId, ref status);
            emanager.SaveList(entity.Corequisite, Entity_ConditionProfileManager.ConnectionProfileType_Corequisite, entity.RowId, ref status);
            emanager.SaveList(entity.EntryCondition, Entity_ConditionProfileManager.ConnectionProfileType_EntryCondition, entity.RowId, ref status);
            emanager.SaveList(entity.Renewal, Entity_ConditionProfileManager.ConnectionProfileType_Renewal, entity.RowId, ref status);

            return(status.WasSectionValid);
        }         //
示例#4
0
        public bool ValidateProfile(ThisEntity profile, ref bool isEmpty, ref SaveStatus status)
        {
            status.HasSectionErrors = false;

            isEmpty = false;

            if (string.IsNullOrWhiteSpace(profile.Description))
            {
                status.AddWarning("A profile description must be entered");
            }

            if (!IsUrlValid(profile.SubjectWebpage, ref commonStatusMessage))
            {
                status.AddWarning("The Subject Webpage Url is invalid. " + commonStatusMessage);
            }
            if (!IsUrlValid(profile.VerificationServiceUrl, ref commonStatusMessage))
            {
                status.AddWarning("The Verification Service Url is invalid. " + commonStatusMessage);
            }
            if (!IsUrlValid(profile.VerificationDirectory, ref commonStatusMessage))
            {
                status.AddWarning("The Verification Directory Url is invalid. " + commonStatusMessage);
            }

            return(!status.HasSectionErrors);
        }
示例#5
0
        private void ctrProductIdentity1_UpdateProductIdentityClick(SaveStatus saveStatus)
        {
            string a = iDTextBox.Text;
            string b = a;
            string c = b;

            if (saveStatus == SaveStatus.Temporary)
            {
                Save();
                LogJobAdapter.SaveLog(JobName.FrmManagerProduct_LuuTam, "Ấn nút lưu tạm", Common.Obj2Int64(iDTextBox.Text), (int)JobTypeData.Product);
            }
            if (saveStatus == SaveStatus.Complete)
            {
                //config thành công
                this.cboStatus.SelectedValue = (byte)QT.Entities.Common.ProductStatus.SPGocConfig;
                if (!Save())
                {
                    MessageBox.Show("Xảy ra lỗi!");
                }
                else
                {
                    this.ctrProductIdentity1.UpdateRootID();
                    LogJobAdapter.SaveLog(JobName.FrmManagerProduct_Luu, "Ấn nút lưu phân tích dữ liệu", Common.Obj2Int64(iDTextBox.Text), (int)JobTypeData.Product);
                }
            }
        }
示例#6
0
文件: Save.cs 项目: Arekva/winecrash
        public static SaveStatus CheckIntegrity(string path, out Save save)
        {
            SaveStatus status = File.Exists(System.IO.Path.Combine(path, SaveInfoConfig.RelativePath)) ? SaveStatus.Created : SaveStatus.Unknown;

            if (File.Exists(System.IO.Path.Combine(path, SaveInfoConfig.RelativePath)))
            {
                try
                {
                    save    = new Save(path.Split('\\', '/').Last(), true);
                    status |= SaveStatus.Sane;

                    if (save.Informations.Version < Winecrash.Version)
                    {
                        status |= SaveStatus.OutOfDate;
                    }
                }
                catch (Exception e)
                {
                    save    = null;
                    status |= SaveStatus.Corrupted;
                }
            }

            else
            {
                save    = null;
                status |= SaveStatus.Corrupted;
            }
            return(status);
        }
示例#7
0
        private bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            bool isAllValid = true;

            EntityPropertyManager mgr = new EntityPropertyManager();

            if (mgr.AddProperties(entity.ClaimType, entity.RowId, CodesManager.ENTITY_TYPE_PROCESS_PROFILE, CodesManager.PROPERTY_CATEGORY_CLAIM_TYPE, false, ref status) == false)
            {
                isAllValid = false;
            }

            //CostProfile
            CostProfileManager cpm = new Factories.CostProfileManager();

            cpm.SaveList(entity.EstimatedCost, entity.RowId, ref status);

            int newId = 0;

            if (entity.TargetCredentialIds != null && entity.TargetCredentialIds.Count > 0)
            {
                Entity_CredentialManager ecm = new Entity_CredentialManager();
                foreach (int id in entity.TargetCredentialIds)
                {
                    ecm.Add(entity.RowId, id, ref newId, ref status);
                }
            }

            return(isAllValid);
        }
示例#8
0
        private bool ValidateProfile(PathwaySet profile, ref SaveStatus status, bool validatingUrls = true)
        {
            status.HasSectionErrors = false;

            if (string.IsNullOrWhiteSpace(profile.Name))
            {
                status.AddError("Error: A PathwaySet Name is required.");
            }
            if (!IsGuidValid(profile.OwningAgentUid))
            {
                //first determine if this is populated in edit mode
                status.AddError("An owning organization must be provided.");
            }

            if (string.IsNullOrWhiteSpace(profile.Description))
            {
                status.AddWarning("A PathwaySet Description must be entered");
            }
            if (string.IsNullOrWhiteSpace(profile.SubjectWebpage))
            {
                status.AddError("A Subject Webpage name must be entered");
            }

            else if (validatingUrls && !IsUrlValid(profile.SubjectWebpage, ref commonStatusMessage))
            {
                status.AddError("The PathwaySet Subject Webpage is invalid. " + commonStatusMessage);
            }


            return(status.WasSectionValid);
        }
示例#9
0
        private AcknowledgementContent GetAcknowledgementContent(SaveStatus saveStatus)
        {
            switch (saveStatus)
            {
            case SaveStatus.AmendAndSend:
                return(new AcknowledgementContent
                {
                    Title = "Cohort sent for review",
                    Text = "Your training provider will review your cohort and contact you as soon as possible."
                });

            case SaveStatus.ApproveAndSend:
                return(new AcknowledgementContent
                {
                    Title = "Cohort approved and sent to training provider",
                    Text = "Your training provider will review your cohort and either confirm the information is correct or contact you to suggest changes."
                });

            case SaveStatus.Save:
                return(new AcknowledgementContent
                {
                    Title = "Message sent",
                    Text =
                        "Your training provider will review your request and contact you as soon as possible - either with questions or to ask you to review the apprentice details they've added."
                });
            }
            return(new AcknowledgementContent());
        }
示例#10
0
        public bool ValidateProfile(ThisEntity profile, ref SaveStatus status)
        {
            status.HasSectionErrors = false;

            //
            if (string.IsNullOrWhiteSpace(profile.FrameworkName))
            {
                status.AddWarning(thisClassName + " - A Framework name must be entered");
            }

            if (!IsUrlValid(profile.Framework, ref commonStatusMessage))
            {
                status.AddWarning(thisClassName + " - The Framework Url is invalid " + commonStatusMessage);
            }

            if (!IsUrlValid(profile.TargetNode, ref commonStatusMessage))
            {
                status.AddWarning(thisClassName + " - The TargetNode Url is invalid " + commonStatusMessage);
            }
            if (!string.IsNullOrWhiteSpace(profile.AlignmentDate) &&
                IsValidDate(profile.AlignmentDate) == false)
            {
                status.AddWarning(thisClassName + " - The Alignment Date is invalid ");
            }

            return(!status.HasSectionErrors);
        }
示例#11
0
        public bool SaveList(List <ThisEntity> list, Guid parentUid, ref SaveStatus status)
        {
            if (!IsValidGuid(parentUid))
            {
                status.AddError(string.Format("A valid parent identifier was not provided to the {0}.Add method.", thisClassName));
                return(false);
            }

            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                status.AddError("Error - the parent entity was not found.");
                return(false);
            }
            DeleteAll(parent, ref status);

            if (list == null || list.Count == 0)
            {
                return(true);
            }

            bool isAllValid = true;

            foreach (ThisEntity item in list)
            {
                Save(item, parent, ref status);
            }

            return(isAllValid);
        }
        }         //

        #endregion
        #endregion

        #region GeoCoordinate  =======================
        #region GeoCoordinate Core  =======================


        public int GeoCoordinates_Add(MC.GeoCoordinates entity, int jpId, ref SaveStatus status)
        {
            if (entity == null || string.IsNullOrWhiteSpace(entity.GeoURI))
            {
                return(0);
            }
            entity.ParentId = jpId;
            EM.GeoCoordinate  efEntity = new EM.GeoCoordinate();
            MC.GeoCoordinates existing = new MC.GeoCoordinates();
            List <String>     messages = new List <string>();

            //extract from "http://geonames.org/6255149/"
            string geoNamesId = UtilityManager.ExtractNameValue(entity.GeoURI, ".org", "/", "/");

            if (IsInteger(geoNamesId))
            {
                entity.GeoNamesId = Int32.Parse(geoNamesId);
            }

            if (GeoCoordinates_Exists(entity.ParentId, entity.GeoNamesId, entity.IsException))
            {
                status.AddWarning("Error this Region has aleady been selected.");
                return(0);
            }

            else
            {
                MapToDB(entity, efEntity);
                //ensure parent jp Id is present
                return(GeoCoordinate_Add(efEntity, ref status));
            }
        }
示例#13
0
        /// <summary>
        /// Save list of assertions
        /// TODO - need to handle change of owner. The old owner is not being deleted.
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="roleId"></param>
        /// <param name="targetUids"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool SaveList(int parentId, int roleId, List <Guid> targetUids, ref SaveStatus status)
        {
            if (targetUids == null || targetUids.Count == 0 || roleId < 1)
            {
                return(true);
            }
            Entity parentEntity = EntityManager.GetEntity(parentId);
            Entity_AgentRelationshipManager emgr = new Entity_AgentRelationshipManager();
            var  searchPendingReindexManager     = new SearchPendingReindexManager();
            var  messages   = new List <string>();
            bool isAllValid = true;

            foreach (Guid targetUid in targetUids)
            {
                Entity targetEntity = EntityManager.GetEntity(targetUid);

                Save(parentId, targetUid, roleId, ref status);

                //check for add to AgentRelationship, if present
                //we don't know what the target is, so can't create a pending record!!!
                //NO SHOULD NOT DO THIS, OTHERWISE HAVE DIRECT AND INDIRECT FROM ONE TRANSACTION
                //20-11-20 mp	- scenario is that QA org adds assertion, which may not exist from target perspecitive
                //				- so this does need to happen. What are the cautions?
                //				- or don't do explicitly, and have the search handle both sides!
                //21-02-02 mp - need to add all targets to be reindexed.
                if (targetEntity.Id > 0)
                {
                    emgr.Save(targetEntity.Id, parentEntity.EntityUid, roleId, ref status);

                    searchPendingReindexManager.Add(targetEntity.EntityTypeId, targetEntity.EntityBaseId, 1, ref messages);
                }
                ;
            }
            return(isAllValid);
        } //
 private void saveError()
 {
     saveStatus = SaveStatus.COMPLETE;
     SetInteractable(isInteractable: true);
     Service.Get <PromptManager>().ShowPrompt("SaveEquipmentFailPrompt", onFailPromptClose);
     isItemSaving = false;
 }
示例#15
0
        public bool ValidateProfile(ThisEntity profile, ref bool isEmpty, ref SaveStatus status)
        {
            status.HasSectionErrors = false;

            isEmpty = false;
            //check if empty

            //&& ( profile.EstimatedCost == null || profile.EstimatedCost.Count == 0 )
            if (string.IsNullOrWhiteSpace(profile.ProfileName))
            {
                status.AddError("A Condition Manifest name must be entered");
            }
            if (string.IsNullOrWhiteSpace(profile.Description))
            {
                status.AddWarning("A Condition Manifest Description must be entered");
            }

            //not sure if this will be selected, or by context
            if (!IsValidGuid(profile.OwningAgentUid))
            {
                status.AddError("An owning organization must be selected");
            }

            if (!IsUrlValid(profile.SubjectWebpage, ref commonStatusMessage))
            {
                status.AddWarning("The Subject Webpage Url is invalid " + commonStatusMessage);
            }

            return(!status.HasSectionErrors);
        }
        public bool SaveList(List <int> list, Guid parentUid, ref SaveStatus status)
        {
            //first do a deleteAll
            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                status.AddError("Error - the parent entity was not found.");
                return(false);
            }
            DeleteAll(parent, ref status);

            if (list == null || list.Count == 0)
            {
                return(true);
            }

            bool isAllValid = true;

            foreach (int item in list)
            {
                Save(parent, item, ref status);
            }

            return(isAllValid);
        }
示例#17
0
 public static MP.TransferValueProfile HandlingExistingEntity(string ctid, ref SaveStatus status)
 {
     MP.TransferValueProfile entity = new MP.TransferValueProfile();
     //warning-
     entity = TransferValueProfileManager.GetByCtid(ctid);
     if (entity != null && entity.Id > 0)
     {
         Entity relatedEntity = EntityManager.GetEntity(entity.RowId);
         if (relatedEntity == null || relatedEntity.Id == 0)
         {
             status.AddError(string.Format("Error - the related Entity for transfer value: '{0}' ({1}), was not found.", entity.Name, entity.Id));
             return(entity);
         }
         //we know for this type, there will entity.learningopp, entity.assessment and entity.credential relationships, and quick likely blank nodes.
         //delete related entity if a reference
         //there are for and from relationships!! - OK in this case it will be all
         new Entity_AssessmentManager().DeleteAll(relatedEntity, ref status);
         new Entity_CredentialManager().DeleteAll(relatedEntity, ref status);
         new Entity_LearningOpportunityManager().DeleteAll(relatedEntity, ref status);
         //also
         entity.TransferValueFor  = new List <TopLevelObject>();
         entity.TransferValueFrom = new List <TopLevelObject>();
     }
     return(entity);
 }
        public bool ProcessEnvelope(ReadEnvelope item, SaveStatus status)
        {
            if (item == null || string.IsNullOrWhiteSpace(item.EnvelopeIdentifier))
            {
                status.AddError("A valid ReadEnvelope must be provided.");
                return(false);
            }

            DateTime createDate         = new DateTime();
            DateTime envelopeUpdateDate = new DateTime();

            if (DateTime.TryParse(item.NodeHeaders.CreatedAt.Replace("UTC", "").Trim(), out createDate))
            {
                status.SetEnvelopeCreated(createDate);
            }
            if (DateTime.TryParse(item.NodeHeaders.UpdatedAt.Replace("UTC", "").Trim(), out envelopeUpdateDate))
            {
                status.SetEnvelopeUpdated(envelopeUpdateDate);
            }
            status.DocumentOwnedBy = item.documentOwnedBy;

            if (item.documentPublishedBy != null)
            {
                if (item.documentOwnedBy == null || (item.documentPublishedBy != item.documentOwnedBy))
                {
                    status.DocumentPublishedBy = item.documentPublishedBy;
                }
            }
            else
            {
                //will need to check elsewhere
                //OR as part of import check if existing one had 3rd party publisher
            }
            string payload            = item.DecodedResource.ToString();
            string envelopeIdentifier = item.EnvelopeIdentifier;
            string ctdlType           = RegistryServices.GetResourceType(payload);
            string envelopeUrl        = RegistryServices.GetEnvelopeUrl(envelopeIdentifier);

            //Already done in  RegistryImport
            //LoggingHelper.WriteLogFile( UtilityManager.GetAppKeyValue( "logFileTraceLevel", 5 ), item.EnvelopeCetermsCtid + "_assessment", payload, "", false );

            if (ImportServiceHelpers.IsAGraphResource(payload))
            {
                //if ( payload.IndexOf( "\"en\":" ) > 0 )
                return(ImportV3(payload, envelopeIdentifier, status));
                //else
                //    return ImportV2( payload, envelopeIdentifier, status );
            }
            else
            {
                status.AddError(thisClassName + ".ImportByResourceUrl - 2019-05-01 ONLY GRAPH BASED IMPORTS ARE HANDLED");
                return(false);

                //LoggingHelper.DoTrace( 5, "		envelopeUrl: " + envelopeUrl );
                //            LoggingHelper.WriteLogFile( 1, "asmt_" + item.EnvelopeIdentifier, payload, "", false );
                //            input = JsonConvert.DeserializeObject<InputEntity>( item.DecodedResource.ToString() );

                //            return Import( input, envelopeIdentifier, status );
            }
        }
示例#19
0
        public bool SaveList(List <ThisEntity> list, Guid parentUid, ref SaveStatus status, bool doingDelete = true)
        {
            if (!IsValidGuid(parentUid))
            {
                status.AddWarning("Error: the parent identifier was not provided.");
                return(false);
            }

            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                status.AddWarning("Error - the parent entity was not found.");
                return(false);
            }
            if (doingDelete)
            {
                DeleteAll(parent, ref status);
            }

            if (list == null || list.Count == 0)
            {
                return(true);
            }

            bool isAllValid = true;

            foreach (ThisEntity item in list)
            {
                Save(item, parentUid, ref status);
            }

            return(isAllValid);
        }
示例#20
0
        public ActionResult Edit(VacationsModel VacationObj)
        {
            ViewData["SBeforeID"] = false;

            if (VacationObj.FromDate > VacationObj.EndDate)
            {
                ModelState.AddModelError("EndDate", "تاريخ انتهاء الاجازة يجب ان يكون اكبر من او يساوى تاريخ البدايه");
            }
            if (ModelState.IsValid)
            {
                SaveStatus SavingStatus = EditVacation(VacationObj);
                if (SavingStatus == SaveStatus.Failed_To_Save)
                {
                    ShowMessage(MessageTypes.Error, "لم يتم الحفظ");
                }
                //else if (SavingStatus == SaveStatus.Saved_Before)
                //{
                //    ViewData["SBeforeID"] = true;
                //    ModelState.AddModelError("", "تم حفظ الاجازة من قبل");
                //}
                if (SavingStatus == SaveStatus.WorkingDay)
                {
                    ShowMessage(MessageTypes.Error, "لا يمكن حفظ اجازة فى يوم عمل");
                }
                else if (SavingStatus == SaveStatus.Saved)
                {
                    ShowMessage(MessageTypes.Success, JIC.Base.Resources.Messages.OperationCompletedSuccessfully);
                }
            }

            return(View(VacationObj));
        }
        public bool UpdateModifiedDate(Guid entityUid, ref SaveStatus status)
        {
            bool isValid = false;

            if (!IsValidGuid(entityUid))
            {
                status.AddError(thisClassName + ".UpdateModifiedDate(). Error - missing a valid identifier for the Entity");
                return(false);
            }
            using (var context = new EntityContext())
            {
                DBentity efEntity = context.Entity
                                    .FirstOrDefault(s => s.EntityUid == entityUid);

                if (efEntity != null && efEntity.Id > 0)
                {
                    efEntity.LastUpdated = DateTime.Now;
                    int count = context.SaveChanges();
                    if (count >= 0)
                    {
                        isValid = true;
                        LoggingHelper.DoTrace(7, thisClassName + string.Format(".UpdateModifiedDate - update last updated for TypeId: {0}, BaseId: {1}", efEntity.EntityTypeId, efEntity.EntityBaseId));
                    }
                }
                else
                {
                    status.AddError(thisClassName + ".UpdateModifiedDate(). Error - Entity  was not found.");
                    LoggingHelper.LogError(thisClassName + string.Format(".UpdateModifiedDate - record was not found. entityUid: {0}", entityUid), true);
                }
            }

            return(isValid);
        }///
示例#22
0
        private bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            bool isAllValid = true;

            //EntityPropertyManager mgr = new EntityPropertyManager();
            Entity_ReferenceManager erm = new Entity_ReferenceManager();

            if (erm.AddTextValue(entity.SocialMediaPages, entity.RowId,
                                 ref status, CodesManager.PROPERTY_CATEGORY_ORGANIZATION_SOCIAL_MEDIA) == false)
            {
                isAllValid = false;
            }


            if (erm.AddTextValue(entity.Emails, entity.RowId, ref status, CodesManager.PROPERTY_CATEGORY_EMAIL_TYPE) == false)
            {
                isAllValid = false;
            }

            if (erm.AddTextValue(entity.PhoneNumbers, entity.RowId,
                                 ref status, CodesManager.PROPERTY_CATEGORY_PHONE_TYPE) == false)
            {
                isAllValid = false;
            }

            return(isAllValid);
        }
        public bool GetEnvelopePayload(ReadEnvelope item, SaveStatus status, ref string payload)
        {
            if (item == null || string.IsNullOrWhiteSpace(item.EnvelopeIdentifier))
            {
                status.AddError("A valid ReadEnvelope must be provided.");
                return(false);
            }
            //
            DateTime createDate         = new DateTime();
            DateTime envelopeUpdateDate = new DateTime();

            if (DateTime.TryParse(item.NodeHeaders.CreatedAt.Replace("UTC", "").Trim(), out createDate))
            {
                status.EnvelopeCreatedDate = createDate;
            }
            if (DateTime.TryParse(item.NodeHeaders.UpdatedAt.Replace("UTC", "").Trim(), out envelopeUpdateDate))
            {
                status.EnvelopeUpdatedDate = envelopeUpdateDate;
            }
            //
            payload = item.DecodedResource.ToString();
            string envelopeIdentifier = item.EnvelopeIdentifier;
            string ctdlType           = RegistryServices.GetResourceType(payload);

            //string envelopeUrl = RegistryServices.GetEnvelopeUrl( envelopeIdentifier );


            return(true);
        }
        /// <summary>
        /// Check if the provided framework has already been sync'd.
        /// If not, it will be added.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="userId"></param>
        /// <param name="messages"></param>
        /// <param name="frameworkId"></param>
        /// <returns></returns>
        //public bool HandleFrameworkRequest( CassFramework request,
        //		int userId,
        //		ref SaveStatus status,
        //		ref int frameworkId )
        //{
        //	bool isValid = true;
        //	if ( request == null || string.IsNullOrWhiteSpace(request._IdAndVersion) )
        //	{
        //		status.AddWarning( "The Cass Request doesn't contain a valid Cass Framework class." );
        //		return false;
        //	}
        //	ThisEntity item = Get( request._IdAndVersion );
        //	if (item != null && item.Id > 0)
        //	{
        //		//TODO - do we want to attempt an update - if changed
        //		//		- if we plan to implement a batch refresh of sync'd content, then not necessary
        //		frameworkId = item.Id;
        //		return true;
        //	}
        //	//add the framework...
        //	ThisEntity entity = new ThisEntity();
        //	entity.Name = request.Name;
        //	entity.Description = request.Description;
        //	entity.FrameworkUrl = request.Url;
        //	entity.RepositoryUri = request._IdAndVersion;

        //	//TDO - need owning org - BUT, first person to reference a framework is not necessarily the owner!!!!!
        //	//actually, we may not care here. Eventually get a ctid from CASS
        //	//entity.OwningOrganizationId = 0;

        //	isValid = Save( entity, userId, ref status );
        //	frameworkId = entity.Id;
        //	return isValid;
        //}


        //actually not likely to have a separate list of frameworks
        //public bool SaveList( List<ThisEntity> list, ref SaveStatus status )
        //{
        //	if ( list == null || list.Count == 0 )
        //		return true;

        //	bool isAllValid = true;
        //	foreach ( ThisEntity item in list )
        //	{
        //		Save( item, ref status );
        //	}

        //	return isAllValid;
        //}

        /// <summary>
        /// Add/Update a Reference_Framework
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="messages"></param>
        /// <returns></returns>
        public bool Save(ThisEntity entity,
                         ref SaveStatus status)
        {
            bool isValid = true;
            int  count   = 0;

            DBEntity efEntity = new DBEntity();

            using (var context = new EntityContext())
            {
                if (ValidateProfile(entity, ref status) == false)
                {
                    return(false);
                }

                if (entity.Id == 0)
                {
                    // - need to check for existance
                    DoesItemExist(entity);
                }

                if (entity.Id == 0)
                {
                    // - Add
                    efEntity = new DBEntity();
                    MapToDB(entity, efEntity);


                    efEntity.Created = DateTime.Now;
                    //efEntity.RowId = Guid.NewGuid();

                    context.Reference_Frameworks.Add(efEntity);

                    count = context.SaveChanges();

                    entity.Id = efEntity.Id;
                    //entity.RowId = efEntity.RowId;
                    if (count == 0)
                    {
                        status.AddWarning(string.Format(" Unable to add Profile: {0} <br\\> ", string.IsNullOrWhiteSpace(entity.Name) ? "no description" : entity.Name));
                    }
                }
                else
                {
                    efEntity = context.Reference_Frameworks.SingleOrDefault(s => s.Id == entity.Id);
                    if (efEntity != null && efEntity.Id > 0)
                    {
                        //entity.RowId = efEntity.RowId;
                        //update
                        MapToDB(entity, efEntity);
                        //has changed?
                        if (HasStateChanged(context))
                        {
                            count = context.SaveChanges();
                        }
                    }
                }
            }
            return(isValid);
        }
示例#25
0
        /// <summary>
        /// For isPartOf, the list is the entity where the credential is a part of.
        /// Get the entity,
        /// </summary>
        /// <param name="parentList">List of credential Ids for the parent where is part of</param>
        /// <param name="parentUid"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool SaveIsPartOfList(List <int> parentList, int credentialId, ref SaveStatus status)
        {
            if (parentList == null || parentList.Count == 0)
            {
                return(true);
            }
            int  newId      = 0;
            bool isAllValid = true;

            foreach (int parentCredentialId in parentList)
            {
                Entity partOfEntity = EntityManager.GetEntity(1, parentCredentialId);
                if (partOfEntity == null || partOfEntity.Id == 0)
                {
                    status.AddError(string.Format(thisClassName + ".SaveIsPartOfList(). Error - the related part Of (parent) credential was not found. parentCredentialId: {0}, credentialId: {1}", parentCredentialId, credentialId));
                    continue;
                }

                Add(partOfEntity, credentialId, BaseFactory.RELATIONSHIP_TYPE_IS_PART_OF, ref newId, ref status);
                if (newId == 0)
                {
                    isAllValid = false;
                }
            }

            return(isAllValid);
        }
示例#26
0
        public bool DeleteAll(Entity parent, ref SaveStatus status)
        {
            bool isValid = true;

            //Entity parent = EntityManager.GetEntity( parentUid );
            if (parent == null || parent.Id == 0)
            {
                status.AddError(thisClassName + ". Error - the provided target parent entity was not provided.");
                return(false);
            }
            using (var context = new EntityContext())
            {
                context.Entity_IdentifierValue.RemoveRange(context.Entity_IdentifierValue.Where(s => s.EntityId == parent.Id));
                int count = context.SaveChanges();
                if (count > 0)
                {
                    isValid = true;
                }
                else
                {
                    //if doing a delete on spec, may not have been any properties
                }
            }

            return(isValid);
        }
示例#27
0
        /// <summary>
        /// Persist Entity Credential
        /// </summary>
        /// <param name="parentUid"></param>
        /// <param name="credentialId"></param>
        /// <param name="relationshipTypeId">1-HasPart; 2-IsPartOf; 3-IsETPLResource</param>
        /// <param name="newId">Return record id of the new record</param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool Add(Guid parentUid, int credentialId, int relationshipTypeId,
                        ref int newId,
                        ref SaveStatus status)
        {
            if (!IsValidGuid(parentUid))
            {
                status.AddError("Error: the parent identifier was not provided.");
            }

            if (credentialId < 1)
            {
                status.AddError("Error: a valid credential was not provided.");
                return(false);
            }

            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                //status.AddError( "Error - the parent entity was not found." );
                return(false);
            }

            return(Add(parent, credentialId, relationshipTypeId, ref newId, ref status));
        }
示例#28
0
    private IEnumerator CheckMatch()
    {
        if (firstRevealed.id == secondRevealed.id)
        {
            score += 2;
            revealed_cards++;
            scoreTxt.text = "SCORE: " + score;
            if (revealed_cards == images.Length)
            {
                globalScore += score;
                Debug.Log("Points Obtained:" + globalScore);
                SaveStatus.Save(globalScore);
                scoreTxt.enabled = false;
                finished         = true;
                returnMenu.SetActive(true);
            }
        }
        else
        {
            yield return(new WaitForSeconds(.5f));

            firstRevealed.Unreveal();
            secondRevealed.Unreveal();
        }
        firstRevealed  = null;
        secondRevealed = null;
    }
示例#29
0
        public bool ProcessEnvelope(ReadEnvelope item, SaveStatus status)
        {
            if (item == null || string.IsNullOrWhiteSpace(item.EnvelopeIdentifier))
            {
                status.AddError("A valid ReadEnvelope must be provided.");
                return(false);
            }

            string payload            = item.DecodedResource.ToString();
            string envelopeIdentifier = item.EnvelopeIdentifier;
            string ctdlType           = RegistryServices.GetResourceType(payload);
            string envelopeUrl        = RegistryServices.GetEnvelopeUrl(envelopeIdentifier);

            if (ImportServiceHelpers.IsAGraphResource(payload))
            {
                //if ( payload.IndexOf( "\"en\":" ) > 0 )
                return(ImportV3(payload, envelopeIdentifier, status));
                //else
                //    return ImportV2( payload, envelopeIdentifier, status );
            }
            else
            {
                LoggingHelper.DoTrace(5, "		envelopeUrl: "+ envelopeUrl);
                LoggingHelper.WriteLogFile(1, "lopp_" + item.EnvelopeIdentifier, payload, "", false);
                input = JsonConvert.DeserializeObject <InputEntity>(item.DecodedResource.ToString());

                return(Import(input, envelopeIdentifier, status));
            }
        }
        public void ImportPendingRecords()
        {
            string where = " [EntityStateId] = 1 ";
            //
            int pTotalRows = 0;

            SaveStatus        status = new SaveStatus();
            List <ThisEntity> list   = AssessmentManager.Search(where, "", 1, 500, ref pTotalRows);

            LoggingHelper.DoTrace(1, string.Format(thisClassName + " - ImportPendingRecords(). Processing {0} records =================", pTotalRows));
            foreach (ThisEntity item in list)
            {
                status = new SaveStatus();
                //SWP contains the resource url
                //pending records will have a  CTID, it should be used to get the envelope!
                //if ( !ImportByResourceUrl( item.SubjectWebpage, status ) )
                if (!ImportByCtid(item.CTID, status))
                {
                    //check for 404
                    LoggingHelper.DoTrace(1, string.Format("     - (). Failed to import pending record: {0}, message(s): {1}", item.Id, status.GetErrorsAsString()));
                }
                else
                {
                    LoggingHelper.DoTrace(1, string.Format("     - (). Successfully imported pending record: {0}", item.Id));
                }
            }
        }
示例#31
0
        public void SaveToPhotosAlbum(SaveStatus status)
        {
            UIImageStatusDispatcher dis = null;
            UIApplication.EnsureUIThread ();

            if (status != null)
                dis = new UIImageStatusDispatcher (status);

            UIImageWriteToSavedPhotosAlbum (Handle, dis != null ? dis.Handle : IntPtr.Zero, dis != null ? Selector.GetHandle (UIImageStatusDispatcher.callbackSelector) : IntPtr.Zero, IntPtr.Zero);
        }
示例#32
0
        public static void SaveToPhotosAlbum(string path, SaveStatus status)
        {
            if (path == null)
                throw new ArgumentNullException ("path");
            if (status == null)
                throw new ArgumentNullException ("status");
            UIApplication.EnsureUIThread ();
            var dis = new UIVideoStatusDispatcher (status);

            using (var ns = new NSString (path))
                UISaveVideoAtPathToSavedPhotosAlbum (ns.Handle, dis.Handle, Selector.GetHandle (UIVideoStatusDispatcher.callbackSelector), IntPtr.Zero);
        }
            public UnloadOrPersistAsyncResult(WorkflowServiceInstance instance, PersistenceOperation operation,
                bool isWorkflowThread, bool isTry, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                // The isTry flag is only true when this is an idle policy initiated persist/unload.
                
                Fx.Assert((isWorkflowThread && !isTry) || !isWorkflowThread, "Either we're the workflow thread and NOT a try or we're not a workflow thread.");

                this.instance = instance;
                this.timeoutHelper = new TimeoutHelper(timeout);
                this.operation = operation;
                this.isWorkflowThread = isWorkflowThread;
                this.isTry = isTry;
                this.tryResult = true;
                this.isUnloaded = (operation == PersistenceOperation.Unload || operation == PersistenceOperation.Delete);
                this.saveStatus = SaveStatus.Locked;
                this.isCompletionTransactionRequired = this.isUnloaded && instance.Controller.State == WorkflowInstanceState.Complete && 
                    instance.creationContext != null && instance.creationContext.IsCompletionTransactionRequired;
                this.isIdlePolicyPersist = isTry && operation == PersistenceOperation.Save;

                if (operation == PersistenceOperation.Unload)
                {
                    this.saveStatus = SaveStatus.Unlocked;
                }
                else if (operation == PersistenceOperation.Delete)
                {
                    this.saveStatus = SaveStatus.Completed;
                }
                else if (operation == PersistenceOperation.Save)
                {
                    SetStartTime();
                }
                
                // Save off the current transaction in case we have an async operation before we end up creating
                // the WorkflowPersistenceContext and create it on another thread. Do a simple clone here to prevent
                // the object referenced by Transaction.Current from disposing before we get around to referencing it
                // when we create the WorkflowPersistenceContext.
                //
                // This will throw TransactionAbortedException by design, if the transaction is already rolled back.
                Transaction currentTransaction = Transaction.Current;
                if (currentTransaction != null)
                {
                    OnCompleting = UnloadOrPersistAsyncResult.completeCallback;
                    this.dependentTransaction = currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                }

                bool completeSelf = true;
                bool success = false;
                try
                {
                    if (this.isWorkflowThread)
                    {
                        Fx.Assert(this.instance.Controller.IsPersistable, "The runtime won't schedule this work item unless we've passed the guard");

                        // We're an internal persistence on the workflow thread which means
                        // that we are passed the guard already, we have the lock, and we know
                        // we aren't detached.

                        completeSelf = OpenProvider();
                    }
                    else
                    {
                        try
                        {
                            completeSelf = LockAndPassGuard();
                        }
                        finally
                        {
                            if (completeSelf)
                            {
                                Fx.Assert(!this.isWorkflowThread, "We should never be calling ReleaseLock if this is the workflow thread.");

                                this.instance.ReleaseLock(ref this.ownsLock, this.isIdlePolicyPersist && this.tryResult);
                            }
                        }
                    }
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        if (this.dependentTransaction != null)
                        {
                            this.dependentTransaction.Complete();
                        }
                    }
                }

                if (completeSelf)
                {
                    Complete(true);
                }
            }
 public UnloadOrPersistAsyncResult(WorkflowServiceInstance instance, WorkflowServiceInstance.PersistenceOperation operation, bool isWorkflowThread, bool isTry, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.instance = instance;
     this.timeoutHelper = new TimeoutHelper(timeout);
     this.operation = operation;
     this.isWorkflowThread = isWorkflowThread;
     this.isTry = isTry;
     this.tryResult = true;
     this.isUnloaded = (operation == WorkflowServiceInstance.PersistenceOperation.Unload) || (operation == WorkflowServiceInstance.PersistenceOperation.Delete);
     this.saveStatus = SaveStatus.Locked;
     this.isCompletionTransactionRequired = ((this.isUnloaded && (instance.Controller.State == WorkflowInstanceState.Complete)) && (instance.creationContext != null)) && instance.creationContext.IsCompletionTransactionRequired;
     this.isIdlePolicyPersist = isTry && (operation == WorkflowServiceInstance.PersistenceOperation.Save);
     if (operation == WorkflowServiceInstance.PersistenceOperation.Unload)
     {
         this.saveStatus = SaveStatus.Unlocked;
     }
     else if (operation == WorkflowServiceInstance.PersistenceOperation.Delete)
     {
         this.saveStatus = SaveStatus.Completed;
     }
     Transaction current = Transaction.Current;
     if (current != null)
     {
         base.OnCompleting = completeCallback;
         this.dependentTransaction = current.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
     }
     bool flag = true;
     bool flag2 = false;
     try
     {
         if (this.isWorkflowThread)
         {
             flag = this.OpenProvider();
         }
         else
         {
             try
             {
                 flag = this.LockAndPassGuard();
             }
             finally
             {
                 if (flag)
                 {
                     this.instance.ReleaseLock(ref this.ownsLock, this.isIdlePolicyPersist);
                 }
             }
         }
         flag2 = true;
     }
     finally
     {
         if (!flag2 && (this.dependentTransaction != null))
         {
             this.dependentTransaction.Complete();
         }
     }
     if (flag)
     {
         base.Complete(true);
     }
 }
            bool Persist()
            {
                IAsyncResult result = null;
                try
                {
                    if (this.operation == PersistenceOperation.Delete)
                    {
                        this.saveStatus = SaveStatus.Completed;
                    }

                    if (this.context == null)
                    {
                        this.context = new WorkflowPersistenceContext(this.instance, (this.pipeline != null && this.pipeline.IsSaveTransactionRequired) || this.isCompletionTransactionRequired,
                            this.dependentTransaction, this.instance.persistTimeout);
                    }

                    using (PrepareTransactionalCall(this.context.PublicTransaction))
                    {
                        result = this.instance.persistenceContext.BeginSave(this.data, this.saveStatus, this.instance.persistTimeout, PrepareInnerAsyncCompletion(persistedCallback), this);
                    }
                }
                catch (InstancePersistenceException)
                {
                    this.updateState = false;
                    throw;
                }
                finally
                {
                    if (result == null && this.context != null)
                    {
                        this.context.Abort();
                    }
                }

                return SyncContinue(result);
            }