示例#1
0
        protected override void ExecuteCmdlet()
        {
            var existingTask = PlannerUtility.GetTaskAsync(HttpClient, AccessToken, TaskId, false, false).GetAwaiter().GetResult();

            if (existingTask != null)
            {
                var plannerTask = new PlannerTask();
                if (ParameterSpecified(nameof(Title)))
                {
                    plannerTask.Title = Title;
                }
                if (ParameterSpecified(nameof(Bucket)))
                {
                    var bucket = Bucket.GetBucket(HttpClient, AccessToken, existingTask.PlanId);
                    if (bucket != null)
                    {
                        plannerTask.BucketId = bucket.Id;
                    }
                }
                if (ParameterSpecified(nameof(PercentComplete)))
                {
                    plannerTask.PercentComplete = PercentComplete;
                }
                if (ParameterSpecified(nameof(DueDateTime)))
                {
                    plannerTask.DueDateTime = DueDateTime.ToUniversalTime();
                }
                if (ParameterSpecified(nameof(StartDateTime)))
                {
                    plannerTask.StartDateTime = StartDateTime.ToUniversalTime();
                }
                if (ParameterSpecified(nameof(AssignedTo)))
                {
                    plannerTask.Assignments = new System.Collections.Generic.Dictionary <string, TaskAssignment>();
                    var chunks = BatchUtility.Chunk(AssignedTo, 20);
                    foreach (var chunk in chunks)
                    {
                        var userIds = BatchUtility.GetPropertyBatchedAsync(HttpClient, AccessToken, chunk.ToArray(), "/users/{0}", "id").GetAwaiter().GetResult();
                        foreach (var userId in userIds)
                        {
                            plannerTask.Assignments.Add(userId.Value, new TaskAssignment());
                        }
                    }
                    foreach (var existingAssignment in existingTask.Assignments)
                    {
                        if (plannerTask.Assignments.FirstOrDefault(t => t.Key == existingAssignment.Key).Key == null)
                        {
                            plannerTask.Assignments.Add(existingAssignment.Key, null);
                        }
                    }
                }


                PlannerUtility.UpdateTaskAsync(HttpClient, AccessToken, existingTask, plannerTask).GetAwaiter().GetResult();
            }
            else
            {
                throw new PSArgumentException("Task not found", nameof(TaskId));
            }
        }
示例#2
0
        /// <summary>
        /// Function To Get The Batch Header ID By Calling The Control Totals For Roll Batch
        /// </summary>
        /// <param name="executionID"></param>
        /// <returns></returns>
        public static int[] RetrieveControlTotals(int executionID, Boolean isCurrentAssessmentYear)
        {
            string rollType = string.Empty;

            //int returnValue=0;
            int[] returnValue = new int[2];
            rollType = "SUPPL";


            try
            {
                Database  database   = DatabaseFactory.CreateDatabase();
                string    sqlCommand = "usp_RC_ControlTotalCaller";
                DbCommand dbCommand  = database.GetStoredProcCommand(sqlCommand);
                dbCommand.CommandTimeout = 0;
                database.AddInParameter(dbCommand, "@RollTypeCode", DbType.String, rollType);
                database.AddInParameter(dbCommand, "@IsCurrentYear", DbType.Int32, isCurrentAssessmentYear);
                database.AddInParameter(dbCommand, "@executionID", DbType.Int32, executionID);
                //database.AddInParameter(dbCommand, "@CreatedBy", DbType.String, createdBy);
                database.AddOutParameter(dbCommand, "@returnCode", DbType.Int32, 0);
                database.ExecuteNonQuery(dbCommand);
                returnValue[0] = Convert.IsDBNull(database.GetParameterValue(dbCommand, "returnCode")) ? 0 : Convert.ToInt32(database.GetParameterValue(dbCommand, "returnCode"));
                returnValue[1] = returnValue[0];
            }
            catch (Exception ex)
            {
                BatchUtility.LogMessage(ex.Message + "--" + DateTime.Now.ToString(), executionID, "EXCEP");
            }
            return(returnValue);
        }
