示例#1
0
        public override void ExecuteOption(OptionReport report)
        {
            string           urlLoginName           = _databaseCreateImportFromStub.urlLoginName;
            DatabaseSchedule ImportFromStubSchedule = _databaseCreateImportFromStub.ImportFromStubSchedule;

            DatabaseUrlLogin      login = DatabaseUrlLogin.GetUrlLogin(Connection, urlLoginName);
            DynamicsCrmConnection dynamicsCrmConnection = DynamicsCrmConnection.GetConnection(login.Url, login.Username, login.Password);

            List <Campaign> campaigns = Campaign.ReadCampaignsToImportStubDataTo(dynamicsCrmConnection);

            foreach (Campaign campaign in campaigns)
            {
                DatabaseWebCampaign webCampaign = ReadOrCreateWebCampaign(campaign);

                bool importExists = DatabaseImportFromStub.ReadByWebCampaign(Connection, webCampaign).Any();
                if (importExists == false)
                {
                    DatabaseImportFromStub.Create(Connection, webCampaign._id, urlLoginName, campaign.name, ImportFromStubSchedule);
                }
            }

            report.Success = true;

            return;
        }
        public override void ExecuteOption(OptionReport report)
        {
            string urlLoginName            = _databaseMaterialeBehovAssignment.urlLoginName;
            int    updateProgressFrequency = _databaseMaterialeBehovAssignment.updateProgressFrequency;

            DatabaseUrlLogin      login = DatabaseUrlLogin.GetUrlLogin(Connection, urlLoginName);
            DynamicsCrmConnection dynamicsCrmConnection = DynamicsCrmConnection.GetConnection(login.Url, login.Username, login.Password);

            Materiale materiale = Materiale.ReadCalculationNeed(dynamicsCrmConnection, Config.GetResourcePath);

            if (materiale == null)
            {
                report.Success = true;
                return;
            }

            materiale.FindBehovDefinitioner(Config.GetResourcePath);

            int total = CountTotalAccountsToUpdate(dynamicsCrmConnection, materiale);
            int staleMaterialeBehovCount = materiale.CountStaleMaterialeBehov(Config.GetResourcePath);

            total += staleMaterialeBehovCount;

            materiale.new_beregningsstatus = 0;
            materiale.Update();

            materiale.RemoveStaleMaterialeBehov(Config.GetResourcePath, currentProgress => updateProgress(materiale, currentProgress, total), updateProgressFrequency);

            int progress = staleMaterialeBehovCount;
            int materialeAddedCurrent = -1;

            MaterialeProcessState state = new MaterialeProcessState();

            state.pagingInformation  = new PagingInformation();
            state.owningbusinessunit = materiale.owningbusinessunitGuid.Value;

            while (materialeAddedCurrent != 0)
            {
                materiale.AddMissingMateriale(state, Config.GetResourcePath);
                materialeAddedCurrent = state.AccountsProcessed;
                progress += materialeAddedCurrent;
                updateProgress(materiale, progress, total);
            }
            materialeAddedCurrent = -1;

            materiale.behovsberegning      = Materiale.behovsberegningEnum.Afsluttet;
            materiale.new_beregningsstatus = null;
            materiale.Update();

            report.Success = true;
            return;
        }
示例#3
0
        public override void ExecuteOption(OptionReport report)
        {
            string urlLoginName = _databaseExposeData.urlLoginName;
            string fetchXmlPath = _databaseExposeData.fetchXmlPath;
            string exposePath   = _databaseExposeData.exposePath;
            string exposeName   = _databaseExposeData.exposeName;

            DatabaseUrlLogin      login = DatabaseUrlLogin.GetUrlLogin(Connection, urlLoginName);
            DynamicsCrmConnection dynamicsCrmConnection = DynamicsCrmConnection.GetConnection(login.Url, login.Username, login.Password);

            string fullFetchXmlPath = Config.GetResourcePath(fetchXmlPath);
            string fullExposePath   = Config.GetResourcePath(exposePath);

            List <dynamic> dataList = DynamicFetch.ReadFromFetchXml(dynamicsCrmConnection, fullFetchXmlPath, new PagingInformation());

            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                NullValueHandling    = NullValueHandling.Ignore,
                StringEscapeHandling = StringEscapeHandling.EscapeNonAscii,
            };

            string json = JsonConvert.SerializeObject(dataList, Formatting.None, settings);

            json = json.Replace("\\r\\n", "\\n");

            if (Directory.Exists(fullExposePath) == false)
            {
                Directory.CreateDirectory(fullExposePath);
            }

            File.WriteAllText(fullExposePath + "/" + exposeName, json, Encoding.UTF8);

            report.Success = true;

            return;
        }