Пример #1
0
        /// <summary>
        /// Delete the Draft & related data from the DB  & related Attached Files From the UNC Path
        /// </summary>
        /// <param name="refid">User Sent reference ID</param>
        /// <returns> it's successfull sent SUCCESS else failed</returns>
        /// SP: K2_DeleteDraft
        public string DeleteDraft(string UserId, string refid)
        {
            string result = null;

            try
            {
                RequestFormMaster form = Db.RequestFormMasters.Where(p => p.ReferenceID == refid).FirstOrDefault();
                if (form != null && form.PreparerUserID == UserId)
                {
                    SqlParameter[] sqlp =
                    {
                        new SqlParameter("ReferId", refid)
                    };
                    var attachlist = Db.Database.SqlQuery <string>("exec [K2_DeleteDraft] @ReferId", sqlp).ToList();
                    result = attachlist[0].ToString();
                    if (!string.IsNullOrEmpty(result.ToString()))
                    {
                        string Dircur = ConfigurationManager.AppSettings.Get("UNCPath") + result.ToString(); //UNC Path From Web Config
                        if (Directory.Exists(Dircur))
                        {
                            System.IO.Directory.Delete(Dircur, true);
                        }
                        result = "SUCCESS";
                    }
                    else
                    {
                        result = "Failed";
                    }
                }
                else
                {
                    result = "Unauthorized";
                }
            }
            catch (Exception ex)
            {
                result = "Failed";
                throw ex;
            }
            return(result);
        }
Пример #2
0
 public void startWorkFlow(string refId)
 {
     try
     {
         RequestFormMaster RFM = new RequestFormMaster();
         RFM = Db.RequestFormMasters.Where(p => p.ReferenceID == refId).FirstOrDefault();
         if (string.IsNullOrEmpty(RFM.ProcInstID) && RFM.FormStatus != "Draft")
         {
             WorkflowFacade workfacade = new WorkflowFacade();
             int            PRInstID   = workfacade.StartProcessInstance(RFM.FormID, RFM.PreparerUserID, RFM.ReferenceID, RFM.Remark);
             if (PRInstID > 0)
             {
                 RFM.ProcInstID      = PRInstID.ToString();
                 Db.Entry(RFM).State = EntityState.Modified;
                 Db.SaveChanges();
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }