Пример #1
0
        public string MoveAttach(LibAttachData attachData)
        {
            LibDataAccess dataAccess = new LibDataAccess();
            List <string> listSql    = new List <string>();

            //更新结构
            UpdateAttachStruct(attachData, listSql);
            //更新附件记录明细
            listSql.Add(string.Format("insert into AXPATTACHMENTRECORDDETAIL(BELONGTOID,ORDERID,FILENAME,PERSONID,CREATETIME) values('{0}',{1},'{2}','{3}',{4})",
                                      attachData.AttachSrc, attachData.OrderId, attachData.FileName, attachData.PersonId, LibDateUtils.GetCurrentDateTime()));

            LibDBTransaction trans = dataAccess.BeginTransaction();

            try
            {
                dataAccess.ExecuteNonQuery(listSql);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }

            string path = Path.Combine(EnvProvider.Default.MainPath, "AxFile", "Attachment", attachData.ProgId, attachData.AttachSrc);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string orgFilePath = Path.Combine(EnvProvider.Default.MainPath, "AxFile", "Attachment", attachData.FileName);

            File.Move(orgFilePath, Path.Combine(path, attachData.FileName));
            return(attachData.AttachSrc);
        }
Пример #2
0
        /// <summary>
        /// 全文索引创建结果的处理
        /// </summary>
        /// <param name="docId"></param>
        /// <param name="modifyVerId">修订版标识号</param>
        /// <param name="isSuccess"></param>
        public static void DealFullIndexResult(string docId, int modifyVerId, bool isSuccess)
        {
            try
            {
                LibDataAccess    dataAccess = new LibDataAccess();
                LibDBTransaction trans      = dataAccess.BeginTransaction();
                try
                {
                    string sql = "";
                    if (dataAccess.DatabaseType == LibDatabaseType.SqlServer)
                    {
                        sql = string.Format(
                            " update a                        " +
                            " set a.ISFULLINDEX = {2}         " +
                            " from DMDOCUMENT a               " +
                            " where a.DOCID = '{0}' and (select max(DOCMODIFYID) from DMDOCMODIFYHISTORY where DOCID = '{0}') = {1}",//修订号与最新修订号相同才设置索引结果
                            docId, modifyVerId, isSuccess ? 1 : 0);
                    }
                    else
                    {
                        //Oracle To do
                    }

                    if (string.IsNullOrEmpty(sql) == false)
                    {
                        dataAccess.ExecuteNonQuery(sql);
                    }
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
            }
            catch (Exception exp)
            {
                //发生异常时记录日志
                DMCommonMethod.WriteLog("DealFullIndexResult", string.Format("DocId:{0}\r\nIsSuccess{1}\r\nnError:{2}",
                                                                             docId, isSuccess, exp.ToString()));
            }
        }
Пример #3
0
        public string SaveAttachStruct(LibAttachData attachData)
        {
            if (attachData.AttachList.Count == 0)
            {
                return(string.Empty);
            }
            LibDataAccess dataAccess = new LibDataAccess();
            List <string> listSql    = new List <string>();

            UpdateAttachStruct(attachData, listSql);
            LibDBTransaction trans = dataAccess.BeginTransaction();

            try
            {
                dataAccess.ExecuteNonQuery(listSql);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            return(attachData.AttachSrc);
        }
Пример #4
0
        public void RemoveFromSaleBillNo(string fromSaleBillNo)
        {
            //通过销售订单号查找派工单号
            string        sql        = string.Format(@"SELECT DISTINCT F.BILLNO
                                          FROM WORKORDER A
                                         INNER JOIN WORKORDERDETAIL B
                                            ON A.BILLNO = B.BILLNO
                                         INNER JOIN PLSSALESORDER C
                                            ON B.FROMBILLNO = C.BILLNO
                                         INNER JOIN PLSPRODUCEMONTHPLANDETAIL D
                                            ON D.WORKORDERBILLNO = B.BILLNO
                                         INNER JOIN PLSPRODUCEDAYPLANDETAIL E
                                            ON E.FROMBILLNO = D.BILLNO
                                           AND E.FROMROWID = D.ROW_ID
                                         INNER JOIN PPWORKORDER F
                                            ON E.PWORKORDERNO = F.BILLNO
                                         WHERE A.PARENTBILLNO IS NULL AND C.BILLNO = {0} ", LibStringBuilder.GetQuotString(fromSaleBillNo));
            LibDataAccess dataAccess = new LibDataAccess();
            StringBuilder builder    = new StringBuilder();
            Int32         index      = 1;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    string        workOrderNo   = LibSysUtils.ToString(reader["BILLNO"]);
                    HYProduceData hyProduceData = LibHYProduceCache.Default.GetProduceData(workOrderNo);
                    DataTable     dt            = hyProduceData.TenWorkRecord.Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string saleBillNo = LibSysUtils.ToString(dt.Rows[i]["FROMSALEBILLNO"]);
                        if (saleBillNo == fromSaleBillNo)
                        {
                            dt.Rows[i].Delete();
                        }
                    }
                    dt.AcceptChanges();
                    if (index == 1)
                    {
                        builder.AppendFormat(" AND (WORKORDERNO = {0}", LibStringBuilder.GetQuotObject(reader["BILLNO"]));
                    }
                    else
                    {
                        builder.AppendFormat(" OR WORKORDERNO = {0}", LibStringBuilder.GetQuotObject(reader["BILLNO"]));
                    }
                    index++;
                }
            }
            if (builder.Length > 0)
            {
                builder.Append(")");
                sql = string.Format(@"DELETE FROM PPTENWORKRECORD WHERE 1=1 {0} AND FROMSALEBILLNO = '{1}'", builder.ToString(), fromSaleBillNo);
                LibDBTransaction trans = dataAccess.BeginTransaction();
                try
                {
                    int result = dataAccess.ExecuteNonQuery(sql);
                    trans.Commit();
                }
                catch (Exception)
                {
                    trans.Rollback();
                }
            }
        }