Esempio n. 1
0
 public bool ChangePassword(string userId, string oldPassword, string newPassword)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(oldPassword) && !string.IsNullOrWhiteSpace(newPassword))
         {
             //Get the user
             User Userexists = PSF.Get <User>("UserId", userId.Trim());
             if (Userexists != null)
             {
                 PassworAuth PA = new PassworAuth();
                 //encode and save the password
                 Userexists.Password = PA.base64Encode(newPassword);
                 PSF.Update <User>(Userexists);
             }
             else
             {
                 throw new Exception("No User found for " + userId.Trim() + "");
             }
         }
         else
         {
             throw new Exception("User/oldPassword/newPassword is required and it cannot be null..");
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 2
0
        public bool EditTicketNote(long id, string note)
        {
            try
            {
                if (id > 0)
                {
                    TicketComments TicketComments = PSF.Get <TicketComments>(id);
                    TicketComments.Note = note;
                    PSF.Update <TicketComments>(TicketComments);
                    return(true);
                }

                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public long SaveOrUpdateInvoice(Invoice Iv, string userId)
 {
     try
     {
         if (Iv != null && Iv.Id > 0)
         {
             Iv.ModifiedBy   = userId;
             Iv.ModifiedDate = DateTime.Now;
             PSF.Update <Invoice>(Iv);
         }
         else
         {
             Iv.CreatedBy   = userId;
             Iv.CreatedDate = DateTime.Now;
             PSF.Save <Invoice>(Iv);
         }
         return(Iv.Id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public long SaveOrUpdateMailTemplate(MailTemplate Mt, string userId)
 {
     try
     {
         if (Mt != null && Mt.MailTemplateId > 0)
         {
             Mt.ModifiedBy   = userId;
             Mt.ModifiedDate = DateTime.Now;
             PSF.Update <MailTemplate>(Mt);
         }
         else
         {
             Mt.CreatedBy    = userId;
             Mt.CreatedDate  = DateTime.Now;
             Mt.ModifiedDate = null;
             PSF.Save <MailTemplate>(Mt);
         }
         return(Mt.MailTemplateId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public long CreateOrUpdateEmailLog(EmailLog Mt)
 {
     try
     {
         if (Mt != null && Mt.Id > 0)
         {
             PSF.Update <EmailLog>(Mt);
         }
         else
         {
             PSF.Save <EmailLog>(Mt);
         }
         return(Mt.Id);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public bool CompleteActivityTicketSystem(TicketSystem TicketSystem, string Template, string userId, string ActivityName, bool isRejection)
        {
            bool retValue = false;

            try
            {
                PSF.SaveOrUpdate <TicketSystem>(TicketSystem);
                WorkFlowTemplate WorkFlowTemplate = PSF.Get <WorkFlowTemplate>("TemplateName", Template);
                //close the current activity
                Activity CurrentActivity = PSF.Get <Activity>("InstanceId", TicketSystem.InstanceId, "ActivityName", ActivityName, "Completed", false);
                if (CurrentActivity != null)
                {
                    //if current activity doesnt need any rejection and there is no rejection then it will be completed
                    //otherwise once the rejection resolved then it will be completed
                    //this need to be obdated as waiting
                    if (CurrentActivity.IsRejApplicable == true && isRejection == true)
                    {
                        CurrentActivity.BranchCode = TicketSystem.BranchCode;
                        CurrentActivity.DeptCode   = TicketSystem.DeptCode;
                        CurrentActivity.Completed  = true;
                        CurrentActivity.Available  = false;
                        CurrentActivity.Assigned   = false;
                        CurrentActivity.Performer  = userId;
                        PSF.SaveOrUpdate(CurrentActivity);
                    }
                    else
                    {
                        Activity WaitingAct = PSF.Get <Activity>("WaitingFor", CurrentActivity.Id);
                        if (WaitingAct != null)
                        {
                            CurrentActivity.BranchCode = TicketSystem.BranchCode;
                            CurrentActivity.DeptCode   = TicketSystem.DeptCode;
                            CurrentActivity.Waiting    = false;
                            PSF.SaveOrUpdate(CurrentActivity);
                            WaitingAct.Completed = true;
                            WaitingAct.Assigned  = false;
                            WaitingAct.Available = false;
                        }
                        CurrentActivity.BranchCode = TicketSystem.BranchCode;
                        CurrentActivity.DeptCode   = TicketSystem.DeptCode;
                        CurrentActivity.Completed  = true;
                        CurrentActivity.Available  = false;
                        CurrentActivity.Assigned   = false;
                        CurrentActivity.Performer  = userId;
                        if (CurrentActivity.ActivityName == "CompleteETicket")
                        {
                            TicketSystem.IsTicketCompleted = true;
                            PSF.Update <TicketSystem>(TicketSystem);
                            ProcessInstance pi = PSF.Get <ProcessInstance>(TicketSystem.InstanceId);
                            pi.Status           = "Completed"; PSF.SaveOrUpdate <ProcessInstance>(pi);
                            TicketSystem.Status = "Completed";
                            PSF.SaveOrUpdate <TicketSystem>(TicketSystem);
                        }
                        PSF.SaveOrUpdate(CurrentActivity);
                    }
                }
                //trigger the next activity //we need to check whether parallel activities are there to complete
                //activities that are coming in the next order
                IList <WorkFlowStatus> WorkFlowStatusList = PSF.GetList <WorkFlowStatus>("TemplateId", WorkFlowTemplate.Id, "ActivityOrder", CurrentActivity.NextActOrder);
                //checking parallel activities get the current order of activities
                Dictionary <string, object> WaitCriteria = new Dictionary <string, object>();
                WaitCriteria.Add("TemplateId", WorkFlowTemplate.Id);
                WaitCriteria.Add("ActivityOrder", CurrentActivity.ActivityOrder);
                WaitCriteria.Add("InstanceId", CurrentActivity.InstanceId);
                Dictionary <long, IList <Activity> > conditionList = PSF.GetListWithSearchCriteriaCount <Activity>(0, 100, string.Empty, string.Empty, WaitCriteria);
                if (conditionList != null && conditionList.Count > 0)
                {
                    IList <Activity> conditionWaitList = conditionList.First().Value;
                    bool?            waiting           = false;
                    foreach (Activity a in conditionWaitList)
                    {
                        if (a.Completed == false && waiting == false)
                        {
                            waiting = true;
                        }
                    }
                    retValue = true;
                    if (waiting == true)
                    {
                        if (CurrentActivity.IsRejApplicable == true && isRejection == true)
                        {
                        }
                        else
                        {
                            return(retValue);
                        }
                    }
                }
                if (WorkFlowStatusList != null && WorkFlowStatusList.Count > 0)
                {
                    //if it is rejection flow then build the logic here
                    //{logic goes here }


                    foreach (WorkFlowStatus wfs in WorkFlowStatusList)
                    {
                        //Rejection Activity
                        if (CurrentActivity.IsRejApplicable == true && isRejection == true)
                        {
                            WorkFlowStatus wfsRej = PSF.Get <WorkFlowStatus>("TemplateId", WorkFlowTemplate.Id, "RejectionFor", CurrentActivity.ActivityOrder);
                            if (wfsRej != null)
                            {
                                Activity NextActivityRej = new Activity();
                                NextActivityRej.CreatedDate  = DateTime.Now;
                                NextActivityRej.ActivityName = wfsRej.WFStatus;
                                if (NextActivityRej.ActivityName == "CompleteETicket")
                                {
                                    NextActivityRej.Completed = true;
                                    //ProcessInstance pi = PSF.Get<ProcessInstance>(CallManagement.InstanceId);
                                    //pi.Status = "Completed"; PSF.SaveOrUpdate<ProcessInstance>(pi);
                                    TicketSystem.Status = NextActivityRej.ActivityName;
                                    PSF.SaveOrUpdate <TicketSystem>(TicketSystem);
                                }
                                else
                                {
                                    NextActivityRej.Completed = false;
                                }
                                NextActivityRej.ActivityFullName = wfsRej.Description;
                                NextActivityRej.AppRole          = wfsRej.Performer;

                                NextActivityRej.Performer        = userId;
                                NextActivityRej.TemplateId       = WorkFlowTemplate.Id;
                                NextActivityRej.InstanceId       = TicketSystem.InstanceId;
                                NextActivityRej.NextActOrder     = wfsRej.NextActOrder;
                                NextActivityRej.ActivityOrder    = wfsRej.ActivityOrder;
                                NextActivityRej.PreviousActOrder = wfsRej.PreviousActOrder;
                                NextActivityRej.ProcessRefId     = TicketSystem.Id;
                                NextActivityRej.RejectionFor     = CurrentActivity.Id;
                                NextActivityRej.Completed        = false;
                                NextActivityRej.Available        = true;
                                NextActivityRej.Assigned         = false;
                                NextActivityRej.BranchCode       = TicketSystem.BranchCode;
                                NextActivityRej.DeptCode         = TicketSystem.DeptCode;
                                PSF.SaveOrUpdate <Activity>(NextActivityRej);
                                TicketSystem.Status = NextActivityRej.ActivityName;
                                PSF.SaveOrUpdate <TicketSystem>(TicketSystem);
                                //CurrentActivity.WaitingFor = NextActivityRej.Id;
                                //PSF.SaveOrUpdate(CurrentActivity);
                            }
                        }
                        else
                        {
                            Activity NextActivity = new Activity();
                            NextActivity.CreatedDate = DateTime.Now;
                            if (wfs.IsRejectionRequired == true)
                            {
                                NextActivity.IsRejApplicable = true;
                            }

                            NextActivity.ActivityName     = wfs.WFStatus;
                            NextActivity.ActivityFullName = wfs.Description;
                            NextActivity.AppRole          = wfs.Performer;
                            NextActivity.Completed        = wfs.WFStatus == "Complete" ? true : false;
                            NextActivity.Available        = wfs.WFStatus != "Complete" ? true : false;
                            //NextActivity.Performer = userId;
                            NextActivity.TemplateId       = WorkFlowTemplate.Id;
                            NextActivity.InstanceId       = TicketSystem.InstanceId;
                            NextActivity.NextActOrder     = wfs.NextActOrder;
                            NextActivity.ActivityOrder    = wfs.ActivityOrder;
                            NextActivity.PreviousActOrder = wfs.PreviousActOrder;
                            NextActivity.ProcessRefId     = TicketSystem.Id;
                            NextActivity.Available        = true;
                            NextActivity.Assigned         = false;
                            NextActivity.Completed        = false;
                            NextActivity.BranchCode       = TicketSystem.BranchCode;
                            NextActivity.DeptCode         = TicketSystem.DeptCode;
                            PSF.SaveOrUpdate <Activity>(NextActivity);
                            TicketSystem.Status = NextActivity.ActivityName;
                            PSF.SaveOrUpdate <TicketSystem>(TicketSystem);
                        }
                    }
                    retValue = true;
                }
                return(retValue);
            }
            catch (Exception)
            {
                throw;
            }
        }