Ejemplo n.º 1
0
 public async Task <int> Install(Input input)
 {
     try
     {
         if (Models.Login.checklog() == 0)
         {
             return(-10);
         }
         else
         {
             Account       act = Login.Get_user();
             ContainerType ct  = input.ct;
             ct.resort();
             CargoNum[] cn   = input.cn;
             string     name = input.name;
             for (int i = 0; i < cn.Length; i++)
             {
                 cn[i].calArea();
             }
             string strSql;
             strSql = "select COUNT(*) from TempProgram where userID=" + act.ID;
             int num = int.Parse(SqlHelper.ExecuteScalar(DBconnect.get(), CommandType.Text, strSql).ToString());
             if (num == 3)
             {
                 return(-1);
             }
             strSql = "insert into TempProgram(userID,status,OAtype,programName) values(" + act.ID.ToString() + ",0," + input.type.ToString() + ",'" + name + "')";
             DBconnect.noQueryDB(strSql);
             strSql = "select ident_current('TempProgram')";
             int p_ID = Decimal.ToInt32(((Decimal)SqlHelper.ExecuteScalar(DBconnect.get(), CommandType.Text, strSql)));
             Task.Run(() => calProgram(ct, cn, input.type, p_ID));
             //Task.Factory.StartNew(() => calProgram(ct, cn, input.type, p_ID), TaskCreationOptions.LongRunning);
             return(p_ID);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }