Example #1
0
        public async Task <IActionResult> CreateVotingHeader(VotingHeaderVM VH)
        {
            SAPEntity.Instance.InitializeCompany();
            if (SAPEntity.Company.Connected)
            {
                ActivitiesService oActSrv = (ActivitiesService)SAPEntity.Company.GetCompanyService().GetBusinessService(ServiceTypes.ActivitiesService);
                Activity          oAct    = (Activity)oActSrv.GetDataInterface(ActivitiesServiceDataInterfaces.asActivity);
                ActivityParams    oParams;
                oAct.CardCode         = VH.cardcode;
                oAct.Activity         = BoActivities.cn_Task;
                oAct.ActivityType     = 1;
                oAct.PreviousActivity = VH.prevactvty;
                //oAct.Subject = VH.subject;
                DateTime StartDate = DateTime.ParseExact(VH.str_startdate, "dd/MM/yyyy", null).Date;
                DateTime CloseDate = DateTime.ParseExact(VH.str_enddate, "dd/MM/yyyy", null).Date;



                oAct.ActivityDate = StartDate.Date;
                //oAct.EndDuedate = CloseDate;
                oAct.Duration     = (CloseDate - StartDate).TotalDays;
                oAct.DurationType = BoDurations.du_Days;
                if (!String.IsNullOrEmpty(VH.time))
                {
                    oAct.UserFields.Item("U_Time").Value = VH.time;
                }
                if (!String.IsNullOrEmpty(VH.opentime))
                {
                    oAct.UserFields.Item("U_OpenTime").Value = VH.opentime;
                }

                oAct.UserFields.Item("U_AddedBy").Value = User.Identity.Name;

                oAct.Notes = VH.remark;
                oParams    = oActSrv.AddActivity(oAct);
                long singleActCode = oParams.ActivityCode;
                if (singleActCode > 0)
                {
                    //-----Email Notification
                    var VOTERS = await _UserManager.GetUsersInRoleAsync("VOTER");

                    string[] VOTERStr       = VOTERS.Select(t => t.Email).Distinct().ToArray();
                    string   voteremails    = String.Join(",", VOTERStr);
                    var      VOTINGMANAGERS = await _UserManager.GetUsersInRoleAsync("VOTINGMANAGER");

                    VOTERStr    = VOTINGMANAGERS.Select(t => t.Email).Distinct().ToArray();
                    voteremails = voteremails + "," + String.Join(",", VOTERStr);
                    _EmailRepo.SaveEmailLog(singleActCode, oAct.CardCode, StartDate.Date, CloseDate, voteremails, User.Identity.Name, VH.prevactvty);
                    //-----Email Notification

                    return(StatusCode(201));
                }
            }
            else
            {
                return(BadRequest("SAP connection failed."));
            }

            return(BadRequest("incorrect inputs provided."));
        }
Example #2
0
        public async Task <IActionResult> CreateBoardMeeting(MeetingVM VM)
        {
            int    IsAttchInserted = -1;
            string strMessage      = "incorrect inputs provided.";

            SAPEntity.Instance.InitializeCompany();
            if (SAPEntity.Company.Connected)
            {
                ActivitiesService oActSrv = (ActivitiesService)SAPEntity.Company.GetCompanyService().GetBusinessService(ServiceTypes.ActivitiesService);
                Activity          oAct    = (Activity)oActSrv.GetDataInterface(ActivitiesServiceDataInterfaces.asActivity);
                ActivityParams    oParams;
                oAct.CardCode     = VM.cardcode;
                oAct.Activity     = BoActivities.cn_Task;
                oAct.ActivityType = 2;

                if (VM.cntctcode > 0)
                {
                    oAct.ContactPersonCode = VM.cntctcode;
                }

                DateTime StartDate = DateTime.ParseExact(VM.str_startdate, "dd/MM/yyyy", null);
                DateTime CloseDate = DateTime.ParseExact(VM.str_enddate, "dd/MM/yyyy", null);

                oAct.ActivityDate = StartDate;
                oAct.Duration     = (CloseDate - StartDate).TotalDays;
                oAct.DurationType = BoDurations.du_Days;
                if (!String.IsNullOrEmpty(VM.time))
                {
                    oAct.UserFields.Item("U_Time").Value = VM.time;
                }
                if (VM.assignesto.HasValue && VM.assignesto.Value > 0)
                {
                    oAct.HandledBy = VM.assignesto.Value;
                }
                oAct.Notes   = VM.notes;
                oAct.Details = VM.details;

                if (VM.files != null && VM.files.Count() > 0)
                {
                    SAPbobsCOM.Attachments2 SAPAttachment = (SAPbobsCOM.Attachments2)SAPEntity.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
                    foreach (var FL in VM.files)
                    {
                        if (!string.IsNullOrEmpty(FL))
                        {
                            SAPAttachment.Lines.SetCurrentLine((SAPAttachment.Lines.Count) - 1);
                            string FileName = System.IO.Path.GetFileName(FL);
                            string FileExt  = System.IO.Path.GetExtension(FileName);
                            FileExt = FileExt.Replace('.', ' ').Trim();
                            SAPAttachment.Lines.SourcePath    = @"H:\Upload";
                            SAPAttachment.Lines.FileName      = FileName;
                            SAPAttachment.Lines.FileExtension = Path.GetExtension(FileExt);
                            SAPAttachment.Lines.Add();
                        }
                    }

                    if (VM.files.Count() > 0)
                    {
                        IsAttchInserted = SAPAttachment.Add();
                        if (IsAttchInserted == 0)
                        {
                            string ObjCode;
                            SAPEntity.Company.GetNewObjectCode(out ObjCode);
                            oAct.AttachmentEntry = Convert.ToInt32(ObjCode);
                        }
                        else
                        {
                            strMessage = SAPEntity.Company.GetLastErrorDescription();
                        }
                    }
                }


                oParams = oActSrv.AddActivity(oAct);
                long singleActCode = oParams.ActivityCode;
                if (singleActCode > 0)
                {
                    return(StatusCode(201));
                }
            }

            return(BadRequest("incorrect inputs provided."));
        }
