Esempio n. 1
0
        public ActionResult SubmitTestTableForm(string KeyValue, FY_Rapid rapid, string BuildFormJson, HttpPostedFileBase Filedata)
        {
            string        ModuleId    = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId"));
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            try
            {
                string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";
                if (!string.IsNullOrEmpty(KeyValue))
                {
                    if (KeyValue == ManageProvider.Provider.Current().UserId)
                    {
                        throw new Exception("无权限编辑信息");
                    }

                    //base_user.Modify(KeyValue);
                    rapid.Modify(KeyValue);
                    if (rapid.IsEmail != 1)
                    {
                        int IsEmail = SendEmail(rapid.res_cpeo, rapid.res_ms);
                        rapid.IsEmail = IsEmail;
                    }
                    if (rapid.RealTime != null && rapid.res_cdate != null && rapid.PlanTime != null)
                    {
                        //int planNum = new TimeSpan(rapid.PlanTime.Ticks - rapid.res_cdate.Ticks).Days;
                        //int realNum = (rapid.RealTime - rapid.res_cdate).Days;
                        //TimeSpan d3 = rapid.RealTime.Subtract(rapid.res_cdate);
                        int realNum = Math.Abs(((TimeSpan)(rapid.RealTime - rapid.res_cdate)).Days);
                        int planNum = Math.Abs(((TimeSpan)(rapid.PlanTime - rapid.res_cdate)).Days);
                        rapid.Rate       = Math.Round(((2.0 - (realNum / (planNum * 1.0))) * 100), 2).ToString() + "%";
                        rapid.RapidState = "已完成";
                    }
                    database.Update(rapid, isOpenTrans);
                }
                else
                {
                    rapid.Create();
                    int IsEmail = SendEmail(rapid.res_cpeo, rapid.res_ms);
                    rapid.IsEmail = IsEmail;
                    database.Insert(rapid, isOpenTrans);
                    //database.Insert(base_employee, isOpenTrans);
                    Base_DataScopePermissionBll.Instance.AddScopeDefault(ModuleId, ManageProvider.Provider.Current().UserId, rapid.res_id, isOpenTrans);
                }
                Base_FormAttributeBll.Instance.SaveBuildForm(BuildFormJson, rapid.res_id, ModuleId, isOpenTrans);
                database.Commit();
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = Message
                }.ToString()));
            }
            catch (Exception ex)
            {
                database.Rollback();
                database.Close();
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }
Esempio n. 2
0
        public ActionResult SetTestForm(string KeyValue)
        {
            FY_Rapid rapid = DataFactory.Database().FindEntity <FY_Rapid>(KeyValue);

            if (rapid == null)
            {
                return(Content(""));
            }
            //Base_Employee base_employee = DataFactory.Database().FindEntity<Base_Employee>(KeyValue);
            //Base_Company base_company = DataFactory.Database().FindEntity<Base_Company>(base_user.CompanyId);
            string strJson = rapid.ToJson();

            //公司
            //strJson = strJson.Insert(1, "\"CompanyName\":\"" + base_company.FullName + "\",");
            //员工信息
            //strJson = strJson.Insert(1, base_employee.ToJson().Replace("{", "").Replace("}", "") + ",");
            //自定义
            strJson = strJson.Insert(1, Base_FormAttributeBll.Instance.GetBuildForm(KeyValue));
            return(Content(strJson));
        }
Esempio n. 3
0
        public ActionResult SubmitUploadify(string FolderId, HttpPostedFileBase Filedata, string type)
        {
            try
            {
                Thread.Sleep(1000);    ////延迟500毫秒
                Base_NetworkFile entity      = new Base_NetworkFile();
                FY_Rapid         rapidentity = DataFactory.Database().FindEntity <FY_Rapid>(FolderId);

                string IsOk = "";
                //没有文件上传,直接返回
                if (Filedata == null || string.IsNullOrEmpty(Filedata.FileName) || Filedata.ContentLength == 0)
                {
                    return(HttpNotFound());
                }
                //获取文件完整文件名(包含绝对路径)
                //文件存放路径格式:/Resource/Document/NetworkDisk/{日期}/{guid}.{后缀名}
                //例如:/Resource/Document/Email/20130913/43CA215D947F8C1F1DDFCED383C4D706.jpg
                string fileGuid       = CommonHelper.GetGuid;
                long   filesize       = Filedata.ContentLength;
                string FileEextension = Path.GetExtension(Filedata.FileName);
                string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                string UserId         = ManageProvider.Provider.Current().UserId;

                string virtualPath = string.Format("~/Resource/Document/NetworkDisk/{0}/{1}/{2}{3}", UserId, uploadDate, fileGuid, FileEextension);
                //rapidentity.res_msfj = virtualPath;

                string fullFileName = this.Server.MapPath(virtualPath);
                //创建文件夹,保存文件
                string path = Path.GetDirectoryName(fullFileName);
                Directory.CreateDirectory(path);
                if (!System.IO.File.Exists(fullFileName))
                {
                    Filedata.SaveAs(fullFileName);
                    try
                    {
                        //文件信息写入数据库
                        //entity.Create();
                        //entity.NetworkFileId = fileGuid;
                        //entity.FolderId = FolderId;
                        //entity.FileName = Filedata.FileName;
                        //entity.FilePath = virtualPath;
                        //entity.FileSize = filesize.ToString();
                        //entity.FileExtensions = FileEextension;
                        //string _FileType = "";
                        //string _Icon = "";
                        //this.DocumentType(FileEextension, ref _FileType, ref _Icon);
                        //entity.Icon = _Icon;
                        //entity.FileType = _FileType;
                        //IsOk = DataFactory.Database().Insert<Base_NetworkFile>(entity).ToString();

                        if (type == "res_msfj")
                        {
                            rapidentity.res_msfj = virtualPath;
                        }
                        if (type == "res_yzb")
                        {
                            rapidentity.res_yzbfj = virtualPath;
                        }
                        if (type == "res_fx")
                        {
                            rapidentity.res_fxfj = virtualPath;
                        }
                        if (type == "res_cs")
                        {
                            rapidentity.res_csfj = virtualPath;
                        }
                        if (type == "res_fcf")
                        {
                            rapidentity.res_fcffj = virtualPath;
                        }
                        if (type == "res_fcsh")
                        {
                            rapidentity.res_fcshfj = virtualPath;
                        }
                        if (type == "res_csgz")
                        {
                            rapidentity.res_csgzfj = virtualPath;
                        }
                        if (type == "res_fmea")
                        {
                            rapidentity.res_fmeafj = virtualPath;
                        }
                        if (type == "res_jyjx")
                        {
                            rapidentity.res_jyjxfj = virtualPath;
                        }
                        if (type == "uploadifyNotCompleteReason")
                        {
                            rapidentity.NotCompleteReasonfj = virtualPath;
                        }
                        if (type == "Action")
                        {
                            rapidentity.Actionfj = virtualPath;
                        }
                        if (type == "res_bzgx")
                        {
                            rapidentity.res_bzgxfj = virtualPath;
                        }
                        DataFactory.Database().Update <FY_Rapid>(rapidentity);
                    }
                    catch (Exception ex)
                    {
                        //IsOk = ex.Message;
                        //System.IO.File.Delete(virtualPath);
                    }
                }
                var JsonData = new
                {
                    Status      = IsOk,
                    NetworkFile = rapidentity,
                };
                return(Content(JsonData.ToJson()));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }