Ejemplo n.º 1
0
        public string updateDbWithoutSend2(updateOAStorageData data, string filename)
        {
            List <updateOAStorageData> list = new List <updateOAStorageData>();

            list.Add(data);
            return(updateDB(list, filename, ""));
        }
Ejemplo n.º 2
0
        private string createFile(string tempDir, string vartOrdernr)
        {
            string error    = "";
            string fileName = "";
            List <updateOAStorageData> updateList = new List <updateOAStorageData>();

            try
            {
                if (!tempDir.EndsWith("/"))
                {
                    tempDir += "/";
                }
                fileName = getFileName(vartOrdernr);
                tempDir += fileName;
                tempDir  = HttpContext.Current.Server.MapPath(tempDir);
                XmlSerializer serializer =
                    new XmlSerializer(typeof(CCompStoreData.TRANSACTION));

                var        appendMode            = false;
                Encoding   encoding              = Encoding.GetEncoding("ISO-8859-1");
                TextWriter writer                = new StreamWriter(tempDir, appendMode, encoding);
                CCompStoreData.TRANSACTION trans = new CCompStoreData.TRANSACTION();

                trans.Company = 1;
                string s = System.DateTime.Today.ToString().Replace("-", "");
                trans.Date = System.DateTime.Today.ToString("yyMMdd");
                trans.Time = System.DateTime.Now.ToString();


                DataTable dt = getOrderArtRows(vartOrdernr, ref error);


                if (error != "")
                {
                    return(error);
                }
                List <CCompStoreData.TRANSACTIONORDERLINE> transLines = new List <CCompStoreData.TRANSACTIONORDERLINE>();



                foreach (DataRow dr in dt.Rows)
                {
                    Decimal stockToSend = 0;
                    string  errTxt      = "";
                    try
                    {
                        errTxt      = "";
                        stockToSend = Convert.ToDecimal(dr["sum_antal"]) - Convert.ToDecimal(dr["oa_sum"]);
                        if (stockToSend > -0.001M && stockToSend < 0.001M)
                        {
                            continue;
                        }
                        CCompStoreData.TRANSACTIONORDERLINE transOrder = new CCompStoreData.TRANSACTIONORDERLINE();
                        int AssignmentTypeId = 2;
                        if (stockToSend < 0)
                        {
                            AssignmentTypeId = 1;
                        }
                        transOrder.AssignmentTypeId = Convert.ToSByte(AssignmentTypeId);
                        transOrder.ItemDescription  = dr["artnamn"].ToString();
                        transOrder.ItemNo           = dr["artikelkod"].ToString();
                        transOrder.OrderlineNo      = getNextRowNo().ToString();
                        transOrder.OrderNo          = vartOrdernr;
                        transOrder.ReqQuantity      = calculateQuantity(stockToSend);
                        transOrder.Status           = 0;


                        transLines.Add(transOrder);
                    }
                    catch (Exception ex)
                    {
                        errTxt = ex.Message;
                    }
                    updateOAStorageData us           = new updateOAStorageData();
                    Decimal             stockToSend2 = errTxt == "" ? stockToSend : 0;
                    us.orderArtId  = Convert.ToInt32(dr["orderArtId"]);
                    us.stockToSend = stockToSend2;
                    us.error       = errTxt;
                    updateList.Add(us);
                }
                trans.ORDERLINES = transLines;
                serializer.Serialize(writer, trans);
                writer.Close();
                error = copyToCSshare(tempDir, fileName);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            if (error == "")
            {
                error = updateDB(updateList, fileName, error);
            }
            return(error);
        }