Example #3
0
        public async Task <IActionResult> CreateSingleActivity(singlecomplianceviewmodel VM)
        {
            string strMessage = "incorrect inputs provided.";
            bool   IsCreate   = true;

            try
            {
                int IsAttchInserted = -1;
                SAPEntity.Instance.InitializeCompany();
                if (SAPEntity.Company.Connected)
                {
                    ActivitiesService oActSrv = (ActivitiesService)SAPEntity.Company.GetCompanyService().GetBusinessService(ServiceTypes.ActivitiesService);
                    Activity          oAct    = (Activity)oActSrv.GetDataInterface(ActivitiesServiceDataInterfaces.asActivity);
                    ActivityParams    oParams;
                    if (VM.clgcode > 0)
                    {
                        IsCreate             = false;
                        oParams              = (ActivityParams)oActSrv.GetDataInterface(ActivitiesServiceDataInterfaces.asActivityParams);
                        oParams.ActivityCode = VM.clgcode;
                        oAct = oActSrv.GetActivity(oParams);
                    }
                    oAct.CardCode = VM.cardcode;
                    if (VM.cntctcode > 0)
                    {
                        oAct.ContactPersonCode = VM.cntctcode;
                    }

                    oAct.Activity     = BoActivities.cn_Task;
                    oAct.ActivityType = VM.type;
                    oAct.Subject      = VM.subject;
                    if (VM.assignesto.HasValue && VM.assignesto.Value > 0)
                    {
                        oAct.HandledBy = VM.assignesto.Value;
                    }
                    oAct.Status   = VM.status;
                    oAct.Priority = VM.prcode == "0" ? BoMsgPriorities.pr_Low : VM.prcode == "1" ? BoMsgPriorities.pr_Normal : BoMsgPriorities.pr_High;
                    oAct.Details  = VM.details;
                    oAct.Notes    = VM.notes;
                    if (!string.IsNullOrEmpty(VM.str_startdate))
                    {
                        DateTime StartDate = DateTime.ParseExact(VM.str_startdate, "dd/MM/yyyy", null);
                        DateTime CloseDate = DateTime.ParseExact(VM.str_enddate, "dd/MM/yyyy", null);
                        oAct.ActivityDate = StartDate;
                        oAct.Duration     = (CloseDate - StartDate).TotalDays;
                        oAct.DurationType = BoDurations.du_Days;
                    }
                    if (VM.files != null && VM.files.Count() > 0)
                    {
                        SAPbobsCOM.Attachments2 SAPAttachment = (SAPbobsCOM.Attachments2)SAPEntity.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
                        foreach (var FL in VM.files)
                        {
                            if (!string.IsNullOrEmpty(FL))
                            {
                                SAPAttachment.Lines.SetCurrentLine((SAPAttachment.Lines.Count) - 1);
                                string FileName = System.IO.Path.GetFileName(FL);
                                string FileExt  = System.IO.Path.GetExtension(FileName);
                                FileExt = FileExt.Replace('.', ' ').Trim();
                                SAPAttachment.Lines.SourcePath    = @"H:\Upload";
                                SAPAttachment.Lines.FileName      = FileName;
                                SAPAttachment.Lines.FileExtension = Path.GetExtension(FileExt);
                                SAPAttachment.Lines.Add();
                            }
                        }

                        if (VM.files.Count() > 0)
                        {
                            IsAttchInserted = SAPAttachment.Add();
                            if (IsAttchInserted == 0)
                            {
                                string ObjCode;
                                SAPEntity.Company.GetNewObjectCode(out ObjCode);
                                oAct.AttachmentEntry = Convert.ToInt32(ObjCode);
                            }
                            else
                            {
                                strMessage = SAPEntity.Company.GetLastErrorDescription();
                            }
                        }
                    }

                    if (IsCreate)
                    {
                        oAct.UserFields.Item("U_AddedBy").Value = User.Identity.Name;
                        oParams = oActSrv.AddActivity(oAct);
                        long singleActCode = oParams.ActivityCode;
                        if (singleActCode > 0)
                        {
                            return(StatusCode(201));
                        }

                        else
                        {
                            strMessage = SAPEntity.Company.GetLastErrorDescription();
                        }
                    }
                    else
                    {
                        oAct.UserFields.Item("U_UpdatedBy").Value = User.Identity.Name;
                        oActSrv.UpdateActivity(oAct);
                        strMessage = SAPEntity.Company.GetLastErrorDescription();
                        if (!string.IsNullOrWhiteSpace(strMessage))
                        {
                            return(BadRequest(strMessage));
                        }
                        else
                        {
                            return(StatusCode(201));
                        }
                    }
                }
            }
            catch (Exception E)
            {
                var tt = E.Message;
            }

            return(BadRequest(strMessage));
        }