示例#3
0
 public void SaveCurrentBatch()
 {
     if (IsBatchSelected)
     {
         BatchUtility.SaveBatch(CurrentBatch);
     }
 }
示例#4
0
        public static async Task <PlannerTask> AddTaskAsync(HttpClient httpClient, string accessToken, string planId, string bucketId, string title, string[] assignedTo = null)
        {
            StringContent stringContent = null;

            if (assignedTo != null)
            {
                var assignments = new Dictionary <string, object>();
                var chunks      = BatchUtility.Chunk(assignedTo, 20);
                foreach (var chunk in chunks)
                {
                    var results = await BatchUtility.GetPropertyBatchedAsync(httpClient, accessToken, chunk.ToArray(), "/users/{0}", "id");

                    foreach (var userid in results.Select(r => r.Value))
                    {
                        assignments.Add(userid, new Model.Planner.PlannerAssignedToUser());
                    }
                }
                stringContent = new StringContent(JsonSerializer.Serialize(new { planId = planId, bucketId = bucketId, title = title, assignments = assignments }));
            }
            else
            {
                stringContent = new StringContent(JsonSerializer.Serialize(new { planId = planId, bucketId = bucketId, title = title }));
            }
            stringContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            return(await GraphHelper.PostAsync <PlannerTask>(httpClient, "v1.0/planner/tasks", stringContent, accessToken));
        }
示例#5
0
        private void AddGravityReading()
        {
            GravityReadingDataModel gravityReading = BatchUtility.CreateGravityReading(CurrentBatch.BatchId);

            gravityReading.PropertyChanged += CurrentBatch.Ingredient_PropertyChanged;
            CurrentBatch.RecordedGravityReadings.Add(gravityReading);
        }
示例#6
0
        private void DeleteBatch(BatchDataModel batch)
        {
            BatchUtility.DeleteBatch(batch);

            if (CurrentBatch == batch)
            {
                int previousBatchIndex = SavedBatches.IndexOf(batch) - 1;
                CurrentBatch = previousBatchIndex >= 0 ? SavedBatches[previousBatchIndex] : SavedBatches.FirstOrDefault();
            }

            SavedBatches.Remove(batch);
        }
