示例#1
0
        //获取文件著录编码流水号
        public static JObject GetFileCodeNumber(string sid, string FileCodePerfix)
        {
            ExReJObject reJo = new ExReJObject();

            try
            {
                User curUser = DBSourceController.GetCurrentUser(sid);
                if (curUser == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                DBSource dbsource = curUser.dBSource;
                if (dbsource == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                string runNum = "";

                string strSql = string.Format(
                    "select lf.FILECODE from CDMS_Doc as cd inner join " +
                    "(select Itemno, CA_FILECODE as FILECODE from User_CATALOGUING where CA_FILECODE like '%{0}%')" +
                    " as lf " +
                    "on  cd.o_itemno = lf.Itemno " +
                    " where cd.o_dmsstatus != 10 order by lf.FILECODE ",
                    FileCodePerfix);

                string[] strArry = dbsource.DBExecuteSQL(strSql);

                if (strArry == null || strArry.Length == 0 ||
                    (strArry[strArry.Length - 1]).Length < FileCodePerfix.Length + 3
                    )
                {
                    runNum = "001";
                }
                else
                {
                    //5位数,不够位数补零
                    int tempNum = Convert.ToInt32((strArry[strArry.Length - 1]).Substring(FileCodePerfix.Length, 3));

                    runNum = (tempNum + 1).ToString("d3");
                }
                reJo.success = true;
                reJo.data    = new JArray(new JObject(new JProperty("RunNum", runNum)));
                return(reJo.Value);
            }
            catch (Exception exception)
            {
                WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace);
                reJo.msg = "获取文件编号失败!" + exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace;
            }
            return(reJo.Value);
        }
示例#2
0
        /// <summary>
        /// 新建厂家资料目录
        /// </summary>
        public static JObject CreateSystem(string sid, string ProjectKeyword, string systemAttrJson)
        {
            ExReJObject reJo = new ExReJObject();

            try
            {
                User curUser = DBSourceController.GetCurrentUser(sid);
                if (curUser == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                DBSource dbsource = curUser.dBSource;
                if (dbsource == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                Project m_prj = dbsource.GetProjectByKeyWord(ProjectKeyword);
                if (m_prj == null)
                {
                    reJo.msg = "参数错误,目录不存在!";
                    return(reJo.Value);
                }


                #region 获取传递过来的属性参数
                //获取传递过来的属性参数
                JArray jaAttr = (JArray)JsonConvert.DeserializeObject(systemAttrJson);

                string strSystemCode = "", strSystemDesc = "",
                       strSystemEngDesc = "", strSystemChinese = "",
                       strAddress = "", strProvince = "",
                       strPostCode = "", strEMail = "",
                       strReceiver = "", strFaxNo = "", strPhone = "";

                foreach (JObject joAttr in jaAttr)
                {
                    string strName  = joAttr["name"].ToString();
                    string strValue = joAttr["value"].ToString();

                    switch (strName)
                    {
                    case "systemCode":
                        strSystemCode = strValue;
                        break;

                    case "systemDesc":
                        strSystemDesc = strValue;
                        break;

                    case "systemEngDesc":
                        strSystemEngDesc = strValue;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(strSystemCode))
                {
                    reJo.msg = "请输入项目编号!";
                    return(reJo.Value);
                }
                if (string.IsNullOrEmpty(strSystemDesc))
                {
                    reJo.msg = "请输入项目名称!";
                    return(reJo.Value);
                }

                #endregion

                Project prjProject = CommonFunction.getParentProjectByTempDefn(m_prj, "HXNY_DOCUMENTSYSTEM");

                if (prjProject == null)
                {
                    reJo.msg = "获取项目目录失败!";
                    return(reJo.Value);
                }

                //获取项目代码
                string strProjCode = prjProject.Code;//.GetAttrDataByKeyWord("COMPANY").ToString;

                JArray  jaData   = new JArray();
                JObject joSystem = new JObject();

                List <DictData> dictDataList = dbsource.GetDictDataList("System");
                //[o_Code]:公司编码,[o_Desc]:公司描述,[o_sValue1]:项目代码

                foreach (DictData data6 in dictDataList)
                {
                    if (!string.IsNullOrEmpty(data6.O_sValue2) && data6.O_sValue2 == strProjCode && data6.O_Code == strSystemCode)
                    {
                        reJo.msg = "已经存在相同的参建单位,请返回重试!";
                        return(reJo.Value);
                    }
                }
                //dbsource.NewDictData
                #region 添加到数据字典
                //添加到数据字典

                string format = "insert CDMS_DictData (" +
                                "o_parentno,o_datatype,o_ikey,o_skey,o_Code,o_Desc,o_sValue1,o_sValue2,o_sValue3,o_sValue4,o_sValue5,o_iValue1 ,o_iValue2)" +
                                " values ({0},{1},{2},'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',{11},{12}" + ")";
                //0,2,0,'Unit','"+strSystemCode+"','"+strSystemDesc+"','"+strProjCode+ "','','','','',0,0
                format = string.Format(format, new object[] {
                    0, 2, 0, "System", strSystemCode, strSystemDesc, strSystemEngDesc, strProjCode, "", "", "", 0, 0
                });
                dbsource.DBExecuteSQL(format);

                DBSourceController.refreshDBSource(sid);

                #endregion


                reJo.success = true;
                return(reJo.Value);
            }
            catch (Exception e)
            {
                reJo.msg = e.Message;
                CommonController.WebWriteLog(reJo.msg);
            }

            return(reJo.Value);
        }
示例#3
0
        /// <summary>
        /// 新建厂家资料目录
        /// </summary>
        public static JObject CreateCompany(string sid, string ProjectKeyword, string projectAttrJson)
        {
            ExReJObject reJo = new ExReJObject();

            try
            {
                User curUser = DBSourceController.GetCurrentUser(sid);
                if (curUser == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                DBSource dbsource = curUser.dBSource;
                if (dbsource == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                Project m_prj = dbsource.GetProjectByKeyWord(ProjectKeyword);
                if (m_prj == null)
                {
                    reJo.msg = "参数错误,目录不存在!";
                    return(reJo.Value);
                }


                #region 获取传递过来的属性参数
                //获取传递过来的属性参数
                JArray jaAttr = (JArray)JsonConvert.DeserializeObject(projectAttrJson);

                string strCompanyCode = "", strCompanyDesc = "",
                       strSecretarilman = "", strCompanyChinese = "",
                       strAddress = "", strProvince = "",
                       strPostCode = "", strEMail = "",
                       strReceiver = "", strFaxNo = "", strPhone = "";

                foreach (JObject joAttr in jaAttr)
                {
                    string strName  = joAttr["name"].ToString();
                    string strValue = joAttr["value"].ToString();

                    switch (strName)
                    {
                    case "companyCode":
                        strCompanyCode = strValue;
                        break;

                    case "companyDesc":
                        strCompanyDesc = strValue;
                        break;

                    case "secretarilman":
                        strSecretarilman = strValue;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(strCompanyCode))
                {
                    reJo.msg = "请输入项目编号!";
                    return(reJo.Value);
                }
                if (string.IsNullOrEmpty(strCompanyDesc))
                {
                    reJo.msg = "请输入项目名称!";
                    return(reJo.Value);
                }

                #endregion

                Project prjProject = CommonFunction.getParentProjectByTempDefn(m_prj, "HXNY_DOCUMENTSYSTEM");

                if (prjProject == null)
                {
                    reJo.msg = "获取项目目录失败!";
                    return(reJo.Value);
                }

                //获取项目代码
                string strProjCode = prjProject.Code;//.GetAttrDataByKeyWord("COMPANY").ToString;

                JArray  jaData    = new JArray();
                JObject joCompany = new JObject();

                List <DictData> dictDataList = dbsource.GetDictDataList("Unit");
                //[o_Code]:公司编码,[o_Desc]:公司描述,[o_sValue1]:项目代码

                foreach (DictData data6 in dictDataList)
                {
                    if (!string.IsNullOrEmpty(data6.O_sValue1) && data6.O_sValue1 == strProjCode && data6.O_Code == strCompanyCode)
                    {
                        reJo.msg = "已经存在相同的参建单位,请返回重试!";
                        return(reJo.Value);
                    }
                }

                //自动设置文控,如果没有与单位代码一样的用户,就自动添加用户
                SetUnitSecUser(sid, dbsource, prjProject, strCompanyCode, strCompanyDesc, ref strSecretarilman);

                //#region 自动设置文控,如果没有与单位代码一样的用户,就自动添加用户

                //if (string.IsNullOrEmpty(strSecretarilman))
                //{
                //    User secUser = dbsource.GetUserByCode(strCompanyCode);
                //    if (secUser == null)
                //    {
                //        ////UserController. CreateUser(sid, strCompanyCode, strCompanyDesc + "文控", "", "0",
                //        ////            "0", "", strCompanyCode, strCompanyCode);
                //        ////secUser = dbsource.GetUserByCode(strCompanyCode);
                //        secUser = dbsource.NewUser(
                //                            enUserFlage.OnLine,
                //                            enUserType.Default,
                //                                "",
                //                               strCompanyCode,
                //                                strCompanyDesc + "文控",
                //                                strCompanyCode,
                //                                "",
                //                                null
                //                                );

                //        if (secUser != null)
                //        {

                //            User m_user = secUser;
                //            m_user.O_suser1 = m_user.dBSource.GUID;

                //            m_user.Modify();

                //            // 强制刷新共享数据源
                //            //
                //            //DBSourceController.RefreshShareDBManager();
                //            DBSourceController.RefreshDBSource(sid);
                //            strSecretarilman = secUser.ToString;
                //        }
                //    }
                //    else
                //    {
                //        strSecretarilman = secUser.ToString;
                //    }
                //}
                //#endregion

                //dbsource.NewDictData
                #region 添加到数据字典
                //添加到数据字典

                //DictData dictdata = new DictData();
                //dictdata.StatusNew = true;
                //dictdata.O_skey = "Unit";
                //dictdata.O_datatype = (int)enDictDataType.TableHead;
                //dictdata.O_Code = strCompanyCode;
                //dictdata.O_Desc = strCompanyDesc;
                //dictdata.O_sValue1 = strProjCode;

                ////设置属性的值
                //SetDictDataPropertyValue(dictdata, 0);

                //dictdata.Modify();
                //strProjCode = "GEDI";

                string format = "insert CDMS_DictData (" +
                                "o_parentno,o_datatype,o_ikey,o_skey,o_Code,o_Desc,o_sValue1,o_sValue2,o_sValue3,o_sValue4,o_sValue5,o_iValue1 ,o_iValue2)" +
                                " values ({0},{1},{2},'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',{11},{12}" + ")";
                //0,2,0,'Unit','"+strCompanyCode+"','"+strCompanyDesc+"','"+strProjCode+ "','','','','',0,0
                format = string.Format(format, new object[] {
                    0, 2, 0, "Unit", strCompanyCode, strCompanyDesc, strProjCode, "", strSecretarilman, "", "", 0, 0
                });
                dbsource.DBExecuteSQL(format);

                DBSourceController.refreshDBSource(sid);

                //自动创建通信类下的单位目录
                CreateUnitProject(dbsource, prjProject, strCompanyCode, strCompanyDesc, strSecretarilman);

                ////通过以上的dictdata新建一个DictData
                //DictData newDictData = CreateNewDictData(dbsource, dictdata, enDictDataType.TableHead);

                //if (!newDictData.Write())
                //{
                //    //MessageBox.Show("创建失败!", "提示", MessageBoxButtons.OK);
                //    reJo.msg = "创建失败!";
                //    return reJo.Value;
                //}
                #endregion

                ////获取所有厂家信息
                //TempDefn mTempDefn = GetTempDefn(dbsource, "COM_UNIT");
                //if (mTempDefn == null)
                //{
                //    reJo.msg = "获取参建单位模板失败,请联系管理员!";
                //    return reJo.Value;
                //}

                //Project project = m_prj.NewProject(strCompanyCode, strCompanyDesc, m_prj.Storage, mTempDefn);
                //if (project == null)
                //{
                //    reJo.msg = "新建版本目录失败,请联系管理员!";
                //    return reJo.Value;
                //}

                ////增加附加属性
                //try
                //{
                //    //project.GetAttrDataByKeyWord("FC_COMPANYCODE").SetCodeDesc(strCompanyCode);       //厂家编码
                //    //project.GetAttrDataByKeyWord("FC_COMPANYCHINESE").SetCodeDesc(strCompanyChinese);    //厂家名称
                //    //project.GetAttrDataByKeyWord("FC_ADDRESS").SetCodeDesc(strAddress);           //厂家地址
                //    //project.GetAttrDataByKeyWord("FC_PROVINCE").SetCodeDesc(strProvince);          //厂家省份
                //    //project.GetAttrDataByKeyWord("FC_POSTCODE").SetCodeDesc(strPostCode);          //厂家邮政
                //    //project.GetAttrDataByKeyWord("FC_EMAIL").SetCodeDesc(strEMail);             //厂家邮箱
                //    //project.GetAttrDataByKeyWord("FC_RECEIVER").SetCodeDesc(strReceiver);          //厂家收件人
                //    //project.GetAttrDataByKeyWord("FC_FAXNO").SetCodeDesc(strFaxNo);             //厂家传真号
                //    //project.GetAttrDataByKeyWord("FC_PHONE").SetCodeDesc(strPhone);             //收件人电话
                //    //project.AttrDataList.SaveData();
                //}
                //catch (Exception ex)
                //{
                //    //MessageBox.Show("获取厂家模板失败,请联系管理员!");
                //    reJo.msg = "获取厂家模板失败,请联系管理员!";
                //    return reJo.Value;
                //}

                //reJo.data = new JArray(new JObject(new JProperty("ProjectKeyword", project.KeyWord)));

                reJo.success = true;
                return(reJo.Value);
            }
            catch (Exception e)
            {
                reJo.msg = e.Message;
                CommonController.WebWriteLog(reJo.msg);
            }

            return(reJo.Value);
        }
示例#4
0
        ////
        ///// <summary>
        ///// 获取文件编码流水号
        ///// </summary>
        ///// <param name="sid"></param>
        ///// <param name="ProjectKeyword"></param>
        ///// <param name="Prefix">文件编码前缀</param>
        ///// <returns></returns>
        //public static JObject GetFileCodeNumber(string sid,string ProjectKeyword,string Prefix)
        //{
        //    ExReJObject reJo = new ExReJObject();
        //    try
        //    {
        //        User curUser = DBSourceController.GetCurrentUser(sid);
        //        if (curUser == null)
        //        {
        //            reJo.msg = "登录验证失败!请尝试重新登录!";
        //            return reJo.Value;
        //        }

        //        DBSource dbsource = curUser.dBSource;
        //        if (dbsource == null)
        //        {
        //            reJo.msg = "登录验证失败!请尝试重新登录!";
        //            return reJo.Value;
        //        }

        //        Project m_Project = dbsource.GetProjectByKeyWord(ProjectKeyword);

        //        if (m_Project == null)
        //        {
        //            reJo.msg = "参数错误!文件夹不存在!";
        //            return reJo.Value;
        //        }

        //        List<Doc> docList = dbsource.SelectDoc(string.Format("select * from CDMS_Doc where o_itemname like '%{0}%' and o_dmsstatus !=10 order by o_itemname", Prefix));
        //        if (docList == null || docList.Count == 0)
        //        {
        //            reJo.data = new JArray(new JObject(
        //                new JProperty("Number", "001")));
        //            //new JProperty("EditTion","A")));
        //            reJo.success = true;
        //            return reJo.Value;
        //        }
        //        else
        //        {
        //            Doc doc = docList[docList.Count - 1];


        //            int tempNum = Convert.ToInt32(doc.O_itemname.Substring(Prefix.Length, 3));

        //            //3位数,不够位数补零
        //            string strNum = (tempNum + 1).ToString("d3");
        //            reJo.data = new JArray(new JObject(
        //                 new JProperty("Number", strNum)));

        //            reJo.success = true;
        //            return reJo.Value;
        //        }

        //        //reJo.success = true;
        //        //return reJo.Value;
        //    }
        //    catch (Exception e)
        //    {
        //        reJo.msg = e.Message;
        //        CommonController.WebWriteLog(reJo.msg);
        //    }
        //    return reJo.Value;

        //}

        /// <summary>
        /// 获取文件临时的后台编码
        /// </summary>
        /// <param name="dbsource"></param>
        /// <param name="RootProjectCode"></param>
        /// <param name="CommType">收文还是发文</param>
        /// <param name="docType"></param>
        /// <param name="strSendCompany"></param>
        /// <param name="strRecCompany"></param>
        /// <returns></returns>
        internal static string getDocTempNumber(DBSource dbsource, string RootProjectCode, string commType, string docType, string strSendCompany, string strRecCompany)
        {
            try
            {
                //string RootProjectCode = proj.GetValueByKeyWord("DESIGNPROJECT_CODE");

                //获取文档前缀
                string sendCompanyCode = strSendCompany.IndexOf("__") >= 0 ? strSendCompany.Substring(0, strSendCompany.IndexOf("__")) : strSendCompany;

                string recCompanyCode = strRecCompany.IndexOf("__") >= 0 ? strRecCompany.Substring(0, strRecCompany.IndexOf("__")) : strRecCompany;


                //编码前缀
                string strPrefix = "";

                strPrefix = commType + docType;

                //if (!string.IsNullOrEmpty(RootProjectCode))
                //{
                //    //项目管理类
                //    //strPrefix = RootProjectCode + "-" + sendCompanyCode + "-" + recCompanyCode + "-" + docType + "-" + commType + docType;
                //    strPrefix = RootProjectCode + "-" + commType + docType;
                //}
                //else
                //{
                //    //运营管理类
                //    strPrefix =  commType + docType;
                //}

                List <Doc> docList = new List <Doc>();
                //信函
                #region 查找信函流水号
                // if (commType == "S" && docType == "LET")
                {
                    string[] strArry = dbsource.DBExecuteSQL(string.Format(
                                                                 "select lf.CA_FILEID from CDMS_Doc as cd inner join " +
                                                                 "(select Itemno, CA_FILEID from User_CATALOGUING where CA_FILEID like '%{0}%') as lf " +
                                                                 "on  cd.o_itemno = lf.Itemno " +
                                                                 " where cd.o_dmsstatus != 10 order by lf.CA_FILEID ",
                                                                 strPrefix));

                    if (strArry == null || strArry.Length == 0)
                    {
                        return(commType + docType + "00001");
                    }
                    else
                    {
                        //5位数,不够位数补零
                        int tempNum = Convert.ToInt32((strArry[strArry.Length - 1]).Substring(strPrefix.Length, 5));

                        return(commType + docType + (tempNum + 1).ToString("d5"));
                    }
                }
                #endregion

                //else
                //{
                //    docList = dbsource.SelectDoc(string.Format("select * from CDMS_Doc where o_itemname like '%{0}%' and o_dmsstatus !=10 order by o_itemname", strPrefix));


                //    if (docList == null || docList.Count == 0)
                //    {
                //        //return "SLET"+"00001"; "-" + docType + "-" + commType + docType;
                //        return commType + docType + "00001";
                //    }
                //    else
                //    {
                //        Doc doc = docList[docList.Count - 1];

                //        int tempNum = Convert.ToInt32(doc.O_itemname.Substring(strPrefix.Length, 5));
                //        //3位数,不够位数补零
                //        //return "SLET" + (tempNum + 1).ToString("d5");
                //        return commType + docType + (tempNum + 1).ToString("d5");
                //    }
                //}
            }
            catch
            {
                //return "SLET" + "00001";
                return(commType + docType + "00001");
            }
        }