示例#7
0
        /// <summary>
        /// Function to export report to byte array
        /// </summary>
        /// <param name="RptServerUrl">Report Server URL</param>
        /// <param name="RptPath">Path at which report resides in the Report Server</param>
        /// <param name="ExportPath">Path where report will be exported temporarily</param>
        /// <param name="ExportFName">Name of the file which has to be generated</param>
        /// <param name="ExportFormat">Format in which report has to be exported</param>
        /// <param name="reportName">Actula name of RDL</param>
        /// <param name="executionID">Execution ID of theb atch generating this report.</param>
        /// <returns></returns>
        public static byte[] ExportReportAs(String RptServerUrl, String RptPath, String ExportPath, String ExportFName, String ExportFormat, string reportName, int executionID, string[] reportParameters)
        {
            byte[]       bytes     = null;
            string       Msg       = string.Empty;
            ReportViewer RptViewer = new ReportViewer();

            try
            {
                RptViewer.ProcessingMode = ProcessingMode.Remote;
                RptViewer.ServerReport.ReportServerUrl = new @Uri(RptServerUrl);
                RptViewer.ServerReport.ReportPath      = RptPath;
                RptViewer.ServerReport.Refresh();
                ReportParameter[] param = null;
                param    = new ReportParameter[reportParameters.Length];
                param[0] = new ReportParameter("BatchHeaderID", reportParameters[0]);
                //param[1] = new ReportParameter("InstallmentNo", reportParameters[1]);

                //param[0] = new ReportParameter("ASSESSMENTYEAR", assessmentYear.ToString());
                //param[1] = new ReportParameter("ExecutionID", executionID);
                //param[2] = new ReportParameter("ROLLDELIVERYNO", rollDeliveryNo);
                //param[3] = new ReportParameter("ROLLDELIVERYNO", rollDeliveryNo);

                RptViewer.ServerReport.SetParameters(param);

                switch (ExportFormat.ToUpper())
                {
                case "PDF": ExportFName += ".pdf";
                    break;

                case "XML": ExportFName += ".xml";
                    break;

                case "EXCEL": ExportFName += ".xls";
                    break;

                case "WORD": ExportFName += ".doc";
                    break;
                }
                Warning[] warnings;
                string[]  streamids;
                string    mimeType, encoding, filenameExtension;
                bytes = RptViewer.ServerReport.Render(ExportFormat, null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
            }
            catch (Exception Ex)
            {
                Msg = "Error Details : " + Ex.Message.ToString();
                BatchUtility.LogMessage(Ex.Message + "--" + DateTime.Now.ToString(), executionID, "EXCEP");
                throw Ex;
            }
            return(bytes);
        }
示例#8
0
        internal static async Task <IEnumerable <Microsoft365Group> > GetGroupsAsync(HttpClient httpClient, string accessToken, bool includeSiteUrl, bool includeOwners)
        {
            var items  = new List <Microsoft365Group>();
            var result = await GraphHelper.GetAsync <RestResultCollection <Microsoft365Group> >(httpClient, "v1.0/groups", accessToken);

            if (result != null && result.Items.Any())
            {
                items.AddRange(result.Items);
                while (!string.IsNullOrEmpty(result.NextLink))
                {
                    result = await GraphHelper.GetAsync <RestResultCollection <Microsoft365Group> >(httpClient, result.NextLink, accessToken);

                    if (result != null && result.Items.Any())
                    {
                        items.AddRange(result.Items);
                    }
                }
            }
            if (includeSiteUrl || includeOwners)
            {
                var chunks = BatchUtility.Chunk(items.Select(g => g.Id.ToString()), 20);
                if (includeOwners)
                {
                    foreach (var chunk in chunks)
                    {
                        var ownerResults = await BatchUtility.GetObjectCollectionBatchedAsync <Microsoft365User>(httpClient, accessToken, chunk.ToArray(), "/groups/{0}/owners");

                        foreach (var ownerResult in ownerResults)
                        {
                            items.First(i => i.Id.ToString() == ownerResult.Key).Owners = ownerResult.Value;
                        }
                    }
                }

                if (includeSiteUrl)
                {
                    foreach (var chunk in chunks)
                    {
                        var results = await BatchUtility.GetPropertyBatchedAsync(httpClient, accessToken, chunk.ToArray(), "/groups/{0}/sites/root", "webUrl");

                        //var results = await GetSiteUrlBatchedAsync(httpClient, accessToken, chunk.ToArray());
                        foreach (var batchResult in results)
                        {
                            items.First(i => i.Id.ToString() == batchResult.Key).SiteUrl = batchResult.Value;
                        }
                    }
                }
            }
            return(items);
        }
示例#9
0
        public BatchesViewModel()
        {
            m_addNewBatchCommand          = new RelayCommand <RecipeDataModel>(AddNewBatch, CanAddNewBatch);
            m_deleteBatchCommand          = new RelayCommand <BatchDataModel>(DeleteBatch);
            m_addGravityReadingCommand    = new RelayCommand(AddGravityReading, CanAddGravityReading);
            m_deleteGravityReadingCommand = new RelayCommand <GravityReadingDataModel>(DeleteGravityReading);

            List <Style> beerStyles = RecipeUtility.GetAvailableBeerStyles().OrderBy(style => style.Name).ToList();

            m_availableRecipes = new ObservableCollection <RecipeDataModel>(RecipeUtility.GetSavedRecipes(beerStyles));
            m_savedBatches     = new ObservableCollection <BatchDataModel>(BatchUtility.GetSavedBatches(m_availableRecipes));

            CurrentBatch = m_savedBatches.FirstOrDefault();
        }
示例#10
0
        public static async Task AddUsersAsync(HttpClient httpClient, string accessToken, string groupId, string[] upn, string role)
        {
            var chunks = BatchUtility.Chunk(upn, 20);

            foreach (var chunk in chunks)
            {
                var results = await BatchUtility.GetPropertyBatchedAsync(httpClient, accessToken, chunk.ToArray(), "/users/{0}", "id");

                var teamChannelMember = new List <TeamChannelMember>();
                foreach (var userid in results.Select(r => r.Value))
                {
                    teamChannelMember.Add(new TeamChannelMember()
                    {
                        Roles = new List <string> {
                            role
                        }, UserIdentifier = $"https://{PnPConnection.Current.GraphEndPoint}/v1.0/users('{userid}')"
                    });
                }
                await GraphHelper.PostAsync(httpClient, $"v1.0/teams/{groupId}/members/add", new { values = teamChannelMember }, accessToken);
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            int[]  returnValue = new int[2];
            int    executionID = 0;
            string batchCode   = string.Empty;
            string batchName   = string.Empty;

            string[] returnMessage;
            bool     IsCurrentAssessmentYear = true;
            int      headerID        = 0;
            string   batchParameters = string.Empty;
            bool     isSuccess       = false;

            // string createdBy = "SYSTEM";
            try
            {
                batchCode   = ConfigurationSettings.AppSettings["BatchCode"];
                executionID = BatchUtility.CreateaExecutionID(batchCode);
                //check to avoid duplicate runs
                if (!BatchUtility.IsDuplicateRun())
                {
                    //Fetch Batch Name from DB
                    batchName = BatchUtility.GetBatchNameBasedOnCode(batchCode, executionID);
                    //log batch start message as type "Information"
                    BatchUtility.LogMessage(batchName + " Batch Started at --" + DateTime.Now.ToString() + ".", executionID, "INFO");
                    returnMessage = BatchUtility.ValidateExecutionID(executionID, batchCode, "");

                    if (returnMessage[1] == "True")
                    {
                        //Log Information of Valid ExecutionID
                        BatchUtility.LogMessage(returnMessage[0], Convert.ToInt32(returnMessage[2]), "INFO");
                        //Actual Batch Call
                        returnValue = DBBalancingCYSupplementalDataAccess.RetrieveControlTotals(executionID, IsCurrentAssessmentYear);

                        if (returnValue[0] > 0)
                        {
                            headerID = returnValue[1];
                            BatchUtility.LogMessage(batchName + "  Completed Creating Control Totals With Header ID " + headerID.ToString() + " -- " + DateTime.Now.ToString(), Convert.ToInt32(returnMessage[2]), "INFO");
                            SaveReportOnBase(executionID, headerID, "RC0006");
                            SaveReportOnBase(executionID, headerID, "RC0018");

                            //Log Batch Success
                            BatchUtility.LogMessage(batchName + " Batch execution finished successfully.", executionID, "SUC");
                            //Updating the Execution End date
                            BatchUtility.UpdateExecutionEndDate(true, Convert.ToInt32(returnMessage[2]));
                            isSuccess = true;
                        }
                        else
                        {
                            //Log Batch Failure
                            BatchUtility.LogMessage(batchName + " Batch execution failed.", executionID, "FAIL");
                            //Updating the Execution End date
                            BatchUtility.UpdateExecutionEndDate(false, Convert.ToInt32(returnMessage[2]));
                        }
                    }
                    else
                    {
                        //Log Information of Invalid Execution ID
                        BatchUtility.LogMessage(returnMessage[0], Convert.ToInt32(returnMessage[2]), "INFO");
                    }
                }
                else
                {
                    //Log Information of duplicate running batch
                    BatchUtility.LogMessage("Batch already in progress. ", executionID, "INFO");
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;
                //Log Batch Exceptions
                BatchUtility.LogMessage(ex.Message + "--" + DateTime.Now.ToString(), executionID, "EXCEP");
            }
            finally
            {
                //Final Log Batch Information
                BatchUtility.LogMessage(batchName + " Batch execution finished at" + "--" + DateTime.Now.ToString() + ".", executionID, "INFO");
                BatchUtility.SendExitCodeToControlM(isSuccess);
            }
        }
示例#12
0
        /// <summary>
        /// This functions save report to OnBase ftp
        /// </summary>
        /// <param name="executionID">Execution Id of the batch</param>
        /// <param name="headerId">The parameter required to generate the report</param>
        /// <param name="ReportCode">Report Code from PTMS which has to be generated.</param>
        /// <returns></returns>
        protected static bool SaveReportOnBase(int executionID, int headerId, string ReportCode)
        {
            //DataSet documentGroup = null;
            string    documentTypeGroupName = string.Empty;
            string    byDate                    = string.Empty;
            DataTable getReportserver           = null;
            string    reportServer              = string.Empty;
            string    reportLocation            = string.Empty;
            string    sFTPLocation              = string.Empty;
            string    sFTPUserName              = string.Empty;
            string    sFTPPassword              = string.Empty;
            string    Msg                       = string.Empty;
            DataTable getDocumentTypeForReports = null;
            string    onbaseDocumentType        = string.Empty;
            string    onbaseDocumentGroup       = string.Empty;

            string[] installmentSecuredReportParameters = null;
            bool     onBaseSuccess = false;
            string   folder        = ConfigurationSettings.AppSettings["ReportFolder"];

            //Declaring Index File Keys variables

            string indexFileKey = string.Empty;

            string[] indexFileKeyParameters = null;
            try
            {
                getDocumentTypeForReports = BatchUtility.GetDocumentGroupAndTypeValue(ReportCode);
                if (getDocumentTypeForReports != null && getDocumentTypeForReports.Rows.Count > 0 &&
                    getDocumentTypeForReports.Columns.Contains("OnbaseDocumentGroup") &&
                    getDocumentTypeForReports.Columns.Contains("OnbaseDocumentType")
                    //&& (!string.IsNullOrEmpty(getDocumentTypeForReports.Rows[0]["OnbaseDocumentGroup"].ToString()))
                    // && (!string.IsNullOrEmpty(getDocumentTypeForReports.Rows[0]["OnbaseDocumentType"].ToString()))
                    )
                {
                    onbaseDocumentGroup = getDocumentTypeForReports.Rows[0]["OnbaseDocumentGroup"].ToString();
                    onbaseDocumentType  = getDocumentTypeForReports.Rows[0]["OnbaseDocumentType"].ToString();
                }

                ////TO BE ADDED//
                //documentGroup = BatchUtility.GetConfigValue("AC", "PEN", "DocumentGroup");
                //if (documentGroup != null && documentGroup.Tables.Count > 0 && documentGroup.Tables[0] != null && documentGroup.Tables[0].Rows.Count > 0)
                //{
                //    documentTypeGroupName = documentGroup.Tables[0].Rows[0]["Value"].ToString();
                //}
                //TO BE CHANGED//

                getReportserver = BatchUtility.getReportServerDetails(folder);

                if (getReportserver != null && getReportserver.Rows.Count > 0 &&
                    getReportserver.Columns.Contains("ReportServerName") &&
                    getReportserver.Columns.Contains("FolderName") &&
                    (!string.IsNullOrEmpty(getReportserver.Rows[0]["ReportServerName"].ToString())) &&
                    (!string.IsNullOrEmpty(getReportserver.Rows[0]["FolderName"].ToString())))
                {
                    reportServer   = getReportserver.Rows[0]["ReportServerName"].ToString();
                    reportLocation = getReportserver.Rows[0]["FolderName"].ToString();



                    DataSet FTPLocation = BatchUtility.GetConfigValue("PTMS", "OnBase_FTP", "ServerAddress");
                    DataSet FTPUserName = BatchUtility.GetConfigValue("PTMS", "OnBase_FTP", "UserName");
                    DataSet FTPPassword = BatchUtility.GetConfigValue("PTMS", "OnBase_FTP", "Password");
                    if (FTPLocation != null && FTPLocation.Tables.Count > 0 && FTPLocation.Tables[0] != null && FTPLocation.Tables[0].Rows.Count > 0) //Null Check Implemented
                    {
                        sFTPLocation = FTPLocation.Tables[0].Rows[0]["Value"].ToString();
                    }
                    if (FTPUserName != null && FTPUserName.Tables.Count > 0 && FTPUserName.Tables[0] != null && FTPUserName.Tables[0].Rows.Count > 0) //Null Check Implemented
                    {
                        sFTPUserName = FTPUserName.Tables[0].Rows[0]["Value"].ToString();
                    }
                    if (FTPPassword != null && FTPPassword.Tables.Count > 0 && FTPPassword.Tables[0] != null && FTPPassword.Tables[0].Rows.Count > 0) //Null Check Implemented
                    {
                        sFTPPassword = FTPPassword.Tables[0].Rows[0]["Value"].ToString();
                    }
                    string onBaseFTPMessageForSecuredReport = string.Empty;
                    string exportLocation   = Environment.CurrentDirectory + @"\";
                    string reportParameters = headerId.ToString();
                    installmentSecuredReportParameters = reportParameters.Split(',');

                    //Writing Index File Key to String Array

                    if (!string.IsNullOrEmpty(onbaseDocumentType) && !string.IsNullOrEmpty(onbaseDocumentGroup))
                    {
                        indexFileKey = "ExecutionID," + executionID.ToString() + ",RunDate," + DateTime.Now.ToShortDateString();

                        indexFileKeyParameters = indexFileKey.Split(',');
                    }

                    //Confirm
                    string reportName  = ConfigurationSettings.AppSettings[ReportCode];
                    String ReportValue = BatchUtility.GetFileName(reportName, executionID);
                    byte[] OutputbytesForSecuredReport = ExportReportAs(reportServer, reportLocation + reportName, exportLocation, reportName, "pdf", reportName, executionID, installmentSecuredReportParameters);
                    onBaseFTPMessageForSecuredReport = BatchUtility.UploadtoOnBaseFTP(sFTPLocation, sFTPUserName, sFTPPassword
                                                                                      , ReportValue + ".pdf", OutputbytesForSecuredReport, onbaseDocumentType, installmentSecuredReportParameters, 0, indexFileKeyParameters
                                                                                      , onbaseDocumentType, onbaseDocumentGroup, "Roll Corrections");
                    if (onBaseFTPMessageForSecuredReport == "1")
                    {
                        onBaseSuccess = true;
                    }
                }
            }
            catch (Exception Ex)
            {
                Msg = "Error Details : " + Ex.Message.ToString();
                BatchUtility.LogMessage(Ex.Message + "--" + DateTime.Now.ToString(), executionID, "EXCEP");
                throw Ex;
            }
            return(onBaseSuccess);
        }
示例#13
0
 private void AddNewBatch(RecipeDataModel recipe)
 {
     SaveCurrentBatch();
     CurrentBatch = BatchUtility.CreateBatch(recipe);
     SavedBatches.Add(CurrentBatch);
 }
示例#14
0
 private void DeleteGravityReading(GravityReadingDataModel gravityReading)
 {
     CurrentBatch.RecordedGravityReadings.Remove(gravityReading);
     BatchUtility.DeleteGravityReading(gravityReading.GravityReadingId);
 }